00001 // This file is part of Eigen, a lightweight C++ template library 00002 // for linear algebra. Eigen itself is part of the KDE project. 00003 // 00004 // Copyright (C) 2008 Gael Guennebaud <g.gael@free.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_SPARSETRANSPOSE_H 00026 #define EIGEN_SPARSETRANSPOSE_H 00027 00028 template<typename MatrixType> 00029 struct ei_traits<SparseTranspose<MatrixType> > : ei_traits<Transpose<MatrixType> > 00030 {}; 00031 00032 template<typename MatrixType> class SparseTranspose 00033 : public SparseMatrixBase<SparseTranspose<MatrixType> > 00034 { 00035 public: 00036 00037 EIGEN_GENERIC_PUBLIC_INTERFACE(SparseTranspose) 00038 00039 class InnerIterator; 00040 class ReverseInnerIterator; 00041 00042 inline SparseTranspose(const MatrixType& matrix) : m_matrix(matrix) {} 00043 00044 //EIGEN_INHERIT_ASSIGNMENT_OPERATORS(SparseTranspose) 00045 00046 inline int rows() const { return m_matrix.cols(); } 00047 inline int cols() const { return m_matrix.rows(); } 00048 inline int nonZeros() const { return m_matrix.nonZeros(); } 00049 00050 // FIXME should be keep them ? 00051 inline Scalar& coeffRef(int row, int col) 00052 { return m_matrix.const_cast_derived().coeffRef(col, row); } 00053 00054 inline const Scalar coeff(int row, int col) const 00055 { return m_matrix.coeff(col, row); } 00056 00057 inline const Scalar coeff(int index) const 00058 { return m_matrix.coeff(index); } 00059 00060 inline Scalar& coeffRef(int index) 00061 { return m_matrix.const_cast_derived().coeffRef(index); } 00062 00063 protected: 00064 const typename MatrixType::Nested m_matrix; 00065 00066 private: 00067 SparseTranspose& operator=(const SparseTranspose&); 00068 }; 00069 00070 template<typename MatrixType> class SparseTranspose<MatrixType>::InnerIterator : public MatrixType::InnerIterator 00071 { 00072 public: 00073 EIGEN_STRONG_INLINE InnerIterator(const SparseTranspose& trans, int outer) 00074 : MatrixType::InnerIterator(trans.m_matrix, outer) 00075 {} 00076 00077 private: 00078 InnerIterator& operator=(const InnerIterator&); 00079 }; 00080 00081 template<typename MatrixType> class SparseTranspose<MatrixType>::ReverseInnerIterator : public MatrixType::ReverseInnerIterator 00082 { 00083 public: 00084 00085 EIGEN_STRONG_INLINE ReverseInnerIterator(const SparseTranspose& xpr, int outer) 00086 : MatrixType::ReverseInnerIterator(xpr.m_matrix, outer) 00087 {} 00088 }; 00089 00090 #endif // EIGEN_SPARSETRANSPOSE_H