Page 1 of 1

Does OpenSim feature full SimTK Core ?

Posted: Sun Feb 03, 2013 1:33 am
by krueger
Hello,
i have the following problem: within an OpenSim API programm I need to make use of some SimTK linear algebra functions. more precisely I want to compute eigenvalues using SimTK::Eigen class. However as soon as I try to call any methods of this class, I get a link error that says: "unresolved symbol"
I was wandering if the OpenSim sdk libs feature all classes of simtk?
Best regards, Daniel

Re: Does OpenSim feature full SimTK Core ?

Posted: Sun Feb 03, 2013 1:46 pm
by sherm
Hi, Daniel.

Yes, OpenSim's API provides full access to everything in the SimTK namespace, including SimTK::Eigen. However, the methods of the Eigen class are templatized, with only certain combinations of template arguments corresponding to available implementations. Any combination that isn't available will produce an "unresolved symbol" link error.

Please post more specific information about precisely what you are trying to do, the code you used to do it, and the exact error message you received. Then I can help you get it to work.

Regards,
Sherm

Re: Does OpenSim feature full SimTK Core ?

Posted: Mon Feb 04, 2013 12:25 am
by krueger
Hi Sherm,
thanks for your reply.
Here is my code:
Matrix H; //matrix of elt <double>

//..init matrix H to something

Vector d; //also double
Matrix V; //also double

Eigen e(H);
e.getAllEigenValuesAndVectors(d,V); //compute Eigenvalues and -vectors

When I try to link this code the following error appears:
error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: void __thiscall SimTK::Eigen::getAllEigenValuesAndVectors<double,double>(class SimTK::Vector_<double> &,class SimTK::Matrix_<double> &)"


"Verweis auf nicht aufgelöstes externes Symbol" = "reference to unresolved external symbol" (german vc++)

This is strange because apparently there is an implementation of .getAllEigenValuesAndVectors for objects of data type <double>.

Thank you for your help!
Daniel

Re: Does OpenSim feature full SimTK Core ?

Posted: Mon Feb 04, 2013 11:06 am
by sherm
Hi, Daniel.

The problem is that eigenvalues and eigenvectors of a general real matrix can be complex. So we didn't implement the method with just real arguments. You can easily use complex arguments:

Code: Select all

Matrix H; // real
// SimTK::Complex is just a typedef to std::complex<double> which you can use instead
// if you prefer.
Vector<Complex> d; // eigenvalues may be complex
Matrix<Complex> V; // same for eigenvectors
Eigen e(H);
e.getAllEigenValuesAndVectors(d,V);
You can extract the real part elementwise but should check for complex results unless 
you're sure there aren't any.

Code: Select all

Vector d_real(d.size());
for (int i=0; i < d.size(); ++i)
   d_real[i] = d[i].real(); 
 
Sorry the documentation is not better for this!

Regards,
Sherm

Re: Does OpenSim feature full SimTK Core ?

Posted: Tue Feb 05, 2013 12:52 am
by krueger
Thank you very much, Sherm!
Complex values really make sense...
Regards,
Daniel