Computational Physics - Department of Physics

(Axel Boer) #1

202 6 Linear Algebra


/**************************************************************/
/* FRIEND FUNCTIONS */
/**************************************************************/
//! Unary operator +
template<classT2>
friendArray<T>operator+ (constArray<T>&); // u = + v
//! Unary operator -
template<classT2>
friendArray<T>operator-(constArray<T>&); // u = - v

/**
*Premultiplication by a floating point number:
*\f$\mathbf{u}= a \mathbf{v}\f$,
*where \f$a\f$ is a scalar and \f$\mathbf{v}\f$ is a array.
**/
template<classT2>
friendArray<T>operator*(double,constArray<T>&);// u = a*v
/**
*Postmultiplication by a floating point number:
*\f$\mathbf{u}= \mathbf{v}a\f$,
*where \f$a\f$ is a scalar and \f$\mathbf{v}\f$ is a array.
**/
template<classT2>
friendArray<T>operator*(constArray<T>&,double);// u = v*a

/**
*Division of the entries of a array by a scalar.
**/
template<classT2>
friendArray<T>operator/(constArray<T>&,double);// u = v/a

};


#include"Array.cpp"


// Destructor
template
inlineArray::~Array(){delete[] data;}


// Index operators
template
inline constT& Array::operator()(inti)const {
#ifCHECKBOUNDS_ON
indexOk(i);
#endif
returndata[i];
}

Free download pdf