log☇︎
158400+ entries in 0.101s
mircea_popescu: 2. a fine example of how "i work for the web man" rots the brain, is that in an implementation of the above discussed mod-distributiver, the "common" consensus impulse would be to add a test, make sure the list elements respect the condition of <modulus. this however is very much the wrong thing ; and it is a tmsr-graduate level question to explain why and wherefore. ☟︎
mircea_popescu: 1. if you actually want metal kbd, your choice of steel is probably ill advised. i'd try silver instead. heuristicallyt there's a reason gunsmiths and silversmiths were ~the same people i nthe early modern period ; moreover silver has better properties in the range sough. ☟︎
mircea_popescu: anyway, three points since i got a blowjob and apparently this inspires me.
phf goes to sleep instead
phf: http://btcbase.org/log/2017-09-12#1712367 << i've went through many layout modifications, but i finally settled on just having () and [] switched around. it's convenient both for prose and lisp (not so much heathen languages though) ☝︎
phf: http://btcbase.org/log/2017-09-12#1712362 << i actually use this one pretty frequently when i type for identifiers, abbreviations and section headers in notes. really any time i need to type more than 2 capitalized letters in a row.. ☝︎
asciilifeform: it requires a constant-time gcd, however, to be constant-time. ( and has a problem same as above in that it takes much MORE time than naive algo if you don't reuse modulus forever )
asciilifeform: incidentally there are other algos where you pre-bake a thing for a given modulus and save some cycles. montgomery's, for example.
mircea_popescu: asciilifeform im pretty sure i read the whole knuth as a teen, so it's likely just memory at work.
asciilifeform: it is ~greater~ number of cycles, by far, if you count the 'tooling' cost of preparing the table for each new modulus.
mircea_popescu: but that inconvenience is not the same as the "Same number of cycles" claim.
asciilifeform: but actually congrats to mircea_popescu for reinventing 2 separate knuth algos.
asciilifeform: it is ok for rsa where you sink it to the bottom of the sea and never intend to change the modulus
mircea_popescu: i'll take your word for it if you say so ; i've not looked at them closely in comparison.
asciilifeform: which takes ages
asciilifeform: because we're muxing over the entire list every single time
mircea_popescu: i dunno about that.
mircea_popescu: this holds for arbitrarily large numbers, and i suspect will be faster than classical.
asciilifeform: except it does exactly as many cycles as the classical method.
mircea_popescu: same thing.
mircea_popescu: if you want constant time, you feed the list 9, 0,0,0,0,8,0,0,1. it will do 18, 1, 18, 1, 18, 1, 18, 1 etc.
mircea_popescu: ok. ima just take the 137 tail cuz lazy. 137 is 10001001. we have precalculated that 128 mod 17 is 9, and that 8 mod 17 is 8, and that 1 mod 17 is 1
asciilifeform: i dun get from where you got the 1s
mircea_popescu: precompiled list of all powers of two is then 1.
asciilifeform: let's take the case where modulus is maxint
mircea_popescu: asciilifeform if this is true, then the above method should be way faster.
asciilifeform: ( additions produce B+W-bit ints, and these get out of hand very quickly)
mircea_popescu: i personally like the formalism of it ; but whatevs.
mircea_popescu: well i have nfi, haven't profiled the thing.
mircea_popescu: whether this approach is actually faster than the current mod of 97 as implemented via knuth is open to discussion, i guess.
asciilifeform: i dun see what this gives you tho
mircea_popescu: consider the number 97. is is 1100001. they do mp_mod (2^6, 2^5, 2^0) ; you can do (2^6, 2^5, 0* 2^4, 0* 2^3,0* 2^2,0* 2^1,2^0). the list method will sitll work, but this time in constanttime.
asciilifeform: you do if you want to get anything out of having a table
mircea_popescu: you don';t have to index.
mircea_popescu: it's not automatically bad just for being a list ; you don't have to pare it down.
mircea_popescu: but the important point re that, is that whenever they use a reduced matrix we can STILL use the ufll matrix!
asciilifeform: whole point of ffa, is this notdoing
asciilifeform: mircea_popescu: that's the kochian table approach
mircea_popescu: this may or may not be cheaper ; but in general you would build a list of the pre-calculated mods of all the powers of 2 up to your bitness and save that to save on work.
asciilifeform: except we dun get to use 'where there are 1s'
mircea_popescu: it is also extensible in the sense that if you wish to compute the mod of a 512 bit number, you can cut it up into as many powers of two as there are 1's, feed it into this, and get a modulus.
asciilifeform: modulus bitness == operand bitness. this is ffa after all.
mircea_popescu: asciilifeform well, modulus bitness sum as opposed to N bitness sum. but sure.
asciilifeform: only if we did not then have to sum'em ( the 30 in the example )
mircea_popescu: but the original idea was that it is indeed cheaper to mod the parts than the whole sum.
asciilifeform: the modulus is same bitness as the operands, and is not small.
mircea_popescu: well, i dunno how expensiuve addition is and how much it adds to the mod.
asciilifeform: but aside from this , it isn't clear to me that it saves any cycles
asciilifeform: i'ma need to find a proof that this holds for all integers. ☟︎
mircea_popescu: no need to even define length of list.
mircea_popescu: in any case : you run it until same length list ; smallest int on it will be the correct mod. always terminates, always constat time etc.
asciilifeform: now what happens if the inputs are not coprime ?
mircea_popescu: you feed into my above function the list 6, 9, 15. it adds them : 30. it then writes down 30 -17 ie 13. it then writes down 13 + 17 = 30. it has peroduced a list as long as the original (3 elements), among which the SECOND is the modulus of 1433293 +7926803 +9266137
asciilifeform: ( i thought we were doing a+b )
asciilifeform: last one was supposed to be mod
mircea_popescu: now then : you could do 1433293 +7926803 +9266137 =
mircea_popescu: smallints confuse the issue.
mircea_popescu: tell you what, you shoot three values.
asciilifeform: so as to avoid this.
mircea_popescu: let's take fucking numerical examples already. a = 349087340 ; b = 1209843095 ; c = 753059056. mod = 17. << final!
mircea_popescu: you can ALSO do : 349087340 mod 7 = 0 holy motherfucking crap omfg what is this.
mircea_popescu: cuz first two are 0's.
mircea_popescu: let's take fucking numerical examples already. a = 349087340 ; b = 1209843095 ; c = 753059056. mod = 7.
mircea_popescu: let's take fucking numerical examples already. a = 349087340 ; b = 1209843095 ; c = 753059056. mod = 5.
mircea_popescu: you don't do that.
asciilifeform: if you allow a+b+c addition to take place, you have exactly same proggy i have now.
asciilifeform: karatsuba terms a+b+c ( k. squaring, for simplicity. mult. has four of'em ). we want a+b+c mod m.
mircea_popescu: and what it spits out is the (a+b+c) mod x.
mircea_popescu: not the a itself.
mircea_popescu: what you feed to this algo is the a mod x
asciilifeform: so as not to feed a massive turd into an O(N^3) division algo
asciilifeform: i thought you had algo for not having to add'em
asciilifeform: waitasec didja.... add them?!
mircea_popescu: will necessarily have the modulus of the sum. this entire procedure is constant time.
mircea_popescu: alrigthy, so. you take a list of numbers. you add these numbers. you write the result down. you compare this result with the modulus. if the result is smaller than the modulus, you add the modulus to it and write it underneath ; if larger, you substract the modulus and write it underneath. you repeat this step until you have a list of added/substracted moduli to the result AS LONG as the original list of elements. in it, you
asciilifeform: ( and what part of (a+b) mod m == (a mod m) + (b mod m) is breakable with infinitely many a,b,m values, is hard ? try it yourself )
asciilifeform: ( i promise i have nfi how to do it. just like i don't know how to make 2+2=5 )
mircea_popescu: alright. then let me tell you how to do it, and if you fucking say you did it in july ima buy a plane ticket and hang you by the tallest petard.
mircea_popescu: is it true or is it false that you understand how to make modulus calculations distributive wrt addition ?
mircea_popescu: now back to the issue. 1. is it true or is it false that currently sums are calculated before the modulus of the result is calculated ?
asciilifeform: ( this is the 'new' karatsuba, simplified, and demands powers-of-two-bitnessed operands. should be easier to read than old.)
mircea_popescu: asciilifeform is the plan here to just keep adding reading material paper over fire ?
mircea_popescu: so, the paste is a division.
asciilifeform: it and the prev, http://btcbase.org/log/2017-09-12#1712905 . ☝︎
asciilifeform: i highly recommend to read the past 1st, it is not long
mircea_popescu: well, let's try and salvage this nonsense through the mafgic of yes and no questions.
asciilifeform: and if mircea_popescu writes one -- i dun care if in fortran, cobol, malbolge, whichever, so long as it's something resembling a proggy -- i promise to read.
asciilifeform: what we do not have -- and don't have because it doesn't actually work -- is the karatsuba cut for modular mult.
mircea_popescu: go have a glass of water, this is unstable.
mircea_popescu: <mircea_popescu> "it" in 3 is mod ? or what ? asciilifeform> aha mod asciilifeform> i was speaking specifically of the division algo
asciilifeform: that one -- we already ahve (see the paste, and the old pastes)
asciilifeform: i was speaking specifically of the division algo
mircea_popescu: but, what you say on this topic is in some proportion not true.
mircea_popescu: and congrats, you've closed the liar circle on yourself. the only task remaining is to establish whether alf lied when he claimed that mp's distributive-mod algo is already in his ffa since july ; or rather he lied when he claimed distributive mod would actually be useful ; or at some other juncture.
jhvh1: shinohai: The operation succeeded.
shinohai: !~later tell danielpbarron http://wotpaste.cascadianhacker.com/pastes/IC3jF/?raw=true
asciilifeform: 1) mircea_popescu describes algo for mod. 2) turns out exactly knuths's, that is in existing ffa 3) describes 'do it to each term of a+b+c in karatsuba' 4) this dun work, if it worked we would be bragging about the new 133337 recursive modular mult algo we've got
mircea_popescu: "have you thought about what'll you do about lingerie ? TRIBAL GIRLS CANT WEAR ANY!"
mircea_popescu: and in today's reason #5409834 why tattoos are a bad idea : http://68.media.tumblr.com/c853da0a74a94227229869f0e9c8f35d/tumblr_nv9nfgHcTJ1stfekto1_1280.jpg
asciilifeform: i think we missed a step in the thread