Exemplo n.º 1
0
void
AccpmLALinSolve(const RealMatrix &A, bool cholesky, RealMatrix &X, const RealMatrix &B)
{
  if (!cholesky) {
    AccpmLALinearSolve(A, X, B);
    return;
  }
  char uplo = 'L';
  long int n = A.size(0);
  long int lda = A.inc(0) * A.gdim(0);
  long int nrhs = B.size(1);
  long int ldb = B.inc(0) * B.gdim(0);
  long int info;
  RealMatrix L(A);

  X.inject(B);
  //double alpha = 1;
  //F77NAME(dtrsm)("L","U","T","N",&n,&nrhs,&alpha,&A(0,0),&n,&X(0,0),&n);
  //F77NAME(dtrsm)("L","U","N","N",&n,&nrhs,&alpha,&A(0,0),&n,&X(0,0),&n);
 
  //F77NAME(dpotrs)(&uplo, &n, &nrhs, (doublereal *)&L(0,0), &lda, &X(0,0), &ldb, &info);
  F77NAME(dpotrs)(&uplo, &n, &nrhs, &L(0,0), &lda, &X(0,0), &ldb, &info);
  if (info < 0) {
    std::cerr << "AccpmLALinSolve: argument " << -info << " is invalid" 
  	      << std::endl;
  }
  
}
Exemplo n.º 2
0
int
AccpmLASymmLinSolve(SymmetricMatrix &A, RealMatrix &X, const RealMatrix &B)
{
  LaLowerTriangMatDouble L(A);
  char uplo = 'L';
  long int n = A.size(0);
  long int lda = A.inc(0) * A.gdim(0);
  long int nrhs = B.size(1);
  long int ldb = B.inc(0) * B.gdim(0);
  long int info;
  
  X.inject(B);

  F77NAME(dposv) (&uplo, &n, &nrhs, &L(0,0), &lda, &X(0,0), &ldb, &info);
 
  if (info > 0) {
    std::cerr << "AccpmLASymmLinSolve: Symmetric Matrix is not positive-definite." 
	      << std::endl;
  } else if (info < 0) {
    std::cerr << "AccpmLASymmLinSolve: argument " << -info << " is invalid" 
	      << std::endl;
  }
  return info;
}