10#ifndef EIGEN_CWISE_NULLARY_OP_H
11#define EIGEN_CWISE_NULLARY_OP_H
16template<
typename NullaryOp,
typename PlainObjectType>
17struct traits<CwiseNullaryOp<NullaryOp, PlainObjectType> > : traits<PlainObjectType>
20 Flags = traits<PlainObjectType>::Flags &
RowMajorBit
59template<
typename NullaryOp,
typename PlainObjectType>
60class CwiseNullaryOp :
public internal::dense_xpr_base< CwiseNullaryOp<NullaryOp, PlainObjectType> >::type, internal::no_assignment_operator
64 typedef typename internal::dense_xpr_base<CwiseNullaryOp>::type Base;
65 EIGEN_DENSE_PUBLIC_INTERFACE(CwiseNullaryOp)
68 CwiseNullaryOp(
Index rows,
Index cols,
const NullaryOp& func = NullaryOp())
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; }
87 const internal::variable_if_dynamic<Index, RowsAtCompileTime> m_rows;
88 const internal::variable_if_dynamic<Index, ColsAtCompileTime> m_cols;
89 const NullaryOp m_functor;
106template<
typename Derived>
107template<
typename CustomNullaryOp>
108EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const CwiseNullaryOp<CustomNullaryOp, typename DenseBase<Derived>::PlainObject>
109DenseBase<Derived>::NullaryExpr(
Index rows,
Index cols,
const CustomNullaryOp& func)
132template<
typename Derived>
133template<
typename CustomNullaryOp>
135DenseBase<Derived>::NullaryExpr(
Index size,
const CustomNullaryOp& func)
137 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
151template<
typename Derived>
152template<
typename CustomNullaryOp>
154DenseBase<Derived>::NullaryExpr(
const CustomNullaryOp& func)
172template<
typename Derived>
176 return DenseBase<Derived>::NullaryExpr(rows, cols, internal::scalar_constant_op<Scalar>(
value));
194template<
typename Derived>
198 return DenseBase<Derived>::NullaryExpr(size, internal::scalar_constant_op<Scalar>(
value));
210template<
typename Derived>
214 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
222template<
typename Derived>
226 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
227 return DenseBase<Derived>::NullaryExpr(size, internal::linspaced_op<Scalar,PacketScalar>(low,high,size));
234template<
typename Derived>
238 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
239 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
240 return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, internal::linspaced_op<Scalar,PacketScalar>(low,high,Derived::SizeAtCompileTime));
266template<
typename Derived>
270 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
271 return DenseBase<Derived>::NullaryExpr(size, internal::linspaced_op<Scalar,PacketScalar>(low,high,size));
278template<
typename Derived>
282 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
283 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
284 return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, internal::linspaced_op<Scalar,PacketScalar>(low,high,Derived::SizeAtCompileTime));
288template<
typename Derived>
290(
const Scalar& val,
const RealScalar& prec)
const
292 typename internal::nested_eval<Derived,1>::type self(derived());
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))
303template<
typename Derived>
305(
const Scalar& val,
const RealScalar& prec)
const
314template<
typename Derived>
324template<
typename Derived>
327 return derived() =
Constant(rows(), cols(), val);
339template<
typename Derived>
340EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
358template<
typename Derived>
359EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
382template<
typename Derived>
385 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
386 return derived() = Derived::NullaryExpr(newSize, internal::linspaced_op<Scalar,PacketScalar>(low,high,newSize));
402template<
typename Derived>
405 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
425template<
typename Derived>
448template<
typename Derived>
465template<
typename Derived>
480template<
typename Derived>
483 typename internal::nested_eval<Derived,1>::type self(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))
498template<
typename Derived>
513template<
typename Derived>
514EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
531template<
typename Derived>
532EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
555template<
typename Derived>
578template<
typename Derived>
595template<
typename Derived>
610template<
typename Derived>
612(
const RealScalar& prec)
const
624template<
typename Derived>
639template<
typename Derived>
640EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
657template<
typename Derived>
658EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
681template<
typename Derived>
685 return DenseBase<Derived>::NullaryExpr(rows, cols, internal::scalar_identity_op<Scalar>());
698template<
typename Derived>
702 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
715template<
typename Derived>
717(
const RealScalar& prec)
const
719 typename internal::nested_eval<Derived,1>::type self(derived());
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))
741template<
typename Derived,
bool Big = (Derived::SizeAtCompileTime>=16)>
742struct setIdentity_impl
745 static EIGEN_STRONG_INLINE Derived& run(Derived& m)
747 return m = Derived::Identity(m.rows(), m.cols());
751template<
typename Derived>
752struct setIdentity_impl<Derived, true>
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);
773template<
typename Derived>
776 return internal::setIdentity_impl<Derived>::run(derived());
789template<
typename Derived>
792 derived().resize(rows, cols);
802template<
typename Derived>
805 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
806 return BasisReturnType(SquareMatrixType::Identity(newSize,newSize), i);
817template<
typename Derived>
820 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
821 return BasisReturnType(SquareMatrixType::Identity(),i);
830template<
typename Derived>
832{
return Derived::Unit(0); }
840template<
typename Derived>
842{
return Derived::Unit(1); }
850template<
typename Derived>
852{
return Derived::Unit(2); }
860template<
typename Derived>
862{
return Derived::Unit(3); }
Generic expression of a matrix where all coefficients are defined by a functor.
Definition CwiseNullaryOp.h:61
const NullaryOp & functor() const
Definition CwiseNullaryOp.h:84
Base class for all dense matrices, vectors, and arrays.
Definition DenseBase.h:47
bool isConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:305
Derived & setOnes()
Definition CwiseNullaryOp.h:625
static const ConstantReturnType Ones()
Definition CwiseNullaryOp.h:597
void resize(Index newSize)
Definition DenseBase.h:241
static const ConstantReturnType Zero()
Definition CwiseNullaryOp.h:467
Derived & setLinSpaced(Index size, const Scalar &low, const Scalar &high)
Sets a linearly spaced vector.
Definition CwiseNullaryOp.h:383
internal::traits< Derived >::Scalar Scalar
Definition DenseBase.h:66
static const ConstantReturnType Constant(Index rows, Index cols, const Scalar &value)
Definition CwiseNullaryOp.h:174
CoeffReturnType value() const
Definition DenseBase.h:480
@ ColsAtCompileTime
Definition DenseBase.h:106
@ RowsAtCompileTime
Definition DenseBase.h:100
void fill(const Scalar &value)
Definition CwiseNullaryOp.h:315
DenseBase()
Definition DenseBase.h:592
bool isOnes(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:612
Derived & setConstant(const Scalar &value)
Definition CwiseNullaryOp.h:325
static const SequentialLinSpacedReturnType LinSpaced(Sequential_t, Index size, const Scalar &low, const Scalar &high)
Definition CwiseNullaryOp.h:224
Derived & setZero()
Definition CwiseNullaryOp.h:499
bool isZero(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:481
bool isApproxToConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:290
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
static const BasisReturnType UnitY()
Definition CwiseNullaryOp.h:841
Derived & setIdentity()
Definition CwiseNullaryOp.h:774
bool isIdentity(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:717
static const BasisReturnType UnitX()
Definition CwiseNullaryOp.h:831
static const IdentityReturnType Identity()
Definition CwiseNullaryOp.h:700
static const BasisReturnType UnitZ()
Definition CwiseNullaryOp.h:851
static const BasisReturnType Unit(Index size, Index i)
Definition CwiseNullaryOp.h:803
static const BasisReturnType UnitW()
Definition CwiseNullaryOp.h:861
Derived & setOnes(Index size)
Definition CwiseNullaryOp.h:641
void resize(Index rows, Index cols)
Definition PlainObjectBase.h:279
Derived & setConstant(Index size, const Scalar &val)
Definition CwiseNullaryOp.h:341
Derived & setZero(Index size)
Definition CwiseNullaryOp.h:515
const unsigned int RowMajorBit
Definition Constants.h:61
Namespace containing all symbols from the Eigen library.
Definition A05_PortingFrom2To3.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:65
const int Dynamic
Definition Constants.h:21