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));
77 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
78 Index rows()
const {
return m_rows.value(); }
79 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR
80 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
109#ifndef EIGEN_PARSED_BY_DOXYGEN
110const CwiseNullaryOp<CustomNullaryOp,typename DenseBase<Derived>::PlainObject>
112const CwiseNullaryOp<CustomNullaryOp,PlainObject>
137template<
typename Derived>
138template<
typename CustomNullaryOp>
139EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
140#ifndef EIGEN_PARSED_BY_DOXYGEN
147 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
161template<
typename Derived>
162template<
typename CustomNullaryOp>
163EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
164#ifndef EIGEN_PARSED_BY_DOXYGEN
187template<
typename Derived>
209template<
typename Derived>
225template<
typename Derived>
229 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
242template<
typename Derived>
246 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
254template<
typename Derived>
258 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
259 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
286template<typename Derived>
287EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename
DenseBase<Derived>::RandomAccessLinSpacedReturnType
290 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
298template<
typename Derived>
302 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
303 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
308template<
typename Derived>
310(
const Scalar& val,
const RealScalar& prec)
const
312 typename internal::nested_eval<Derived,1>::type self(
derived());
315 if(!internal::isApprox(self.coeff(i, j), val, prec))
323template<
typename Derived>
325(
const Scalar& val,
const RealScalar& prec)
const
334template<
typename Derived>
344template<
typename Derived>
347 return derived() =
Constant(rows(), cols(), val);
359template<
typename Derived>
360EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
378template<
typename Derived>
379EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
392template<
typename Derived>
393EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
405template<
typename Derived>
406EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
429template<
typename Derived>
432 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
433 return derived() = Derived::NullaryExpr(newSize, internal::linspaced_op<Scalar>(low,high,newSize));
449template<
typename Derived>
452 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
472template<
typename Derived>
495template<
typename Derived>
512template<
typename Derived>
527template<
typename Derived>
530 typename internal::nested_eval<Derived,1>::type self(
derived());
533 if(!internal::isMuchSmallerThan(self.coeff(i, j),
static_cast<Scalar>(1), prec))
545template<
typename Derived>
560template<
typename Derived>
561EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
578template<
typename Derived>
579EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
592template<
typename Derived>
593EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
605template<
typename Derived>
606EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
628template<
typename Derived>
651template<
typename Derived>
668template<
typename Derived>
683template<
typename Derived>
685(
const RealScalar& prec)
const
697template<
typename Derived>
712template<
typename Derived>
713EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
730template<
typename Derived>
731EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
744template<
typename Derived>
745EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
757template<
typename Derived>
758EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived&
780template<
typename Derived>
797template<
typename Derived>
801 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
814template<
typename Derived>
816(
const RealScalar& prec)
const
818 typename internal::nested_eval<Derived,1>::type self(
derived());
825 if(!internal::isApprox(self.coeff(i, j),
static_cast<Scalar>(1), prec))
830 if(!internal::isMuchSmallerThan(self.coeff(i, j),
static_cast<RealScalar
>(1), prec))
840template<
typename Derived,
bool Big = (Derived::SizeAtCompileTime>=16)>
841struct setIdentity_impl
844 static EIGEN_STRONG_INLINE Derived& run(Derived& m)
846 return m = Derived::Identity(m.rows(), m.cols());
850template<
typename Derived>
851struct setIdentity_impl<Derived, true>
854 static EIGEN_STRONG_INLINE Derived& run(Derived& m)
857 const Index size = numext::mini(m.rows(), m.cols());
858 for(
Index i = 0; i < size; ++i) m.coeffRef(i,i) =
typename Derived::Scalar(1);
872template<
typename Derived>
875 return internal::setIdentity_impl<Derived>::run(
derived());
888template<
typename Derived>
901template<
typename Derived>
904 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
905 return BasisReturnType(SquareMatrixType::Identity(newSize,newSize), i);
916template<
typename Derived>
919 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
920 return BasisReturnType(SquareMatrixType::Identity(),i);
929template<
typename Derived>
931{
return Derived::Unit(0); }
939template<
typename Derived>
941{
return Derived::Unit(1); }
949template<
typename Derived>
951{
return Derived::Unit(2); }
959template<
typename Derived>
961{
return Derived::Unit(3); }
971template<
typename Derived>
974 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
975 eigen_assert(i<
size());
990template<
typename Derived>
993 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
994 eigen_assert(i<newSize);
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
@ SizeAtCompileTime
Definition DenseBase.h:113
@ ColsAtCompileTime
Definition DenseBase.h:106
@ RowsAtCompileTime
Definition DenseBase.h:100
static EIGEN_DEPRECATED const RandomAccessLinSpacedReturnType LinSpaced(Sequential_t, Index size, const Scalar &low, const Scalar &high)
Definition CwiseNullaryOp.h:244
bool isConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:325
Derived & setOnes()
Definition CwiseNullaryOp.h:698
static const ConstantReturnType Ones()
Definition CwiseNullaryOp.h:670
void resize(Index newSize)
Definition DenseBase.h:246
static const CwiseNullaryOp< CustomNullaryOp, PlainObject > NullaryExpr(Index rows, Index cols, const CustomNullaryOp &func)
Definition CwiseNullaryOp.h:114
static const ConstantReturnType Zero()
Definition CwiseNullaryOp.h:514
Derived & setLinSpaced(Index size, const Scalar &low, const Scalar &high)
Sets a linearly spaced vector.
Definition CwiseNullaryOp.h:430
internal::traits< Derived >::Scalar Scalar
Definition DenseBase.h:66
static const ConstantReturnType Constant(Index rows, Index cols, const Scalar &value)
Definition CwiseNullaryOp.h:189
CoeffReturnType value() const
Definition DenseBase.h:526
void fill(const Scalar &value)
Definition CwiseNullaryOp.h:335
DenseBase()
Definition DenseBase.h:681
bool isOnes(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:685
ArrayWrapper< ExpressionType > & setConstant(const Scalar &value)
Definition CwiseNullaryOp.h:345
Derived & setZero()
Definition CwiseNullaryOp.h:546
bool isZero(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:528
bool isApproxToConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:310
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition EigenBase.h:63
Derived & derived()
Definition EigenBase.h:46
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition EigenBase.h:60
EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
Definition EigenBase.h:67
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
static const BasisReturnType UnitY()
Definition CwiseNullaryOp.h:940
Derived & setIdentity()
Definition CwiseNullaryOp.h:873
bool isIdentity(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:816
static const BasisReturnType UnitX()
Definition CwiseNullaryOp.h:930
static const IdentityReturnType Identity()
Definition CwiseNullaryOp.h:799
static const BasisReturnType UnitZ()
Definition CwiseNullaryOp.h:950
static const BasisReturnType Unit(Index size, Index i)
Definition CwiseNullaryOp.h:902
Derived & setUnit(Index i)
Set the coefficients of *this to the i-th unit (basis) vector.
Definition CwiseNullaryOp.h:972
static const BasisReturnType UnitW()
Definition CwiseNullaryOp.h:960
Derived & setOnes(Index size)
Definition CwiseNullaryOp.h:714
void resize(Index rows, Index cols)
Definition PlainObjectBase.h:271
Derived & setConstant(Index size, const Scalar &val)
Definition CwiseNullaryOp.h:361
Derived & setZero(Index size)
Definition CwiseNullaryOp.h:562
const unsigned int RowMajorBit
Definition Constants.h:66
Namespace containing all symbols from the Eigen library.
Definition Core:141
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
const int Dynamic
Definition Constants.h:22