Multiplying a matrix with a list with jit.gen


    Nov 14 2011 | 10:14 am
    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

    • Nov 14 2011 | 11:01 am
      Allright, found it ;)
      Cheers, Mattijs
    • Nov 14 2011 | 5:03 pm
      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:
    • Nov 15 2011 | 9:37 am
      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
    • Nov 15 2011 | 4:40 pm
      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
    • Nov 17 2011 | 9:52 pm
      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.
    • Nov 18 2011 | 9:22 am
      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?