[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:11:19 +0000 |
CVSROOT: /sources/toon
Module name: TooN
Changes by: Damian Eads <eads> 09/08/27 11:11:18
Modified files:
. : SymEigen.h
Log message:
Added matrix square root.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/SymEigen.h?cvsroot=toon&r1=1.19&r2=1.20
Patches:
Index: SymEigen.h
===================================================================
RCS file: /sources/toon/TooN/SymEigen.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- SymEigen.h 26 Aug 2009 07:49:20 -0000 1.19
+++ SymEigen.h 27 Aug 2009 11:11:18 -0000 1.20
@@ -265,6 +265,18 @@
return det;
}
+ /// Calculate the square root M=sqrt(A) of a matrix, which is
+ /// the matrix M such that M.T*M=sqrt(A).
+ Matrix<Size, Size, Precision> get_sqrtm () const {
+ Vector<Size, Precision> Dsqrt(my_evalues.size());
+ // In the future, maybe throw an exception if an
+ // eigenvalue is negative?
+ for (int i = 0; i < my_evalues.size(); ++i) {
+ Dsqrt[i] = std::sqrt(my_evalues[i]);
+ }
+ return my_evectors.T() * diagmult(Dsqrt, my_evectors);
+ }
+
private:
// eigen vectors laid out row-wise so evectors[i] is the ith evector
Matrix<Size,Size,Precision> my_evectors;