- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
is the first time I try to use MKL, im confused and kind of frustrated because I am searching a cross product and ROTATION MATRIX subrutine and cant find it, i will thank if someone can tell me what MKL function can help me.
Regards!
Regards!
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't see cross product either, it might be because it's only defined for 3 dimensions, while most MKL functions are for more general n-dimensions.
You might look at the wikipedia page for cross product, under "Conversion to Matrix Multiplication". You can store one vector as a 3x3 matrix then do a matrix-vector multiply using one of the BLAS level 2 functions in MKL.
For rotation matrices, can't you just construct them yourself then use MKL to apply them?
If you're after speed, I'd look to see if graphics cards can do these things in hardware.
Quoting - kooka
is the first time I try to use MKL, im confused and kind of frustrated because I am searching a cross product and ROTATION MATRIX subrutine and cant find it, i will thank if someone can tell me what MKL function can help me.
Regards!
Regards!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - kooka
is the first time I try to use MKL, im confused and kind of frustrated because I am searching a cross product and ROTATION MATRIX subrutine and cant find it, i will thank if someone can tell me what MKL function can help me.
Regards!
Regards!
kooka,
I am just interested what are the typical sizes of vectors and matrices you are working with?
--Gennady
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - kooka
is the first time I try to use MKL, im confused and kind of frustrated because I am searching a cross product and ROTATION MATRIX subrutine and cant find it, i will thank if someone can tell me what MKL function can help me.
Regards!
Regards!
If you are using C++, I wrote this code to construct a rotation matrix that makes a right-handed rotation about a normal vector.
Regards,
Jay
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include
#include
typedef float Real;
// computes a 3x3 rotation matrix
void compute_R_3x3(Real *v, Real a, Real *R);
// test program
int main()
{
// v is a normal vector that is the axis of rotation
Real v[3] = {0.0, 0.0, 1.0};
// a is the angle (in radians) that you rotate about v (right-handed)
Real a = (45.0/180.0)*acos(-1.0);
// 3x3 matrix (column-major) - pre-initialized for debug purposes
Real R[] = {99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9};
// call the rotation matrix function
compute_R_3x3(v, a, R);
// output the matrix to console
for (int i=0; i<3; i++) std::cout<<<'t'< return 0;
}
// computes a 3x3 rotation matrix
void compute_R_3x3(Real *v, Real a, Real *R)
{
const Real eijk[2] = {-1.0, 1.0}; // permutation value
const Real COSa=cos(a), SINa=sin(a);
for (int i=0; i<3; i++){
const double cv = (1.0 - COSa) * v;
R = cv*v[0];
R[i+3] = cv*v[1];
R[i+6] = cv*v[2];
R[4*i] += COSa;
int j = (i&1)+(i!=2); // computes cyclic permutation of i
R[i+3*j] -= SINa*v[3-i-j]*eijk[i-j+3*(j>i)-1];
j = (j&1)+(j!=2); // compute(i-j+3*(j>i))-1s cyclic permutation of j
R[i+3*j] -= SINa*v[3-i-j]*eijk[i-j+3*(j>i)-1];
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include
typedef float Real;
// computes a 3x3 rotation matrix
void compute_R_3x3(Real *v, Real a, Real *R);
// test program
int main()
{
// v is a normal vector that is the axis of rotation
Real v[3] = {0.0, 0.0, 1.0};
// a is the angle (in radians) that you rotate about v (right-handed)
Real a = (45.0/180.0)*acos(-1.0);
// 3x3 matrix (column-major) - pre-initialized for debug purposes
Real R[] = {99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9, 99.9};
// call the rotation matrix function
compute_R_3x3(v, a, R);
// output the matrix to console
for (int i=0; i<3; i++) std::cout<
}
// computes a 3x3 rotation matrix
void compute_R_3x3(Real *v, Real a, Real *R)
{
const Real eijk[2] = {-1.0, 1.0}; // permutation value
const Real COSa=cos(a), SINa=sin(a);
for (int i=0; i<3; i++){
const double cv = (1.0 - COSa) * v;
R = cv*v[0];
R[i+3] = cv*v[1];
R[i+6] = cv*v[2];
R[4*i] += COSa;
int j = (i&1)+(i!=2); // computes cyclic permutation of i
R[i+3*j] -= SINa*v[3-i-j]*eijk[i-j+3*(j>i)-1];
j = (j&1)+(j!=2); // compute(i-j+3*(j>i))-1s cyclic permutation of j
R[i+3*j] -= SINa*v[3-i-j]*eijk[i-j+3*(j>i)-1];
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Gennady Fedorov (Intel)
kooka,
I am just interested what are the typical sizes of vectors and matrices you are working with?
--Gennady
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
kooka,
this is very inefficient to use MKL for such small inputs because of MKL mainly oriented on the task size much bigger then 3x3 you are using.
I'd recommend you to use another library - Intel Integrated Performance Primitives (Intel IPP), aka IPP.
Please refer to the ippmman.pdf ( Small matrix ) manual and you can find there all needed routines.
The main advantage of IPP's small matrix functionality - these functions is highly optimized for the inputs you needed.
--Gennady

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page