00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef EIGEN_SKYLINEMATRIXBASE_H
00026 #define EIGEN_SKYLINEMATRIXBASE_H
00027
00028 #include "SkylineUtil.h"
00029
00030 namespace Eigen {
00031
00041 template<typename Derived> class SkylineMatrixBase : public EigenBase<Derived> {
00042 public:
00043
00044 typedef typename internal::traits<Derived>::Scalar Scalar;
00045 typedef typename internal::traits<Derived>::StorageKind StorageKind;
00046 typedef typename internal::index<StorageKind>::type Index;
00047
00048 enum {
00049 RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
00055 ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
00062 SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,
00063 internal::traits<Derived>::ColsAtCompileTime>::ret),
00068 MaxRowsAtCompileTime = RowsAtCompileTime,
00069 MaxColsAtCompileTime = ColsAtCompileTime,
00070
00071 MaxSizeAtCompileTime = (internal::size_at_compile_time<MaxRowsAtCompileTime,
00072 MaxColsAtCompileTime>::ret),
00073
00074 IsVectorAtCompileTime = RowsAtCompileTime == 1 || ColsAtCompileTime == 1,
00080 Flags = internal::traits<Derived>::Flags,
00085 CoeffReadCost = internal::traits<Derived>::CoeffReadCost,
00090 IsRowMajor = Flags & RowMajorBit ? 1 : 0
00091 };
00092
00093 #ifndef EIGEN_PARSED_BY_DOXYGEN
00094
00100 typedef typename NumTraits<Scalar>::Real RealScalar;
00101
00103 typedef Matrix<Scalar, EIGEN_SIZE_MAX(RowsAtCompileTime, ColsAtCompileTime),
00104 EIGEN_SIZE_MAX(RowsAtCompileTime, ColsAtCompileTime) > SquareMatrixType;
00105
00106 inline const Derived& derived() const {
00107 return *static_cast<const Derived*> (this);
00108 }
00109
00110 inline Derived& derived() {
00111 return *static_cast<Derived*> (this);
00112 }
00113
00114 inline Derived& const_cast_derived() const {
00115 return *static_cast<Derived*> (const_cast<SkylineMatrixBase*> (this));
00116 }
00117 #endif // not EIGEN_PARSED_BY_DOXYGEN
00118
00120 inline Index rows() const {
00121 return derived().rows();
00122 }
00123
00125 inline Index cols() const {
00126 return derived().cols();
00127 }
00128
00131 inline Index size() const {
00132 return rows() * cols();
00133 }
00134
00137 inline Index nonZeros() const {
00138 return derived().nonZeros();
00139 }
00140
00143 Index outerSize() const {
00144 return (int(Flags) & RowMajorBit) ? this->rows() : this->cols();
00145 }
00146
00149 Index innerSize() const {
00150 return (int(Flags) & RowMajorBit) ? this->cols() : this->rows();
00151 }
00152
00153 bool isRValue() const {
00154 return m_isRValue;
00155 }
00156
00157 Derived& markAsRValue() {
00158 m_isRValue = true;
00159 return derived();
00160 }
00161
00162 SkylineMatrixBase() : m_isRValue(false) {
00163
00164 }
00165
00166 inline Derived & operator=(const Derived& other) {
00167 this->operator=<Derived > (other);
00168 return derived();
00169 }
00170
00171 template<typename OtherDerived>
00172 inline void assignGeneric(const OtherDerived& other) {
00173 derived().resize(other.rows(), other.cols());
00174 for (Index row = 0; row < rows(); row++)
00175 for (Index col = 0; col < cols(); col++) {
00176 if (other.coeff(row, col) != Scalar(0))
00177 derived().insert(row, col) = other.coeff(row, col);
00178 }
00179 derived().finalize();
00180 }
00181
00182 template<typename OtherDerived>
00183 inline Derived & operator=(const SkylineMatrixBase<OtherDerived>& other) {
00184
00185 }
00186
00187 template<typename Lhs, typename Rhs>
00188 inline Derived & operator=(const SkylineProduct<Lhs, Rhs, SkylineTimeSkylineProduct>& product);
00189
00190 friend std::ostream & operator <<(std::ostream & s, const SkylineMatrixBase& m) {
00191 s << m.derived();
00192 return s;
00193 }
00194
00195 template<typename OtherDerived>
00196 const typename SkylineProductReturnType<Derived, OtherDerived>::Type
00197 operator*(const MatrixBase<OtherDerived> &other) const;
00198
00200 template<typename DenseDerived>
00201 void evalTo(MatrixBase<DenseDerived>& dst) const {
00202 dst.setZero();
00203 for (Index i = 0; i < rows(); i++)
00204 for (Index j = 0; j < rows(); j++)
00205 dst(i, j) = derived().coeff(i, j);
00206 }
00207
00208 Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime> toDense() const {
00209 return derived();
00210 }
00211
00217 EIGEN_STRONG_INLINE const typename internal::eval<Derived, IsSkyline>::type eval() const {
00218 return typename internal::eval<Derived>::type(derived());
00219 }
00220
00221 protected:
00222 bool m_isRValue;
00223 };
00224
00225 }
00226
00227 #endif // EIGEN_SkylineMatrixBase_H