CPPLapack
 All Classes Files Functions Variables Friends Pages
zgbmatrix-lapack.hpp
Go to the documentation of this file.
1 //=============================================================================
2 /*! solve A*X=Y using zgbsv\n
3  The argument is zgematrix Y. Y is overwritten and become the solution X.
4  A is also overwritten. */
5 inline CPPL_INT zgbmatrix::zgbsv(zgematrix& mat)
6 {CPPL_VERBOSE_REPORT;
7 #ifdef CPPL_DEBUG
8  if(m!=n || n!=mat.m){
9  ERROR_REPORT;
10  std::cerr << "These matrix and vector cannot be solved." << std::endl
11  << "Your input was (" << m << "x" << n << ") and (" << mat.m << "x" << mat.n << ")." << std::endl;
12  exit(1);
13  }
14 #endif//CPPL_DEBUG
15 
16  zgbmatrix newmat(m,n,kl,ku+kl);
17  for(CPPL_INT i=0; i<m; i++){
18  const CPPL_INT jmax =std::min(n,i+ku+1);
19  for(CPPL_INT j=std::max(CPPL_INT(0),i-kl); j<jmax; j++){
20  newmat(i,j) =operator()(i,j);
21  }
22  }
23 
24  CPPL_INT NRHS(mat.n), LDAB(2*kl+ku+1), *IPIV(new CPPL_INT[n]), LDB(mat.m), INFO(1);
25  zgbsv_(&n, &kl, &ku, &NRHS, newmat.array, &LDAB, IPIV, mat.array, &LDB, &INFO);
26  delete [] IPIV;
27 
28  swap(*this,newmat);
29 
30  if(INFO!=0){
31  WARNING_REPORT;
32  std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
33  }
34  return INFO;
35 }
36 
37 //=============================================================================
38 /*! solve A*x=y using zgbsv\n
39  The argument is zcovector y. y is overwritten and become the solution x.
40  A is also overwritten. */
41 inline CPPL_INT zgbmatrix::zgbsv(zcovector& vec)
42 {CPPL_VERBOSE_REPORT;
43 #ifdef CPPL_DEBUG
44  if(m!=n || n!=vec.l){
45  ERROR_REPORT;
46  std::cerr << "These matrix and vector cannot be solved." << std::endl
47  << "Your input was (" << m << "x" << n << ") and (" << vec.l << ")." << std::endl;
48  exit(1);
49  }
50 #endif//CPPL_DEBUG
51 
52  zgbmatrix newmat(m,n,kl,ku+kl);
53  for(CPPL_INT i=0; i<m; i++){
54  const CPPL_INT jmax =std::min(n,i+ku+1);
55  for(CPPL_INT j=std::max(CPPL_INT(0),i-kl); j<jmax; j++){
56  newmat(i,j) =operator()(i,j);
57  }
58  }
59 
60  CPPL_INT NRHS(1), LDAB(2*kl+ku+1), *IPIV(new CPPL_INT[n]), LDB(vec.l), INFO(1);
61  zgbsv_(&n, &kl, &ku, &NRHS, newmat.array, &LDAB, IPIV, vec.array, &LDB, &INFO);
62  delete [] IPIV;
63 
64  swap(*this,newmat);
65 
66  if(INFO!=0){
67  WARNING_REPORT;
68  std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
69  }
70  return INFO;
71 }
comple * array
1D array to store vector data
Definition: zcovector.hpp:10
comple & operator()(const CPPL_INT &, const CPPL_INT &)
Definition: zgbmatrix-io.hpp:3
CPPL_INT l
vector size
Definition: zcovector.hpp:9
CPPL_INT zgbsv(zgematrix &)
friend _zgematrix i(const zgbmatrix &)
CPPL_INT n
matrix column size
Definition: zgbmatrix.hpp:10
CPPL_INT ku
upper band width
Definition: zgbmatrix.hpp:12
CPPL_INT n
matrix column size
Definition: zgematrix.hpp:10
Complex Double-precision General Dence Matrix Class.
Definition: zgematrix.hpp:3
comple * array
1D array to store matrix data
Definition: zgematrix.hpp:11
CPPL_INT m
matrix row size
Definition: zgbmatrix.hpp:9
Complex Double-precision General Band Matrix Class.
Definition: zgbmatrix.hpp:3
CPPL_INT m
matrix row size
Definition: zgematrix.hpp:9
CPPL_INT kl
lower band width
Definition: zgbmatrix.hpp:11
Complex Double-precision Column Vector Class.
Definition: zcovector.hpp:3
friend void swap(zgbmatrix &, zgbmatrix &)
comple * array
1D array to store matrix data
Definition: zgbmatrix.hpp:13