/* Example programs from the book Scientific and Engineering Programming in C++: An Introduction with Advanced Techniques and Examples, Addison-Wesley, 1994. (c) COPYRIGHT INTERNATIONAL BUSINESS MACHINES CORPORATION 1994. ALL RIGHTS RESERVED. See README file for further details. */ #include "SciEng/utils.h" #include "LapackWrap/LapackSubroutines.h" template SymPosDefPackedLURep::Factored::Factored(SymPosDefPackedLURep::Unfactored* mp) : facmat_p(mp) { int info; // info return from LAPACK factor routine. LapackSubroutines::xpptrf("Upper", mp->shape(0), &(*mp)(0,0), info); if (info != 0) throw LapackErr::NotPositiveDefinite(info); } template void SymPosDefPackedLURep::Factored::solve(ConcreteFortranArray2d& b) { int info; // info return from LAPACK solve routine. LapackSubroutines::xpptrs("Upper", facmat_p->shape(0), b.shape(1), &(*facmat_p)(0,0), b.firstDatum(), b.shape(0), info); if (info != 0) throw LapackErr::UnableToSolve(info); } template void SymPosDefPackedLURep::Factored::solve(ConcreteFortranArray2d& x, const ConcreteFortranArray2d& b) { x = b; // LAPACK overwrites for LU decompositions. solve(x); } template void SymPosDefPackedLURep::Factored::solve(ConcreteFortranArray1d& b) { int info; // info return from LAPACK solve routine. LapackSubroutines::xpptrs("Upper", facmat_p->shape(0), b.shape(1), &(*facmat_p)(0,0), b.firstDatum(), b.shape(0), info); if (info != 0) throw LapackErr::UnableToSolve(info); } template void SymPosDefPackedLURep::Factored::solve(ConcreteFortranArray1d& x, const ConcreteFortranArray1d& b) { x = b; // LAPACK overwrites for LU decompositions. solve(x); }