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

Matrix inside another Matrix

Tags: None
(comma "," separated)
Uskok
Registered Member
Posts
2
Karma
0

Matrix inside another Matrix

Mon Apr 14, 2014 7:42 am
Hi,

It is possible to define matrix inside another matrix and use algebra?

Code: Select all
#include <iostream>

#include <complex>
typedef std::complex<double> dcomplex;

#include <Eigen/Dense>

typedef Eigen::Matrix<dcomplex, 3, 3> Matrix3dc;
typedef Eigen::Matrix<Matrix3dc, 2, 2> Matrix2dc3x3;

typedef Eigen::Matrix<dcomplex, 3, 1> Vector3dc;
typedef Eigen::Matrix<Vector3dc, 2, 1> Vector2dc3x1;

using namespace std;

int main()
{
  Vector3dc dcVec1;
  dcVec1 << dcomplex(1,0),
            dcomplex(2,0),
            dcomplex(3,0);

  Vector3dc dcVec2;
  dcVec2 << dcomplex(0,1),
            dcomplex(0,2),
            dcomplex(0,3);

  Vector2dc3x1 dcVecIn;
  dcVecIn << dcVec1, dcVec2;

  cout << "Here is dcVecIn[0]: " << endl << dcVecIn[0]  << endl;
  cout << "Here is dcVecIn[1]: " << endl << dcVecIn[1]  << endl;

  Matrix3dc a11, a12, a21, a22;
  a11 = Matrix3dc::Random();
  a12 = Matrix3dc::Random();
  a21 = Matrix3dc::Random();
  a22 = Matrix3dc::Random();

  Matrix2dc3x3 dcMat;
  dcMat << a11, a12, a21, a22;

  cout << "Here is dcMat[0,0]: " << endl << dcMat(0,0)  << endl;
  cout << "Here is dcMat[0,1]: " << endl << dcMat(0,1)  << endl;
  cout << "Here is dcMat[1,0]: " << endl << dcMat(1,0)  << endl;
  cout << "Here is dcMat[1,1]: " << endl << dcMat(1,1)  << endl;

  Vector2dc3x1 dcVecOut;

  //dcVecOut = dcMat * dcVecIn;  <- Problem !!!

  return 0;
}


Storage part is working, but the matrix multiplication makes some problems.
I would like to have two-port network independent of current model (1 or 3 phases).
jitseniesen
Registered Member
Posts
204
Karma
2

Re: Matrix inside another Matrix

Mon Apr 14, 2014 8:59 am
I think it is pretty much as you say: some things work, some things don't. It is a long term goal to support this but there does not seem to be much work on it recently. It is recorded in http://eigen.tuxfamily.org/bz/show_bug.cgi?id=100 in bugzilla.
Uskok
Registered Member
Posts
2
Karma
0

Re: Matrix inside another Matrix

Mon Apr 14, 2014 9:09 am
jitseniesen wrote:I think it is pretty much as you say: some things work, some things don't. It is a long term goal to support this but there does not seem to be much work on it recently. It is recorded in http://eigen.tuxfamily.org/bz/show_bug.cgi?id=100 in bugzilla.


Thanks for the info.
As I understand, the workaround could be to use external storage for the matrix and with the help of Map crate the views and use them in the rest of the calculations.
Any suggestions are welcome.


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], rblackwell