If then else in Jitter Matrix?

    Apr 25 2010 | 6:37 pm
    Can anyone tell me if it's possible to put an if statement into a matrix calculation?
    Basically, I'm taking 2 matrices, and using a few jit.op objects for some functions (such as multiplying, adding etc) and outputting values in matrix form. The problem is I don't want to end up with any values less than 1, so anything
    I've done it in Max before, whereby I use:
    if $f1
    Is there a way to do this in a matrix format in jitter?

    • Apr 25 2010 | 8:15 pm
      you have to make use of jit.expr to construct an equivalent expression using equality and logical operators.
      one way to achieve your stated goal:
      @expr (in[0]1)*in[0])
      breaking this down, we are testing if the input is greater than 1, and multiplying this result (which will be 1 if greater than 1) with the input. this yields either the input if input is greater than 1, else 0.
      we can then add this to the result of comparing if the input is less or equal to 1, which basically turns the 0s to 1s.
    • Apr 25 2010 | 9:08 pm
      This is genius...thank you!!
    • Mar 05 2014 | 11:19 pm
      So is there a way to do "else"?
    • Mar 07 2014 | 12:09 am
      What exactly are you trying to do? The if/else construct doesn't make a lot of sense with matrix processing since you always output a value for a given cell. If you have two different expressions you want to evaluate depending on some condition, there are a number of ways to implement it, but how it's implemented might depend on exactly what you're trying to accomplish.