In the next J6.02 beta the monad u&.(a.&i.) will be fast and lean
for "reasonable" u , likewise the dyad m b.&.(a.&i.)
x=: a.{~ 1e6 [EMAIL PROTECTED] 256
y=: a.{~ 1e6 [EMAIL PROTECTED] 256
ts=: 6!:2 , 7!:[EMAIL PROTECTED]
NB. Monads
ts 'a.{~ 256|>:a.i.x'
0.0206454 1.36325e7
ts '(256|>:)&.(a.&i.) x'
0.00472487 1.06451e6
ts 'a.{~ 256|17*a.i.x'
0.0206249 1.36325e7
ts '(256|17*])&.(a.&i.) x'
0.00470051 1.0647e6
ts 'a.{~ 123 (23 b.) a.i.x'
0.0147518 9.43834e6
ts '123&(23 b.)&.(a.i.]) x'
0.00155621 1.06253e6
Regarding the last monad, see
http://www.jsoftware.com/jwiki/Essays/Bitwise_Functions_on_Characters
NB. Dyads
ts 'a.{~x 22 b.&(a.&i.) y'
0.0228362 1.25863e7
ts 'x 22 b.&.(a.&i.) y'
0.00215877 1.05197e6
ts 'a.{~x 27 b.&(a.&i.) y'
0.0230133 1.25863e7
ts 'x 27 b.&.(a.&i.) y'
0.00215705 1.05197e6
----- Original Message -----
From: Oleg Kobchenko <[EMAIL PROTECTED]>
Date: Friday, November 9, 2007 12:11
Subject: Re: [Jbeta] integer-valued multiply vs divide
To: Beta forum <[email protected]>
> Yes, I knew about the enhancement (though did not
> pay attention to integer argument and power of 2).
> It is very impressive indeed.
>
> I just wanted to put it in context: indeed division
> is multiplication, thus multiplication may in the
> same way benefit from rounding. In particular, should
> definitely do so in space. But then any <[EMAIL PROTECTED] should
> benefit in space.
>
> One of the applications is operations in color space.
> Related to it also is the problem that color is represented
> as bytes in an integer (word), so what is the best way
> to do optimal component-wise calculation?
> - 256 256 256 #. 0>.255<.<. ...calc... 256 256 256
> #: cInt
> - (0>.255<.[:<. ...calc...)&.(a.i.) cChar
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm