Forums > Jitter

question about jit.op

April 8, 2008 | 9:35 am

I cannot figure out how jit.op functions. I use jit.op to multiply two matrix but the resulted matrix does not seem to be mathematically right. For example, the 6th cell of the left matrix is 255, the 6th cell of the right matrix is 100, and the resulted value from jit.op with multiplication function is 99 instead of 25500.

Could anyone explain to me ? Thanks.

max v2;
#N vpatcher 162 112 1034 610;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 409 17 48 196617 loadbang;
#P user jit.pwindow 275 296 82 62 0 1 0 0 1 0;
#P user jit.cellblock 390 274 587 356 3 9 4 4 45 17 0 1 1 0 0 0 1 1 1 0 0 0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 215 215 240 1 1 1 0 4 0 0 0;
#P user jit.pwindow 529 179 82 62 0 1 0 0 1 0;
#P user jit.cellblock 617 169 816 256 3 9 4 4 45 17 0 1 1 0 0 0 1 1 1 0 0 0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 215 215 240 1 1 1 0 4 0 0 0;
#P newex 617 140 132 196617 jit.matrix test2 1 char 4 4;
#P message 617 89 178 196617 1 0 0 0 0 100 100 0 0 60 60 0 0 0 0;
#P newex 617 112 73 196617 jit.fill test2 0;
#P user jit.pwindow 38 167 82 62 0 1 0 0 1 0;
#P user jit.cellblock 126 157 323 239 3 9 4 4 45 17 0 1 1 0 0 0 1 1 1 0 0 0 255 255 255 0 0 0 0 0 0 191 191 191 0 0 0 215 215 240 1 1 1 0 4 0 0 0;
#P newex 126 128 132 196617 jit.matrix test1 1 char 4 4;
#P message 126 77 202 196617 0 0 0 0 0 255 255 0 0 255 255 0 0 0 0 0;
#P newex 126 100 73 196617 jit.fill test1 0;
#P newex 390 228 65 196617 jit.op @op *;
#P connect 3 0 5 0;
#P connect 13 0 2 0;
#P connect 2 0 1 0;
#P connect 1 0 3 0;
#P connect 3 0 4 0;
#P connect 0 0 12 0;
#P connect 3 0 0 0;
#P connect 0 0 11 0;
#P connect 8 0 0 1;
#P connect 8 0 10 0;
#P connect 13 0 7 0;
#P connect 7 0 6 0;
#P connect 6 0 8 0;
#P connect 8 0 9 0;
#P pop;


April 8, 2008 | 11:15 am

It is because you are working with a matrix of type char.
Char type is a value between 0 and 255, correponding in a multiplication to 0 and 1.

When you multiply by a char, between 0 and 255, it means that 0 multiply by 0, 255 by 1 and for exemple multiply by 128 correspond to multiply by 0.5.

25500 does not exist in char type. If you want the results you describe, try to change your matrix in type long, or float32.


April 8, 2008 | 1:48 pm

Quote: David Buff wrote on Tue, 08 April 2008 05:15
—————————————————-
> It is because you are working with a matrix of type char.
> Char type is a value between 0 and 255, correponding in a multiplication to 0 and 1.
>
> When you multiply by a char, between 0 and 255, it means that 0 multiply by 0, 255 by 1 and for exemple multiply by 128 correspond to multiply by 0.5.
>
> 25500 does not exist in char type. If you want the results you describe, try to change your matrix in type long, or float32.
—————————————————-

Thank you so much. Now I understand it better.


Viewing 3 posts - 1 through 3 (of 3 total)