In what order are wave names evaluated within commands?
dtadams
I can find a go-around to this problem, but I'd like to understand Igor better for the future.
I recently wrote a function called "rotMatrix" that takes in an axis number "axis" (1->x, 2->y, 3->z) and an angle "theta" as arguments, and generates a rotation matrix that rotates by theta around the specified axis. To make my code more compact, I had the function store the result in a matrix called "rotMatrixResult"; at the end of the function I returned the name of this matrix, so that I could do this:
$(rotMatrix(1, pi/2))
evaluates to...$("rotMatrixResult")
evaluates to...rotMatrixResult
Thus, $(rotMatrix(1, pi/2)) returns the wave in which I've stored the result.
Here is my problem: When I try to run a command with MULTIPLE $(rotMatrix) calls, like
MatrixMultiply $(rotMatrix(1, pi/2)), $(rotMatrix(2, pi/4)), $(rotMatrix(3, pi))
I'm not sure which results stored under "rotMatrix" Igor is using. Before moving on to the second wave argument, does Igor evaluate the first wave to "rotMatrixResult", or does it actually evaluate until it knows the contents of the wave?
That is, does Igor evaluate like this:
MatrixMultiply $(rotMatrix(1, pi/2)), $(rotMatrix(2, pi/4)), $(rotMatrix(3, pi))
->MatrixMultiply {{...}{...}{...}}, $(rotMatrix(2, pi/4)), $(rotMatrix(3, pi))
->MatrixMultiply {{...}{...}{...}}, {{...}{...}{...}}, $(rotMatrix(3, pi))
...resulting in three different matrices? Or like this:
MatrixMultiply $(rotMatrix(1, pi/2)), $(rotMatrix(2, pi/4)), $(rotMatrix(3, pi))
->MatrixMultiply rotMatrixResult, $(rotMatrix(2, pi/4)), $(rotMatrix(3, pi))
->MatrixMultiply rotMatrixResult, rotMatrixResult, $(rotMatrix(3, pi))
...resulting in the same matrix three times?
(And if it's the second way, is there some other way to make my code this compact? I thought it was a very beautiful solution until my code stopped working :/)
July 2, 2014 at 11:57 am - Permalink
Thanks so much! I hadn't heard of either of those Igor features, that helps a lot.
July 2, 2014 at 02:06 pm - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
July 2, 2014 at 02:36 pm - Permalink