LINEAR++ library: AFF to LAPACK

◆ dposv() [1/2]

void linear::lapack::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.

Compute the solution to a real system of linear equations A * X = B.

Parameters
UPLO(input) CHARACTER*1 = 'U': Upper triangle of A is stored; = 'L': Lower triangle of A is stored.
A(input/output) DOUBLE PRECISION array, dimension (LDA,N) On entry, the symmetric matrix A. If UPLO = 'U', the leading N-by-N upper triangular part of A con­ tains the upper triangular part of the matrix A, and the strictly lower triangular part of A is not referenced. If UPLO = 'L', the leading N-by-N lower triangular part of A contains the lower tri­ angular part of the matrix A, and the strictly upper triangular part of A is not referenced. On exit, if INFO = 0, the factor U or L from the Cholesky factorization A = U**T*U or A = L*L**T.
B(input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) On entry, the N-by-NRHS right hand side matrix B. On exit, if INFO = 0, the N-by-NRHS solution matrix X.
INFO(output) INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an ille­ gal value > 0: if INFO = i, the leading minor of order i of A is not positive definite, so the factorization could not be completed, and the solution has not been computed.
debug(input) bool switch debug messages on

Definition at line 87 of file dposv_if.cc.

References dposv_(), LINEAR_assert, LINEAR_debug, and LINEAR_LAPACK_failure.

Referenced by dposv(), main(), and test().

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
long int integer
Definition: f77lapack.h:61
#define LINEAR_debug(C, N, M)
produce debug outputCode which uses this macro has to include <iostream>
Definition: error.h:195
#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
#define LINEAR_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:176
Here is the call graph for this function:
Here is the caller graph for this function: