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

(-)a/Eigen/Core (+1 lines)
Lines 368-373 Link Here
368
#include "src/Core/ProductBase.h"
368
#include "src/Core/ProductBase.h"
369
#include "src/Core/GeneralProduct.h"
369
#include "src/Core/GeneralProduct.h"
370
#include "src/Core/Solve.h"
370
#include "src/Core/Solve.h"
371
#include "src/Core/InPlaceSolver.h"
371
#include "src/Core/Inverse.h"
372
#include "src/Core/Inverse.h"
372
#include "src/Core/TriangularMatrix.h"
373
#include "src/Core/TriangularMatrix.h"
373
#include "src/Core/SelfAdjointView.h"
374
#include "src/Core/SelfAdjointView.h"
(-)24c0a51b38eb (+54 lines)
Added Link Here
1
// This file is part of Eigen, a lightweight C++ template library
2
// for linear algebra.
3
//
4
// Copyright (C) 2015 Chen-Pang He <jdh8@ms63.hinet.net>
5
//
6
// This Source Code Form is subject to the terms of the Mozilla
7
// Public License v. 2.0. If a copy of the MPL was not distributed
8
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
10
#ifndef EIGEN_INPLACE_SOLVER_H
11
#define EIGEN_INPLACE_SOLVER_H
12
13
namespace Eigen {
14
/*!
15
 * \brief Helper class representing an in-place solver.
16
 *
17
 * As Solve calls _solve_impl to get the solution, and there are many in-place
18
 * solvers in numerical linear algebra, such as triangular solver, we introduce
19
 * this helper class.  A class implementing \c solveInPlace method can inherit
20
 * InPlaceSolver to gain \c solve method.
21
 */
22
template<typename Derived>
23
struct InPlaceSolver
24
{
25
  //! \brief Get the derived solver.
26
  EIGEN_DEVICE_FUNC
27
  const Derived& derived() const
28
  {
29
    return *static_cast<const Derived*>(this);
30
  }
31
32
  //! \brief Let Solve call Derived::solveInPlace.
33
  template<typename Rhs, typename Dst>
34
  EIGEN_DEVICE_FUNC
35
  void _solve_impl(const Rhs& rhs, Dst& dst) const
36
  {
37
    if (!(internal::is_same<Rhs,Dst>::value && internal::extract_data(dst) == internal::extract_data(rhs)))
38
      dst = rhs;
39
40
    derived().solveInPlace(dst);
41
  }
42
43
  //! \brief Return the solution.
44
  template<typename Rhs>
45
  EIGEN_DEVICE_FUNC
46
  Solve<Derived, Rhs> solve(const MatrixBase<Rhs>& rhs) const
47
  {
48
    return Solve<Derived, Rhs>(derived(), rhs.derived());
49
  }
50
};
51
52
} // namespace Eigen
53
54
#endif // EIGEN_INPLACE_SOLVER_H
(-)a/Eigen/src/Core/TriangularMatrix.h (-15 / +4 lines)
Lines 182-188 Link Here
182
template<typename _MatrixType, unsigned int _Mode, typename StorageKind> class TriangularViewImpl;
182
template<typename _MatrixType, unsigned int _Mode, typename StorageKind> class TriangularViewImpl;
183
183
184
template<typename _MatrixType, unsigned int _Mode> class TriangularView
184
template<typename _MatrixType, unsigned int _Mode> class TriangularView
185
  : public TriangularViewImpl<_MatrixType, _Mode, typename internal::traits<_MatrixType>::StorageKind >
185
  : public TriangularViewImpl<_MatrixType, _Mode, typename internal::traits<_MatrixType>::StorageKind >,
186
    public InPlaceSolver<TriangularView<_MatrixType, _Mode> >
186
{
187
{
187
  public:
188
  public:
188
189
Lines 202-207 Link Here
202
    typedef typename internal::traits<TriangularView>::Index Index;
203
    typedef typename internal::traits<TriangularView>::Index Index;
203
    typedef typename internal::traits<TriangularView>::MatrixTypeNestedCleaned NestedExpression;
204
    typedef typename internal::traits<TriangularView>::MatrixTypeNestedCleaned NestedExpression;
204
205
206
    using InPlaceSolver<TriangularView>::solve;
207
205
    enum {
208
    enum {
206
      Mode = _Mode,
209
      Mode = _Mode,
207
      Flags = internal::traits<TriangularView>::Flags,
210
      Flags = internal::traits<TriangularView>::Flags,
Lines 260-271 Link Here
260
    {
263
    {
261
      return ConstTransposeReturnType(m_matrix.transpose());
264
      return ConstTransposeReturnType(m_matrix.transpose());
262
    }
265
    }
263
264
    template<typename Other>
265
    EIGEN_DEVICE_FUNC
266
    inline const Solve<TriangularView, Other> 
267
    solve(const MatrixBase<Other>& other) const
268
    { return Solve<TriangularView, Other>(*this, other.derived()); }
269
    
266
    
270
  // workaround MSVC ICE
267
  // workaround MSVC ICE
271
  #if EIGEN_COMP_MSVC
268
  #if EIGEN_COMP_MSVC
Lines 462-475 Link Here
462
      call_assignment(derived(), other.const_cast_derived(), internal::swap_assign_op<Scalar>());
459
      call_assignment(derived(), other.const_cast_derived(), internal::swap_assign_op<Scalar>());
463
    }
460
    }
464
461
465
    template<typename RhsType, typename DstType>
466
    EIGEN_DEVICE_FUNC
467
    EIGEN_STRONG_INLINE void _solve_impl(const RhsType &rhs, DstType &dst) const {
468
      if(!(internal::is_same<RhsType,DstType>::value && internal::extract_data(dst) == internal::extract_data(rhs)))
469
        dst = rhs;
470
      this->solveInPlace(dst);
471
    }
472
473
    template<typename ProductType>
462
    template<typename ProductType>
474
    EIGEN_DEVICE_FUNC
463
    EIGEN_DEVICE_FUNC
475
    EIGEN_STRONG_INLINE TriangularViewType& _assignProduct(const ProductType& prod, const Scalar& alpha);
464
    EIGEN_STRONG_INLINE TriangularViewType& _assignProduct(const ProductType& prod, const Scalar& alpha);

Return to bug 934