[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [analitza/aucahuasi/matrixeigen] analitza: Fix eigenvectors implementation and add tests.
From:       Percy_Camilo_Triveño_Aucahuasi <percy.camilo.ta () gmail ! com>
Date:       2014-06-23 8:58:11
Message-ID: E1Wz04p-00043a-VO () scm ! kde ! org
[Download RAW message or body]

Git commit 8cc4fc29ec1f1e6a269d1f952cba3948f8a6a4d9 by Percy Camilo Triveño \
Aucahuasi. Committed on 23/06/2014 at 08:57.
Pushed by aucahuasi into branch 'aucahuasi/matrixeigen'.

Fix eigenvectors implementation and add tests.

M  +2    -2    analitza/commands/eigencommands.cpp
M  +8    -0    analitza/tests/commandstest.cpp

http://commits.kde.org/analitza/8cc4fc29ec1f1e6a269d1f952cba3948f8a6a4d9

diff --git a/analitza/commands/eigencommands.cpp \
b/analitza/commands/eigencommands.cpp index d29b7e6..77bda6b 100644
--- a/analitza/commands/eigencommands.cpp
+++ b/analitza/commands/eigencommands.cpp
@@ -176,7 +176,7 @@ Expression EigenvectorsCommand::operator()(const QList< \
Analitza::Expression >&  
 		return ret;
 	}
-	const int neigenvectors = eigeninfo.cols();
+	const int neigenvectors = eigeninfo.rows();
 	
 	Analitza::List *list = new Analitza::List;
 	
@@ -185,7 +185,7 @@ Expression EigenvectorsCommand::operator()(const QList< \
Analitza::Expression >&  Analitza::Vector *eigenvector = new \
Analitza::Vector(neigenvectors);  
 		for (int i = 0; i < neigenvectors; ++i) {
-			const std::complex<double> eigenvalue = eigeninfo(i);
+			const std::complex<double> eigenvalue = col(i);
 			const double realpart = eigenvalue.real();
 			const double imagpart = eigenvalue.imag();
 			
diff --git a/analitza/tests/commandstest.cpp b/analitza/tests/commandstest.cpp
index 5e8d90c..897431c 100644
--- a/analitza/tests/commandstest.cpp
+++ b/analitza/tests/commandstest.cpp
@@ -388,6 +388,14 @@ void CommandsTest::testCorrect_data()
 	script.clear();
 	script << "eigenvalues(matrix(vector{3,4}, vector{-2, -1}))";
 	QTest::newRow("eigenvalues: full complex") << script << "list { 1+2*i, 1-2*i }";
+	
+	script.clear();
+	script << "eigenvectors(identitymatrix(4))";
+	QTest::newRow("eigenvectors: from Id") << script << "list { vector { 1, 0, 0, 0 }, \
vector { 0, 1, 0, 0 }, vector { 0, 0, 1, 0 }, vector { 0, 0, 0, 1 } }"; +	
+	script.clear();
+	script << "eigenvectors(matrix(vector{3,4}, vector{-2, -1}))";
+	QTest::newRow("complex eigenvectors") << script << "list { vector { \
-0.408248290464+0.408248290464*i, 0.816496580928*i }, vector { \
-0.408248290464-0.408248290464*i, -0.816496580928*i } }";  #endif
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic