mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-09 18:29:03 +08:00
reorganize header files, split MatrixBase into smaller files.
expose only a few meta-headers to the user, the rest moves to a internal/ subdirectory
This commit is contained in:
parent
3b727ef939
commit
1af61c6ff0
@ -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
|
@ -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)
|
32
src/Core
Normal file
32
src/Core
Normal file
@ -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
|
33
src/Manip
Normal file
33
src/Manip
Normal file
@ -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
|
6
src/internal/CMakeLists.txt
Normal file
6
src/internal/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
FILE(GLOB Eigen_internal_SRCS "*.h")
|
||||
|
||||
INSTALL(FILES
|
||||
${Eigen_internal_SRCS}
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/internal
|
||||
)
|
@ -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
|
116
src/internal/MatrixAlias.h
Normal file
116
src/internal/MatrixAlias.h
Normal file
@ -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
|
@ -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
|
76
src/internal/MatrixRef.h
Normal file
76
src/internal/MatrixRef.h
Normal file
@ -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
|
@ -26,8 +26,8 @@
|
||||
#ifndef EIGEN_UTIL_H
|
||||
#define EIGEN_UTIL_H
|
||||
|
||||
#include<iostream>
|
||||
#include<cassert>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
#undef minor
|
||||
|
@ -187,7 +187,4 @@ class VectorX : public MatrixBase<VectorX<T> >
|
||||
|
||||
} // namespace Eigen
|
||||
|
||||
#include"MatrixOps.h"
|
||||
#include"ScalarOps.h"
|
||||
|
||||
#endif // EIGEN_VECTOR_H
|
10
test/main.h
10
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;
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user