This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
View | Details | Raw Unified | Return to bug 505
Collapse All | Expand All

(-)a/Eigen/src/Core/ProductBase.h (-12 / +2 lines)
Lines 108-131 class ProductBase : public MatrixBase<De Link Here
108
    inline void subTo(Dest& dst) const { scaleAndAddTo(dst,Scalar(-1)); }
108
    inline void subTo(Dest& dst) const { scaleAndAddTo(dst,Scalar(-1)); }
109
109
110
    template<typename Dest>
110
    template<typename Dest>
111
    inline void scaleAndAddTo(Dest& dst, const Scalar& alpha) const { derived().scaleAndAddTo(dst,alpha); }
111
    inline void scaleAndAddTo(Dest& dst, const Scalar& alpha) const { derived().scaleAndAddTo(dst,alpha); }
112
112
113
    const _LhsNested& lhs() const { return m_lhs; }
113
    const _LhsNested& lhs() const { return m_lhs; }
114
    const _RhsNested& rhs() const { return m_rhs; }
114
    const _RhsNested& rhs() const { return m_rhs; }
115
115
116
    // Implicit conversion to the nested type (trigger the evaluation of the product)
117
    operator const PlainObject& () const
118
    {
119
      m_result.resize(m_lhs.rows(), m_rhs.cols());
120
      derived().evalTo(m_result);
121
      return m_result;
122
    }
123
124
    const Diagonal<const FullyLazyCoeffBaseProductType,0> diagonal() const
116
    const Diagonal<const FullyLazyCoeffBaseProductType,0> diagonal() const
125
    { return FullyLazyCoeffBaseProductType(m_lhs, m_rhs); }
117
    { return FullyLazyCoeffBaseProductType(m_lhs, m_rhs); }
126
118
127
    template<int Index>
119
    template<int Index>
128
    const Diagonal<FullyLazyCoeffBaseProductType,Index> diagonal() const
120
    const Diagonal<FullyLazyCoeffBaseProductType,Index> diagonal() const
129
    { return FullyLazyCoeffBaseProductType(m_lhs, m_rhs); }
121
    { return FullyLazyCoeffBaseProductType(m_lhs, m_rhs); }
130
122
131
    const Diagonal<FullyLazyCoeffBaseProductType,Dynamic> diagonal(Index index) const
123
    const Diagonal<FullyLazyCoeffBaseProductType,Dynamic> diagonal(Index index) const
Lines 165-191 class ProductBase : public MatrixBase<De Link Here
165
      eigen_assert(this->rows() == 1 && this->cols() == 1);
157
      eigen_assert(this->rows() == 1 && this->cols() == 1);
166
      return derived().coeffRef(i);
158
      return derived().coeffRef(i);
167
    }
159
    }
168
160
169
  protected:
161
  protected:
170
162
171
    LhsNested m_lhs;
163
    LhsNested m_lhs;
172
    RhsNested m_rhs;
164
    RhsNested m_rhs;
173
174
    mutable PlainObject m_result;
175
};
165
};
176
166
177
// here we need to overload the nested rule for products
167
// here we need to overload the nested rule for products
178
// such that the nested type is a const reference to a plain matrix
168
// such that the nested type is a plain matrix storing the result of the product
179
namespace internal {
169
namespace internal {
180
template<typename Lhs, typename Rhs, int Mode, int N, typename PlainObject>
170
template<typename Lhs, typename Rhs, int Mode, int N, typename PlainObject>
181
struct nested<GeneralProduct<Lhs,Rhs,Mode>, N, PlainObject>
171
struct nested<GeneralProduct<Lhs,Rhs,Mode>, N, PlainObject>
182
{
172
{
183
  typedef PlainObject const& type;
173
  typedef PlainObject type;
184
};
174
};
185
}
175
}
186
176
187
template<typename NestedProduct>
177
template<typename NestedProduct>
188
class ScaledProduct;
178
class ScaledProduct;
189
179
190
// Note that these two operator* functions are not defined as member
180
// Note that these two operator* functions are not defined as member
191
// functions of ProductBase, because, otherwise we would have to
181
// functions of ProductBase, because, otherwise we would have to
(-)a/Eigen/src/Core/products/CoeffBasedProduct.h (-11 / +2 lines)
Lines 185-235 class CoeffBasedProduct Link Here
185
      PacketScalar res;
