// This may look like C code, but it is really -*- C++ -*- // C.Magneville 05/99 #ifndef TVECTOR_SEEN #define TVECTOR_SEEN #include "tmatrix.h" namespace PlanckDPC { class GeneralFit; template class TVector : public TMatrix { public: // Creation / destruction TVector(uint_4 n=1); TVector(uint_4 n, T* values,Bridge* br=NULL); TVector(const TVector& v); TVector(const TVector& v,bool share); TVector(const TMatrix& a); // Gestion taille/Remplissage inline void ReSize(uint_4 n) {TMatrix::ReSize(n,1);} // Reallocation de place // Informations pointeur/data inline uint_4 NElts() const {return NRows();} // Acces aux elements inline T& operator()(uint_4 n) {return (*this)[n];} inline T const& operator()(uint_4 n) const {return (*this)[n];} // Operateur d'affectation inline TVector& operator = (const TVector& v) {TMatrix::operator =(v); return *this;} inline TVector& operator = (T x) {for(uint_4 i=0;i FitResidus(GeneralFit& gfit,double xorg=0.,double dx=1.); TVector FitFunction(GeneralFit& gfit,double xorg=0.,double dx=1.); }; // produit scalaire, matrice*vecteur template inline T operator* (const TVector& v1, const TVector& v2) {if(v1.NRows() != v2.NRows()) throw(SzMismatchError("TVector::operator*(TVector& v1,TVector v2) size mismatch")); T *p = const_cast(v1.Data()), *pEnd = p+v1.NElts(), *q = const_cast(v2.Data()), r = 0; while (p inline TVector operator* (const TMatrix& a, const TVector& b) {return TVector(a * ((TMatrix const&)(b)));} // Resolution du systeme A*C = B inline r_8 LinSolveInPlace(TMatrix& a, TVector& b) { if(a.NCols() != b.NRows() || a.NCols() != a.NRows()) throw(SzMismatchError("LinSolveInPlace(TMatrix,TVector) size mismatch")); return TMatrix::GausPiv(a,b); } // Resolution du systeme A*C = B, avec C retourne dans B inline r_8 LinSolve(const TMatrix& a, const TVector& b, TVector& c) { if(a.NCols() != b.NRows() || a.NCols() != a.NRows()) throw(SzMismatchError("LinSolve(TMatrix,TVector) size mismatch")); c = b; TMatrix a1(a); return TMatrix::GausPiv(a1,c); } ///////////////////////////////////////////////////////////////////////// // Classe pour la gestion de persistance template class FIO_TVector : public PPersist { public: FIO_TVector(); FIO_TVector(string const & filename); FIO_TVector(const TVector & obj); FIO_TVector(TVector * obj); virtual ~FIO_TVector(); virtual AnyDataObj* DataObj(); inline operator TVector() { return(*dobj); } protected : virtual void ReadSelf(PInPersist&); virtual void WriteSelf(POutPersist&) const; TVector * dobj; bool ownobj; }; } // Fin du namespace #endif