您的位置:首页 > 其它

Lesson 6 Transposition and conjugation

2015-11-02 21:04 176 查看
The transpose 

, conjugate 

,
and adjoint (i.e., conjugate transpose) 

 of a matrix or vector 

 are
obtained by the member functions transpose()conjugate(),
and adjoint(), respectively.
Example:Output:
MatrixXcf a =

MatrixXcf::Random(2,2);

cout << "Here is the matrix a\n" << a << endl;

cout << "Here is the matrix a^T\n" << a.transpose() << endl;

cout << "Here is the conjugate of a\n" << a.conjugate() << endl;

cout << "Here is the matrix a^*\n" << a.adjoint() << endl;

Here is the matrix a
(-0.211,0.68) (-0.605,0.823)
(0.597,0.566)  (0.536,-0.33)
Here is the matrix a^T
(-0.211,0.68)  (0.597,0.566)
(-0.605,0.823)  (0.536,-0.33)
Here is the conjugate of a
(-0.211,-0.68) (-0.605,-0.823)
(0.597,-0.566)    (0.536,0.33)
Here is the matrix a^*
(-0.211,-0.68)  (0.597,-0.566)
(-0.605,-0.823)    (0.536,0.33)

For real matrices, 
conjugate()
 is a no-operation, and so 
adjoint()
 is equivalent to 
transpose()
.

As for basic arithmetic operators, 
transpose()
 and 
adjoint()
 simply return a proxy object without doing the actual transposition. If you do 
b = a.transpose()
, then the transpose is evaluated at the same time as the result
is written into 
b
. However, there is a complication here. If you do 
a = a.transpose()
, then Eigen starts
writing the result into 
a
before the evaluation of the transpose is finished. Therefore, the instruction 
a = a.transpose()
 does not replace 
a
 with its transpose, as one would expect:
Example:Output:
Matrix2i a; a << 1, 2, 3, 4;

cout << "Here is the matrix a:\n" << a << endl;

a = a.transpose(); // !!! do NOT do this !!!

cout << "and the result of the aliasing effect:\n" << a << endl;

Here is the matrix a:
1 2
3 4
and the result of the aliasing effect:
1 2
2 4

This is the so-called aliasing issue. In "debug mode", i.e., when assertions have
not been disabled, such common pitfalls are automatically detected.

For in-place transposition, as for instance in 
a = a.transpose()
, simply use the transposeInPlace() function:
Example:Output:
MatrixXf a(2,3); a << 1, 2, 3, 4, 5, 6;

cout << "Here is the initial matrix a:\n" << a << endl;

a.transposeInPlace();

cout << "and after being transposed:\n" << a << endl;

Here is the initial matrix a:
1 2 3
4 5 6
and after being transposed:
1 4
2 5
3 6

There is also the adjointInPlace() function for complex
matrices.

The word adjoint has a number of related meanings. In linear algebra, it refers to the conjugate transpose and is most commonly
denoted 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: