valarray

valarray

apply·cshift·fill·free·max·min· ``operator T *`` ·operator!·operator%= ·operator&=·operator>>=·operator<<=·operato r*=·operator+·operator+=·operator-·operator-=·operator/=·operator=·operator[] ·operator^=·operator|=·operator~·resize·shift·size·sum·valarray·value_type

template<class T>
    class valarray {
public:
    typedef T value_type;
    valarray();
    explicit valarray(size_t n);
    valarray(const T& val, size_t n));
    valarray(const T *p, size_t n);
    valarray(const slice_array<T>& sa);
    valarray(const gslice_array<T>& ga);
    valarray(const mask_array<T>& ma);
    valarray(const indirect_array<T>& ia);
    valarray<T>& operator=(const valarray<T>& va);
    valarray<T>& operator=(const T& x);
    valarray<T>& operator=(const slice_array<T>& sa);
    valarray<T>& operator=(const gslice_array<T>& ga);
    valarray<T>& operator=(const mask_array<T>& ma);
    valarray<T>& operator=(const indirect_array<T>& ia);
    T operator[](size_t n) const;
    T& operator[](size_t n);
    valarray<T> operator[](slice sa) const;
    slice_array<T> operator[](slice sa);
    valarray<T> operator[](const gslice& ga) const;
    gslice_array<T> operator[](const gslice& ga);
    valarray<T> operator[](const valarray<bool>& ba) const;
    mask_array<T> operator[](const valarray<bool>& ba);
    valarray<T> operator[](const valarray<size_t>& xa) const;
    indirect_array<T> operator[](const valarray<size_t>& xa);
    valarray<T> operator+();
    valarray<T> operator-();
    valarray<T> operator~();
    valarray<bool> operator!();
    valarray<T>& operator*=(const valarray<T>& x);
    valarray<T>& operator*=(const T& x);
    valarray<T>& operator/=(const valarray<T>& x);
    valarray<T>& operator/=(const T& x);
    valarray<T>& operator%=(const valarray<T>& x);
    valarray<T>& operator%=(const T& x);
    valarray<T>& operator+=(const valarray<T>& x);
    valarray<T>& operator+=(const T& x);
    valarray<T>& operator-=(const valarray<T>& x);
    valarray<T>& operator-=(const T& x);
    valarray<T>& operator^=(const valarray<T>& x);
    valarray<T>& operator^=(const T& x);
    valarray<T>& operator&=(const valarray<T>& x);
    valarray<T>& operator&=(const T& x);
    valarray<T>& operator|=(const valarray<T>& x);
    valarray<T>& operator|=(const T& x);
    valarray<T>& operator<<=(const valarray<T>& x);
    valarray<T>& operator<<=(const T& x);
    valarray<T>& operator>>=(const valarray<T>& x);
    valarray<T>& operator>>=(const T& x);
    size_t size() const;
    T sum() const;
    T max() const;
    T min() const;
    valarray<T> shift(int n) const;
    valarray<T> cshift(int n) const;
    valarray<T> apply(T fn(T)) const;
    valarray<T> apply(T fn(const T&)) const;
    void fill(const T& val);
    void free();
    void resize(size_t n, const T& c = T());
    };

The template class describes an object that controls a varying-length sequence of elements of type T. The sequence is stored as an array of T. It differs from template class vector in two important ways:

  • It defines numerous arithmetic operations between corresponding elements of valarray<T> objects of the same type and length, such as x = cos(y) + sin(z).
  • It defines a variety of interesting ways to subscript a valarray<T> object, by overloading operator[].