1c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This file is part of Eigen, a lightweight C++ template library
2c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// for linear algebra.
3c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath//
4c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
5c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath//
6c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// This Source Code Form is subject to the terms of the Mozilla
7c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Public License v. 2.0. If a copy of the MPL was not distributed
8c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
10c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath#ifndef EIGEN_CWISE_NULLARY_OP_H
11c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath#define EIGEN_CWISE_NULLARY_OP_H
12c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
13c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathnamespace Eigen {
14c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
15c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \class CwiseNullaryOp
16c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \ingroup Core_Module
17c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
18c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \brief Generic expression of a matrix where all coefficients are defined by a functor
19c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
20c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param NullaryOp template functor implementing the operator
21c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \param PlainObjectType the underlying plain matrix/array type
22c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
23c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * This class represents an expression of a generic nullary operator.
24c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * It is the return type of the Ones(), Zero(), Constant(), Identity() and Random() methods,
25c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * and most of the time this is the only way it is used.
26c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
27c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * However, if you want to write a function returning such an expression, you
28c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * will need to use this class.
29c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
30c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class CwiseUnaryOp, class CwiseBinaryOp, DenseBase::NullaryExpr()
31c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
32c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
33c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathnamespace internal {
34c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename NullaryOp, typename PlainObjectType>
35c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathstruct traits<CwiseNullaryOp<NullaryOp, PlainObjectType> > : traits<PlainObjectType>
36c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
37c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  enum {
38c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    Flags = (traits<PlainObjectType>::Flags
39c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      & (  HereditaryBits
40c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath         | (functor_has_linear_access<NullaryOp>::ret ? LinearAccessBit : 0)
41c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath         | (functor_traits<NullaryOp>::PacketAccess ? PacketAccessBit : 0)))
42c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      | (functor_traits<NullaryOp>::IsRepeatable ? 0 : EvalBeforeNestingBit),
43c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    CoeffReadCost = functor_traits<NullaryOp>::Cost
44c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  };
45c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath};
46c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
47c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
48c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename NullaryOp, typename PlainObjectType>
49c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathclass CwiseNullaryOp : internal::no_assignment_operator,
50c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  public internal::dense_xpr_base< CwiseNullaryOp<NullaryOp, PlainObjectType> >::type
51c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
52c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  public:
53c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
54c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    typedef typename internal::dense_xpr_base<CwiseNullaryOp>::type Base;
55c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    EIGEN_DENSE_PUBLIC_INTERFACE(CwiseNullaryOp)
56c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
577faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez    CwiseNullaryOp(Index nbRows, Index nbCols, const NullaryOp& func = NullaryOp())
587faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez      : m_rows(nbRows), m_cols(nbCols), m_functor(func)
59c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    {
607faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez      eigen_assert(nbRows >= 0
617faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez            && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == nbRows)
627faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez            &&  nbCols >= 0
637faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez            && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == nbCols));
64c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    }
65c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
66c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    EIGEN_STRONG_INLINE Index rows() const { return m_rows.value(); }
67c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    EIGEN_STRONG_INLINE Index cols() const { return m_cols.value(); }
68c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
697faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez    EIGEN_STRONG_INLINE const Scalar coeff(Index rowId, Index colId) const
70c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    {
717faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez      return m_functor(rowId, colId);
72c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    }
73c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
74c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    template<int LoadMode>
757faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez    EIGEN_STRONG_INLINE PacketScalar packet(Index rowId, Index colId) const
76c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    {
777faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez      return m_functor.packetOp(rowId, colId);
78c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    }
79c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
80c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    EIGEN_STRONG_INLINE const Scalar coeff(Index index) const
81c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    {
82c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      return m_functor(index);
83c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    }
84c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
85c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    template<int LoadMode>
86c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    EIGEN_STRONG_INLINE PacketScalar packet(Index index) const
87c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    {
88c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      return m_functor.packetOp(index);
89c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    }
90c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
91c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    /** \returns the functor representing the nullary operation */
92c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    const NullaryOp& functor() const { return m_functor; }
93c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
94c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  protected:
95c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    const internal::variable_if_dynamic<Index, RowsAtCompileTime> m_rows;
96c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    const internal::variable_if_dynamic<Index, ColsAtCompileTime> m_cols;
97c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    const NullaryOp m_functor;
98c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath};
99c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
100c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
101c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of a matrix defined by a custom functor \a func
102c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
103c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The parameters \a rows and \a cols are the number of rows and of columns of
104c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * the returned matrix. Must be compatible with this MatrixBase type.
105c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
106c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
107c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * it is redundant to pass \a rows and \a cols as arguments, so Zero() should be used
108c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * instead.
109c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
110c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The template parameter \a CustomNullaryOp is the type of the functor.
111c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
112c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class CwiseNullaryOp
113c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
114c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
115c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename CustomNullaryOp>
116c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, Derived>
117c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathDenseBase<Derived>::NullaryExpr(Index rows, Index cols, const CustomNullaryOp& func)
118c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
119c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return CwiseNullaryOp<CustomNullaryOp, Derived>(rows, cols, func);
120c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
121c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
122c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of a matrix defined by a custom functor \a func
123c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
124c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The parameter \a size is the size of the returned vector.
125c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Must be compatible with this MatrixBase type.
126c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
127c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \only_for_vectors
128c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
129c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * This variant is meant to be used for dynamic-size vector types. For fixed-size types,
130c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * it is redundant to pass \a size as argument, so Zero() should be used
131c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * instead.
132c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
133c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The template parameter \a CustomNullaryOp is the type of the functor.
134c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
135c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class CwiseNullaryOp
136c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
137c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
138c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename CustomNullaryOp>
139c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, Derived>
140c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathDenseBase<Derived>::NullaryExpr(Index size, const CustomNullaryOp& func)
141c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
142c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
143c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  if(RowsAtCompileTime == 1) return CwiseNullaryOp<CustomNullaryOp, Derived>(1, size, func);
144c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  else return CwiseNullaryOp<CustomNullaryOp, Derived>(size, 1, func);
145c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
146c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
147c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of a matrix defined by a custom functor \a func
148c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
149c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * This variant is only for fixed-size DenseBase types. For dynamic-size types, you
150c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * need to use the variants taking size arguments.
151c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
152c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The template parameter \a CustomNullaryOp is the type of the functor.
153c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
154c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class CwiseNullaryOp
155c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
156c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
157c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename CustomNullaryOp>
158c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const CwiseNullaryOp<CustomNullaryOp, Derived>
159c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathDenseBase<Derived>::NullaryExpr(const CustomNullaryOp& func)
160c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
161c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return CwiseNullaryOp<CustomNullaryOp, Derived>(RowsAtCompileTime, ColsAtCompileTime, func);
162c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
163c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
164c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of a constant matrix of value \a value
165c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
1667faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * The parameters \a nbRows and \a nbCols are the number of rows and of columns of
167c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * the returned matrix. Must be compatible with this DenseBase type.
168c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
169c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
1707faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * it is redundant to pass \a nbRows and \a nbCols as arguments, so Zero() should be used
171c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * instead.
172c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
173c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The template parameter \a CustomNullaryOp is the type of the functor.
174c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
175c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class CwiseNullaryOp
176c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
177c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
178c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
1797faaa9f3f0df9d23790277834d426c3d992ac3baCarlos HernandezDenseBase<Derived>::Constant(Index nbRows, Index nbCols, const Scalar& value)
180c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
1817faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return DenseBase<Derived>::NullaryExpr(nbRows, nbCols, internal::scalar_constant_op<Scalar>(value));
182c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
183c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
184c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of a constant matrix of value \a value
185c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
186c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The parameter \a size is the size of the returned vector.
187c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Must be compatible with this DenseBase type.
188c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
189c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \only_for_vectors
190c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
191c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * This variant is meant to be used for dynamic-size vector types. For fixed-size types,
192c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * it is redundant to pass \a size as argument, so Zero() should be used
193c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * instead.
194c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
195c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The template parameter \a CustomNullaryOp is the type of the functor.
196c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
197c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class CwiseNullaryOp
198c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
199c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
200c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
201c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathDenseBase<Derived>::Constant(Index size, const Scalar& value)
202c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
203c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return DenseBase<Derived>::NullaryExpr(size, internal::scalar_constant_op<Scalar>(value));
204c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
205c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
206c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of a constant matrix of value \a value
207c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
208c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * This variant is only for fixed-size DenseBase types. For dynamic-size types, you
209c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * need to use the variants taking size arguments.
210c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
211c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The template parameter \a CustomNullaryOp is the type of the functor.
212c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
213c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class CwiseNullaryOp
214c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
215c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
216c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
217c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathDenseBase<Derived>::Constant(const Scalar& value)
218c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
219c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
220c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return DenseBase<Derived>::NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_constant_op<Scalar>(value));
221c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
222c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
223c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/**
224c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \brief Sets a linearly space vector.
225c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
226c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The function generates 'size' equally spaced values in the closed interval [low,high].
227c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * This particular version of LinSpaced() uses sequential access, i.e. vector access is
228c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * assumed to be a(0), a(1), ..., a(size). This assumption allows for better vectorization
229c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * and yields faster code than the random access version.
230c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
231c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * When size is set to 1, a vector of length 1 containing 'high' is returned.
232c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
233c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \only_for_vectors
234c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
235c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include DenseBase_LinSpaced_seq.cpp
236c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude DenseBase_LinSpaced_seq.out
237c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
238c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa setLinSpaced(Index,const Scalar&,const Scalar&), LinSpaced(Index,Scalar,Scalar), CwiseNullaryOp
239c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
240c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
241c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const typename DenseBase<Derived>::SequentialLinSpacedReturnType
242c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathDenseBase<Derived>::LinSpaced(Sequential_t, Index size, const Scalar& low, const Scalar& high)
243c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
244c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
245c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return DenseBase<Derived>::NullaryExpr(size, internal::linspaced_op<Scalar,false>(low,high,size));
246c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
247c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
248c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/**
249c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \copydoc DenseBase::LinSpaced(Sequential_t, Index, const Scalar&, const Scalar&)
250c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Special version for fixed size types which does not require the size parameter.
251c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
252c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
253c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const typename DenseBase<Derived>::SequentialLinSpacedReturnType
254c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathDenseBase<Derived>::LinSpaced(Sequential_t, const Scalar& low, const Scalar& high)
255c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
256c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
257c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
258c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, internal::linspaced_op<Scalar,false>(low,high,Derived::SizeAtCompileTime));
259c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
260c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
261c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/**
262c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \brief Sets a linearly space vector.
263c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
264c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The function generates 'size' equally spaced values in the closed interval [low,high].
265c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * When size is set to 1, a vector of length 1 containing 'high' is returned.
266c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
267c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \only_for_vectors
268c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
269c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include DenseBase_LinSpaced.cpp
270c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude DenseBase_LinSpaced.out
271c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
272c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa setLinSpaced(Index,const Scalar&,const Scalar&), LinSpaced(Sequential_t,Index,const Scalar&,const Scalar&,Index), CwiseNullaryOp
273c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
274c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
275c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType
276c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathDenseBase<Derived>::LinSpaced(Index size, const Scalar& low, const Scalar& high)
277c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
278c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
279c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return DenseBase<Derived>::NullaryExpr(size, internal::linspaced_op<Scalar,true>(low,high,size));
280c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
281c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
282c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/**
283c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \copydoc DenseBase::LinSpaced(Index, const Scalar&, const Scalar&)
284c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Special version for fixed size types which does not require the size parameter.
285c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
286c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
287c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const typename DenseBase<Derived>::RandomAccessLinSpacedReturnType
288c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathDenseBase<Derived>::LinSpaced(const Scalar& low, const Scalar& high)
289c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
290c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
291c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
292c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, internal::linspaced_op<Scalar,true>(low,high,Derived::SizeAtCompileTime));
293c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
294c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
2957faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** \returns true if all coefficients in this matrix are approximately equal to \a val, to within precision \a prec */
296c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
297c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathbool DenseBase<Derived>::isApproxToConstant
2987faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez(const Scalar& val, const RealScalar& prec) const
299c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
300c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  for(Index j = 0; j < cols(); ++j)
301c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    for(Index i = 0; i < rows(); ++i)
3027faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez      if(!internal::isApprox(this->coeff(i, j), val, prec))
303c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath        return false;
304c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return true;
305c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
306c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
307c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** This is just an alias for isApproxToConstant().
308c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
309c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \returns true if all coefficients in this matrix are approximately equal to \a value, to within precision \a prec */
310c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
311c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathbool DenseBase<Derived>::isConstant
3127faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez(const Scalar& val, const RealScalar& prec) const
313c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
3147faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return isApproxToConstant(val, prec);
315c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
316c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
3177faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** Alias for setConstant(): sets all coefficients in this expression to \a val.
318c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
319c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa setConstant(), Constant(), class CwiseNullaryOp
320c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
321c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
3227faaa9f3f0df9d23790277834d426c3d992ac3baCarlos HernandezEIGEN_STRONG_INLINE void DenseBase<Derived>::fill(const Scalar& val)
323c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
3247faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  setConstant(val);
325c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
326c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
327c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** Sets all coefficients in this expression to \a value.
328c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
329c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa fill(), setConstant(Index,const Scalar&), setConstant(Index,Index,const Scalar&), setZero(), setOnes(), Constant(), class CwiseNullaryOp, setZero(), setOnes()
330c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
331c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
3327faaa9f3f0df9d23790277834d426c3d992ac3baCarlos HernandezEIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setConstant(const Scalar& val)
333c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
3347faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return derived() = Constant(rows(), cols(), val);
335c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
336c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
337c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** Resizes to the given \a size, and sets all coefficients in this expression to the given \a value.
338c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
339c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \only_for_vectors
340c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
341c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include Matrix_setConstant_int.cpp
342c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude Matrix_setConstant_int.out
343c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
344c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa MatrixBase::setConstant(const Scalar&), setConstant(Index,Index,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&)
345c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
346c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
347c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE Derived&
3487faaa9f3f0df9d23790277834d426c3d992ac3baCarlos HernandezPlainObjectBase<Derived>::setConstant(Index size, const Scalar& val)
349c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
350c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  resize(size);
3517faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return setConstant(val);
352c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
353c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
354c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** Resizes to the given size, and sets all coefficients in this expression to the given \a value.
355c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
3567faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param nbRows the new number of rows
3577faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param nbCols the new number of columns
3587faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param val the value to which all coefficients are set
359c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
360c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include Matrix_setConstant_int_int.cpp
361c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude Matrix_setConstant_int_int.out
362c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
363c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa MatrixBase::setConstant(const Scalar&), setConstant(Index,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&)
364c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
365c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
366c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE Derived&
3677faaa9f3f0df9d23790277834d426c3d992ac3baCarlos HernandezPlainObjectBase<Derived>::setConstant(Index nbRows, Index nbCols, const Scalar& val)
368c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
3697faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  resize(nbRows, nbCols);
3707faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return setConstant(val);
371c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
372c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
373c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/**
374c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \brief Sets a linearly space vector.
375c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
376c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The function generates 'size' equally spaced values in the closed interval [low,high].
377c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * When size is set to 1, a vector of length 1 containing 'high' is returned.
378c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
379c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \only_for_vectors
380c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
381c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include DenseBase_setLinSpaced.cpp
382c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude DenseBase_setLinSpaced.out
383c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
384c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa CwiseNullaryOp
385c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
386c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
3877faaa9f3f0df9d23790277834d426c3d992ac3baCarlos HernandezEIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setLinSpaced(Index newSize, const Scalar& low, const Scalar& high)
388c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
389c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
3907faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return derived() = Derived::NullaryExpr(newSize, internal::linspaced_op<Scalar,false>(low,high,newSize));
391c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
392c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
393c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/**
394c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \brief Sets a linearly space vector.
395c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
396c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The function fill *this with equally spaced values in the closed interval [low,high].
397c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * When size is set to 1, a vector of length 1 containing 'high' is returned.
398c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
399c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \only_for_vectors
400c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
401c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa setLinSpaced(Index, const Scalar&, const Scalar&), CwiseNullaryOp
402c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
403c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
404c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setLinSpaced(const Scalar& low, const Scalar& high)
405c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
406c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
407c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return setLinSpaced(size(), low, high);
408c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
409c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
410c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// zero:
411c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
412c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of a zero matrix.
413c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
414c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The parameters \a rows and \a cols are the number of rows and of columns of
415c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * the returned matrix. Must be compatible with this MatrixBase type.
416c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
417c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
418c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * it is redundant to pass \a rows and \a cols as arguments, so Zero() should be used
419c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * instead.
420c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
421c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_zero_int_int.cpp
422c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_zero_int_int.out
423c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
424c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa Zero(), Zero(Index)
425c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
426c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
427c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
4287faaa9f3f0df9d23790277834d426c3d992ac3baCarlos HernandezDenseBase<Derived>::Zero(Index nbRows, Index nbCols)
429c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
4307faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return Constant(nbRows, nbCols, Scalar(0));
431c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
432c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
433c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of a zero vector.
434c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
435c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * The parameter \a size is the size of the returned vector.
436c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Must be compatible with this MatrixBase type.
437c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
438c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \only_for_vectors
439c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
440c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * This variant is meant to be used for dynamic-size vector types. For fixed-size types,
441c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * it is redundant to pass \a size as argument, so Zero() should be used
442c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * instead.
443c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
444c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_zero_int.cpp
445c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_zero_int.out
446c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
447c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa Zero(), Zero(Index,Index)
448c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
449c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
450c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
451c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathDenseBase<Derived>::Zero(Index size)
452c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
453c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Constant(size, Scalar(0));
454c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
455c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
456c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of a fixed-size zero matrix or vector.
457c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
458c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you
459c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * need to use the variants taking size arguments.
460c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
461c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_zero.cpp
462c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_zero.out
463c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
464c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa Zero(Index), Zero(Index,Index)
465c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
466c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
467c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
468c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathDenseBase<Derived>::Zero()
469c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
470c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Constant(Scalar(0));
471c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
472c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
473c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns true if *this is approximately equal to the zero matrix,
474c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *          within the precision given by \a prec.
475c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
476c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_isZero.cpp
477c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_isZero.out
478c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
479c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class CwiseNullaryOp, Zero()
480c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
481c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
4827faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandezbool DenseBase<Derived>::isZero(const RealScalar& prec) const
483c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
484c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  for(Index j = 0; j < cols(); ++j)
485c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    for(Index i = 0; i < rows(); ++i)
486c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      if(!internal::isMuchSmallerThan(this->coeff(i, j), static_cast<Scalar>(1), prec))
487c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath        return false;
488c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return true;
489c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
490c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
491c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** Sets all coefficients in this expression to zero.
492c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
493c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_setZero.cpp
494c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_setZero.out
495c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
496c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class CwiseNullaryOp, Zero()
497c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
498c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
499c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setZero()
500c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
501c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return setConstant(Scalar(0));
502c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
503c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
504c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** Resizes to the given \a size, and sets all coefficients in this expression to zero.
505c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
506c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \only_for_vectors
507c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
508c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include Matrix_setZero_int.cpp
509c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude Matrix_setZero_int.out
510c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
511c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa DenseBase::setZero(), setZero(Index,Index), class CwiseNullaryOp, DenseBase::Zero()
512c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
513c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
514c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE Derived&
5157faaa9f3f0df9d23790277834d426c3d992ac3baCarlos HernandezPlainObjectBase<Derived>::setZero(Index newSize)
516c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
5177faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  resize(newSize);
518c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return setConstant(Scalar(0));
519c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
520c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
521c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** Resizes to the given size, and sets all coefficients in this expression to zero.
522c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
5237faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param nbRows the new number of rows
5247faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param nbCols the new number of columns
525c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
526c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include Matrix_setZero_int_int.cpp
527c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude Matrix_setZero_int_int.out
528c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
529c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa DenseBase::setZero(), setZero(Index), class CwiseNullaryOp, DenseBase::Zero()
530c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
531c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
532c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE Derived&
5337faaa9f3f0df9d23790277834d426c3d992ac3baCarlos HernandezPlainObjectBase<Derived>::setZero(Index nbRows, Index nbCols)
534c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
5357faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  resize(nbRows, nbCols);
536c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return setConstant(Scalar(0));
537c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
538c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
539c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// ones:
540c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
541c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of a matrix where all coefficients equal one.
542c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
5437faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * The parameters \a nbRows and \a nbCols are the number of rows and of columns of
544c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * the returned matrix. Must be compatible with this MatrixBase type.
545c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
546c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
547c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * it is redundant to pass \a rows and \a cols as arguments, so Ones() should be used
548c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * instead.
549c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
550c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_ones_int_int.cpp
551c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_ones_int_int.out
552c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
553c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa Ones(), Ones(Index), isOnes(), class Ones
554c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
555c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
556c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
5577faaa9f3f0df9d23790277834d426c3d992ac3baCarlos HernandezDenseBase<Derived>::Ones(Index nbRows, Index nbCols)
558c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
5597faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return Constant(nbRows, nbCols, Scalar(1));
560c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
561c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
562c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of a vector where all coefficients equal one.
563c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
5647faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * The parameter \a newSize is the size of the returned vector.
565c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Must be compatible with this MatrixBase type.
566c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
567c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \only_for_vectors
568c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
569c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * This variant is meant to be used for dynamic-size vector types. For fixed-size types,
570c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * it is redundant to pass \a size as argument, so Ones() should be used
571c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * instead.
572c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
573c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_ones_int.cpp
574c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_ones_int.out
575c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
576c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa Ones(), Ones(Index,Index), isOnes(), class Ones
577c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
578c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
579c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
5807faaa9f3f0df9d23790277834d426c3d992ac3baCarlos HernandezDenseBase<Derived>::Ones(Index newSize)
581c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
5827faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return Constant(newSize, Scalar(1));
583c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
584c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
585c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of a fixed-size matrix or vector where all coefficients equal one.
586c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
587c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you
588c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * need to use the variants taking size arguments.
589c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
590c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_ones.cpp
591c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_ones.out
592c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
593c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa Ones(Index), Ones(Index,Index), isOnes(), class Ones
594c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
595c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
596c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const typename DenseBase<Derived>::ConstantReturnType
597c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathDenseBase<Derived>::Ones()
598c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
599c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return Constant(Scalar(1));
600c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
601c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
602c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns true if *this is approximately equal to the matrix where all coefficients
603c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *          are equal to 1, within the precision given by \a prec.
604c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
605c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_isOnes.cpp
606c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_isOnes.out
607c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
608c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class CwiseNullaryOp, Ones()
609c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
610c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
611c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathbool DenseBase<Derived>::isOnes
6127faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez(const RealScalar& prec) const
613c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
614c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return isApproxToConstant(Scalar(1), prec);
615c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
616c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
617c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** Sets all coefficients in this expression to one.
618c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
619c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_setOnes.cpp
620c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_setOnes.out
621c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
622c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class CwiseNullaryOp, Ones()
623c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
624c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
625c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE Derived& DenseBase<Derived>::setOnes()
626c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
627c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return setConstant(Scalar(1));
628c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
629c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
6307faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez/** Resizes to the given \a newSize, and sets all coefficients in this expression to one.
631c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
632c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \only_for_vectors
633c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
634c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include Matrix_setOnes_int.cpp
635c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude Matrix_setOnes_int.out
636c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
637c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa MatrixBase::setOnes(), setOnes(Index,Index), class CwiseNullaryOp, MatrixBase::Ones()
638c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
639c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
640c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE Derived&
6417faaa9f3f0df9d23790277834d426c3d992ac3baCarlos HernandezPlainObjectBase<Derived>::setOnes(Index newSize)
642c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
6437faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  resize(newSize);
644c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return setConstant(Scalar(1));
645c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
646c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
647c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** Resizes to the given size, and sets all coefficients in this expression to one.
648c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
6497faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param nbRows the new number of rows
6507faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * \param nbCols the new number of columns
651c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
652c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include Matrix_setOnes_int_int.cpp
653c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude Matrix_setOnes_int_int.out
654c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
655c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa MatrixBase::setOnes(), setOnes(Index), class CwiseNullaryOp, MatrixBase::Ones()
656c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
657c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
658c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE Derived&
6597faaa9f3f0df9d23790277834d426c3d992ac3baCarlos HernandezPlainObjectBase<Derived>::setOnes(Index nbRows, Index nbCols)
660c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
6617faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  resize(nbRows, nbCols);
662c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return setConstant(Scalar(1));
663c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
664c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
665c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath// Identity:
666c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
667c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of the identity matrix (not necessarily square).
668c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
6697faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  * The parameters \a nbRows and \a nbCols are the number of rows and of columns of
670c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * the returned matrix. Must be compatible with this MatrixBase type.
671c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
672c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * This variant is meant to be used for dynamic-size matrix types. For fixed-size types,
673c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * it is redundant to pass \a rows and \a cols as arguments, so Identity() should be used
674c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * instead.
675c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
676c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_identity_int_int.cpp
677c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_identity_int_int.out
678c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
679c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa Identity(), setIdentity(), isIdentity()
680c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
681c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
682c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const typename MatrixBase<Derived>::IdentityReturnType
6837faaa9f3f0df9d23790277834d426c3d992ac3baCarlos HernandezMatrixBase<Derived>::Identity(Index nbRows, Index nbCols)
684c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
6857faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez  return DenseBase<Derived>::NullaryExpr(nbRows, nbCols, internal::scalar_identity_op<Scalar>());
686c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
687c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
688c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns an expression of the identity matrix (not necessarily square).
689c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
690c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * This variant is only for fixed-size MatrixBase types. For dynamic-size types, you
691c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * need to use the variant taking size arguments.
692c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
693c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_identity.cpp
694c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_identity.out
695c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
696c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa Identity(Index,Index), setIdentity(), isIdentity()
697c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
698c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
699c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathEIGEN_STRONG_INLINE const typename MatrixBase<Derived>::IdentityReturnType
700c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan KamathMatrixBase<Derived>::Identity()
701c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
702c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
703c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return MatrixBase<Derived>::NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_identity_op<Scalar>());
704c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
705c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
706c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath/** \returns true if *this is approximately equal to the identity matrix
707c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *          (not necessarily square),
708c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *          within the precision given by \a prec.
709c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
710c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Example: \include MatrixBase_isIdentity.cpp
711c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * Output: \verbinclude MatrixBase_isIdentity.out
712c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  *
713c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  * \sa class CwiseNullaryOp, Identity(), Identity(Index,Index), setIdentity()
714c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  */
715c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
716c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathbool MatrixBase<Derived>::isIdentity
7177faaa9f3f0df9d23790277834d426c3d992ac3baCarlos Hernandez(const RealScalar& prec) const
718c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
719c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  for(Index j = 0; j < cols(); ++j)
720c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  {
721c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    for(Index i = 0; i < rows(); ++i)
722c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    {
723c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      if(i == j)
724c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      {
725c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath        if(!internal::isApprox(this->coeff(i, j), static_cast<Scalar>(1), prec))
726c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          return false;
727c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      }
728c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      else
729c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      {
730c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath        if(!internal::isMuchSmallerThan(this->coeff(i, j), static_cast<RealScalar>(1), prec))
731c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath          return false;
732c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath      }
733c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    }
734c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  }
735c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  return true;
736c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath}
737c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
738c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathnamespace internal {
739c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
740c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived, bool Big = (Derived::SizeAtCompileTime>=16)>
741c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathstruct setIdentity_impl
742c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
743c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  static EIGEN_STRONG_INLINE Derived& run(Derived& m)
744c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  {
745c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath    return m = Derived::Identity(m.rows(), m.cols());
746c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  }
747c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath};
748c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath
749c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathtemplate<typename Derived>
750c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamathstruct setIdentity_impl<Derived, true>
751c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath{
752c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  typedef typename Derived::Index Index;
753c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  static EIGEN_STRONG_INLINE Derived& run(Derived& m)
754c981c48f5bc9aefeffc0bcb0cc3934c2fae179ddNarayan Kamath  {
755