[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Toon-members] TooN/regressions eigen-sqrt.cc eigen-sqrt.txt
From: |
Damian Eads |
Subject: |
[Toon-members] TooN/regressions eigen-sqrt.cc eigen-sqrt.txt |
Date: |
Tue, 29 Sep 2009 15:32:33 +0000 |
CVSROOT: /sources/toon
Module name: TooN
Changes by: Damian Eads <eads> 09/09/29 15:32:32
Added files:
regressions : eigen-sqrt.cc eigen-sqrt.txt
Log message:
Added regression test for eigen-sqrt using Ed's new regression
framework.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/regressions/eigen-sqrt.cc?cvsroot=toon&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/TooN/regressions/eigen-sqrt.txt?cvsroot=toon&rev=1.1
Patches:
Index: eigen-sqrt.cc
===================================================================
RCS file: eigen-sqrt.cc
diff -N eigen-sqrt.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ eigen-sqrt.cc 29 Sep 2009 15:32:32 -0000 1.1
@@ -0,0 +1,43 @@
+#include <iostream>
+#include <TooN/TooN.h>
+#include <TooN/SymEigen.h>
+
+using namespace std;
+using namespace TooN;
+
+int main() {
+ // construct M
+ double d1[][3] = {{1,2,3},{2,5,6},{3,6,7}};
+ Matrix<3> M(3,3);
+ M[0]=makeVector(4,0,2);
+ M[1]=makeVector(0,5,3);
+ M[2]=makeVector(2,3,6);
+
+ Vector<3> dg(makeVector(2,4,9));
+ // create the eigen decomposition of M
+ SymEigen<3> eigM(M);
+ cout << M << endl;
+
+ cout << endl;
+
+ // Print the eigenvalues and eigenvectors
+ cout << eigM.get_evalues() << endl;
+ cout << eigM.get_evectors() << endl << endl;
+
+ // print the square root of the matrix.
+ cout << eigM.get_sqrtm() << endl << endl;
+
+ // print the square root of the matrix squared.
+ cout << eigM.get_sqrtm().T() * eigM.get_sqrtm() << endl << endl;
+
+ // print the inverse of the matrix.
+ cout << eigM.get_pinv() << endl;
+
+ // print the inverse square root of the matrix.
+ cout << eigM.get_isqrtm() << endl;
+
+ // print the inverse square root of the matrix squared.
+ cout << eigM.get_isqrtm().T() * eigM.get_isqrtm() << endl;
+
+ return 0;
+}
Index: eigen-sqrt.txt
===================================================================
RCS file: eigen-sqrt.txt
diff -N eigen-sqrt.txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ eigen-sqrt.txt 29 Sep 2009 15:32:32 -0000 1.1
@@ -0,0 +1,37 @@
+# A
+4 0 2
+0 5 3
+2 3 6
+
+# Eigenvalues of A
+1.63463 4.33626 9.02911
+
+# Eigenvectors of A
+0.533741 0.562714 -0.631247
+0.789159 -0.599687 0.13268
+0.30389 0.568971 0.764149
+
+# R=sqrt(A)
+1.93856 -0.0819276 0.485048
+-0.0819276 2.12647 0.686608
+0.485048 0.686608 2.30072
+
+# R^T*R (should equal A)
+4 0 2
+0 5 3
+2 3 6
+
+# A^-1
+0.328125 0.09375 -0.15625
+0.09375 0.3125 -0.1875
+-0.15625 -0.1875 0.3125
+
+# Q=isqrt(A)
+0.552621 0.0651912 -0.135961
+0.0651912 0.528101 -0.171346
+-0.135961 -0.171346 0.514446
+
+# Q^T*Q (should equal A^-1)
+0.328125 0.09375 -0.15625
+0.09375 0.3125 -0.1875
+-0.15625 -0.1875 0.3125
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Toon-members] TooN/regressions eigen-sqrt.cc eigen-sqrt.txt,
Damian Eads <=