.\" ident @(#)valarray.3 .\" Standard Template Library .\" $$RW_INSERT_HEADER "slyrs.man" .TH valarray 3C++ "02 Apr 1998" "Rogue Wave Software" "-" .ce2 Standard C++ Library Copyright 1998, Rogue Wave Software, Inc. .SH NAME \f2valarray\fP \ - An optimized array class for numeric operations. .SH SYNOPSIS .br #include .br template .br class valarray ; .SH DESCRIPTION valarray and associated classes (slice_array, gslice_array, mask_array, and indirect_array) represent and manipulate one dimensional arrays of values. Elements in a valarray are indexed sequentially beginning with zero. Unlike other classes in the Standard Library, valarray can only be used with a fairly narrow range of types. This restriction ensures that numeric operations on a valarray can be as efficient as possible by avoiding aliasing ambiguities and excess temporaries. .SH INTERFACE .br template class valarray { .br public: .br .br // types .br typedef T value_type; .br .br // constructors .br valarray( ); .br explicit valarray(size_t); .br valarray(const T&, size_t); .br valarray(const T* , size_t); .br valarray(const valarray&); .br valarray(const slice_array&); .br valarray(const gslice_array&); .br valarray(const mask_array&); .br valarray(const indirect_array&); .br .br // destructor .br ~valarray(); .br .br // operator = .br valarray& operator= (const valarray&); .br valarray& operator= (const slice_array&); .br valarray& operator= (const gslice_array&); .br valarray& operator= (const mask_array&); .br valarray& operator= (const indirect_array&); .br valarray& operator= (const T&); .br // operator[] .br T operator[] (size_t) const; .br T& operator[] (size_t); .br valarray operator[](slice) const; .br inline slice_array operator[](slice); .br valarray operator[](const gslice&) const; .br inline gslice_array operator[](const gslice&); .br valarray operator[](const valarray&) const; .br inline mask_array operator[](const valarray&); .br valarray operator[](const valarray&) const; .br inline indirect_array operator[](const valarray&); .br .br // unary operators .br valarray operator+() const; .br valarray operator-() const; .br valarray operator~() const; .br valarray operator!() const; .br .br // computed assignment .br valarray& operator*= (const valarray&); .br valarray& operator/= (const valarray&); .br valarray& operator+= (const valarray&); .br valarray& operator-= (const valarray&); .br valarray& operator%= (const valarray&); .br valarray& operator^= (const valarray&); .br valarray& operator&= (const valarray&); .br valarray& operator|= (const valarray&); .br valarray& operator<<= (const valarray&); .br valarray& operator>>= (const valarray&); .br valarray& operator*= (const T&); .br valarray& operator/= (const T&); .br valarray& operator%= (const T&); .br valarray& operator+= (const T&); .br valarray& operator-= (const T&); .br valarray& operator^= (const T&); .br valarray& operator&= (const T&); .br valarray& operator|= (const T&); .br valarray& operator<<= (const T&); .br valarray& operator>>= (const T&); .br .br .br // others .br size_t size() const; .br T sum() const; .br T min() const; .br T max() const; .br .br valarray shift(int) const; .br valarray cshift(int) const; .br .br valarray apply(T func(T)) const; .br valarray apply(T func(const T&)) const; .br void free(); .br void resize(size_t, const T& = T() ); .br }; .br .br // Non-member binary operators .br template valarray .br operator* (const valarray& , const valarray& ); .br template valarray .br operator/ (const valarray& , const valarray& ); .br template valarray .br operator% (const valarray&, const valarray&); .br template valarray .br operator+ (const valarray& , const valarray& ); .br template valarray .br operator- (const valarray& , const valarray& ); .br template valarray .br operator^ (const valarray&, const valarray&); .br template valarray .br operator& (const valarray&, const valarray&); .br template valarray .br operator| (const valarray&, const valarray&); .br template valarray .br operator<< (const valarray&, const valarray&); .br template valarray .br operator>> (const valarray&, const valarray&); .br .br template valarray .br operator* (const valarray& , const T& ); .br template valarray .br operator/ (const valarray& , const T& ); .br template valarray .br operator% (const valarray&, const T&); .br template valarray .br operator+ (const valarray& , const T& ); .br template valarray .br operator- (const valarray& , const T& ); .br template valarray .br operator^ (const valarray&, const T&); .br template valarray .br operator& (const valarray&, const T&); .br template valarray .br operator| (const valarray&, const T&); .br template valarray .br operator<< (const valarray&, const T&); .br template valarray .br operator>> (const valarray&, const T&); .br .br template valarray .br operator* (const T& , const valarray& ); .br template valarray .br operator/ (const T& , const valarray& ); .br template valarray .br operator% (const T&, const valarray&); .br template valarray .br operator+ (const T& , const valarray& ); .br template valarray .br operator- (const T& , const valarray& ); .br template valarray .br operator^ (const T&, const valarray&); .br template valarray .br operator& (const T&, const valarray&); .br template valarray .br operator| (const T&, const valarray&); .br template valarray .br operator<< (const T&, const valarray&); .br template valarray .br operator>> (const T&, const valarray&); .br .br // Non-member logical operators .br .br template valarray .br operator== (const valarray& , const valarray& ); .br template valarray .br operator!= (const valarray& , const valarray& ); .br template valarray .br operator< (const valarray& , const valarray& ); .br template valarray .br operator> (const valarray& , const valarray& ); .br template valarray .br operator<= (const valarray& , const valarray& ); .br template valarray .br operator>= (const valarray& , const valarray& ); .br template valarray .br operator|| (const valarray& , const valarray&); .br template valarray .br operator&& (const valarray&, const valarray&); .br .br template valarray .br operator== (const valarray& , const T& ); .br template valarray .br operator!= (const valarray& , const T& ); .br template valarray .br operator< (const valarray& , const T& ); .br template valarray .br operator> (const valarray& , const T& ); .br template valarray .br operator<= (const valarray& , const T& ); .br template valarray .br operator>= (const valarray& , const T& ); .br template valarray .br operator|| (const valarray& , const T& ); template valarray .br operator&& (const valarray&, const T&); .br .br template valarray .br operator== (const T& , const valarray& ); .br template valarray .br operator!= (const T& , const valarray& ); .br template valarray .br operator< (const T& , const valarray& ); .br template valarray .br operator> (const T& , const valarray& ); .br template valarray .br operator<= (const T& , const valarray& ); .br template valarray .br operator>= (const T& , const valarray& ); .br template valarray .br operator|| (const T& , const valarray& ); .br template valarray .br operator&& (const T&, const valarray&); .br .br // non-member transcendental functions .br .br template valarray abs(const valarray& ); .br template valarray acos(const valarray& ); .br template valarray asin(const valarray& ); .br template valarray atan(const valarray& ); .br template valarray cos(const valarray& ); .br template valarray cosh(const valarray& ); .br template valarray exp(const valarray& ); .br template valarray log(const valarray& ); .br template valarray log10(const valarray& ); .br template valarray sinh(const valarray& ); .br template valarray sin(const valarray& ); .br template valarray sqrt(const valarray& ); .br template valarray tan(const valarray& ); .br template valarray tanh(const valarray& ); .br .br template valarray .br atan2(const valarray& , const valarray& ); .br template valarray .br atan2(const valarray& , const T& ); .br template valarray .br atan2(const T& , const valarray& ); .br template valarray .br pow(const valarray& , const valarray& ); .br template valarray .br pow(const valarray& , const T& ); .br template valarray .br pow(const T& , const valarray& ); .SH CONSTRUCTORS .br valarray(); .RE .RS 3 Creates a valarray of length zero. .RE .br explicit valarray(size_t n); .RE .RS 3 Creates a valarray of length \f2n\fP, containing \f2n\fP values initialized with the default value for type \f2T\fP. \f2T\fP must have a default constructor. .RE .br explicit valarray(const T& value, size_t n); .RE .RS 3 Creates a valarray of length \f2n\fP, containing \f2n\fP values initialized with \f2value\fP. .RE .br explicit valarray(const T* value, size_t n); .RE .RS 3 Creates a valarray of length \f2n\fP, containing \f2n\fP values initialized with the first \f2n\fP elements pointed to by \f2value\fP. The array pointed to by \f2value\fP must contain at least \f2n\fP values. .RE .br valarray(const valarray& x); .RE .RS 3 Creates a copy of \f2x\fP. .RE .br valarray(const slice_array& x); .RE .RS 3 Creates a valarray from the slice_array \f2x\fP. .RE .br valarray(const gslice_array& x); .RE .RS 3 Creates a valarray from the gslice_array \f2x\fP. .RE .br valarray(const mask_array& x); .RE .RS 3 Creates a valarray from the mask_array \f2x\fP. .RE .br valarray(const indirect_array& x); .RE .RS 3 Creates a valarray from the indirect_array \f2x\fP. .RE .SH DESTRUCTORS .br ~valarray(); .RE .RS 3 Applies \f2~T()\fP to every element in the valarray and returns all allocated memory. .RE .SH ASSIGNMENT OPERATORS .br valarray& .br operator=(const valarray& x); .RE .RS 3 Assigns to each element of self the corresponding value from \f2x\fP. If self has more or fewer elements than \f2x\fP, then self is resized to match the size of \f2x\fP. Returns a reference to self. .RE .br valarray& .br operator=(const T& x); .RE .RS 3 Assigns to each element of self the value of \f2x\fP. Returns a reference to self. .RE .br valarray& .br operator=(const slice_array& x); .RE .RS 3 Copies elements from \f2x\fP into self by stepping through each slice consecutively. If self has more or fewer elements than \f2x\fP, then self is resized to match the size of \f2x\fP. Returns a reference to self. .RE .br valarray& .br operator=(const gslice_array& x); .RE .RS 3 Copies elements from \f2x\fP into self by stepping through each slice consecutively. If self has more or fewer elements than \f2x\fP, then self is resized to match the size of \f2x\fP. Returns a reference to self. .RE .br valarray& .br operator=(const mask& x); .RE .RS 3 Copies each consecutive element from \f2x\fP into self. If self has more or fewer elements than \f2x\fP, then self is resized to match the size of \f2x\fP. Returns a reference to self. .RE .br valarray& .br operator=(const indirect_array& x); .RE .RS 3 Copies each consecutive element from \f2x\fP into self. If self has more or fewer elements than \f2x\fP, then self is resized to match the size of \f2x\fP. Returns a reference to self. .RE .SH REFERENCE OPERATORS .br T& operator[](size_type n); .RE .RS 3 Returns a reference to element \f2n\fP of self. The result can be used as an \f2lvalue\fP. This reference is valid until the resize function is called or the array is destroyed. The index \f2n\fP must be between \f20\fP and \f2size\fP less one. .RE .br T operator[](size_type n) const; .RE .RS 3 Returns the value at element \f2n\fP of self. The index \f2n\fP must be between \f20\fP and \f2size\fP less one. .RE .SH SUBSET OPERATORS .br valarray operator[](slice s) const; .RE .RS 3 Returns a subset of the self as specified by \f2s\fP. The return value is a new valarray object. See slice for a description of a BLAS-like slice. .RE .br slice_array operator[](slice s); .RE .RS 3 Returns a subset of the self as specified by \f2s\fP. The return value is a slice_array referencing elements inside self. See slice and slice_array. .RE .br valarray operator[](const gslice& s) const; .RE .RS 3 Returns a subset of the self as specified by \f2s\fP. The return value is a new valarray object. See gslice for a description of a generalized slice. .RE .br gslice_array operator[](const gslice& s); .RE .RS 3 Returns a subset of the self as specified by \f2s\fP. The return value is a gslice_array referencing elements inside self. See gslice and gslice_array. .RE .br valarray operator[](const valarray& v) const; .RE .RS 3 Returns a subset of the self as specified by \f2s\fP. The return value is a new valarray object. .RE .br mask_array operator[](const valarray& v); .RE .RS 3 Returns a subset of the self as specified by \f2s\fP. The return value is a mask_array referencing elements inside self. See mask_array. .RE .br valarray operator[](const valarray& v) const; .RE .RS 3 Returns a subset of the self as specified by \f2s\fP. The return value is a new valarray object. .RE .br Indirect_array operator[](const valarray& v); .RE .RS 3 Returns a subset of the self as specified by \f2s\fP. The return value is a indirect_array referencing elements inside self. See indirect_array. .RE .SH UNARY OPERATORS .br valarray operator+() const; .RE .RS 3 Returns a new valarray object of the same size as the array in self where each element has been initialized by applying \f2operator+\fP to the corresponding element in self. This operation can only be applied to a valarray instantiated on a type \f2T\fP that supports an \f2operator+\fP that returns \f2T\fP or a type convertible to \f2T\fP. .RE .br valarray operator-() const; .RE .RS 3 Returns a new valarray object of the same size as the array in self where each element has been initialized by applying \f2operator-\fP to the corresponding element in self. This operation can only be applied to a valarray instantiated on a type \f2T\fP that supports an \f2operator-\fP returning \f2T\fP or a type convertible to \f2T\fP. .RE .br valarray operator~() const; .RE .RS 3 Returns a new valarray object of the same size as the array in self where each element has been initialized by applying \f2operator~\fP to the corresponding element in self. This operation can only be applied to a valarray instantiated on a type \f2T\fP that supports an \f2operator~\fP returning \f2T\fP or a type convertible to \f2T\fP. .RE .br valarray operator!() const; .RE .RS 3 Returns a new valarray object of the same size as the array in self where each element has been initialized by applying \f2operator!\fP to the corresponding element in self. This operation can only be applied to a valarray instantiated on a type \f2T\fP that supports an \f2operator!\fP returning \f2bool\fP or a type convertible to \f2bool\fP. .RE .SH COMPUTED ASSIGNMENT OPERATORS .br valarray& operator*=(const valarray& val); .br valarray& operator/=(const valarray& val); .br valarray& operator%=(const valarray& val); .br valarray& operator+=(const valarray& val); .br valarray& operator-=(const valarray& val); .br valarray& operator^=(const valarray& val); .br valarray& operator&=(const valarray& val); .br valarray& operator|=(const valarray& val); .br valarray& operator<<=(const valarray& val); .br valarray& operator>>=(const valarray& val); .RE .RS 3 Applies the indicated operation to each element in self, using the corresponding element from \f2val\fP as the right hand argument (for example, for all \f20 <= n < *this.size(), *this[n] += val[n]\fP). This operation can only be applied to a valarray instantiated on a type \f2T\fP that supports the indicated operation. The length of \f2val\fP must also equal the length of self. Returns self. .RE .br valarray& operator*=(const T& val); .br valarray& operator/=(const T& val); .br valarray& operator%=(const T& val); .br valarray& operator+=(const T& val); .br valarray& operator-=(const T& val); .br valarray& operator^=(const T& val); .br valarray& operator&=(const T& val); .br valarray& operator|=(const T& val); .br valarray& operator<<=(const T& val); .br valarray& operator>>=(const T& val); .RE .RS 3 Applies the indicated operation to each element in self, using \f2val\fP as the right hand argument (for example, for all \f20 <= n < *this.size(), *this[n] += val\fP). This operation can only be applied to a valarray instantiated on a type \f2T\fP that supports the indicated operation. Returns self. .RE .SH MEMBER FUNCTIONS .br size_t size() const; .RE .RS 3 Returns the number of elements. .RE .br T sum() const; .RE .RS 3 This function uses \f2operator+=\fP to sum all the elements of the array. Sum can only be called for a valarray instantiated on a type that supports \f2operator+=\fP. The array must also have at least one element. Returns the sum of all elements in the array. .RE .br T min() const; .RE .RS 3 This function uses \f2operator<\fP to find the minimum element in the array. The array must have at least one element. Returns the minimum of all elements in the array. .RE .br T max() const; .RE .RS 3 This function uses \f2operator>\fP to find the maximum element in the array. The array must have at least one element. Returns the maximum of all elements in the array. .RE .br valarray shift(int n) const; .RE .RS 3 This function returns a new valarray object whose elements have all been shifted \f2n\fP places to left or right with respect to self. A positive value of \f2n\fP shifts the elements to the left, a negative value to the right. The default constructor for \f2T\fP is used to fill in behind the shifting elements. For example, applying \f2shift(2)\fP to an array corresponding to [3,4,5,6] results in [5,6,0,0], and applying \f2shift(-1)\fP to [3,4,5,6] results in [0,3,4,5]. .RE .br valarray cshift(int n) const; .RE .RS 3 This function returns a new valarray object whose elements have all been rotated \f2n\fP places to left or right with respect to self. A positive value of \f2n\fP shifts the elements to the left, a negative value to the right. For example, applying \f2shift(2)\fP to an array corresponding to [3,4,5,6] results in [5,6,3,4], and applying \f2shift(-1)\fP to [3,4,5,6] results in [6,3,4,5]. .RE .br valarray apply(T func(T)) const; .RE .RS 3 This function returns a new valarray object with the same length as the array in self but whose elements have all been initialized by applying the argument function \f2func\fP to the corresponding element in self (in other words, for all\f2 n < *this.size()\fP, the \f2nth\fP element of the returned array equals\f2 func(*this[n]))\fP. .RE .br valarray apply(T func(const T&)) const; .RE .RS 3 This function returns a new valarray object with the same length as the array in self but whose elements have all been initialized by applying the argument function \f2func\fP to the corresponding element in self (in other words, for all \f20 <= n < *this.size()\fP, the \f2nth\fP element of the returned array equals \f2func(*this[n]))\fP. .RE .br void .br resize(size_type sz, T c = T()); .RE .RS 3 Changes the length of self to \f2sz\fP, and assigns \f2c\fP to every element. This function also invalidates all outstanding references to self. .RE .SH NON-MEMBER BINARY OPERATORS .br template valarray .br operator*(const valarray& lhs, const valarray& rhs); .br template valarray .br operator/(const valarray& lhs, const valarray& rhs); .br template valarray .br operator%(const valarray& lhs, const valarray& rhs); .br template valarray .br operator+(const valarray& lhs, const valarray& rhs); .br template valarray .br operator-(const valarray& lhs, const valarray& rhs); .br template valarray .br operator^(const valarray& lhs, const valarray& rhs); .br template valarray .br operator&(const valarray& lhs, const valarray& rhs); .br template valarray .br operator|(const valarray& lhs, const valarray& rhs); .br template valarray .br operator<<(const valarray& lhs, const valarray& rhs); .br template valarray .br operator>>(const valarray& lhs, const valarray& rhs); .RE .RS 3 Returns a new valarray object of the same size as the argument arrays where each element has been initialized by applying the indicated operation to the corresponding elements in the argument arrays. The operation can only be applied to a valarray instantiated on a type \f2T\fP that supports a form of the indicated operation that returns \f2T\fP or a type convertible to \f2T\fP. The argument arrays must have the same length. .RE .br template valarray .br operator*(const valarray& lhs, T& rhs); .br template valarray .br operator/(const valarray& lhs, const T& rhs); .br template valarray .br operator%(const valarray& lhs, const T& rhs); .br template valarray .br operator+(const valarray& lhs, const T& rhs); .br template valarray .br operator-(const valarray& lhs, const T& rhs); .br template valarray .br operator^(const valarray& lhs, const T& rhs); .br template valarray .br operator&(const valarray& lhs, const T& rhs); .br template valarray .br operator|(const valarray& lhs, const T& rhs); .br template valarray .br operator<<(const valarray& lhs, const T& rhs); .br template valarray .br operator>>(const valarray& lhs, const T& rhs); .RE .RS 3 Returns a new valarray object of the same size as the valarray \f2lhs\fP where each element has been initialized by applying the indicated operation to the corresponding element in \f2lhs\fP and the value \f2rhs\fP. The operation can only be used with a type \f2T\fP that supports a form of the indicated operation that returns \f2T\fP or a type convertible to \f2T\fP. .RE .br template valarray .br operator*(const T& rhs, valarray& rhs); .br template valarray .br operator/(const T& lhs, const valarray& rhs); .br template valarray .br operator%(const T& lhs, const valarray& rhs); .br template valarray .br operator+(const T& lhs, const valarray& rhs); .br template valarray .br operator-(const T& lhs, const valarray& rhs); .br template valarray .br operator^(const T& lhs, const valarray& rhs); .br template valarray .br operator&(const T& lhs, const valarray& rhs); .br template valarray .br operator|(const T& lhs, const valarray& rhs); .br template valarray .br operator<<(const T& lhs, const valarray& rhs); .br template valarray .br operator>>(const T& lhs, const valarray& rhs); .RE .RS 3 Returns a new valarray object of the same size as the valarray \f2rhs\fP where each element has been initialized by applying the indicated operation to the corresponding element in \f2rhs\fP and the value \f2lhs\fP. The operation can only be used with a type \f2T\fP that supports a form of the indicated operation that returns \f2T\fP or a type convertible to \f2T\fP. .RE .SH NON-MEMBER LOGICAL OPERATORS .br template valarray .br operator==(const valarray& lhs, const valarray& rhs); .br template valarray .br operator!=(const valarray& lhs, const valarray& rhs); .br template valarray .br operator<(const valarray& lhs, const valarray& rhs); .br template valarray .br operator>(const valarray& lhs, const valarray& rhs); .br template valarray .br operator<=(const valarray& lhs, const valarray& rhs); .br template valarray .br operator>=(const valarray& lhs, const valarray& rhs); .br template valarray .br operator&&(const valarray& lhs, const valarray& rhs); .br template valarray .br operator||(const valarray& lhs, const valarray& rhs); .RE .RS 3 Returns a valarray object of the same size as the argument arrays where each element has been initialized by applying the indicated operation to the corresponding elements in the argument arrays. The operation can only be applied to a valarray instantiated on a type \f2T\fP that support a form of the indicated operation that returns \f2bool\fP or a type convertible to \f2bool\fP. The argument arrays must have the same length. .RE .br template valarray .br operator==(const valarray& lhs, T& rhs); .br template valarray .br operator!=(const valarray& lhs, const T& rhs); .br template valarray .br operator<(const valarray& lhs, const T& rhs); .br template valarray .br operator>(const valarray& lhs, const T& rhs); .br template valarray .br operator<=(const valarray& lhs, const T& rhs); .br template valarray .br operator>=(const valarray& lhs, const T& rhs); .br template valarray .br operator&&(const valarray& lhs, const T& rhs); .br template valarray .br operator||(const valarray& lhs, const T& rhs); .RE .RS 3 Returns a valarray object of the same size as the valarray \f2lhs\fP where each element has been initialized by applying the indicated operation to the corresponding element in \f2lhs\fP and the value \f2rhs\fP. The operation can only be used with a type \f2T\fP that supports a form of the indicated operation that returns \f2bool\fP or a type convertible to \f2bool\fP. .RE .br template valarray .br operator==(const T& rhs, valarray& rhs); .br template valarray .br operator!=(const T& lhs, const valarray& rhs); .br template valarray .br operator<(const T& lhs, const valarray& rhs); .br template valarray .br operator>(const T& lhs, const valarray& rhs); .br template valarray .br operator<=(const T& lhs, const valarray& rhs); .br template valarray .br operator>=(const T& lhs, const valarray& rhs); .br template valarray .br operator&&(const T& lhs, const valarray& rhs); .br template valarray .br operator||(const T& lhs, const valarray& rhs); .RE .RS 3 Returns a valarray object of the same size as the valarray \f2rhs\fP where each element has been initialized by applying indicated operation to the corresponding element in \f2rhs\fP and the value \f2lhs\fP. The operation can only be used with a type \f2T\fP that supports a form of the indicated operation that returns \f2bool\fP or a type convertible to \f2bool\fP. .RE .SH NON-MEMBER TRANSCENDENTAL FUNCTIONS .br template valarray abs(const valarray& v); .br template valarray acos(const valarray& v); .br template valarray asin(const valarray& v); .br template valarray atan(const valarray& v); .br template valarray cos(const valarray& v); .br template valarray cosh(const valarray& v); .br template valarray exp(const valarray& v); .br template valarray log(const valarray& v); .br template valarray log10(const valarray& v); .br template valarray sin(const valarray& v); .br template valarray sinh(const valarray& v); .br template valarray sqrt(const valarray& v); .br template valarray tan(const valarray& v); .br template valarray tanh(const valarray& v); .RE .RS 3 Returns a new valarray object of the same size as the argument array where each element has been initialized by applying the indicated transcendental function to the corresponding elements in the argument array. The operation can only be applied to a valarray instantiated on a type \f2T\fP that supports a unique form of the indicated function that returns \f2T\fP or a type convertible to \f2T\fP. .RE .br template valarray .br atan2(const valarray& v, const valarray& v2); .br template valarray .br pow(const valarray& v, const valarray& v2); .RE .RS 3 Returns a new valarray object of the same size as the argument arrays where each element has been initialized by applying the indicated transcendental function to the corresponding elements in the argument arrays. The operation can only be applied to a valarray instantiated on a type \f2T\fP that supports a unique form of the indicated function that returns \f2T\fP or a type convertible to \f2T\fP. .RE .br template valarray .br atan2(const valarray& v, const T& v2); .br template valarray .br pow(const valarray& v, const T& v2); .RE .RS 3 Returns a new valarray object of the same size as the argument array \f2v\fP where each element has been initialized by applying the indicated transcendental function to the corresponding elements in \f2v\fP along with the value \f2v2\fP. The operation can only be applied to a valarray instantiated on a type \f2T\fP that supports a unique form of the indicated function that returns \f2T\fP or a type convertible to \f2T\fP. .RE .br template valarray .br atan2(const T& v, const valarray v2); .br template valarray .br pow(const T& v, const valarray v2); .RE .RS 3 Returns a new valarray object of the same size as the argument array \f2v2\fP where each element has been initialized by applying the indicated transcendental function to the corresponding elements in \f2v2\fP along with the value \f2v\fP. The operation can only be applied to a valarray instantiated on a type \f2T\fP that supports a unique form of the indicated function that returns \f2T\fP or a type convertible to \f2T\fP. .RE .SH EXAMPLE .br // .br // valarray.cpp .br // .br #include "valarray.h" // Contains a valarray stream inserter .br using namespace std; .br int main(void) .br { .RE .RS 1 int ibuf[10] = {0,1,2,3,4,5,6,7,8,9}; .br int ibuf2[10] = {10,11,12,13,14,15,16,17,18,19}; .RE .RS 0 .RE .RS 2 // create 2 valarrays of ints .RE .RS 0 valarray vi(ibuf,10); .br valarray vi2(ibuf2,10); .br .RE .RS 2 // print them out .RE .RS 1 cout << vi << endl << vi2 << endl; .RE .RS 0 .RE .RS 1 vi += vi2; .br vi2 *= 2; .br valarry vi3 = vi2 % vi; .RE .RS 0 .RE .RS 2 // print them out again .RE .RS 1 cout << vi << endl << vi2 << endl << vi3 << endl; .RE .RS 0 .RE .RS 1 return 0; .RE .RS 0 } .br