Idiosyncrasy of dim() in Gen when using a 1d/2d matrix

MakePatchesNotWar's icon

Hello,

When using a 3-plane 1d-matrix in Jit.gen it will assign dim().x to y and z as well. If you use a 3-plane 2d-matrix Gen will output a 0 for the z value.

Came across this when summing all the values of a matrix in Gen and calculating the mean. I noticed the mean still appearing correct but the sum was off.

So you need to let Gen know beforehand how many dimensions a matrix has and accommodate for this. I actually expected dim().y to be 1 when using a 1d matrix because having it like this would keep any nested for-loops working right? The code in this example would break if it had a for-loop for a 3d matrix and would be given a 2d matrix.

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