11#ifndef EIGEN_DIAGONALMATRIX_H
12#define EIGEN_DIAGONALMATRIX_H
16#ifndef EIGEN_PARSED_BY_DOXYGEN
17template<
typename Derived>
22 typedef typename DiagonalVectorType::Scalar Scalar;
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,
41 inline const Derived& derived()
const {
return *
static_cast<const Derived*
>(
this); }
43 inline Derived& derived() {
return *
static_cast<Derived*
>(
this); }
49 inline const DiagonalVectorType& diagonal()
const {
return derived().
diagonal(); }
51 inline DiagonalVectorType& diagonal() {
return derived().
diagonal(); }
54 inline Index rows()
const {
return diagonal().size(); }
56 inline Index cols()
const {
return diagonal().size(); }
58 template<
typename MatrixDerived>
75 inline const DiagonalWrapper<
const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(DiagonalVectorType,Scalar,product) >
76 operator*(
const Scalar& scalar)
const
81 friend inline const DiagonalWrapper<
const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(Scalar,DiagonalVectorType,product) >
82 operator*(
const Scalar& scalar,
const DiagonalBase& other)
87 template<
typename OtherDerived>
89 #ifdef EIGEN_PARSED_BY_DOXYGEN
92 inline const DiagonalWrapper<
const EIGEN_CWISE_BINARY_RETURN_TYPE(DiagonalVectorType,
typename OtherDerived::DiagonalVectorType,sum) >
96 return (diagonal() + other.
diagonal()).asDiagonal();
99 template<
typename OtherDerived>
101 #ifdef EIGEN_PARSED_BY_DOXYGEN
104 inline const DiagonalWrapper<
const EIGEN_CWISE_BINARY_RETURN_TYPE(DiagonalVectorType,
typename OtherDerived::DiagonalVectorType,
difference) >
108 return (diagonal() - other.
diagonal()).asDiagonal();
128template<
typename _Scalar,
int SizeAtCompileTime,
int MaxSizeAtCompileTime>
130 :
traits<Matrix<_Scalar,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >
139template<
typename _Scalar,
int SizeAtCompileTime,
int MaxSizeAtCompileTime>
141 :
public DiagonalBase<DiagonalMatrix<_Scalar,SizeAtCompileTime,MaxSizeAtCompileTime> >
144 #ifndef EIGEN_PARSED_BY_DOXYGEN
147 typedef _Scalar Scalar;
154 DiagonalVectorType m_diagonal;
160 inline const DiagonalVectorType&
diagonal()
const {
return m_diagonal; }
163 inline DiagonalVectorType&
diagonal() {
return m_diagonal; }
179 inline DiagonalMatrix(
const Scalar& x,
const Scalar& y,
const Scalar& z) : m_diagonal(x,y,z) {}
193 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
195 : m_diagonal(
a0,
a1,
a2, args...) {}
201 explicit EIGEN_STRONG_INLINE
DiagonalMatrix(
const std::initializer_list<std::initializer_list<Scalar>>& list)
202 : m_diagonal(list) {}
206 template<
typename OtherDerived>
210 #ifndef EIGEN_PARSED_BY_DOXYGEN
216 template<
typename OtherDerived>
222 template<
typename OtherDerived>
230 #ifndef EIGEN_PARSED_BY_DOXYGEN
274template<
typename _DiagonalVectorType>
278 typedef typename DiagonalVectorType::Scalar Scalar;
279 typedef typename DiagonalVectorType::StorageIndex StorageIndex;
283 RowsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
284 ColsAtCompileTime = DiagonalVectorType::SizeAtCompileTime,
285 MaxRowsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,
286 MaxColsAtCompileTime = DiagonalVectorType::MaxSizeAtCompileTime,
292template<
typename _DiagonalVectorType>
297 #ifndef EIGEN_PARSED_BY_DOXYGEN
311 typename DiagonalVectorType::Nested m_diagonal;
323template<
typename Derived>
324EIGEN_DEVICE_FUNC
inline const DiagonalWrapper<const Derived>
338template<
typename Derived>
341 if(cols() != rows())
return false;
343 for(
Index j = 0; j < cols(); ++j)
348 for(
Index j = 0; j < cols(); ++j)
349 for(
Index i = 0; i < j; ++i)
366template<
typename DstXprType,
typename SrcXprType,
typename Functor>
EIGEN_DEVICE_FUNC void resize(Index newSize)
Only plain matrices/arrays, not expressions, may be resized; therefore the only useful resize methods...
Definition DenseBase.h:246
EIGEN_DEVICE_FUNC Derived & setZero()
Sets all coefficients in this expression to zero.
Definition CwiseNullaryOp.h:546
EIGEN_DEVICE_FUNC Derived & setOnes()
Sets all coefficients in this expression to one.
Definition CwiseNullaryOp.h:698
Definition DiagonalMatrix.h:19
Represents a diagonal matrix with its storage.
Definition DiagonalMatrix.h:142
EIGEN_DEVICE_FUNC const DiagonalVectorType & diagonal() const
const version of diagonal().
Definition DiagonalMatrix.h:160
EIGEN_DEVICE_FUNC DiagonalMatrix(const Scalar &x, const Scalar &y)
2D constructor.
Definition DiagonalMatrix.h:175
EIGEN_DEVICE_FUNC DiagonalMatrix(const MatrixBase< OtherDerived > &other)
generic constructor from expression of the diagonal coefficients
Definition DiagonalMatrix.h:218
EIGEN_DEVICE_FUNC void setIdentity()
Sets this matrix to be the identity matrix of the current size.
Definition DiagonalMatrix.h:253
EIGEN_DEVICE_FUNC void setZero()
Sets all coefficients to zero.
Definition DiagonalMatrix.h:247
EIGEN_DEVICE_FUNC void resize(Index size)
Resizes to given size.
Definition DiagonalMatrix.h:244
EIGEN_DEVICE_FUNC DiagonalVectorType & diagonal()
Definition DiagonalMatrix.h:163
EIGEN_DEVICE_FUNC DiagonalMatrix & operator=(const DiagonalMatrix &other)
This is a special case of the templated operator=.
Definition DiagonalMatrix.h:235
EIGEN_DEVICE_FUNC DiagonalMatrix()
Default constructor without initialization.
Definition DiagonalMatrix.h:167
EIGEN_DEVICE_FUNC DiagonalMatrix(Index dim)
Constructs a diagonal matrix with given dimension
Definition DiagonalMatrix.h:171
EIGEN_DEVICE_FUNC void setZero(Index size)
Resizes and sets all coefficients to zero.
Definition DiagonalMatrix.h:250
EIGEN_DEVICE_FUNC DiagonalMatrix & operator=(const DiagonalBase< OtherDerived > &other)
Copy operator.
Definition DiagonalMatrix.h:224
DiagonalMatrix(const DiagonalMatrix &other)
copy constructor.
Definition DiagonalMatrix.h:212
EIGEN_DEVICE_FUNC DiagonalMatrix(const DiagonalBase< OtherDerived > &other)
Copy constructor.
Definition DiagonalMatrix.h:208
EIGEN_DEVICE_FUNC void setIdentity(Index size)
Sets this matrix to be the identity matrix of the given size.
Definition DiagonalMatrix.h:256
EIGEN_DEVICE_FUNC DiagonalMatrix(const Scalar &x, const Scalar &y, const Scalar &z)
3D constructor.
Definition DiagonalMatrix.h:179
Expression of a diagonal matrix.
Definition DiagonalMatrix.h:295
EIGEN_DEVICE_FUNC const DiagonalVectorType & diagonal() const
Definition DiagonalMatrix.h:308
EIGEN_DEVICE_FUNC DiagonalWrapper(DiagonalVectorType &a_diagonal)
Constructor from expression of diagonal coefficients to wrap.
Definition DiagonalMatrix.h:304
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
EIGEN_DEVICE_FUNC DiagonalReturnType diagonal()
Definition Diagonal.h:187
Definition XprHelper.h:110
const unsigned int NoPreferredStorageOrderBit
for an expression, this means that the storage order can be either row-major or column-major.
Definition Constants.h:178
const unsigned int LvalueBit
Means the expression has a coeffRef() method, i.e.
Definition Constants.h:144
Namespace containing all symbols from the Eigen library.
Definition LDLT.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
Definition Constants.h:528
Definition Constants.h:531
Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor Matrix...
Definition EigenBase.h:30
Eigen::Index Index
The interface type of indices.
Definition EigenBase.h:39
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
Definition EigenBase.h:67
Definition AssignEvaluator.h:817
Definition AssignEvaluator.h:824
Definition DiagonalMatrix.h:361
Definition AssignmentFunctors.h:46
Definition AssignmentFunctors.h:21
Definition CoreEvaluators.h:29
Definition AssignmentFunctors.h:67
Definition ForwardDeclarations.h:17