ALPS Project

Header file vectormath.h

This header implements a few basic mathematical operations on std::vector. The motivation for these operations is the fact that std::valarray does not fulfill the requirements as a value type in a standard container. The operations defined in this header allow a std::vector to be used instead in some applications. If performance is an issue expression template based array libraries such as the Blitz++ should however be used instead.

This header will be deprecated as soon as the lattice library has been changed to ublas.

Synopsis

template <class T>
std::vector<T> operator-(const std::vector<T>& x);

template <class T>
std::vector<T> operator+(const std::vector<T>& x, const std::vector<T>& y);

template <class T>
std::vector<T> operator-(const std::vector<T>& x, const std::vector<T>& y);

template 
std::vector<T> operator*(S x, const std::vector<T>& y);

template 
std::vector<T> operator*(const std::vector<T>& x, S y);

Operations

template <class T>
std::vector<T> operator-(const std::vector<T>& x);
returns a vector with all elements negated.
template <class T>
std::vector<T> operator+(const std::vector<T>& x, const std::vector<T>& y);

template <class T>
std::vector<T> operator-(const std::vector<T>& x, const std::vector<T>& y);
returns the element wise sum or difference of two vectors. The size of the resulting vector is the maximum of the size of the two arguments. If one argument vector is shorter it will be assumed to be padded with the default value (usually 0) up to the length of the other vector.
template 
std::vector<T> operator*(S x, const std::vector<T>& y);

template 
std::vector<T> operator*(const std::vector<T>& x, S y);
returns a vector element wise multiplied with a scalar.

copyright (c) 1994-2010 by Matthias Troyer

Distributed under the Boost Software License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt)