/* Temporary implementation of vector and matrix classes No attempt is made to check if the function arguments are valid */ #include #include // for sqrt() #include "linalg.h" double eps() { /* Returns the machine precision : (min { x >= 0 : 1 + x > 1 }) NB This routine should be replaced by LAPACK_LAMCH */ double Current, Last, OnePlusCurrent ; Current = 1.0 ; do { Last = Current ; Current /= 2.0 ; OnePlusCurrent = 1.0 + Current ; } while (OnePlusCurrent > 1.0) ; return Last ; } RVector::RVector() { // Constructor len=0; elements=0; (*this)=0.; } RVector::RVector(int n) { // Constructor len=n; elements=new double[len]; (*this)=0.; } RVector::RVector(RCRVector vect) { // Constructor + Copy len=vect.len; elements=new double[len]; (*this)=vect; } RCRVector RVector::operator=(RCRVector vect) { // Copy for (int i=0;i0) os << "," ; os << v.elements[i] ; } return os << ']'; } /*************************** Matrix Class ***********************/ RMatrix::RMatrix() { // Constructor Dim=0 ; Vals=0 ; (*this)=0 ; } RMatrix::RMatrix(int dim) { // Constructor Dim=dim; Vals=new double[long(Dim)*long(Dim)]; (*this)=0.; } RMatrix::RMatrix(RCRMatrix matr) { // Constructor + Copy Dim=matr.Dim; Vals=new double[long(Dim)*long(Dim)]; (*this)=matr; } RCRMatrix RMatrix::operator=(RCRMatrix mat) { // Assignment, A=B long int Len=long(Dim)*long(Dim); for (int i=0;i