SkylineMatrixBase.h
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2008-2009 Guillaume Saupin <guillaume.saupin@cea.fr>
00005 //
00006 // This Source Code Form is subject to the terms of the Mozilla
00007 // Public License v. 2.0. If a copy of the MPL was not distributed
00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00009 
00010 #ifndef EIGEN_SKYLINEMATRIXBASE_H
00011 #define EIGEN_SKYLINEMATRIXBASE_H
00012 
00013 #include "SkylineUtil.h"
00014 
00015 namespace Eigen { 
00016 
00026 template<typename Derived> class SkylineMatrixBase : public EigenBase<Derived> {
00027 public:
00028 
00029     typedef typename internal::traits<Derived>::Scalar Scalar;
00030     typedef typename internal::traits<Derived>::StorageKind StorageKind;
00031     typedef typename internal::index<StorageKind>::type Index;
00032 
00033     enum {
00034         RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
00040         ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
00047         SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,
00048         internal::traits<Derived>::ColsAtCompileTime>::ret),
00053         MaxRowsAtCompileTime = RowsAtCompileTime,
00054         MaxColsAtCompileTime = ColsAtCompileTime,
00055 
00056         MaxSizeAtCompileTime = (internal::size_at_compile_time<MaxRowsAtCompileTime,
00057         MaxColsAtCompileTime>::ret),
00058 
00059         IsVectorAtCompileTime = RowsAtCompileTime == 1 || ColsAtCompileTime == 1,
00065         Flags = internal::traits<Derived>::Flags,
00070         CoeffReadCost = internal::traits<Derived>::CoeffReadCost,
00075         IsRowMajor = Flags & RowMajorBit ? 1 : 0
00076     };
00077 
00078 #ifndef EIGEN_PARSED_BY_DOXYGEN
00079 
00085     typedef typename NumTraits<Scalar>::Real RealScalar;
00086 
00088     typedef Matrix<Scalar, EIGEN_SIZE_MAX(RowsAtCompileTime, ColsAtCompileTime),
00089                            EIGEN_SIZE_MAX(RowsAtCompileTime, ColsAtCompileTime) > SquareMatrixType;
00090 
00091     inline const Derived& derived() const {
00092         return *static_cast<const Derived*> (this);
00093     }
00094 
00095     inline Derived& derived() {
00096         return *static_cast<Derived*> (this);
00097     }
00098 
00099     inline Derived& const_cast_derived() const {
00100         return *static_cast<Derived*> (const_cast<SkylineMatrixBase*> (this));
00101     }
00102 #endif // not EIGEN_PARSED_BY_DOXYGEN
00103 
00105     inline Index rows() const {
00106         return derived().rows();
00107     }
00108 
00110     inline Index cols() const {
00111         return derived().cols();
00112     }
00113 
00116     inline Index size() const {
00117         return rows() * cols();
00118     }
00119 
00122     inline Index nonZeros() const {
00123         return derived().nonZeros();
00124     }
00125 
00128     Index outerSize() const {
00129         return (int(Flags) & RowMajorBit) ? this->rows() : this->cols();
00130     }
00131 
00134     Index innerSize() const {
00135         return (int(Flags) & RowMajorBit) ? this->cols() : this->rows();
00136     }
00137 
00138     bool isRValue() const {
00139         return m_isRValue;
00140     }
00141 
00142     Derived& markAsRValue() {
00143         m_isRValue = true;
00144         return derived();
00145     }
00146 
00147     SkylineMatrixBase() : m_isRValue(false) {
00148         /* TODO check flags */
00149     }
00150 
00151     inline Derived & operator=(const Derived& other) {
00152         this->operator=<Derived > (other);
00153         return derived();
00154     }
00155 
00156     template<typename OtherDerived>
00157     inline void assignGeneric(const OtherDerived& other) {
00158         derived().resize(other.rows(), other.cols());
00159         for (Index row = 0; row < rows(); row++)
00160             for (Index col = 0; col < cols(); col++) {
00161                 if (other.coeff(row, col) != Scalar(0))
00162                     derived().insert(row, col) = other.coeff(row, col);
00163             }
00164         derived().finalize();
00165     }
00166 
00167     template<typename OtherDerived>
00168             inline Derived & operator=(const SkylineMatrixBase<OtherDerived>& other) {
00169         //TODO
00170     }
00171 
00172     template<typename Lhs, typename Rhs>
00173             inline Derived & operator=(const SkylineProduct<Lhs, Rhs, SkylineTimeSkylineProduct>& product);
00174 
00175     friend std::ostream & operator <<(std::ostream & s, const SkylineMatrixBase& m) {
00176         s << m.derived();
00177         return s;
00178     }
00179 
00180     template<typename OtherDerived>
00181     const typename SkylineProductReturnType<Derived, OtherDerived>::Type
00182     operator*(const MatrixBase<OtherDerived> &other) const;
00183 
00185     template<typename DenseDerived>
00186     void evalTo(MatrixBase<DenseDerived>& dst) const {
00187         dst.setZero();
00188         for (Index i = 0; i < rows(); i++)
00189             for (Index j = 0; j < rows(); j++)
00190                 dst(i, j) = derived().coeff(i, j);
00191     }
00192 
00193     Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime> toDense() const {
00194         return derived();
00195     }
00196 
00202     EIGEN_STRONG_INLINE const typename internal::eval<Derived, IsSkyline>::type eval() const {
00203         return typename internal::eval<Derived>::type(derived());
00204     }
00205 
00206 protected:
00207     bool m_isRValue;
00208 };
00209 
00210 } // end namespace Eigen
00211 
00212 #endif // EIGEN_SkylineMatrixBase_H


win_eigen
Author(s): Daniel Stonier
autogenerated on Mon Oct 6 2014 12:26:06