Changeset 508 in Sophya for trunk/SophyaLib/NTools/cvector.cc
- Timestamp:
- Oct 25, 1999, 12:36:22 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/NTools/cvector.cc
r307 r508 6 6 7 7 //++ 8 // Class Vector8 // Class OVector 9 9 // Lib Outils++ 10 10 // include cvector.h … … 16 16 //++ 17 17 // Links Parents 18 // Matrix18 // OMatrix 19 19 //-- 20 20 … … 24 24 25 25 //++ 26 Vector::Vector(int n)26 OVector::OVector(int n) 27 27 // 28 28 // Constructeur, n = nombre d'éléments. 29 29 //-- 30 : Matrix(n, 1)30 : OMatrix(n, 1) 31 31 {END_CONSTRUCTOR} 32 32 33 33 34 34 //++ 35 Vector::Vector(int n, double* values)35 OVector::OVector(int n, double* values) 36 36 // 37 37 // Constructeur, à partir des valeurs. Pas d'allocation. 38 38 //-- 39 : Matrix(n, 1, values)39 : OMatrix(n, 1, values) 40 40 {END_CONSTRUCTOR} 41 41 42 42 43 43 //++ 44 Vector::Vector(constVector& v)44 OVector::OVector(const OVector& v) 45 45 // 46 46 // Constructeur par copie. 47 47 //-- 48 : Matrix(v)48 : OMatrix(v) 49 49 {END_CONSTRUCTOR} 50 50 51 51 52 52 //++ 53 Vector::Vector(constMatrix& a)53 OVector::OVector(const OMatrix& a) 54 54 // 55 55 // Constructeur par "copie" à partir d'une matrice, qui doit avoir une seule colonne. … … 58 58 // sizeMismatchErr si la matrice a plus d'une colonne 59 59 //-- 60 : Matrix(a.nr,1) //Matrix(a) ne marche pas, pourquoi ???? bug gcc ???60 : OMatrix(a.nr,1) // OMatrix(a) ne marche pas, pourquoi ???? bug gcc ??? 61 61 { 62 62 if (a.nc != 1) THROW(sizeMismatchErr); … … 66 66 67 67 //++ 68 Vector::Vector(const TVector<r_8>& v)68 OVector::OVector(const TVector<r_8>& v) 69 69 // 70 70 // Constructeur par "copie" a partir d'un TVector<r_8>. 71 71 // Attention, les donnees sont partagees. 72 72 //-- 73 : Matrix(v)73 : OMatrix(v) 74 74 { 75 75 } … … 87 87 88 88 //++ 89 Vector&Vector::operator = (double x)89 OVector& OVector::operator = (double x) 90 90 // 91 91 // Affectation à partir d'un scalaire. Tous les éléments prennent cette valeur. … … 98 98 99 99 //++ 100 double operator* (const Vector& v1, constVector& v2)100 double operator* (const OVector& v1, const OVector& v2) 101 101 // 102 102 // Produit scalaire entre deux vecteurs. … … 117 117 118 118 //++ 119 // Vector operator* (constVector& v, double b)119 // OVector operator* (const OVector& v, double b) 120 120 // multiplication par un scalaire. 121 121 //-- 122 122 123 123 //++ 124 // Vector operator* (const Matrix& a, constVector& b)124 // OVector operator* (const OMatrix& a, const OVector& b) 125 125 // produit matrice*vecteur. 126 126 //-- … … 144 144 145 145 //++ 146 double LinSolveInPlace( Matrix& a,Vector& b)146 double LinSolveInPlace(OMatrix& a, OVector& b) 147 147 // 148 148 // Résolution du système A*C = B … … 152 152 if (a.NCol() != a.NRows()) THROW(sizeMismatchErr); 153 153 154 return Matrix::GausPiv(a,b);155 } 156 157 158 //++ 159 double LinSolve(const Matrix& a, const Vector& b,Vector& c)154 return OMatrix::GausPiv(a,b); 155 } 156 157 158 //++ 159 double LinSolve(const OMatrix& a, const OVector& b, OVector& c) 160 160 // 161 161 // Résolution du système A*C = B, avec C retourné dans B … … 165 165 if (a.NCol() != a.NRows()) THROW(sizeMismatchErr); 166 166 c = b; 167 Matrix a1(a);168 return Matrix::GausPiv(a1,c);167 OMatrix a1(a); 168 return OMatrix::GausPiv(a1,c); 169 169 } 170 170 171 171 ////////////////////////////////////////////////////////// 172 172 //++ 173 VectorVector::FitResidus(GeneralFit& gfit,double xorg,double dx)173 OVector OVector::FitResidus(GeneralFit& gfit,double xorg,double dx) 174 174 // 175 175 // Retourne une classe contenant les residus du fit ``gfit''. … … 178 178 { 179 179 if(NElts()<=0) 180 throw(SzMismatchError(" Vector::FitResidus: size mismatch\n"));180 throw(SzMismatchError("OVector::FitResidus: size mismatch\n")); 181 181 GeneralFunction* f = gfit.GetFunction(); 182 182 if(f==NULL) 183 throw(NullPtrError(" Vector::FitResidus: NULL pointer\n"));184 Vector par = gfit.GetParm();185 Vector v(*this);183 throw(NullPtrError("OVector::FitResidus: NULL pointer\n")); 184 OVector par = gfit.GetParm(); 185 OVector v(*this); 186 186 for(int i=0;i<NElts();i++) { 187 187 double x = xorg+i*dx; … … 192 192 193 193 //++ 194 VectorVector::FitFunction(GeneralFit& gfit,double xorg,double dx)194 OVector OVector::FitFunction(GeneralFit& gfit,double xorg,double dx) 195 195 // 196 196 // Retourne une classe contenant la fonction du fit ``gfit''. … … 199 199 { 200 200 if(NElts()<=0) 201 throw(SzMismatchError(" Vector::FitResidus: size mismatch\n"));201 throw(SzMismatchError("OVector::FitResidus: size mismatch\n")); 202 202 GeneralFunction* f = gfit.GetFunction(); 203 203 if(f==NULL) 204 throw(NullPtrError(" Vector::FitResidus: NULL pointer\n"));205 Vector par = gfit.GetParm();206 Vector v(*this);204 throw(NullPtrError("OVector::FitResidus: NULL pointer\n")); 205 OVector par = gfit.GetParm(); 206 OVector v(*this); 207 207 for(int i=0;i<NElts();i++) { 208 208 double x = xorg+i*dx;
Note:
See TracChangeset
for help on using the changeset viewer.