VERB_code_2.3
zgbmatrix-lapack.hpp
1 //=============================================================================
5 inline long zgbmatrix::zgbsv(zgematrix& mat)
6 {
7 #ifdef CPPL_VERBOSE
8  std::cerr << "# [MARK] zgbmatrix::zgbsv(zgematrix&)"
9  << std::endl;
10 #endif//CPPL_VERBOSE
11 
12 #ifdef CPPL_DEBUG
13  if(M!=N || N!=mat.M){
14  std::cerr << "[ERROR] zgbmatrix::zgbsv(zgematrix&) " << 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  zgbmatrix 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  zgbsv_(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] zgbmatrix::zgbsv(zgematrix&) "
36  << "Serious trouble happend. INFO = "<< INFO << "." << std::endl;
37  }
38  return INFO;
39 }
40 
41 //=============================================================================
45 inline long zgbmatrix::zgbsv(zcovector& vec)
46 {
47 #ifdef CPPL_VERBOSE
48  std::cerr << "# [MARK] zgbmatrix::zgbsv(zcovector&)"
49  << std::endl;
50 #endif//CPPL_VERBOSE
51 
52 #ifdef CPPL_DEBUG
53  if(M!=N || N!=vec.L){
54  std::cerr << "[ERROR] zgbmatrix::zgbsv(zcovector&) " << 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  zgbmatrix 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  zgbsv_(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] zgbmatrix::zgbsv(zcovector&) "
76  << "Serious trouble happend. INFO = "<< INFO << "." << std::endl;
77  }
78  return INFO;
79 }
std::complex< double > & operator()(const long &, const long &)
Definition: zgbmatrix-io.hpp:3
double max(double v1, double v2)
Return maximum.
Definition: variousFunctions.cpp:355
friend _zgematrix i(const zgbmatrix &)
Definition: zgbmatrix-calc.hpp:22
long const & n
matrix column size (readable)
Definition: zgbmatrix.hpp:17
long zgbsv(zgematrix &)
Definition: zgbmatrix-lapack.hpp:5
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
Complex Double-precision General Band Matrix Class.
Definition: zgbmatrix.hpp:3
Complex Double-precision Column Vector Class.
Definition: zcovector.hpp:3
friend void swap(zgbmatrix &, zgbmatrix &)
Definition: zgbmatrix-misc.hpp:167