SkylineMatrixBase.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008-2009 Guillaume Saupin <guillaume.saupin@cea.fr>
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_SKYLINEMATRIXBASE_H
11 #define EIGEN_SKYLINEMATRIXBASE_H
12 
13 #include "SkylineUtil.h"
14 
15 #include "./InternalHeaderCheck.h"
16 
17 namespace Eigen {
18 
28 template<typename Derived> class SkylineMatrixBase : public EigenBase<Derived> {
29 public:
30 
31  typedef typename internal::traits<Derived>::Scalar Scalar;
32  typedef typename internal::traits<Derived>::StorageKind StorageKind;
33  typedef typename internal::index<StorageKind>::type Index;
34 
35  enum {
36  RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
42  ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
49  SizeAtCompileTime = (internal::size_of_xpr_at_compile_time<Derived>::ret),
56 
59 
66  Flags = internal::traits<Derived>::Flags,
71  CoeffReadCost = internal::traits<Derived>::CoeffReadCost,
76  IsRowMajor = Flags & RowMajorBit ? 1 : 0
77  };
78 
79 #ifndef EIGEN_PARSED_BY_DOXYGEN
86  typedef typename NumTraits<Scalar>::Real RealScalar;
87 
91 
92  inline const Derived& derived() const {
93  return *static_cast<const Derived*> (this);
94  }
95 
96  inline Derived& derived() {
97  return *static_cast<Derived*> (this);
98  }
99 
100  inline Derived& const_cast_derived() const {
101  return *static_cast<Derived*> (const_cast<SkylineMatrixBase*> (this));
102  }
103 #endif // not EIGEN_PARSED_BY_DOXYGEN
104 
106  inline EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT {
107  return derived().rows();
108  }
109 
111  inline EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT {
112  return derived().cols();
113  }
114 
117  inline EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT {
118  return rows() * cols();
119  }
120 
123  inline Index nonZeros() const {
124  return derived().nonZeros();
125  }
126 
129  Index outerSize() const {
130  return (int(Flags) & RowMajorBit) ? this->rows() : this->cols();
131  }
132 
135  Index innerSize() const {
136  return (int(Flags) & RowMajorBit) ? this->cols() : this->rows();
137  }
138 
139  bool isRValue() const {
140  return m_isRValue;
141  }
142 
143  Derived& markAsRValue() {
144  m_isRValue = true;
145  return derived();
146  }
147 
149  /* TODO check flags */
150  }
151 
152  inline Derived & operator=(const Derived& other) {
153  this->operator=<Derived > (other);
154  return derived();
155  }
156 
157  template<typename OtherDerived>
158  inline void assignGeneric(const OtherDerived& other) {
159  derived().resize(other.rows(), other.cols());
160  for (Index row = 0; row < rows(); row++)
161  for (Index col = 0; col < cols(); col++) {
162  if (other.coeff(row, col) != Scalar(0))
163  derived().insert(row, col) = other.coeff(row, col);
164  }
165  derived().finalize();
166  }
167 
168  template<typename OtherDerived>
169  inline Derived & operator=(const SkylineMatrixBase<OtherDerived>& other) {
170  //TODO
171  }
172 
173  template<typename Lhs, typename Rhs>
175 
176  friend std::ostream & operator <<(std::ostream & s, const SkylineMatrixBase& m) {
177  s << m.derived();
178  return s;
179  }
180 
181  template<typename OtherDerived>
183  operator*(const MatrixBase<OtherDerived> &other) const;
184 
186  template<typename DenseDerived>
187  void evalTo(MatrixBase<DenseDerived>& dst) const {
188  dst.setZero();
189  for (Index i = 0; i < rows(); i++)
190  for (Index j = 0; j < rows(); j++)
191  dst(i, j) = derived().coeff(i, j);
192  }
193 
195  return derived();
196  }
197 
203  EIGEN_STRONG_INLINE const typename internal::eval<Derived, IsSkyline>::type eval() const {
204  return typename internal::eval<Derived>::type(derived());
205  }
206 
207 protected:
209 };
210 
211 } // end namespace Eigen
212 
213 #endif // EIGEN_SKYLINEMATRIXBASE_H
Matrix3f m
int i
RowXpr row(Index i) const
ColXpr col(Index i) const
#define EIGEN_CONSTEXPR
Derived & setZero()
Base class of any skyline matrices or skyline expressions.
const SkylineProductReturnType< Derived, OtherDerived >::Type operator*(const MatrixBase< OtherDerived > &other) const
Derived & operator=(const SkylineMatrixBase< OtherDerived > &other)
Derived & operator=(const SkylineProduct< Lhs, Rhs, SkylineTimeSkylineProduct > &product)
Matrix< Scalar, RowsAtCompileTime, ColsAtCompileTime > toDense() const
Derived & operator=(const Derived &other)
EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
internal::index< StorageKind >::type Index
internal::traits< Derived >::StorageKind StorageKind
internal::traits< Derived >::Scalar Scalar
const internal::eval< Derived, IsSkyline >::type eval() const
void evalTo(MatrixBase< DenseDerived > &dst) const
void assignGeneric(const OtherDerived &other)
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
friend std::ostream & operator<<(std::ostream &s, const SkylineMatrixBase &m)
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
const unsigned int RowMajorBit
constexpr int size_at_compile_time(int rows, int cols)
constexpr int max_size_prefer_dynamic(A a, B b)
: TensorContractionSycl.h, provides various tensor contraction kernel for SYCL backend
Derived & const_cast_derived() const
std::ptrdiff_t j