Simbody
3.7
|
This is the common base class for Simbody's Vector_ and Matrix_ classes for handling large, variable-sized vectors and matrices. More...
Classes | |
struct | EltResult |
Public Member Functions | |
const MatrixCommitment & | getCharacterCommitment () const |
const MatrixCharacter & | getMatrixCharacter () const |
void | commitTo (const MatrixCommitment &mc) |
Change the handle commitment for this matrix handle; only allowed if the handle is currently clear. More... | |
int | nrow () const |
Return the number of rows m in the logical shape of this matrix. More... | |
int | ncol () const |
Return the number of columns n in the logical shape of this matrix. More... | |
ptrdiff_t | nelt () const |
Return the number of elements in the logical shape of this matrix. More... | |
bool | isResizeable () const |
Return true if either dimension of this Matrix is resizable. More... | |
MatrixBase () | |
The default constructor builds a 0x0 matrix managed by a helper that understands how many scalars there are in one of our elements but is otherwise uncommitted. More... | |
MatrixBase (int m, int n) | |
This constructor allocates the default matrix a completely uncommitted matrix commitment, given particular initial dimensions. More... | |
MatrixBase (const MatrixCommitment &commitment) | |
This constructor takes a handle commitment and allocates the default matrix for that kind of commitment. More... | |
MatrixBase (const MatrixCommitment &commitment, int m, int n) | |
This constructor takes a handle commitment and allocates the default matrix for that kind of commitment given particular initial minimum dimensions, which cannot be larger than those permitted by the commitment. More... | |
MatrixBase (const MatrixBase &b) | |
Copy constructor is a deep copy (not appropriate for views!). More... | |
MatrixBase (const TNeg &b) | |
Implicit conversion from matrix with negated elements (otherwise this is just like the copy constructor. More... | |
MatrixBase & | copyAssign (const MatrixBase &b) |
Copy assignment is a deep copy but behavior depends on type of lhs: if view, rhs must match. More... | |
MatrixBase & | operator= (const MatrixBase &b) |
MatrixBase & | viewAssign (const MatrixBase &src) |
View assignment is a shallow copy, meaning that we disconnect the MatrixBase from whatever it used to refer to (destructing as necessary), then make it a new view for the data descriptor referenced by the source. More... | |
MatrixBase (const MatrixCommitment &commitment, int m, int n, const ELT &initialValue) | |
Initializing constructor with all of the initially-allocated elements initialized to the same value. More... | |
MatrixBase (const MatrixCommitment &commitment, int m, int n, const ELT *cppInitialValuesByRow) | |
Initializing constructor with the initially-allocated elements initialized from a C++ array of elements, which is provided in row major order. More... | |
MatrixBase (const MatrixCommitment &commitment, MatrixHelper< Scalar > &source, const typename MatrixHelper< Scalar >::ShallowCopy &shallow) | |
MatrixBase (const MatrixCommitment &commitment, const MatrixHelper< Scalar > &source, const typename MatrixHelper< Scalar >::ShallowCopy &shallow) | |
MatrixBase (const MatrixCommitment &commitment, const MatrixHelper< Scalar > &source, const typename MatrixHelper< Scalar >::DeepCopy &deep) | |
void | clear () |
This restores the MatrixBase to the state it would be in had it been constructed specifying only its handle commitment. More... | |
MatrixBase & | operator*= (const StdNumber &t) |
MatrixBase & | operator/= (const StdNumber &t) |
MatrixBase & | operator+= (const MatrixBase &r) |
MatrixBase & | operator-= (const MatrixBase &r) |
template<class EE > | |
MatrixBase (const MatrixBase< EE > &b) | |
template<class EE > | |
MatrixBase & | operator= (const MatrixBase< EE > &b) |
template<class EE > | |
MatrixBase & | operator+= (const MatrixBase< EE > &b) |
template<class EE > | |
MatrixBase & | operator-= (const MatrixBase< EE > &b) |
MatrixBase & | operator= (const ELT &t) |
Matrix assignment to an element sets only the diagonal elements to the indicated value; everything else is set to zero. More... | |
template<class S > | |
MatrixBase & | scalarAssign (const S &s) |
Set M's diagonal elements to a "scalar" value S, and all off-diagonal elements to zero. More... | |
template<class S > | |
MatrixBase & | scalarAddInPlace (const S &s) |
Add a scalar to M's diagonal. More... | |
template<class S > | |
MatrixBase & | scalarSubtractInPlace (const S &s) |
Subtract a scalar from M's diagonal. More... | |
template<class S > | |
MatrixBase & | scalarSubtractFromLeftInPlace (const S &s) |
Set M(i,i) = S - M(i,i), M(i,j) = -M(i,j) for i!=j. More... | |
template<class S > | |
MatrixBase & | scalarMultiplyInPlace (const S &) |
Set M(i,j) = M(i,j)*S for some "scalar" S. More... | |
template<class S > | |
MatrixBase & | scalarMultiplyFromLeftInPlace (const S &) |
Set M(i,j) = S * M(i,j) for some "scalar" S. More... | |
template<class S > | |
MatrixBase & | scalarDivideInPlace (const S &) |
Set M(i,j) = M(i,j)/S for some "scalar" S. More... | |
template<class S > | |
MatrixBase & | scalarDivideFromLeftInPlace (const S &) |
Set M(i,j) = S/M(i,j) for some "scalar" S. More... | |
template<class EE > | |
MatrixBase & | rowScaleInPlace (const VectorBase< EE > &) |
M = diag(r) * M; r must have nrow() elements. More... | |
template<class EE > | |
void | rowScale (const VectorBase< EE > &r, typename EltResult< EE >::Mul &out) const |
Return type is a new matrix which will have the same dimensions as 'this' but will have element types appropriate for the elementwise multiply being performed. More... | |
template<class EE > | |
EltResult< EE >::Mul | rowScale (const VectorBase< EE > &r) const |
template<class EE > | |
MatrixBase & | colScaleInPlace (const VectorBase< EE > &) |
M = M * diag(c); c must have ncol() elements. More... | |
template<class EE > | |
void | colScale (const VectorBase< EE > &c, typename EltResult< EE >::Mul &out) const |
template<class EE > | |
EltResult< EE >::Mul | colScale (const VectorBase< EE > &c) const |
template<class ER , class EC > | |
MatrixBase & | rowAndColScaleInPlace (const VectorBase< ER > &r, const VectorBase< EC > &c) |
M = diag(r) * M * diag(c); r must have nrow() elements; must have ncol() elements. More... | |
template<class ER , class EC > | |
void | rowAndColScale (const VectorBase< ER > &r, const VectorBase< EC > &c, typename EltResult< typename VectorBase< ER >::template EltResult< EC >::Mul >::Mul &out) const |
template<class ER , class EC > | |
EltResult< typename VectorBase< ER >::template EltResult< EC >::Mul >::Mul | rowAndColScale (const VectorBase< ER > &r, const VectorBase< EC > &c) const |
template<class S > | |
MatrixBase & | elementwiseAssign (const S &s) |
Set M(i,j)=s for every element of M and some value s. More... | |
MatrixBase & | elementwiseAssign (int s) |
Overloaded to allow an integer argument, which is converted to Real. More... | |
MatrixBase & | elementwiseInvertInPlace () |
Set M(i,j) = M(i,j)^-1. More... | |
void | elementwiseInvert (MatrixBase< typename CNT< E >::TInvert > &out) const |
MatrixBase< typename CNT< E >::TInvert > | elementwiseInvert () const |
template<class S > | |
MatrixBase & | elementwiseAddScalarInPlace (const S &s) |
Set M(i,j)+=s for every element of M and some value s. More... | |
template<class S > | |
void | elementwiseAddScalar (const S &s, typename EltResult< S >::Add &) const |
template<class S > | |
EltResult< S >::Add | elementwiseAddScalar (const S &s) const |
template<class S > | |
MatrixBase & | elementwiseSubtractScalarInPlace (const S &s) |
Set M(i,j)-=s for every element of M and some value s. More... | |
template<class S > | |
void | elementwiseSubtractScalar (const S &s, typename EltResult< S >::Sub &) const |
template<class S > | |
EltResult< S >::Sub | elementwiseSubtractScalar (const S &s) const |
template<class S > | |
MatrixBase & | elementwiseSubtractFromScalarInPlace (const S &s) |
Set M(i,j) = s - M(i,j) for every element of M and some value s. More... | |
template<class S > | |
void | elementwiseSubtractFromScalar (const S &, typename MatrixBase< S >::template EltResult< E >::Sub &) const |
template<class S > | |
MatrixBase< S >::template EltResult< E >::Sub | elementwiseSubtractFromScalar (const S &s) const |
template<class EE > | |
MatrixBase & | elementwiseMultiplyInPlace (const MatrixBase< EE > &) |
M(i,j) *= R(i,j); R must have same dimensions as this. More... | |
template<class EE > | |
void | elementwiseMultiply (const MatrixBase< EE > &, typename EltResult< EE >::Mul &) const |
template<class EE > | |
EltResult< EE >::Mul | elementwiseMultiply (const MatrixBase< EE > &m) const |
template<class EE > | |
MatrixBase & | elementwiseMultiplyFromLeftInPlace (const MatrixBase< EE > &) |
M(i,j) = R(i,j) * M(i,j); R must have same dimensions as this. More... | |
template<class EE > | |
void | elementwiseMultiplyFromLeft (const MatrixBase< EE > &, typename MatrixBase< EE >::template EltResult< E >::Mul &) const |
template<class EE > | |
MatrixBase< EE >::template EltResult< E >::Mul | elementwiseMultiplyFromLeft (const MatrixBase< EE > &m) const |
template<class EE > | |
MatrixBase & | elementwiseDivideInPlace (const MatrixBase< EE > &) |
M(i,j) /= R(i,j); R must have same dimensions as this. More... | |
template<class EE > | |
void | elementwiseDivide (const MatrixBase< EE > &, typename EltResult< EE >::Dvd &) const |
template<class EE > | |
EltResult< EE >::Dvd | elementwiseDivide (const MatrixBase< EE > &m) const |
template<class EE > | |
MatrixBase & | elementwiseDivideFromLeftInPlace (const MatrixBase< EE > &) |
M(i,j) = R(i,j) / M(i,j); R must have same dimensions as this. More... | |
template<class EE > | |
void | elementwiseDivideFromLeft (const MatrixBase< EE > &, typename MatrixBase< EE >::template EltResult< E >::Dvd &) const |
template<class EE > | |
MatrixBase< EE >::template EltResult< EE >::Dvd | elementwiseDivideFromLeft (const MatrixBase< EE > &m) const |
MatrixBase & | setTo (const ELT &t) |
Fill every element in current allocation with given element (or NaN or 0). More... | |
MatrixBase & | setToNaN () |
MatrixBase & | setToZero () |
RowVectorView_< ELT > | row (int i) const |
RowVectorView_< ELT > | updRow (int i) |
VectorView_< ELT > | col (int j) const |
VectorView_< ELT > | updCol (int j) |
RowVectorView_< ELT > | operator[] (int i) const |
RowVectorView_< ELT > | operator[] (int i) |
VectorView_< ELT > | operator() (int j) const |
VectorView_< ELT > | operator() (int j) |
MatrixView_< ELT > | block (int i, int j, int m, int n) const |
MatrixView_< ELT > | updBlock (int i, int j, int m, int n) |
MatrixView_< ELT > | operator() (int i, int j, int m, int n) const |
MatrixView_< ELT > | operator() (int i, int j, int m, int n) |
MatrixView_< EHerm > | transpose () const |
MatrixView_< EHerm > | updTranspose () |
MatrixView_< EHerm > | operator~ () const |
MatrixView_< EHerm > | operator~ () |
VectorView_< ELT > | diag () const |
Select main diagonal (of largest leading square if rectangular) and return it as a read-only view of the diagonal elements of this Matrix. More... | |
VectorView_< ELT > | updDiag () |
Select main diagonal (of largest leading square if rectangular) and return it as a writable view of the diagonal elements of this Matrix. More... | |
VectorView_< ELT > | diag () |
This non-const version of diag() is an alternate name for updDiag() available for historical reasons. More... | |
TInvert | invert () const |
void | invertInPlace () |
void | dump (const char *msg=0) const |
Matlab-compatible debug output. More... | |
const ELT & | getElt (int i, int j) const |
Element selection for stored elements. More... | |
ELT & | updElt (int i, int j) |
const ELT & | operator() (int i, int j) const |
ELT & | operator() (int i, int j) |
void | getAnyElt (int i, int j, ELT &value) const |
This returns a copy of the element value for any position in the logical matrix, regardless of whether it is stored in memory. More... | |
ELT | getAnyElt (int i, int j) const |
ScalarNormSq | scalarNormSqr () const |
Scalar norm square is sum( squares of all scalars ). More... | |
void | abs (TAbs &mabs) const |
abs() is elementwise absolute value; that is, the return value has the same dimension as this Matrix but with each element replaced by whatever it thinks its absolute value is. More... | |
TAbs | abs () const |
abs() with the result as a function return. More... | |
TStandard | standardize () const |
Return a Matrix of the same shape and contents as this one but with the element type converted to one based on the standard C++ scalar types: float, double, complex<float>, complex<double>. More... | |
ScalarNormSq | normSqr () const |
This is the scalar Frobenius norm, and its square. More... | |
CNT< ScalarNormSq >::TSqrt | norm () const |
CNT< ScalarNormSq >::TSqrt | normRMS () const |
We only allow RMS norm if the elements are scalars. More... | |
RowVector_< ELT > | colSum () const |
Form the column sums of this matrix, returned as a RowVector. More... | |
RowVector_< ELT > | sum () const |
Alternate name for colSum(); behaves like the Matlab function sum(). More... | |
Vector_< ELT > | rowSum () const |
Form the row sums of this matrix, returned as a Vector. More... | |
const MatrixBase & | operator+ () const |
const TNeg & | negate () const |
TNeg & | updNegate () |
const TNeg & | operator- () const |
TNeg & | operator- () |
MatrixBase & | negateInPlace () |
MatrixBase & | resize (int m, int n) |
Change the size of this matrix. More... | |
MatrixBase & | resizeKeep (int m, int n) |
Change the size of this matrix, retaining as much of the old data as will fit. More... | |
void | lockShape () |
void | unlockShape () |
const MatrixView_< ELT > & | getAsMatrixView () const |
MatrixView_< ELT > & | updAsMatrixView () |
const Matrix_< ELT > & | getAsMatrix () const |
Matrix_< ELT > & | updAsMatrix () |
const VectorView_< ELT > & | getAsVectorView () const |
VectorView_< ELT > & | updAsVectorView () |
const Vector_< ELT > & | getAsVector () const |
Vector_< ELT > & | updAsVector () |
const VectorBase< ELT > & | getAsVectorBase () const |
VectorBase< ELT > & | updAsVectorBase () |
const RowVectorView_< ELT > & | getAsRowVectorView () const |
RowVectorView_< ELT > & | updAsRowVectorView () |
const RowVector_< ELT > & | getAsRowVector () const |
RowVector_< ELT > & | updAsRowVector () |
const RowVectorBase< ELT > & | getAsRowVectorBase () const |
RowVectorBase< ELT > & | updAsRowVectorBase () |
int | getNScalarsPerElement () const |
This is the number of consecutive scalars used to represent one element of type ELT. More... | |
int | getPackedSizeofElement () const |
This is like sizeof(ELT), but returning the number of bytes we use to store the element which may be fewer than what C++ would use. More... | |
bool | hasContiguousData () const |
ptrdiff_t | getContiguousScalarDataLength () const |
const Scalar * | getContiguousScalarData () const |
Scalar * | updContiguousScalarData () |
void | replaceContiguousScalarData (Scalar *newData, ptrdiff_t length, bool takeOwnership) |
void | replaceContiguousScalarData (const Scalar *newData, ptrdiff_t length) |
void | swapOwnedContiguousScalarData (Scalar *newData, ptrdiff_t length, Scalar *&oldData) |
MatrixBase (MatrixHelperRep< Scalar > *hrep) | |
Helper rep-stealing constructor. More... | |
template<class EE > | |
MatrixBase< ELT > & | rowScaleInPlace (const VectorBase< EE > &v) |
template<class EE > | |
void | rowScale (const VectorBase< EE > &v, typename MatrixBase< ELT >::template EltResult< EE >::Mul &out) const |
template<class EE > | |
MatrixBase< ELT > & | colScaleInPlace (const VectorBase< EE > &v) |
template<class EE > | |
void | colScale (const VectorBase< EE > &v, typename MatrixBase< ELT >::template EltResult< EE >::Mul &out) const |
template<class ER , class EC > | |
MatrixBase< ELT > & | rowAndColScaleInPlace (const VectorBase< ER > &r, const VectorBase< EC > &c) |
template<class S > | |
MatrixBase< ELT > & | elementwiseAssign (const S &s) |
template<class S > | |
MatrixBase< ELT > & | elementwiseAddScalarInPlace (const S &s) |
template<class S > | |
void | elementwiseAddScalar (const S &s, typename MatrixBase< ELT >::template EltResult< S >::Add &out) const |
template<class S > | |
MatrixBase< ELT > & | elementwiseSubtractScalarInPlace (const S &s) |
template<class S > | |
void | elementwiseSubtractScalar (const S &s, typename MatrixBase< ELT >::template EltResult< S >::Sub &out) const |
template<class S > | |
MatrixBase< ELT > & | elementwiseSubtractFromScalarInPlace (const S &s) |
template<class EE > | |
MatrixBase< ELT > & | elementwiseMultiplyInPlace (const MatrixBase< EE > &r) |
template<class EE > | |
void | elementwiseMultiply (const MatrixBase< EE > &r, typename MatrixBase< ELT >::template EltResult< EE >::Mul &out) const |
template<class EE > | |
MatrixBase< ELT > & | elementwiseMultiplyFromLeftInPlace (const MatrixBase< EE > &r) |
template<class EE > | |
MatrixBase< ELT > & | elementwiseDivideInPlace (const MatrixBase< EE > &r) |
template<class EE > | |
void | elementwiseDivide (const MatrixBase< EE > &r, typename MatrixBase< ELT >::template EltResult< EE >::Dvd &out) const |
template<class EE > | |
MatrixBase< ELT > & | elementwiseDivideFromLeftInPlace (const MatrixBase< EE > &r) |
Matrix view of pre-exising data | |
Non-resizeable view of someone else's already-allocated memory of a size and storage type indicated by the supplied MatrixCharacter. The spacing argument has different interpretations depending on the storage format. Typically it is the leading dimension for Lapack-style full storage or stride for a vector. Spacing is in units like "number of scalars between elements" or "number of scalars between columns" so it can be used to deal with C++ packing vs. Simmatrix packing if necessary. | |
MatrixBase (const MatrixCommitment &commitment, const MatrixCharacter &character, int spacing, const Scalar *data) | |
Construct a read-only view of pre-existing data. More... | |
MatrixBase (const MatrixCommitment &commitment, const MatrixCharacter &character, int spacing, Scalar *data) | |
Construct a writable view of pre-existing data. More... | |
Protected Member Functions | |
const MatrixHelper< Scalar > & | getHelper () const |
MatrixHelper< Scalar > & | updHelper () |
Friends | |
template<class EE > | |
class | MatrixBase |
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 MatrixBase< E > &v) |
Specialize for MatrixBase<E> delegating to RowVectorBase<E> with newlines separating the rows, but no final newline. More... | |
This is the common base class for Simbody's Vector_ and Matrix_ classes for handling large, variable-sized vectors and matrices.
MatrixBase does not normally appear in user programs. Instead classes Vector_ and Matrix_ are used, or more commonly the typedefs Vector and Matrix which are abbreviations for Vector_<Real> and Matrix_<Real>.
Matrix base is a variable-size 2d matrix of Composite Numerical Type (CNT) elements. This is a container of such elements, it is NOT a Composite Numerical Type itself.
MatrixBase<ELT> uses MatrixHelper<S> for implementation, where S is ELT::Scalar, that is, the underlying float, double, complex<float>, negator<conjugate<double>>, etc. from which ELT is constructed. This is a finite set of which all members are explicitly instantiated in the implementation code, so clients don't have to know how anything is implemented.
MatrixBase is the only class in the Matrix/Vector family which has any data members (it has exactly one MatrixHelper, which itself consists only of a single pointer to an opaque class). Thus all other objects in this family (that is, derived from MatrixBase) are exactly the same size in memory and may be "reinterpreted" as appropriate. For example, a Vector may be reinterpreted as a Matrix or vice versa, provided runtime requirements are met (e.g., exactly 1 column).
Unlike the small matrix classes, very little is encoded in the type. Only the element type, and matrix vs. vector vs. row are in the type; everything else like shape, storage layout, and writability are handled at run time.
typedef ELT SimTK::MatrixBase< ELT >::E |
typedef CNT<E>::TNeg SimTK::MatrixBase< ELT >::ENeg |
typedef CNT<E>::TWithoutNegator SimTK::MatrixBase< ELT >::EWithoutNegator |
typedef CNT<E>::TReal SimTK::MatrixBase< ELT >::EReal |
typedef CNT<E>::TImag SimTK::MatrixBase< ELT >::EImag |
typedef CNT<E>::TComplex SimTK::MatrixBase< ELT >::EComplex |
typedef CNT<E>::THerm SimTK::MatrixBase< ELT >::EHerm |
typedef CNT<E>::TPosTrans SimTK::MatrixBase< ELT >::EPosTrans |
typedef CNT<E>::TAbs SimTK::MatrixBase< ELT >::EAbs |
typedef CNT<E>::TStandard SimTK::MatrixBase< ELT >::EStandard |
typedef CNT<E>::TInvert SimTK::MatrixBase< ELT >::EInvert |
typedef CNT<E>::TNormalize SimTK::MatrixBase< ELT >::ENormalize |
typedef CNT<E>::TSqHermT SimTK::MatrixBase< ELT >::ESqHermT |
typedef CNT<E>::TSqTHerm SimTK::MatrixBase< ELT >::ESqTHerm |
typedef CNT<E>::Scalar SimTK::MatrixBase< ELT >::EScalar |
typedef CNT<E>::Number SimTK::MatrixBase< ELT >::ENumber |
typedef CNT<E>::StdNumber SimTK::MatrixBase< ELT >::EStdNumber |
typedef CNT<E>::Precision SimTK::MatrixBase< ELT >::EPrecision |
typedef CNT<E>::ScalarNormSq SimTK::MatrixBase< ELT >::EScalarNormSq |
typedef EScalar SimTK::MatrixBase< ELT >::Scalar |
typedef ENumber SimTK::MatrixBase< ELT >::Number |
typedef EStdNumber SimTK::MatrixBase< ELT >::StdNumber |
typedef EPrecision SimTK::MatrixBase< ELT >::Precision |
typedef EScalarNormSq SimTK::MatrixBase< ELT >::ScalarNormSq |
typedef MatrixBase<ENeg> SimTK::MatrixBase< ELT >::TNeg |
typedef MatrixBase<EWithoutNegator> SimTK::MatrixBase< ELT >::TWithoutNegator |
typedef MatrixBase<EReal> SimTK::MatrixBase< ELT >::TReal |
typedef MatrixBase<EImag> SimTK::MatrixBase< ELT >::TImag |
typedef MatrixBase<EComplex> SimTK::MatrixBase< ELT >::TComplex |
typedef MatrixBase<EHerm> SimTK::MatrixBase< ELT >::THerm |
typedef MatrixBase<E> SimTK::MatrixBase< ELT >::TPosTrans |
typedef MatrixBase<EAbs> SimTK::MatrixBase< ELT >::TAbs |
typedef MatrixBase<EStandard> SimTK::MatrixBase< ELT >::TStandard |
typedef MatrixBase<EInvert> SimTK::MatrixBase< ELT >::TInvert |
typedef MatrixBase<ENormalize> SimTK::MatrixBase< ELT >::TNormalize |
typedef MatrixBase<ESqHermT> SimTK::MatrixBase< ELT >::TSqHermT |
typedef MatrixBase<ESqTHerm> SimTK::MatrixBase< ELT >::TSqTHerm |
|
inline |
The default constructor builds a 0x0 matrix managed by a helper that understands how many scalars there are in one of our elements but is otherwise uncommitted.
|
inline |
This constructor allocates the default matrix a completely uncommitted matrix commitment, given particular initial dimensions.
|
inlineexplicit |
This constructor takes a handle commitment and allocates the default matrix for that kind of commitment.
If a dimension is set to a particular (unchangeable) value in the commitment then the initial allocation will use that value. Unlocked dimensions are given the smallest value consistent with other committed attributes, typically 0.
|
inline |
This constructor takes a handle commitment and allocates the default matrix for that kind of commitment given particular initial minimum dimensions, which cannot be larger than those permitted by the commitment.
|
inline |
Copy constructor is a deep copy (not appropriate for views!).
|
inline |
Implicit conversion from matrix with negated elements (otherwise this is just like the copy constructor.
|
inline |
Initializing constructor with all of the initially-allocated elements initialized to the same value.
The given dimensions are treated as minimum dimensions in case the commitment requires more. So it is always permissible to set them both to 0 in which case you'll get the smallest matrix that satisfies the commitment, with each of its elements (if any) set to the given initial value.
|
inline |
Initializing constructor with the initially-allocated elements initialized from a C++ array of elements, which is provided in row major order.
The given dimensions are treated as minimum dimensions in case the commitment requires more. The array is presumed to be long enough to supply a value for each element. Note that C++ packing for elements may be different than Simmatrix packing of the same elements (Simmatrix packs them more tightly in some cases). So you should not use this constructor to copy elements from one Simmatrix matrix to another; this is exclusively for initializing a Simmatrix from a C++ array.
|
inline |
Construct a read-only view of pre-existing data.
|
inline |
Construct a writable view of pre-existing data.
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineexplicit |
Helper rep-stealing constructor.
We take over ownership of this rep here. Note that this defines the handle commitment for this handle. This is intended for internal use only – don't call this constructor unless you really know what you're doing.
|
inline |
|
inline |
|
inline |
Change the handle commitment for this matrix handle; only allowed if the handle is currently clear.
|
inline |
Return the number of rows m in the logical shape of this matrix.
|
inline |
Return the number of columns n in the logical shape of this matrix.
|
inline |
Return the number of elements in the logical shape of this matrix.
This has nothing to do with how many elements are actually stored; it is simply the product of the logical number of rows and columns, that is, nrow()*ncol(). Note that although each dimension is limited to a 32 bit size, the product of those dimensions may be > 32 bits on a 64 bit machine so the return type may be larger than that of nrow() and ncol().
|
inline |
Return true if either dimension of this Matrix is resizable.
|
inline |
Copy assignment is a deep copy but behavior depends on type of lhs: if view, rhs must match.
If owner, we reallocate and copy rhs.
|
inline |
|
inline |
View assignment is a shallow copy, meaning that we disconnect the MatrixBase from whatever it used to refer to (destructing as necessary), then make it a new view for the data descriptor referenced by the source.
CAUTION: we always take the source as const, but that is ignored in determining whether the resulting view is writable. Instead, that is inherited from the writability status of the source. We have to do this in order to allow temporary view objects to be writable – the compiler creates temporaries like m(i,j,m,n) as const.
|
inline |
This restores the MatrixBase to the state it would be in had it been constructed specifying only its handle commitment.
The size will have been reduced to the smallest size consistent with the commitment.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Matrix assignment to an element sets only the diagonal elements to the indicated value; everything else is set to zero.
This is particularly useful for setting a Matrix to zero or to the identity; for other values it creates a Matrix which acts like the scalar. That is, if the scalar is s and we do M=s, then multiplying another Matrix B by the resulting diagonal matrix M gives the same result as multiplying B by s. That is (M=s)*B == s*B.
NOTE: this must be overridden for Vector and RowVector since then scalar assignment is defined to copy the scalar to every element.
|
inline |
Set M's diagonal elements to a "scalar" value S, and all off-diagonal elements to zero.
S can be any type which is assignable to an element of type E. This is the same as the Matrix assignment operator M=S for a scalar type S. It is overriden for Vector and Row types to behave as elementwiseScalarAssign.
|
inline |
Add a scalar to M's diagonal.
This is the same as the Matrix += operator. This is overridden for Vector and Row types to behave as elementwiseAddScalarInPlace.
|
inline |
Subtract a scalar from M's diagonal.
This is the same as the Matrix -= operator. This is overridden for Vector and Row types to behave as elementwiseSubtractScalarInPlace.
|
inline |
Set M(i,i) = S - M(i,i), M(i,j) = -M(i,j) for i!=j.
This is overridden for Vector and Row types to behave as elementwiseSubtractFromScalarInPlace.
|
inline |
Set M(i,j) = M(i,j)*S for some "scalar" S.
Actually S can be any type for which E = E*S makes sense. That is, S must be conformant with E and it must be possible to store the result back in an E. This is the *= operator for M *= S and behaves the same way for Matrix, Vector, and RowVector: every element gets multiplied in place on the right by S.
|
inline |
Set M(i,j) = S * M(i,j) for some "scalar" S.
This is the same as the above routine if S really is a scalar, but for S a more complicated CNT it will be different.
|
inline |
Set M(i,j) = M(i,j)/S for some "scalar" S.
Actually S can be any type for which E = E/S makes sense. That is, S^-1 must be conformant with E and it must be possible to store the result back in an E. This is the /= operator for M /= S and behaves the same way for Matrix, Vector, and RowVector: every element gets divided in place on the right by S.
|
inline |
Set M(i,j) = S/M(i,j) for some "scalar" S.
Actually S can be any type for which E = S/E makes sense. That is, S must be conformant with E^-1 and it must be possible to store the result back in an E.
|
inline |
M = diag(r) * M; r must have nrow() elements.
That is, M[i] *= r[i].
|
inline |
Return type is a new matrix which will have the same dimensions as 'this' but will have element types appropriate for the elementwise multiply being performed.
|
inline |
|
inline |
M = M * diag(c); c must have ncol() elements.
That is, M(j) *= c[j].
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Set M(i,j)=s for every element of M and some value s.
This requires only that s be assignment compatible with M's elements; s doesn't actually have to be a scalar. Note that for Matrix types this behavior is different than scalar assignment, which puts the scalar only on M's diagonal and sets the rest of M to zero. For Vector and RowVector types, this operator is identical to the normal assignment operator and scalarAssignInPlace() method which also assign the scalar to every element.
|
inline |
Overloaded to allow an integer argument, which is converted to Real.
|
inline |
Set M(i,j) = M(i,j)^-1.
|
inline |
|
inline |
|
inline |
Set M(i,j)+=s for every element of M and some value s.
This requires that s be conformant with M's elements (of type E) and that the result can be stored in an E. For Matrix types this behavior is different than the normal += or scalarAddInPlace() operators, which add the scalar only to the Matrix diagonal. For Vector and RowVector, this operator is identical to += and scalarAddInPlace() which also add the scalar to every element.
|
inline |
|
inline |
|
inline |
Set M(i,j)-=s for every element of M and some value s.
This requires that s be conformant with M's elements (of type E) and that the result can be stored in an E. For Matrix types this behavior is different than the normal -= or scalarSubtractInPlace() operators, which subtract the scalar only from the Matrix diagonal. For Vector and RowVector, this operator is identical to -= and scalarSubtractInPlace() which also subtract the scalar from every element.
|
inline |
|
inline |
|
inline |
Set M(i,j) = s - M(i,j) for every element of M and some value s.
This requires that s be conformant with M's elements (of type E) and that the result can be stored in an E. For Matrix types this behavior is different than the scalarSubtractFromLeftInPlace() operator, which subtracts only the diagonal elements of M from s, while simply negating the off diagonal elements. For Vector and RowVector, this operator is identical to scalarSubtractFromLeftInPlace() which also subtracts every element of M from the scalar.
|
inline |
|
inline |
|
inline |
M(i,j) *= R(i,j); R must have same dimensions as this.
|
inline |
|
inline |
|
inline |
M(i,j) = R(i,j) * M(i,j); R must have same dimensions as this.
|
inline |
|
inline |
|
inline |
M(i,j) /= R(i,j); R must have same dimensions as this.
|
inline |
|
inline |
|
inline |
M(i,j) = R(i,j) / M(i,j); R must have same dimensions as this.
|
inline |
|
inline |
|
inline |
Fill every element in current allocation with given element (or NaN or 0).
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Select main diagonal (of largest leading square if rectangular) and return it as a read-only view of the diagonal elements of this Matrix.
|
inline |
Select main diagonal (of largest leading square if rectangular) and return it as a writable view of the diagonal elements of this Matrix.
|
inline |
|
inline |
|
inline |
|
inline |
Matlab-compatible debug output.
|
inline |
Element selection for stored elements.
These are the fastest element access methods but may not be able to access all elements of the logical matrix when some of its elements are not stored in memory. For example, a Hermitian matrix stores only half its elements and other ones have to be calculated by conjugation if they are to be returned as type ELT. (You can get them for free by recasting the matrix so that the elements are reinterpreted as conjugates.) If you want to guarantee that you can access the value of every element of a matrix, stored or not, use getAnyElt() instead.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Scalar norm square is sum( squares of all scalars ).
Note that this is not very useful unless the elements are themselves scalars.
|
inline |
abs() is elementwise absolute value; that is, the return value has the same dimension as this Matrix but with each element replaced by whatever it thinks its absolute value is.
|
inline |
|
inline |
Return a Matrix of the same shape and contents as this one but with the element type converted to one based on the standard C++ scalar types: float, double, complex<float>, complex<double>.
That is, negator<> and conjugate<> are eliminated from the element type by performing any needed negations computationally. Note that this is actually producing a new matrix with new data; you can also do this for free by reinterpreting the current matrix as a different type, if you don't mind looking at shared data.
|
inline |
This is the scalar Frobenius norm, and its square.
Note: if this is a Matrix then the Frobenius norm is NOT the same as the 2-norm, although they are equivalent for Vectors.
|
inline |
|
inline |
We only allow RMS norm if the elements are scalars.
If there are no elements in this Matrix, we'll define its RMS norm to be 0, although NaN might be a better choice.
|
inline |
Form the column sums of this matrix, returned as a RowVector.
|
inline |
|
inline |
Form the row sums of this matrix, returned as a Vector.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Change the size of this matrix.
This is only allowed for owner matrices. The current storage format is retained, but all the data is lost. If you want to keep the old data, use resizeKeep().
|
inline |
Change the size of this matrix, retaining as much of the old data as will fit.
This is only allowed for owner matrices. The current storage format is retained, and the existing data is copied into the new memory to the extent that it will fit.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
This is the number of consecutive scalars used to represent one element of type ELT.
This may be fewer than C++ would use for the element, since it may introduce some padding.
|
inline |
This is like sizeof(ELT), but returning the number of bytes we use to store the element which may be fewer than what C++ would use.
We store these packed elements adjacent to one another in memory.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineprotected |
|
inlineprotected |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
related |
Specialize for MatrixBase<E> delegating to RowVectorBase<E> with newlines separating the rows, but no final newline.