[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38759] branches/soc-2011-avocado/blender/ intern/autoseam: Initial attempt to modularize the eigen value calculation code.
shuvro sarker
shuvro05 at gmail.com
Wed Jul 27 19:16:08 CEST 2011
Revision: 38759
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38759
Author: shuvro
Date: 2011-07-27 17:16:07 +0000 (Wed, 27 Jul 2011)
Log Message:
-----------
Initial attempt to modularize the eigen value calculation code. Need to modify this soon.
Modified Paths:
--------------
branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.cpp
branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.h
branches/soc-2011-avocado/blender/intern/autoseam/CMakeLists.txt
Added Paths:
-----------
branches/soc-2011-avocado/blender/intern/autoseam/EigenSolver.cpp
branches/soc-2011-avocado/blender/intern/autoseam/EigenSolver.h
branches/soc-2011-avocado/blender/intern/autoseam/EigenSolverArpack.cpp
branches/soc-2011-avocado/blender/intern/autoseam/EigenSolverArpack.h
Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.cpp 2011-07-27 16:29:28 UTC (rev 38758)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.cpp 2011-07-27 17:16:07 UTC (rev 38759)
@@ -31,6 +31,7 @@
#include "BKE_report.h"
#include "AutoseamAdjacency.h"
#include "MEM_guardedalloc.h"
+#include "EigenSolverArpack.h"
#ifdef WITH_ARPACK
@@ -68,6 +69,7 @@
int i;
Eigen::VectorXd output(dimension);
+
//printf("the dimesion passed here : %d\n The output values are: \n", dimension);
for(i = 0; i < dimension; i++){
@@ -164,14 +166,9 @@
{
#ifdef WITH_ARPACK
- /* System generated locals */
- integer i__1;
- doublereal d__1;
-
- /* Local variables */
- integer j, n;
- integer nx, ido, ncv, nev;
+ integer n;
+ integer ido, ncv, nev;
doublereal tol;
char bmat[1];
integer info;
@@ -181,7 +178,7 @@
char which[3] = "SM"; // we are looking for the smallest eigen values
- integer nconv;
+ //integer nconv;
integer ipntr[11];
integer iparam[11];
integer ldv;
@@ -410,10 +407,16 @@
a(i,i) = -rowsum;
}
- // We need to calculate eigen values from here.
-
eigen_vectors = calculate_eigen_arpack();
+
+ // Need to modify the errors of the commented code.
+
+ /*EigenSolverArpack solver(matrix_dimension, num_eigen_values);
+ solver.matrix = a;
+ eigen_vectors = solver.calculate_eigen_space();*/
+
+
//dssimp_();
if(a.rows() && a.cols() && eigen_vectors != NULL){
Modified: branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.h 2011-07-27 16:29:28 UTC (rev 38758)
+++ branches/soc-2011-avocado/blender/intern/autoseam/AutoseamAdjacency.h 2011-07-27 17:16:07 UTC (rev 38759)
@@ -33,7 +33,7 @@
#include "AutoseamEigenspace.h"
#include <vector>
-#define NUM_EIGEN_VAL 25
+#define NUM_EIGEN_VAL 100
//#define NUM_EIGEN_VECTOR 30
class AutoseamAdjacency
Modified: branches/soc-2011-avocado/blender/intern/autoseam/CMakeLists.txt
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/CMakeLists.txt 2011-07-27 16:29:28 UTC (rev 38758)
+++ branches/soc-2011-avocado/blender/intern/autoseam/CMakeLists.txt 2011-07-27 17:16:07 UTC (rev 38759)
@@ -54,6 +54,10 @@
AutoseamEigenspace.cpp
AutoseamAdjacency.h
AutoseamAdjacency.cpp
+ EigenSolver.h
+ EigenSolver.cpp
+ EigenSolverArpack.h
+ EigenSolverArpack.cpp
)
set (SRC_AUTOSEAM_ARPACK
Added: branches/soc-2011-avocado/blender/intern/autoseam/EigenSolver.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/EigenSolver.cpp (rev 0)
+++ branches/soc-2011-avocado/blender/intern/autoseam/EigenSolver.cpp 2011-07-27 17:16:07 UTC (rev 38759)
@@ -0,0 +1,58 @@
+/* $Id: AutoseamAdjacency.cpp 38737 2011-07-26 16:37:38Z shuvro $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2011 by Shuvro Sarker.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Shuvro Sarker
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "EigenSolver.h"
+#include "MEM_guardedalloc.h"
+
+
+EigenSolver::EigenSolver(int dimension, int eigen_vectors)
+{
+ matrix_dimension = dimension;
+ num_eigen_vectors = eigen_vectors;
+
+ // Allocate memories for eigenspace
+
+}
+
+int EigenSolver::multiply_matrix_vector(int dimension, double *result, double *input)
+{
+ for (int i = 0; i < A.n ; i++) {
+ *(result + i) = 0.0;
+ }
+
+ for (int k = 0; k < A.nnz; k++) {
+ *(result + A.i[k]) += A.v[k] * (*(input + A.j[k]));
+ }
+
+ return 0;
+}
+
+EigenSolver::~EigenSolver()
+{
+
+}
Added: branches/soc-2011-avocado/blender/intern/autoseam/EigenSolver.h
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/EigenSolver.h (rev 0)
+++ branches/soc-2011-avocado/blender/intern/autoseam/EigenSolver.h 2011-07-27 17:16:07 UTC (rev 38759)
@@ -0,0 +1,61 @@
+/* $Id: AutoseamAdjacency.h 38650 2011-07-24 05:24:46Z shuvro $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2011 by Shuvro Sarker.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Shuvro Sarker
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef EIGEN_SOLVER_H
+#define EIGEN_SOLVER_H
+
+struct SparseMatrix{
+ int n; // matrix dimension
+ int nnz; // number of non-zero coefficients
+ int *i; // row indices, array of size nnz;
+ int *j; // column indices, array of size nnz;
+ double *v; // non-zero coefficients, array of size nnz;
+};
+
+class EigenSolver{
+
+ protected:
+ SparseMatrix A;
+ bool is_allocated;
+ int matrix_dimension;
+ int num_eigen_vectors;
+ double *eigen_vectors; // This is of size matrix_dimension * num_eigen_vectors
+ double *eigen_values; // This is of size matrix_dimension
+
+ public:
+ EigenSolver(int dimension, int num_eigen_vectors);
+ int allocate_matrix(int dimension, int non_zero); // allocates memory for matrix
+ int set_matrix(int row, int column, double value); // sets a specific element of Sparse Matrix A
+ virtual double * calculate_eigen_space() = 0; // Declared it as pure virtual, so that subclasses must have to implement this.
+ int multiply_matrix_vector(int dimension, double *result, double *input);
+ ~EigenSolver();
+
+
+};
+
+#endif
\ No newline at end of file
Added: branches/soc-2011-avocado/blender/intern/autoseam/EigenSolverArpack.cpp
===================================================================
--- branches/soc-2011-avocado/blender/intern/autoseam/EigenSolverArpack.cpp (rev 0)
+++ branches/soc-2011-avocado/blender/intern/autoseam/EigenSolverArpack.cpp 2011-07-27 17:16:07 UTC (rev 38759)
@@ -0,0 +1,307 @@
+/* $Id: AutoseamAdjacency.cpp 38737 2011-07-26 16:37:38Z shuvro $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2011 by Shuvro Sarker.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Shuvro Sarker
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "EigenSolverArpack.h"
+#include "MEM_guardedalloc.h"
+#include <stdio.h>
+
+#define EIGEN_DEBUG_ARPACK 1
+#define NUM_EIGEN_VAL 30
+#define minimum(a,b) (a <= b) ? a : b;
+
+extern "C"{
+ extern int dsaupd_(integer *, char *, integer *, char *, integer *, doublereal *, doublereal *, integer *, doublereal *, integer *, integer *, integer *, doublereal *, doublereal *, integer *, integer *, ftnlen, ftnlen);
+ extern int dseupd_(logical *, char *, logical *, doublereal *, doublereal *, integer *, doublereal *, char *, integer *, char *, integer *, doublereal *, doublereal *, integer *, doublereal *, integer *, integer *, integer *, doublereal *, doublereal *, integer *, integer *, ftnlen, ftnlen, ftnlen);
+}
+
+
+//EigenSolverArpack:: EigenSolverArpack(int dimension)
+//{
+// matrix_dimension = dimension;
+// //num_eigen_vectors = eigen_vectors;
+//}
+EigenSolverArpack::~EigenSolverArpack()
+{
+ printf("Destructor is being called.");
+}
+
+
+EigenSolverArpack::EigenSolverArpack(int dimension, int eigen_vectors) : EigenSolver(dimension, eigen_vectors)
+{
+ //
+ // Allocate memories for eigenspace
+
+}
+
+int EigenSolverArpack:: mul_matrix_vector(int dimension, double *vec, double * result)
+{
+ int i;
+ Eigen::VectorXd output(dimension);
+ Eigen::VectorXd mul_vec(dimension);
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list