// TrfVector_LA.h #ifndef TrfVector_LA_H #define TrfVector_LA_H // Version of TrfVector using FNAL ZOOM linearAlgebra package. // Contains headers for underlying TrfVector, TrfMatrix and TrfSMatrix // classes and corresponding typedefs. #include #include #include #include "LinearAlgebra/ColumnVector.h" #include "LinearAlgebra/Matrix.h" #include "trfutil/TRFMath.h" //********************************************************************** class TrfVector : public ColumnVector { public: // methods // Constructor. explicit TrfVector(int len) : ColumnVector(len) { } // Constructor from subclass. TrfVector(const ColumnVector& vec) : ColumnVector(vec) { } // Constructor from subclass. TrfVector(const MatrixD& mtx) : ColumnVector(mtx.rows()) { assert( mtx.columns() == 1 ); MatrixD::operator=(mtx); } // Return the length. int length() const { return rows(); } // Return the length. int nrow() const { return rows(); } // Fill the vector. void fill(double val) { for ( int i=0; i val ) val = newval; } return val; } // Return the minimum absolute value in the vector. double amin() const { double val = std::abs(operator()(0)); for ( int i=1; i val ) val = newval; } return val; } // Addition. TrfVector& operator+=(const TrfVector& rhs) { TrfVector& lhs = *this; assert( lhs.nrow() == rhs.nrow() ); for ( int i=0; i val ) val = newval; } } return val; } // Return the minimum absolute value in the matrix. double amin() const { double val = std::abs(operator()(0,0)); for ( int i=0; i val ) val = newval; } } return val; } // Transpose. TrfMatrix transpose() const { return MatrixD::transpose(); } }; //********************************************************************** class TrfSMatrix : public MatrixD { public: // methods // constructor explicit TrfSMatrix(int dim) : MatrixD(dim,dim) { declareSymmetric(); } // Constructor from subclass. TrfSMatrix(const MatrixD& mtx) : MatrixD(mtx) { } // Return the length. int nrow() const { return rows(); } int ncol() const { return columns(); } // Fill the matrix. void fill(double val) { for ( int i=0; i val ) val = newval; } } return val; } // Return the minimum absolute value in the matrix. double amin() const { double val = std::abs(operator()(0,0)); for ( int i=1; i val ) val = newval; } } return val; } // Return the maximum absolute value in the matrix. double amax() const { double val = std::abs(operator()(0,0)); for ( int i=1; i M * S * MT TrfSMatrix xform(const TrfMatrix& mtx) const { return xsxt(mtx); } // Xform S --> MT * S * M TrfSMatrix xformt(const TrfMatrix& mtx) const { return xtsx(mtx); } }; // Normalize a matrix. // Transformation which makes all diagonal elements unity. inline void normalize(TrfSMatrix& sma) { std::vector vec(sma.nrow()); for ( int irow=0; irow