void bug987()
{
  Matrix3Xd points = Matrix3Xd::Random(3, 3);
  Vector2d diag = Vector2d::Random();
  Matrix2Xd tmp1 = points.topRows<2>(), res1, res2;
  VERIFY_IS_APPROX( res1 = diag.asDiagonal() * points.topRows<2>(), res2 = diag.asDiagonal() * tmp1 );
  Matrix2d tmp2 = points.topLeftCorner<2,2>();
  VERIFY_IS_APPROX(( res1 = points.topLeftCorner<2,2>()*diag.asDiagonal()) , res2 = tmp2*diag.asDiagonal() );
}
Beispiel #2
0
vd EigenInterface::eigenVectors(vd mm) {
  Matrix2d m(2,2);
  m(0,0) = mm[0];
  m(1,0) = mm[1];
  m(0,1) = mm[2];
  m(1,1) = mm[3];
  cout << m << endl;
  VectorXcd eigenval = m.eigenvalues();
  cout << "Eigenvalues: "<< endl;
  cout << eigenval << endl;
  cout << "Diagonal:" << endl;
  cout << m.diagonal() << endl;

  Vector2d w = {1,2};
  Matrix2d mu = w.asDiagonal();

  cout << "Diagonal matrix from: " << w << endl;
  cout << mu << "||||\n";

  //Jacobi decomposition: projecting-out the positive part
  JacobiSVD<Matrix2d> svd(m, ComputeFullU | ComputeFullV);
  auto sing = svd.singularValues();
  Matrix2d U = svd.matrixU();
  Vector2d sin = svd.singularValues();
  cout << "Printing the vectof of singular values:\n";
  cout << sin << endl;
  cout << "-------------\n";
  cout << "Printing U:\n";
  cout << svd.matrixU() << endl;
  cout << "Printing V:\n";
  cout << svd.matrixU() << endl;
  cout << "--------------\n";
  EigenSolver<Matrix2d> roz(m);
  cout << "Eigenvalues:\n" << roz.eigenvalues() << endl;
  cout << "Eigenvectors:\n" << roz.eigenvectors() << endl;
//  cout << "Singular values from decomposed m:" << wsing << endl;

  //Type casting:
//  Eigen::MatrixXd d;                       // Matrix of doubles.
//  Eigen::MatrixXf f = d.cast <float> ();   // Matrix of floats.

  return vd();
}