Ravelin
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
VECTORN Class Reference

A generic N-dimensional floating point vector. More...

#include <VectorN.h>

Public Member Functions

template<class ForwardIterator >
 VECTORN (ForwardIterator begin, ForwardIterator end)
 
 VECTORN ()
 Default constructor - constructs an empty vector.
 
 VECTORN (unsigned N)
 Constructs an uninitialized N-dimensional vector.
 
 VECTORN (const VECTORN &source)
 Copy constructor.
 
 VECTORN (const SHAREDVECTORN &source)
 Copy constructor.
 
 VECTORN (const CONST_SHAREDVECTORN &source)
 Copy constructor.
 
 VECTORN (const VECTOR2 &v)
 Constructs a vector from a VECTOR2.
 
 VECTORN (const VECTOR3 &v)
 Constructs a vector from a VECTOR3.
 
 VECTORN (const MATRIXN &v)
 Copy constructor.
 
 VECTORN (const SHAREDMATRIXN &v)
 Copy constructor.
 
 VECTORN (const CONST_SHAREDMATRIXN &v)
 Copy constructor.
 
 VECTORN (unsigned N, const REAL *array)
 Constructs a N-dimensional vector from the given array. More...
 
VECTORNnormalize ()
 
unsigned size () const
 
REAL norm_inf () const
 
REAL norm1 () const
 
REAL norm () const
 
REAL norm_sq () const
 
VECTORNaugment (const VECTORN &v)
 
VECTORNresize (unsigned N, bool preserve=false)
 
SHAREDVECTORN segment (unsigned start_idx, unsigned end_idx)
 Gets a subvector of this vector as a shared vector.
 
CONST_SHAREDVECTORN segment (unsigned start_idx, unsigned end_idx) const
 Gets a subvector of this vector as a shared vector.
 
VECTORNoperator= (REAL r)
 Assigns this vector to a scalar.
 
VECTORNoperator= (const VECTOR2 &source)
 Copies another vector.
 
VECTORNoperator= (const VECTOR3 &source)
 Copies another vector.
 
VECTORNoperator= (const VECTORN &source)
 Copies another vector.
 
VECTORNoperator= (const SHAREDVECTORN &source)
 Copies another vector.
 
VECTORNoperator= (const CONST_SHAREDVECTORN &source)
 Copies another vector.
 
VECTORNoperator= (const MATRIXN &source)
 Sets this vector to a matrix.
 
VECTORNoperator= (const SHAREDMATRIXN &source)
 Sets this vector to a matrix.
 
VECTORNoperator= (const CONST_SHAREDMATRIXN &source)
 Sets this vector to a matrix.
 
VECTORNoperator/= (REAL scalar)
 
REAL * data ()
 
const REAL * data () const
 
VECTORNresize (unsigned m, unsigned n, bool preserve=false)
 Resizes the vector.
 
void free_memory ()
 
void compress ()
 
unsigned rows () const
 
unsigned columns () const
 
unsigned leading_dim () const
 
unsigned inc () const
 
REAL & operator[] (unsigned i)
 Returns the desired component of this vector.
 
REAL operator[] (unsigned i) const
 Returns the desired component of this vector.
 
REAL * data (unsigned i)
 Gets the appropriate data element.
 
const REAL * data (unsigned i) const
 Gets the appropriate data element.
 
COLUMN_ITERATOR segment_iterator_begin (unsigned start, unsigned end)
 
CONST_COLUMN_ITERATOR segment_iterator_begin (unsigned start, unsigned end) const
 
COLUMN_ITERATOR segment_iterator_end (unsigned start, unsigned end)
 
CONST_COLUMN_ITERATOR segment_iterator_end (unsigned start, unsigned end) const
 
CONST_ROW_ITERATOR row_iterator_begin () const
 
CONST_ROW_ITERATOR row_iterator_end () const
 
ROW_ITERATOR row_iterator_begin ()
 
ROW_ITERATOR row_iterator_end ()
 
CONST_COLUMN_ITERATOR column_iterator_begin () const
 
CONST_COLUMN_ITERATOR column_iterator_end () const
 
COLUMN_ITERATOR column_iterator_begin ()
 
COLUMN_ITERATOR column_iterator_end ()
 
COLUMN_ITERATOR begin ()
 Returns the column iterator.
 
CONST_COLUMN_ITERATOR begin () const
 Returns the constant column iterator.
 
COLUMN_ITERATOR end ()
 Returns the column iterator.
 
CONST_COLUMN_ITERATOR end () const
 Returns the constant column iterator.
 
XVECTORN & set_zero ()
 Sets the vector to the zero vector.
 
XVECTORN & set_zero (unsigned m, unsigned n=1)
 Sets the vector to the zero vector.
 
XVECTORN & set_one ()
 Sets the vector to the zero vector.
 
XVECTORN & set_one (unsigned m, unsigned n=1)
 Sets the vector to the zero vector.
 
bool is_finite () const
 Returns true if all components of this vector are not infinite and not NaN, and false otherwise.
 
XVECTORN & negate ()
 Negates the matrix in place.
 
XVECTORN & operator*= (REAL scalar)
 Multiplies this vector in place by a scalar.
 
template<class V >
XVECTORN & set_sub_vec (unsigned start, const V &v)
 Sets a sub-vector of this vector. More...
 
template<class V >
XVECTORN & operator+= (const V &v)
 Adds a vector from this one in place.
 
template<class V >
XVECTORN & operator-= (const V &v)
 Subtracts a vector from this one in place.
 
template<class ForwardIterator , class V >
XVECTORN & set (ForwardIterator idx_begin, ForwardIterator idx_end, const V &v)
 Sets a subvector; other components are unchanged.
 
template<class V >
XVECTORN & set (std::vector< bool > &indices, const V &v)
 Sets a subvector; other components are unchanged.
 
template<class V >
V & get_sub_vec (unsigned start, unsigned end, V &v) const
 Gets a sub-vector from this vector. More...
 
template<class V >
bool operator< (const V &v) const
 Compares two vectors lexographically.
 
template<class V >
bool operator== (const V &v) const
 Compares two vectors. More...
 
template<class V >
REAL dot (const V &v) const
 Computes the dot-product between two vectors.
 
template<class V >
V & select (const std::vector< bool > &indices, V &v) const
 Gets a subvector (not necessarily contiguous)
 
template<class ForwardIterator , class V >
V & select (ForwardIterator idx_begin, ForwardIterator idx_end, V &v) const
 Gets a subvector (not necessarily contiguous)
 

Static Public Member Functions

static VECTORN construct_variable (unsigned N,...)
 Constructs a N-dimension vector from the list of double values. More...
 
static REAL norm_sq (const VECTORN &v)
 
static REAL norm (const VECTORN &v)
 
static VECTORN one (unsigned N)
 Returns a N-dimensional one vector.
 
static VECTORNconcat (const VECTORN &v1, const VECTORN &v2, VECTORN &result)
 Concatenates two vectors together and stores the result in a third.
 
static VECTORN zero (unsigned n)
 Returns a N-dimensional zero vector.
 
static VECTORNparse (const std::string &s, VECTORN &v)
 Parses a string for a vector value.
 
static VECTORN parse (const std::string &s)
 
template<class V1 , class V2 >
static REAL dot (const V1 &v1, const V2 &v2)
 Computes the dot-product between two vectors.
 
static REAL norm_inf (const XVECTORN &v)
 Computes the infinity norm of this vector.
 
static REAL norm1 (const XVECTORN &v)
 Computes the l1-norm of this vector.
 

Protected Attributes

SharedResizable< REAL > _data
 

Detailed Description

A generic N-dimensional floating point vector.

Constructor & Destructor Documentation

VECTORN::VECTORN ( unsigned  N,
const REAL *  array 
)

Constructs a N-dimensional vector from the given array.

Parameters
arraya N-dimensional (or larger) array

Member Function Documentation

VECTORN VECTORN::construct_variable ( unsigned  N,
  ... 
)
static

Constructs a N-dimension vector from the list of double values.

Note
There is no means in C++ to check the types of a list of variable arguments. If the variable arguments are not of type double, then unexpected values will result. Constructing a vector using the statement VECTORN::construct_variable(3, 1.0, 1.0, 0) is incorrect because the programmer has assumed that the integer 0 will be converted to a double type; this is not the case.
template<class V >
V& VECTORN::get_sub_vec ( unsigned  start,
unsigned  end,
V &  v 
) const
inline

Gets a sub-vector from this vector.

Parameters
start_idxthe starting index (inclusive)
end_idxthe ending index (exclusive)

Referenced by FSAB_ALGORITHM::apply_generalized_impulse().

template<class V >
bool VECTORN::operator== ( const V &  v) const
inline

Compares two vectors.

Note
this method exists solely for convenience of use with iterators
template<class V >
XVECTORN& VECTORN::set_sub_vec ( unsigned  start,
const V &  v 
)
inline

Sets a sub-vector of this vector.

Parameters
start_idxthe starting index (inclusive)
va (end_idx - start_idx + 1)-dimensional vector

Referenced by concat(), and SPARITH::concat().


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