SourcePro® API Reference Guide

 
List of all members | Public Types | Public Member Functions | Friends | Related Functions
RWMathVec< T > Class Template Reference

A templatized vector class. More...

#include <rw/math/mathvec.h>

Inheritance diagram for RWMathVec< T >:
RWVecView RWDataView

Public Types

typedef RWMathVecConstIterator< T > const_iterator
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 
typedef RWMathVecIterator< T > iterator
 
typedef rw_numeric_traits< T >::mathFunType mathFunType
 
typedef rw_numeric_traits< T >::mathFunType2 mathFunType2
 
typedef rw_numeric_traits< T >::norm_type norm_type
 
typedef rw_numeric_traits< T >::promote_type promote_type
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
- Public Types inherited from RWDataView
enum  Storage { COLUMN_MAJOR, ROW_MAJOR, RWEITHER }
 

Public Member Functions

 RWMathVec (size_t n, RWRandInterface &r)
 
 RWMathVec ()
 
 RWMathVec (const RWMathVec< T > &a)
 
 RWMathVec (size_t n, RWUninitialized)
 
 RWMathVec (size_t n, const T &initval)
 
 RWMathVec (size_t n, const T &initval, const T &incr)
 
 RWMathVec (const char *s)
 
 RWMathVec (const RWMathVecPick< T > &p)
 
 RWMathVec (const T *dat, size_t n)
 
 RWMathVec (const RWMathVec< double > &re, const RWMathVec< double > &im)
 
RWMathVec< T > apply (typename rw_numeric_traits< T >::mathFunType f) const
 
RWMathVec< norm_typeapply2 (mathFunType2 f) const
 
iterator begin ()
 
const_iterator begin () const
 
size_t binaryStoreSize () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
RWMathVec< T > copy () const
 
const_reverse_iterator crbegin () const
 
const_reverse_iterator crend () const
 
T * data ()
 
const T * data () const
 
RWMathVec< T > deepCopy () const
 
void deepenShallowCopy ()
 
iterator end ()
 
const_iterator end () const
 
size_t length () const
 
 operator RWMathVec< promote_type > ()
 
bool operator!= (const RWMathVec< T > &v) const
 
T & operator() (int i)
 
operator() (int i) const
 
RWMathVec< T > operator() (const RWSlice &)
 
const RWMathVec< T > operator() (const RWSlice &) const
 
RWMathVec< T > & operator*= (const T &v)
 
RWMathVec< T > & operator*= (const RWMathVec< T > &v)
 
RWMathVec< T > & operator++ ()
 
void operator++ (int)
 
RWMathVec< T > & operator+= (const T &v)
 
RWMathVec< T > & operator+= (const RWMathVec< T > &v)
 
RWMathVec< T > & operator-- ()
 
void operator-- (int)
 
RWMathVec< T > & operator-= (const T &v)
 
RWMathVec< T > & operator-= (const RWMathVec< T > &v)
 
RWMathVec< T > & operator/= (const T &v)
 
RWMathVec< T > & operator/= (const RWMathVec< T > &v)
 
RWMathVec< T > & operator= (const RWMathVec< T > &v)
 
RWMathVec< T > & operator= (const RWMathVecPick< T > &v)
 
RWMathVec< T > & operator= (const T &v)
 
bool operator== (const RWMathVec< T > &) const
 
T & operator[] (int i)
 
operator[] (int i) const
 
RWMathVec< T > operator[] (const RWSlice &)
 
const RWMathVec< T > operator[] (const RWSlice &) const
 
RWMathVecPick< T > pick (const RWIntVec &v)
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
RWMathVec< T > & reference (const RWMathVec< T > &v)
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
void reshape (size_t n)
 
void resize (size_t n)
 
void restoreFrom (RWFile &)
 
void restoreFrom (RWvistream &)
 
void saveOn (RWFile &) const
 
void saveOn (RWvostream &) const
 
RWMathVec< T > slice (int start, size_t n, int stride=1) const
 
int stride () const
 
- Public Member Functions inherited from RWVecView
size_t length () const
 
int stride () const
 

Friends

RWMathVec< double > imag (const RWMathVec< DComplex > &v)
 
RWMathVec< double > real (const RWMathVec< DComplex > &v)
 

Related Functions

(Note that these are not member functions.)

RWMathVec< double > abs (const RWMathVec< double > &)
 
RWMathVec< float > abs (const RWMathVec< float > &)
 
RWMathVec< int > abs (const RWMathVec< int > &)
 
RWMathVec< double > abs (const RWMathVec< DComplex > &)
 
RWMathVec< signed char > abs (const RWMathVec< signed char > &)
 
template<class T >
RWMathVec< T > acos (const RWMathVec< T > &x)
 
RWMathVec< double > arg (const RWMathVec< DComplex > &v)
 
template<class T >
RWMathVec< T > asin (const RWMathVec< T > &x)
 
template<class T >
RWMathVec< T > atan (const RWMathVec< T > &x)
 
template<class T >
RWMathVec< T > atan2 (const RWMathVec< T > &x, const RWMathVec< T > &y)
 
template<class T >
RWMathVec< T > ceil (const RWMathVec< T > &x)
 
RWMathVec< DComplexconj (const RWMathVec< DComplex > &x)
 
DComplex conjDot (const RWMathVec< DComplex > &x, const RWMathVec< DComplex > &y)
 
template<class T >
RWMathVec< T > cos (const RWMathVec< T > &x)
 
template<class T >
RWMathVec< T > cosh (const RWMathVec< T > &x)
 
template<class T >
RWMathVec< T > cumsum (const RWMathVec< T > &x)
 
template<class T >
RWMathVec< T > delta (const RWMathVec< T > &x)
 
template<class T >
dot (const RWMathVec< T > &x, const RWMathVec< T > &y)
 
template<class T >
RWMathVec< T > exp (const RWMathVec< T > &x)
 
RWMathVec< DComplexexpandConjugateEven (const RWMathVec< DComplex > &)
 
RWMathVec< DComplexexpandConjugateOdd (const RWMathVec< DComplex > &)
 
template<class T >
RWMathVec< T > expandEven (const RWMathVec< T > &)
 
template<class T >
RWMathVec< T > expandOdd (const RWMathVec< T > &)
 
template<class T >
RWMathVec< T > floor (const RWMathVec< T > &V)
 
double frobNorm (const RWMathVec< double > &v)
 
float frobNorm (const RWMathVec< float > &v)
 
double frobNorm (const RWMathVec< DComplex > &v)
 
double kurtosis (const RWMathVec< double > &)
 
double l1Norm (const RWMathVec< double > &v)
 
float l1Norm (const RWMathVec< float > &v)
 
double l1Norm (const RWMathVec< DComplex > &v)
 
double l2Norm (const RWMathVec< double > &v)
 
float l2Norm (const RWMathVec< float > &v)
 
double l2Norm (const RWMathVec< DComplex > &v)
 
double linfNorm (const RWMathVec< double > &v)
 
float linfNorm (const RWMathVec< float > &v)
 
double linfNorm (const RWMathVec< DComplex > &v)
 
template<class T >
RWMathVec< T > log (const RWMathVec< T > &x)
 
template<class T >
RWMathVec< T > log10 (const RWMathVec< T > &x)
 
template<class T >
int maxIndex (const RWMathVec< T > &)
 
double maxNorm (const RWMathVec< double > &v)
 
float maxNorm (const RWMathVec< float > &v)
 
double maxNorm (const RWMathVec< DComplex > &v)
 
template<class T >
maxValue (const RWMathVec< T > &)
 
template<class T >
mean (const RWMathVec< T > &V)
 
template<class T >
int minIndex (const RWMathVec< T > &)
 
template<class T >
minValue (const RWMathVec< T > &)
 
RWMathVec< double > norm (const RWMathVec< DComplex > &x)
 
template<class T >
RWMathVec< T > operator* (const RWMathVec< T > &u, const RWMathVec< T > &v)
 
template<class T >
RWMathVec< T > operator* (const RWMathVec< T > &u, const T &s)
 
template<class T >
RWMathVec< T > operator* (const T &s, const RWMathVec< T > &v)
 
template<class T >
RWMathVec< T > operator+ (const RWMathVec< T > &v)
 
template<class T >
RWMathVec< T > operator+ (const RWMathVec< T > &u, const RWMathVec< T > &v)
 
template<class T >
RWMathVec< T > operator+ (const RWMathVec< T > &u, const T &s)
 
template<class T >
RWMathVec< T > operator+ (const T &s, const RWMathVec< T > &v)
 
template<class T >
RWMathVec< T > operator- (const RWMathVec< T > &v)
 
template<class T >
RWMathVec< T > operator- (const RWMathVec< T > &u, const RWMathVec< T > &v)
 
template<class T >
RWMathVec< T > operator- (const T &s, const RWMathVec< T > &v)
 
template<class T >
RWMathVec< T > operator- (const RWMathVec< T > &u, const T &s)
 
template<class T >
RWMathVec< T > operator/ (const RWMathVec< T > &u, const RWMathVec< T > &v)
 
template<class T >
RWMathVec< T > operator/ (const T &s, const RWMathVec< T > &v)
 
template<class T >
RWMathVec< T > operator/ (const RWMathVec< T > &u, const T &s)
 
template<class T >
std::ostream & operator<< (std::ostream &s, const RWMathVec< T > &v)
 
template<class T >
std::istream & operator>> (std::istream &s, RWMathVec< T > &v)
 
template<class T >
RWGenMat< T > outerProduct (const RWMathVec< T > &x, const RWMathVec< T > &y)
 
template<class T >
RWMathVec< T > pow (const RWMathVec< T > &x, const RWMathVec< T > &y)
 
template<class T >
RWMathVec< T > pow (const RWMathVec< T > &x, T y)
 
template<class T >
RWMathVec< T > pow (T x, const RWMathVec< T > &y)
 
template<class T >
prod (const RWMathVec< T > &)
 
template<class T >
RWMathVec< T > reverse (const RWMathVec< T > &)
 
RWMathVec< DComplexrootsOfOne (int N, size_t nterms)
 Returns a complex vector v containing the complex Nth roots of unity. More...
 
RWMathVec< DComplexrootsOfOne (int N)
 Returns a complex vector v containing the complex Nth roots of unity. More...
 
template<class T >
RWMathVec< T > sin (const RWMathVec< T > &V)
 
template<class T >
RWMathVec< T > sinh (const RWMathVec< T > &V)
 
double skewness (const RWMathVec< double > &)
 
RWMathVec< double > sort (const RWMathVec< double > &)
 
double spectralVariance (const RWMathVec< DComplex > &)
 
template<class T >
RWMathVec< T > sqrt (const RWMathVec< T > &V)
 
template<class T >
sum (const RWMathVec< T > &)
 
template<class T >
RWMathVec< T > tan (const RWMathVec< T > &V)
 
template<class T >
RWMathVec< T > tanh (const RWMathVec< T > &V)
 
RWMathVec< signed char > toChar (const RWMathVec< int > &v)
 
RWMathVec< float > toFloat (const RWMathVec< double > &v)
 
RWMathVec< int > toInt (const RWMathVec< double > &v)
 
RWMathVec< int > toInt (const RWMathVec< float > &v)
 
double variance (const RWMathVec< double > &)
 
double variance (const RWMathVec< DComplex > &)
 
float variance (const RWMathVec< float > &)
 

Detailed Description

template<class T>
class RWMathVec< T >

Class RWMathVec is a templatized vector class.

Synopsis
#include <rw/math/mathvec.h>
RWMathVec<T> vector;
Example
#include <rw/math/mathvec.h>
int main()
{
v = 3; // Set all elements in v to 3
RWMathVec<int> w = v + 1;
RWMathVec<int> y = v + w;
}
See also
RWConvertMathVec

Member Typedef Documentation

template<class T>
typedef RWMathVecConstIterator<T> RWMathVec< T >::const_iterator

A type that provides a const random-access iterator over the elements in the container.

template<class T>
typedef std::reverse_iterator<const_iterator> RWMathVec< T >::const_reverse_iterator

A type that provides a const random-access, reverse-order iterator over the elements in the container.

template<class T>
typedef RWMathVecIterator<T> RWMathVec< T >::iterator

A type that provides a random-access iterator over the elements in the container.

template<class T>
typedef rw_numeric_traits<T>::mathFunType RWMathVec< T >::mathFunType

Typedef for the function pointer used in the method apply(). For more information, see rw_numeric_traits<T>::mathFunType.

template<class T>
typedef rw_numeric_traits<T>::mathFunType2 RWMathVec< T >::mathFunType2

Typedef for the function pointer used in the method apply2(). For more information, see rw_numeric_traits<T>::mathFunType2.

template<class T>
typedef rw_numeric_traits<T>::norm_type RWMathVec< T >::norm_type

Typedef for the usual return type of numerical norm-like functions. For more information, see rw_numeric_traits<T>::norm_type.

template<class T>
typedef rw_numeric_traits<T>::promote_type RWMathVec< T >::promote_type

Typedef for the promotion type. For more information, see rw_numeric_traits<T>::promote_type.

template<class T>
typedef std::reverse_iterator<iterator> RWMathVec< T >::reverse_iterator

A type that provides a random-access, reverse-order iterator over the elements in the container.

Constructor & Destructor Documentation

template<class T>
RWMathVec< T >::RWMathVec ( size_t  n,
RWRandInterface r 
)

Constructs a vector with n elements initialized with random numbers generated by r.

template<class T>
RWMathVec< T >::RWMathVec ( )
inline

