aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/spbench
diff options
context:
space:
mode:
authorGravatar Desire NUENTSA <desire.nuentsa_wakam@inria.fr>2012-07-19 18:03:44 +0200
committerGravatar Desire NUENTSA <desire.nuentsa_wakam@inria.fr>2012-07-19 18:03:44 +0200
commit59642da88bf83709e918667680e4ed63af4c31e5 (patch)
treee47446315cbccb3bd67aaa35d8218652a8117acd /bench/spbench
parentb0cba2d988de3f4535e0b7ac9799b19700e09b7c (diff)
Add exception handler to memory allocation
Diffstat (limited to 'bench/spbench')
-rw-r--r--bench/spbench/CMakeLists.txt2
-rw-r--r--bench/spbench/test_sparseLU.cpp21
2 files changed, 12 insertions, 11 deletions
diff --git a/bench/spbench/CMakeLists.txt b/bench/spbench/CMakeLists.txt
index 4b3c6f8e3..a093cc5d9 100644
--- a/bench/spbench/CMakeLists.txt
+++ b/bench/spbench/CMakeLists.txt
@@ -67,4 +67,4 @@ add_executable(spsolver sp_solver.cpp)
target_link_libraries (spsolver ${SPARSE_LIBS})
add_executable(test_sparseLU test_sparseLU.cpp)
-target_link_libraries (test_sparseLU ${SPARSE_LIBS}) \ No newline at end of file
+target_link_libraries (test_sparseLU ${SPARSE_LIBS})
diff --git a/bench/spbench/test_sparseLU.cpp b/bench/spbench/test_sparseLU.cpp
index 6fbf03454..31273add5 100644
--- a/bench/spbench/test_sparseLU.cpp
+++ b/bench/spbench/test_sparseLU.cpp
@@ -13,13 +13,14 @@ using namespace Eigen;
int main(int argc, char **args)
{
- SparseMatrix<double, ColMajor> A;
- typedef SparseMatrix<double, ColMajor>::Index Index;
- typedef Matrix<double, Dynamic, Dynamic> DenseMatrix;
- typedef Matrix<double, Dynamic, 1> DenseRhs;
- VectorXd b, x, tmp;
-// SparseLU<SparseMatrix<double, ColMajor>, AMDOrdering<int> > solver;
- SparseLU<SparseMatrix<double, ColMajor>, COLAMDOrdering<int> > solver;
+ typedef complex<double> scalar;
+ SparseMatrix<scalar, ColMajor> A;
+ typedef SparseMatrix<scalar, ColMajor>::Index Index;
+ typedef Matrix<scalar, Dynamic, Dynamic> DenseMatrix;
+ typedef Matrix<scalar, Dynamic, 1> DenseRhs;
+ Matrix<scalar, Dynamic, 1> b, x, tmp;
+// SparseLU<SparseMatrix<scalar, ColMajor>, AMDOrdering<int> > solver;
+ SparseLU<SparseMatrix<scalar, ColMajor>, COLAMDOrdering<int> > solver;
ifstream matrix_file;
string line;
int n;
@@ -36,7 +37,7 @@ int main(int argc, char **args)
if (iscomplex) { cout<< " Not for complex matrices \n"; return -1; }
if (isvector) { cout << "The provided file is not a matrix file\n"; return -1;}
if (sym != 0) { // symmetric matrices, only the lower part is stored
- SparseMatrix<double, ColMajor> temp;
+ SparseMatrix<scalar, ColMajor> temp;
temp = A;
A = temp.selfadjointView<Lower>();
}
@@ -72,8 +73,8 @@ int main(int argc, char **args)
timer.stop();
cout << "solve time " << timer.value() << std::endl;
/* Check the accuracy */
- VectorXd tmp2 = b - A*x;
- double tempNorm = tmp2.norm()/b.norm();
+ Matrix<scalar, Dynamic, 1> tmp2 = b - A*x;
+ scalar tempNorm = tmp2.norm()/b.norm();
cout << "Relative norm of the computed solution : " << tempNorm <<"\n";
cout << "Number of nonzeros in the factor : " << solver.nnzL() + solver.nnzU() << std::endl;