Eigen  5.0.1
 
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// SPDX-License-Identifier: MPL-2.0
10
11#ifndef EIGEN_CWISE_NULLARY_OP_H
12#define EIGEN_CWISE_NULLARY_OP_H
13
14// IWYU pragma: private
15#include "./InternalHeaderCheck.h"
16
17namespace Eigen {
18
19namespace internal {
20template <typename NullaryOp, typename PlainObjectType>
21struct traits<CwiseNullaryOp<NullaryOp, PlainObjectType> > : traits<PlainObjectType> {
22 enum { Flags = traits<PlainObjectType>::Flags & RowMajorBit };
23};
24
25} // namespace internal
26
63template <typename NullaryOp, typename PlainObjectType>
64class CwiseNullaryOp : public internal::dense_xpr_base<CwiseNullaryOp<NullaryOp, PlainObjectType> >::type,
65 internal::no_assignment_operator {
66 public:
67 using Base = typename internal::dense_xpr_base<CwiseNullaryOp>::type;
68 EIGEN_DENSE_PUBLIC_INTERFACE(CwiseNullaryOp)
69
70 EIGEN_DEVICE_FUNC constexpr CwiseNullaryOp(Index rows, Index cols, const NullaryOp& func = NullaryOp())
71 : m_rows(rows), m_cols(cols), m_functor(func) {
72 eigen_assert(rows >= 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) && cols >= 0 &&
73 (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
74 }
75 EIGEN_DEVICE_FUNC constexpr CwiseNullaryOp(Index size, const NullaryOp& func = NullaryOp())
76 : CwiseNullaryOp(RowsAtCompileTime == 1 ? 1 : size, RowsAtCompileTime == 1 ? size : 1, func) {
77 EIGEN_STATIC_ASSERT(CwiseNullaryOp::IsVectorAtCompileTime, YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX);
78 }
79
80 EIGEN_DEVICE_FUNC constexpr Index rows() const { return m_rows.value(); }
81 EIGEN_DEVICE_FUNC constexpr Index cols() const { return m_cols.value(); }
82
84 EIGEN_DEVICE_FUNC constexpr const NullaryOp& functor() const { return m_functor; }
85
86 protected:
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;
90};
91
105template <typename Derived>
106template <typename CustomNullaryOp>
107EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
108#ifndef EIGEN_PARSED_BY_DOXYGEN
109 const CwiseNullaryOp<CustomNullaryOp, typename DenseBase<Derived>::PlainObject>
110#else
111 const CwiseNullaryOp<CustomNullaryOp, PlainObject>
112#endif
113 DenseBase<Derived>::NullaryExpr(Index rows, Index cols, const CustomNullaryOp& func) {
114 return CwiseNullaryOp<CustomNullaryOp, PlainObject>(rows, cols, func);
115}
116
135template <typename Derived>
136template <typename CustomNullaryOp>
137EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
138#ifndef EIGEN_PARSED_BY_DOXYGEN
140#else
142#endif
143 DenseBase<Derived>::NullaryExpr(Index size, const CustomNullaryOp& func) {
144 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
145 EIGEN_IF_CONSTEXPR (RowsAtCompileTime == 1) {
147 } else {
149 }
150}
151
161template <typename Derived>
162template <typename CustomNullaryOp>
163EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
164#ifndef EIGEN_PARSED_BY_DOXYGEN
166#else
168#endif
172
184template <typename Derived>
185EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
186DenseBase<Derived>::Constant(Index rows, Index cols, const Scalar& value) {
187 return DenseBase<Derived>::NullaryExpr(rows, cols, internal::scalar_constant_op<Scalar>(value));
188}
189
203template <typename Derived>
204EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
206 return DenseBase<Derived>::NullaryExpr(size, internal::scalar_constant_op<Scalar>(value));
207}
208
216template <typename Derived>
217EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
219 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
221 internal::scalar_constant_op<Scalar>(value));
222}
223
233template <typename Derived>
234EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType
235DenseBase<Derived>::LinSpaced(Sequential_t, Index size, const Scalar& low, const Scalar& high) {
236 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
237 return DenseBase<Derived>::NullaryExpr(size, internal::linspaced_op<Scalar>(low, high, size));
238}
239
244template <typename Derived>
245EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType
246DenseBase<Derived>::LinSpaced(Sequential_t, const Scalar& low, const Scalar& high) {
247 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
248 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
249 return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime,
250 internal::linspaced_op<Scalar>(low, high, Derived::SizeAtCompileTime));
253/**
254 * \brief Sets a linearly spaced vector.
255 *
256 * The function generates 'size' equally spaced values in the closed interval [low,high].
257 * When size is set to 1, a vector of length 1 containing 'high' is returned.
258 *
259 * \only_for_vectors
261 * Example: \include DenseBase_LinSpaced.cpp
262 * Output: \verbinclude DenseBase_LinSpaced.out
263 *
264 * For integer scalar types, an even spacing is possible if and only if the length of the range,
265 * i.e., \c high-low is a scalar multiple of \c size-1, or if \c size is a scalar multiple of the
266 * number of values \c high-low+1 (meaning each value can be repeated the same number of times).
267 * If one of these two conditions is not satisfied, then \c high is lowered to the largest value
268 * satisfying one of this constraint.
269 * Here are some examples:
270 *
271 * Example: \include DenseBase_LinSpacedInt.cpp
272 * Output: \verbinclude DenseBase_LinSpacedInt.out
273 *
274 * \sa setLinSpaced(Index,const Scalar&,const Scalar&), CwiseNullaryOp
275 */
276template <typename Derived>
277EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType
278DenseBase<Derived>::LinSpaced(Index size, const Scalar& low, const Scalar& high) {
279 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
280 return DenseBase<Derived>::NullaryExpr(size, internal::linspaced_op<Scalar>(low, high, size));
281}
282
287template <typename Derived>
288EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType
290 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
291 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
292 return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime,
293 internal::linspaced_op<Scalar>(low, high, Derived::SizeAtCompileTime));
294}
295
296template <typename Derived>
297EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessEqualSpacedReturnType
298DenseBase<Derived>::EqualSpaced(Index size, const Scalar& low, const Scalar& step) {
299 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
300 return DenseBase<Derived>::NullaryExpr(size, internal::equalspaced_op<Scalar>(low, step));
301}
302
303template <typename Derived>
304EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessEqualSpacedReturnType
305DenseBase<Derived>::EqualSpaced(const Scalar& low, const Scalar& step) {
306 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
307 return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, internal::equalspaced_op<Scalar>(low, step));
308}
312 * \returns true if all coefficients in this matrix are approximately equal to \a value, to within precision \a prec */
313template <typename Derived>
314EIGEN_DEVICE_FUNC bool DenseBase<Derived>::isConstant(const Scalar& val, const RealScalar& prec) const {
315 return isApproxToConstant(val, prec);
316}
322template <typename Derived>
323EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void DenseBase<Derived>::fill(const Scalar& val) {
325}
326
327/** Sets all coefficients in this expression to value \a val.
328 *
329 * \sa fill(), setConstant(Index,const Scalar&), setConstant(Index,Index,const Scalar&), setZero(), setOnes(),
330 * Constant(), class CwiseNullaryOp, setZero(), setOnes()
331 */
332template <typename Derived>
333EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setConstant(const Scalar& val) {
334 internal::eigen_fill_impl<Derived>::run(derived(), val);
335 return derived();
340 * \only_for_vectors
342 * Example: \include Matrix_setConstant_int.cpp
343 * Output: \verbinclude Matrix_setConstant_int.out
344 *
345 * \sa MatrixBase::setConstant(const Scalar&), setConstant(Index,Index,const Scalar&), class CwiseNullaryOp,
346 * MatrixBase::Constant(const Scalar&)
347 */
348template <typename Derived>
349EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setConstant(Index size, const Scalar& val) {
350 resize(size);
351 return setConstant(val);
352}
353
360 * Example: \include Matrix_setConstant_int_int.cpp
361 * Output: \verbinclude Matrix_setConstant_int_int.out
362 *
363 * \sa MatrixBase::setConstant(const Scalar&), setConstant(Index,const Scalar&), class CwiseNullaryOp,
364 * MatrixBase::Constant(const Scalar&)
365 */
366template <typename Derived>
367EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setConstant(Index rows, Index cols,
368 const Scalar& val) {
369 resize(rows, cols);
370 return setConstant(val);
371}
372
380template <typename Derived>
381EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setConstant(NoChange_t, Index cols,
382 const Scalar& val) {
383 return setConstant(rows(), cols, val);
384}
385
393template <typename Derived>
394EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setConstant(Index rows, NoChange_t,
395 const Scalar& val) {
396 return setConstant(rows, cols(), val);
397}
398
415template <typename Derived>
416EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setLinSpaced(Index newSize, const Scalar& low,
417 const Scalar& high) {
418 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
419 return derived() = Derived::NullaryExpr(newSize, internal::linspaced_op<Scalar>(low, high, newSize));
420}
421
435template <typename Derived>
436EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setLinSpaced(const Scalar& low, const Scalar& high) {
437 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
438 return setLinSpaced(size(), low, high);
439}
440
441template <typename Derived>
442EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setEqualSpaced(Index newSize, const Scalar& low,
443 const Scalar& step) {
444 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
445 return derived() = Derived::NullaryExpr(newSize, internal::equalspaced_op<Scalar>(low, step));
446}
447template <typename Derived>
448EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setEqualSpaced(const Scalar& low,
449 const Scalar& step) {
450 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
451 return setEqualSpaced(size(), low, step);
452}
453
454// zero:
455
470template <typename Derived>
471EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ZeroReturnType DenseBase<Derived>::Zero(
472 Index rows, Index cols) {
473 return ZeroReturnType(rows, cols);
474}
475
492template <typename Derived>
493EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ZeroReturnType DenseBase<Derived>::Zero(
494 Index size) {
495 return ZeroReturnType(size);
496}
497
508template <typename Derived>
509EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ZeroReturnType DenseBase<Derived>::Zero() {
510 return ZeroReturnType(RowsAtCompileTime, ColsAtCompileTime);
511}
512
520template <typename Derived>
521EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setZero() {
522 internal::eigen_zero_impl<Derived>::run(derived());
523 return derived();
524}
525
535template <typename Derived>
536EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setZero(Index newSize) {
537 resize(newSize);
538 return setZero();
539}
540
551template <typename Derived>
552EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setZero(Index rows, Index cols) {
553 resize(rows, cols);
554 return setZero();
555}
556
564template <typename Derived>
565EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setZero(NoChange_t, Index cols) {
566 return setZero(rows(), cols);
567}
568
576template <typename Derived>
577EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setZero(Index rows, NoChange_t) {
578 return setZero(rows, cols());
579}
580
581// ones:
582
597template <typename Derived>
598EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType DenseBase<Derived>::Ones(
599 Index rows, Index cols) {
600 return Constant(rows, cols, Scalar(1));
601}
602
619template <typename Derived>
620EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType DenseBase<Derived>::Ones(
621 Index newSize) {
622 return Constant(newSize, Scalar(1));
623}
624
635template <typename Derived>
636EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType DenseBase<Derived>::Ones() {
637 return Constant(Scalar(1));
638}
639
648template <typename Derived>
649EIGEN_DEVICE_FUNC bool DenseBase<Derived>::isOnes(const RealScalar& prec) const {
650 return isApproxToConstant(Scalar(1), prec);
651}
652
660template <typename Derived>
661EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setOnes() {
662 return setConstant(Scalar(1));
663}
664
669 * Example: \include Matrix_setOnes_int.cpp
670 * Output: \verbinclude Matrix_setOnes_int.out
672 * \sa MatrixBase::setOnes(), setOnes(Index,Index), class CwiseNullaryOp, MatrixBase::Ones()
673 */
674template <typename Derived>
675EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setOnes(Index newSize) {
676 resize(newSize);
677 return setConstant(Scalar(1));
678}
679
680/** Resizes to the given size, and sets all coefficients in this expression to one.
682 * \param rows the new number of rows
683 * \param cols the new number of columns
684 *
685 * Example: \include Matrix_setOnes_int_int.cpp
686 * Output: \verbinclude Matrix_setOnes_int_int.out
687 *
688 * \sa MatrixBase::setOnes(), setOnes(Index), class CwiseNullaryOp, MatrixBase::Ones()
689 */
690template <typename Derived>
691EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setOnes(Index rows, Index cols) {
692 resize(rows, cols);
693 return setConstant(Scalar(1));
694}
695
703template <typename Derived>
704EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setOnes(Index rows, NoChange_t) {
705 return setOnes(rows, cols());
706}
707
715template <typename Derived>
716EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& PlainObjectBase<Derived>::setOnes(NoChange_t, Index cols) {
717 return setOnes(rows(), cols);
718}
719
720// Identity:
721
736template <typename Derived>
737EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::IdentityReturnType
738MatrixBase<Derived>::Identity(Index rows, Index cols) {
739 return DenseBase<Derived>::NullaryExpr(rows, cols, internal::scalar_identity_op<Scalar>());
740}
741
752template <typename Derived>
753EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::IdentityReturnType
755 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
756 return MatrixBase<Derived>::NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_identity_op<Scalar>());
757}
758
768template <typename Derived>
769bool MatrixBase<Derived>::isIdentity(const RealScalar& prec) const {
770 typename internal::nested_eval<Derived, 1>::type self(derived());
771 for (Index j = 0; j < cols(); ++j) {
772 for (Index i = 0; i < rows(); ++i) {
773 if (i == j) {
774 if (!internal::isApprox(self.coeff(i, j), static_cast<Scalar>(1), prec)) return false;
775 } else {
776 if (!internal::isMuchSmallerThan(self.coeff(i, j), static_cast<RealScalar>(1), prec)) return false;
777 }
778 }
779 }
780 return true;
781}
782
783namespace internal {
784
785template <typename Derived, bool Big = (Derived::SizeAtCompileTime >= 16)>
786struct setIdentity_impl {
787 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Derived& run(Derived& m) {
788 return m = Derived::Identity(m.rows(), m.cols());
789 }
790};
791
792template <typename Derived>
793struct setIdentity_impl<Derived, true> {
794 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Derived& run(Derived& m) {
795 m.setZero();
796 const Index size = numext::mini(m.rows(), m.cols());
797 for (Index i = 0; i < size; ++i) m.coeffRef(i, i) = typename Derived::Scalar(1);
798 return m;
799 }
800};
801
802} // end namespace internal
803
811template <typename Derived>
812EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setIdentity() {
813 return internal::setIdentity_impl<Derived>::run(derived());
814}
815
826template <typename Derived>
827EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setIdentity(Index rows, Index cols) {
828 derived().resize(rows, cols);
829 return setIdentity();
830}
831
838template <typename Derived>
839EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::Unit(
840 Index newSize, Index i) {
841 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
842 return BasisReturnType(SquareMatrixType::Identity(newSize, newSize), i);
843}
844
853template <typename Derived>
854EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::Unit(
855 Index i) {
856 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
857 return BasisReturnType(SquareMatrixType::Identity(), i);
858}
859
867template <typename Derived>
868EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitX() {
869 return Derived::Unit(0);
870}
871
879template <typename Derived>
880EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitY() {
881 return Derived::Unit(1);
882}
883
891template <typename Derived>
892EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitZ() {
893 return Derived::Unit(2);
894}
895
903template <typename Derived>
904EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename MatrixBase<Derived>::BasisReturnType MatrixBase<Derived>::UnitW() {
905 return Derived::Unit(3);
906}
907
916template <typename Derived>
917EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setUnit(Index i) {
918 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
919 eigen_assert(i < size());
920 derived().setZero();
921 derived().coeffRef(i) = Scalar(1);
922 return derived();
923}
924
934template <typename Derived>
935EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setUnit(Index newSize, Index i) {
936 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
937 eigen_assert(i < newSize);
938 derived().resize(newSize);
939 return setUnit(i);
940}
941
942} // end namespace Eigen
943
944#endif // EIGEN_CWISE_NULLARY_OP_H
Generic expression of a matrix where all coefficients are defined by a functor.
Definition CwiseNullaryOp.h:65
constexpr const NullaryOp & functor() const
Definition CwiseNullaryOp.h:84
Base class for all dense matrices, vectors, and arrays.
Definition DenseBase.h:45
bool isConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:314
Derived & setOnes()
Definition CwiseNullaryOp.h:661
static const ConstantReturnType Ones()
Definition CwiseNullaryOp.h:636
static const CwiseNullaryOp< CustomNullaryOp, PlainObject > NullaryExpr(Index rows, Index cols, const CustomNullaryOp &func)
Definition CwiseNullaryOp.h:113
Derived & setLinSpaced(Index size, const Scalar &low, const Scalar &high)
Sets a linearly spaced vector.
Definition CwiseNullaryOp.h:416
static const ConstantReturnType Constant(Index rows, Index cols, const Scalar &value)
Definition CwiseNullaryOp.h:186
CoeffReturnType value() const
Definition DenseBase.h:450
@ SizeAtCompileTime
Definition DenseBase.h:109
@ ColsAtCompileTime
Definition DenseBase.h:103
@ RowsAtCompileTime
Definition DenseBase.h:97
void fill(const Scalar &value)
Definition CwiseNullaryOp.h:323
constexpr DenseBase()=default
bool isOnes(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:649
typename internal::traits< Derived >::Scalar Scalar
Definition DenseBase.h:63
ArrayWrapper< ExpressionType > & setConstant(const Scalar &value)
Definition CwiseNullaryOp.h:333
static const ZeroReturnType Zero()
Definition CwiseNullaryOp.h:509
static const RandomAccessLinSpacedReturnType LinSpaced(Sequential_t, Index size, const Scalar &low, const Scalar &high)
Definition CwiseNullaryOp.h:235
Derived & setZero()
Definition CwiseNullaryOp.h:521
bool isApproxToConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition Visitor.h:696
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:53
static const BasisReturnType UnitY()
Definition CwiseNullaryOp.h:880
Derived & setIdentity()
Definition CwiseNullaryOp.h:812
bool isIdentity(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:769
static const BasisReturnType UnitX()
Definition CwiseNullaryOp.h:868
static const IdentityReturnType Identity()
Definition CwiseNullaryOp.h:754
static const BasisReturnType UnitZ()
Definition CwiseNullaryOp.h:892
static const BasisReturnType Unit(Index size, Index i)
Definition CwiseNullaryOp.h:839
Derived & setUnit(Index i)
Set the coefficients of *this to the i-th unit (basis) vector.
Definition CwiseNullaryOp.h:917
static const BasisReturnType UnitW()
Definition CwiseNullaryOp.h:904
Derived & setOnes(Index size)
Definition CwiseNullaryOp.h:675
Derived & setConstant(Index size, const Scalar &val)
Definition CwiseNullaryOp.h:349
Derived & setZero(Index size)
Definition CwiseNullaryOp.h:536
constexpr void resize(Index rows, Index cols)
Definition PlainObjectBase.h:282
constexpr unsigned int RowMajorBit
Definition Constants.h:71