Constructs a 0-length vector, useful for declaring arrays of vectors. Like any other vector, this vector can subsequently be reshaped or resized (see member functions reshape() and resize()).

template<class T>
RWMathVec< T >::RWMathVec ( const RWMathVec< T > &  a)
inline

Copy constructor. The new vector and the old vector both view the same data.

template<class T>
RWMathVec< T >::RWMathVec ( size_t  n,
RWUninitialized   
)
inline

Constructs a vector with n elements. The RWUninitialized type is an enumeration type with only one value, rwUninitialized. The rwUninitialized argument is used to distinguish the last dimension size from an initial value.

template<class T>
RWMathVec< T >::RWMathVec ( size_t  n,
const T &  initval 
)

Constructs a vector with n elements, initialized to initval.

template<class T>
RWMathVec< T >::RWMathVec ( size_t  n,
const T &  initval,
const T &  incr 
)

Constructs a vector with n elements. The first has value initval; each succeeding element is incremented by incr.

template<class T>
RWMathVec< T >::RWMathVec ( const char *  s)

Constructs a matrix from the null terminated character string s. The format of the character string is the same as that expected by the global operator operator>>() described in this entry.

template<class T>
RWMathVec< T >::RWMathVec ( const RWMathVecPick< T > &  p)

Constructs a new vector from an RWMathVecPick. A copy of p's data is made.

template<class T>
RWMathVec< T >::RWMathVec ( const T *  dat,
size_t  n 
)

Constructs a vector with n elements, using the data in the vector dat as initial data. A copy of dat is made. The vector dat must have at least n elements.

template<class T>
RWMathVec< T >::RWMathVec ( const RWMathVec< double > &  re,
const RWMathVec< double > &  im 
)

A complex vec is constructed from the double precision arrays re and im, with the real part of the vec equal to re and the imaginary part equal to im. A new copy of the data is made.

Member Function Documentation

template<class T>
RWMathVec<T> RWMathVec< T >::apply ( typename rw_numeric_traits< T >::mathFunType  f) const
inline

Returns the result of applying the passed function to every element in the vector. A function of type RWMathVec<T>::mathFunType takes and returns a T; a function of type RWMathVec<T>::mathFunType2 takes a T and returns an RWMathVec<T>::norm_type.

See also
rw_numeric_traits for a description of RWMathVec<T>::norm_type.
template<class T>
RWMathVec<norm_type> RWMathVec< T >::apply2 ( mathFunType2  f) const

Returns the result of applying the passed function to every element in the vector. A function of type RWMathVec<T>::mathFunType takes and returns a T; a function of type RWMathVec<T>::mathFunType2 takes a T and returns an RWMathVec<T>::norm_type.

See also
rw_numeric_traits for a description of RWMathVec<T>::norm_type.
template<class T>
iterator RWMathVec< T >::begin ( )
inline

Returns an iterator that points to the first element in the vector.

template<class T>
const_iterator RWMathVec< T >::begin ( ) const
inline

Returns an iterator that points to the first element in the vector.

template<class T>
size_t RWMathVec< T >::binaryStoreSize ( ) const

Returns the number of bytes required to store the vector to an RWFile using member function saveOn(RWFile&).

template<class T>
const_iterator RWMathVec< T >::cbegin ( ) const
inline

Returns an iterator that points to the first element in the vector.

template<class T>
const_iterator RWMathVec< T >::cend ( ) const
inline

Returns an iterator that points to one element past the last element in the vector.

template<class T>
RWMathVec<T> RWMathVec< T >::copy ( ) const

Returns a copy with distinct instance variables.

template<class T>
const_reverse_iterator RWMathVec< T >::crbegin ( ) const
inline

Returns an iterator that points to the first element in the vector.

template<class T>
const_reverse_iterator RWMathVec< T >::crend ( ) const
inline

Returns an iterator that points to one element past the first element in the vector.

template<class T>
T* RWMathVec< T >::data ( void  )
inline

Returns a pointer to the start of a vector's data. Should be used with care, as this accesses the vector's data directly. You are responsible for recognizing the length and the stride of the vector.

template<class T>
const T* RWMathVec< T >::data ( void  ) const
inline

Returns a pointer to the start of a vector's data. Should be used with care, as this accesses the vector's data directly. You are responsible for recognizing the length and the stride of the vector.

template<class T>
RWMathVec<T> RWMathVec< T >::deepCopy ( ) const

Alias for copy().

template<class T>
void RWMathVec< T >::deepenShallowCopy ( )

When invoked for a vector, guarantees that there is only one reference to that object and that its data are in contiguous storage.

template<class T>
iterator RWMathVec< T >::end ( )
inline

Returns an iterator that points to one element past the last element in the vector.

template<class T>
const_iterator RWMathVec< T >::end ( ) const
inline

Returns an iterator that points to one element past the last element in the vector.

template<class T>
size_t RWMathVec< T >::length ( ) const
inline

Returns the number of elements in the vector.

template<class T>
RWMathVec< T >::operator RWMathVec< promote_type > ( )
inline

Implicit conversion operator to RWMathVec. The promote_type is rw_numeric_traits::promote_type.

See also
rw_numeric_traits for more information.
template<class T>
bool RWMathVec< T >::operator!= ( const RWMathVec< T > &  v) const

Returns false if self and the argument are equivalent. To be equivalent, they must have the same number of entries and each element in self must equal the corresponding element in the argument.

template<class T >
T & RWMathVec< T >::operator() ( int  i)
inline

Subscripting operators for the vector, with optional bounds checking. Bounds checking is enabled by defining the preprocessor macro RWBOUNDS_CHECK before including the header file. All subscripting operators return a new view of the same data as the vector being subscripted. An object of type RWRange or RWToEnd, the global object RWAll, or a character string may be substituted for an RWSlice.

template<class T >
T RWMathVec< T >::operator() ( int  i) const
inline

Subscripting operators for the vector, with optional bounds checking. Bounds checking is enabled by defining the preprocessor macro RWBOUNDS_CHECK before including the header file. All subscripting operators return a new view of the same data as the vector being subscripted. An object of type RWRange or RWToEnd, the global object RWAll, or a character string may be substituted for an RWSlice.

template<class T >
RWMathVec< T > RWMathVec< T >::operator() ( const RWSlice s)
inline

Subscripting operators for the vector, with optional bounds checking. Bounds checking is enabled by defining the preprocessor macro RWBOUNDS_CHECK before including the header file. All subscripting operators return a new view of the same data as the vector being subscripted. An object of type RWRange or RWToEnd, the global object RWAll, or a character string may be substituted for an RWSlice.

template<class T >
const RWMathVec< T > RWMathVec< T >::operator() ( const RWSlice s) const
inline

Subscripting operators for the vector, with optional bounds checking. Bounds checking is enabled by defining the preprocessor macro RWBOUNDS_CHECK before including the header file. All subscripting operators return a new view of the same data as the vector being subscripted. An object of type RWRange or RWToEnd, the global object RWAll, or a character string may be substituted for an RWSlice.

template<class T>
RWMathVec<T>& RWMathVec< T >::operator*= ( const T &  v)

Assignment by multiplication operator for scalars. The expression this *= v implies \(this_{i} = this_{i} * v\)

template<class T>
RWMathVec<T>& RWMathVec< T >::operator*= ( const RWMathVec< T > &  v)

Assignment by multiplication operator for vectors. The vectors must have the same dimensions. The expression this *= v implies \(this_{i} = this_{i} * v_{i}\)

template<class T>
RWMathVec<T>& RWMathVec< T >::operator++ ( )

Increments each element of self. The functions taking an integer parameter are invoked if the operator is used as a postfix operator.

template<class T>
void RWMathVec< T >::operator++ ( int  )
inline

Increments each element of self. The functions taking an integer parameter are invoked if the operator is used as a postfix operator.

template<class T>
RWMathVec<T>& RWMathVec< T >::operator+= ( const T &  v)

Assignment by addition operator for scalars. The expression this += v implies \(this_{i} = this_{i} + v\)

template<class T>
RWMathVec<T>& RWMathVec< T >::operator+= ( const RWMathVec< T > &  v)

Assignment by addition operator for vectors. The vectors must have the same dimensions. The expression this += v implies \(this_{i} = this_{i} + v_{i}\)

template<class T>
RWMathVec<T>& RWMathVec< T >::operator-- ( )

Decrements each element of self. The functions taking an integer parameter are invoked if the operator is used as a postfix operator.

template<class T>
void RWMathVec< T >::operator-- ( int  )
inline

Decrements each element of self. The functions taking an integer parameter are invoked if the operator is used as a postfix operator.

template<class T>
RWMathVec<T>& RWMathVec< T >::operator-= ( const T &  v)

Assignment by subtraction operator for scalars. The expression this -= v implies \(this_{i} = this_{i} - v\)

template<class T>
RWMathVec<T>& RWMathVec< T >::operator-= ( const RWMathVec< T > &  v)

Assignment by subtraction operator for vectors. The vectors must have the same dimensions. The expression this -= v implies \(this_{i} = this_{i} - v_{i}\)

template<class T>
RWMathVec<T>& RWMathVec< T >::operator/= ( const T &  v)

Assignment by division operator for scalars. The expression this /= v implies \(this_{i} = this_{i} / v\)

template<class T>
RWMathVec<T>& RWMathVec< T >::operator/= ( const RWMathVec< T > &  v)

Assignment by division operator for vectors. The vectors must have the same dimensions. The expression this /= v; implies \(this_{i} = this_{i} / v_{i}\)

template<class T>
RWMathVec<T>& RWMathVec< T >::operator= ( const RWMathVec< T > &  v)

Assignment operator for vectors. The vectors must have the same dimensions. The expression this = v implies \(this_{i} = v_{i}\)

template<class T>
RWMathVec<T>& RWMathVec< T >::operator= ( const RWMathVecPick< T > &  v)

Assignment operator for vectors. The vectors must have the same dimensions. The expression this = v implies \(this_{i} = v_{i}\)

template<class T>
RWMathVec<T>& RWMathVec< T >::operator= ( const T &  v)

Assignment operator for scalars. The expression this = v implies \(this_{i} = v\)

template<class T>
bool RWMathVec< T >::operator== ( const RWMathVec< T > &  ) const

Returns true if self and the argument are equivalent. To be equivalent, they must have the same number of entries and each element in self must equal the corresponding element in the argument.

template<class T >
T & RWMathVec< T >::operator[] ( int  i)
inline

Subscripting operator for the vector, with bounds checking. All subscripting operators return a new view of the same data as the vector being subscripted. An object of type RWRange or RWToEnd, the global object RWAll, or a character string may be substituted for an RWSlice.

template<class T >
T RWMathVec< T >::operator[] ( int  i) const
inline

Subscripting operator for the vector, with bounds checking. All subscripting operators return a new view of the same data as the vector being subscripted. An object of type RWRange or RWToEnd, the global object RWAll, or a character string may be substituted for an RWSlice.

template<class T >
RWMathVec< T > RWMathVec< T >::operator[] ( const RWSlice s)
inline

Subscripting operator for the vector, with bounds checking. All subscripting operators return a new view of the same data as the vector being subscripted. An object of type RWRange or RWToEnd, the global object RWAll, or a character string may be substituted for an RWSlice.

template<class T >
const RWMathVec< T > RWMathVec< T >::operator[] ( const RWSlice s) const
inline

Subscripting operator for the vector, with bounds checking. All subscripting operators return a new view of the same data as the vector being subscripted. An object of type RWRange or RWToEnd, the global object RWAll, or a character string may be substituted for an RWSlice.

template<class T>
RWMathVecPick<T> RWMathVec< T >::pick ( const RWIntVec v)

Returns a vector pick. The results can be used as an lvalue. You can think of the picked elements as representing a vector in the order specified by the vector of indices v. Before using this function, you must include the header file rw/math/mthvecpk.h.

template<class T>
reverse_iterator RWMathVec< T >::rbegin ( )
inline

Returns an iterator that points to the last element in the vector.

template<class T>
const_reverse_iterator RWMathVec< T >::rbegin ( ) const
inline

Returns an iterator that points to the first element in the vector.

template<class T>
RWMathVec<T>& RWMathVec< T >::reference ( const RWMathVec< T > &  v)

Makes self a view of v's data. The view currently associated with the vector is lost.

template<class T>
reverse_iterator RWMathVec< T >::rend ( )
inline

Returns an iterator that points to one element past the first element in the vector.

template<class T>
const_reverse_iterator RWMathVec< T >::rend ( ) const
inline

Returns an iterator that points to one element past the first element in the vector.

template<class T>
void RWMathVec< T >::reshape ( size_t  n)

Changes the length of the vector to n elements. After reshaping, the contents of the vector are undefined; that is, they can be and probably will be garbage.

template<class T>
void RWMathVec< T >::resize ( size_t  n)

Changes the size of the vector to n elements, adding 0s or truncating as necessary.

template<class T>
void RWMathVec< T >::restoreFrom ( RWFile )

Restores self from a virtual stream or an RWFile. To use these functions with a user-defined type T, the corresponding operator>> must be defined:

template<class T>
void RWMathVec< T >::restoreFrom ( RWvistream )

Restores self from a virtual stream or an RWFile. To use these functions with a user-defined type T, the corresponding operator>> must be defined:

template<class T>
void RWMathVec< T >::saveOn ( RWFile ) const

Stores self to a virtual stream, or in a binary format to an RWFile. To use these functions with a user-defined type T, the corresponding operator<< must be defined:

template<class T>
void RWMathVec< T >::saveOn ( RWvostream ) const

Stores self to a virtual stream, or in a binary format to an RWFile. To use these functions with a user-defined type T, the corresponding operator<< must be defined:

template<class T>
RWMathVec<T> RWMathVec< T >::slice ( int  start,
size_t  n,
int  stride = 1 
) const

Returns a vector which views a slice of the data. The slice begins at element start and extends for n elements. The increment between successive elements in the slice is stride.

template<class T>
int RWMathVec< T >::stride ( ) const
inline

Returns the distance between successive elements of the vector. The stride can be computed using &v[i+1]-&v[i].

Friends And Related Function Documentation

template<class T>
RWMathVec< double > abs ( const RWMathVec< double > &  )
related

Returns the absolute values of each element.

Example
#include <rw/math/mathvec.h>
#include <iostream>
const double adata[] = {1.2,2.4,-1.2,0.8,-4.5};
int main() {
RWMathVec<double> a(adata,5);
std::cout << b;
return 0;
}

Program Output:

[ 1.2 2.4 1.2 0.8 4.5 ]
template<class T>
RWMathVec< float > abs ( const RWMathVec< float > &  )
related

Returns the absolute values of each element.

template<class T>
RWMathVec< int > abs ( const RWMathVec< int > &  )
related

Returns the absolute values of each element.

template<class T>
RWMathVec< double > abs ( const RWMathVec< DComplex > &  )
related

Returns the absolute values of each element.

template<class T>
RWMathVec< signed char > abs ( const RWMathVec< signed char > &  )
related

Returns the absolute values of each element.

Note
The absolute value of a complex number is of type double. Therefore, if abs() is invoked for class RWMathVec<DComplex>, a vector of class RWMathVec<double> is returned.
template<class T >
RWMathVec< T > acos ( const RWMathVec< T > &  x)
related

Returns arc cosines y such that \(y_{i} = cos^{-1} (x_{i})\). The yi(in radians) are in the range \(0 < y_{i} \leq \pi\), for elements xi with absolute values \(|x_{i}| \leq 1\).

template<class T>
RWMathVec< double > arg ( const RWMathVec< DComplex > &  v)
related

Returns the arguments ai (in radians) of x in the range \(-\pi < a_{i} \leq \pi\), where \(a_{i} = tan_{-1}[Im(x_{i})/Re(x_{i})]\). Multiple valued functions of complex arguments, such as sqrt() and log(), are therefore constrained to their principle value.

template<class T >
RWMathVec< T > asin ( const RWMathVec< T > &  x)
related

Takes x as an argument and returns arc sines y such that \(y_{i} = sin^{-1} (x_{i})\). The yi (in radians) are in the range \(-\pi/2 < y_{i} \leq \pi/2\), for elements xi with absolute values \(|x_{i}| \leq 1\).

template<class T >
RWMathVec< T > atan ( const RWMathVec< T > &  x)
related

Takes x and returns y of arc tangents (in radians), such that \(y_{i} = tan^{-1}x_{i}\), where \(-\pi/2 < y_{i} \leq \pi/2\).

At least one of the arguments xi or yi must be nonzero.

template<class T >
RWMathVec< T > atan2 ( const RWMathVec< T > &  x,
const RWMathVec< T > &  y 
)
related

Takes two arguments and returns quadrant correct arc tangents z (in radians), such that \(z_{i} = tan^{-1} ( x_{i}/y_{i})\). For each element i, the expression \(atan2(x_{i}, y_{i})\) is mathematically equivalent to:

\[ tan^{-1}\left(\frac{x_i}{y_i}\right) \]

At least one of the arguments xi or yi must be nonzero.

template<class T >
RWMathVec< T > ceil ( const RWMathVec< T > &  x)
related

Takes x as an argument and returns y such that yi corresponds to the next integer greater than or equal to xi. For example, if x = [ -1.3, 4.3, 7.9] then y = [ -1, 5, 8].

template<class T>
RWMathVec< DComplex > conj ( const RWMathVec< DComplex > &  x)
related

Takes complex x as an argument and returns the complex conjugates x*. For example, if xi = (2.3, 1.4), then xi* = (2.3, -1.4).

template<class T>
DComplex conjDot ( const RWMathVec< DComplex > &  x,
const RWMathVec< DComplex > &  y 
)
related

Returns the complex-conjugate dot product of two vectors x and y:

\[ z = \sum_{j=0}^{N-1} x_j y_j \]

The two vectors must have the same number of elements or an exception with value MATH_VNMATCH occurs.

template<class T >
RWMathVec< T > cos ( const RWMathVec< T > &  x)
related

Takes x as an argument and returns y such that \(y_{i} = cos(x_{i})\). The xi are in radians. For complex arguments, the complex cosine is returned.

template<class T >
RWMathVec< T > cosh ( const RWMathVec< T > &  x)
related

Takes x as an argument and returns hyperbolic cosines y such that \(y_{i} = cosh(x_{i})\). For complex arguments, the complex hyperbolic cosine is returned.

template<class T >
RWMathVec< T > cumsum ( const RWMathVec< T > &  x)
related

Takes a vector x and returns a vector y of values corresponding to the cumulative sum of x:

\[ y_i = \sum_{j=0}^{i} x_j \]

Example
#include <rw/math/mathvec.h>
#include <iostream>
int main()
{
const double adata[] = { 1.2, 2.4, -1.2, 0.8, 4.5 };
RWMathVec<double> a(adata, 5);
std::cout << b;
}

Program output:

[ 1.2 3.6 2.4 3.2 7.7]
template<class T >
RWMathVec< T > delta ( const RWMathVec< T > &  x)
related

Takes a vector x as an argument and returns a vector y of element differences. The first element in y is set equal to the first element of x. An element y(i) where i is not 0 is set equal to \(x(i) - x(i-1)\).

For example, if x = [2, 4, 5, 8] then y = [2, 2, 1, 3].

template<class T >
T dot ( const RWMathVec< T > &  x,
const RWMathVec< T > &  y 
)
related

Returns the vector dot product z of two vectors, x and y. The two vectors must have the same number of elements or an exception with value MATH_VNMATCH occurs.

\[ z = \sum_{j=0}^{N-1} x_j y_j \]

For example, if x = [ 0, 1, 2] and y = [ 1, 3, 2], then z = 0 + 3 + 4 = 7. For vectors of type complex, see also function conjDot().

template<class T >
RWMathVec< T > exp ( const RWMathVec< T > &  x)
related

Takes an argument x and returns y such that:

\[ y_i = e^{x_i} \]

If class T is complex, the complex exponential is returned.

template<class T>
RWMathVec< DComplex > expandConjugateEven ( const RWMathVec< DComplex > &  )
related

Given a complex sequence \(C(n), n=0, \ldots , 2N\) points long, it is a complex conjugate-even sequence if:

\[ C(n) = conj[C(-n)] = conj[C(2N - n)] \]

,

Note that for a sequence to be complex conjugate-even, the imaginary parts of \(C(0)\) and \(C(N)\) must be 0. Given the lower half of the sequence, that is, \(C(n), n=0, \ldots , N\), this function expands it out to the entire sequence \(C(n), n=0, ..., 2N\).

template<class T>
RWMathVec< DComplex > expandConjugateOdd ( const RWMathVec< DComplex > &  )
related

Given a complex sequence \(C(n), n=0, \ldots, 2N\) points long, it is a complex conjugate-odd sequence if:

\[ C(n) = - conj[C(-n)] = - conj[C(2N - n)] \]

.

Note that for a sequence to be complex conjugate-odd, the real parts of \(C(0)\) and \(C(N)\) must be 0. Given the lower half of the sequence, that is, \(C(n), n=0, \ldots , N\), this function expands it out to the entire sequence \(C(n), n=0, ..., 2N\).

template<class T >
RWMathVec< T > expandEven ( const RWMathVec< T > &  )
related

Given a real sequence \(V(n), n=0, \ldots , 2N\) points long, it is an even sequence if:

\[ V(n) = V(-n) = V(2N - n) \]

Given the lower half of an even sequence, that is, \(V(n), n=0, \ldots , N\), expandEven() expands it out to the entire sequence \(V(n), n=0, \ldots, 2N\).

template<class T >
RWMathVec< T > expandOdd ( const RWMathVec< T > &  )
related

Given a real sequence \(V(n), n=0, \ldots , 2N\) points long, it is an odd sequence if:

\[ V(n) = - V(-n) = - V(2N - n) \]

Note that for a sequence to be odd, \(V(0) = V(N) = 0\). Given the lower half of an odd sequence, that is, \(V(n), n=1, \ldots , N-1\), expandOdd() expands it out to the entire sequence \(V(n), n=0, \ldots , 2N\).

template<class T >
RWMathVec< T > floor ( const RWMathVec< T > &  V)
related

Takes x as an argument and returns y such that yi corresponds to the largest integer less than or equal to xi. For example, if x = [ 1.3, 4.4, -3.2], then y = [ 1, 4, -4].

template<class T>
double frobNorm ( const RWMathVec< double > &  v)
related

Computes the Frobenius norm, which is the square root of the sum of squares of its entries. For a vector, the formula is:

\[ \left \| x \right \|_{\text{Frob}} = \sqrt{\sum_{i=0}^{N-1}\left | x_{i} \right |^2} \]

template<class T>
float frobNorm ( const RWMathVec< float > &  v)
related

Computes the Frobenius norm, which is the square root of the sum of squares of its entries. For a vector, the formula is:

\[ \left \| x \right \|_{\text{Frob}} = \sqrt{\sum_{i=0}^{N-1}\left | x_{i} \right |^2} \]

template<class T>
double frobNorm ( const RWMathVec< DComplex > &  v)
related

Computes the Frobenius norm, which is the square root of the sum of squares of its entries. For a vector, the formula is:

\[ \left \| x \right \|_{\text{Frob}} = \sqrt{\sum_{i=0}^{N-1}\left | x_{i} \right |^2} \]

template<class T>
RWMathVec< double > imag ( const RWMathVec< DComplex > &  v)
friend

Takes complex x as an argument and returns y containing the imaginary parts \(y_{i} = Im(x_{i})\). With most versions of complex, the results can be used as an l-value:

RWMathVec<DComplex> v(5, 0); // (0, 0), (0, 0), ...
imag(v) = 1.0; // (0, 1), (0, 1), ...
template<class T>
double kurtosis ( const RWMathVec< double > &  )
related
Header File
#include <rw/dstats.h>

Returns the kurtosis of a vector of doubles:

\[ \frac{1}{N}\sum_{i=0}^{N-1}\left ( \frac{x_i - \langle x \rangle}{\sigma} \right )^4 - 3 \]

where <x> is the mean of the vector and \( \sigma \) is its standard deviation (that is, the square root of the variance). The -3 term is designed to make the kurtosis 0 for a normal distribution.

template<class T>
double l1Norm ( const RWMathVec< double > &  v)
related

The function l1Norm() is the sum of absolute values of its entries:

\[ \left \| x \right \| = \sum_{i=0}^{N-1}\left | x_i \right | \]

template<class T>
float l1Norm ( const RWMathVec< float > &  v)
related

The function l1Norm() is the sum of absolute values of its entries:

\[ \left \| x \right \| = \sum_{i=0}^{N-1}\left | x_i \right | \]

template<class T>
double l1Norm ( const RWMathVec< DComplex > &  v)
related

The function l1Norm() is the sum of absolute values of its entries:

\[ \left \| x \right \| = \sum_{i=0}^{N-1}\left | x_i \right | \]

template<class T>
double l2Norm ( const RWMathVec< double > &  v)
related

The function l2Norm() is the square root of the sum of the squares of its entries:

\[ \left \| x \right \|_2 = \sqrt{ \sum_{i=0}^{N-1} \left (x_i \right )^2 } \]

template<class T>
float l2Norm ( const RWMathVec< float > &  v)
related

The function l2Norm() is the square root of the sum of the squares of its entries:

\[ \left \| x \right \|_2 = \sqrt{ \sum_{i=0}^{N-1} \left (x_i \right )^2 } \]

template<class T>
double l2Norm ( const RWMathVec< DComplex > &  v)
related

The function l2Norm() is the square root of the sum of the squares of its entries:

\[ \left \| x \right \|_2 = \sqrt{ \sum_{i=0}^{N-1} \left (x_i \right )^2 } \]

template<class T>
double linfNorm ( const RWMathVec< double > &  v)
related

The function linfNorm() is the maximum of absolute values of its entries:

\[ \left \| x \right \|_{\infty} = \begin{array}{c c} \scriptstyle max \\ \scriptstyle j=0,...,N-1 \end{array} \left | x_i \right | \]

template<class T>
float linfNorm ( const RWMathVec< float > &  v)
related

The function linfNorm() is the maximum of absolute values of its entries:

\[ \left \| x \right \|_{\infty} = \begin{array}{c c} \scriptstyle max \\ \scriptstyle j=0,...,N-1 \end{array} \left | x_i \right | \]

template<class T>
double linfNorm ( const RWMathVec< DComplex > &  v)
related

The function linfNorm() is the maximum of absolute values of its entries:

\[ \left \| x \right \|_{\infty} = \begin{array}{c c} \scriptstyle max \\ \scriptstyle j=0,...,N-1 \end{array} \left | x_i \right | \]

template<class T >
RWMathVec< T > log ( const RWMathVec< T > &  x)
related

Takes x as an argument and returns natural logarithms y such that \(y_{i}=log(x_{i})\). The arguments x i must not be 0. For complex arguments, the principal value of the complex natural logarithm is returned.

template<class T >
RWMathVec< T > log10 ( const RWMathVec< T > &  x)
related

Takes x as an argument and returns base 10 logarithms y such that \(y_{i} = log_{10}(x_{i})\). The arguments x i must not be 0.

template<class T >
int maxIndex ( const RWMathVec< T > &  )
related

Return the index of the maximum element of the vector. If instead you want the maximum value use function maxValue().

template<class T>
double maxNorm ( const RWMathVec< double > &  v)
related

Returns the value of the element with largest absolute value. Note that this is not a norm in the mathematical sense of the word.

template<class T>
float maxNorm ( const RWMathVec< float > &  v)
related

Returns the value of the element with largest absolute value. Note that this is not a norm in the mathematical sense of the word.

template<class T>
double maxNorm ( const RWMathVec< DComplex > &  v)
related

Returns the value of the element with largest absolute value. Note that this is not a norm in the mathematical sense of the word.

template<class T >
T maxValue ( const RWMathVec< T > &  )
related

Return the maximum value.

template<class T >
T mean ( const RWMathVec< T > &  V)
related

Takes a RWMathVec an argument and returns <x>, the mean value, where:

\[ \langle x \rangle = \frac{1}{n}\sum_{i=0}^{n-1}x_i \]

For example, if x = [1, 4, 3, 4], then <x> = 3.

template<class T >
int minIndex ( const RWMathVec< T > &  )
related

Return the index of the minimum element of the vector. If instead you want the minimum value use function minValue().

template<class T >
T minValue ( const RWMathVec< T > &  )
related

Return the minimum value.

template<class T>
RWMathVec< double > norm ( const RWMathVec< DComplex > &  x)
related

Takes complex x as an argument and returns real y containing the norm:

