## Problems with speed of patch using Expr and Matrix

Aug 1, 2007 at 3:14pm

# Problems with speed of patch using Expr and Matrix

Okay, I’ve looked at my patch again and it is not the ‘virtual sand’ that I orignally thought was the problem.

[img]index.php?t=getfile&id=777&private=0[/img]

I have 20 or so formula’s in a java external. They are selected using values, n and m in inlet 2 and 3 – no processing at all. The selected formula is passed out of the outlet into jit.expr. As the formula is be passed into jit.expr it starts a bang, where a new matrix is also passed into jit.expr. If I scroll through the values n/m I get lots of slow down! I’m sure it has something to do with creating a new matrix for each expr! Though I dont know a better approach? Any ideas?

Thanks.

#33116
Aug 1, 2007 at 3:28pm

#109785
Aug 1, 2007 at 3:52pm

Okay I see. Though I’m not entirely sure what you mean by an optimized pipeline. Do you have a reference? Btw, just for clarification, this is one of my formulas.

(-0.034886*pow(norm[0]\,6)-0.087331*pow(norm[0]\,5)+0.58852*pow(norm[0]\,4)-0.024326*pow(norm[0]\,3)-1.4418*pow(norm[0]\,2)-0.00025598*norm[0]+1)*sin(norm[0]*2)*cos(0*PI*snorm[1])

jeanfrancois.charles, ahh yes, I solved that one with a delay.

Quote: wesley.hoke@gmail.com wrote on Wed, 01 August 2007 09:24
—————————————————-
> It’s not creating a new matrix that’s the problem, it’s more than
> likely the speed of jit.expr’s evaluation. It’s not a fast object by
> its very nature, especially if you have decently sized exressions. If
> you have a fixed number of expressions, I would recommend building an
> optimized pipeline for each and switching between those. If you’re
> using JAVA than this is fairly easy to do because you can make a
> function for each expression and switch between them based on a
> parameter.
>
> wes
>
> On 8/1/07, Carl Knott wrote:
> > Okay, I’ve looked at my patch again and it is not the ‘virtual sand’ that I orignally thought was the problem.
> >
> > [img]index.php?t=getfile&id=777&private=0[/img]
> >
> > I have 20 or so formula’s in a java external. They are selected using values, n and m in inlet 2 and 3 – no processing at all. The selected formula is passed out of the outlet into jit.expr. As the formula is be passed into jit.expr it starts a bang, where a new matrix is also passed into jit.expr. If I scroll through the values n/m I get lots of slow down! I’m sure it has something to do with creating a new matrix for each expr! Though I dont know a better approach? Any ideas?
> >
> > Thanks.
> >
> >
> >
> >
> >
> >
>
—————————————————-

#109786
Aug 1, 2007 at 4:17pm

One thing that hasn’t been suggested is that you create one jit.expr
object for each expression you are going to use, and then a gate to
route the bang/matrix to the right one. This will save you a lot of
processing time as you aren’t having to evaluate the expression string
each time you switch. Jit.expr should be no different from using the
equivalent jit.op objects when working with float32 matrices (in theory).

Andrew B.

#109788
Aug 1, 2007 at 4:21pm

Do you have an example of the optimized pipe line Wez? I dont know what you mean.

#109789
Aug 1, 2007 at 5:38pm

“One thing that hasn’t been suggested is that you create one jit.expr
object for each expression you are going to use, and then a gate to
route the bang/matrix to the right one. This will save you a lot of
processing time as you aren’t having to evaluate the expression string
each time you switch. Jit.expr should be no different from using the
equivalent jit.op objects when working with float32 matrices (in theory).

Andrew B.”

Ah, I was thinking among the same lines.. but set up an array of Matrix in Java, process it in the constructor, then return the correct matrix through the outlet.

#109791
Aug 1, 2007 at 6:53pm

For people who have a similar problem in the future, I solved it by writing this algorithm…

JitterObject myexpr = new JitterObject(“jit.expr”);
boolean result;
for(int i=0; i
for(int j=1; j
jm[i][j] = new JitterMatrix(1, “float32″,256, 256);
out[i][j] = new JitterMatrix(1, “float32″,256, 256);
myexpr.send(“expr”, CircleMembraneFormula[i][j]);
result = myexpr.matrixcalc(jm[i][j],out[i][j]);
post(“RESULT: ” + result);
}
}

I put it into my constructor, it just takes an extra couple of seconds to load the patch :)

Quote: andrewb@cycling74.com wrote on Wed, 01 August 2007 10:17
—————————————————-
> One thing that hasn’t been suggested is that you create one jit.expr
> object for each expression you are going to use, and then a gate to
> route the bang/matrix to the right one. This will save you a lot of
> processing time as you aren’t having to evaluate the expression string
> each time you switch. Jit.expr should be no different from using the
> equivalent jit.op objects when working with float32 matrices (in theory).
>
> Andrew B.
>
—————————————————-

#109792

You must be logged in to reply to this topic.