MyraMath
Public Types | Public Member Functions | Static Public Member Functions | List of all members
myra::Vector< Number > Class Template Reference

Tabulates a vector of length N, allows random access. More...

#include <Vector.h>

Public Types

typedef std::pair< CVectorRange< Number >, CVectorRange< Number > > CPair
 Useful typedefs.
 
typedef std::pair< VectorRange< Number >, VectorRange< Number > > Pair
 
typedef ReflectPrecision< Number >::type Precision
 

Public Member Functions

 Vector ()
 Default constructor, makes size 0 empty Vector.
 
 Vector (int N)
 Constructs a Vector of length N, filled with Number(0)
 
 Vector (const Expression< 1, Number > &e)
 Constructs a Vector from an Expression.
 
 Vector (const Vector &that)
 Copy constructor.
 
void swap (Vector &that)
 Member swap.
 
 Vector (Vector &&that)
 Move constructor, default construct and swap idiom.
 
Vectoroperator= (Vector that)
 Copy-assignment operator, copy construct and swap idiom.
 
 Vector (const CVectorRange< Number > &that)
 Constructs from a VectorRange (same size, values copied).
 
 Vector (const CMatrixRange< Number > &that)
 Constructs from a MatrixRange, but only if it's exactly 1 row or 1 column.
 
 Vector (InputStream &in)
 InputStream constructor, complements write(OutputStream) method.
 
void write (OutputStream &out) const
 Writes to OutputStream, complements InputStream constructor.
 
const Vector< Number > & add_const () const
 Returns const reference to *this.
 
 ~Vector ()
 Releases internal resources.
 
int size () const
 Size inspector.
 
int n_words () const
 Storage requirements.
 
template<class Functor >
void transform (const Functor &f)
 Overwrites every x(n) in this Vector with f(x(n)).
 
Vectoroperator= (const CVectorRange< Number > &that)
 Assigns this = that.
 
Vectoroperator= (const Expression< 1, Number > &that)
 
void assign (const CVectorRange< Number > &that)
 Like operator =, but does not reallocate/resize. Requires matching sizes.
 
void assign (const Expression< 1, Number > &that)
 
void operator+= (const CVectorRange< Number > &that)
 Adds this += that.
 
void operator+= (const Expression< 1, Number > &that)
 
void operator-= (const CVectorRange< Number > &that)
 Subtracts this -= that.
 
void operator-= (const Expression< 1, Number > &that)
 
void operator*= (Number alpha)
 Scales this *= alpha.
 
void operator/= (Number alpha)
 Scales this /= alpha.
 
Vector< Number > operator- ()
 Unary minus (sign negation).
 
template<>
Vector< NumberSlogspace (NumberS x0, NumberS x1, int N)
 Generates a Vector filled with N Number's logarithmically spaced between (10^x0,10^x1)
 
template<>
Vector< NumberD > logspace (NumberD x0, NumberD x1, int N)
 
template<>
Vector< NumberC > logspace (NumberS x0, NumberS x1, int N)
 
template<>
Vector< NumberZ > logspace (NumberD x0, NumberD x1, int N)
 
CVectorRange< Number > range () const
 Explicit conversion, returns a VectorRange over all of *this.
 
VectorRange< Number > range ()
 Explicit conversion, returns a VectorRange over all of *this.
 
 operator CVectorRange< Number > () const
 Implicit conversion into a VectorRange.
 
 operator VectorRange< Number > ()
 Implicit conversion into a VectorRange.
 
CVectorRange< Number > window (int n0, int n1) const
 Returns a VectorRange over this(n0:n1)
 
VectorRange< Number > window (int n0, int n1)
 Returns a VectorRange over this(n0:n1)
 
Array1< CVectorRange< Number > > windows (const intCRange &n) const
 Returns multiple windows using given sizes.
 
Array1< VectorRange< Number > > windows (const intCRange &n)
 Returns multiple windows using given sizes.
 
CMatrixRange< Number > column () const
 Returns an Nx1 column-shaped MatrixRange over all of *this.
 
MatrixRange< Number > column ()
 Returns an Nx1 column-shaped MatrixRange over all of *this.
 
CMatrixRange< Number > row () const
 Returns a 1xN row-shaped MatrixRange over all of *this.
 
MatrixRange< Number > row ()
 Returns a 1xN row-shaped MatrixRange over all of *this.
 
const Number & operator() (int n) const
 Random accessor/mutator.
 
const Number & operator[] (int n) const
 Random accessor/mutator.
 
Number & operator() (int n)
 Random accessor/mutator.
 
Number & operator[] (int n)
 Random accessor/mutator.
 
const Number & at (int n) const
 Bounds checked random accessor/mutator.
 
Number & at (int n)
 Bounds checked random accessor/mutator.
 
CVectorRange< Number > first (int n) const
 Returns a VectorRange over the first n entries, this(0:n)
 
VectorRange< Number > first (int n)
 Returns a VectorRange over the first n entries, this(0:n)
 
CVectorRange< Number > cut_first (int n) const
 Returns a VectorRange that cuts the first n entries, this(n:N)
 
VectorRange< Number > cut_first (int n)
 Returns a VectorRange that cuts the first n entries, this(n:N)
 
CPair split_first (int n) const
 Splits into two VectorRange's, returns [this->first(n), this->cut_first(n)].
 
Pair split_first (int n)
 Splits into two VectorRange's, returns [this->first(n), this->cut_first(n)].
 
CVectorRange< Number > last (int n) const
 Returns a VectorRange over the last n entries, this(N-n:N)
 
VectorRange< Number > last (int n)
 Returns a VectorRange over the last n entries, this(N-n:N)
 
CVectorRange< Number > cut_last (int n) const
 Returns a VectorRange that cuts the last n entries, this(0:N-n)
 
VectorRange< Number > cut_last (int n)
 Returns a VectorRange that cuts the last n entries, this(0:N-n)
 
CPair split_last (int n) const
 Splits into two VectorRange's, returns [this->cut_last(n), this->last(n)].
 
Pair split_last (int n)
 Splits into two VectorRange's, returns [this->cut_last(n), this->last(n)].
 

Static Public Member Functions

static Vector< Number > random (int N)
 Generates a random Vector of specified size.
 
static Vector< Number > zeros (int N)
 Generates a zeros Vector of specified size.
 
static Vector< Number > ones (int N)
 Generates a ones Vector of specified size.
 
static Vector< Number > fill (int N, Number c)
 Generates a Vector of specified size filled with constant c.
 
static Vector< Number > fill (std::initializer_list< Number > list)
 Generates a Vector of specified size filled with a std::initializer_list.
 
static Vector< Number > linspace (Number x0, Number x1, int N)
 Generates a Vector filled with N Number's linearly spaced between (x0,x1).
 
static Vector< Number > logspace (Precision x0, Precision x1, int N)
 Generates a Vector filled with N Number's logarithmically spaced between (10^x0,10^x1).
 
static Vector< Number > evaluate (const Expression< 1, Number > &e)
 Generates a Vector by evaluating an arity-1 Expression of Number.
 

Detailed Description

template<class Number>
class myra::Vector< Number >

Tabulates a vector of length N, allows random access.


The documentation for this class was generated from the following files: