Note that there are some explanatory texts on larger screens.

plurals
  1. POLinear Algebra MatrixMultiply method
    primarykey
    data
    text
    <p><b>EDIT:</b><br> After fixing the syntax error and working with this algorithm I found the MKL provider is not the matrix multiplication needed. This algorithm simply multiplies element by element and does not compute the <code>dot(row_n,column_n)</code> as I had originally thought. </p> <p><a href="http://numerics.mathdotnet.com/api/MathNet.Numerics.LinearAlgebra.Single/DenseMatrix.htm#Multiply" rel="nofollow">other source</a></p> <p><b>End Edit</b></p> <p>I can't get this passed the compiler. I have looked all over for a good example but have come up short. The documentation I'm referencing is <a href="http://numerics.mathdotnet.com/api/MathNet.Numerics.Algorithms.LinearAlgebra.Mkl/MklLinearAlgebraProvider.htm#MatrixMultiply" rel="nofollow">MklLinearAlgebraProvider</a></p> <p><code>MathNet.Numerics.Algorithms.LinearAlgebra.Mkl.MklLinearAlgebraProvider</code> </p> <p>I'm trying to write a simple method to compute the rotation matrix <code>R = rz*ry*rx</code> from Euler angles. The problem is the compiler won't take <code>ryXrx</code> or <code>resultMat</code> arrays I'm trying to pass it. I've tried <code>out</code> keyword as well.</p> <p><code>inputMat</code> is a 1-D array of the form {x,y,z,rx,ry,rz} where x,y and z are translations and rx,ry and rz are rotation angles in degrees.</p> <pre><code> private float[,] EulerToHMat(float[] inputMat) { var linalg = new MathNet.Numerics.Algorithms.LinearAlgebra.Mkl.MklLinearAlgebraProvider(); double rzRad = ((double)inputMat[5])*Math.PI/180; double cosZ = Math.Cos(rzRad); double sinZ = Math.Sin(rzRad); double ryRad = ((double)inputMat[4])*Math.PI/180; double cosY= Math.Cos(ryRad); double sinY = Math.Sin(ryRad); double rxRad = ((double)inputMat[3])*Math.PI/180; double cosX= Math.Cos(rxRad); double sinX = Math.Sin(rxRad); var rz = new float[,] { { (float)cosZ, -(float)sinZ, 0 }, { (float)sinZ, (float)cosZ , 0 }, {0,0,1 } }; var ry = new float[,] { { (float)cosY , 0 , (float)sinY }, { 0, 1 , 0 }, { -(float)sinY, 0, (float)cosY } }; var rx = new float[,] { {1,0,0 }, {0,(float)cosX,-(float)sinX }, {0,(float)sinX,(float)cosX } }; var ryXrx = new float[3,3]; var resultMat = new float[3, 3]; // won't take the matrix --ryXrx-- here linalg.MatrixMultiply(ry, 3, 3, rx, 3, 3,ryXrx); // won't take the matrix --resultMat-- here linalg.MatrixMultiply(rz, 3, 3, ryXrx, 3, 3,resultMat); return resultMat; } </code></pre> <p>This seems like it should be simple.... Please ignore the casting mess.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload