Honeycomb  0.1
Component-Model Framework
Public Member Functions | List of all members
honey::Vec< Dim, Real, Options, Alloc > Class Template Reference

N-dimensional vector. More...

#include <Traits.h>

Inheritance diagram for honey::Vec< Dim, Real, Options, Alloc >:
Inheritance graph
[legend]
Collaboration diagram for honey::Vec< Dim, Real, Options, Alloc >:
Collaboration graph
[legend]

Public Member Functions

 Vec ()
 No init. More...
 
template<class Int >
 Vec (Int dim, typename std::enable_if< std::is_integral< Int >::value &&s_size==matrix::dynamic >::type *_=0)
 Allocate elements for dimension size, only available if vector is dynamic. More...
 
 Vec (Real scalar)
 Construct uniform vector. More...
 
 Vec (const Real *a, sdt dim)
 Initialize from array with dimension dim More...
 
 Vec (const Alloc &alloc)
 Construct with allocator, for a dynamic vector. Allocator element type must be int8. More...
 
template<class T >
 Vec (const MatrixBase< T > &rhs)
 Construct from row or column vector of any dimension. Asserts that if this vector has a fixed dimension then it matches rhs. More...
 
template<class T >
Vecoperator= (const MatrixBase< T > &rhs)
 Assign to row or column vector of any dimension. Asserts that if this vector has a fixed dimension then it matches rhs. More...
 
- Public Member Functions inherited from honey::VecBase< Vec< Dim, Real, Options, Alloc > >
VecSfromAxis (sdt i)
 Initialize with unit axis (all zeros except for a one at index i) More...
 
VecBaseoperator= (const MatrixBase< T > &rhs)
 Assign to row or column vector of any dimension. Asserts that if this vector has a fixed dimension then it matches rhs. More...
 
vec::priv::Segment< VecS, Dim >::type segment (sdt i, sdt dim=-1)
 Get segment at offset i with dimension dim. If dimension is fixed then dim may be left unspecified. Segments are the vector analog of matrix blocks. More...
 
vec::priv::Segment< const VecS, Dim >::type segment (sdt i, sdt dim=-1) const
 
vec::priv::Segment< VecS >::type segment (sdt i, sdt dim)
 Get dynamic segment at offset i with dimension dim More...
 
vec::priv::Segment< const VecS >::type segment (sdt i, sdt dim) const
 
VecSresize (sdt dim)
 Sets number of dimensions and reallocates only if different. All previous data is lost on reallocation. Returns self. More...
 
Real lengthSqr () const
 Get the square of the length. More...
 
Real length () const
 Get length (magnitude) of vector. More...
 
VecS normalize (optional< Real & > len=optnull) const
 Get unit vector. The pre-normalized length will be returned in len if specified. More...
 
Real dot (const VecBase< T > &v) const
 Vector dot product. More...
 
- Public Member Functions inherited from honey::MatrixBase< Vec< Dim, Real, Options, Alloc > >
MatrixSfromArray (const Num *a, bool rowMajor=true)
 Initialize from array. If the array is in row-major format set rowMajor to true, otherwise set to false for column-major. More...
 
MatrixSfromArray (const Real *a, bool rowMajor=true)
 
MatrixSfromZero ()
 Zero all elements. More...
 
MatrixSfromScalar (Real f)
 Initialize with scalar in every element. More...
 
MatrixSfromIdentity ()
 Make matrix identity. For non-square matrices the identity is in the upper-left square block, the rest is filled with zero. More...
 
matrix::Builder< MatrixSoperator<< (T &&val)
 Initialize matrix elements from scalars and other matrices using the comma operator: Matrix() << 1, 2, vec*5 ... The number of assigned elements must total up to be the matrix size exactly. More...
 
MatrixBaseoperator= (const MatrixBase< T > &rhs)
 Assign to matrix of any size. Asserts that any fixed dimensions in this matrix match those in rhs. More...
 
Matrix cast ()
 Convert to a matrix of another real type. More...
 
bool operator== (const MatrixBase< T > &rhs) const
 
bool operator!= (const MatrixBase< T > &rhs) const
 
bool operator< (const MatrixBase< T > &rhs) const
 
bool operator> (const MatrixBase< T > &rhs) const
 
bool operator<= (const MatrixBase< T > &rhs) const
 
bool operator>= (const MatrixBase< T > &rhs) const
 
Res && add (const T &rhs, Res &&res) const
 Add another matrix. Stores result in and returns res. res may reference the same matrix as this or rhs. More...
 
MatrixS operator+ () const
 
MatrixS operator+ (const MatrixBase< T > &rhs) const
 
MatrixSoperator+= (const MatrixBase< T > &rhs)
 
Res && sub (const T &rhs, Res &&res) const
 Subtract another matrix. Stores result in and returns res. res may reference the same matrix as this or rhs. More...
 
MatrixS operator- () const
 
MatrixS operator- (const MatrixBase< T > &rhs) const
 
MatrixSoperator-= (const MatrixBase< T > &rhs)
 
Res && mul (const T &rhs, Res &&res) const
 Multiply with another matrix. This mat's column size must match rhs' row size. Stores result in and returns res. Complexity: $ O(m n\ rhs_n) $. More...
 
Matrix< s_rows, T::s_cols, Realoperator* (const T &rhs) const
 Multiply with another matrix. Returns a new matrix. More...
 
MatrixS operator* (Real rhs) const
 
MatrixSoperator*= (const MatrixBase< T > &rhs)
 
MatrixSoperator*= (Real rhs)
 
MatrixS operator/ (Real rhs) const
 
MatrixSoperator/= (Real rhs)
 
MatrixS elemAdd (Real rhs) const
 Add rhs to each element. Returns a new matrix with the results. More...
 
MatrixSelemAddEq (Real rhs)
 Add rhs to each element. More...
 
MatrixS elemSub (Real rhs) const
 Subtract rhs from each element. Returns a new matrix with the results. More...
 
MatrixSelemSubEq (Real rhs)
 Subtract rhs from each element. More...
 
MatrixS elemMul (const MatrixBase< T > &rhs) const
 Multiply each element with its corresponding element in rhs. Returns a new matrix with the results. More...
 
MatrixSelemMulEq (const MatrixBase< T > &rhs)
 Multiply each element with its corresponding element in rhs. More...
 
MatrixS elemDiv (const MatrixBase< T > &rhs) const
 Divide each element by its corresponding element in rhs. Returns a new matrix with the results. More...
 
MatrixSelemDivEq (const MatrixBase< T > &rhs)
 Divide each element by its corresponding element in rhs. More...
 
MatrixS elemAbs () const
 Get the absolute value of each element. Returns a new matrix with the results. More...
 
MatrixS elemSqr () const
 Square each element. Returns a new matrix with the results. More...
 
MatrixS elemInverse () const
 Inverse each element. Returns a new matrix with the results. More...
 
MatrixS elemMin (const MatrixBase< T > &rhs) const
 Get the min of each element and its corresponding element in rhs. Returns a new matrix with the results. More...
 
MatrixS elemMax (const MatrixBase< T > &rhs) const
 Get the max of each element and its corresponding element in rhs. Returns a new matrix with the results. More...
 
bool isZero () const
 Check if each element is exactly zero. More...
 
bool isNearZero (Real tol=Real_::zeroTol) const
 Check if each element is close to zero. More...
 
MatrixS clamp (const MatrixBase< T > &min, const MatrixBase< T > &max) const
 Clamp each element between its corresponding elements in min and max. Returns a new matrix with the results. More...
 
Real sum () const
 Get the sum of all elements. More...
 
Real prod () const
 Get the product of all elements. More...
 
Real mean () const
 Get the mean of all elements. More...
 
Real min () const
 Get the minimum element. More...
 
Real max () const
 Get the maximum element. More...
 
matrix::Block< MatrixS, Rows, Cols > block (sdt row, sdt col, sdt rows=-1, sdt cols=-1)
 Get block at offset (row,col) with size (Rows, Cols). If Rows or Cols is fixed then rows or cols may be left unspecified. More...
 
matrix::Block< const MatrixS, Rows, Cols > block (sdt row, sdt col, sdt rows=-1, sdt cols=-1) const
 
matrix::Block< MatrixSblock (sdt row, sdt col, sdt rows, sdt cols)
 Get dynamic block at offset (row,col) with size (rows, cols) More...
 
matrix::Block< const MatrixSblock (sdt row, sdt col, sdt rows, sdt cols) const
 
matrix::Block< MatrixS, 1, s_cols > row (sdt row)
 Get row as a row vector. More...
 
matrix::Block< const MatrixS, 1, s_cols > row (sdt row) const
 
matrix::Block< MatrixS, s_rows, 1 > col (sdt col)
 Get column as a column vector. More...
 
matrix::Block< const MatrixS, s_rows, 1 > col (sdt col) const
 
MatrixSresize (sdt rows, sdt cols)
 Sets number of rows/columns and reallocates only if the size has changed (rows*cols). All previous data is lost on reallocation. Returns self. More...
 
matrix::Iter< MatrixSbegin ()
 Get an iterator over the elements in row-major order. More...
 
matrix::Iter< const MatrixSbegin () const
 
matrix::Iter< MatrixSend ()
 Get an iterator to the end of the iteration provided by begin() More...
 
matrix::Iter< const MatrixSend () const
 
matrix::Iter< MatrixSiter (sdt i)
 Get an iterator to the element at index. More...
 
matrix::Iter< const MatrixSiter (sdt i) const
 
matrix::Iter< MatrixSiter (sdt row, sdt col)
 Get an iterator to the element at (row, col) More...
 
matrix::Iter< const MatrixSiter (sdt row, sdt col) const
 
Num * toArray (Num *a, bool rowMajor=true) const
 Copy matrix into array. If the array is in row-major format set rowMajor to true, otherwise set to false for column-major. More...
 
RealtoArray (Real *a, bool rowMajor=true) const
 
Res && transpose (Res &&res) const
 $ M^T $ transpose and store result in res. Returns res. More...
 
Matrix< s_cols, s_rows, Realtranspose () const
 Returns new matrix. More...
 
void transposeInPlace ()
 transpose and store in this matrix, only valid for square matrices More...
 
Res && transposeMul (const T &rhs, Res &&res) const
 $ M^T * rhs $ Stores result in and returns res. More...
 
Matrix< s_cols, T::s_cols, RealtransposeMul (const T &rhs) const
 Returns new matrix. More...
 
Res && mulTranspose (const T &rhs, Res &&res) const
 $ M * rhs^T $ Stores result in and returns res. More...
 
Matrix< s_rows, T::s_rows, RealmulTranspose (const T &rhs) const
 Returns new matrix. More...
 
Res && transposeMulTranspose (const T &rhs, Res &&res) const
 $ M^T * rhs^T = (rhs*M)^T $ Stores result in and returns res. More...
 
Matrix< s_cols, T::s_rows, RealtransposeMulTranspose (const T &rhs) const
 Returns new matrix. More...
 
auto minor (sdt row, sdt col) const -> Matrix< (s_rows > 0)?s_rows-1:s_rows, (s_cols > 0)?s_cols-1:s_cols, Real >
 Returns a matrix without the selected row and column. More...
 
Matrix< s_cols, s_rows, Realinverse (optional< Real & > det=optnull) const
 Get the pseudo-inverse of this matrix. The pseudo-determinant will be returned in det if specified. More...
 
Real determinant () const
 Get the determinant. Returns the pseudo-determinant if this matrix is not square. More...
 
