// Matrix operations // // Burkhard Militzer Urbana 4-1-99 // #ifndef _MATRIXALGEBRA_ #define _MATRIXALGEBRA_ #include "Standard.h" #include "Array.h" void ludcmp(Array2 & a, const int n, Array1 & indx, double & d); void lubksb(const Array2 & a, const int n, const Array1 & indx, Array1 & b); double Determinant(const Array2 & a, const int n); void LogDeterminant(Array2 & a, const int n, double & logD, double & sign); void MultiplyMatrices(const Array2 & a, const Array2 & b, Array2 & c, int n); void InvertMatrix(const Array2 & a, Array2 & a1, const int n); double InverseUpdateRow(Array2 & a1, const Array2 & a, const int lRow, const int n); double InverseUpdateRow(Array2 & a1, const Array1 & newRow, const int lRow, const int n); double InverseUpdateColumn(Array2 & a1, const Array2 & a, const int lCol, const int n); double InverseUpdateColumn(Array2 & a1, const Array1 & newCol, const int lCol, const int n); void TransposeMatrix(Array2 & a, const int n); double TransposeInverseMatrix(const Array2 & a, Array2 & a1, const int n); double TransposeInverseUpdateRow(Array2 & a1, const Array2 & a, const int lCol, const int n); double TransposeInverseUpdateColumn(Array2 & a1, const Array2 & a, const int lRow, const int n); void SolveMatrixEquation(Array2 & a, Array1 & b, const int n); void SolveMatrixEquation(Array2 & a, const Array1 & b, Array1 & x, const int n); void SolveDiagonalMatrixEquation(Array2 & a, const Array1 & b, Array1 & x, const int n); void SolveDiagonalMatrixEquation(Array2 & a, Array1 & x, const int n); void SolveMatrixEquationPreserveA(const Array2 & a, const Array1 & b, Array1 & x, const int n); void MatrixTimesVector(const Array2 & a, const Array1 & x, Array1 & b, int n); void TransposeMatrixTimesVector(const Array2 & a, const Array1 & x, Array1 & b, int n); void WriteMatrix(const Array2 & a, int n1= -1, int n2= -1); void WriteVector(const Array1 & a, int n= -1); void WriteMatrixNonZero(const Array2 & a, double limit=1e-10, int n1=-1, int n2=-1); void WriteVectorNonZero(const Array1 & a, double limit=1e-10, int n=-1); void SaveVector(const string & filename, const Array1 & a); void SaveVectorText(const string & filename, const Array1 & a, const bool saveDimensions=false, const int p=8); void LoadVector(const string & filename, Array1 & a, const bool fixedDimensions=false); void LoadVectorText(const string & filename, Array1 & a, const bool fixedDimensions=false); void SaveMatrix(const string & filename, const Array2 & a); void SaveMatrixText(const string & filename, const Array2 & a, const bool saveDimensions=false, const int p=8); void LoadMatrix(const string & filename, Array2 & a, const bool fixedDimensions=false); void LoadMatrixText(const string & filename, Array2 & a, const bool readDimensions=false, const bool fixedDimensions=false); Array2 IdentityMatrix(const int nF); #endif // _MATRIXALGEBRA_