Associative Iteration - Shaping Ancient Mathematical Knowledge Into Powerful Bit-fiddling Techniques

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ม.ค. 2025

ความคิดเห็น • 29

  • @adampond6099
    @adampond6099 หลายเดือนก่อน +13

    I was expecting you to explain how Tutankhamen would debug my binary tree.

  • @dextercd_
    @dextercd_ 5 วันที่ผ่านมา +1

    Multiplying by shifting the bits in the opposite direction is also explored in Programming the Z80 3rd ed. on page 128.

  • @Roibarkan
    @Roibarkan 3 วันที่ผ่านมา

    13:31 This slide shows that another drawback of the “regressive” way is not only its higher iteration count, but also that every iteration has one extra invocation of “operation”. Great talk, I’m sure a generic approach that chooses regressive vs. ‘forward’ via some heuristic or caller-choice can be devised.

  • @rompa6972
    @rompa6972 4 วันที่ผ่านมา +2

    Not trying to throw shade, but what is old is new again? 8-bit coders and game devs have been using techniques like this since the early 80s (or perhaps earlier) like multiplication on 6502 which only supports addition and shifting by 1 bit. So much 8-bit coding knowledge has been lost to time, it seems.
    Interesting extension to using generic monoids though, and it was very nice to see in a more formal light and nicely presented, thank you.

  • @lombeelo8780
    @lombeelo8780 5 วันที่ผ่านมา

    In university, we are being taught 4 multiplication algorithms:
    1. Multiplication from the least significant bits of the multiplier and shifting the multiplicand to the left
    2. Multiplication from the least significant bits of the multiplier and shifting the sum of partial products to the right
    3. Multiplication from the highest significant bits of the multiplier and shifting the multiplicand to the right
    4. Multiplication from the highest significant bits of the multiplier and shifting the sum of partial products to the left
    Would be nice if the remaining 2 could also be used for abstract operations.

  • @Roibarkan
    @Roibarkan 3 วันที่ผ่านมา

    15:06 Naming is hard. I think I would rename the IterationCount type to ‘StepOperand’ and ‘CountHalver’ to ‘StepIncrement’. I would then allow the forSquaring parameter to have a different type (maybe SquareStepOperand, default to StepOperand) to allow the Operator to be overaloaded for 2 types of operands similar to the (iterator vs. sentinel approach done for ranges).
    Great talk!

  • @Roibarkan
    @Roibarkan 3 วันที่ผ่านมา

    34:31 well, division isn’t associative. There is the ‘long division’ algorithm which perhaps can be implemented using the suggested approach- but if so it might teach us more about the domain for which this technique applies

  • @Roibarkan
    @Roibarkan 3 วันที่ผ่านมา

    16:15 I think this slide has a typo, seems to imply that the function is recursive. I assume the name of the function presented at the second line of code should actually be something like template_regressive_egyptian_exponentiate

  • @hemangandhi4596
    @hemangandhi4596 วันที่ผ่านมา

    At 34:20, they talk about division and subtraction, but those aren't associative, right? (a - (b - c)) = (a - b) + c != ((a - b) -c)

  • @japedr
    @japedr 5 วันที่ผ่านมา

    Nice talk!
    The "forward" algorithm is usually called "exponentiation by squaring", AFAIK, not sure if that can help you naming your invention.
    My favorite toy application for this is the computation of the nth Fibonacci number using matrix exponentiation (actually, that can be generalized to any linear recurrence relation).

  • @Roibarkan
    @Roibarkan 3 วันที่ผ่านมา

    20:32 Note the use of ‘horizontalEq(sum, c)’ and not simply ‘sum == c’. There was a lot of discussion in the C++ committee about the semantics of operator== for std::simd - so it’s smart of Jamie to steer away from it.

  • @dennisestenson7820
    @dennisestenson7820 5 วันที่ผ่านมา

    Please post these videos at 720@30fps so I can read the text on the slides without frame drops.

  • @JohnB5290
    @JohnB5290 4 วันที่ผ่านมา

    Starting with the most significant bit is the so-called Horner's scheme.

  • @JohnDlugosz
    @JohnDlugosz 5 วันที่ผ่านมา +1

    Population count only needs log base 2 of the word size, not a linear scanning of all n bit positions.
    Another example of a monoid not on your platform might be to build a *string* of x copies of an original, faster than the naive loop through x times.

  • @Cheerleader11223344
    @Cheerleader11223344 หลายเดือนก่อน +1

    This is so interesting! Great presentation!

  • @Sarah1Smith-v4r
    @Sarah1Smith-v4r หลายเดือนก่อน +2

    Thank you, this is insightful, well done.

    • @jamiepond
      @jamiepond หลายเดือนก่อน

      @@Sarah1Smith-v4r thanks!

  • @JeremyKlein
    @JeremyKlein หลายเดือนก่อน +1

    Such a cool perspective! Thanks for the presentation

    • @jamiepond
      @jamiepond หลายเดือนก่อน

      Thanks dude!! Glad you enjoyed!

  • @jamiepond
    @jamiepond หลายเดือนก่อน +4

    hey that guy looks familiar

  • @Andmoon391
    @Andmoon391 หลายเดือนก่อน +1

    Thank you!

    • @jamiepond
      @jamiepond หลายเดือนก่อน

      Thank you!

  • @craftycactus7735
    @craftycactus7735 5 วันที่ผ่านมา

    How does this relate to fastpow?

  • @jessicareboul124
    @jessicareboul124 หลายเดือนก่อน +1

    Super interesting:)

    • @jamiepond
      @jamiepond หลายเดือนก่อน

      Cheers!

  • @EalesOnWheels
    @EalesOnWheels หลายเดือนก่อน +1

    Jamie is so cool!

    • @jamiepond
      @jamiepond หลายเดือนก่อน

      Damn right.

  • @knayamwashere
    @knayamwashere หลายเดือนก่อน +1

    This is amazing 👏

  • @JohnDlugosz
    @JohnDlugosz 5 วันที่ผ่านมา

    The book you're talking about is very good -- I got it when it came out and also spent some time working through it.
    The "regressive" algorithm you describe isn't always an inefficient round-about method -- I first learned about it (and really understood it when I figured it out for myself) in the '80's, where 8-bit computers *did not have* multiplication and division as hardware primitives. More recently, even higher levels of SSE didn't have integer division!
    To really speed it up, you have to get rid of the `if` test for the least bit. When called for arbitrary numbers, this will essentially be random, and performance suffers do to impossible branch prediction. You need to always calculate the update in a separate variable, and then (only) conditionally replace the accumulated value -- the compiler should generate a CMOV for that on X86/X64.