Simbody  3.6
SimTK::RowVectorBase< ELT > Class Template Reference

This is a dataless rehash of the MatrixBase class to specialize it for RowVectors. More...

Classes

struct  EltResult
 

Public Member Functions

RowVectorBaseoperator= (const RowVectorBase &b)
 Copy assignment is deep copy but behavior depends on type of lhs: if view, rhs must match. More...
 
RowVectorBaseoperator*= (const StdNumber &t)
 
RowVectorBaseoperator/= (const StdNumber &t)
 
RowVectorBaseoperator+= (const RowVectorBase &r)
 
RowVectorBaseoperator-= (const RowVectorBase &r)
 
template<class EE >
RowVectorBaseoperator= (const RowVectorBase< EE > &b)
 
template<class EE >
RowVectorBaseoperator+= (const RowVectorBase< EE > &b)
 
template<class EE >
RowVectorBaseoperator-= (const RowVectorBase< EE > &b)
 
RowVectorBaseoperator= (const ELT &t)
 Fill current allocation with copies of element. More...
 
template<class EE >
RowVectorBasecolScaleInPlace (const VectorBase< EE > &v)
 There's only one row here so it's a bit weird to use colScale rather than elementwiseMultiply, but there's nothing really wrong with it. More...
 
template<class EE >
void colScale (const VectorBase< EE > &v, typename EltResult< EE >::Mul &out) const
 
template<class EE >
EltResult< EE >::Mul colScale (const VectorBase< EE > &v) const
 
template<class EE >
RowVectorBaseelementwiseMultiplyInPlace (const RowVectorBase< EE > &r)
 
template<class EE >
void elementwiseMultiply (const RowVectorBase< EE > &v, typename EltResult< EE >::Mul &out) const
 
template<class EE >
EltResult< EE >::Mul elementwiseMultiply (const RowVectorBase< EE > &v) const
 
template<class EE >
RowVectorBaseelementwiseMultiplyFromLeftInPlace (const RowVectorBase< EE > &r)
 
template<class EE >
void elementwiseMultiplyFromLeft (const RowVectorBase< EE > &v, typename RowVectorBase< EE >::template EltResult< ELT >::Mul &out) const
 
template<class EE >
RowVectorBase< EE >::template EltResult< ELT >::Mul elementwiseMultiplyFromLeft (const RowVectorBase< EE > &v) const
 
template<class EE >
RowVectorBaseelementwiseDivideInPlace (const RowVectorBase< EE > &r)
 
template<class EE >
void elementwiseDivide (const RowVectorBase< EE > &v, typename EltResult< EE >::Dvd &out) const
 
template<class EE >
EltResult< EE >::Dvd elementwiseDivide (const RowVectorBase< EE > &v) const
 
template<class EE >
RowVectorBaseelementwiseDivideFromLeftInPlace (const RowVectorBase< EE > &r)
 
template<class EE >
void elementwiseDivideFromLeft (const RowVectorBase< EE > &v, typename RowVectorBase< EE >::template EltResult< ELT >::Dvd &out) const
 
template<class EE >
RowVectorBase< EE >::template EltResult< ELT >::Dvd elementwiseDivideFromLeft (const RowVectorBase< EE > &v) const
 
 operator const RowVector_< ELT > & () const
 
 operator RowVector_< ELT > & ()
 
 operator const RowVectorView_< ELT > & () const
 
 operator RowVectorView_< ELT > & ()
 
 operator const Matrix_< ELT > & () const
 
 operator Matrix_< ELT > & ()
 
 operator const MatrixView_< ELT > & () const
 
 operator MatrixView_< ELT > & ()
 
int size () const
 
int nrow () const
 
int ncol () const
 
ptrdiff_t nelt () const
 
TAbs abs () const
 
const ELT & operator[] (int j) const
 
ELT & operator[] (int j)
 
const ELT & operator() (int j) const
 
ELT & operator() (int j)
 
RowVectorView_< ELT > operator() (int j, int n) const
 
RowVectorView_< ELT > operator() (int j, int n)
 
RowVectorView_< ELT > index (const Array_< int > &indices) const
 
RowVectorView_< ELT > updIndex (const Array_< int > &indices)
 
RowVectorView_< ELT > operator() (const Array_< int > &indices) const
 
RowVectorView_< ELT > operator() (const Array_< int > &indices)
 
THerm transpose () const
 
THerm updTranspose ()
 
THerm operator~ () const
 
THerm operator~ ()
 
const RowVectorBaseoperator+ () const
 
const TNegnegate () const
 
TNegupdNegate ()
 
const TNegoperator- () const
 
TNegoperator- ()
 
RowVectorBaseresize (int n)
 
RowVectorBaseresizeKeep (int n)
 
void clear ()
 
ELT sum () const
 
VectorIterator< ELT, RowVectorBase< ELT > > begin ()
 
VectorIterator< ELT, RowVectorBase< ELT > > end ()
 
RowVectorBase "owner" construction

These constructors create new RowVectorBase objects which own their own data and are (at least by default) resizable.

The resulting matrices are 1 x n with the number of rows locked at 1. If there is any data allocated but not explicitly initialized, that data will be uninitialized garbage in Release builds but will be initialized to NaN (at a performance cost) in Debug builds.

 RowVectorBase (int n=0)
 Default constructor makes a 1x0 matrix locked at 1 row; you can provide an initial allocation if you want. More...
 
 RowVectorBase (const RowVectorBase &source)
 Copy constructor is a deep copy (not appropriate for views!). More...
 
 RowVectorBase (const TNeg &source)
 Implicit conversion from compatible row vector with negated elements. More...
 
 RowVectorBase (int n, const ELT &initialValue)
 Construct an owner row vector of length n, with each element initialized to the given value. More...
 
 RowVectorBase (int n, const ELT *cppInitialValues)
 Construct an owner vector of length n, with the elements initialized sequentially from a C++ array of elements which is assumed to be of length n. More...
 
RowVectorBase construction from pre-existing data

Construct a non-resizeable, RowVectorBase view of externally supplied data.

Note that stride should be interpreted as "the number of scalars between elements" and for composite elements may have a different value if the source is a C++ array of elements vs. a Simmatrix packed data array. We provide constructors for both read-only and writable external data.

 RowVectorBase (int n, int stride, const Scalar *s)
 Construct a read-only view of existing data. More...
 
 RowVectorBase (int n, int stride, Scalar *s)
 Construct a writable view into existing data. More...
 
RowVectorBase construction from an existing Helper.

Create a new RowVectorBase from an existing helper.

Both shallow (view) and deep copies are possible. For shallow copies, there is a constructor providing a read-only view of the original data and one providing a writable view into the original data.

 RowVectorBase (MatrixHelper< Scalar > &h, const typename MatrixHelper< Scalar >::ShallowCopy &s)
 Construct a writable view into the source data. More...
 
 RowVectorBase (const MatrixHelper< Scalar > &h, const typename MatrixHelper< Scalar >::ShallowCopy &s)
 Construct a read-only view of the source data. More...
 
 RowVectorBase (const MatrixHelper< Scalar > &h, const typename MatrixHelper< Scalar >::DeepCopy &d)
 Construct a new owner vector initialized with the data from the source. More...
 

Protected Member Functions

 RowVectorBase (MatrixHelperRep< Scalar > *hrep)
 

Related Functions

(Note that these are not member functions.)

Matrix_<T> serialization and I/O

These methods are at namespace scope but are logically part of the Vector classes.

These deal with reading and writing Vectors from and to streams, which places an additional requirement on the element type T: the element must support the same operation you are trying to do on the Vector as a whole.

template<class E >
void writeUnformatted (std::ostream &o, const RowVectorBase< E > &v)
 Specialize for RowVectorBase<E> to delegate to element type E, with spaces separating the elements; raw output is same as VectorBase. More...
 

Detailed Description

template<class ELT>
class SimTK::RowVectorBase< ELT >

This is a dataless rehash of the MatrixBase class to specialize it for RowVectors.

This mostly entails overriding a few of the methods. Note that all the MatrixBase operations remain available if you static_cast this up to a MatrixBase.

Constructor & Destructor Documentation

◆ RowVectorBase() [1/11]

template<class ELT >
SimTK::RowVectorBase< ELT >::RowVectorBase ( int  n = 0)
inlineexplicit

Default constructor makes a 1x0 matrix locked at 1 row; you can provide an initial allocation if you want.

◆ RowVectorBase() [2/11]

template<class ELT >
SimTK::RowVectorBase< ELT >::RowVectorBase ( const RowVectorBase< ELT > &  source)
inline

Copy constructor is a deep copy (not appropriate for views!).

That means it creates a new, densely packed vector whose elements are initialized from the source object.

◆ RowVectorBase() [3/11]

template<class ELT >
SimTK::RowVectorBase< ELT >::RowVectorBase ( const TNeg source)
inline

Implicit conversion from compatible row vector with negated elements.

◆ RowVectorBase() [4/11]

template<class ELT >
SimTK::RowVectorBase< ELT >::RowVectorBase ( int  n,
const ELT &  initialValue 
)
inline

Construct an owner row vector of length n, with each element initialized to the given value.

◆ RowVectorBase() [5/11]

template<class ELT >
SimTK::RowVectorBase< ELT >::RowVectorBase ( int  n,
const ELT *  cppInitialValues 
)
inline

Construct an owner vector of length n, with the elements initialized sequentially from a C++ array of elements which is assumed to be of length n.

Note that we are expecting C++ packing; don't use this to initialize one Simmatrix vector from another because Simmatrix may pack its elements more densely than C++.

◆ RowVectorBase() [6/11]

template<class ELT >
SimTK::RowVectorBase< ELT >::RowVectorBase ( int  n,
int  stride,
const Scalar *  s 
)
inline

Construct a read-only view of existing data.

◆ RowVectorBase() [7/11]

template<class ELT >
SimTK::RowVectorBase< ELT >::RowVectorBase ( int  n,
int  stride,
Scalar *  s 
)
inline

Construct a writable view into existing data.

◆ RowVectorBase() [8/11]

template<class ELT >
SimTK::RowVectorBase< ELT >::RowVectorBase ( MatrixHelper< Scalar > &  h,
const typename MatrixHelper< Scalar >::ShallowCopy &  s 
)
inline

Construct a writable view into the source data.

◆ RowVectorBase() [9/11]

template<class ELT >
SimTK::RowVectorBase< ELT >::RowVectorBase ( const MatrixHelper< Scalar > &  h,
const typename MatrixHelper< Scalar >::ShallowCopy &  s 
)
inline

Construct a read-only view of the source data.

◆ RowVectorBase() [10/11]

template<class ELT >
SimTK::RowVectorBase< ELT >::RowVectorBase ( const MatrixHelper< Scalar > &  h,
const typename MatrixHelper< Scalar >::DeepCopy &  d 
)
inline

Construct a new owner vector initialized with the data from the source.

◆ RowVectorBase() [11/11]

template<class ELT >
SimTK::RowVectorBase< ELT >::RowVectorBase ( MatrixHelperRep< Scalar > *  hrep)
inlineexplicitprotected

Member Function Documentation

◆ operator=() [1/3]

template<class ELT >
RowVectorBase& SimTK::RowVectorBase< ELT >::operator= ( const RowVectorBase< ELT > &  b)
inline

Copy assignment is deep copy but behavior depends on type of lhs: if view, rhs must match.

If owner, we reallocate and copy rhs.

◆ operator*=()

