Math operations on true/false flags from [jit.op]?

mharter's icon

from my observations, true/false data from jit.op or jit.expr render as 0 or 255 in a jit.cellblock, but do not behave like real integers if further math is done on them. Is there something special about true/false output from jiter operations that I should know about?

I am working with char matrices. Here is an example patch:

Max Patch
Copy patch and select New From Clipboard in Max.

Thanks!

Wesley Smith's icon

What do you mean they don't behave like real integers? in char-land true=255, false=0 as you noticed. It's basically true=white, 0=black. long matrices have 0/1 behavior. If you do jit.op @op > and then multiply the result by a video, the video's pixels will be multiplied by 255 where true, which doesn't affect their brightness. If true were 1 as you suggest, then you'd have to multiply the output of jit.op @op > by 255 before using the T/F matrix to mask an image.

mharter's icon

Strange, now it just started working in the demo patch, but not in my real patch. Time to rebuild.

mharter's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Here is an example of [jit.expr] generating zeros for all output instead of processing the math:

Wesley Smith's icon
Max Patch
Copy patch and select New From Clipboard in Max.

You misspelled in:

mharter's icon

Well, that'll do it.

Is it Max's fault? 0
Is it my fault? 255

Thanks!

mharter's icon

With further investigation I found that scalar values are not properly calculated in the expression. They work as expected from a float32 matrix though (of course the number ranges are different because float32 noise generates 0. to 1. vs. char noise 0 to 255

Max Patch
Copy patch and select New From Clipboard in Max.

Note that the same multiplier written into the expression, and it works as I would expect.