Added interface and test for lapack tridiagonal solver.

This commit is contained in:
Atgeirr Flø Rasmussen
2012-03-01 14:36:10 +01:00
parent 21d118959b
commit f02e1e9ff7
3 changed files with 56 additions and 1 deletions

View File

@@ -71,6 +71,16 @@ void dgetrs_(const char *trans, const MAT_SIZE_T *n,
const MAT_SIZE_T *ipiv , double *B,
const MAT_SIZE_T *ldb , MAT_SIZE_T *info);
/* B <- A \ B, tridiagonal A with bands DL, D, DU */
void dgtsv_(const MAT_SIZE_T *n ,
const MAT_SIZE_T *nrhs ,
double *DL ,
double *D ,
double *DU ,
double *B ,
const MAT_SIZE_T *ldb ,
MAT_SIZE_T *info);
/* A <- chol(A) */
void dpotrf_(const char *uplo, const MAT_SIZE_T *n,
double *A , const MAT_SIZE_T *lda,

View File

@@ -18,7 +18,9 @@ test_readpolymer \
test_readvector \
test_sf2p \
test_writeVtkData \
test_column_extract \
unit_test \
test_lapack \
test_column_extract \
unit_test
bo_resprop_test_SOURCES = bo_resprop_test.cpp
@@ -36,6 +38,7 @@ test_writeVtkData_SOURCES = test_writeVtkData.cpp
test_column_extract_SOURCES = test_column_extract.cpp
test_column_extract_LDADD = $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LDADD)
unit_test_SOURCES = unit_test.cpp
test_lapack_SOURCES = test_lapack.cpp
if UMFPACK
noinst_PROGRAMS += test_cfs_tpfa

42
tests/test_lapack.cpp Normal file
View File

@@ -0,0 +1,42 @@
/*
Copyright 2012 SINTEF ICT, Applied Mathematics.
This file is part of the Open Porous Media project (OPM).
OPM 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 3 of the License, or
(at your option) any later version.
OPM 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 OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <opm/core/linalg/blas_lapack.h>
#include <iostream>
int main()
{
const int N = 5;
const int nrhs = 1;
double DU[N-1] = { 2.1, -1.0, 1.9, 8.0 };
double D[N] = { 3.0, 2.3, -5.0, -0.9, 7.1 };
double DL[N-1] = { 3.4, 3.6, 7.0, -6.0 };
double B[N] = { 2.7, -0.5, 2.6, 0.6, 2.7 };
int ldb = 1;
int info = 0;
dgtsv_(&N, &nrhs, DL, D, DU, B, &N, &info);
if (info == 0) {
for (int i = 0; i < N; ++i) {
std::cout << B[i] << ' ';
}
std::cout << std::endl;
} else {
std::cerr << "Something went wrong in dgtsv_()\n";
}
}