template<class ELT >
RowVectorBase& SimTK::RowVectorBase< ELT >::operator*= ( const StdNumber &  t)
inline

◆ operator/=()

template<class ELT >
RowVectorBase& SimTK::RowVectorBase< ELT >::operator/= ( const StdNumber &  t)
inline

◆ operator+=() [1/2]

template<class ELT >
RowVectorBase& SimTK::RowVectorBase< ELT >::operator+= ( const RowVectorBase< ELT > &  r)
inline

◆ operator-=() [1/2]

template<class ELT >
RowVectorBase& SimTK::RowVectorBase< ELT >::operator-= ( const RowVectorBase< ELT > &  r)
inline

◆ operator=() [2/3]

template<class ELT >
template<class EE >
RowVectorBase& SimTK::RowVectorBase< ELT >::operator= ( const RowVectorBase< EE > &  b)
inline

◆ operator+=() [2/2]

template<class ELT >
template<class EE >
RowVectorBase& SimTK::RowVectorBase< ELT >::operator+= ( const RowVectorBase< EE > &  b)
inline

◆ operator-=() [2/2]

template<class ELT >
template<class EE >
RowVectorBase& SimTK::RowVectorBase< ELT >::operator-= ( const RowVectorBase< EE > &  b)
inline

◆ operator=() [3/3]

template<class ELT >
RowVectorBase& SimTK::RowVectorBase< ELT >::operator= ( const ELT &  t)
inline

Fill current allocation with copies of element.

Note that this is not the same behavior as assignment for Matrices, where only the diagonal is set (and everything else is set to zero.)

◆ colScaleInPlace()

template<class ELT >
template<class EE >
RowVectorBase& SimTK::RowVectorBase< ELT >::colScaleInPlace ( const VectorBase< EE > &  v)
inline

There's only one row here so it's a bit weird to use colScale rather than elementwiseMultiply, but there's nothing really wrong with it.

Using rowScale would be really wacky since it is the same as a scalar multiply. We won't support rowScale here except through inheritance where it will not be much use.

◆ colScale() [1/2]

template<class ELT >
template<class EE >
void SimTK::RowVectorBase< ELT >::colScale ( const VectorBase< EE > &  v,
typename EltResult< EE >::Mul &  out 
) const
inline

◆ colScale() [2/2]

template<class ELT >
template<class EE >
EltResult<EE>::Mul SimTK::RowVectorBase< ELT >::colScale ( const VectorBase< EE > &  v) const
inline

◆ elementwiseMultiplyInPlace()

template<class ELT >
template<class EE >
RowVectorBase& SimTK::RowVectorBase< ELT >::elementwiseMultiplyInPlace ( const RowVectorBase< EE > &  r)
inline

◆ elementwiseMultiply() [1/2]

template<class ELT >
template<class EE >
void SimTK::RowVectorBase< ELT >::elementwiseMultiply ( const RowVectorBase< EE > &  v,
typename EltResult< EE >::Mul &  out 
) const
inline

◆ elementwiseMultiply() [2/2]

template<class ELT >
template<class EE >
EltResult<EE>::Mul SimTK::RowVectorBase< ELT >::elementwiseMultiply ( const RowVectorBase< EE > &  v) const
inline

◆ elementwiseMultiplyFromLeftInPlace()

template<class ELT >
template<class EE >
RowVectorBase& SimTK::RowVectorBase< ELT >::elementwiseMultiplyFromLeftInPlace ( const RowVectorBase< EE > &  r)
inline

◆ elementwiseMultiplyFromLeft() [1/2]

template<class ELT >
template<class EE >
void SimTK::RowVectorBase< ELT >::elementwiseMultiplyFromLeft ( const RowVectorBase< EE > &  v,
typename RowVectorBase< EE >::template EltResult< ELT >::Mul &  out 
) const
inline

◆ elementwiseMultiplyFromLeft() [2/2]

