11 #ifndef EIGEN_DIAGONALMATRIX_H 12 #define EIGEN_DIAGONALMATRIX_H 16 #ifndef EIGEN_PARSED_BY_DOXYGEN 17 template<
typename Derived>
23 typedef typename DiagonalVectorType::RealScalar RealScalar;
28 RowsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
29 ColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
30 MaxRowsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,
31 MaxColsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,
32 IsVectorAtCompileTime = 0,
40 inline const Derived& derived()
const {
return *
static_cast<const Derived*
>(
this); }
41 inline Derived& derived() {
return *
static_cast<Derived*
>(
this); }
43 DenseMatrixType toDenseMatrix()
const {
return derived(); }
44 template<
typename DenseDerived>
46 template<
typename DenseDerived>
49 template<
typename DenseDerived>
53 inline const DiagonalVectorType& diagonal()
const {
return derived().diagonal(); }
54 inline DiagonalVectorType& diagonal() {
return derived().diagonal(); }
56 inline Index rows()
const {
return diagonal().size(); }
57 inline Index cols()
const {
return diagonal().size(); }
61 template<
typename MatrixDerived>
71 return diagonal().cwiseInverse();
77 return diagonal() * scalar;
82 return other.diagonal() * scalar;
86 template<
typename OtherDerived>
89 return diagonal().isApprox(other.diagonal(), precision);
91 template<
typename OtherDerived>
94 return toDenseMatrix().isApprox(other, precision);
99 template<
typename Derived>
100 template<
typename DenseDerived>
122 template<
typename _Scalar,
int SizeAtCompileTime,
int MaxSizeAtCompileTime>
124 :
traits<Matrix<_Scalar,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >
128 typedef DenseIndex Index;
134 template<
typename _Scalar,
int SizeAtCompileTime,
int MaxSizeAtCompileTime>
136 :
public DiagonalBase<DiagonalMatrix<_Scalar,SizeAtCompileTime,MaxSizeAtCompileTime> >
139 #ifndef EIGEN_PARSED_BY_DOXYGEN 142 typedef _Scalar Scalar;
149 DiagonalVectorType m_diagonal;
154 inline const DiagonalVectorType&
diagonal()
const {
return m_diagonal; }
156 inline DiagonalVectorType&
diagonal() {
return m_diagonal; }
168 inline DiagonalMatrix(
const Scalar& x,
const Scalar& y,
const Scalar& z) : m_diagonal(x,y,z) {}
171 template<
typename OtherDerived>
174 #ifndef EIGEN_PARSED_BY_DOXYGEN 180 template<
typename OtherDerived>
185 template<
typename OtherDerived>
188 m_diagonal = other.diagonal();
192 #ifndef EIGEN_PARSED_BY_DOXYGEN 206 inline void setZero() { m_diagonal.setZero(); }
230 template<
typename _DiagonalVectorType>
233 typedef _DiagonalVectorType DiagonalVectorType;
235 typedef typename DiagonalVectorType::Index Index;
236 typedef typename DiagonalVectorType::StorageKind StorageKind;
238 RowsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
239 ColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
240 MaxRowsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
241 MaxColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
247 template<
typename _DiagonalVectorType>
252 #ifndef EIGEN_PARSED_BY_DOXYGEN 253 typedef _DiagonalVectorType DiagonalVectorType;
261 const DiagonalVectorType&
diagonal()
const {
return m_diagonal; }
264 typename DiagonalVectorType::Nested m_diagonal;
276 template<
typename Derived>
291 template<
typename Derived>
295 if(cols() != rows())
return false;
296 RealScalar maxAbsOnDiagonal =
static_cast<RealScalar
>(-1);
297 for(
Index j = 0; j < cols(); ++j)
299 RealScalar absOnDiagonal = abs(coeff(j,j));
300 if(absOnDiagonal > maxAbsOnDiagonal) maxAbsOnDiagonal = absOnDiagonal;
302 for(
Index j = 0; j < cols(); ++j)
303 for(
Index i = 0; i < j; ++i)
305 if(!internal::isMuchSmallerThan(coeff(i, j), maxAbsOnDiagonal, prec))
return false;
306 if(!internal::isMuchSmallerThan(coeff(j, i), maxAbsOnDiagonal, prec))
return false;
313 #endif // EIGEN_DIAGONALMATRIX_H DiagonalMatrix & operator=(const DiagonalBase< OtherDerived > &other)
Copy operator.
Definition: DiagonalMatrix.h:186
DiagonalMatrix(const DiagonalBase< OtherDerived > &other)
Copy constructor.
Definition: DiagonalMatrix.h:172
internal::traits< Derived >::Index Index
The type of indices.
Definition: DenseBase.h:60
void setIdentity()
Sets this matrix to be the identity matrix of the current size.
Definition: DiagonalMatrix.h:210
DiagonalReturnType diagonal()
Definition: Diagonal.h:168
const unsigned int LvalueBit
Means the expression has a coeffRef() method, i.e.
Definition: Constants.h:131
DiagonalMatrix(const Scalar &x, const Scalar &y)
2D constructor.
Definition: DiagonalMatrix.h:165
const DiagonalProduct< MatrixDerived, Derived, OnTheLeft > operator*(const MatrixBase< MatrixDerived > &matrix) const
Definition: DiagonalMatrix.h:63
Represents a diagonal matrix with its storage.
Definition: DiagonalMatrix.h:135
Derived & setZero()
Sets all coefficients in this expression to zero.
Definition: CwiseNullaryOp.h:499
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: TestIMU_Common.h:87
Holds information about the various numeric (i.e.
Definition: NumTraits.h:88
void resize(Index size)
Resizes to given size.
Definition: DiagonalMatrix.h:204
DiagonalWrapper(DiagonalVectorType &a_diagonal)
Constructor from expression of diagonal coefficients to wrap.
Definition: DiagonalMatrix.h:258
const DiagonalVectorType & diagonal() const
const version of diagonal().
Definition: DiagonalMatrix.h:154
Definition: XprHelper.h:32
void setZero()
Sets all coefficients to zero.
Definition: DiagonalMatrix.h:206
Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor Matrix...
Definition: EigenBase.h:26
DiagonalMatrix()
Default constructor without initialization.
Definition: DiagonalMatrix.h:159
Index size() const
Definition: EigenBase.h:49
DiagonalMatrix(const Scalar &x, const Scalar &y, const Scalar &z)
3D constructor.
Definition: DiagonalMatrix.h:168
bool isDiagonal(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: DiagonalMatrix.h:292
const DiagonalWrapper< const Derived > asDiagonal() const
Definition: DiagonalMatrix.h:278
DiagonalMatrix(Index dim)
Constructs a diagonal matrix with given dimension.
Definition: DiagonalMatrix.h:162
Definition: DiagonalProduct.h:45
const DiagonalVectorType & diagonal() const
Definition: DiagonalMatrix.h:261
DiagonalMatrix & operator=(const DiagonalMatrix &other)
This is a special case of the templated operator=.
Definition: DiagonalMatrix.h:196
Definition: BandTriangularSolver.h:13
DiagonalVectorType & diagonal()
Definition: DiagonalMatrix.h:156
Definition: DiagonalMatrix.h:18
Expression of a diagonal matrix.
Definition: DiagonalMatrix.h:248
void setIdentity(Index size)
Sets this matrix to be the identity matrix of the given size.
Definition: DiagonalMatrix.h:212
The type used to identify a dense storage.
Definition: Constants.h:428
DiagonalMatrix(const MatrixBase< OtherDerived > &other)
generic constructor from expression of the diagonal coefficients
Definition: DiagonalMatrix.h:181
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
void setZero(Index size)
Resizes and sets all coefficients to zero.
Definition: DiagonalMatrix.h:208
Definition: ForwardDeclarations.h:17
double Scalar
Common scalar type.
Definition: FlexibleKalmanBase.h:48
DiagonalMatrix(const DiagonalMatrix &other)
copy constructor.
Definition: DiagonalMatrix.h:176