From d658eac59de78cf1c79ab718e3885b623c5641ad Mon Sep 17 00:00:00 2001
From: Van Dung Nguyen <vandung.nguyen@ulg.ac.be>
Date: Fri, 7 Feb 2014 13:17:24 +0000
Subject: [PATCH] add func in eigenSolver

---
 Solver/eigenSolver.cpp | 25 +++++++++++++++++++++++++
 Solver/eigenSolver.h   |  4 ++++
 2 files changed, 29 insertions(+)

diff --git a/Solver/eigenSolver.cpp b/Solver/eigenSolver.cpp
index bc2bc3f51c..e2591937fe 100644
--- a/Solver/eigenSolver.cpp
+++ b/Solver/eigenSolver.cpp
@@ -183,4 +183,29 @@ bool eigenSolver::solve(int numEigenValues, std::string which)
 
 }
 
+
+void eigenSolver::normalize_mode(){
+	Msg::Info("Normalize all eigenvectors");
+  for (unsigned int i=0; i<_eigenVectors.size(); i++){
+		double norm = 0.;
+    for (unsigned int j=0; j<_eigenVectors[i].size(); j++){
+			std::complex<double> val = _eigenVectors[i][j];
+      double normval = std::abs(val);
+      if (normval >norm) 
+				norm = normval;
+    };
+    
+	  
+    if (norm == 0) {
+			Msg::Error("zero eigenvector");
+      return;
+		};
+    	
+ 		for (unsigned int j=0; j<_eigenVectors[i].size(); j++){
+    	_eigenVectors[i][j] /= norm;
+    };
+
+  };  
+};
+
 #endif
diff --git a/Solver/eigenSolver.h b/Solver/eigenSolver.h
index 62ad7be665..d8d8ef2c8f 100644
--- a/Solver/eigenSolver.h
+++ b/Solver/eigenSolver.h
@@ -41,6 +41,8 @@ class eigenSolver{
   {
     return _eigenVectors[num][com];
   };
+  int getNumberEigenvectors() {return _eigenVectors.size();};
+  void normalize_mode();
 };
 
 #else
@@ -65,6 +67,8 @@ class eigenSolver{
   std::vector<std::complex<double> > &getEigenVector(int num){ return _dummy; }
   void clear(){}
   std::complex<double> getEigenVectorComp(int num, int com) { return 0.; }
+	int getNumberEigenvectors() {return 0;};
+	void normalize_mode() {};
 };
 
 #endif
-- 
GitLab