template<class ELT >
template<class EE >
RowVectorBase<EE>::template EltResult<ELT>::Mul SimTK::RowVectorBase< ELT >::elementwiseMultiplyFromLeft ( const RowVectorBase< EE > &  v) const
inline

◆ elementwiseDivideInPlace()

template<class ELT >
template<class EE >
RowVectorBase& SimTK::RowVectorBase< ELT >::elementwiseDivideInPlace ( const RowVectorBase< EE > &  r)
inline

◆ elementwiseDivide() [1/2]

template<class ELT >
template<class EE >
void SimTK::RowVectorBase< ELT >::elementwiseDivide ( const RowVectorBase< EE > &  v,
typename EltResult< EE >::Dvd &  out 
) const
inline

◆ elementwiseDivide() [2/2]

template<class ELT >
template<class EE >
EltResult<EE>::Dvd SimTK::RowVectorBase< ELT >::elementwiseDivide ( const RowVectorBase< EE > &  v) const
inline

◆ elementwiseDivideFromLeftInPlace()

template<class ELT >
template<class EE >
RowVectorBase& SimTK::RowVectorBase< ELT >::elementwiseDivideFromLeftInPlace ( const RowVectorBase< EE > &  r)
inline

◆ elementwiseDivideFromLeft() [1/2]

template<class ELT >
template<class EE >
void SimTK::RowVectorBase< ELT >::elementwiseDivideFromLeft ( const RowVectorBase< EE > &  v,
typename RowVectorBase< EE >::template EltResult< ELT >::Dvd &  out 
) const
inline

◆ elementwiseDivideFromLeft() [2/2]

template<class ELT >
template<class EE >
RowVectorBase<EE>::template EltResult<ELT>::Dvd SimTK::RowVectorBase< ELT >::elementwiseDivideFromLeft ( const RowVectorBase< EE > &  v) const
inline

◆ operator const RowVector_< ELT > &()

template<class ELT >
SimTK::RowVectorBase< ELT >::operator const RowVector_< ELT > & ( ) const
inline

◆ operator RowVector_< ELT > &()

template<class ELT >
SimTK::RowVectorBase< ELT >::operator RowVector_< ELT > & ( )
inline

◆ operator const RowVectorView_< ELT > &()

template<class ELT >
SimTK::RowVectorBase< ELT >::operator const RowVectorView_< ELT > & ( ) const
inline

◆ operator RowVectorView_< ELT > &()

template<class ELT >
SimTK::RowVectorBase< ELT >::operator RowVectorView_< ELT > & ( )
inline

◆ operator const Matrix_< ELT > &()

template<class ELT >
SimTK::RowVectorBase< ELT >::operator const Matrix_< ELT > & ( ) const
inline

◆ operator Matrix_< ELT > &()

template<class ELT >
SimTK::RowVectorBase< ELT >::operator Matrix_< ELT > & ( )
inline

◆ operator const MatrixView_< ELT > &()

template<class ELT >
SimTK::RowVectorBase< ELT >::operator const MatrixView_< ELT > & ( ) const
inline

◆ operator MatrixView_< ELT > &()

template<class ELT >
SimTK::RowVectorBase< ELT >::operator MatrixView_< ELT > & ( )
inline

◆ size()

template<class ELT >
int SimTK::RowVectorBase< ELT >::size ( ) const
inline

◆ nrow()

template<class ELT >
int SimTK::RowVectorBase< ELT >::nrow ( ) const
inline

◆ ncol()

template<class ELT >
int SimTK::RowVectorBase< ELT >::ncol ( ) const
inline

◆ nelt()

template<class ELT >
ptrdiff_t SimTK::RowVectorBase< ELT >::nelt ( ) const
inline

◆ abs()

template<class ELT >
TAbs SimTK::RowVectorBase< ELT >::abs ( ) const
inline

◆ operator[]() [1/2]

