diff options
-rw-r--r-- | doc/tutorial.cpp | 2 | ||||
-rw-r--r-- | src/All (renamed from src/All.h) | 13 | ||||
-rw-r--r-- | src/CMakeLists.txt | 8 | ||||
-rw-r--r-- | src/Core | 32 | ||||
-rw-r--r-- | src/Manip | 33 | ||||
-rw-r--r-- | src/internal/Block.h (renamed from src/Block.h) | 0 | ||||
-rw-r--r-- | src/internal/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/internal/Matrix.h (renamed from src/Matrix.h) | 4 | ||||
-rw-r--r-- | src/internal/MatrixAlias.h | 116 | ||||
-rw-r--r-- | src/internal/MatrixBase.h (renamed from src/MatrixBase.h) | 134 | ||||
-rw-r--r-- | src/internal/MatrixOps.h (renamed from src/MatrixOps.h) | 0 | ||||
-rw-r--r-- | src/internal/MatrixRef.h | 76 | ||||
-rw-r--r-- | src/internal/MatrixXpr.h (renamed from src/MatrixXpr.h) | 0 | ||||
-rw-r--r-- | src/internal/Minor.h (renamed from src/Minor.h) | 0 | ||||
-rw-r--r-- | src/internal/RowAndCol.h (renamed from src/RowAndCol.h) | 0 | ||||
-rw-r--r-- | src/internal/ScalarOps.h (renamed from src/ScalarOps.h) | 0 | ||||
-rw-r--r-- | src/internal/Util.h (renamed from src/Util.h) | 4 | ||||
-rw-r--r-- | src/internal/Vector.h (renamed from src/Vector.h) | 3 | ||||
-rw-r--r-- | test/main.h | 10 | ||||
-rw-r--r-- | test/matrixmanip.cpp | 2 | ||||
-rw-r--r-- | test/matrixops.cpp | 2 | ||||
-rw-r--r-- | test/vectorops.cpp | 2 |
22 files changed, 294 insertions, 153 deletions
diff --git a/doc/tutorial.cpp b/doc/tutorial.cpp index 967f0a544..3b4489522 100644 --- a/doc/tutorial.cpp +++ b/doc/tutorial.cpp @@ -1,4 +1,4 @@ -#include"../src/All.h" +#include "../src/All" using namespace std; using namespace Eigen; @@ -23,13 +23,10 @@ // License. This exception does not invalidate any other reasons why a work // based on this file might be covered by the GNU General Public License. -#ifndef EIGEN_EIGEN_H -#define EIGEN_EIGEN_H +#ifndef EIGEN_ALL_H +#define EIGEN_ALL_H -#include"Matrix.h" -#include"Vector.h" -#include"RowAndCol.h" -#include"Minor.h" -#include"Block.h" +#include "Core" +#include "Manip" -#endif // EIGEN_EIGEN_H +#endif // EIGEN_ALL_H diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5459d7453..d5cdda888 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,8 @@ -FILE(GLOB Eigen_SRCS "*.h") +set(Eigen_SRCS + All + Core + Manip +) SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/eigen2" @@ -10,3 +14,5 @@ INSTALL(FILES ${Eigen_SRCS} DESTINATION ${INCLUDE_INSTALL_DIR} ) + +add_subdirectory(internal)
\ No newline at end of file diff --git a/src/Core b/src/Core new file mode 100644 index 000000000..767fb73e0 --- /dev/null +++ b/src/Core @@ -0,0 +1,32 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. Eigen itself is part of the KDE project. +// +// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> +// +// Eigen is free software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 or (at your option) any later version. +// +// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along +// with Eigen; if not, write to the Free Software Foundation, Inc., 51 +// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +// +// As a special exception, if other files instantiate templates or use macros +// or functions from this file, or you compile this file and link it +// with other works to produce a work based on this file, this file does not +// by itself cause the resulting work to be covered by the GNU General Public +// License. This exception does not invalidate any other reasons why a work +// based on this file might be covered by the GNU General Public License. + +#ifndef EIGEN_CORE_H +#define EIGEN_CORE_H + +#include "internal/Vector.h" +#include "internal/Matrix.h" + +#endif // EIGEN_CORE_H diff --git a/src/Manip b/src/Manip new file mode 100644 index 000000000..0bfc4f14b --- /dev/null +++ b/src/Manip @@ -0,0 +1,33 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. Eigen itself is part of the KDE project. +// +// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> +// +// Eigen is free software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 or (at your option) any later version. +// +// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along +// with Eigen; if not, write to the Free Software Foundation, Inc., 51 +// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +// +// As a special exception, if other files instantiate templates or use macros +// or functions from this file, or you compile this file and link it +// with other works to produce a work based on this file, this file does not +// by itself cause the resulting work to be covered by the GNU General Public +// License. This exception does not invalidate any other reasons why a work +// based on this file might be covered by the GNU General Public License. + +#ifndef EIGEN_MANIP_H +#define EIGEN_MANIP_H + +#include "internal/RowAndCol.h" +#include "internal/Block.h" +#include "internal/Minor.h" + +#endif // EIGEN_MANIP_H diff --git a/src/Block.h b/src/internal/Block.h index 68c4439cd..68c4439cd 100644 --- a/src/Block.h +++ b/src/internal/Block.h diff --git a/src/internal/CMakeLists.txt b/src/internal/CMakeLists.txt new file mode 100644 index 000000000..c3643b916 --- /dev/null +++ b/src/internal/CMakeLists.txt @@ -0,0 +1,6 @@ +FILE(GLOB Eigen_internal_SRCS "*.h") + +INSTALL(FILES + ${Eigen_internal_SRCS} + DESTINATION ${INCLUDE_INSTALL_DIR}/internal + ) diff --git a/src/Matrix.h b/src/internal/Matrix.h index 8ff819902..be7c22bc3 100644 --- a/src/Matrix.h +++ b/src/internal/Matrix.h @@ -176,8 +176,4 @@ class MatrixX : public MatrixBase< MatrixX<T> > } // namespace Eigen -#include"MatrixOps.h" -#include"ScalarOps.h" -#include"RowAndCol.h" - #endif // EIGEN_MATRIX_H diff --git a/src/internal/MatrixAlias.h b/src/internal/MatrixAlias.h new file mode 100644 index 000000000..868011321 --- /dev/null +++ b/src/internal/MatrixAlias.h @@ -0,0 +1,116 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. Eigen itself is part of the KDE project. +// +// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> +// +// Eigen is free software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 or (at your option) any later version. +// +// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along +// with Eigen; if not, write to the Free Software Foundation, Inc., 51 +// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +// +// As a special exception, if other files instantiate templates or use macros +// or functions from this file, or you compile this file and link it +// with other works to produce a work based on this file, this file does not +// by itself cause the resulting work to be covered by the GNU General Public +// License. This exception does not invalidate any other reasons why a work +// based on this file might be covered by the GNU General Public License. + +#ifndef EIGEN_MATRIXALIAS_H +#define EIGEN_MATRIXALIAS_H + +namespace Eigen +{ + +template<typename Derived> class MatrixAlias +{ + public: + typedef typename Derived::Scalar Scalar; + typedef MatrixRef<MatrixAlias<Derived> > Ref; + typedef MatrixXpr<Ref> Xpr; + + MatrixAlias(Derived& matrix) : m_aliased(matrix), m_tmp(matrix) {} + MatrixAlias(const MatrixAlias& other) : m_aliased(other.m_aliased), m_tmp(other.m_tmp) {} + + ~MatrixAlias() + { + m_aliased.xpr() = m_tmp; + } + + Ref ref() + { + return Ref(*this); + } + + Xpr xpr() + { + return Xpr(ref()); + } + + static bool hasDynamicNumRows() + { + return MatrixBase<Derived>::hasDynamicNumRows(); + } + + static bool hasDynamicNumCols() + { + return MatrixBase<Derived>::hasDynamicNumCols(); + } + + int rows() const { return m_tmp.rows(); } + int cols() const { return m_tmp.cols(); } + + Scalar& write(int row, int col) + { + return m_tmp.write(row, col); + } + + MatrixXpr<MatrixRow<Xpr> > row(int i) { return xpr().row(i); }; + MatrixXpr<MatrixCol<Xpr> > col(int i) { return xpr().col(i); }; + MatrixXpr<MatrixMinor<Xpr> > minor(int row, int col) { return xpr().minor(row, col); }; + MatrixXpr<MatrixBlock<Xpr> > + block(int startRow, int endRow, int startCol = 0, int endCol = 0) + { + return xpr().block(startRow, endRow, startCol, endCol); + } + + template<typename XprContent> + void operator=(const MatrixXpr<XprContent> &other) + { + xpr() = other; + } + + template<typename XprContent> + void operator+=(const MatrixXpr<XprContent> &other) + { + xpr() += other; + } + + template<typename XprContent> + void operator-=(const MatrixXpr<XprContent> &other) + { + xpr() -= other; + } + + protected: + MatrixRef<MatrixBase<Derived> > m_aliased; + Derived m_tmp; +}; + +template<typename Derived> +typename MatrixBase<Derived>::Alias +MatrixBase<Derived>::alias() +{ + return Alias(*static_cast<Derived*>(this)); +} + +} // namespace Eigen + +#endif // EIGEN_MATRIXALIAS_H diff --git a/src/MatrixBase.h b/src/internal/MatrixBase.h index 5859a14cc..910cc4ac0 100644 --- a/src/MatrixBase.h +++ b/src/internal/MatrixBase.h @@ -26,54 +26,13 @@ #ifndef EIGEN_MATRIXBASE_H #define EIGEN_MATRIXBASE_H -#include"Util.h" -#include"MatrixXpr.h" +#include "Util.h" +#include "MatrixXpr.h" +#include "MatrixRef.h" namespace Eigen { -template<typename MatrixType> class MatrixRef -{ - public: - typedef typename ForwardDecl<MatrixType>::Scalar Scalar; - typedef MatrixXpr<MatrixRef<MatrixType> > Xpr; - - MatrixRef(MatrixType& matrix) : m_matrix(matrix) {} - MatrixRef(const MatrixRef& other) : m_matrix(other.m_matrix) {} - ~MatrixRef() {} - - static bool hasDynamicNumRows() - { - return MatrixType::hasDynamicNumRows(); - } - - static bool hasDynamicNumCols() - { - return MatrixType::hasDynamicNumCols(); - } - - int rows() const { return m_matrix.rows(); } - int cols() const { return m_matrix.cols(); } - - const Scalar& read(int row, int col) const - { - return m_matrix.read(row, col); - } - - Scalar& write(int row, int col) - { - return m_matrix.write(row, col); - } - - Xpr xpr() - { - return Xpr(*this); - } - - protected: - MatrixType& m_matrix; -}; - template<typename Derived> class MatrixBase { @@ -232,88 +191,11 @@ std::ostream & operator << (std::ostream & s, return s; } -template<typename Derived> class MatrixAlias -{ - public: - typedef typename Derived::Scalar Scalar; - typedef MatrixRef<MatrixAlias<Derived> > Ref; - typedef MatrixXpr<Ref> Xpr; - - MatrixAlias(Derived& matrix) : m_aliased(matrix), m_tmp(matrix) {} - MatrixAlias(const MatrixAlias& other) : m_aliased(other.m_aliased), m_tmp(other.m_tmp) {} - - ~MatrixAlias() - { - m_aliased.xpr() = m_tmp; - } - - Ref ref() - { - return Ref(*this); - } - - Xpr xpr() - { - return Xpr(ref()); - } - - static bool hasDynamicNumRows() - { - return MatrixBase<Derived>::hasDynamicNumRows(); - } - - static bool hasDynamicNumCols() - { - return MatrixBase<Derived>::hasDynamicNumCols(); - } - - int rows() const { return m_tmp.rows(); } - int cols() const { return m_tmp.cols(); } - - Scalar& write(int row, int col) - { - return m_tmp.write(row, col); - } - - MatrixXpr<MatrixRow<Xpr> > row(int i) { return xpr().row(i); }; - MatrixXpr<MatrixCol<Xpr> > col(int i) { return xpr().col(i); }; - MatrixXpr<MatrixMinor<Xpr> > minor(int row, int col) { return xpr().minor(row, col); }; - MatrixXpr<MatrixBlock<Xpr> > - block(int startRow, int endRow, int startCol = 0, int endCol = 0) - { - return xpr().block(startRow, endRow, startCol, endCol); - } - - template<typename XprContent> - void operator=(const MatrixXpr<XprContent> &other) - { - xpr() = other; - } - - template<typename XprContent> - void operator+=(const MatrixXpr<XprContent> &other) - { - xpr() += other; - } - - template<typename XprContent> - void operator-=(const MatrixXpr<XprContent> &other) - { - xpr() -= other; - } - - protected: - MatrixRef<MatrixBase<Derived> > m_aliased; - Derived m_tmp; -}; - -template<typename Derived> -typename MatrixBase<Derived>::Alias -MatrixBase<Derived>::alias() -{ - return Alias(*static_cast<Derived*>(this)); -} - } // namespace Eigen +#include "MatrixAlias.h" +#include "MatrixOps.h" +#include "ScalarOps.h" +#include "RowAndCol.h" + #endif // EIGEN_MATRIXBASE_H diff --git a/src/MatrixOps.h b/src/internal/MatrixOps.h index e76e64c85..e76e64c85 100644 --- a/src/MatrixOps.h +++ b/src/internal/MatrixOps.h diff --git a/src/internal/MatrixRef.h b/src/internal/MatrixRef.h new file mode 100644 index 000000000..0123c535c --- /dev/null +++ b/src/internal/MatrixRef.h @@ -0,0 +1,76 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. Eigen itself is part of the KDE project. +// +// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> +// +// Eigen is free software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 or (at your option) any later version. +// +// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along +// with Eigen; if not, write to the Free Software Foundation, Inc., 51 +// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +// +// As a special exception, if other files instantiate templates or use macros +// or functions from this file, or you compile this file and link it +// with other works to produce a work based on this file, this file does not +// by itself cause the resulting work to be covered by the GNU General Public +// License. This exception does not invalidate any other reasons why a work +// based on this file might be covered by the GNU General Public License. + +#ifndef EIGEN_MATRIXREF_H +#define EIGEN_MATRIXREF_H + +namespace Eigen +{ + +template<typename MatrixType> class MatrixRef +{ + public: + typedef typename ForwardDecl<MatrixType>::Scalar Scalar; + typedef MatrixXpr<MatrixRef<MatrixType> > Xpr; + + MatrixRef(MatrixType& matrix) : m_matrix(matrix) {} + MatrixRef(const MatrixRef& other) : m_matrix(other.m_matrix) {} + ~MatrixRef() {} + + static bool hasDynamicNumRows() + { + return MatrixType::hasDynamicNumRows(); + } + + static bool hasDynamicNumCols() + { + return MatrixType::hasDynamicNumCols(); + } + + int rows() const { return m_matrix.rows(); } + int cols() const { return m_matrix.cols(); } + + const Scalar& read(int row, int col) const + { + return m_matrix.read(row, col); + } + + Scalar& write(int row, int col) + { + return m_matrix.write(row, col); + } + + Xpr xpr() + { + return Xpr(*this); + } + + protected: + MatrixType& m_matrix; +}; + +} // namespace Eigen + +#endif // EIGEN_MATRIXREF_H diff --git a/src/MatrixXpr.h b/src/internal/MatrixXpr.h index fe890d16c..fe890d16c 100644 --- a/src/MatrixXpr.h +++ b/src/internal/MatrixXpr.h diff --git a/src/Minor.h b/src/internal/Minor.h index da0d759de..da0d759de 100644 --- a/src/Minor.h +++ b/src/internal/Minor.h diff --git a/src/RowAndCol.h b/src/internal/RowAndCol.h index 5da3cfa23..5da3cfa23 100644 --- a/src/RowAndCol.h +++ b/src/internal/RowAndCol.h diff --git a/src/ScalarOps.h b/src/internal/ScalarOps.h index 01772569a..01772569a 100644 --- a/src/ScalarOps.h +++ b/src/internal/ScalarOps.h diff --git a/src/Util.h b/src/internal/Util.h index f1b51bbe1..31b94b421 100644 --- a/src/Util.h +++ b/src/internal/Util.h @@ -26,8 +26,8 @@ #ifndef EIGEN_UTIL_H #define EIGEN_UTIL_H -#include<iostream> -#include<cassert> +#include <iostream> +#include <cassert> #undef minor diff --git a/src/Vector.h b/src/internal/Vector.h index ae43a50c7..0d1c719c5 100644 --- a/src/Vector.h +++ b/src/internal/Vector.h @@ -187,7 +187,4 @@ class VectorX : public MatrixBase<VectorX<T> > } // namespace Eigen -#include"MatrixOps.h" -#include"ScalarOps.h" - #endif // EIGEN_VECTOR_H diff --git a/test/main.h b/test/main.h index ea7e22f2b..45cabd369 100644 --- a/test/main.h +++ b/test/main.h @@ -26,11 +26,11 @@ #ifndef EIGEN_TEST_MAIN_H #define EIGEN_TEST_MAIN_H -#include<QtTest/QtTest> -#include<All.h> -#include<complex> -#include<cstdlib> -#include<ctime> +#include <QtTest/QtTest> +#include <All> +#include <complex> +#include <cstdlib> +#include <ctime> using namespace std; using namespace Eigen; diff --git a/test/matrixmanip.cpp b/test/matrixmanip.cpp index b3413212a..90ddcaca9 100644 --- a/test/matrixmanip.cpp +++ b/test/matrixmanip.cpp @@ -23,7 +23,7 @@ // License. This exception does not invalidate any other reasons why a work // based on this file might be covered by the GNU General Public License. -#include"main.h" +#include "main.h" template<typename MatrixType> void matrixManip(const MatrixType& m) { diff --git a/test/matrixops.cpp b/test/matrixops.cpp index 56b252287..b8fd122c3 100644 --- a/test/matrixops.cpp +++ b/test/matrixops.cpp @@ -23,7 +23,7 @@ // License. This exception does not invalidate any other reasons why a work // based on this file might be covered by the GNU General Public License. -#include"main.h" +#include "main.h" template<typename MatrixType1, typename MatrixType2> void matrixOps(const MatrixType1& m1, const MatrixType2& m2) diff --git a/test/vectorops.cpp b/test/vectorops.cpp index de0f03e6f..33aa72178 100644 --- a/test/vectorops.cpp +++ b/test/vectorops.cpp @@ -23,7 +23,7 @@ // License. This exception does not invalidate any other reasons why a work // based on this file might be covered by the GNU General Public License. -#include"main.h" +#include "main.h" template<typename VectorType> void vectorOps(const VectorType& v) { |