This forum has been archived. All content is frozen. Please use KDE Discuss instead.

asAxialVector() and asSkewMatrix() methods

Tags: None
(comma "," separated)
n2k
Registered Member
Posts
41
Karma
0
Hi,

in continuum mechanics is very common to transform a skew-symmetric matrix into its correspondent axial vector
v_{k}=1/2*epsilon_{ijk}*M_{ij}
and viceversa:
M_{ij}=epsilon_{ijk}*v_{k}
where epsilon_{ijk} is the rank-3 permutation tensor.

I would like to write an implementation of this such that I can write
Code: Select all
Eigen::Matrix<double,3,3> M;
Eigen::Matrix<double,3,1> v=M.asAxialVector();

and
Code: Select all
Eigen::Matrix<double,3,1> v;
Eigen::Matrix<double,3,3> M=v.asSkewMatrix();


How can I implement this efficiently using Eigen internal mechanisms? For example, if I have:
Code: Select all
Eigen::Matrix<double,3,1> v;
Eigen::Matrix<double,3,3> M1;
Eigen::Matrix<double,3,3> M2=M1+v.asSkewMatrix();

can I code asSkewMatrix() without creating temporaries?

Thanks!
normvcr
Registered Member
Posts
12
Karma
0
OS
I'm not sure if this is helpful, but it seems related:

http://eigen.tuxfamily.org/dox-devel/TopicFunctionTakingEigenTypes.html

This explains how to pass expressions into functions without first converting to a temporary.
lbruce
Registered Member
Posts
1
Karma
0
Hi,

I'm also interested in this topic. The documentation in the link does not solve the problem, I think.

I am particularly interested about the asSkew() method.
Is there any Eigen-way with template expressions to implement it, rather than just creating a plain 3x3 matrix, fill the coefficients, and return by value?

I understand that with a 3x3 it may be not worth to have a complex implementation, because temporaries are small.
But the problem is actually more general: how do I turn a vector (of length n) into a matrix (eg nxn) whose coefficients are a function of the vector? Without using a temporary matrix, if there is a more efficient way.

thanks a lot
B


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]