jit.gen - use of vec

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

Not sure what I'm doing wrong here. Example patch below showing simple use of jit.gen and 'vec' to combine four single-plane matrices into one four-plane matrix. Output is still single-plane. Is this a bug or have I left something out?

Wesley Smith's icon

Hi David,
All of jit.gen inputs and outputs have the same matrix format, which is determined by the matrix input to the left inlet. Since all of your input matrices are 1 float32 10 10, the output will also be 1 float32 10 10. Your use of vec is correct, but the output is converted to 1-plane since the output matrix only has 1-plane.

I just looked at the Gen Overview document and don't see this mentioned. I will add it.

David Butler's icon

Thanks Wes, seeing a 600% performance gain in by replacing some simple jit.expr calculations with jit.gen (in those calculations). Very exciting.

While we're on the subject of documentation, I would perhaps suggest that the short explanations of the gen operators that appear in the autocomplete box be clarified for the 'swiz' and 'vec' operators. They are a little unclear for people unfamiliar with programming technology, but familiar with jitter terminology. For example, 'Swiz' currently reads as 'swizzle and mask vector components'. While I understand that this is a good description in terms of the programming function the operator is actually performing, it doesn't give much clue as to its most common practical use for most jitter users, that of unpacking multi-plane matrices.

Wesley Smith's icon

Thanks David. This is a very good point about the documentation. Something more familiar like you suggest is a good idea. 600%, love to hear that!