template<class ELT >
const ELT& SimTK::RowVectorBase< ELT >::operator[] ( int  j) const
inline

◆ operator[]() [2/2]

template<class ELT >
ELT& SimTK::RowVectorBase< ELT >::operator[] ( int  j)
inline

◆ operator()() [1/6]

template<class ELT >
const ELT& SimTK::RowVectorBase< ELT >::operator() ( int  j) const
inline

◆ operator()() [2/6]

template<class ELT >
ELT& SimTK::RowVectorBase< ELT >::operator() ( int  j)
inline

◆ operator()() [3/6]

template<class ELT >
RowVectorView_<ELT> SimTK::RowVectorBase< ELT >::operator() ( int  j,
int  n 
) const
inline

◆ operator()() [4/6]

template<class ELT >
RowVectorView_<ELT> SimTK::RowVectorBase< ELT >::operator() ( int  j,
int  n 
)
inline

◆ index()

template<class ELT >
RowVectorView_<ELT> SimTK::RowVectorBase< ELT >::index ( const Array_< int > &  indices) const
inline

◆ updIndex()

template<class ELT >
RowVectorView_<ELT> SimTK::RowVectorBase< ELT >::updIndex ( const Array_< int > &  indices)
inline

◆ operator()() [5/6]

template<class ELT >
RowVectorView_<ELT> SimTK::RowVectorBase< ELT >::operator() ( const Array_< int > &  indices) const
inline

◆ operator()() [6/6]

template<class ELT >
RowVectorView_<ELT> SimTK::RowVectorBase< ELT >::operator() ( const Array_< int > &  indices)
inline

◆ transpose()

template<class ELT >
THerm SimTK::RowVectorBase< ELT >::transpose ( ) const
inline

◆ updTranspose()

template<class ELT >
THerm SimTK::RowVectorBase< ELT >::updTranspose ( )
inline

◆ operator~() [1/2]

template<class ELT >
THerm SimTK::RowVectorBase< ELT >::operator~ ( ) const
inline

◆ operator~() [2/2]

template<class ELT >
THerm SimTK::RowVectorBase< ELT >::operator~ ( )
inline

◆ operator+()

template<class ELT >
const RowVectorBase& SimTK::RowVectorBase< ELT >::operator+ ( ) const
inline

◆ negate()

template<class ELT >
const TNeg& SimTK::RowVectorBase< ELT >::negate ( ) const
inline

◆ updNegate()

template<class ELT >
TNeg& SimTK::RowVectorBase< ELT >::updNegate ( )
inline

◆ operator-() [1/2]

template<class ELT >
const TNeg& SimTK::RowVectorBase< ELT >::operator- ( ) const
inline

◆ operator-() [2/2]

template<class ELT >
TNeg& SimTK::RowVectorBase< ELT >::operator- ( )
inline

◆ resize()

template<class ELT >
RowVectorBase& SimTK::RowVectorBase< ELT >::resize ( int  n)
inline

◆ resizeKeep()

template<class ELT >
RowVectorBase& SimTK::RowVectorBase< ELT >::resizeKeep ( int  n)
inline

◆ clear()

template<class ELT >
void SimTK::RowVectorBase< ELT >::clear ( )
inline

◆ sum()

template<class ELT >
ELT SimTK::RowVectorBase< ELT >::sum ( ) const
inline

◆ begin()

template<class ELT >
VectorIterator<ELT, RowVectorBase<ELT> > SimTK::RowVectorBase< ELT >::begin ( )
inline

◆ end()

template<class ELT >
VectorIterator<ELT, RowVectorBase<ELT> > SimTK::RowVectorBase< ELT >::end ( )
inline

Friends And Related Function Documentation

◆ writeUnformatted()

template<class E >
void writeUnformatted ( std::ostream &  o,
const RowVectorBase< E > &  v 
)
related

Specialize for RowVectorBase<E> to delegate to element type E, with spaces separating the elements; raw output is same as VectorBase.


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