10#ifndef EIGEN_CWISE_NULLARY_OP_H
11#define EIGEN_CWISE_NULLARY_OP_H
34template<
typename NullaryOp,
typename PlainObjectType>
43template<
typename NullaryOp,
typename PlainObjectType>
53 : m_rows(rows), m_cols(cols), m_functor(func)
55 eigen_assert(rows >= 0
56 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
58 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
62 EIGEN_STRONG_INLINE Index rows()
const {
return m_rows.value(); }
64 EIGEN_STRONG_INLINE Index cols()
const {
return m_cols.value(); }
67 EIGEN_STRONG_INLINE
const Scalar coeff(Index
rowId, Index
colId)
const
72 template<
int LoadMode>
73 EIGEN_STRONG_INLINE PacketScalar packet(Index
rowId, Index
colId)
const
79 EIGEN_STRONG_INLINE
const Scalar coeff(Index index)
const
81 return m_functor(index);
84 template<
int LoadMode>
85 EIGEN_STRONG_INLINE PacketScalar packet(Index index)
const
87 return m_functor.packetOp(index);
114template<
typename Derived>
115template<
typename CustomNullaryOp>
116EIGEN_STRONG_INLINE
const CwiseNullaryOp<CustomNullaryOp, typename DenseBase<Derived>::PlainObject>
140template<
typename Derived>
141template<
typename CustomNullaryOp>
145 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
159template<
typename Derived>
160template<
typename CustomNullaryOp>
180template<
typename Derived>
202template<
typename Derived>
218template<
typename Derived>
222 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
243template<
typename Derived>
247 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
255template<
typename Derived>
259 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
260 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
261 return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, internal::linspaced_op<Scalar,PacketScalar,
false>(
low,
high,Derived::SizeAtCompileTime));
281 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
289template<
typename Derived>
293 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
294 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
299template<
typename Derived>
301(
const Scalar& val,
const RealScalar&
prec)
const
304 for(Index
j = 0;
j < cols(); ++
j)
305 for(Index i = 0; i < rows(); ++i)
306 if(!internal::isApprox(self.coeff(i,
j), val,
prec))
314template<
typename Derived>
316(
const Scalar& val,
const RealScalar&
prec)
const
318 return isApproxToConstant(val,
prec);
325template<
typename Derived>
335template<
typename Derived>
338 return derived() = Constant(rows(), cols(), val);
350template<
typename Derived>
351EIGEN_STRONG_INLINE Derived&
355 return setConstant(val);
369template<
typename Derived>
370EIGEN_STRONG_INLINE Derived&
374 return setConstant(val);
390template<
typename Derived>
393 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
407template<
typename Derived>
410 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
411 return setLinSpaced(size(),
low,
high);
430template<
typename Derived>
434 return Constant(rows, cols,
Scalar(0));
453template<
typename Derived>
457 return Constant(size,
Scalar(0));
470template<
typename Derived>
474 return Constant(
Scalar(0));
485template<
typename Derived>
489 for(Index
j = 0;
j < cols(); ++
j)
490 for(Index i = 0; i < rows(); ++i)
491 if(!internal::isMuchSmallerThan(self.coeff(i,
j),
static_cast<Scalar>(1),
prec))
503template<
typename Derived>
506 return setConstant(
Scalar(0));
518template<
typename Derived>
519EIGEN_STRONG_INLINE Derived&
523 return setConstant(Scalar(0));
536template<
typename Derived>
537EIGEN_STRONG_INLINE Derived&
541 return setConstant(Scalar(0));
560template<
typename Derived>
564 return Constant(rows, cols,
Scalar(1));
583template<
typename Derived>
600template<
typename Derived>
604 return Constant(
Scalar(1));
615template<
typename Derived>
617(
const RealScalar&
prec)
const
629template<
typename Derived>
632 return setConstant(
Scalar(1));
644template<
typename Derived>
645EIGEN_STRONG_INLINE Derived&
649 return setConstant(Scalar(1));
662template<
typename Derived>
663EIGEN_STRONG_INLINE Derived&
667 return setConstant(Scalar(1));
686template<
typename Derived>
703template<
typename Derived>
707 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
720template<
typename Derived>
722(
const RealScalar&
prec)
const
725 for(Index
j = 0;
j < cols(); ++
j)
727 for(Index i = 0; i < rows(); ++i)
731 if(!internal::isApprox(self.coeff(i,
j),
static_cast<Scalar
>(1),
prec))
736 if(!internal::isMuchSmallerThan(self.coeff(i,
j),
static_cast<RealScalar
>(1),
prec))
746template<
typename Derived,
bool Big = (Derived::SizeAtCompileTime>=16)>
750 static EIGEN_STRONG_INLINE Derived& run(Derived& m)
752 return m = Derived::Identity(m.rows(), m.cols());
756template<
typename Derived>
760 static EIGEN_STRONG_INLINE Derived& run(Derived& m)
763 const Index size = (std::min)(m.rows(), m.cols());
764 for(Index i = 0; i < size; ++i) m.coeffRef(i,i) =
typename Derived::Scalar(1);
778template<
typename Derived>
794template<
typename Derived>
797 derived().resize(rows, cols);
798 return setIdentity();
807template<
typename Derived>
810 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
822template<
typename Derived>
825 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
835template<
typename Derived>
837{
return Derived::Unit(0); }
845template<
typename Derived>
847{
return Derived::Unit(1); }
855template<
typename Derived>
857{
return Derived::Unit(2); }
865template<
typename Derived>
867{
return Derived::Unit(3); }
Generic expression of a matrix where all coefficients are defined by a functor.
Definition CwiseNullaryOp.h:45
EIGEN_DEVICE_FUNC const NullaryOp & functor() const
Definition CwiseNullaryOp.h:92
Base class for all dense matrices, vectors, and arrays.
Definition DenseBase.h:49
EIGEN_DEVICE_FUNC Derived & setZero()
Sets all coefficients in this expression to zero.
Definition CwiseNullaryOp.h:504
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:316
static EIGEN_DEVICE_FUNC const SequentialLinSpacedReturnType LinSpaced(Sequential_t, Index size, const Scalar &low, const Scalar &high)
Sets a linearly space vector.
Definition CwiseNullaryOp.h:245
EIGEN_DEVICE_FUNC void fill(const Scalar &value)
Alias for setConstant(): sets all coefficients in this expression to val.
Definition CwiseNullaryOp.h:326
EIGEN_DEVICE_FUNC Derived & setConstant(const Scalar &value)
Sets all coefficients in this expression to value.
Definition CwiseNullaryOp.h:336
internal::traits< Derived >::Scalar Scalar
The numeric type of the expression' coefficients, e.g.
Definition DenseBase.h:68
static EIGEN_DEVICE_FUNC const ConstantReturnType Ones()
Definition CwiseNullaryOp.h:602
EIGEN_DEVICE_FUNC Derived & setOnes()
Sets all coefficients in this expression to one.
Definition CwiseNullaryOp.h:630
EIGEN_DEVICE_FUNC bool isOnes(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:617
static EIGEN_DEVICE_FUNC const ConstantReturnType Zero()
Definition CwiseNullaryOp.h:472
EIGEN_DEVICE_FUNC Derived & setLinSpaced(Index size, const Scalar &low, const Scalar &high)
Sets a linearly space vector.
Definition CwiseNullaryOp.h:391
EIGEN_DEVICE_FUNC bool isZero(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:486
EIGEN_DEVICE_FUNC bool isApproxToConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:301
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
static EIGEN_DEVICE_FUNC const IdentityReturnType Identity()
Definition CwiseNullaryOp.h:705
static EIGEN_DEVICE_FUNC const BasisReturnType UnitW()
Definition CwiseNullaryOp.h:866
EIGEN_DEVICE_FUNC Derived & setIdentity()
Writes the identity expression (not necessarily square) into *this.
Definition CwiseNullaryOp.h:779
static EIGEN_DEVICE_FUNC const BasisReturnType UnitX()
Definition CwiseNullaryOp.h:836
bool isIdentity(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:722
static EIGEN_DEVICE_FUNC const BasisReturnType UnitZ()
Definition CwiseNullaryOp.h:856
static EIGEN_DEVICE_FUNC const BasisReturnType Unit(Index size, Index i)
Definition CwiseNullaryOp.h:808
static EIGEN_DEVICE_FUNC const BasisReturnType UnitY()
Definition CwiseNullaryOp.h:846
EIGEN_DEVICE_FUNC 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:352
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
Resizes to the given size, and sets all coefficients in this expression to zero.
Definition CwiseNullaryOp.h:520
EIGEN_DEVICE_FUNC Derived & setOnes(Index size)
Resizes to the given newSize, and sets all coefficients in this expression to one.
Definition CwiseNullaryOp.h:646
Pseudo expression representing a solving operation.
Definition Solve.h:63
Definition XprHelper.h:50
Definition XprHelper.h:67
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:61
Definition XprHelper.h:428
Definition NullaryFunctors.h:107
Definition NullaryFunctors.h:18
Definition NullaryFunctors.h:31
Definition CwiseNullaryOp.h:748
Definition ForwardDeclarations.h:17