File indexing completed on 2025-01-18 09:57:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef EIGEN_SKYLINEMATRIXBASE_H
0011 #define EIGEN_SKYLINEMATRIXBASE_H
0012
0013 #include "SkylineUtil.h"
0014
0015 namespace Eigen {
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 template<typename Derived> class SkylineMatrixBase : public EigenBase<Derived> {
0027 public:
0028
0029 typedef typename internal::traits<Derived>::Scalar Scalar;
0030 typedef typename internal::traits<Derived>::StorageKind StorageKind;
0031 typedef typename internal::index<StorageKind>::type Index;
0032
0033 enum {
0034 RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
0035
0036
0037
0038
0039
0040 ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
0041
0042
0043
0044
0045
0046
0047 SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,
0048 internal::traits<Derived>::ColsAtCompileTime>::ret),
0049
0050
0051
0052
0053 MaxRowsAtCompileTime = RowsAtCompileTime,
0054 MaxColsAtCompileTime = ColsAtCompileTime,
0055
0056 MaxSizeAtCompileTime = (internal::size_at_compile_time<MaxRowsAtCompileTime,
0057 MaxColsAtCompileTime>::ret),
0058
0059 IsVectorAtCompileTime = RowsAtCompileTime == 1 || ColsAtCompileTime == 1,
0060
0061
0062
0063
0064
0065 Flags = internal::traits<Derived>::Flags,
0066
0067
0068
0069
0070 CoeffReadCost = internal::traits<Derived>::CoeffReadCost,
0071
0072
0073
0074
0075 IsRowMajor = Flags & RowMajorBit ? 1 : 0
0076 };
0077
0078 #ifndef EIGEN_PARSED_BY_DOXYGEN
0079
0080
0081
0082
0083
0084
0085 typedef typename NumTraits<Scalar>::Real RealScalar;
0086
0087
0088 typedef Matrix<Scalar, EIGEN_SIZE_MAX(RowsAtCompileTime, ColsAtCompileTime),
0089 EIGEN_SIZE_MAX(RowsAtCompileTime, ColsAtCompileTime) > SquareMatrixType;
0090
0091 inline const Derived& derived() const {
0092 return *static_cast<const Derived*> (this);
0093 }
0094
0095 inline Derived& derived() {
0096 return *static_cast<Derived*> (this);
0097 }
0098
0099 inline Derived& const_cast_derived() const {
0100 return *static_cast<Derived*> (const_cast<SkylineMatrixBase*> (this));
0101 }
0102 #endif
0103
0104
0105 inline EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT {
0106 return derived().rows();
0107 }
0108
0109
0110 inline EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT {
0111 return derived().cols();
0112 }
0113
0114
0115
0116 inline EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT {
0117 return rows() * cols();
0118 }
0119
0120
0121
0122 inline Index nonZeros() const {
0123 return derived().nonZeros();
0124 }
0125
0126
0127
0128 Index outerSize() const {
0129 return (int(Flags) & RowMajorBit) ? this->rows() : this->cols();
0130 }
0131
0132
0133
0134 Index innerSize() const {
0135 return (int(Flags) & RowMajorBit) ? this->cols() : this->rows();
0136 }
0137
0138 bool isRValue() const {
0139 return m_isRValue;
0140 }
0141
0142 Derived& markAsRValue() {
0143 m_isRValue = true;
0144 return derived();
0145 }
0146
0147 SkylineMatrixBase() : m_isRValue(false) {
0148
0149 }
0150
0151 inline Derived & operator=(const Derived& other) {
0152 this->operator=<Derived > (other);
0153 return derived();
0154 }
0155
0156 template<typename OtherDerived>
0157 inline void assignGeneric(const OtherDerived& other) {
0158 derived().resize(other.rows(), other.cols());
0159 for (Index row = 0; row < rows(); row++)
0160 for (Index col = 0; col < cols(); col++) {
0161 if (other.coeff(row, col) != Scalar(0))
0162 derived().insert(row, col) = other.coeff(row, col);
0163 }
0164 derived().finalize();
0165 }
0166
0167 template<typename OtherDerived>
0168 inline Derived & operator=(const SkylineMatrixBase<OtherDerived>& other) {
0169
0170 }
0171
0172 template<typename Lhs, typename Rhs>
0173 inline Derived & operator=(const SkylineProduct<Lhs, Rhs, SkylineTimeSkylineProduct>& product);
0174
0175 friend std::ostream & operator <<(std::ostream & s, const SkylineMatrixBase& m) {
0176 s << m.derived();
0177 return s;
0178 }
0179
0180 template<typename OtherDerived>
0181 const typename SkylineProductReturnType<Derived, OtherDerived>::Type
0182 operator*(const MatrixBase<OtherDerived> &other) const;
0183
0184
0185 template<typename DenseDerived>
0186 void evalTo(MatrixBase<DenseDerived>& dst) const {
0187 dst.setZero();
0188 for (Index i = 0; i < rows(); i++)
0189 for (Index j = 0; j < rows(); j++)
0190 dst(i, j) = derived().coeff(i, j);
0191 }
0192
0193 Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime> toDense() const {
0194 return derived();
0195 }
0196
0197
0198
0199
0200
0201
0202 EIGEN_STRONG_INLINE const typename internal::eval<Derived, IsSkyline>::type eval() const {
0203 return typename internal::eval<Derived>::type(derived());
0204 }
0205
0206 protected:
0207 bool m_isRValue;
0208 };
0209
0210 }
0211
0212 #endif