[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Toon-members] TooN SymEigen.h
From: |
Damian Eads |
Subject: |
[Toon-members] TooN SymEigen.h |
Date: |
Thu, 27 Aug 2009 11:38:55 +0000 |
CVSROOT: /sources/toon
Module name: TooN
Changes by: Damian Eads <eads> 09/08/27 11:38:55
Modified files:
. : SymEigen.h
Log message:
Example demonstrates matrix square root. Changed matrix in example to
give positive eigenvalues. Fixed typo in new sqrtm function's docs.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/SymEigen.h?cvsroot=toon&r1=1.20&r2=1.21
Patches:
Index: SymEigen.h
===================================================================
RCS file: /sources/toon/TooN/SymEigen.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- SymEigen.h 27 Aug 2009 11:11:18 -0000 1.20
+++ SymEigen.h 27 Aug 2009 11:38:55 -0000 1.21
@@ -129,15 +129,20 @@
are the eigenvalues of \f$M\f$. These quantities are often of use directly,
and can
be obtained as follows:
@code
-// construct M
-double d1[][] = {{1,2,3},{2,5,6},{3,6,7}};
-Matrix<3> M(d1);
+Matrix<3> M(3,3);
+M[0]=makeVector(4,0,2);
+M[1]=makeVector(0,5,3);
+M[2]=makeVector(2,3,6);
// create the eigen decomposition of M
SymEigen<3> eigM(M);
// print the smallest eigenvalue
cout << eigM.get_evalues()[0] << endl;
// print the associated eigenvector
cout << eigM.get_evectors()[0] << endl;
+// print the square root of the matrix.
+cout << eigM.get_sqrtm() << endl;
+// print the square root of the matrix squared.
+cout << eigM.get_sqrtm().T() * eigM.get_sqrtm() << endl;
@endcode
This decomposition is very similar to the SVD (q.v.), and can be used to solve
@@ -266,7 +271,7 @@
}
/// Calculate the square root M=sqrt(A) of a matrix, which is
- /// the matrix M such that M.T*M=sqrt(A).
+ /// the matrix M such that M.T*M=A.
Matrix<Size, Size, Precision> get_sqrtm () const {
Vector<Size, Precision> Dsqrt(my_evalues.size());
// In the future, maybe throw an exception if an