CLHEP/Matrix/Vector.h
// -*- C++ -*-
// CLASSDOC OFF
// $Id: Vector.h,v 1.12 1999/08/06 10:03:29 evc Exp $
// ---------------------------------------------------------------------------
// CLASSDOC ON
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
//
//
// Copyright Cornell University 1993, 1996, All Rights Reserved.
//
// This software written by Nobu Katayama and Mike Smyth, Cornell University.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice and author attribution, this list of conditions and the
// following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice and author attribution, this list of conditions and the
// following disclaimer in the documentation and/or other materials
// provided with the distribution.
// 3. Neither the name of the University nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// Creation of derivative forms of this software for commercial
// utilization may be subject to restriction; written permission may be
// obtained from Cornell University.
//
// CORNELL MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. By way
// of example, but not limitation, CORNELL MAKES NO REPRESENTATIONS OR
// WARRANTIES OF MERCANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
// THE USE OF THIS SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS,
// COPYRIGHTS, TRADEMARKS, OR OTHER RIGHTS. Cornell University shall not be
// held liable for any liability with respect to any claim by the user or any
// other party arising from use of the program.
//
// Although Vector and Matrix class are very much related, I like the typing
// information I get by making them different types. It is usually an error
// to use a Matrix where a Vector is expected, except in the case that the
// Matrix is a single column. But this case can be taken care of by using
// constructors as conversions. For this same reason, I don't want to make
// a Vector a derived class of Matrix.
//
#ifndef _Vector_H_
#define _Vector_H_
#ifdef GNUPRAGMA
#pragma interface
#endif
#include "CLHEP/Matrix/GenMatrix.h"
#ifdef HEP_USE_RANDOM
class HepRandom;
#endif
class HepMatrix;
class HepSymMatrix;
class HepDiagMatrix;
#ifdef HEP_USE_VECTOR_MODULE
class Hep3Vector;
#endif
class HepVector : public HepGenMatrix {
public:
inline HepVector();
// Default constructor. Gives vector of length 0.
// Another Vector can be assigned to it.
HepVector(int p);
HepVector(int p, int);
// Constructor. Gives vector of length p.
#ifdef HEP_USE_RANDOM
HepVector(int p, HepRandom &r);
#endif
HepVector(const HepVector &v);
HepVector(const HepMatrix &m);
// Copy constructors.
// Note that there is an assignment operator for v = Hep3Vector.
virtual ~HepVector();
// Destructor.
inline const HepDouble & operator()(int row) const;
inline HepDouble & operator()(int row);
// Read or write a matrix element.
// ** Note that the indexing starts from (1). **
inline const HepDouble & operator[](int row) const;
inline HepDouble & operator[](int row);
// Read and write an element of a Vector.
// ** Note that the indexing starts from [0]. **
inline virtual const HepDouble & operator()(int row, int col) const;
inline virtual HepDouble & operator()(int row, int col);
// Read or write a matrix element.
// ** Note that the indexing starts from (1,1). **
// Allows accessing Vector using GenMatrix
HepVector & operator*=(HepDouble t);
// Multiply a Vector by a floating number.
HepVector & operator/=(HepDouble t);
// Divide a Vector by a floating number.
HepVector & operator+=( const HepMatrix &v2);
HepVector & operator+=( const HepVector &v2);
HepVector & operator-=( const HepMatrix &v2);
HepVector & operator-=( const HepVector &v2);
// Add or subtract a Vector.
HepVector & operator=( const HepVector &m2);
// Assignment operators.
HepVector& operator=(const HepMatrix &);
#ifdef HEP_USE_VECTOR_MODULE
HepVector& operator=(const Hep3Vector &);
#endif
// assignment operators from other classes.
HepVector operator- () const;
// unary minus, ie. flip the sign of each element.
HepVector apply(HepDouble (*f)(HepDouble, int)) const;
// Apply a function to all elements.
HepVector sub(int min_row, int max_row) const;
// Returns a sub vector.
#ifdef HEP_CC_NEED_SUB_WITHOUT_CONST
HepVector sub(int min_row, int max_row);
// SGI CC bug. I have to have both with/without const. I should not need
// one without const.
#endif
void sub(int row, const HepVector &v1);
// Replaces a sub vector of a Vector with v1.
inline HepDouble normsq() const;
// Returns norm squared.
inline HepDouble norm() const;
// Returns norm.
inline virtual int num_row() const;
// Returns number of rows.
inline virtual int num_col() const;
// Number of columns. Always returns 1. Provided for compatibility with
// GenMatrix.
HepMatrix T() const;
// Returns the transpose of a Vector. Note that the returning type is
// Matrix.
friend inline void swap(HepVector &v1, HepVector &v2);
// Swaps two vectors.
protected:
virtual inline int num_size() const;
private:
virtual void invert(int&);
// produces an error. Demanded by GenMatrix
friend class HepDiagMatrix;
friend class HepSymMatrix;
friend class HepMatrix;
// friend classes
friend HepDouble dot(const HepVector &v1, const HepVector &v2);
// f = v1 * v2;
friend HepVector operator+(const HepVector &v1, const HepVector &v2);
friend HepVector operator-(const HepVector &v1, const HepVector &v2);
friend HepVector operator*(const HepSymMatrix &m1, const HepVector &m2);
friend HepVector operator*(const HepDiagMatrix &m1, const HepVector &m2);
friend HepMatrix operator*(const HepVector &m1, const HepMatrix &m2);
friend HepVector operator*(const HepMatrix &m1, const HepVector &m2);
friend HepVector solve(const HepMatrix &a, const HepVector &v);
friend void tridiagonal(HepSymMatrix *a,HepMatrix *hsm);
friend void row_house(HepMatrix *,const HepMatrix &, HepDouble, int, int,
int, int);
friend void row_house(HepMatrix *,const HepVector &, HepDouble, int, int);
friend void back_solve(const HepMatrix &R, HepVector *b);
friend void col_house(HepMatrix *,const HepMatrix &,HepDouble, int, int,
int, int);
friend HepVector house(const HepSymMatrix &a,int row,int col);
friend HepVector house(const HepMatrix &a,int row,int col);
friend void house_with_update(HepMatrix *a,int row,int col);
friend HepSymMatrix vT_times_v(const HepVector &v);
friend HepVector qr_solve(HepMatrix *, const HepVector &);
HepDouble *m;
int nrow;
};
//
// Operations other than member functions
//
HepStd::ostream& operator<<(HepStd::ostream &s, const HepVector &v);
// Write out Matrix, SymMatrix, DiagMatrix and Vector into ostream.
HepVector operator*(const HepMatrix &m1, const HepVector &m2);
HepVector operator*(HepDouble t, const HepVector &v1);
HepVector operator*(const HepVector &v1, HepDouble t);
// Multiplication operators.
// Note that m *= x is always faster than m = m * x.
HepVector operator/(const HepVector &v1, HepDouble t);
// Divide by a real number.
HepVector operator+(const HepMatrix &m1, const HepVector &v2);
HepVector operator+(const HepVector &v1, const HepMatrix &m2);
HepVector operator+(const HepVector &v1, const HepVector &v2);
// Addition operators
HepVector operator-(const HepMatrix &m1, const HepVector &v2);
HepVector operator-(const HepVector &v1, const HepMatrix &m2);
HepVector operator-(const HepVector &v1, const HepVector &v2);
// subtraction operators
HepVector dsum(const HepVector &s1, const HepVector &s2);
// Direct sum of two vectors;
#ifdef HEP_SHORT_NAMES
typedef HepVector Vector;
#endif
#include "CLHEP/Matrix/Vector.icc"
#endif /*!_Vector_H*/
Generated by GNU enscript 1.6.1.