10 #ifndef EIGEN_CWISE_NULLARY_OP_H 11 #define EIGEN_CWISE_NULLARY_OP_H 16 template<
typename NullaryOp,
typename PlainObjectType>
59 template<
typename NullaryOp,
typename PlainObjectType>
69 : m_rows(rows), m_cols(cols), m_functor(
func)
71 eigen_assert(rows >= 0
72 && (RowsAtCompileTime ==
Dynamic || RowsAtCompileTime == rows)
74 && (ColsAtCompileTime ==
Dynamic || ColsAtCompileTime == cols));
78 EIGEN_STRONG_INLINE
Index rows()
const {
return m_rows.value(); }
80 EIGEN_STRONG_INLINE
Index cols()
const {
return m_cols.value(); }
84 const NullaryOp&
functor()
const {
return m_functor; }
89 const NullaryOp m_functor;
106 template<
typename Derived>
107 template<
typename CustomNullaryOp>
132 template<
typename Derived>
133 template<
typename CustomNullaryOp>
137 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
151 template<
typename Derived>
152 template<
typename CustomNullaryOp>
172 template<
typename Derived>
194 template<
typename Derived>
210 template<
typename Derived>
214 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
222 template<
typename Derived>
226 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
234 template<
typename Derived>
238 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
239 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
266 template<
typename Derived>
270 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
278 template<
typename Derived>
282 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
283 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
288 template<
typename Derived>
290 (
const Scalar& val,
const RealScalar& prec)
const 293 for(
Index j = 0; j < cols(); ++j)
294 for(
Index i = 0; i < rows(); ++i)
295 if(!internal::isApprox(
self.coeff(i, j), val, prec))
303 template<
typename Derived>
305 (
const Scalar& val,
const RealScalar& prec)
const 307 return isApproxToConstant(val, prec);
314 template<
typename Derived>
324 template<
typename Derived>
327 return derived() = Constant(rows(), cols(), val);
339 template<
typename Derived>
340 EIGEN_STRONG_INLINE Derived&
344 return setConstant(val);
358 template<
typename Derived>
359 EIGEN_STRONG_INLINE Derived&
363 return setConstant(val);
382 template<
typename Derived>
385 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
402 template<
typename Derived>
405 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
406 return setLinSpaced(size(), low, high);
425 template<
typename Derived>
429 return Constant(rows, cols,
Scalar(0));
448 template<
typename Derived>
452 return Constant(size,
Scalar(0));
465 template<
typename Derived>
469 return Constant(
Scalar(0));
480 template<
typename Derived>
484 for(
Index j = 0; j < cols(); ++j)
485 for(
Index i = 0; i < rows(); ++i)
486 if(!internal::isMuchSmallerThan(
self.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&
536 return setConstant(Scalar(0));
555 template<
typename Derived>
559 return Constant(rows, cols,
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&
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 720 for(
Index j = 0; j < cols(); ++j)
722 for(
Index i = 0; i < rows(); ++i)
726 if(!internal::isApprox(
self.coeff(i, j), static_cast<Scalar>(1), prec))
731 if(!internal::isMuchSmallerThan(
self.coeff(i, j), static_cast<RealScalar>(1), prec))
741 template<
typename Derived,
bool Big = (Derived::SizeAtCompileTime>=16)>
745 static EIGEN_STRONG_INLINE Derived& run(Derived& m)
747 return m = Derived::Identity(m.rows(), m.cols());
751 template<
typename Derived>
755 static EIGEN_STRONG_INLINE Derived& run(Derived& m)
758 const Index size = numext::mini(m.rows(), m.cols());
759 for(
Index i = 0; i < size; ++i) m.coeffRef(i,i) =
typename Derived::Scalar(1);
773 template<
typename Derived>
789 template<
typename Derived>
792 derived().resize(rows, cols);
793 return setIdentity();
802 template<
typename Derived>
805 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
806 return BasisReturnType(SquareMatrixType::Identity(newSize,newSize), i);
817 template<
typename Derived>
820 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
830 template<
typename Derived>
832 {
return Derived::Unit(0); }
840 template<
typename Derived>
842 {
return Derived::Unit(1); }
850 template<
typename Derived>
852 {
return Derived::Unit(2); }
860 template<
typename Derived>
862 {
return Derived::Unit(3); }
866 #endif // EIGEN_CWISE_NULLARY_OP_H Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:60
EIGEN_DEVICE_FUNC void fill(const Scalar &value)
Alias for setConstant(): sets all coefficients in this expression to val.
Definition: CwiseNullaryOp.h:315
EIGEN_DEVICE_FUNC bool isZero(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: CwiseNullaryOp.h:481
internal::traits< Derived >::Scalar Scalar
The numeric type of the expression' coefficients, e.g.
Definition: DenseBase.h:66
static EIGEN_DEVICE_FUNC const BasisReturnType UnitW()
Definition: CwiseNullaryOp.h:861
EIGEN_DEVICE_FUNC Derived & setConstant(const Scalar &value)
Sets all coefficients in this expression to value val.
Definition: CwiseNullaryOp.h:325
EIGEN_DEVICE_FUNC Derived & setIdentity()
Writes the identity expression (not necessarily square) into *this.
Definition: CwiseNullaryOp.h:774
EIGEN_DEVICE_FUNC Derived & setOnes()
Sets all coefficients in this expression to one.
Definition: CwiseNullaryOp.h:625
EIGEN_DEVICE_FUNC Derived & setZero()
Sets all coefficients in this expression to zero.
Definition: CwiseNullaryOp.h:499
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:85
static EIGEN_DEVICE_FUNC const BasisReturnType UnitY()
Definition: CwiseNullaryOp.h:841
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition: Constants.h:61
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:41
Definition: XprHelper.h:89
Definition: XprHelper.h:463
static EIGEN_DEVICE_FUNC const ConstantReturnType Zero()
Definition: CwiseNullaryOp.h:467
EIGEN_DEVICE_FUNC Derived & setLinSpaced(Index size, const Scalar &low, const Scalar &high)
Sets a linearly spaced vector.
Definition: CwiseNullaryOp.h:383
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
EIGEN_DEVICE_FUNC const NullaryOp & functor() const
Definition: CwiseNullaryOp.h:84
EIGEN_DEVICE_FUNC bool isConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
This is just an alias for isApproxToConstant().
Definition: CwiseNullaryOp.h:305
static EIGEN_DEVICE_FUNC const BasisReturnType UnitZ()
Definition: CwiseNullaryOp.h:851
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
Resizes to the given size, and sets all coefficients in this expression to zero.
Definition: CwiseNullaryOp.h:515
EIGEN_DEVICE_FUNC Derived & setConstant(Index size, const Scalar &val)
Resizes to the given size, and sets all coefficients in this expression to the given value val...
Definition: CwiseNullaryOp.h:341
static EIGEN_DEVICE_FUNC const IdentityReturnType Identity()
Definition: CwiseNullaryOp.h:700
EIGEN_DEVICE_FUNC 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: NullaryFunctors.h:119
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:103
Definition: NullaryFunctors.h:31
EIGEN_DEVICE_FUNC bool isApproxToConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: CwiseNullaryOp.h:290
static EIGEN_DEVICE_FUNC const ConstantReturnType Ones()
Definition: CwiseNullaryOp.h:597
Definition: CwiseNullaryOp.h:742
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
static EIGEN_DEVICE_FUNC const BasisReturnType UnitX()
Definition: CwiseNullaryOp.h:831
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:55
static EIGEN_DEVICE_FUNC const ConstantReturnType Constant(Index rows, Index cols, const Scalar &value)
Definition: CwiseNullaryOp.h:174
EIGEN_DEVICE_FUNC bool isOnes(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: CwiseNullaryOp.h:612
static EIGEN_DEVICE_FUNC const BasisReturnType Unit(Index size, Index i)
Definition: CwiseNullaryOp.h:803
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Definition: ForwardDeclarations.h:17
static EIGEN_DEVICE_FUNC const SequentialLinSpacedReturnType LinSpaced(Sequential_t, Index size, const Scalar &low, const Scalar &high)
Definition: CwiseNullaryOp.h:224
Definition: NullaryFunctors.h:18