Closed sekisushai closed 7 years ago
Hi Pierre,
if(c,t,e)
is very slow compared to pattern matching. Therefore I suggest replacing all remaining if
in your code with the equivalent using pattern matching.
Let me know if that solves the problem...
Cheers
Yann
Hi Yann,
Thank you for the suggestion. That solved it up to M=4
!
I've replaced ba.if
occurrences with:
case{
(1) => t;
(0) => f;
}(test)
Unfortunately, the compilation never stops at order M=5
. My guess is that the recurrence formula brings very long trigonometric formula, if intermediate simplifications are not done by the compiler.
For example, the term rot(2,1,1)
gives:
rot(2,1,1) = cos(pitch)^2*cos(roll)*cos(yaw) +
sin(pitch)*(-cos(roll)*cos(yaw)*sin(pitch) + sin(roll)*sin(yaw))
Which, after factorization gives
rot(2,1,1) = cos(roll)*cos(yaw)*(cos(pitch)^2 - sin(pitch)^2)) + sin(pitch)*sin(roll)*sin(yaw)
However, knowing that cos(pitch)^2 - sin(pitch)^2 = cos(2*pitch)
the latter expression could be simplified with:
rot(2,1,1) = cos(roll)*cos(yaw)*cos(2*pitch) + sin(pitch)*sin(roll)*sin(yaw)
which is a simpler expression. This kind of simplification can be done for majority of terms in the rotation matrix.
I'm not sure if the compiler implements trigonometric simplifications, but this would be a great feature !
Hello, I'm having some trouble to compile a matrix where the terms are computed with a recurrence formula. The code is attached at the end of this report
This code compute a rotation matrix of size
(M+1)^2 x (M+1)^2
to rotate a HOA soundscape described at orderM
.Each term of the matrix is computed with a recurrence formula starting with rotation matrix of order
M=1
.The recurrence formula are a bit complex and taken from ref [1] [1] Ivanic, J., & Ruedenberg, K. (1996). Rotation matrices for real spherical harmonics. Direct determination by recursion. The Journal of Physical Chemistry, 100(15), 6342–6347.
In the code, a term of the rotation matrix at order
M
is given by:rot(M,n1,n2) with -M <= n1,n2 <= M
So far, everything compiles up to order
M=3
. However as soon as the order is set asM=4
or higher, faust never finish the compilation.In order to have more clues on this, I can ask as output only on term of the matrix, for example
process = rot(M,M,M) // bottom right term of the matrix at order M
In the same vein, I can ask a whole line of the matrix:
process = row(M,i) // where 0 <= i <= (M+1)^2-1
For
M=4
, all the terms compile separately, as well as all the line of the matrix. However, as soon as I ask the whole matrix, it doesn't compile anymore..Any ideas ?
Thanks, Pierre