10 #ifndef EIGEN_CWISE_NULLARY_OP_H 11 #define EIGEN_CWISE_NULLARY_OP_H 34 template<
typename NullaryOp,
typename PlainObjectType>
48 template<
typename NullaryOp,
typename PlainObjectType>
58 : m_rows(nbRows), m_cols(nbCols), m_functor(
func)
60 eigen_assert(nbRows >= 0
61 && (RowsAtCompileTime ==
Dynamic || RowsAtCompileTime == nbRows)
63 && (ColsAtCompileTime ==
Dynamic || ColsAtCompileTime == nbCols));
66 EIGEN_STRONG_INLINE Index rows()
const {
return m_rows.value(); }
67 EIGEN_STRONG_INLINE Index cols()
const {
return m_cols.value(); }
69 EIGEN_STRONG_INLINE
const Scalar coeff(Index rowId, Index colId)
const 71 return m_functor(rowId, colId);
74 template<
int LoadMode>
75 EIGEN_STRONG_INLINE PacketScalar packet(Index rowId, Index colId)
const 77 return m_functor.packetOp(rowId, colId);
80 EIGEN_STRONG_INLINE
const Scalar coeff(Index index)
const 82 return m_functor(index);
85 template<
int LoadMode>
86 EIGEN_STRONG_INLINE PacketScalar packet(Index index)
const 88 return m_functor.packetOp(index);
92 const NullaryOp&
functor()
const {
return m_functor; }
97 const NullaryOp m_functor;
114 template<
typename Derived>
115 template<
typename CustomNullaryOp>
137 template<
typename Derived>
138 template<
typename CustomNullaryOp>
142 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
156 template<
typename Derived>
157 template<
typename CustomNullaryOp>
177 template<
typename Derived>
199 template<
typename Derived>
215 template<
typename Derived>
219 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
240 template<
typename Derived>
244 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
252 template<
typename Derived>
256 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
257 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
274 template<
typename Derived>
278 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
286 template<
typename Derived>
290 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
291 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
296 template<
typename Derived>
298 (
const Scalar& val,
const RealScalar& prec)
const 300 for(
Index j = 0; j < cols(); ++j)
301 for(
Index i = 0; i < rows(); ++i)
302 if(!internal::isApprox(this->coeff(i, j), val, prec))
310 template<
typename Derived>
312 (
const Scalar& val,
const RealScalar& prec)
const 314 return isApproxToConstant(val, prec);
321 template<
typename Derived>
331 template<
typename Derived>
334 return derived() = Constant(rows(), cols(), val);
346 template<
typename Derived>
347 EIGEN_STRONG_INLINE Derived&
351 return setConstant(val);
365 template<
typename Derived>
366 EIGEN_STRONG_INLINE Derived&
369 resize(nbRows, nbCols);
370 return setConstant(val);
386 template<
typename Derived>
389 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
403 template<
typename Derived>
406 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
407 return setLinSpaced(
size(), low, high);
426 template<
typename Derived>
430 return Constant(nbRows, nbCols,
Scalar(0));
449 template<
typename Derived>
453 return Constant(size,
Scalar(0));
466 template<
typename Derived>
470 return Constant(
Scalar(0));
481 template<
typename Derived>
484 for(
Index j = 0; j < cols(); ++j)
485 for(
Index i = 0; i < rows(); ++i)
486 if(!internal::isMuchSmallerThan(this->coeff(i, j), static_cast<Scalar>(1), prec))
498 template<
typename Derived>
501 return setConstant(
Scalar(0));
513 template<
typename Derived>
514 EIGEN_STRONG_INLINE Derived&
518 return setConstant(
Scalar(0));
531 template<
typename Derived>
532 EIGEN_STRONG_INLINE Derived&
535 resize(nbRows, nbCols);
536 return setConstant(
Scalar(0));
555 template<
typename Derived>
559 return Constant(nbRows, nbCols,
Scalar(1));
578 template<
typename Derived>
582 return Constant(newSize,
Scalar(1));
595 template<
typename Derived>
599 return Constant(
Scalar(1));
610 template<
typename Derived>
612 (
const RealScalar& prec)
const 614 return isApproxToConstant(
Scalar(1), prec);
624 template<
typename Derived>
627 return setConstant(
Scalar(1));
639 template<
typename Derived>
640 EIGEN_STRONG_INLINE Derived&
644 return setConstant(
Scalar(1));
657 template<
typename Derived>
658 EIGEN_STRONG_INLINE Derived&
661 resize(nbRows, nbCols);
662 return setConstant(
Scalar(1));
681 template<
typename Derived>
698 template<
typename Derived>
702 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
715 template<
typename Derived>
717 (
const RealScalar& prec)
const 719 for(
Index j = 0; j < cols(); ++j)
721 for(
Index i = 0; i < rows(); ++i)
725 if(!internal::isApprox(this->coeff(i, j), static_cast<Scalar>(1), prec))
730 if(!internal::isMuchSmallerThan(this->coeff(i, j), static_cast<RealScalar>(1), prec))
740 template<
typename Derived,
bool Big = (Derived::SizeAtCompileTime>=16)>
743 static EIGEN_STRONG_INLINE Derived& run(Derived& m)
745 return m = Derived::Identity(m.rows(), m.cols());
749 template<
typename Derived>
752 typedef typename Derived::Index Index;
753 static EIGEN_STRONG_INLINE Derived& run(Derived& m)
756 const Index
size = (std::min)(m.rows(), m.cols());
771 template<
typename Derived>
787 template<
typename Derived>
790 derived().resize(nbRows, nbCols);
791 return setIdentity();
800 template<
typename Derived>
803 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
804 return BasisReturnType(SquareMatrixType::Identity(newSize,newSize), i);
815 template<
typename Derived>
818 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
828 template<
typename Derived>
830 {
return Derived::Unit(0); }
838 template<
typename Derived>
840 {
return Derived::Unit(1); }
848 template<
typename Derived>
850 {
return Derived::Unit(2); }
858 template<
typename Derived>
860 {
return Derived::Unit(3); }
864 #endif // EIGEN_CWISE_NULLARY_OP_H Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:49
void fill(const Scalar &value)
Alias for setConstant(): sets all coefficients in this expression to val.
Definition: CwiseNullaryOp.h:322
Definition: gtest_unittest.cc:5031
bool isZero(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: CwiseNullaryOp.h:482
static const BasisReturnType UnitW()
Definition: CwiseNullaryOp.h:859
Derived & setConstant(const Scalar &value)
Sets all coefficients in this expression to value.
Definition: CwiseNullaryOp.h:332
Derived & setIdentity()
Writes the identity expression (not necessarily square) into *this.
Definition: CwiseNullaryOp.h:772
internal::traits< Derived >::Index Index
The type of indices.
Definition: DenseBase.h:60
Derived & setOnes()
Sets all coefficients in this expression to one.
Definition: CwiseNullaryOp.h:625
static const SequentialLinSpacedReturnType LinSpaced(Sequential_t, Index size, const Scalar &low, const Scalar &high)
Sets a linearly space vector.
Definition: CwiseNullaryOp.h:242
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
Definition: Functors.h:689
static const BasisReturnType UnitY()
Definition: CwiseNullaryOp.h:839
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:41
Definition: XprHelper.h:32
const unsigned int PacketAccessBit
Short version: means the expression might be vectorized.
Definition: Constants.h:81
Definition: XprHelper.h:350
detail::size< coerce_list< Ts... >> size
Get the size of a list (number of elements.)
Definition: Size.h:56
static const ConstantReturnType Zero()
Definition: CwiseNullaryOp.h:468
Derived & setLinSpaced(Index size, const Scalar &low, const Scalar &high)
Sets a linearly space vector.
Definition: CwiseNullaryOp.h:387
bool isConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
This is just an alias for isApproxToConstant().
Definition: CwiseNullaryOp.h:312
static const BasisReturnType UnitZ()
Definition: CwiseNullaryOp.h:849
Derived & setZero(Index size)
Resizes to the given size, and sets all coefficients in this expression to zero.
Definition: CwiseNullaryOp.h:515
Derived & setConstant(Index size, const Scalar &value)
Resizes to the given size, and sets all coefficients in this expression to the given value...
Definition: CwiseNullaryOp.h:348
static const IdentityReturnType Identity()
Definition: CwiseNullaryOp.h:700
Derived & setOnes(Index size)
Resizes to the given newSize, and sets all coefficients in this expression to one.
Definition: CwiseNullaryOp.h:641
Definition: benchGeometry.cpp:23
Definition: BandTriangularSolver.h:13
Definition: Functors.h:647
Definition: XprHelper.h:89
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:103
Definition: Functors.h:571
bool isApproxToConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: CwiseNullaryOp.h:298
static const ConstantReturnType Ones()
Definition: CwiseNullaryOp.h:597
Definition: CwiseNullaryOp.h:741
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time, and that instead the value is stored in some runtime variable.
Definition: Constants.h:21
bool isIdentity(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: CwiseNullaryOp.h:717
const unsigned int EvalBeforeNestingBit
means the expression should be evaluated by the calling expression
Definition: Constants.h:58
static const BasisReturnType UnitX()
Definition: CwiseNullaryOp.h:829
static const ConstantReturnType Constant(Index rows, Index cols, const Scalar &value)
Definition: CwiseNullaryOp.h:179
const NullaryOp & functor() const
Definition: CwiseNullaryOp.h:92
bool isOnes(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: CwiseNullaryOp.h:612
static const BasisReturnType Unit(Index size, Index i)
Definition: CwiseNullaryOp.h:801
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
const unsigned int LinearAccessBit
Short version: means the expression can be seen as 1D vector.
Definition: Constants.h:117
Definition: ForwardDeclarations.h:17
double Scalar
Common scalar type.
Definition: FlexibleKalmanBase.h:48
Definition: Functors.h:556