Eigen  3.4.90 (git rev 9589cc4e7fd8e4538bedef80dd36c7738977a8be)
 
Loading...
Searching...
No Matches
CwiseNullaryOp.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
5//
6// This Source Code Form is subject to the terms of the Mozilla
7// Public License v. 2.0. If a copy of the MPL was not distributed
8// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
10#ifndef EIGEN_CWISE_NULLARY_OP_H
11#define EIGEN_CWISE_NULLARY_OP_H
12
13// IWYU pragma: private
14#include "./InternalHeaderCheck.h"
15
16namespace Eigen {
17
18namespace internal {
19template <typename NullaryOp, typename PlainObjectType>
20struct traits<CwiseNullaryOp<NullaryOp, PlainObjectType> > : traits<PlainObjectType> {
21 enum { Flags = traits<PlainObjectType>::Flags & RowMajorBit };
22};
23
24} // namespace internal
25
62template <typename NullaryOp, typename PlainObjectType>
63class CwiseNullaryOp : public internal::dense_xpr_base<CwiseNullaryOp<NullaryOp, PlainObjectType> >::type,
64 internal::no_assignment_operator {
65 public:
66 typedef typename internal::dense_xpr_base<CwiseNullaryOp>::type Base;
67 EIGEN_DENSE_PUBLIC_INTERFACE(CwiseNullaryOp)
68
69 EIGEN_DEVICE_FUNC CwiseNullaryOp(Index rows, Index cols, const NullaryOp& func = NullaryOp())
70 : m_rows(rows), m_cols(cols), m_functor(func) {
71 eigen_assert(rows >= 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) && cols >= 0 &&
72 (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
73 }
74 EIGEN_DEVICE_FUNC CwiseNullaryOp(Index size, const NullaryOp& func = NullaryOp())
75 : CwiseNullaryOp(RowsAtCompileTime == 1 ? 1 : size, RowsAtCompileTime == 1 ? size : 1, func) {
76 EIGEN_STATIC_ASSERT(CwiseNullaryOp::IsVectorAtCompileTime, YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX);
77 }
78
79 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const { return m_rows.value(); }
80 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const { return m_cols.value(); }
81
83 EIGEN_DEVICE_FUNC const NullaryOp& functor() const { return m_functor; }
84
85 protected:
86 const internal::variable_if_dynamic<Index, RowsAtCompileTime> m_rows;
87 const internal::variable_if_dynamic<Index, ColsAtCompileTime> m_cols;
88 const NullaryOp m_functor;
89};
90
104template <typename Derived>
105template <typename CustomNullaryOp>
106EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
107#ifndef EIGEN_PARSED_BY_DOXYGEN
108 const CwiseNullaryOp<CustomNullaryOp, typename DenseBase<Derived>::PlainObject>
109#else
110 const CwiseNullaryOp<CustomNullaryOp, PlainObject>
111#endif
112 DenseBase<Derived>::NullaryExpr(Index rows, Index cols, const CustomNullaryOp& func) {
113 return CwiseNullaryOp<CustomNullaryOp, PlainObject>(rows, cols, func);
114}
115
134template <typename Derived>
135template <typename CustomNullaryOp>
136EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
137#ifndef EIGEN_PARSED_BY_DOXYGEN
139#else
141#endif
142 DenseBase<Derived>::NullaryExpr(Index size, const CustomNullaryOp& func) {
143 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
144 if (RowsAtCompileTime == 1)
146 else
148}
149
159template <typename Derived>
160template <typename CustomNullaryOp>
161EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
162#ifndef EIGEN_PARSED_BY_DOXYGEN
164#else
166#endif
170
184template <typename Derived>
185EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
187 return DenseBase<Derived>::NullaryExpr(rows, cols, internal::scalar_constant_op<Scalar>(value));
188}
189
205template <typename Derived>
206EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
208 return DenseBase<Derived>::NullaryExpr(size, internal::scalar_constant_op<Scalar>(value));
209}
210
220template <typename Derived>
221EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
223 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
225 internal::scalar_constant_op<Scalar>(value));
226}
227
237template <typename Derived>
238EIGEN_DEPRECATED EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<
239 Derived>::RandomAccessLinSpacedReturnType
240DenseBase<Derived>::LinSpaced(Sequential_t, Index size, const Scalar& low, const Scalar& high) {
241 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
242 return DenseBase<Derived>::NullaryExpr(size, internal::linspaced_op<Scalar>(low, high, size));
243}
244
247 * \sa LinSpaced(const Scalar&, const Scalar&)
248 */
249template <typename Derived>
250EIGEN_DEPRECATED EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<
251 Derived>::RandomAccessLinSpacedReturnType
252DenseBase<Derived>::LinSpaced(Sequential_t, const Scalar& low, const Scalar& high) {
253 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
254 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
255 return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime,
256 internal::linspaced_op<Scalar>(low, high, Derived::SizeAtCompileTime));
257}
258
259/**
260 * \brief Sets a linearly spaced vector.
262 * The function generates 'size' equally spaced values in the closed interval [low,high].
263 * When size is set to 1, a vector of length 1 containing 'high' is returned.
265 * \only_for_vectors
266 *
267 * Example: \include DenseBase_LinSpaced.cpp
268 * Output: \verbinclude DenseBase_LinSpaced.out
269 *
270 * For integer scalar types, an even spacing is possible if and only if the length of the range,
271 * i.e., \c high-low is a scalar multiple of \c size-1, or if \c size is a scalar multiple of the
272 * number of values \c high-low+1 (meaning each value can be repeated the same number of time).
273 * If one of these two considions is not satisfied, then \c high is lowered to the largest value
274 * satisfying one of this constraint.
275 * Here are some examples:
276 *
277 * Example: \include DenseBase_LinSpacedInt.cpp
278 * Output: \verbinclude DenseBase_LinSpacedInt.out
279 *
280 * \sa setLinSpaced(Index,const Scalar&,const Scalar&), CwiseNullaryOp
281 */
282template <typename Derived>
283EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType
284DenseBase<Derived>::LinSpaced(Index size, const Scalar& low, const Scalar& high) {
285 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
286 return DenseBase<Derived>::NullaryExpr(size, internal::linspaced_op<Scalar>(low, high, size));
287}
288
293template <typename Derived>
294EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType
296 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
297 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
298 return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime,
299 internal::linspaced_op<Scalar>(low, high, Derived::SizeAtCompileTime));
300}
301
302template <typename Derived>
303EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessEqualSpacedReturnType
304DenseBase<Derived>::EqualSpaced(Index size, const Scalar& low, const Scalar& step) {
305 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
306 return DenseBase<Derived>::NullaryExpr(size, internal::equalspaced_op<Scalar>(low, step));
308
309template <typename Derived>
310EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessEqualSpacedReturnType
311DenseBase<Derived>::EqualSpaced(const Scalar& low, const Scalar& step) {
312 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
313 return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, internal::equalspaced_op<Scalar>(low, step));
314}
315
316/** \returns true if all coefficients in this matrix are approximately equal to \a val, to within precision \a prec */
317template <typename Derived>
318EIGEN_DEVICE_FUNC bool DenseBase<Derived>::isApproxToConstant(const Scalar& val, const RealScalar& prec) const {
319 typename internal::nested_eval<Derived, 1>::type self(derived());
320 for (Index j = 0; j < cols(); ++j)
321 for (Index i = 0; i < rows(); ++i)
322 if (!internal::isApprox(self.coeff(i, j), val, prec)) return false;
323 return true;
324}
328 * \returns true if all coefficients in this matrix are approximately equal to \a value, to within precision \a prec */
329template <typename Derived>
330EIGEN_DEVICE_FUNC bool DenseBase<Derived>::isConstant(const Scalar& val, const RealScalar& prec) const {
331 return isApproxToConstant(val, prec);
332}
334/** Alias for setConstant(): sets all coefficients in this expression to \a val.
336 * \sa setConstant(), Constant(), class CwiseNullaryOp
337 */
338template <typename Derived>
339EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void DenseBase<Derived>::fill(const Scalar& val) {
343/** Sets all coefficients in this expression to value \a val.
344 *
345 * \sa fill(), setConstant(Index,const Scalar&), setConstant(Index,Index,const Scalar&), setZero(), setOnes(),
346 * Constant(), class CwiseNullaryOp, setZero(), setOnes()
347 */
348template <typename Derived>
349EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setConstant(const Scalar& val) {
350 internal::eigen_fill_impl<Derived>::run(derived(), val);
351 return derived();
352}
353
359 * Output: \verbinclude Matrix_setConstant_int.out
360 *
361 * \sa MatrixBase::setConstant(const Scalar&), setConstant(Index,Index,const Scalar&), class CwiseNullaryOp,
362 * MatrixBase::Constant(const Scalar&)
363 */
364template <typename Derived>
365EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setConstant(Index size, const Scalar& val) {
366 resize(size);
367 return setConstant(val);
368}
369
382template <typename Derived>
383EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setConstant(Index rows, Index cols,
384 const Scalar& val) {
385 resize(rows, cols);
386 return setConstant(val);
387}
388
396template <typename Derived>
397EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setConstant(NoChange_t, Index cols,
398 const Scalar& val) {
399 return setConstant(rows(), cols, val);
400}
401
409template <typename Derived>
410EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setConstant(Index rows, NoChange_t,
411 const Scalar& val) {
412 return setConstant(rows, cols(), val);
413}
414
431template <typename Derived>
432EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setLinSpaced(Index newSize, const Scalar& low,
433 const Scalar& high) {
434 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
435 return derived() = Derived::NullaryExpr(newSize, internal::linspaced_op<Scalar>(low, high, newSize));
436}
437
451template <typename Derived>
452EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setLinSpaced(const Scalar& low, const Scalar& high) {
453 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
454 return setLinSpaced(size(), low, high);
455}
456
457template <typename Derived>
458EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setEqualSpaced(Index newSize, const Scalar& low,
459 const Scalar& step) {
460 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
461 return derived() = Derived::NullaryExpr(newSize, internal::equalspaced_op<Scalar>(low, step));
462}
463template <typename Derived>
464EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setEqualSpaced(const Scalar& low,
465 const Scalar& step) {
466 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
467 return setEqualSpaced(size(), low, step);
468}
469
470// zero:
471
486template <typename Derived>
487EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ZeroReturnType DenseBase<Derived>::Zero(
488 Index rows, Index cols) {
489 return ZeroReturnType(rows, cols);
490}
491
508template <typename Derived>
509EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ZeroReturnType DenseBase<Derived>::Zero(
510 Index size) {
511 return ZeroReturnType(size);
512}
513
524template <typename Derived>
525EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ZeroReturnType DenseBase<Derived>::Zero() {
526 return ZeroReturnType(RowsAtCompileTime, ColsAtCompileTime);
527}
528
537template <typename Derived>
538EIGEN_DEVICE_FUNC bool DenseBase<Derived>::isZero(const RealScalar& prec) const {
539 typename internal::nested_eval<Derived, 1>::type self(derived());
540 for (Index j = 0; j < cols(); ++j)
541 for (Index i = 0; i < rows(); ++i)
542 if (!internal::isMuchSmallerThan(self.coeff(i, j), static_cast<Scalar>(1), prec)) return false;
543 return true;
544}
545
553template <typename Derived>
554EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setZero() {
555 internal::eigen_zero_impl<Derived>::run(derived());
556 return derived();
557}
558
568template <typename Derived>
569EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setZero(Index newSize) {
570 resize(newSize);
571 return setZero();
572}
573
584template <typename Derived>
585EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setZero(Index rows, Index cols) {
586 resize(rows, cols);
587 return setZero();
588}
589
597template <typename Derived>
598EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setZero(NoChange_t, Index cols) {
599 return setZero(rows(), cols);
600}
601
609template <typename Derived>
610EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setZero(Index rows, NoChange_t) {
611 return setZero(rows, cols());
612}
613
614// ones:
615
630template <typename Derived>
631EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType DenseBase<Derived>::Ones(
632 Index rows, Index cols) {
633 return Constant(rows, cols, Scalar(1));
634}
635
652template <typename Derived>
653EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType DenseBase<Derived>::Ones(
654 Index newSize) {
655 return Constant(newSize, Scalar(1));
657
660 * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you
661 * need to use the variants taking size arguments.
663 * Example: \include MatrixBase_ones.cpp
664 * Output: \verbinclude MatrixBase_ones.out
666 * \sa Ones(Index), Ones(Index,Index), isOnes(), class Ones
667 */
668template <typename Derived>
669EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType DenseBase<Derived>::Ones() {
670 return Constant(Scalar(1));
671}
672
681template <typename Derived>
682EIGEN_DEVICE_FUNC bool DenseBase<Derived>::isOnes(const RealScalar& prec) const {
683 return isApproxToConstant(Scalar(1), prec);
684}
685
693template <typename Derived>
694EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setOnes() {
695 return setConstant(Scalar(1));
696}
697
707template <typename Derived>
708EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setOnes(Index newSize) {
709 resize(newSize);
710 return setConstant(Scalar(1));
711}
712
723template <typename Derived>
724EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setOnes(Index rows, Index cols) {
725 resize(rows, cols);
726 return setConstant(Scalar(1));
727}
728
736template <typename Derived>
737EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setOnes(Index rows, NoChange_t) {
738 return setOnes(rows, cols());
739}
740
748template <typename Derived>
749EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setOnes(NoChange_t, Index cols) {
750 return setOnes(rows(), cols);
751}
752
753// Identity:
754
769template <typename Derived>
770EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::IdentityReturnType
772 return DenseBase<Derived>::NullaryExpr(rows, cols, internal::scalar_identity_op<Scalar>());
773}
774
785template <typename Derived>
786EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::IdentityReturnType
788 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
789 return MatrixBase<Derived>::NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_identity_op<Scalar>());
790}
791
801template <typename Derived>
802bool MatrixBase<Derived>::isIdentity(const RealScalar& prec) const {
803 typename internal::nested_eval<Derived, 1>::type self(derived());
804 for (Index j = 0; j < cols(); ++j) {
805 for (Index i = 0; i < rows(); ++i) {
806 if (i == j) {
807 if (!internal::isApprox(self.coeff(i, j), static_cast<Scalar>(1), prec)) return false;
808 } else {
809 if (!internal::isMuchSmallerThan(self.coeff(i, j), static_cast<RealScalar>(1), prec)) return false;
810 }
811 }
812 }
813 return true;
814}
815
816namespace internal {
817
818template <typename Derived, bool Big = (Derived::SizeAtCompileTime >= 16)>
819struct setIdentity_impl {
820 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Derived& run(Derived& m) {
821 return m = Derived::Identity(m.rows(), m.cols());
822 }
823};
824
825template <typename Derived>
826struct setIdentity_impl<Derived, true> {
827 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Derived& run(Derived& m) {
828 m.setZero();
829 const Index size = numext::mini(m.rows(), m.cols());
830 for (Index i = 0; i < size; ++i) m.coeffRef(i, i) = typename Derived::Scalar(1);
831 return m;
832 }
833};
834
835} // end namespace internal
836
844template <typename Derived>
845EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setIdentity() {
846 return internal::setIdentity_impl<Derived>::run(derived());
847}
848
859template <typename Derived>
860EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setIdentity(Index rows, Index cols) {
861 derived().resize(rows, cols);
862 return setIdentity();
863}
864
871template <typename Derived>
872EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::Unit(
873 Index newSize, Index i) {
874 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
875 return BasisReturnType(SquareMatrixType::Identity(newSize, newSize), i);
876}
877
886template <typename Derived>
887EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::Unit(
888 Index i) {
889 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
890 return BasisReturnType(SquareMatrixType::Identity(), i);
891}
892
900template <typename Derived>
901EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitX() {
902 return Derived::Unit(0);
903}
904
912template <typename Derived>
913EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitY() {
914 return Derived::Unit(1);
915}
916
924template <typename Derived>
925EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitZ() {
926 return Derived::Unit(2);
927}
928
936template <typename Derived>
937EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitW() {
938 return Derived::Unit(3);
939}
940
949template <typename Derived>
950EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setUnit(Index i) {
951 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
952 eigen_assert(i < size());
953 derived().setZero();
954 derived().coeffRef(i) = Scalar(1);
955 return derived();
956}
957
967template <typename Derived>
968EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setUnit(Index newSize, Index i) {
969 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
970 eigen_assert(i < newSize);
971 derived().resize(newSize);
972 return setUnit(i);
973}
974
975} // end namespace Eigen
976
977#endif // EIGEN_CWISE_NULLARY_OP_H
Generic expression of a matrix where all coefficients are defined by a functor.
Definition ForwardDeclarations.h:104
const NullaryOp & functor() const
Definition CwiseNullaryOp.h:83
Base class for all dense matrices, vectors, and arrays.
Definition ForwardDeclarations.h:59
static EIGEN_DEPRECATED const RandomAccessLinSpacedReturnType LinSpaced(Sequential_t, Index size, const Scalar &low, const Scalar &high)
Definition CwiseNullaryOp.h:240
bool isConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:330
Derived & setOnes()
Definition CwiseNullaryOp.h:694
static const ConstantReturnType Ones()
Definition CwiseNullaryOp.h:669
static const CwiseNullaryOp< CustomNullaryOp, PlainObject > NullaryExpr(Index rows, Index cols, const CustomNullaryOp &func)
Definition CwiseNullaryOp.h:112
Derived & setLinSpaced(Index size, const Scalar &low, const Scalar &high)
Sets a linearly spaced vector.
Definition CwiseNullaryOp.h:432
internal::traits< Derived >::Scalar Scalar
Definition DenseBase.h:62
@ ColsAtCompileTime
Definition DenseBase.h:102
@ RowsAtCompileTime
Definition DenseBase.h:96
static const ConstantReturnType Constant(Index rows, Index cols, const Scalar &value)
Definition CwiseNullaryOp.h:186
CoeffReturnType value() const
Definition DenseBase.h:481
void fill(const Scalar &value)
Definition CwiseNullaryOp.h:339
constexpr DenseBase()=default
bool isOnes(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:682
ArrayWrapper< ExpressionType > & setConstant(const Scalar &value)
Definition CwiseNullaryOp.h:349
static const ZeroReturnType Zero()
Definition CwiseNullaryOp.h:525
Derived & setZero()
Definition CwiseNullaryOp.h:554
bool isZero(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:538
bool isApproxToConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:318
Base class for all dense matrices, vectors, and expressions.
Definition ForwardDeclarations.h:73
static const BasisReturnType UnitY()
Definition CwiseNullaryOp.h:913
Derived & setIdentity()
Definition CwiseNullaryOp.h:845
bool isIdentity(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:802
static const BasisReturnType UnitX()
Definition CwiseNullaryOp.h:901
static const IdentityReturnType Identity()
Definition CwiseNullaryOp.h:787
static const BasisReturnType UnitZ()
Definition CwiseNullaryOp.h:925
static const BasisReturnType Unit(Index size, Index i)
Definition CwiseNullaryOp.h:872
Derived & setUnit(Index i)
Set the coefficients of *this to the i-th unit (basis) vector.
Definition CwiseNullaryOp.h:950
static const BasisReturnType UnitW()
Definition CwiseNullaryOp.h:937
Derived & setOnes(Index size)
Definition CwiseNullaryOp.h:708
Derived & setConstant(Index size, const Scalar &val)
Definition CwiseNullaryOp.h:365
Derived & setZero(Index size)
Definition CwiseNullaryOp.h:569
constexpr void resize(Index rows, Index cols)
Definition PlainObjectBase.h:268
const unsigned int RowMajorBit
Definition Constants.h:70
Namespace containing all symbols from the Eigen library.
Definition B01_Experimental.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:82
const int Dynamic
Definition Constants.h:25