Path Tracer
EigenBase.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
5 // Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_EIGENBASE_H
12 #define EIGEN_EIGENBASE_H
13 
14 namespace Eigen {
15 
29 template<typename Derived> struct EigenBase
30 {
31 // typedef typename internal::plain_matrix_type<Derived>::type PlainObject;
32 
40 
41  // FIXME is it needed?
42  typedef typename internal::traits<Derived>::StorageKind StorageKind;
43 
45  EIGEN_DEVICE_FUNC
46  Derived& derived() { return *static_cast<Derived*>(this); }
48  EIGEN_DEVICE_FUNC
49  const Derived& derived() const { return *static_cast<const Derived*>(this); }
50 
51  EIGEN_DEVICE_FUNC
52  inline Derived& const_cast_derived() const
53  { return *static_cast<Derived*>(const_cast<EigenBase*>(this)); }
54  EIGEN_DEVICE_FUNC
55  inline const Derived& const_derived() const
56  { return *static_cast<const Derived*>(this); }
57 
59  EIGEN_DEVICE_FUNC
60  inline Index rows() const { return derived().rows(); }
62  EIGEN_DEVICE_FUNC
63  inline Index cols() const { return derived().cols(); }
66  EIGEN_DEVICE_FUNC
67  inline Index size() const { return rows() * cols(); }
68 
70  template<typename Dest>
71  EIGEN_DEVICE_FUNC
72  inline void evalTo(Dest& dst) const
73  { derived().evalTo(dst); }
74 
76  template<typename Dest>
77  EIGEN_DEVICE_FUNC
78  inline void addTo(Dest& dst) const
79  {
80  // This is the default implementation,
81  // derived class can reimplement it in a more optimized way.
82  typename Dest::PlainObject res(rows(),cols());
83  evalTo(res);
84  dst += res;
85  }
86 
88  template<typename Dest>
89  EIGEN_DEVICE_FUNC
90  inline void subTo(Dest& dst) const
91  {
92  // This is the default implementation,
93  // derived class can reimplement it in a more optimized way.
94  typename Dest::PlainObject res(rows(),cols());
95  evalTo(res);
96  dst -= res;
97  }
98 
100  template<typename Dest>
101  EIGEN_DEVICE_FUNC inline void applyThisOnTheRight(Dest& dst) const
102  {
103  // This is the default implementation,
104  // derived class can reimplement it in a more optimized way.
105  dst = dst * this->derived();
106  }
107 
109  template<typename Dest>
110  EIGEN_DEVICE_FUNC inline void applyThisOnTheLeft(Dest& dst) const
111  {
112  // This is the default implementation,
113  // derived class can reimplement it in a more optimized way.
114  dst = this->derived() * dst;
115  }
116 
117 };
118 
119 /***************************************************************************
120 * Implementation of matrix base methods
121 ***************************************************************************/
122 
131 template<typename Derived>
132 template<typename OtherDerived>
133 EIGEN_DEVICE_FUNC
135 {
136  call_assignment(derived(), other.derived());
137  return derived();
138 }
139 
140 template<typename Derived>
141 template<typename OtherDerived>
142 EIGEN_DEVICE_FUNC
144 {
145  call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
146  return derived();
147 }
148 
149 template<typename Derived>
150 template<typename OtherDerived>
151 EIGEN_DEVICE_FUNC
152 Derived& DenseBase<Derived>::operator-=(const EigenBase<OtherDerived> &other)
153 {
154  call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());
155  return derived();
156 }
157 
158 } // end namespace Eigen
159 
160 #endif // EIGEN_EIGENBASE_H
Eigen
Namespace containing all symbols from the Eigen library.
Definition: LDLT.h:16
Eigen::EigenBase::derived
EIGEN_DEVICE_FUNC Derived & derived()
Definition: EigenBase.h:46
Eigen::EigenBase::rows
EIGEN_DEVICE_FUNC Index rows() const
Definition: EigenBase.h:60
Eigen::EigenBase::Index
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:39
Eigen::EigenBase
Definition: EigenBase.h:30
Eigen::EigenBase::size
EIGEN_DEVICE_FUNC Index size() const
Definition: EigenBase.h:67
Eigen::EigenBase::cols
EIGEN_DEVICE_FUNC Index cols() const
Definition: EigenBase.h:63
Eigen::EigenBase::derived
EIGEN_DEVICE_FUNC const Derived & derived() const
Definition: EigenBase.h:49
Eigen::internal::traits
Definition: ForwardDeclarations.h:17
Eigen::DenseBase
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:47
Eigen::DenseBase::operator=
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived & operator=(const DenseBase< OtherDerived > &other)
Definition: Assign.h:39
Eigen::internal::add_assign_op
Definition: AssignmentFunctors.h:46
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:42