185
      PacketScalar res;
186
      internal::product_packet_impl<Flags&RowMajorBit ? RowMajor : ColMajor,
186
      internal::product_packet_impl<Flags&RowMajorBit ? RowMajor : ColMajor,
187
                              Unroll ? InnerSize-1 : Dynamic,
187
                              Unroll ? InnerSize-1 : Dynamic,
188
                              _LhsNested, _RhsNested, PacketScalar, LoadMode>
188
                              _LhsNested, _RhsNested, PacketScalar, LoadMode>
189
        ::run(row, col, m_lhs, m_rhs, res);
189
        ::run(row, col, m_lhs, m_rhs, res);
190
      return res;
190
      return res;
191
    }
191
    }
192
192
193
    // Implicit conversion to the nested type (trigger the evaluation of the product)
194
    EIGEN_STRONG_INLINE operator const PlainObject& () const
195
    {
196
      m_result.lazyAssign(*this);
197
      return m_result;
198
    }
199
200
    const _LhsNested& lhs() const { return m_lhs; }
193
    const _LhsNested& lhs() const { return m_lhs; }
201
    const _RhsNested& rhs() const { return m_rhs; }
194
    const _RhsNested& rhs() const { return m_rhs; }
202
195
203
    const Diagonal<const LazyCoeffBasedProductType,0> diagonal() const
196
    const Diagonal<const LazyCoeffBasedProductType,0> diagonal() const
204
    { return reinterpret_cast<const LazyCoeffBasedProductType&>(*this); }
197
    { return reinterpret_cast<const LazyCoeffBasedProductType&>(*this); }
205
198
206
    template<int DiagonalIndex>
199
    template<int DiagonalIndex>
207
    const Diagonal<const LazyCoeffBasedProductType,DiagonalIndex> diagonal() const
200
    const Diagonal<const LazyCoeffBasedProductType,DiagonalIndex> diagonal() const
208
    { return reinterpret_cast<const LazyCoeffBasedProductType&>(*this); }
201
    { return reinterpret_cast<const LazyCoeffBasedProductType&>(*this); }
209
202
210
    const Diagonal<const LazyCoeffBasedProductType,Dynamic> diagonal(Index index) const
203
    const Diagonal<const LazyCoeffBasedProductType,Dynamic> diagonal(Index index) const
211
    { return reinterpret_cast<const LazyCoeffBasedProductType&>(*this).diagonal(index); }
204
    { return reinterpret_cast<const LazyCoeffBasedProductType&>(*this).diagonal(index); }
212
205
213
  protected:
206
  protected:
214
    typename internal::add_const_on_value_type<LhsNested>::type m_lhs;
207
    typename internal::add_const_on_value_type<LhsNested>::type m_lhs;
215
    typename internal::add_const_on_value_type<RhsNested>::type m_rhs;
208
    typename internal::add_const_on_value_type<RhsNested>::type m_rhs;
216
217
    mutable PlainObject m_result;
218
};
209
};
219
210
220
namespace internal {
211
namespace internal {
221
212
222
// here we need to overload the nested rule for products
213
// here we need to overload the nested rule for products
223
// such that the nested type is a const reference to a plain matrix
214
// such that the nested type is a plain matrix storing the result of the product
224
template<typename Lhs, typename Rhs, int N, typename PlainObject>
215
template<typename Lhs, typename Rhs, int N, typename PlainObject>
225
struct nested<CoeffBasedProduct<Lhs,Rhs,EvalBeforeNestingBit|EvalBeforeAssigningBit>, N, PlainObject>
216
struct nested<CoeffBasedProduct<Lhs,Rhs,EvalBeforeNestingBit|EvalBeforeAssigningBit>, N, PlainObject>
226
{
217
{
227
  typedef PlainObject const& type;
218
  typedef PlainObject type;
228
};
219
};
229
220
230
/***************************************************************************
221
/***************************************************************************
231
* Normal product .coeff() implementation (with meta-unrolling)
222
* Normal product .coeff() implementation (with meta-unrolling)
232
***************************************************************************/
223
***************************************************************************/
233
224
234
/**************************************
225
/**************************************
235
*** Scalar path  - no vectorization ***
226
*** Scalar path  - no vectorization ***

Return to bug 505