向量内积
Vector2d m(1, 2);
Vector2d n(4, 5);
cout << m.dot(n) << endl;
cout << m.adjoint() * n << endl;
cout << (m.adjoint() * n).value() << endl;
转置与伴随矩阵
Matrix2d m, n;
m << 1, 2,
3, 4;
n = m.transpose();
n = m.adjoint();
m.adjointInPlace();
Matrix2cf m = Matrix2cf::Random();
cout << "Here is the 2x2 complex matrix m:" << endl << m << endl;
cout << "Here is the adjoint of m:" << endl << m.adjoint() << endl;
Here is the 2x2 complex matrix m:
(0.127171,-0.997497) (-0.0402539,0.170019)
(0.617481,-0.613392) (0.791925,-0.299417)
Here is the adjoint of m:
(0.127171,0.997497) (0.617481,0.613392)
(-0.0402539,-0.170019) (0.791925,0.299417)
范数与单位化
Vector2d vec1(3, 4);
Vector2d vec2;
double scalar = vec1.norm();
scalar = vec1.squaredNorm();
vec2 = vec1.normalized();
vec1.normalize();
叉积
Vector3d vec1(1, 2, 3);
Vector3d vec2(3, 4, 5);
cout << "cross: " << endl << vec1.cross(vec2) << endl;
cross:
-2
4
-2