// =====================< FACTPLR.HPP >======================= // * Class FactoredPLR derived from Factored * // * Class FactoredGauss derived from FactoredPLR * // * Class FactoredCrout derived from FactoredPLR * // * Description: Chapter 15 * // * Scientific C++ Building Numerical Libraries * // * the Object-Oriented Way * // * by G. Buzzi-Ferraris * // * Addison-Wesley (1993) * // =========================================================== // * These classes permit linear system solutions * // * and solutions to related problems only with * // * square matrices * // * These are the ones that require the least time for * // * calculation. * // *********************************************************** #ifndef FACTOREDPLR_HPP #define FACTOREDPLR_HPP // =========================================================== // ============ prototype PLR functions =================== // =========================================================== char GaussFactorization (int n,float **a,int *indx,int *signd); char CroutFactorization (int n,float **a,int *indx,int *signd); void PLRSolution (int n,float **a,float *b,int *indx); void PLRTransposeSolution (int n,float **a,float *b,int *indx); float PLRNormInvEst (int n,float **a,int *indx); // =========================================================== // ================ class FactoredPLR ==================== // =========================================================== class Vector; class Matrix; class FactoredPLR : public Factored { protected: int *indx; int signd; // initialisation of constructors void FurtherInit(void); // initialisation of special vectors (indx) virtual void SpecificInitialize(void); // deinitialisation of special vectors (indx) virtual void SpecificDeinitialize(void); // constructor A('*',3,5); FactoredPLR(char ch,int rows,int columns) : Factored(ch,rows,columns){FurtherInit();} // =========================================================== // ************* Functions for linear algebra ************** // =========================================================== virtual void Factorization(void) = 0; virtual void Solution(Vector *bx); virtual void Solution(const Vector &b,Vector *x); virtual void TransposeSolution(Vector *bx); virtual void TransposeSolution (const Vector &b,Vector *x); virtual void Solution(Matrix *BX); virtual void Solution(const Matrix &B,Matrix *X); virtual float Condition(void); virtual double DeterminantEvaluation(void); public: // =========================================================== // ****************** constructors *********************** // =========================================================== // default constructor type Factored A; FactoredPLR(void) : Factored(){FurtherInit();} // copy constructor FactoredPLR(const Factored &rval) : Factored(rval){FurtherInit();} // constructor A(3,5); FactoredPLR(int rows,int columns) : Factored(rows,columns){FurtherInit();} // constructor A(3,5,w); FactoredPLR(int rows,int columns,float *initvalues) : Factored(rows,columns,initvalues){FurtherInit();} // constructor from Matrix FactoredPLR(const Matrix &rval) : Factored(rval){FurtherInit();} // makes a submatrix with rows,columns FactoredPLR(int rows,int columns,const Matrix &rval) : Factored(rows,columns,rval){FurtherInit();} // as above, commencing from irow,jcol FactoredPLR(int rows,int columns,int irow, int jcol,const Matrix &rval) : Factored(rows,columns,irow,jcol,rval){FurtherInit();} // =========================================================== // ******************** destructor *********************** // =========================================================== ~FactoredPLR(void); }; // =========================================================== // =============== class FactoredGauss =================== // =========================================================== class FactoredGauss : public FactoredPLR { public: // =========================================================== // ****************** constructors *********************** // =========================================================== // default constructor type Factored A; FactoredGauss(void) : FactoredPLR(){} // copy constructor FactoredGauss(const Factored &rval) : FactoredPLR(rval){} // constructor A(3,5); FactoredGauss(int rows,int columns) : FactoredPLR(rows,columns){} // constructor A(2,2,1.,2.,3.,4.); FactoredGauss(int rows,int columns,double a11,...); // constructor A(3,5,w); FactoredGauss(int rows,int columns,float *initvalues) : FactoredPLR(rows,columns,initvalues){} // constructor from Matrix FactoredGauss(const Matrix &rval) : FactoredPLR(rval){} // makes a submatrix with rows,columns FactoredGauss(int rows,int columns,const Matrix &rval) : FactoredPLR(rows,columns,rval){} // as above, commencing from irow,jcol FactoredGauss(int rows,int columns, int irow,int jcol,const Matrix &rval) : FactoredPLR(rows,columns,irow,jcol,rval){} // =========================================================== // ******************** destructor *********************** // =========================================================== ~FactoredGauss(void); // =========================================================== // *************** assignment operators ****************** // =========================================================== void operator = (const FactoredGauss &rval); FactoredGauss &operator = (const Matrix &rval); // =========================================================== // ************ Functions for linear algebra *************** // =========================================================== virtual void Factorization(void); }; // fine class FactoredGauss // =========================================================== // =============== class FactoredCrout =================== // =========================================================== class FactoredCrout : public FactoredPLR { public: // =========================================================== // ****************** constructors *********************** // =========================================================== // default constructor type Factored A; FactoredCrout(void) : FactoredPLR(){} // copy constructor FactoredCrout(const Factored &rval) : FactoredPLR(rval){} // constructor A(3,5); FactoredCrout(int rows,int columns) : FactoredPLR(rows,columns){} // constructor A(2,2,1.,2.,3.,4.); FactoredCrout(int rows,int columns,double a11,...); // constructor A(3,5,w); FactoredCrout(int rows,int columns,float *initvalues) : FactoredPLR(rows,columns,initvalues){} // constructor from Matrix FactoredCrout(const Matrix &rval) : FactoredPLR(rval){} // make a submatrix with rows,columns FactoredCrout(int rows,int columns,const Matrix &rval) : FactoredPLR(rows,columns,rval){} //as above, commencing from irow,jcol FactoredCrout(int rows,int columns,int irow, int jcol,const Matrix &rval) : FactoredPLR(rows,columns,irow,jcol,rval){} // =========================================================== // ******************** destructor *********************** // =========================================================== ~FactoredCrout(void); // =========================================================== // *************** assignment operators ******************* // =========================================================== void operator = (const FactoredCrout &rval); FactoredCrout &operator = (const Matrix &rval); // =========================================================== // ************* Functions for linear algebra ************** // =========================================================== virtual void Factorization(void); }; // fine class FactoredCrout #endif FACTOREDPLR_HPP