\[ y_{i} = [Re(x_{i})]^{2} + [Im(x_{i}]^{2} \]

template<class T >
RWMathVec< T > operator* ( const RWMathVec< T > &  u,
const RWMathVec< T > &  v 
)
related

Multiplication operator, applied element-by-element. For example, for vectors u, v, and w, the expression w = u * v implies \(w_{i} = u_{i} * v_{i}\). This implies an element-by-element multiply, not the inner product. If you want the inner product, use global function dot() or conjDot().

template<class T >
RWMathVec< T > operator* ( const RWMathVec< T > &  u,
const T &  s 
)
related

Multiplication operator, applied element-by-element. For example, for vectors u, w, and scaler s, the expression w = u * s implies \(w_{i} = u_{i} * s\).

template<class T >
RWMathVec< T > operator* ( const T &  s,
const RWMathVec< T > &  v 
)
related

Multiplication operator, applied element-by-element. For example, for scaler s, and vectors v, and w, the expression w = s * v implies \(w_{i} = s * v_{i}\).

template<class T >
RWMathVec< T > operator+ ( const RWMathVec< T > &  v)
related

Unary plus operator, applied element-by-element. For example, for vectors u, and v, the expression u = +v implies \(u_{i} = +v_{i}\).

template<class T >
RWMathVec< T > operator+ ( const RWMathVec< T > &  u,
const RWMathVec< T > &  v 
)
related

Addition operator, applied element-by-element. For example, for vectors u, v, and w, the expression w = u + v implies \(w_{i} = u_{i} + v_{i}\).

template<class T >
RWMathVec< T > operator+ ( const RWMathVec< T > &  u,
const T &  s 
)
related

Addition operator, applied element-by-element. For example, for vectors u, w, and scaler s, the expression w = u + s implies \(w_{i} = u_{i} + s\).

template<class T >
RWMathVec< T > operator+ ( const T &  s,
const RWMathVec< T > &  v 
)
related

Addition operator, applied element-by-element. For example, for scaler s, and vectors v, and w, the expression w = s + v implies \(w_{i} = s + v_{i}\).

template<class T >
RWMathVec< T > operator- ( const RWMathVec< T > &  v)
related

Unary minus operator, applied element-by-element. For example, for vectors u, and v, the expression u = -v implies \(u_{i} = -v_{i}\).

template<class T >
RWMathVec< T > operator- ( const RWMathVec< T > &  u,
const RWMathVec< T > &  v 
)
related

Subtraction operator, applied element-by-element. For example, for vectors u, v, and w, the expression w = u - v implies \(w_{i} = u_{i} - v_{i}\).

template<class T >
RWMathVec< T > operator- ( const T &  s,
const RWMathVec< T > &  v 
)
related

Subraction operator, applied element-by-element. For example, for scaler s, and vectors v, and w, the expression w = s - v implies \(w_{i} = s - v_{i}\).

template<class T >
RWMathVec< T > operator- ( const RWMathVec< T > &  u,
const T &  s 
)
related

Subtraction operator, applied element-by-element. For example, for vectors u, w, and scaler s, the expression w = u - s implies \(w_{i} = u_{i} - s\).

template<class T >
RWMathVec< T > operator/ ( const RWMathVec< T > &  u,
const RWMathVec< T > &  v 
)
related

Division operator, applied element-by-element. For example, for vectors u, v, and w, the expression w = u / v implies \(w_{i} = u_{i} / v_{i}\).

template<class T >
RWMathVec< T > operator/ ( const T &  s,
const RWMathVec< T > &  v 
)
related

Division operator, applied element-by-element. For example, for scaler s, and vectors v, and w, the expression w = s / v implies \(w_{i} = s / v_{i}\).

template<class T >
RWMathVec< T > operator/ ( const RWMathVec< T > &  u,
const T &  s 
)
related

Division operator, applied element-by-element. For example, for vectors u, w, and scaler s, the expression w = u / s implies \(w_{i} = u_{i} / s\).

template<class T >
std::ostream & operator<< ( std::ostream &  s,
const RWMathVec< T > &  v 
)
related

Outputs a vector v to std::ostream s beginning with a left bracket [ and terminating with a right bracket ]. The output numbers are separated by spaces. If T is a user-defined type, the following operator must be defined for RWvostream and/or RWFile:

operator<<(ostream&s,constT&t);

template<class T >
std::istream & operator>> ( std::istream &  s,
RWMathVec< T > &  v 
)
related

Reads vector v from stream s. It reads a sequence of numbers separated by white space. If the sequence of numbers begins with a left bracket [, the operator reads to a matching right bracket ]. If no left bracket is present, it reads to end of file. The vector v is initialized to the correct length. If T is a user-defined type, the following operator must be defined for RWvistream and/or RWFile:

operator>>(ostream&s,constT&t);

template<class T >
RWGenMat< T > outerProduct ( const RWMathVec< T > &  x,
const RWMathVec< T > &  y 
)
related

Returns the outer product of two vectors. The outer product of the vectors \(x = (x_{1}, x_{2},\ldots , x_{n})\) and \(y = (y_{1}, y_{2},\ldots , y_{m})\) is the matrix A whose ijth entry is xiyj: that is, the jth column of A is yjx.

template<class T >
RWMathVec< T > pow ( const RWMathVec< T > &  x,
const RWMathVec< T > &  y 
)
related

The function pow() takes two arguments: pow( x, y ).

Returns z such that:

\[ z_i = (x_i)^{y_i} \]

If the number of elements in x does not match the number of elements in y, an exception with value RWMATH_MNMATCH will occur.

template<class T >
RWMathVec< T > pow ( const RWMathVec< T > &  x,
y 
)
related

The function pow() takes two arguments: pow( x, y ).

Returns z such that:

\[ z_i = (x_i)^{y} \]

template<class T >
RWMathVec< T > pow ( x,
const RWMathVec< T > &  y 
)
related

The function pow() takes two arguments: pow( x, y ).

Returns z such that:

\[ z_i = (x)^{y_i} \]

template<class T >
T prod ( const RWMathVec< T > &  )
related

Takes a vector xi with n elements as an argument and returns the product of the elements of the vector. For example, if x = [1, 4, 3], then y = 12.

template<class T>
RWMathVec< double > real ( const RWMathVec< DComplex > &  v)
friend

Takes a complex argument x and returns real y containing the real part \(y_{i}=Re(x_{i})\). With most versions of complex, the results can be used as an l-value:

RWMathVec<DComplex> v(5, 0); // (0, 0), (0, 0), ...
real(v) = 1.0; // (1, 0), (1, 0), ...
template<class T >
RWMathVec< T > reverse ( const RWMathVec< T > &  )
related

Takes a vector x as an argument and returns a vector y whose elements are in reversed order. For example, if x = [2, 5, 1, 6], then y = [6, 1, 5, 2]. The reversed vector y is actually a reversed slice of the original vector. Hence, the results of this function can be used as an lvalue.

template<class T>
RWMathVec< DComplex > rootsOfOne ( int  N,
size_t  nterms 
)
related

Returns a complex vector v containing the complex Nth roots of unity, that is:

\[ \begin{array}{l r} v_k = e^{(2k\pi) / N} & \text{ k = 0, ..., nterms - 1} \end{array} \]

If rootsOfOne() is invoked with arguments N and nterms, only the the first nterms of the N roots are returned in a vector of type RWMathVec<DComplex> with nterms elements.

template<class T>
RWMathVec< DComplex > rootsOfOne ( int  N)
related

Returns a complex vector v containing the complex Nth roots of unity, that is:

\[ \begin{array}{l r} v_k = e^{(2k\pi) / N} & \text{ k = 0, ..., nterms - 1} \end{array} \]

If rootsOfOne() is invoked with argument N, the N roots are returned in a vector of type RWMathVec<DComplex> with N elements.

template<class T >
RWMathVec< T > sin ( const RWMathVec< T > &  V)
related

The function sin() takes x as an argument and returns y such that \(y_{i} = sin(x_{i})\). The xi are in radians. For complex classes, the complex sine is returned.

template<class T >
RWMathVec< T > sinh ( const RWMathVec< T > &  V)
related

The function sinh() takes x as an argument and returns y such that \(y_{i} = sinh(x_{i})\). For complex classes, the complex hyperbolic sine is returned.

template<class T>
double skewness ( const RWMathVec< double > &  )
related
Header File
#include <rw/dstats.h>

Returns the skewness of a vector of doubles:

\[ \frac{1}{N}\sum_{i=0}^{N-1}\left ( \frac{x_{i}-\left \langle x \right \rangle}{\sigma} \right )^3 \]

where <x> is the mean of the vector and \( \sigma \) is its standard deviation, that is, the square root of the variance.

template<class T>
RWMathVec< double > sort ( const RWMathVec< double > &  )
related
Header File
#include <rw/dstats.h>

Returns a sorted vector, smallest to largest.

template<class T>
double spectralVariance ( const RWMathVec< DComplex > &  )
related

Returns the spectral variance of a Fourier transformed series. If v is a complex series containing the complex spectral estimates, the spectral variance S is given by:

\[ \text{S} = \sum_{i=0}^{N-1}\left ( \text{Re}(v_{i})^2 + \text{Im}(v_{i})^2 \right ) \]

Note that the first term, the mean, is excluded from the sum.

template<class T >
RWMathVec< T > sqrt ( const RWMathVec< T > &  V)
related

The square root function. Takes x as an argument and returns y such that \(y_{i} = (x_{i})^{1/2}\). For complex classes, the principal value of the complex square root is returned.

template<class T >
T sum ( const RWMathVec< T > &  )
related

Returns the sum of the elements of the vector. For example, if x = [1, 4, 3, 4], then y = 12.

template<class T >
RWMathVec< T > tan ( const RWMathVec< T > &  V)
related

The function tan() takes argument x and returns y such that \(y_{i} = tan(x_{i})\).

template<class T >
RWMathVec< T > tanh ( const RWMathVec< T > &  V)
related

The function tanh() takes argument x and returns y such that \(y_{i} = tanh(x_{i})\).

template<class T>
RWMathVec< signed char > toChar ( const RWMathVec< int > &  v)
related

Converts an RWMathVec<int> instance into a corresponding RWMathVec<signed char> instance. Note that this is a narrowing operation; high order bits are removed.

See also
RWConvertMathVec
template<class T>
RWMathVec< float > toFloat ( const RWMathVec< double > &  v)
related

Converts an RWMathVec<double> instance into a corresponding RWMathVec<float> instance. Note that this is a narrowing operation; high order bits are removed.

See also
RWConvertMathVec
template<class T>
RWMathVec< int > toInt ( const RWMathVec< double > &  v)
related

Converts an RWMathVec<double> instance into a corresponding RWMathVec<int> instance. Note that truncation occurs.

See also
RWConvertMathVec
template<class T>
RWMathVec< int > toInt ( const RWMathVec< float > &  v)
related

Converts an RWMathVec<float> instance into a corresponding RWMathVec<int> instance. Note that truncation occurs.

See also
RWConvertMathVec
template<class T>
double variance ( const RWMathVec< double > &  )
related

Takes a vector x as an argument and returns its variance y as in:

\[ y=\frac{1}{N}\sum_{i=0}^{N-1}(x_i-<x>)^2 \]

where <x> is the mean of the vector and N is the length of the vector. Note that this is the biased variance.

template<class T>
double variance ( const RWMathVec< DComplex > &  )
related

Takes a vector x as an argument and returns its variance y as in:

\[ y=\frac{1}{N}\sum_{i=0}^{N-1}(x_i-<x>)^2 \]

where <x> is the mean of the vector and N is the length of the vector. Note that this is the biased variance.

template<class T>
float variance ( const RWMathVec< float > &  )
related

Takes a vector x as an argument and returns its variance y as in:

\[ y=\frac{1}{N}\sum_{i=0}^{N-1}(x_i-<x>)^2 \]

where <x> is the mean of the vector and N is the length of the vector. Note that this is the biased variance.

Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.