Yes, good point. Or, more concisely:
ri =: * * [: <. 0.5 + | ri&.+. 3.45 1j1 3j4.5 3 1j1 3j5 (...though &.: would give better performance than &. on large arrays, and for ri produce the same result.) Thanks, -- Raul On Sat, Jan 16, 2016 at 5:04 PM, Kip Murray <[email protected]> wrote: > Raul, would you like > > ri NB. round to integer > * * [: <. 0.5 + | > ric NB. round to Gaussian integer > [: j./"1 [: ri +. > ric 3.45 1j1 3j4.5 > 3 1j1 3j5 > > ? > > --Kip > > On Saturday, January 16, 2016, Raul Miller <[email protected]> wrote: > >> Hmm.. clearly not intended for gaussian integers. >> >> ri =: * * [: <. 0.5 + | >> ri 1j1 >> 0.707107j0.707107 >> >> But I guess that's the thing about what we get taught... it tends to >> have only situational relevance. >> >> Thanks, >> >> -- >> Raul >> >> >> On Sat, Jan 16, 2016 at 10:50 AM, Kip Murray <[email protected] >> <javascript:;>> wrote: >> > Here is my latest round-to-integer. It rounds the absolute value and >> then >> > restores the sign -- the way I was taught to round. Apologies if someone >> > else has already presented this. >> > >> > ri =: * * [: <. 0.5 + | >> > ri _1234.56 >> > _1235 >> > ri 123.45 >> > 123 >> > >> > --Kip Murray >> > >> > >> > -- >> > Sent from Gmail Mobile >> > ---------------------------------------------------------------------- >> > For information about J forums see http://www.jsoftware.com/forums.htm >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm > > > > -- > Sent from Gmail Mobile > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
