Eigen  5.0.1-dev+60122df6
 
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 constexpr Index rows() const { return m_rows.value(); }
80 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE 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_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType
239DenseBase<Derived>::LinSpaced(Sequential_t, Index size, const Scalar& low, const Scalar& high) {
240 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
241 return DenseBase<Derived>::NullaryExpr(size, internal::linspaced_op<Scalar>(low, high, size));
242}
243
246 * \sa LinSpaced(const Scalar&, const Scalar&)
247 */
248template <typename Derived>
249EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType
250DenseBase<Derived>::LinSpaced(Sequential_t, const Scalar& low, const Scalar& high) {
251 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
252 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
253 return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime,
254 internal::linspaced_op<Scalar>(low, high, Derived::SizeAtCompileTime));
255}
256
260 * The function generates 'size' equally spaced values in the closed interval [low,high].
261 * When size is set to 1, a vector of length 1 containing 'high' is returned.
263 * \only_for_vectors
265 * Example: \include DenseBase_LinSpaced.cpp
266 * Output: \verbinclude DenseBase_LinSpaced.out
267 *
268 * For integer scalar types, an even spacing is possible if and only if the length of the range,
269 * i.e., \c high-low is a scalar multiple of \c size-1, or if \c size is a scalar multiple of the
270 * number of values \c high-low+1 (meaning each value can be repeated the same number of time).
271 * If one of these two considions is not satisfied, then \c high is lowered to the largest value
272 * satisfying one of this constraint.
273 * Here are some examples:
274 *
275 * Example: \include DenseBase_LinSpacedInt.cpp
276 * Output: \verbinclude DenseBase_LinSpacedInt.out
277 *
278 * \sa setLinSpaced(Index,const Scalar&,const Scalar&), CwiseNullaryOp
279 */
280template <typename Derived>
281EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType
282DenseBase<Derived>::LinSpaced(Index size, const Scalar& low, const Scalar& high) {
283 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
284 return DenseBase<Derived>::NullaryExpr(size, internal::linspaced_op<Scalar>(low, high, size));
285}
286
291template <typename Derived>
292EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType
294 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
295 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
296 return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime,
297 internal::linspaced_op<Scalar>(low, high, Derived::SizeAtCompileTime));
298}
299
300template <typename Derived>
301EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessEqualSpacedReturnType
302DenseBase<Derived>::EqualSpaced(Index size, const Scalar& low, const Scalar& step) {
303 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
304 return DenseBase<Derived>::NullaryExpr(size, internal::equalspaced_op<Scalar>(low, step));
307template <typename Derived>
308EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessEqualSpacedReturnType
309DenseBase<Derived>::EqualSpaced(const Scalar& low, const Scalar& step) {
310 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
311 return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, internal::equalspaced_op<Scalar>(low, step));
312}
315template <typename Derived>
316EIGEN_DEVICE_FUNC bool DenseBase<Derived>::isApproxToConstant(const Scalar& val, const RealScalar& prec) const {
317 typename internal::nested_eval<Derived, 1>::type self(derived());
318 for (Index j = 0; j < cols(); ++j)
319 for (Index i = 0; i < rows(); ++i)
320 if (!internal::isApprox(self.coeff(i, j), val, prec)) return false;
321 return true;
322}
323
326 * \returns true if all coefficients in this matrix are approximately equal to \a value, to within precision \a prec */
327template <typename Derived>
328EIGEN_DEVICE_FUNC bool DenseBase<Derived>::isConstant(const Scalar& val, const RealScalar& prec) const {
329 return isApproxToConstant(val, prec);
330}
334 * \sa setConstant(), Constant(), class CwiseNullaryOp
335 */
336template <typename Derived>
337EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void DenseBase<Derived>::fill(const Scalar& val) {
339}
341/** Sets all coefficients in this expression to value \a val.
343 * \sa fill(), setConstant(Index,const Scalar&), setConstant(Index,Index,const Scalar&), setZero(), setOnes(),
344 * Constant(), class CwiseNullaryOp, setZero(), setOnes()
345 */
346template <typename Derived>
347EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setConstant(const Scalar& val) {
348 internal::eigen_fill_impl<Derived>::run(derived(), val);
349 return derived();
350}
351
359 * \sa MatrixBase::setConstant(const Scalar&), setConstant(Index,Index,const Scalar&), class CwiseNullaryOp,
360 * MatrixBase::Constant(const Scalar&)
361 */
362template <typename Derived>
363EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setConstant(Index size, const Scalar& val) {
364 resize(size);
365 return setConstant(val);
366}
367
380template <typename Derived>
381EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setConstant(Index rows, Index cols,
382 const Scalar& val) {
383 resize(rows, cols);
384 return setConstant(val);
385}
386
394template <typename Derived>
395EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setConstant(NoChange_t, Index cols,
396 const Scalar& val) {
397 return setConstant(rows(), cols, val);
398}
399
407template <typename Derived>
408EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setConstant(Index rows, NoChange_t,
409 const Scalar& val) {
410 return setConstant(rows, cols(), val);
411}
412
429template <typename Derived>
430EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setLinSpaced(Index newSize, const Scalar& low,
431 const Scalar& high) {
432 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
433 return derived() = Derived::NullaryExpr(newSize, internal::linspaced_op<Scalar>(low, high, newSize));
434}
435
449template <typename Derived>
450EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setLinSpaced(const Scalar& low, const Scalar& high) {
451 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
452 return setLinSpaced(size(), low, high);
453}
454
455template <typename Derived>
456EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setEqualSpaced(Index newSize, const Scalar& low,
457 const Scalar& step) {
458 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
459 return derived() = Derived::NullaryExpr(newSize, internal::equalspaced_op<Scalar>(low, step));
460}
461template <typename Derived>
462EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setEqualSpaced(const Scalar& low,
463 const Scalar& step) {
464 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
465 return setEqualSpaced(size(), low, step);
466}
467
468// zero:
469
484template <typename Derived>
485EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ZeroReturnType DenseBase<Derived>::Zero(
486 Index rows, Index cols) {
487 return ZeroReturnType(rows, cols);
488}
489
506template <typename Derived>
507EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ZeroReturnType DenseBase<Derived>::Zero(
508 Index size) {
509 return ZeroReturnType(size);
510}
511
522template <typename Derived>
523EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ZeroReturnType DenseBase<Derived>::Zero() {
524 return ZeroReturnType(RowsAtCompileTime, ColsAtCompileTime);
525}
526
535template <typename Derived>
536EIGEN_DEVICE_FUNC bool DenseBase<Derived>::isZero(const RealScalar& prec) const {
537 typename internal::nested_eval<Derived, 1>::type self(derived());
538 for (Index j = 0; j < cols(); ++j)
539 for (Index i = 0; i < rows(); ++i)
540 if (!internal::isMuchSmallerThan(self.coeff(i, j), static_cast<Scalar>(1), prec)) return false;
541 return true;
542}
543
551template <typename Derived>
552EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setZero() {
553 internal::eigen_zero_impl<Derived>::run(derived());
554 return derived();
555}
556
566template <typename Derived>
567EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setZero(Index newSize) {
568 resize(newSize);
569 return setZero();
570}
571
582template <typename Derived>
583EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setZero(Index rows, Index cols) {
584 resize(rows, cols);
585 return setZero();
586}
587
595template <typename Derived>
596EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setZero(NoChange_t, Index cols) {
597 return setZero(rows(), cols);
598}
599
607template <typename Derived>
608EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setZero(Index rows, NoChange_t) {
609 return setZero(rows, cols());
610}
611
612// ones:
613
628template <typename Derived>
629EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType DenseBase<Derived>::Ones(
630 Index rows, Index cols) {
631 return Constant(rows, cols, Scalar(1));
632}
633
650template <typename Derived>
651EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType DenseBase<Derived>::Ones(
652 Index newSize) {
653 return Constant(newSize, Scalar(1));
656/** \returns an expression of a fixed-size matrix or vector where all coefficients equal one.
657 *
658 * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you
659 * need to use the variants taking size arguments.
661 * Example: \include MatrixBase_ones.cpp
662 * Output: \verbinclude MatrixBase_ones.out
663 *
664 * \sa Ones(Index), Ones(Index,Index), isOnes(), class Ones
665 */
666template <typename Derived>
667EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType DenseBase<Derived>::Ones() {
668 return Constant(Scalar(1));
669}
670
679template <typename Derived>
680EIGEN_DEVICE_FUNC bool DenseBase<Derived>::isOnes(const RealScalar& prec) const {
681 return isApproxToConstant(Scalar(1), prec);
682}
683
691template <typename Derived>
692EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setOnes() {
693 return setConstant(Scalar(1));
694}
695
705template <typename Derived>
706EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setOnes(Index newSize) {
707 resize(newSize);
708 return setConstant(Scalar(1));
709}
710
721template <typename Derived>
722EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setOnes(Index rows, Index cols) {
723 resize(rows, cols);
724 return setConstant(Scalar(1));
725}
726
734template <typename Derived>
735EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setOnes(Index rows, NoChange_t) {
736 return setOnes(rows, cols());
737}
738
746template <typename Derived>
747EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setOnes(NoChange_t, Index cols) {
748 return setOnes(rows(), cols);
749}
750
751// Identity:
752
767template <typename Derived>
768EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::IdentityReturnType
770 return DenseBase<Derived>::NullaryExpr(rows, cols, internal::scalar_identity_op<Scalar>());
771}
772
783template <typename Derived>
784EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::IdentityReturnType
786 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
787 return MatrixBase<Derived>::NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_identity_op<Scalar>());
788}
789
799template <typename Derived>
800bool MatrixBase<Derived>::isIdentity(const RealScalar& prec) const {
801 typename internal::nested_eval<Derived, 1>::type self(derived());
802 for (Index j = 0; j < cols(); ++j) {
803 for (Index i = 0; i < rows(); ++i) {
804 if (i == j) {
805 if (!internal::isApprox(self.coeff(i, j), static_cast<Scalar>(1), prec)) return false;
806 } else {
807 if (!internal::isMuchSmallerThan(self.coeff(i, j), static_cast<RealScalar>(1), prec)) return false;
808 }
809 }
810 }
811 return true;
812}
813
814namespace internal {
815
816template <typename Derived, bool Big = (Derived::SizeAtCompileTime >= 16)>
817struct setIdentity_impl {
818 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Derived& run(Derived& m) {
819 return m = Derived::Identity(m.rows(), m.cols());
820 }
821};
822
823template <typename Derived>
824struct setIdentity_impl<Derived, true> {
825 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Derived& run(Derived& m) {
826 m.setZero();
827 const Index size = numext::mini(m.rows(), m.cols());
828 for (Index i = 0; i < size; ++i) m.coeffRef(i, i) = typename Derived::Scalar(1);
829 return m;
830 }
831};
832
833} // end namespace internal
834
842template <typename Derived>
843EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setIdentity() {
844 return internal::setIdentity_impl<Derived>::run(derived());
845}
846
857template <typename Derived>
858EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setIdentity(Index rows, Index cols) {
859 derived().resize(rows, cols);
860 return setIdentity();
861}
862
869template <typename Derived>
870EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::Unit(
871 Index newSize, Index i) {
872 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
873 return BasisReturnType(SquareMatrixType::Identity(newSize, newSize), i);
874}
875
884template <typename Derived>
885EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::Unit(
886 Index i) {
887 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
888 return BasisReturnType(SquareMatrixType::Identity(), i);
889}
890
898template <typename Derived>
899EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitX() {
900 return Derived::Unit(0);
901}
902
910template <typename Derived>
911EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitY() {
912 return Derived::Unit(1);
913}
914
922template <typename Derived>
923EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitZ() {
924 return Derived::Unit(2);
925}
926
934template <typename Derived>
935EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitW() {
936 return Derived::Unit(3);
937}
938
947template <typename Derived>
948EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setUnit(Index i) {
949 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
950 eigen_assert(i < size());
951 derived().setZero();
952 derived().coeffRef(i) = Scalar(1);
953 return derived();
954}
955
965template <typename Derived>
966EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setUnit(Index newSize, Index i) {
967 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
968 eigen_assert(i < newSize);
969 derived().resize(newSize);
970 return setUnit(i);
971}
972
973} // end namespace Eigen
974
975#endif // EIGEN_CWISE_NULLARY_OP_H
Generic expression of a matrix where all coefficients are defined by a functor.
Definition CwiseNullaryOp.h:64
const NullaryOp & functor() const
Definition CwiseNullaryOp.h:83
Base class for all dense matrices, vectors, and arrays.
Definition DenseBase.h:44
bool isConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:328
Derived & setOnes()
Definition CwiseNullaryOp.h:692
static const ConstantReturnType Ones()
Definition CwiseNullaryOp.h:667
void resize(Index newSize)
Definition DenseBase.h:228
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:430
internal::traits< Derived >::Scalar Scalar
Definition DenseBase.h:62
static const ConstantReturnType Constant(Index rows, Index cols, const Scalar &value)
Definition CwiseNullaryOp.h:186
CoeffReturnType value() const
Definition DenseBase.h:486
@ SizeAtCompileTime
Definition DenseBase.h:108
@ ColsAtCompileTime
Definition DenseBase.h:102
@ RowsAtCompileTime
Definition DenseBase.h:96
void fill(const Scalar &value)
Definition CwiseNullaryOp.h:337
constexpr DenseBase()=default
bool isOnes(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:680
ArrayWrapper< ExpressionType > & setConstant(const Scalar &value)
Definition CwiseNullaryOp.h:347
static const ZeroReturnType Zero()
Definition CwiseNullaryOp.h:523
static const RandomAccessLinSpacedReturnType LinSpaced(Sequential_t, Index size, const Scalar &low, const Scalar &high)
Definition CwiseNullaryOp.h:239
Derived & setZero()
Definition CwiseNullaryOp.h:552
bool isZero(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:536
bool isApproxToConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:316
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:52
static const BasisReturnType UnitY()
Definition CwiseNullaryOp.h:911
Derived & setIdentity()
Definition CwiseNullaryOp.h:843
bool isIdentity(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:800
static const BasisReturnType UnitX()
Definition CwiseNullaryOp.h:899
static const IdentityReturnType Identity()
Definition CwiseNullaryOp.h:785
static const BasisReturnType UnitZ()
Definition CwiseNullaryOp.h:923
static const BasisReturnType Unit(Index size, Index i)
Definition CwiseNullaryOp.h:870
Derived & setUnit(Index i)
Set the coefficients of *this to the i-th unit (basis) vector.
Definition CwiseNullaryOp.h:948
static const BasisReturnType UnitW()
Definition CwiseNullaryOp.h:935
Derived & setOnes(Index size)
Definition CwiseNullaryOp.h:706
Derived & setConstant(Index size, const Scalar &val)
Definition CwiseNullaryOp.h:363
Derived & setZero(Index size)
Definition CwiseNullaryOp.h:567
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