SparseMatrixBase.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 Gael Guennebaud <gael.guennebaud@inria.fr>
00005 //
00006 // Eigen is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 3 of the License, or (at your option) any later version.
00010 //
00011 // Alternatively, you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License as
00013 // published by the Free Software Foundation; either version 2 of
00014 // the License, or (at your option) any later version.
00015 //
00016 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00017 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00018 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00019 // GNU General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License and a copy of the GNU General Public License along with
00023 // Eigen. If not, see <http://www.gnu.org/licenses/>.
00024 
00025 #ifndef EIGEN_SPARSEMATRIXBASE_H
00026 #define EIGEN_SPARSEMATRIXBASE_H
00027 
00039 template<typename Derived> class SparseMatrixBase : public EigenBase<Derived>
00040 {
00041   public:
00042 
00043     typedef typename internal::traits<Derived>::Scalar Scalar;
00044     typedef typename internal::packet_traits<Scalar>::type PacketScalar;
00045     typedef typename internal::traits<Derived>::StorageKind StorageKind;
00046     typedef typename internal::traits<Derived>::Index Index;
00047 
00048     typedef SparseMatrixBase StorageBaseType;
00049     typedef EigenBase<Derived> Base;
00050     
00051     template<typename OtherDerived>
00052     Derived& operator=(const EigenBase<OtherDerived> &other)
00053     {
00054       other.derived().evalTo(derived());
00055       return derived();
00056     }
00057     
00058 //     using Base::operator=;
00059 
00060     enum {
00061 
00062       RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
00068       ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
00075       SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,
00076                                                    internal::traits<Derived>::ColsAtCompileTime>::ret),
00081       MaxRowsAtCompileTime = RowsAtCompileTime,
00082       MaxColsAtCompileTime = ColsAtCompileTime,
00083 
00084       MaxSizeAtCompileTime = (internal::size_at_compile_time<MaxRowsAtCompileTime,
00085                                                       MaxColsAtCompileTime>::ret),
00086 
00087       IsVectorAtCompileTime = RowsAtCompileTime == 1 || ColsAtCompileTime == 1,
00093       Flags = internal::traits<Derived>::Flags,
00098       CoeffReadCost = internal::traits<Derived>::CoeffReadCost,
00103       IsRowMajor = Flags&RowMajorBit ? 1 : 0,
00104 
00105       #ifndef EIGEN_PARSED_BY_DOXYGEN
00106       _HasDirectAccess = (int(Flags)&DirectAccessBit) ? 1 : 0 // workaround sunCC
00107       #endif
00108     };
00109 
00110     /* \internal the return type of MatrixBase::conjugate() */
00111 //     typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
00112 //                         const SparseCwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, Derived>,
00113 //                         const Derived&
00114 //                      >::type ConjugateReturnType;
00115     /* \internal the return type of MatrixBase::real() */
00116 //     typedef SparseCwiseUnaryOp<internal::scalar_real_op<Scalar>, Derived> RealReturnType;
00117     /* \internal the return type of MatrixBase::imag() */
00118 //     typedef SparseCwiseUnaryOp<internal::scalar_imag_op<Scalar>, Derived> ImagReturnType;
00120     typedef typename internal::conditional<NumTraits<Scalar>::IsComplex,
00121                         CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, Eigen::Transpose<const Derived> >,
00122                         Transpose<const Derived>
00123                      >::type AdjointReturnType;
00124 
00125 
00126     typedef SparseMatrix<Scalar, Flags&RowMajorBit ? RowMajor : ColMajor> PlainObject;
00127 
00128 #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase
00129 #   include "../plugins/CommonCwiseUnaryOps.h"
00130 #   include "../plugins/CommonCwiseBinaryOps.h"
00131 #   include "../plugins/MatrixCwiseUnaryOps.h"
00132 #   include "../plugins/MatrixCwiseBinaryOps.h"
00133 #   ifdef EIGEN_SPARSEMATRIXBASE_PLUGIN
00134 #     include EIGEN_SPARSEMATRIXBASE_PLUGIN
00135 #   endif
00136 #   undef EIGEN_CURRENT_STORAGE_BASE_CLASS
00137 #undef EIGEN_CURRENT_STORAGE_BASE_CLASS
00138 
00139 #ifndef EIGEN_PARSED_BY_DOXYGEN
00140 
00146     typedef typename NumTraits<Scalar>::Real RealScalar;
00147 
00150     typedef typename internal::conditional<_HasDirectAccess, const Scalar&, Scalar>::type CoeffReturnType;
00151 
00153     typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,Matrix<Scalar,Dynamic,Dynamic> > ConstantReturnType;
00154 
00156     typedef Matrix<Scalar,EIGEN_SIZE_MAX(RowsAtCompileTime,ColsAtCompileTime),
00157                           EIGEN_SIZE_MAX(RowsAtCompileTime,ColsAtCompileTime)> SquareMatrixType;
00158 
00159     inline const Derived& derived() const { return *static_cast<const Derived*>(this); }
00160     inline Derived& derived() { return *static_cast<Derived*>(this); }
00161     inline Derived& const_cast_derived() const
00162     { return *static_cast<Derived*>(const_cast<SparseMatrixBase*>(this)); }
00163 #endif // not EIGEN_PARSED_BY_DOXYGEN
00164 
00166     inline Index rows() const { return derived().rows(); }
00168     inline Index cols() const { return derived().cols(); }
00171     inline Index size() const { return rows() * cols(); }
00174     inline Index nonZeros() const { return derived().nonZeros(); }
00179     inline bool isVector() const { return rows()==1 || cols()==1; }
00182     Index outerSize() const { return (int(Flags)&RowMajorBit) ? this->rows() : this->cols(); }
00185     Index innerSize() const { return (int(Flags)&RowMajorBit) ? this->cols() : this->rows(); }
00186 
00187     bool isRValue() const { return m_isRValue; }
00188     Derived& markAsRValue() { m_isRValue = true; return derived(); }
00189 
00190     SparseMatrixBase() : m_isRValue(false) { /* TODO check flags */ }
00191     
00192     inline Derived& operator=(const Derived& other)
00193     {
00194 //       std::cout << "Derived& operator=(const Derived& other)\n";
00195 //       if (other.isRValue())
00196 //         derived().swap(other.const_cast_derived());
00197 //       else
00198         this->operator=<Derived>(other);
00199       return derived();
00200     }
00201     
00202     template<typename OtherDerived>
00203     Derived& operator=(const ReturnByValue<OtherDerived>& other)
00204     {
00205       other.evalTo(derived());
00206       return derived();
00207     }
00208 
00209 
00210     template<typename OtherDerived>
00211     inline void assignGeneric(const OtherDerived& other)
00212     {
00213 //       std::cout << "Derived& operator=(const MatrixBase<OtherDerived>& other)\n";
00214       //const bool transpose = (Flags & RowMajorBit) != (OtherDerived::Flags & RowMajorBit);
00215       eigen_assert(( ((internal::traits<Derived>::SupportedAccessPatterns&OuterRandomAccessPattern)==OuterRandomAccessPattern) ||
00216                   (!((Flags & RowMajorBit) != (OtherDerived::Flags & RowMajorBit)))) &&
00217                   "the transpose operation is supposed to be handled in SparseMatrix::operator=");
00218 
00219       enum { Flip = (Flags & RowMajorBit) != (OtherDerived::Flags & RowMajorBit) };
00220 
00221       const Index outerSize = other.outerSize();
00222       //typedef typename internal::conditional<transpose, LinkedVectorMatrix<Scalar,Flags&RowMajorBit>, Derived>::type TempType;
00223       // thanks to shallow copies, we always eval to a tempary
00224       Derived temp(other.rows(), other.cols());
00225 
00226       temp.reserve((std::max)(this->rows(),this->cols())*2);
00227       for (Index j=0; j<outerSize; ++j)
00228       {
00229         temp.startVec(j);
00230         for (typename OtherDerived::InnerIterator it(other.derived(), j); it; ++it)
00231         {
00232           Scalar v = it.value();
00233           if (v!=Scalar(0))
00234             temp.insertBackByOuterInner(Flip?it.index():j,Flip?j:it.index()) = v;
00235         }
00236       }
00237       temp.finalize();
00238 
00239       derived() = temp.markAsRValue();
00240     }
00241 
00242 
00243     template<typename OtherDerived>
00244     inline Derived& operator=(const SparseMatrixBase<OtherDerived>& other)
00245     {
00246 //       std::cout << typeid(OtherDerived).name() << "\n";
00247 //       std::cout << Flags << " " << OtherDerived::Flags << "\n";
00248       const bool transpose = (Flags & RowMajorBit) != (OtherDerived::Flags & RowMajorBit);
00249 //       std::cout << "eval transpose = " << transpose << "\n";
00250       const Index outerSize = (int(OtherDerived::Flags) & RowMajorBit) ? other.rows() : other.cols();
00251       if ((!transpose) && other.isRValue())
00252       {
00253         // eval without temporary
00254         derived().resize(other.rows(), other.cols());
00255         derived().setZero();
00256         derived().reserve((std::max)(this->rows(),this->cols())*2);
00257         for (Index j=0; j<outerSize; ++j)
00258         {
00259           derived().startVec(j);
00260           for (typename OtherDerived::InnerIterator it(other.derived(), j); it; ++it)
00261           {
00262             Scalar v = it.value();
00263             if (v!=Scalar(0))
00264               derived().insertBackByOuterInner(j,it.index()) = v;
00265           }
00266         }
00267         derived().finalize();
00268       }
00269       else
00270       {
00271         assignGeneric(other.derived());
00272       }
00273       return derived();
00274     }
00275 
00276     template<typename Lhs, typename Rhs>
00277     inline Derived& operator=(const SparseSparseProduct<Lhs,Rhs>& product);
00278 
00279     template<typename Lhs, typename Rhs>
00280     inline void _experimentalNewProduct(const Lhs& lhs, const Rhs& rhs);
00281 
00282     friend std::ostream & operator << (std::ostream & s, const SparseMatrixBase& m)
00283     {
00284       if (Flags&RowMajorBit)
00285       {
00286         for (Index row=0; row<m.outerSize(); ++row)
00287         {
00288           Index col = 0;
00289           for (typename Derived::InnerIterator it(m.derived(), row); it; ++it)
00290           {
00291             for ( ; col<it.index(); ++col)
00292               s << "0 ";
00293             s << it.value() << " ";
00294             ++col;
00295           }
00296           for ( ; col<m.cols(); ++col)
00297             s << "0 ";
00298           s << std::endl;
00299         }
00300       }
00301       else
00302       {
00303         if (m.cols() == 1) {
00304           Index row = 0;
00305           for (typename Derived::InnerIterator it(m.derived(), 0); it; ++it)
00306           {
00307             for ( ; row<it.index(); ++row)
00308               s << "0" << std::endl;
00309             s << it.value() << std::endl;
00310             ++row;
00311           }
00312           for ( ; row<m.rows(); ++row)
00313             s << "0" << std::endl;
00314         }
00315         else
00316         {
00317           SparseMatrix<Scalar, RowMajorBit> trans = m.derived();
00318           s << trans;
00319         }
00320       }
00321       return s;
00322     }
00323 
00324 //     const SparseCwiseUnaryOp<internal::scalar_opposite_op<typename internal::traits<Derived>::Scalar>,Derived> operator-() const;
00325 
00326 //     template<typename OtherDerived>
00327 //     const CwiseBinaryOp<internal::scalar_sum_op<typename internal::traits<Derived>::Scalar>, Derived, OtherDerived>
00328 //     operator+(const SparseMatrixBase<OtherDerived> &other) const;
00329 
00330 //     template<typename OtherDerived>
00331 //     const CwiseBinaryOp<internal::scalar_difference_op<typename internal::traits<Derived>::Scalar>, Derived, OtherDerived>
00332 //     operator-(const SparseMatrixBase<OtherDerived> &other) const;
00333 
00334     template<typename OtherDerived>
00335     Derived& operator+=(const SparseMatrixBase<OtherDerived>& other);
00336     template<typename OtherDerived>
00337     Derived& operator-=(const SparseMatrixBase<OtherDerived>& other);
00338 
00339 //     template<typename Lhs,typename Rhs>
00340 //     Derived& operator+=(const Flagged<Product<Lhs,Rhs,CacheFriendlyProduct>, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit>& other);
00341 
00342     Derived& operator*=(const Scalar& other);
00343     Derived& operator/=(const Scalar& other);
00344 
00345     #define EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE \
00346       CwiseBinaryOp< \
00347         internal::scalar_product_op< \
00348           typename internal::scalar_product_traits< \
00349             typename internal::traits<Derived>::Scalar, \
00350             typename internal::traits<OtherDerived>::Scalar \
00351           >::ReturnType \
00352         >, \
00353         Derived, \
00354         OtherDerived \
00355       >
00356 
00357     template<typename OtherDerived>
00358     EIGEN_STRONG_INLINE const EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE
00359     cwiseProduct(const MatrixBase<OtherDerived> &other) const;
00360 
00361 //     const SparseCwiseUnaryOp<internal::scalar_multiple_op<typename internal::traits<Derived>::Scalar>, Derived>
00362 //     operator*(const Scalar& scalar) const;
00363 //     const SparseCwiseUnaryOp<internal::scalar_quotient1_op<typename internal::traits<Derived>::Scalar>, Derived>
00364 //     operator/(const Scalar& scalar) const;
00365 
00366 //     inline friend const SparseCwiseUnaryOp<internal::scalar_multiple_op<typename internal::traits<Derived>::Scalar>, Derived>
00367 //     operator*(const Scalar& scalar, const SparseMatrixBase& matrix)
00368 //     { return matrix*scalar; }
00369 
00370 
00371     // sparse * sparse
00372     template<typename OtherDerived>
00373     const typename SparseSparseProductReturnType<Derived,OtherDerived>::Type
00374     operator*(const SparseMatrixBase<OtherDerived> &other) const;
00375 
00376     // sparse * diagonal
00377     template<typename OtherDerived>
00378     const SparseDiagonalProduct<Derived,OtherDerived>
00379     operator*(const DiagonalBase<OtherDerived> &other) const;
00380 
00381     // diagonal * sparse
00382     template<typename OtherDerived> friend
00383     const SparseDiagonalProduct<OtherDerived,Derived>
00384     operator*(const DiagonalBase<OtherDerived> &lhs, const SparseMatrixBase& rhs)
00385     { return SparseDiagonalProduct<OtherDerived,Derived>(lhs.derived(), rhs.derived()); }
00386 
00388     template<typename OtherDerived> friend
00389     const typename DenseSparseProductReturnType<OtherDerived,Derived>::Type
00390     operator*(const MatrixBase<OtherDerived>& lhs, const Derived& rhs)
00391     { return typename DenseSparseProductReturnType<OtherDerived,Derived>::Type(lhs.derived(),rhs); }
00392 
00394     template<typename OtherDerived>
00395     const typename SparseDenseProductReturnType<Derived,OtherDerived>::Type
00396     operator*(const MatrixBase<OtherDerived> &other) const;
00397 
00398     template<typename OtherDerived>
00399     Derived& operator*=(const SparseMatrixBase<OtherDerived>& other);
00400 
00401     #ifdef EIGEN2_SUPPORT
00402     // deprecated
00403     template<typename OtherDerived>
00404     typename internal::plain_matrix_type_column_major<OtherDerived>::type
00405     solveTriangular(const MatrixBase<OtherDerived>& other) const;
00406 
00407     // deprecated
00408     template<typename OtherDerived>
00409     void solveTriangularInPlace(MatrixBase<OtherDerived>& other) const;
00410 //     template<typename OtherDerived>
00411 //     void solveTriangularInPlace(SparseMatrixBase<OtherDerived>& other) const;
00412     #endif // EIGEN2_SUPPORT
00413 
00414     template<int Mode>
00415     inline const SparseTriangularView<Derived, Mode> triangularView() const;
00416 
00417     template<unsigned int UpLo> inline const SparseSelfAdjointView<Derived, UpLo> selfadjointView() const;
00418     template<unsigned int UpLo> inline SparseSelfAdjointView<Derived, UpLo> selfadjointView();
00419 
00420     template<typename OtherDerived> Scalar dot(const MatrixBase<OtherDerived>& other) const;
00421     template<typename OtherDerived> Scalar dot(const SparseMatrixBase<OtherDerived>& other) const;
00422     RealScalar squaredNorm() const;
00423     RealScalar norm()  const;
00424 //     const PlainObject normalized() const;
00425 //     void normalize();
00426 
00427     Transpose<Derived> transpose() { return derived(); }
00428     const Transpose<const Derived> transpose() const { return derived(); }
00429     // void transposeInPlace();
00430     const AdjointReturnType adjoint() const { return transpose(); }
00431 
00432     // sub-vector
00433     SparseInnerVectorSet<Derived,1> row(Index i);
00434     const SparseInnerVectorSet<Derived,1> row(Index i) const;
00435     SparseInnerVectorSet<Derived,1> col(Index j);
00436     const SparseInnerVectorSet<Derived,1> col(Index j) const;
00437     SparseInnerVectorSet<Derived,1> innerVector(Index outer);
00438     const SparseInnerVectorSet<Derived,1> innerVector(Index outer) const;
00439 
00440     // set of sub-vectors
00441     SparseInnerVectorSet<Derived,Dynamic> subrows(Index start, Index size);
00442     const SparseInnerVectorSet<Derived,Dynamic> subrows(Index start, Index size) const;
00443     SparseInnerVectorSet<Derived,Dynamic> subcols(Index start, Index size);
00444     const SparseInnerVectorSet<Derived,Dynamic> subcols(Index start, Index size) const;
00445     SparseInnerVectorSet<Derived,Dynamic> innerVectors(Index outerStart, Index outerSize);
00446     const SparseInnerVectorSet<Derived,Dynamic> innerVectors(Index outerStart, Index outerSize) const;
00447 
00448 //     typename BlockReturnType<Derived>::Type block(int startRow, int startCol, int blockRows, int blockCols);
00449 //     const typename BlockReturnType<Derived>::Type
00450 //     block(int startRow, int startCol, int blockRows, int blockCols) const;
00451 //
00452 //     typename BlockReturnType<Derived>::SubVectorType segment(int start, int size);
00453 //     const typename BlockReturnType<Derived>::SubVectorType segment(int start, int size) const;
00454 //
00455 //     typename BlockReturnType<Derived,Dynamic>::SubVectorType start(int size);
00456 //     const typename BlockReturnType<Derived,Dynamic>::SubVectorType start(int size) const;
00457 //
00458 //     typename BlockReturnType<Derived,Dynamic>::SubVectorType end(int size);
00459 //     const typename BlockReturnType<Derived,Dynamic>::SubVectorType end(int size) const;
00460 //
00461 //     template<int BlockRows, int BlockCols>
00462 //     typename BlockReturnType<Derived, BlockRows, BlockCols>::Type block(int startRow, int startCol);
00463 //     template<int BlockRows, int BlockCols>
00464 //     const typename BlockReturnType<Derived, BlockRows, BlockCols>::Type block(int startRow, int startCol) const;
00465 
00466 //     template<int Size> typename BlockReturnType<Derived,Size>::SubVectorType start(void);
00467 //     template<int Size> const typename BlockReturnType<Derived,Size>::SubVectorType start() const;
00468 
00469 //     template<int Size> typename BlockReturnType<Derived,Size>::SubVectorType end();
00470 //     template<int Size> const typename BlockReturnType<Derived,Size>::SubVectorType end() const;
00471 
00472 //     template<int Size> typename BlockReturnType<Derived,Size>::SubVectorType segment(int start);
00473 //     template<int Size> const typename BlockReturnType<Derived,Size>::SubVectorType segment(int start) const;
00474 
00475 //     Diagonal<Derived> diagonal();
00476 //     const Diagonal<Derived> diagonal() const;
00477 
00478 //     template<unsigned int Mode> Part<Derived, Mode> part();
00479 //     template<unsigned int Mode> const Part<Derived, Mode> part() const;
00480 
00481 
00482 //     static const ConstantReturnType Constant(int rows, int cols, const Scalar& value);
00483 //     static const ConstantReturnType Constant(int size, const Scalar& value);
00484 //     static const ConstantReturnType Constant(const Scalar& value);
00485 
00486 //     template<typename CustomNullaryOp>
00487 //     static const CwiseNullaryOp<CustomNullaryOp, Derived> NullaryExpr(int rows, int cols, const CustomNullaryOp& func);
00488 //     template<typename CustomNullaryOp>
00489 //     static const CwiseNullaryOp<CustomNullaryOp, Derived> NullaryExpr(int size, const CustomNullaryOp& func);
00490 //     template<typename CustomNullaryOp>
00491 //     static const CwiseNullaryOp<CustomNullaryOp, Derived> NullaryExpr(const CustomNullaryOp& func);
00492 
00493 //     static const ConstantReturnType Zero(int rows, int cols);
00494 //     static const ConstantReturnType Zero(int size);
00495 //     static const ConstantReturnType Zero();
00496 //     static const ConstantReturnType Ones(int rows, int cols);
00497 //     static const ConstantReturnType Ones(int size);
00498 //     static const ConstantReturnType Ones();
00499 //     static const IdentityReturnType Identity();
00500 //     static const IdentityReturnType Identity(int rows, int cols);
00501 //     static const BasisReturnType Unit(int size, int i);
00502 //     static const BasisReturnType Unit(int i);
00503 //     static const BasisReturnType UnitX();
00504 //     static const BasisReturnType UnitY();
00505 //     static const BasisReturnType UnitZ();
00506 //     static const BasisReturnType UnitW();
00507 
00508 //     const DiagonalMatrix<Derived> asDiagonal() const;
00509 
00510 //     Derived& setConstant(const Scalar& value);
00511 //     Derived& setZero();
00512 //     Derived& setOnes();
00513 //     Derived& setRandom();
00514 //     Derived& setIdentity();
00515 
00517       template<typename DenseDerived>
00518       void evalTo(MatrixBase<DenseDerived>& dst) const
00519       {
00520         dst.setZero();
00521         for (Index j=0; j<outerSize(); ++j)
00522           for (typename Derived::InnerIterator i(derived(),j); i; ++i)
00523             dst.coeffRef(i.row(),i.col()) = i.value();
00524       }
00525 
00526       Matrix<Scalar,RowsAtCompileTime,ColsAtCompileTime> toDense() const
00527       {
00528         return derived();
00529       }
00530 
00531     template<typename OtherDerived>
00532     bool isApprox(const SparseMatrixBase<OtherDerived>& other,
00533                   RealScalar prec = NumTraits<Scalar>::dummy_precision()) const
00534     { return toDense().isApprox(other.toDense(),prec); }
00535 
00536     template<typename OtherDerived>
00537     bool isApprox(const MatrixBase<OtherDerived>& other,
00538                   RealScalar prec = NumTraits<Scalar>::dummy_precision()) const
00539     { return toDense().isApprox(other,prec); }
00540 //     bool isMuchSmallerThan(const RealScalar& other,
00541 //                            RealScalar prec = NumTraits<Scalar>::dummy_precision()) const;
00542 //     template<typename OtherDerived>
00543 //     bool isMuchSmallerThan(const MatrixBase<OtherDerived>& other,
00544 //                            RealScalar prec = NumTraits<Scalar>::dummy_precision()) const;
00545 
00546 //     bool isApproxToConstant(const Scalar& value, RealScalar prec = NumTraits<Scalar>::dummy_precision()) const;
00547 //     bool isZero(RealScalar prec = NumTraits<Scalar>::dummy_precision()) const;
00548 //     bool isOnes(RealScalar prec = NumTraits<Scalar>::dummy_precision()) const;
00549 //     bool isIdentity(RealScalar prec = NumTraits<Scalar>::dummy_precision()) const;
00550 //     bool isDiagonal(RealScalar prec = NumTraits<Scalar>::dummy_precision()) const;
00551 
00552 //     bool isUpper(RealScalar prec = NumTraits<Scalar>::dummy_precision()) const;
00553 //     bool isLower(RealScalar prec = NumTraits<Scalar>::dummy_precision()) const;
00554 
00555 //     template<typename OtherDerived>
00556 //     bool isOrthogonal(const MatrixBase<OtherDerived>& other,
00557 //                       RealScalar prec = NumTraits<Scalar>::dummy_precision()) const;
00558 //     bool isUnitary(RealScalar prec = NumTraits<Scalar>::dummy_precision()) const;
00559 
00560 //     template<typename OtherDerived>
00561 //     inline bool operator==(const MatrixBase<OtherDerived>& other) const
00562 //     { return (cwise() == other).all(); }
00563 
00564 //     template<typename OtherDerived>
00565 //     inline bool operator!=(const MatrixBase<OtherDerived>& other) const
00566 //     { return (cwise() != other).any(); }
00567 
00568 
00569 //     template<typename NewType>
00570 //     const SparseCwiseUnaryOp<internal::scalar_cast_op<typename internal::traits<Derived>::Scalar, NewType>, Derived> cast() const;
00571 
00577     inline const typename internal::eval<Derived>::type eval() const
00578     { return typename internal::eval<Derived>::type(derived()); }
00579 
00580 //     template<typename OtherDerived>
00581 //     void swap(MatrixBase<OtherDerived> const & other);
00582 
00583 //     template<unsigned int Added>
00584 //     const SparseFlagged<Derived, Added, 0> marked() const;
00585 //     const Flagged<Derived, 0, EvalBeforeNestingBit | EvalBeforeAssigningBit> lazy() const;
00586 
00592 //     inline int stride(void) const { return derived().stride(); }
00593 
00594 // FIXME
00595 //     ConjugateReturnType conjugate() const;
00596 //     const RealReturnType real() const;
00597 //     const ImagReturnType imag() const;
00598 
00599 //     template<typename CustomUnaryOp>
00600 //     const SparseCwiseUnaryOp<CustomUnaryOp, Derived> unaryExpr(const CustomUnaryOp& func = CustomUnaryOp()) const;
00601 
00602 //     template<typename CustomBinaryOp, typename OtherDerived>
00603 //     const CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>
00604 //     binaryExpr(const MatrixBase<OtherDerived> &other, const CustomBinaryOp& func = CustomBinaryOp()) const;
00605 
00606 
00607     Scalar sum() const;
00608 //     Scalar trace() const;
00609 
00610 //     typename internal::traits<Derived>::Scalar minCoeff() const;
00611 //     typename internal::traits<Derived>::Scalar maxCoeff() const;
00612 
00613 //     typename internal::traits<Derived>::Scalar minCoeff(int* row, int* col = 0) const;
00614 //     typename internal::traits<Derived>::Scalar maxCoeff(int* row, int* col = 0) const;
00615 
00616 //     template<typename BinaryOp>
00617 //     typename internal::result_of<BinaryOp(typename internal::traits<Derived>::Scalar)>::type
00618 //     redux(const BinaryOp& func) const;
00619 
00620 //     template<typename Visitor>
00621 //     void visit(Visitor& func) const;
00622 
00623 
00624 //     const SparseCwise<Derived> cwise() const;
00625 //     SparseCwise<Derived> cwise();
00626 
00627 //     inline const WithFormat<Derived> format(const IOFormat& fmt) const;
00628 
00630     /*
00631     bool all(void) const;
00632     bool any(void) const;
00633 
00634     const VectorwiseOp<Derived,Horizontal> rowwise() const;
00635     const VectorwiseOp<Derived,Vertical> colwise() const;
00636 
00637     static const CwiseNullaryOp<internal::scalar_random_op<Scalar>,Derived> Random(int rows, int cols);
00638     static const CwiseNullaryOp<internal::scalar_random_op<Scalar>,Derived> Random(int size);
00639     static const CwiseNullaryOp<internal::scalar_random_op<Scalar>,Derived> Random();
00640 
00641     template<typename ThenDerived,typename ElseDerived>
00642     const Select<Derived,ThenDerived,ElseDerived>
00643     select(const MatrixBase<ThenDerived>& thenMatrix,
00644            const MatrixBase<ElseDerived>& elseMatrix) const;
00645 
00646     template<typename ThenDerived>
00647     inline const Select<Derived,ThenDerived, typename ThenDerived::ConstantReturnType>
00648     select(const MatrixBase<ThenDerived>& thenMatrix, typename ThenDerived::Scalar elseScalar) const;
00649 
00650     template<typename ElseDerived>
00651     inline const Select<Derived, typename ElseDerived::ConstantReturnType, ElseDerived >
00652     select(typename ElseDerived::Scalar thenScalar, const MatrixBase<ElseDerived>& elseMatrix) const;
00653 
00654     template<int p> RealScalar lpNorm() const;
00655     */
00656 
00657 
00658 //     template<typename OtherDerived>
00659 //     Scalar dot(const MatrixBase<OtherDerived>& other) const
00660 //     {
00661 //       EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00662 //       EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived)
00663 //       EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename OtherDerived::Scalar>::value),
00664 //         YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
00665 //
00666 //       eigen_assert(derived().size() == other.size());
00667 //       // short version, but the assembly looks more complicated because
00668 //       // of the CwiseBinaryOp iterator complexity
00669 //       // return res = (derived().cwise() * other.derived().conjugate()).sum();
00670 //
00671 //       // optimized, generic version
00672 //       typename Derived::InnerIterator i(derived(),0);
00673 //       typename OtherDerived::InnerIterator j(other.derived(),0);
00674 //       Scalar res = 0;
00675 //       while (i && j)
00676 //       {
00677 //         if (i.index()==j.index())
00678 //         {
00679 // //           std::cerr << i.value() << " * " << j.value() << "\n";
00680 //           res += i.value() * internal::conj(j.value());
00681 //           ++i; ++j;
00682 //         }
00683 //         else if (i.index()<j.index())
00684 //           ++i;
00685 //         else
00686 //           ++j;
00687 //       }
00688 //       return res;
00689 //     }
00690 //
00691 //     Scalar sum() const
00692 //     {
00693 //       Scalar res = 0;
00694 //       for (typename Derived::InnerIterator iter(*this,0); iter; ++iter)
00695 //       {
00696 //         res += iter.value();
00697 //       }
00698 //       return res;
00699 //     }
00700 
00701   protected:
00702 
00703     bool m_isRValue;
00704 };
00705 
00706 #endif // EIGEN_SPARSEMATRIXBASE_H


libicr
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:33:37