Real cond () const
 Get the condition value. A high value means the matrix is ill-conditioned and close to singular, so inversion and linear ops will be unreliable. More...
 

Additional Inherited Members

- Public Types inherited from honey::VecBase< Vec< Dim, Real, Options, Alloc > >
typedef Vec< Dim, Real, Options, Alloc > VecS
 
typedef Numeral< Real >::Real_ Real_
 
- Public Types inherited from honey::MatrixBase< Vec< Dim, Real, Options, Alloc > >
typedef Vec< Dim, Real, Options, Alloc > MatrixS
 
typedef Vec< s_rows, RealVecCol
 
typedef Vec< s_cols, Real, matrix::Option::vecRow > VecRow
 
- Protected Types inherited from honey::VecBase< Vec< Dim, Real, Options, Alloc > >
typedef Alge_< RealAlge
 
- Protected Types inherited from honey::MatrixBase< Vec< Dim, Real, Options, Alloc > >
typedef matrix::priv::Traits< Vec< Dim, Real, Options, Alloc > >::Storage Storage
 
typedef Numeral< Real >::Real_ Real_
 
typedef Real_::DoubleType Double_
 
typedef Double_::Real Double
 
typedef Alge_< RealAlge
 
typedef Alge_< DoubleAlge_d
 
typedef Trig_< RealTrig
 
typedef Svd< RealSvd
 
- Protected Member Functions inherited from honey::MatrixBase< Vec< Dim, Real, Options, Alloc > >
const Realm (sdt i) const
 Access matrix element at index. Wrapper for convenience only, more readable than (*this)(i) More...
 
Realm (sdt i)
 
const Realm (sdt row, sdt col) const
 Access matrix element with (row, column) More...
 
Realm (sdt row, sdt col)
 
MatrixSfromColMajor (const Num *a)
 
Num * toColMajor (Num *a) const
 

Detailed Description

template<sdt Dim, class Real, int Options, class Alloc>
class honey::Vec< Dim, Real, Options, Alloc >

N-dimensional vector.

Constructor & Destructor Documentation

template<sdt Dim, class Real, int Options, class Alloc>
honey::Vec< Dim, Real, Options, Alloc >::Vec ( )
inline

No init.

template<sdt Dim, class Real, int Options, class Alloc>
template<class Int >
honey::Vec< Dim, Real, Options, Alloc >::Vec ( Int  dim,
typename std::enable_if< std::is_integral< Int >::value &&s_size==matrix::dynamic >::type *  _ = 0 
)
inlineexplicit

Allocate elements for dimension size, only available if vector is dynamic.

template<sdt Dim, class Real, int Options, class Alloc>
honey::Vec< Dim, Real, Options, Alloc >::Vec ( Real  scalar)
inlineexplicit

Construct uniform vector.

template<sdt Dim, class Real, int Options, class Alloc>
honey::Vec< Dim, Real, Options, Alloc >::Vec ( const Real a,
sdt  dim 
)
inline

Initialize from array with dimension dim

template<sdt Dim, class Real, int Options, class Alloc>
honey::Vec< Dim, Real, Options, Alloc >::Vec ( const Alloc &  alloc)
inline

Construct with allocator, for a dynamic vector. Allocator element type must be int8.

template<sdt Dim, class Real, int Options, class Alloc>
template<class T >
honey::Vec< Dim, Real, Options, Alloc >::Vec ( const MatrixBase< T > &  rhs)
inline

Construct from row or column vector of any dimension. Asserts that if this vector has a fixed dimension then it matches rhs.

Member Function Documentation

template<sdt Dim, class Real, int Options, class Alloc>
template<class T >
Vec& honey::Vec< Dim, Real, Options, Alloc >::operator= ( const MatrixBase< T > &  rhs)
inline

Assign to row or column vector of any dimension. Asserts that if this vector has a fixed dimension then it matches rhs.


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