@ wrote... (13 years, 11 months ago)

I still don't know what eigenvalues are, what they're for, or how to use them, but I needed to calculate them for work and make sure they were positive.

I use MSVC at work and none of the other packages I looked at had VS solutions or projects. One did, but it didn't compile. I used the Eigen package and since it's templates based “compiling” is the simple part.

Download Eigen from: http://eigen.tuxfamily.org

#include <Eigen/Eigen>
using namespace Eigen;

void PrintEigenvalues( Array inputs )
    MatrixXd matrix( inputs.GetSize(), inputs.GetSize() ); // rows, cols

    // populate the matrix via inputs. matrix(r,c) = n;

    SelfAdjointEigenSolver<MatrixXd> solver( matrix );
    SelfAdjointEigenSolver<MatrixXd>::RealVectorType values = solver.eigenvalues();

    cout << values << endl;

I never did figure out how to call matrix.eigenvalues(), kept getting “Flags&SelfAdjointBit” assertions.

Category: tech, Tags: cpp, programming
Comments: 0
Click here to add a comment