1 #ifndef SimTK_SIMMATRIX_MATRIXBASE_H_
2 #define SimTK_SIMMATRIX_MATRIXBASE_H_
68 template <
class ELT>
class MatrixBase {
187 b.helper, typename
MatrixHelper<Scalar>::DeepCopy()) { }
193 b.helper, typename
MatrixHelper<Scalar>::DeepCopy()) { }
227 { helper.
fillWith(reinterpret_cast<const Scalar*>(&initialValue)); }
240 const ELT* cppInitialValuesByRow)
259 int spacing,
const Scalar* data)
261 commitment, character, spacing, data) {}
266 int spacing, Scalar* data)
268 commitment, character, spacing, data) {}
275 : helper(commitment, source, shallow) {}
279 : helper(commitment, source, shallow) {}
283 : helper(commitment, source, deep) {}
299 { helper = b.helper;
return *
this; }
301 { helper.
addIn(b.helper);
return *
this; }
303 { helper.
subIn(b.helper);
return *
this; }
336 updDiag().elementwiseAddScalarInPlace(s);
345 updDiag().elementwiseSubtractScalarInPlace(s);
353 updDiag().elementwiseAddScalarInPlace(s);
394 template <
class EE>
inline void
397 template <
class EE>
inline typename EltResult<EE>::Mul
399 typename EltResult<EE>::Mul out(
nrow(),
ncol());
rowScale(r,out);
return out;
407 template <
class EE>
inline void
410 template <
class EE>
inline typename EltResult<EE>::Mul
412 typename EltResult<EE>::Mul out(
nrow(),
ncol());
colScale(c,out);
return out;
420 template <
class ER,
class EC>
inline MatrixBase&
423 template <
class ER,
class EC>
inline void
427 template <
class ER,
class EC>
inline typename EltResult<typename VectorBase<ER>::template EltResult<EC>::Mul>::Mul
429 typename EltResult<typename VectorBase<ER>::template EltResult<EC>::Mul>::Mul
446 {
return elementwiseAssign<Real>(
Real(s)); }
469 template <
class S>
inline void
472 template <
class S>
inline typename EltResult<S>::Add
474 typename EltResult<S>::Add out(
nrow(),
ncol());
489 template <
class S>
inline void
492 template <
class S>
inline typename EltResult<S>::Sub
494 typename EltResult<S>::Sub out(
nrow(),
ncol());
510 template <
class S>
inline void
518 elementwiseSubtractFromScalar<S>(s,out);
526 template <
class EE>
inline void
529 template <
class EE>
inline typename EltResult<EE>::Mul
531 typename EltResult<EE>::Mul out(
nrow(),
ncol());
532 elementwiseMultiply<EE>(m,out);
540 template <
class EE>
inline void
547 typename EltResult<EE>::Mul out(
nrow(),
ncol());
548 elementwiseMultiplyFromLeft<EE>(m,out);
556 template <
class EE>
inline void
559 template <
class EE>
inline typename EltResult<EE>::Dvd
561 typename EltResult<EE>::Dvd out(
nrow(),
ncol());
562 elementwiseDivide<EE>(m,out);
570 template <
class EE>
inline void
578 elementwiseDivideFromLeft<EE>(m,out);
603 {
return block(i,j,m,n); }
644 void dump(
const char* msg=0)
const {
656 const ELT&
getElt(
int i,
int j)
const {
return *
reinterpret_cast<const ELT*
>(helper.
getElt(i,j)); }
657 ELT&
updElt(
int i,
int j) {
return *
reinterpret_cast< ELT*
>(helper.
updElt(i,j)); }
667 { helper.
getAnyElt(i,j,reinterpret_cast<Scalar*>(&value)); }
677 for(
int j=0;j<nc;++j)
678 for (
int i=0; i<nr; ++i)
688 void abs(TAbs& mabs)
const {
691 for(
int j=0;j<nc;++j)
692 for (
int i=0; i<nr; ++i)
699 TAbs
abs()
const { TAbs mabs;
abs(mabs);
return mabs; }
713 TStandard mstd(nr, nc);
714 for(
int j=0;j<nc;++j)
715 for (
int i=0; i<nr; ++i)
742 const int cols =
ncol();
744 for (
int j = 0; j < cols; ++j)
745 helper.
colSum(j, reinterpret_cast<Scalar*>(&row[j]));
753 const int rows =
nrow();
755 for (
int i = 0; i < rows; ++i)
756 helper.
rowSum(i, reinterpret_cast<Scalar*>(&col[i]));
762 const TNeg&
negate()
const {
return *
reinterpret_cast<const TNeg*
>(
this); }
763 TNeg&
updNegate() {
return *
reinterpret_cast<TNeg*
>(
this); }
890 template <
class ELT_A,
class ELT_B>
894 helper.matmul(beta,alpha,A.helper,B.helper);
902 #endif // SimTK_SIMMATRIX_MATRIXBASE_H_
Here we define class MatrixHelper, the scalar-type templatized helper class for the more general...
Definition: MatrixHelper.h:79
MatrixView_< ELT > block(int i, int j, int m, int n) const
Definition: BigMatrix.h:200
ScalarNormSq normSqr() const
This is the scalar Frobenius norm, and its square.
Definition: MatrixBase.h:723
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.
MatrixView_< EHerm > updTranspose()
Definition: BigMatrix.h:230
const TNeg & operator-() const
Definition: MatrixBase.h:765
MatrixBase & scalarMultiplyInPlace(const S &)
Set M(i,j) = M(i,j)*S for some "scalar" S.
MatrixBase & viewAssign(const MatrixBase &src)
View assignment is a shallow copy, meaning that we disconnect the MatrixBase from whatever it used to...
Definition: MatrixBase.h:212
CNT< E >::TComplex EComplex
Definition: MatrixBase.h:80
MatrixBase< EHerm > THerm
Definition: MatrixBase.h:109
CNT< E >::Number ENumber
Definition: MatrixBase.h:92
void colScale(const VectorBase< EE > &c, typename EltResult< EE >::Mul &out) const
K::ScalarNormSq ScalarNormSq
Definition: CompositeNumericalTypes.h:166
VectorView_< ELT > col(int j) const
Definition: BigMatrix.h:252
RowVector_< ELT > sum() const
Alternate name for colSum(); behaves like the Matlab function sum().
Definition: MatrixBase.h:749
MatrixBase< E > TPosTrans
Definition: MatrixBase.h:110
EltResult< EE >::Mul elementwiseMultiply(const MatrixBase< EE > &m) const
Definition: MatrixBase.h:530
TNeg & operator-()
Definition: MatrixBase.h:766
void dump(const char *msg=0) const
Matlab-compatible debug output.
Definition: MatrixBase.h:644
K::TReal TReal
Definition: CompositeNumericalTypes.h:141
EltResult< typename VectorBase< ER >::template EltResult< EC >::Mul >::Mul rowAndColScale(const VectorBase< ER > &r, const VectorBase< EC > &c) const
Definition: MatrixBase.h:428
const MatrixHelper< Scalar > & getHelper() const
Definition: MatrixBase.h:865
RowVector_< ELT > colSum() const
Form the column sums of this matrix, returned as a RowVector.
Definition: MatrixBase.h:741
void resize(int m, int n)
const MatrixView_< ELT > & getAsMatrixView() const
Definition: MatrixBase.h:793
MatrixBase & scalarDivideFromLeftInPlace(const S &)
Set M(i,j) = S/M(i,j) for some "scalar" S.
MatrixBase & operator=(const MatrixBase< EE > &b)
Definition: MatrixBase.h:298
ptrdiff_t getContiguousScalarDataLength() const
Definition: MatrixBase.h:839
MatrixBase & rowScaleInPlace(const VectorBase< EE > &)
M = diag(r) * M; r must have nrow() elements.
RowVectorView_< ELT > operator[](int i) const
Definition: MatrixBase.h:593
VectorView_< ELT > operator()(int j)
Definition: MatrixBase.h:596
MatrixBase(const MatrixCommitment &commitment, int m, int n)
This constructor takes a handle commitment and allocates the default matrix for that kind of commitme...
Definition: MatrixBase.h:181
Vector_< ELT > & updAsVector()
Definition: MatrixBase.h:804
void resizeKeep(int m, int n)
MatrixView_< EHerm > transpose() const
Definition: BigMatrix.h:222
MatrixHelper & copyAssign(const MatrixHelper &source)
MatrixView_< ELT > operator()(int i, int j, int m, int n)
Definition: MatrixBase.h:604
MatrixBase< EWithoutNegator > TWithoutNegator
Definition: MatrixBase.h:105
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
MatrixBase & operator-=(const MatrixBase< EE > &b)
Definition: MatrixBase.h:302
K::TSqrt TSqrt
Definition: CompositeNumericalTypes.h:154
ELT & operator()(int i, int j)
Definition: MatrixBase.h:660
Definition: MatrixBase.h:129
static TSqrt sqrt(const K &t)
Definition: CompositeNumericalTypes.h:239
MatrixBase< ENormalize > TNormalize
Definition: MatrixBase.h:115
const MatrixCharacter & getMatrixCharacter() const
MatrixBase(const MatrixCommitment &commitment, const MatrixCharacter &character, int spacing, const Scalar *data)
Construct a read-only view of pre-existing data.
Definition: MatrixBase.h:257
K::Scalar Scalar
Definition: CompositeNumericalTypes.h:160
MatrixBase< typename CNT< E >::TInvert > elementwiseInvert() const
Definition: MatrixBase.h:453
A MatrixCharacter is a set containing a value for each of the matrix characteristics except element t...
Definition: MatrixCharacteristics.h:596
MatrixView_< EHerm > operator~() const
Definition: MatrixBase.h:611
K::TNormalize TNormalize
Definition: CompositeNumericalTypes.h:158
EltResult< S >::Sub elementwiseSubtractScalar(const S &s) const
Definition: MatrixBase.h:493
CNT< E >::TImag EImag
Definition: MatrixBase.h:79
void elementwiseDivideFromLeft(const MatrixBase< EE > &, typename MatrixBase< EE >::template EltResult< E >::Dvd &) const
Definition: BigMatrix.h:533
MatrixBase & elementwiseDivideFromLeftInPlace(const MatrixBase< EE > &)
M(i,j) = R(i,j) / M(i,j); R must have same dimensions as this.
MatrixView_< EHerm > operator~()
Definition: MatrixBase.h:612
(Advanced) This class is identical to Matrix_ except that it has shallow (reference) copy and assignm...
Definition: BigMatrix.h:167
const RowVector_< ELT > & getAsRowVector() const
Definition: MatrixBase.h:815
CNT< E >::StdNumber EStdNumber
Definition: MatrixBase.h:93
K::TImag TImag
Definition: CompositeNumericalTypes.h:142
CNT< E >::TSqHermT ESqHermT
Definition: MatrixBase.h:88
Definition: Exception.h:297
This is a dataless rehash of the MatrixBase class to specialize it for Vectors.
Definition: BigMatrix.h:164
MatrixBase & scalarMultiplyFromLeftInPlace(const S &)
Set M(i,j) = S * M(i,j) for some "scalar" S.
Scalar * updContiguousScalarData()
Definition: MatrixBase.h:845
MatrixBase< EStandard > TStandard
Definition: MatrixBase.h:113
MatrixBase(const MatrixCommitment &commitment, const MatrixHelper< Scalar > &source, const typename MatrixHelper< Scalar >::ShallowCopy &shallow)
Definition: MatrixBase.h:276
MatrixBase & operator=(const MatrixBase &b)
Definition: MatrixBase.h:201
RowVector_< ELT > & updAsRowVector()
Definition: MatrixBase.h:817
Definition: MatrixBase.h:154
const TNeg & negate() const
Definition: MatrixBase.h:762
MatrixBase & elementwiseInvertInPlace()
Set M(i,j) = M(i,j)^-1.
Definition: BigMatrix.h:361
MatrixBase & scalarSubtractInPlace(const S &s)
Subtract a scalar from M's diagonal.
Definition: MatrixBase.h:344
CNT< E >::TStandard EStandard
Definition: MatrixBase.h:85
void colSum(int j, S *eltp) const
SimTK_Real Real
This is the default compiled-in floating point type for SimTK, either float or double.
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:577
void swapOwnedContiguousData(S *newData, ptrdiff_t length, S *&oldData)
VectorView_< ELT > operator()(int j) const
Definition: MatrixBase.h:595
MatrixBase< ESqTHerm > TSqTHerm
Definition: MatrixBase.h:117
MatrixBase & scalarSubtractFromLeftInPlace(const S &s)
Set M(i,i) = S - M(i,i), M(i,j) = -M(i,j) for i!=j.
Definition: MatrixBase.h:351
const RowVectorView_< ELT > & getAsRowVectorView() const
Definition: MatrixBase.h:811
void scaleBy(const StdNumber &)
EltResult< EE >::Mul colScale(const VectorBase< EE > &c) const
Definition: MatrixBase.h:411
static TStandard standardize(const K &t)
Definition: CompositeNumericalTypes.h:241
const Vector_< ELT > & getAsVector() const
Definition: MatrixBase.h:802
ELT getAnyElt(int i, int j) const
Definition: MatrixBase.h:668
MatrixBase< EInvert > TInvert
Definition: MatrixBase.h:114
MatrixBase< EImag > TImag
Definition: MatrixBase.h:107
MatrixHelper< Scalar > & updHelper()
Definition: MatrixBase.h:866
bool isResizeable() const
Return true if either dimension of this Matrix is resizable.
Definition: MatrixBase.h:151
MatrixBase & operator*=(const StdNumber &t)
Definition: MatrixBase.h:290
RowVectorView_< ELT > operator[](int i)
Definition: MatrixBase.h:594
MatrixBase(const MatrixCommitment &commitment, const MatrixHelper< Scalar > &source, const typename MatrixHelper< Scalar >::DeepCopy &deep)
Definition: MatrixBase.h:280
MatrixBase & elementwiseDivideInPlace(const MatrixBase< EE > &)
M(i,j) /= R(i,j); R must have same dimensions as this.
This is the common base class for Simbody's Vector_ and Matrix_ classes for handling large...
Definition: BigMatrix.h:163
VectorView_< ELT > updCol(int j)
Definition: BigMatrix.h:261
ptrdiff_t nelt() const
Return the number of elements in the logical shape of this matrix.
Definition: MatrixBase.h:148
MatrixBase< typename CNT< E >::template Result< P >::Sub > Sub
Definition: MatrixBase.h:133
int getNScalarsPerElement() const
This is the number of consecutive scalars used to represent one element of type ELT.
Definition: MatrixBase.h:831
VectorView_< ELT > diag() const
Select main diagonal (of largest leading square if rectangular) and return it as a read-only view of ...
Definition: BigMatrix.h:238
K::TSqTHerm TSqTHerm
Definition: CompositeNumericalTypes.h:147
MatrixView_< ELT > & updAsMatrixView()
Definition: MatrixBase.h:794
void copyInByRowsFromCpp(const S *elts)
void fillWith(const S *eltp)
ELT & updElt(int i, int j)
Definition: MatrixBase.h:657
EltResult< S >::Add elementwiseAddScalar(const S &s) const
Definition: MatrixBase.h:473
const Scalar * getContiguousScalarData() const
Definition: MatrixBase.h:842
MatrixBase & copyAssign(const MatrixBase &b)
Copy assignment is a deep copy but behavior depends on type of lhs: if view, rhs must match...
Definition: MatrixBase.h:197
void elementwiseMultiplyFromLeft(const MatrixBase< EE > &, typename MatrixBase< EE >::template EltResult< E >::Mul &) const
Definition: BigMatrix.h:484
void replaceContiguousScalarData(Scalar *newData, ptrdiff_t length, bool takeOwnership)
Definition: MatrixBase.h:848
EltResult< EE >::Dvd elementwiseDivide(const MatrixBase< EE > &m) const
Definition: MatrixBase.h:560
void rowAndColScale(const VectorBase< ER > &r, const VectorBase< EC > &c, typename EltResult< typename VectorBase< ER >::template EltResult< EC >::Mul >::Mul &out) const
Definition: BigMatrix.h:337
const VectorView_< ELT > & getAsVectorView() const
Definition: MatrixBase.h:798
void rowSum(int i, S *eltp) const
RowVectorView_< ELT > updRow(int i)
Definition: BigMatrix.h:279
K::Precision Precision
Definition: CompositeNumericalTypes.h:164
ENumber Number
Definition: MatrixBase.h:98
MatrixBase(const TNeg &b)
Implicit conversion from matrix with negated elements (otherwise this is just like the copy construct...
Definition: MatrixBase.h:191
MatrixBase & elementwiseSubtractScalarInPlace(const S &s)
Set M(i,j)-=s for every element of M and some value s.
const MatrixBase & operator+() const
Definition: MatrixBase.h:761
TAbs abs() const
abs() with the result as a function return.
Definition: MatrixBase.h:699
K::TInvert TInvert
Definition: CompositeNumericalTypes.h:157
CNT< E >::TWithoutNegator EWithoutNegator
Definition: MatrixBase.h:77
CNT< E >::ScalarNormSq EScalarNormSq
Definition: MatrixBase.h:95
MatrixBase & operator+=(const MatrixBase< EE > &b)
Definition: MatrixBase.h:300
EStdNumber StdNumber
Definition: MatrixBase.h:99
MatrixBase(const MatrixCommitment &commitment)
This constructor takes a handle commitment and allocates the default matrix for that kind of commitme...
Definition: MatrixBase.h:173
Matrix_< ELT > & updAsMatrix()
Definition: MatrixBase.h:796
MatrixBase< EE >::template EltResult< E >::Mul elementwiseMultiplyFromLeft(const MatrixBase< EE > &m) const
Definition: MatrixBase.h:546
MatrixBase< EComplex > TComplex
Definition: MatrixBase.h:108
void subIn(const MatrixHelper &)
MatrixBase & operator/=(const StdNumber &t)
Definition: MatrixBase.h:291
MatrixBase & operator+=(const MatrixBase &r)
Definition: MatrixBase.h:292
const RowVectorBase< ELT > & getAsRowVectorBase() const
Definition: MatrixBase.h:819
MatrixBase< typename CNT< E >::template Result< P >::Add > Add
Definition: MatrixBase.h:132
MatrixBase & negateInPlace()
Definition: MatrixBase.h:768
MatrixBase< typename CNT< E >::template Result< P >::Dvd > Dvd
Definition: MatrixBase.h:131
#define SimTK_THROW1(exc, a1)
Definition: Exception.h:311
MatrixBase & resize(int m, int n)
Change the size of this matrix.
Definition: MatrixBase.h:774
MatrixBase & elementwiseAssign(const S &s)
Set M(i,j)=s for every element of M and some value s.
MatrixView_< ELT > updBlock(int i, int j, int m, int n)
Definition: BigMatrix.h:211
int getPackedSizeofElement() const
This is like sizeof(ELT), but returning the number of bytes we use to store the element which may be ...
Definition: MatrixBase.h:836
void elementwiseSubtractScalar(const S &s, typename EltResult< S >::Sub &) const
void clear()
This restores the MatrixBase to the state it would be in had it been constructed specifying only its ...
Definition: MatrixBase.h:288
TInvert invert() const
Definition: MatrixBase.h:635
MatrixBase< S >::template EltResult< E >::Sub elementwiseSubtractFromScalar(const S &s) const
Definition: MatrixBase.h:516
Represents a variable size row vector; much less common than the column vector type Vector_...
Definition: BigMatrix.h:174
K::TPosTrans TPosTrans
Definition: CompositeNumericalTypes.h:145
MatrixBase(const MatrixBase< EE > &b)
Definition: MatrixBase.h:295
MatrixBase & setTo(const ELT &t)
Fill every element in current allocation with given element (or NaN or 0).
Definition: MatrixBase.h:583
VectorView_< ELT > diag()
This non-const version of diag() is an alternate name for updDiag() available for historical reasons...
Definition: MatrixBase.h:622
RowVectorBase< ELT > & updAsRowVectorBase()
Definition: MatrixBase.h:821
int nrow() const
Return the number of rows m in the logical shape of this matrix.
Definition: MatrixBase.h:137
void elementwiseAddScalar(const S &s, typename EltResult< S >::Add &) const
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...
MatrixHelper & writableViewAssign(MatrixHelper &source)
EPrecision Precision
Definition: MatrixBase.h:100
VectorView_< ELT > updDiag()
Select main diagonal (of largest leading square if rectangular) and return it as a writable view of t...
Definition: BigMatrix.h:245
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...
Definition: MatrixBase.h:225
MatrixBase(int m, int n)
This constructor allocates the default matrix a completely uncommitted matrix commitment, given particular initial dimensions.
Definition: MatrixBase.h:165
(Advanced) This class is identical to RowVector_ except that it has shallow (reference) copy and assi...
Definition: BigMatrix.h:173
K::StdNumber StdNumber
Definition: CompositeNumericalTypes.h:163
int ncol() const
Return the number of columns n in the logical shape of this matrix.
Definition: MatrixBase.h:139
void abs(TAbs &mabs) const
abs() is elementwise absolute value; that is, the return value has the same dimension as this Matrix ...
Definition: MatrixBase.h:688
const S * getElt(int i, int j) const
MatrixBase & resizeKeep(int m, int n)
Change the size of this matrix, retaining as much of the old data as will fit.
Definition: MatrixBase.h:780
void lockShape()
Definition: MatrixBase.h:784
bool hasContiguousData() const
CNT< E >::TPosTrans EPosTrans
Definition: MatrixBase.h:82
Specialized information about Composite Numerical Types which allows us to define appropriate templat...
Definition: CompositeNumericalTypes.h:136
MatrixBase< E > T
Definition: MatrixBase.h:103
ScalarNormSq scalarNormSqr() const
Scalar norm square is sum( squares of all scalars ).
Definition: MatrixBase.h:674
const MatrixCommitment & getCharacterCommitment() const
Definition: MatrixBase.h:119
EScalar Scalar
Definition: MatrixBase.h:97
This is the vector class intended to appear in user code for large, variable size column vectors...
Definition: BigMatrix.h:171
MatrixBase< ENeg > TNeg
Definition: MatrixBase.h:104
MatrixBase< EE >::template EltResult< EE >::Dvd elementwiseDivideFromLeft(const MatrixBase< EE > &m) const
Definition: MatrixBase.h:576
bool hasContiguousData() const
Definition: MatrixBase.h:838
MatrixBase & elementwiseAddScalarInPlace(const S &s)
Set M(i,j)+=s for every element of M and some value s.
CNT< ScalarNormSq >::TSqrt norm() const
Definition: MatrixBase.h:726
void addIn(const MatrixHelper &)
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 whethe...
Definition: MatrixBase.h:666
CNT< ScalarNormSq >::TSqrt normRMS() const
We only allow RMS norm if the elements are scalars.
Definition: MatrixBase.h:732
MatrixBase & colScaleInPlace(const VectorBase< EE > &)
M = M * diag(c); c must have ncol() elements.
const ELT & getElt(int i, int j) const
Element selection for stored elements.
Definition: MatrixBase.h:656
MatrixBase< EReal > TReal
Definition: MatrixBase.h:106
CNT< E >::Precision EPrecision
Definition: MatrixBase.h:94
ptrdiff_t getContiguousDataLength() const
void getAnyElt(int i, int j, S *value) const
K::TNeg TNeg
Definition: CompositeNumericalTypes.h:139
const ELT & operator()(int i, int j) const
Definition: MatrixBase.h:659
K::TStandard TStandard
Definition: CompositeNumericalTypes.h:156
void elementwiseSubtractFromScalar(const S &, typename MatrixBase< S >::template EltResult< E >::Sub &) const
Definition: BigMatrix.h:435
CNT< E >::TNeg ENeg
Definition: MatrixBase.h:76
void commitTo(const MatrixCommitment &mc)
Change the handle commitment for this matrix handle; only allowed if the handle is currently clear...
Definition: MatrixBase.h:124
K::TWithoutNegator TWithoutNegator
Definition: CompositeNumericalTypes.h:140
VectorView_< ELT > & updAsVectorView()
Definition: MatrixBase.h:800
MatrixBase & scalarAssign(const S &s)
Set M's diagonal elements to a "scalar" value S, and all off-diagonal elements to zero...
Definition: MatrixBase.h:326
MatrixBase & elementwiseMultiplyFromLeftInPlace(const MatrixBase< EE > &)
M(i,j) = R(i,j) * M(i,j); R must have same dimensions as this.
VectorBase< ELT > & updAsVectorBase()
Definition: MatrixBase.h:808
CNT< E >::TNormalize ENormalize
Definition: MatrixBase.h:87
CNT< E >::THerm EHerm
Definition: MatrixBase.h:81
MatrixBase(const MatrixCommitment &commitment, int m, int n, const ELT *cppInitialValuesByRow)
Initializing constructor with the initially-allocated elements initialized from a C++ array of elemen...
Definition: MatrixBase.h:239
void commitTo(const MatrixCommitment &)
const Matrix_< ELT > & getAsMatrix() const
Definition: MatrixBase.h:795
void elementwiseDivide(const MatrixBase< EE > &, typename EltResult< EE >::Dvd &) const
void invertInPlace()
Definition: MatrixBase.h:641
A MatrixCommitment provides a set of acceptable matrix characteristics.
Definition: MatrixCharacteristics.h:831
RowVectorView_< ELT > & updAsRowVectorView()
Definition: MatrixBase.h:813
This is a dataless rehash of the MatrixBase class to specialize it for RowVectors.
Definition: BigMatrix.h:165
MatrixBase & operator-=(const MatrixBase &r)
Definition: MatrixBase.h:293
MatrixBase< EAbs > TAbs
Definition: MatrixBase.h:112
MatrixBase & elementwiseMultiplyInPlace(const MatrixBase< EE > &)
M(i,j) *= R(i,j); R must have same dimensions as this.
(Advanced) This class is identical to Vector_ except that it has shallow (reference) copy and assignm...
Definition: BigMatrix.h:170
void replaceContiguousData(S *newData, ptrdiff_t length, bool takeOwnership)
MatrixBase & elementwiseAssign(int s)
Overloaded to allow an integer argument, which is converted to Real.
Definition: MatrixBase.h:445
bool isResizeable() const
Definition: MatrixCharacteristics.h:924
MatrixBase(const MatrixCommitment &commitment, MatrixHelper< Scalar > &source, const typename MatrixHelper< Scalar >::ShallowCopy &shallow)
Definition: MatrixBase.h:272
K::TComplex TComplex
Definition: CompositeNumericalTypes.h:143
CNT< E >::TReal EReal
Definition: MatrixBase.h:78
MatrixBase(const MatrixCommitment &commitment, const MatrixCharacter &character, int spacing, Scalar *data)
Construct a writable view of pre-existing data.
Definition: MatrixBase.h:264
TStandard standardize() const
Return a Matrix of the same shape and contents as this one but with the element type converted to one...
Definition: MatrixBase.h:711
K::Number Number
Definition: CompositeNumericalTypes.h:162
static TAbs abs(const K &t)
Definition: CompositeNumericalTypes.h:240
MatrixBase & setToZero()
Definition: MatrixBase.h:585
MatrixBase(const MatrixBase &b)
Copy constructor is a deep copy (not appropriate for views!).
Definition: MatrixBase.h:185
void dump(const char *msg=0) const
MatrixBase & scalarAddInPlace(const S &s)
Add a scalar to M's diagonal.
Definition: MatrixBase.h:335
RowVectorView_< ELT > row(int i) const
Definition: BigMatrix.h:270
CNT< E >::TSqTHerm ESqTHerm
Definition: MatrixBase.h:89
void replaceContiguousScalarData(const Scalar *newData, ptrdiff_t length)
Definition: MatrixBase.h:851
const VectorBase< ELT > & getAsVectorBase() const
Definition: MatrixBase.h:806
void elementwiseMultiply(const MatrixBase< EE > &, typename EltResult< EE >::Mul &) const
ELT E
Definition: MatrixBase.h:75
void swapOwnedContiguousScalarData(Scalar *newData, ptrdiff_t length, Scalar *&oldData)
Definition: MatrixBase.h:854
K::TSqHermT TSqHermT
Definition: CompositeNumericalTypes.h:146
MatrixBase & operator=(const ELT &t)
Matrix assignment to an element sets only the *diagonal* elements to the indicated value; everything ...
Definition: MatrixBase.h:315
TNeg & updNegate()
Definition: MatrixBase.h:763
const MatrixCharacter & getMatrixCharacter() const
Definition: MatrixBase.h:120
MatrixBase< typename CNT< E >::template Result< P >::Mul > Mul
Definition: MatrixBase.h:130
const S * getContiguousData() const
This is the matrix class intended to appear in user code for large, variable size matrices...
Definition: BigMatrix.h:168
K::THerm THerm
Definition: CompositeNumericalTypes.h:144
const MatrixCommitment & getCharacterCommitment() const
MatrixBase & elementwiseSubtractFromScalarInPlace(const S &s)
Set M(i,j) = s - M(i,j) for every element of M and some value s.
CNT< E >::TInvert EInvert
Definition: MatrixBase.h:86
EltResult< EE >::Mul rowScale(const VectorBase< EE > &r) const
Definition: MatrixBase.h:398
EScalarNormSq ScalarNormSq
Definition: MatrixBase.h:101
Vector_< ELT > rowSum() const
Form the row sums of this matrix, returned as a Vector.
Definition: MatrixBase.h:752
MatrixBase< ESqHermT > TSqHermT
Definition: MatrixBase.h:116
void fillWithScalar(const StdNumber &)
MatrixBase & scalarDivideInPlace(const S &)
Set M(i,j) = M(i,j)/S for some "scalar" S.
CNT< E >::TAbs EAbs
Definition: MatrixBase.h:84
MatrixBase()
The default constructor builds a 0x0 matrix managed by a helper that understands how many scalars the...
Definition: MatrixBase.h:161
MatrixBase & setToNaN()
Definition: MatrixBase.h:584
K::TAbs TAbs
Definition: CompositeNumericalTypes.h:155
MatrixView_< ELT > operator()(int i, int j, int m, int n) const
Definition: MatrixBase.h:602
Definition: MatrixBase.h:155
void unlockShape()
Definition: MatrixBase.h:790
MatrixBase(MatrixHelperRep< Scalar > *hrep)
Helper rep-stealing constructor.
Definition: MatrixBase.h:862
CNT< E >::Scalar EScalar
Definition: MatrixBase.h:91