LINEAR++ library: AFF to LAPACK
dposv_if.cc
Go to the documentation of this file.
1 
35 #define LINEAR_DPOSV_IF_CC_VERSION \
36  "TF_DPOSV_IF_CC V1.1"
37 
38 #include <iostream>
39 #include <aff/fortranshape.h>
40 #include <linearxx/f77lapack.h>
41 #include <linearxx/lapackxx.h>
42 #include <linearxx/error.h>
43 
44 namespace linear {
45 
46 namespace lapack {
47 
87  void dposv(char UPLO, TDmatrix& A, TDmatrix& B, int& INFO, const bool& debug)
88  {
89  LINEAR_debug(debug, "dposv", "solve system of linear equations");
90  // convert to Fortran interfacing array
91  typedef aff::FortranArray<TDmatrix> Tfortranarray;
92  Tfortranarray FA(A);
93  Tfortranarray FB(B);
94  LINEAR_assert((FA.last(0)==FA.last(1)),
95  "ERROR (dposv): Matrix A is not a square matrix");
96  LINEAR_assert((FB.last(0)==FA.last(0)),
97  "ERROR (dposv): Dimension of right hand side "
98  "does not match");
99  f77lapack::integer N=FA.last(0);
100  f77lapack::integer NRHS=FB.last(1);
101  f77lapack::integer LDA=FA.dimlast(0);
102  f77lapack::integer LDB=FB.dimlast(0);
103  f77lapack::integer f77INFO;
104  f77lapack::doublereal* PA=FA.castedpointer<f77lapack::doublereal>();
105  f77lapack::doublereal* PB=FB.castedpointer<f77lapack::doublereal>();
106  LINEAR_debug(debug, "dposv", "N: " << N
107  << " NRHS: " << NRHS
108  << " LDA: " << LDA
109  << " LDB: " << LDB);
110  LINEAR_debug(debug, "dposv", "first in A: " << *PA
111  << " first in B: " << *PB);
112  f77lapack::dposv_(&UPLO, &N, &NRHS, PA, &LDA, PB, &LDB, &f77INFO);
113  LINEAR_debug(debug, "dposv", "INFO: " << f77INFO);
114  INFO=f77INFO;
115  LINEAR_LAPACK_failure((INFO<0),"dposv",
116  "the -INFO-th argument had an illegal value",
117  INFO);
118  LINEAR_LAPACK_failure((INFO>0),"dposv",
119  "the leading INFO-th order is not positive definite",
120  INFO);
121  } // dposv
122 
124  TDmatrix dposv(const TDmatrix::Tcoc& A,
125  const TDmatrix::Tcoc& B,
126  char UPLO, const bool& debug)
127  {
128  // factorized Matrix
129  TDmatrix M(A.copyout());
130  // return value
131  TDmatrix X=B.copyout();
132  int INFO;
133  dposv(UPLO, M, X, INFO, debug);
134  return(X);
135  } // dposv
136 
137 } // namespace lapack
138 
139 } // namespace linear
140 
141 /* ----- END OF dposv_if.cc ----- */
long int integer
Definition: f77lapack.h:61
prototypes for C++ LAPACK interface functions (prototypes)
Exception class for this library (prototypes)
#define LINEAR_debug(C, N, M)
produce debug outputCode which uses this macro has to include <iostream>
Definition: error.h:195
aff::Array< double > TDmatrix
Definition: matrix.h:46
#define LINEAR_LAPACK_failure(C, N, M, V)
Check an assertion for a LAPACK return value and report by throwing an exception. ...
Definition: error.h:166
void dposv_(char *uplo, integer *m, integer *k, doublereal *A, integer *lda, doublereal *X, integer *ldx, integer *info)
double doublereal
Definition: f77lapack.h:62
Modules of liblinearxx.a.
Definition: error.cc:43
void dposv(char UPLO, TDmatrix &A, TDmatrix &B, int &INFO, const bool &debug)
Compute the solution to a real system of linear equations A * X = B.
Definition: dposv_if.cc:87
#define LINEAR_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:176
prototypes for interfaced F77 LAPACK subroutines (prototypes)