~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to extern/Eigen3/Eigen/src/Eigen2Support/LU.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// This file is part of Eigen, a lightweight C++ template library
 
2
// for linear algebra.
 
3
//
 
4
// Copyright (C) 2011 Benoit Jacob <jacob.benoit.1@gmail.com>
 
5
//
 
6
// Eigen is free software; you can redistribute it and/or
 
7
// modify it under the terms of the GNU Lesser General Public
 
8
// License as published by the Free Software Foundation; either
 
9
// version 3 of the License, or (at your option) any later version.
 
10
//
 
11
// Alternatively, you can redistribute it and/or
 
12
// modify it under the terms of the GNU General Public License as
 
13
// published by the Free Software Foundation; either version 2 of
 
14
// the License, or (at your option) any later version.
 
15
//
 
16
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
 
17
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
18
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
 
19
// GNU General Public License for more details.
 
20
//
 
21
// You should have received a copy of the GNU Lesser General Public
 
22
// License and a copy of the GNU General Public License along with
 
23
// Eigen. If not, see <http://www.gnu.org/licenses/>.
 
24
 
 
25
#ifndef EIGEN2_LU_H
 
26
#define EIGEN2_LU_H
 
27
 
 
28
template<typename MatrixType>
 
29
class LU : public FullPivLU<MatrixType>
 
30
{
 
31
  public:
 
32
 
 
33
    typedef typename MatrixType::Scalar Scalar;
 
34
    typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
 
35
    typedef Matrix<int, 1, MatrixType::ColsAtCompileTime, MatrixType::Options, 1, MatrixType::MaxColsAtCompileTime> IntRowVectorType;
 
36
    typedef Matrix<int, MatrixType::RowsAtCompileTime, 1, MatrixType::Options, MatrixType::MaxRowsAtCompileTime, 1> IntColVectorType;
 
37
    typedef Matrix<Scalar, 1, MatrixType::ColsAtCompileTime, MatrixType::Options, 1, MatrixType::MaxColsAtCompileTime> RowVectorType;
 
38
    typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1, MatrixType::Options, MatrixType::MaxRowsAtCompileTime, 1> ColVectorType;
 
39
 
 
40
    typedef Matrix<typename MatrixType::Scalar,
 
41
                  MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix" is the number of cols of the original matrix
 
42
                                                 // so that the product "matrix * kernel = zero" makes sense
 
43
                  Dynamic,                       // we don't know at compile-time the dimension of the kernel
 
44
                  MatrixType::Options,
 
45
                  MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter
 
46
                  MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space, whose dimension is the number
 
47
                                                   // of columns of the original matrix
 
48
    > KernelResultType;
 
49
 
 
50
    typedef Matrix<typename MatrixType::Scalar,
 
51
                   MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose dimension is the number
 
52
                                                  // of rows of the original matrix
 
53
                   Dynamic,                       // we don't know at compile time the dimension of the image (the rank)
 
54
                   MatrixType::Options,
 
55
                   MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original matrix,
 
56
                   MatrixType::MaxColsAtCompileTime  // so it has the same number of rows and at most as many columns.
 
57
    > ImageResultType;
 
58
 
 
59
    typedef FullPivLU<MatrixType> Base;
 
60
    LU() : Base() {}
 
61
 
 
62
    template<typename T>
 
63
    explicit LU(const T& t) : Base(t), m_originalMatrix(t) {}
 
64
 
 
65
    template<typename OtherDerived, typename ResultType>
 
66
    bool solve(const MatrixBase<OtherDerived>& b, ResultType *result) const
 
67
    {
 
68
      *result = static_cast<const Base*>(this)->solve(b);
 
69
      return true;
 
70
    }
 
71
 
 
72
    template<typename ResultType>
 
73
    inline void computeInverse(ResultType *result) const
 
74
    {
 
75
      solve(MatrixType::Identity(this->rows(), this->cols()), result);
 
76
    }
 
77
    
 
78
    template<typename KernelMatrixType>
 
79
    void computeKernel(KernelMatrixType *result) const
 
80
    {
 
81
      *result = static_cast<const Base*>(this)->kernel();
 
82
    }
 
83
    
 
84
    template<typename ImageMatrixType>
 
85
    void computeImage(ImageMatrixType *result) const
 
86
    {
 
87
      *result = static_cast<const Base*>(this)->image(m_originalMatrix);
 
88
    }
 
89
    
 
90
    const ImageResultType image() const
 
91
    {
 
92
      return static_cast<const Base*>(this)->image(m_originalMatrix);
 
93
    }
 
94
    
 
95
    const MatrixType& m_originalMatrix;
 
96
};
 
97
 
 
98
#if EIGEN2_SUPPORT_STAGE < STAGE20_RESOLVE_API_CONFLICTS
 
99
/** \lu_module
 
100
  *
 
101
  * Synonym of partialPivLu().
 
102
  *
 
103
  * \return the partial-pivoting LU decomposition of \c *this.
 
104
  *
 
105
  * \sa class PartialPivLU
 
106
  */
 
107
template<typename Derived>
 
108
inline const LU<typename MatrixBase<Derived>::PlainObject>
 
109
MatrixBase<Derived>::lu() const
 
110
{
 
111
  return LU<PlainObject>(eval());
 
112
}
 
113
#endif
 
114
 
 
115
#ifdef EIGEN2_SUPPORT
 
116
/** \lu_module
 
117
  *
 
118
  * Synonym of partialPivLu().
 
119
  *
 
120
  * \return the partial-pivoting LU decomposition of \c *this.
 
121
  *
 
122
  * \sa class PartialPivLU
 
123
  */
 
124
template<typename Derived>
 
125
inline const LU<typename MatrixBase<Derived>::PlainObject>
 
126
MatrixBase<Derived>::eigen2_lu() const
 
127
{
 
128
  return LU<PlainObject>(eval());
 
129
}
 
130
#endif
 
131
 
 
132
 
 
133
#endif // EIGEN2_LU_H