VERB_code_2.3
dgbmatrix-lapack.hpp
1 //=============================================================================
5 inline long dgbmatrix::dgbsv(dgematrix& mat)
6 {
7 #ifdef CPPL_VERBOSE
8  std::cerr << "# [MARK] dgbmatrix::dgbsv(dgematrix&)"
9  << std::endl;
10 #endif//CPPL_VERBOSE
11 
12 #ifdef CPPL_DEBUG
13  if(M!=N || N!=mat.M){
14  std::cerr << "[ERROR] dgbmatrix::dgbsv(dgematrix&) " << std::endl
15  << "These matrix and vector cannot be solved." << std::endl
16  << "Your input was (" << M << "x" << N << ") and ("
17  << mat.M << "x" << mat.N << ")." << std::endl;
18  exit(1);
19  }
20 #endif//CPPL_DEBUG
21 
22  dgbmatrix newmat(M,N,KL,KU+KL);
23  for(long i=0; i<M; i++){ for(long j=max(0,i-KL); j<min(N,i+KU+1); j++){
24  newmat(i,j) =operator()(i,j);
25  }}
26 
27  long NRHS(mat.N), LDAB(2*KL+KU+1),
28  *IPIV(new long[N]), LDB(mat.M), INFO(1);
29  dgbsv_(N, KL, KU, NRHS, newmat.Array, LDAB, IPIV, mat.Array, LDB, INFO);
30  delete [] IPIV;
31 
32  swap(*this,newmat);
33 
34  if(INFO!=0){
35  std::cerr << "[WARNING] dgbmatrix::dgbsv(dgematrix&) "
36  << "Serious trouble happend. INFO = "<< INFO << "." << std::endl;
37  }
38  return INFO;
39 }
40 
41 //=============================================================================
45 inline long dgbmatrix::dgbsv(dcovector& vec)
46 {
47 #ifdef CPPL_VERBOSE
48  std::cerr << "# [MARK] dgbmatrix::dgbsv(dcovector&)"
49  << std::endl;
50 #endif//CPPL_VERBOSE
51 
52 #ifdef CPPL_DEBUG
53  if(M!=N || N!=vec.L){
54  std::cerr << "[ERROR] dgbmatrix::dgbsv(dcovector&) " << std::endl
55  << "These matrix and vector cannot be solved." << std::endl
56  << "Your input was (" << M << "x" << N << ") and ("
57  << vec.L << ")." << std::endl;
58  exit(1);
59  }
60 #endif//CPPL_DEBUG
61 
62  dgbmatrix newmat(M,N,KL,KU+KL);
63  for(long i=0; i<M; i++){ for(long j=max(0,i-KL); j<min(N,i+KU+1); j++){
64  newmat(i,j) =operator()(i,j);
65  }}
66 
67  long NRHS(1), LDAB(2*KL+KU+1),
68  *IPIV(new long[N]), LDB(vec.L), INFO(1);
69  dgbsv_(N, KL, KU, NRHS, newmat.Array, LDAB, IPIV, vec.Array, LDB, INFO);
70  delete [] IPIV;
71 
72  swap(*this,newmat);
73 
74  if(INFO!=0){
75  std::cerr << "[WARNING] dgbmatrix::dgbsv(dgematrix&) "
76  << "Serious trouble happend. INFO = "<< INFO << "." << std::endl;
77  }
78  return INFO;
79 }
friend _dgematrix i(const dgbmatrix &)
Definition: dgbmatrix-calc.hpp:22
double max(double v1, double v2)
Return maximum.
Definition: variousFunctions.cpp:355
double & operator()(const long &, const long &)
Definition: dgbmatrix-io.hpp:3
Real Double-precision General Dence Matrix Class.
Definition: dgematrix.hpp:3
Real Double-precision General Band Matrix Class.
Definition: dgbmatrix.hpp:3
Real Double-precision Column Vector Class.
Definition: dcovector.hpp:3
long dgbsv(dgematrix &)
Definition: dgbmatrix-lapack.hpp:5
friend void swap(dgbmatrix &, dgbmatrix &)
Definition: dgbmatrix-misc.hpp:167