Multiplying a matrix with a list with jit.gen
Hey everyone,
Has anyone tried to use jit.gen to multiply a 4-plane char matrix with a list of 4 floats, multiplying each plane with the matching float in the list?
Below is a patch that uses jit.expr to do this, I'm wondering whether it is possible to do this with jit.gen.
Thanks for any help,
Mattijs
Allright, found it ;)
Cheers,
Mattijs
Hi Mattijs,
Here's the best way to do what you want. Jitter binary ops (+, -, *, /, %, ...) can handle vector multiplication, you so don't have to do it on a per-component basis. It's going to be more efficient this way:
Hey Wesley, thanks!
I think I tried to directly enter the list in the second inlet of the jit.gen object, which didn't give me the desired results, so I assumed that using vectors á la jit.expr wouldn't be possible at all.
Seeing that the ops support this, would it be an idea to allow inputting lists through the inputs of the jit.gen?
Best,
Mattijs
Inputs have to be matrices. Lists are not accepted like with jit.expr. However, you can set parameters as lists and use the parameter name in the binop directly like I did in the example I posted. Also note that params now generate object attributes for jit.gen, jit.pix, and jit.gl.pix so you don't have to do [prepend param], but can just use argb directly. I don't think this is so burdensome. Also, it makes it pretty clear what's going on.
wes
Hi Wesley, I can see your point, accepting lists as input besides matrices might make things less transparent. I do agree that I have had some trouble in the past finding out the exact behavior of jit.expr when inputting lists and matrices of various sizes.
Btw I love codebox, it seems I really enjoy mixing text based programming and visual programming.
just out of curiosity, what is the most effective way the binop or the codebox way in wesley's example?
i assume it is -in this case- indifferent, since there is only one binop stage?