Jump to content

Sensei

Senior Members
  • Posts

    7722
  • Joined

  • Last visited

  • Days Won

    26

Posts posted by Sensei

  1. "Is there some law of computation which states that `if` statements are unavoidable?"

    Why not try answering it?

    try and come up with a program that can't be replaced by a huge look-up table.

     

    If() is used to exit loop abnormally f.e.

     

    for( ; ; )

    {

    [...]

    if( [condition] ) break;

    [...]

    }

     

    If() is used to end loop cycle f.e.

     

    for( i = 0; i < 100; i++ )

    {

    [...]

    if( [condition] ) continue;

    [...]

    }

  2.  

    Since OP stands to Original Post, anything that was stated in any subsequent post hasn't got anything to do with it.

    Post #5 isn't post #1

     

    Again, wrong. OP means Original Poster in the first place.

    http://acronyms.thefreedictionary.com/OP

    In this context = author of this thread. So all of his replies are equally valid, to understand his intentions.

     

    Yet another websites will explain you what OP means:

    http://www.urbandictionary.com/define.php?term=op

     

    http://www.webopedia.com/TERM/O/op_original_poster.html

  3. There is a deeper question, does an OR gate or AND gate count as a conditional branch?

    I'd say no, because there's no clear branching

    Wrong.

     

    BEQ for instance is Branch if EQual. When Z flag status register is set to 1, there is jump, otherwise no jump. That's what programmer see from outside.

    But it's doing AND operation between Z flag status register and parameter (relative offset).

    Then result of this AND operation is added to PC (Program Counter) register. Simple math operation on one of CPU registers!

     

    So actually BEQ instruction is equivalent to:

    PC += relative offset & Z flag; // (extend in mind single Z bit to whole word/long word)

     

    Z flag is 0 -> to PC there will be added 0, and nothing will happen. Because it was cleared by AND operation.

    Z flag is 1 -> to PC there will be added relative offset.

     

    In BNE (Branch if Not Equal), Z flag will be passed through NOT gate, prior AND (or simply NAND).

    PC += relative offset & ~Z flag;

    And that's it. Bitwise AND operation, then adding operation, one by one..

     

    Do you want me to also explain you how ADD operation looks like from point of view of logic gates?

    The OP didn't ask about speed or efficiency, but it did accept that this uses a lot of memory.

    So any discussion on those points is pretty well beside the point.

     

    Have you bother reading thread you're replying? In post #5 he clearly thinks his solution is speeding up program..

  4. Hydrogen H2 requires first to split to two separate H, it's taking approximately 4.52 eV to do so.

    Then each H requires 13.6 eV to ionize.

    So overall you have to spend 4.52 eV + 2*13.6 eV = 31.72 eV per H2 molecule.

     

    At the same time Helium needs 24.58 eV to ionize to He1+

    Argon needs 15.76 eV to ionize to Ar1+

    Xenon needs 12.13 eV to ionize to Xe1+

     

    Decrease pressure of gases in tube. It should help.

     

    Be careful with Hydrogen.

    One my tube with Hydrogen that I have made exploded after 3rd ignition by 40+ kV Cockcroft-Walton generator.

    It was not hermetic and little Oxygen from air get to inside. Good that it didn't destroy anything in room (50 centimeters from LED monitors).

     

    Search eBay for "discharge tube". There is plenty of them.

    f.e.

    http://www.ebay.com/itm/Spectrum-Analysis-Gas-Spectrum-Tube-set-of-6-Discharge-Tubes-Xenon-Krypton-etc-/301365429384?pt=LH_DefaultDomain_0&hash=item462ac78488

    6 tubes with different gases inside, for 80 usd is pretty good price.

  5. One of the recent visitors to my profile was a user called "YOUTUBE HITLER WMAP".

     

    My too.

    Sounds like bot which is searching for e-mails in content.

    "YOUTUBE HITLER WMAP

    21 Oct 2014 - 16:34"

    It is nice to get rep points, and I find myself checking if I have any more. I don't know why, I think I am not that bothered, but my subconscious may think differently.

     

    If I can make you happy, so be it.. :)

    Perhaps some people who post on here, are more interested in getting "rep" points, than being really interested in Science?

     

    So they are not openly saying what they're really thinking, right? Afraid of getting negatives..

     

    I wish Swansont came with some speculative idea or theory, to discuss, some day..

  6. Hello!

     

    In other thread author suggested using jump-table with sub-routines as a method of optimizing complex if() { } else if() { } statement.

     

    I have other, alternative suggestion. Hand-made binary-tree for complex if() statement..

     

    Suppose so we have following code:

     

    if( state == 0 )

    {

    }

    else if( state == 1 )

    {

    }

    else if( state == 2 )

    {

    }

     

    else if( state == 3 )
    {
    }
    else if( state == 4 )
    {
    }
    else if( state == 5 )
    {
    }
    else if( state == 6 )
    {
    }
    else if( state == 7 )
    {
    }
    else if( state == 8 )
    {
    }
    else if( state == 9 )
    {
    }
    else if( state == 10 )
    {
    }
    else if( state == 11 )
    {
    }
    else if( state == 12 )
    {
    }
    else if( state == 13 )
    {
    }

     

    else if( state == 14 )

    {

    [... code executed for 14...]

    }

    else if( state == 15 )

    {

    [... code executed for 15...]

    }

     

    In the best case, it'll find appropriate code after 1 comparison, in the worst scenario it'll have to compare all 16 cases.

     

    Such code we can rearrange to:

     

    if( state >= 8 ) // 50% of cases

    {

    if( state >= 12 ) // 25% of cases

    {

    if( state >= 14 ) // 12.5% of cases

    {

    if( state == 15 ) // 6.25% of cases

    {

    [... code executed for 15...]

    }

    else

    {

    [... code executed for 14...]

    }

    }

    else // states 12-13

    {

    [...]

    }

    }

    else // states between 8 and 11

    {

    [...]

    }

    }

    else // states smaller than 8

    {

    [...]

    }

     

    Now any case is found after just 4 executions of if(). max.400% speedup.

    [math]\log_2(16)=4[/math]

     

    If we would have 256 cases in normal if() else if(),

    this method would reduce them to just 8 executions of if(). max.3200% speedup.

    [math]\log_2(256)=8[/math]

     

    Using it has sense when cases have approximately the same probability of being executed.

     

    It shouldn't be hard to make program generating such code with empty {} to fill them, taking as argument quantity of cases..

     

    Best Regards!

  7. I understand also that matter is energy itself, so does the acceleration of the charge convert the mass of the charge into radiation (that is how I will use the world emission for this context) or is it simply the oscillation of the charge that produces radiation waves?

     

    There is no such thing as "mass of the charge".

    There is however "mass of particle", and "charge of particle".

    Mass is independent property, charge is independent property.

  8. Then why did you bring it up? I was simply correcting your misinformation.

    You misunderstood.

    I gave writing EMULATOR of CPU as example of where jumping-table can be useful (instead of handling banking account).

     

    You either need to try writing an emulator OR learn how to do it better.

    Using JIT would be even worser off topic. JIT is not portable. So it's better to have first make interpreter code. And then add JIT for specific target CPU. And user will pick up whether he wants JIT or normal emulation in options.

     

    Is it? Did the OP ask about performance?

    Post #5.

  9. Many 16 and 32 bit microprocessors use a microcoded instruction set where there is typically a jump table to go from opcode to microcode entry point.

    Now you're talking about CPUs internals implemented in transistors. Even more nothing to do with programming side of them..

     

    (And, of course, a 16 bit processor doesn't have 64K instructions.)

    Of course 8 bit CPU have 8 bit wide instructions. 1 byte per instruction (plus additional optional 1-2 bytes parameters). Take f.e. Motorola 6502,6510 as example.

    Of course 16 bit CPU can have 16 bit wide instruction. 2 bytes per instruction (plus additional optional 2,4,6,8 bytes parameters). Take f.e. Motorola 680x0 as example. Each instruction has at least 2 bytes. It doesn't mean there is 64 k instructions. But emulator has to read whole word and use as index to jump-table. Some fields will be causing exception.

    If 16 bit CPU would have 8 bit wide instruction-1 byte, it would be often reading from not word aligned address! Which would cause problem with CPU cache, if one half of instruction is in cache, and other byte outside in physical memory.

     

    Intel is different as its instruction set grew up with time?

     

    See

    http://www.eventhelix.com/realtimemantra/ByteAlignmentAndOrdering.htm#.VE4UWle198E

    "Most 16-bit and 32-bit processors do not allow words and long words to be stored at any offset. For example, the Motorola 68000 does not allow a 16 bit word to be stored at an odd address. Attempting to write a 16 bit number at an odd address results in an exception."

     

    Which is utterly irrelevant. It doesn't matter how it is implemented.

    Nonsense. Purpose is to have faster working program. Why to bother so much to have slower working code?

    Jumping to sub-routine is time expensive!

     

    I have programmed dozens of different processors. I can only think of one that didn't support subroutine calls. However, there were several that support conditional subroutine calls. But you can still implement any of these techniques on any of them.

    Add to list cheap GPUs..

     

    What! :eek: What on earth do GPUs have to do with it? The question was about programming models and computability.

     

    I think you should stop digging that hole.

    Are you up to date with modern GPUs?

    You can program pixel and vertex shaders.

    They're programs, developed by programmers, compiled for their GPUs..

    Executed by GPUs at demand of programmer.

  10. In some circumstances - for example when the problem is specified as a table of inputs and outcomes, it's easier and clearer to code the problem as a look-up table rather than a set of conditions.

    But there must be very few conditions and/or functions must be repeatable and table filled automatically at initialization.

    In presented by OP example there is needed 40 thousands unique sub-routines! With bank accounts up to 1 mln, 10^12 entries.

     

    Example place where there could be used jump-table is interpreter of language with up to 8 bit commands, emulator of 8 bit cpu.

    They would have array of size 256 entries to sub-routines called to process single instruction.

    For 16 bit wide instructions it would stop making sense (65536 entries), and for 32 bit wide instructions (4 bln) even not possible. Out of memory for table (16 GB on 32 bit machine, and 32 GB on 64 bit machine).

     

    However the question wasn't asked as a day to day issue, but as a matter of principle and, the answer is that you can do without if statements.

    Reminds me what Maria Antonia said...

     

    And showing that the If function is implemented at a machine code level is not that same as showing that it is needed.

     

    I showed it's implemented by the most basic CPUs.

    JSR/BSR - Jump Sub-Routine - can be not implemented.

    Early graphics card GPUs often didn't have it. And they couldn't have recursion, nor didn't have cpu stack.

    However even the simplest CPUs/GPUs have conditional jumps Bxx (xx - condition).

     

    Conditional/absolute branch instruction in CPU are superior to jumping to sub-routine.

     

    Every action must have purpose, sense. OP said "Is memory more important than execution time?" But his code won't be faster, it will be actually slower, than code with if()..

    That's why I told him to benchmark both codes, to compare and see it on eyes.

  11. I thought it was a very intelligent question. Working out that you can code a jump table like that, instead of using explicit conditional code, is pretty smart.

    Are you programming on daily basis? I don't think so, if you're considering jump-table as viable alternative option for if() for presented case..

    Below code is simply jumping to sub-routine! While if() is jumping to relative address omitting what if contains in { }.

     

    200 states * 200 deposit amount = 40000 sub-routines needed.

    For 1 mln states and 1 mln deposits = 10^12 sub-routines needed.

     

    Jump to subroutine is *slow*. Requires putting all registers on stack. Return address is put on stack. Then subroutine also does initializations at beginning and cleaning up on ending. Then stored registers are restored from CPU stack.

    It's much more expensive than simple comparison of values..

     

    The rest of your answer appears to be irrelevant to the question asked. (It wasn't me who gave you a negative vote ... but it was tempting!)

    It's very relevant. I'm showing that if() handling is at CPU machine code level implemented..

     

    Is memory more important than execution time?

    You should make example code and run it f.e. 1 mln/bln execution times and compare times, to check your statement whether it's faster or slower..

     

    Typically we can do it by f.e.:

     

    clock_t t0 = clock();

     

    [..code...]

     

    clock_t t = clock() - t0;

    printf( "Clock %d seconds\n", t / CLOCKS_PER_SEC );

     

    or use time() instead of clock()

  12. You must have a lot of free time, to waste it asking such questions..

     

    In Motorola assembler we had:

     

    BRA - branch (jump) to relative address, without checking conditional flags

    BEQ - branch if equal

    BNE - branch if not equal

    BPL - branch if plus

    BMI - branch if minus

     

    In your case:

     

    if( balance >= n )

     

    CPU has to subtract in memory (not stored result, just flags changed) balance = balance - n

    and set flags

    if flag is negative after subtraction, jump to omit part of code.

    It's built-in very deeply, inside of processor.. Branch and status flags are essential instructions for CPUs. You can have no multiplication function (it's often missing in cheap 8 bit cpus used in electronics, have to be simulated by hand (shifts and adding)), but must have branches/flags.

     

     

    Some if() could be avoided and changed to single line f.e.

     

    if( x > y ) x = y;

     

    could be replaced by:

     

    x = ( x > y ) ? y : x;

     

    or

     

    x = min( x, y );

  13. If your referring to Olbers paradox (which you probably are) the universe is

    not flooded with light from the stars as both the steady state model and the inflation models are expanding. The steady state universe is an expanding universe.

     

    I don't think so expansion is required to solve Olbers' paradox.

     

    First of all we have large distances between stars (we can hypothesize that neutral gases were created where they're now)

    Photons illuminating surface obey inverse-square law, so the larger distance, the smaller quantity of photons per area unit arriving.

     

    [math]P=\frac{P_0}{4 \pi r^2}[/math]

     

    Now repeat it for the all stars in the galaxy and universe, and sum powers together.

     

    [math]\sum_{i=0}^{i<j}\frac{P_0(i)}{4 \pi r(i)^2}[/math]

     

    The one that has the smallest distance (our Sun in our current location), has the largest influence on result from this equation.

    Which is 3.661*10^21 photons with average 532 nm per second per m^2 of Earth at noon.

    960000 light years from the Sun it'll be average 1 photon per m^2 per second.

    (Notice that this easy equation also gives maximum limit of stars emitting light in radius of 1 mln ly from us.

    If there would be 3.661*10^21 stars (with power equivalent to the Sun) at distance 1 mln ly from us, they would sum to the current max power of the Sun, and we would have day all day long)

     

    Secondly, stars don't exist forever. They're forming, living and dying, typically running out of fuel to fuse further (so I should rather say "not emitting light anymore", than dying)

    Something that Olbers didn't realize.

     

    Thirdly, stars don't exist at the same time. Only fraction of gas existing in the Universe is emitting photons from fusion. It must collapse enough to form new star.

     

    We can hypothesize that free protons and free electrons (violating current conservation theories obviously, which also does BB) are appearing from nowhere everywhere in space between existing galaxies.

    Before they would become new star it would take billions of years in the meantime. Before that we wouldn't even know about their existence.

    Star equivalent to the Sun would need 5.761*10^56 Hydrogen and 4.907*10^55 Helium-4 at the beginning.

    If rate of production would be 1 bln per second, it would take 1.82*10^31 billion years to make such amount of "fresh neutral Hydrogen gas".

  14. Vacuum vessels are common, but not of this size... 110-140m long and I suppose 4m diameter. Wiki tells it's separated from the surrounding tower to decouple the wind force, and made of steel.

    The easiest solutions are usually the best one - why not put drop tube in old unused mine, or oil drill. They can be even a few kilometers long, but below ground. You don't have to worry at least about wind force.

     

    Standard satellite integration must be helpful to cool electronic components in vacuum and hold the circuits when braking:

    To cool down electronics, I would try surrounding them by some heat conductive (but electric not conductive) liquid.

  15. I work for a company that supplies Nitrogen to vendors. I've had to learn a lot about Nitrogen vs. Oxygen because of this. We also supply reimbursement for tire damage for some of our dealers as well. This year I've had a few people tell me that they experienced a blow out shortly after (about a week or two) after having a deflating tire topped off with oxygen. We receive a lot of claims, so I can only imagine the ones I didn't talk to personally. Is there something about potential damage to a tire and adding oxygen to nitrogen that makes this a volatile environment that would cause a blow-out? If so, can you explain? If not, is there something else that could explain this phenomenon?

     

    Nitrogen alone is non reactive.

    while Oxygen is very reactive.

     

    Especially if you increase temperature (which is obviously happening inside of tire, because of braking, friction with road).

    Asphalt road temperatures can be quite high also, especially in hot regions of Earth.

     

    If you will leave f.e. Iron (or other metal) inside of chamber with N2 gas, after months or years nothing will happen to metal (most likely).

    Oxygen sooner or later will create iron/metal oxides.

    If you will pass current through iron wire inside of chamber with pure oxygen reaction will be immediate.

     

    Remember also that in tire you have gas under high pressure.

     

    Make a map where are living people that had problems. Ask them about environment temperature. Try finding "common denominator" for them.

     

    Here is article (use translator) about whether it's worth to fill tires by nitrogen or air:

    http://www.motofakty.pl/artykul/czy-warto-pompowac-opony-azotem.html

     

    (Google translator)

    "Nitrogen is an odorless, colorless, tasteless, non-flammable, free from moisture, chemically little active. In connection with its specific chemical properties at the beginning of the sixties of the last century, scientists from the laboratories of tire manufacturers have explored how it behaves inflated tire. Tests have proved that a tire filled with just this component of the air is gaining a lot longer for life. That is why since the decade began to use the technique of nitrogen tire inflation. The pioneers were the vehicles used in mining, aerospace, transportation of dangerous goods (such as. Flammable), and thus heavy vehicles. Nitrogen has long been filled tires wheels in Formula 1 cars which, because of the enormous speed are exposed, inter alia, to launch and fire. Pumping nitrogen is recommended primarily owners of car fleets, it helps significantly reduce operating costs."

     

    Azot jest gazem bezwonnym, bezbarwnym, bez smaku, niepalnym, wolnym od wilgoci, mało aktywnym chemicznie. W związku ze swymi specyficznymi właściwościami chemicznymi już na początku lat sześćdziesiątych ubiegłego wieku naukowcy z laboratoriów producentów ogumienia sprawdzali, jak zachowuje się napompowana nim opona. Próby dowiodły, że opona wypełniona jedynie tym składnikiem powietrza zyskuje o wiele dłużej na żywotności. Dlatego właśnie już od tej dekady zaczęto stosować technikę pompowania kół azotem. Pionierami były pojazdy wykorzystywane w przemyśle wydobywczym, lotniczym, transporcie towarów niebezpiecznych (np. łatwopalnych), a więc pojazdy ciężkie. Azot od dawna wypełnia opony kół w autach Formuły 1, które z powodu ogromnych prędkości narażone są m.in. na wystrzelenie i pożar. Pompowanie azotem polecane jest przede wszystkim właścicielom flot samochodowych, gdyż pomaga w istotny sposób obniżać koszty eksploatacji.
    Azot jest gazem bezwonnym, bezbarwnym, bez smaku, niepalnym, wolnym od wilgoci, mało aktywnym chemicznie. W związku ze swymi specyficznymi właściwościami chemicznymi już na początku lat sześćdziesiątych ubiegłego wieku naukowcy z laboratoriów producentów ogumienia sprawdzali, jak zachowuje się napompowana nim opona. Próby dowiodły, że opona wypełniona jedynie tym składnikiem powietrza zyskuje o wiele dłużej na żywotności. Dlatego właśnie już od tej dekady zaczęto stosować technikę pompowania kół azotem. Pionierami były pojazdy wykorzystywane w przemyśle wydobywczym, lotniczym, transporcie towarów niebezpiecznych (np. łatwopalnych), a więc pojazdy ciężkie. Azot od dawna wypełnia opony kół w autach Formuły 1, które z powodu ogromnych prędkości narażone są m.in. na wystrzelenie i pożar. Pompowanie azotem polecane jest przede wszystkim właścicielom flot samochodowych, gdyż pomaga w istotny sposób obniżać koszty eksploatacji.

    Azot jest gazem bezwonnym, bezbarwnym, bez smaku, niepalnym, wolnym od wilgoci, mało aktywnym chemicznie. W związku ze swymi specyficznymi właściwościami chemicznymi już na początku lat sześćdziesiątych ubiegłego wieku naukowcy z laboratoriów producentów ogumienia sprawdzali, jak zachowuje się napompowana nim opona. Próby dowiodły, że opona wypełniona jedynie tym składnikiem powietrza zyskuje o wiele dłużej na żywotności. Dlatego właśnie już od tej dekady zaczęto stosować technikę pompowania kół azotem. Pionierami były pojazdy wykorzystywane w przemyśle wydobywczym, lotniczym, transporcie towarów niebezpiecznych (np. łatwopalnych), a więc pojazdy ciężkie. Azot od dawna wypełnia opony kół w autach Formuły 1, które z powodu ogromnych prędkości narażone są m.in. na wystrzelenie i pożar. Pompowanie azotem polecane jest przede wszystkim właścicielom flot samochodowych, gdyż pomaga w istotny sposób obniżać koszty eksploatacji.
    Azot jest gazem bezwonnym, bezbarwnym, bez smaku, niepalnym, wolnym od wilgoci, mało aktywnym chemicznie. W związku ze swymi specyficznymi właściwościami chemicznymi już na początku lat sześćdziesiątych ubiegłego wieku naukowcy z laboratoriów producentów ogumienia sprawdzali, jak zachowuje się napompowana nim opona. Próby dowiodły, że opona wypełniona jedynie tym składnikiem powietrza zyskuje o wiele dłużej na żywotności. Dlatego właśnie już od tej dekady zaczęto stosować technikę pompowania kół azotem. Pionierami były pojazdy wykorzystywane w przemyśle wydobywczym, lotniczym, transporcie towarów niebezpiecznych (np. łatwopalnych), a więc pojazdy ciężkie. Azot od dawna wypełnia opony kół w autach Formuły 1, które z powodu ogromnych prędkości narażone są m.in. na wystrzelenie i pożar. Pompowanie azotem polecane jest przede wszystkim właścicielom flot samochodowych, gdyż pomaga w istotny sposób obniżać koszty eksploatacji.

    Notice sentence

    "Pumping nitrogen is dedicated especially to owners of cars equipped with steel wheels."

     

    (iron in steel can react with oxygen).

  16. Earlier in the thread I saw comments made that after 2,000yrs anyone could be said not to have lived. That plus the argument that Jesus' having been real is the best explanation for Christianity feels empty. Julius Caesar lived over 2,000yrs ago and there is an enormous amount of evidence of his life. Much was written about him and art work created contemporarily to his life. Not only in Roman but all the areas he traveled and impacted like Egypt. Ceasar himself wrote things and fragments of those writings exist. No magical claims to dig though searching for cross references. Tons of contemporary work. Everything from portraits, cions that bore his face, to works made from his own hands.

    one might argue that Caesar can not be compared to Jesus because Caesar was so powerful and influential; what was Jesus? Jesus had he lived was influential enough to convince people he was GOD and start a religion that has gone on to dominate the globe. Billions pray to Jesus today, not Caesar. Yet Caesar has for more documented? Caesar was obviously more important to his contemporaries?

     

    Hundred millions people prayed to Caesar-god after his death for a few hundred years.

    He has been deified at 42 BC (in the middle of article) by his grant-nephew Octavian August.

    http://en.wikipedia.org/wiki/Julius_Caesar

     

    Cult of Caesar

    http://en.wikipedia.org/wiki/Imperial_cult_%28ancient_Rome%29#Divus_Julius

     

    If there would be no delegalization of ancient religions in Roman Empire, his cult could be continued.

  17. This might be a little bit off topic, but I remember back in college we had a lot of different colored wooden spheres that had different amount of holes in them that would represent different elements. I remember black was carbon, white was oxygen, etc. And you could connect them with either wooden sticks or springs, which we used in a lot of our chemistry classes. I cannot remember what they are called. If someone knows what they are called, or even better has a link to where I can read up on them/buy them, I would be really grateful.

     

    c027.jpg

    This 245 balls with 310 connectors set costs $140

    http://www.eduvis.pl/oferta/chemia-pomoce-dydaktyczne/chemiczny-zestaw-nr-27-modele-kulkowe-detail

     

    Google for "ball and stick model"

    http://en.wikipedia.org/wiki/Ball-and-stick_model

    or "molymod"

    http://www.molymod.com

     

    ps. Stop bringing up ancient threads to top.. It's unwelcome behaving on the all forums..

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.