Democracy 1 - 0 Dictatorship

After huge thread on eigen mailing list, it appears that i'm the
only one in favor of prefix Ei. Everybody else prefers namespace
Eigen like we did in Eigen 1. So, revert.

Also add a macro USING_EIGEN_DATA_TYPES that application programmers
can use to automatically do "using"on the Matrix class and its
matrix/vector typedefs:
using Eigen::Matrix;
using Eigen::Matrix2d;
using Eigen::Vector2d;
... (the list of typedefs is really long).

thanks to the suffixes, the Vector typedefs aren't really polluting.

CCMAIL:eigen@lists.tuxfamily.org

P.S. Danny, please skip this one :) I know you already reported the
namespace->prefix move, now that one would be too much noise :)
This commit is contained in:
Benoit Jacob 2007-10-11 20:14:01 +00:00
parent 3c98677376
commit 61de15f361
32 changed files with 531 additions and 497 deletions

View File

@ -1,4 +1,4 @@
project(Eigen) project(gen)
OPTION(BUILD_TESTS "Build tests" OFF) OPTION(BUILD_TESTS "Build tests" OFF)
OPTION(BUILD_EXAMPLES "Build examples" OFF) OPTION(BUILD_EXAMPLES "Build examples" OFF)

View File

@ -1,23 +1,25 @@
#include "../src/Core.h" #include "../src/Core.h"
USING_EIGEN_DATA_TYPES
using namespace std; using namespace std;
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
void foo(const EiObject<Scalar, Derived>& m) void foo(const Eigen::Object<Scalar, Derived>& m)
{ {
cout << "Here's m:" << endl << m << endl; cout << "Here's m:" << endl << m << endl;
} }
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
EiScalarProduct<Derived> Eigen::ScalarProduct<Derived>
twice(const EiObject<Scalar, Derived>& m) twice(const Eigen::Object<Scalar, Derived>& m)
{ {
return 2 * m; return 2 * m;
} }
int main(int, char**) int main(int, char**)
{ {
EiMatrix2d m; Matrix2d m;
m(0,0)= 1; m(0,0)= 1;
m(1,0)= 2; m(1,0)= 2;
m(0,1)= 3; m(0,1)= 3;

View File

@ -1,10 +1,12 @@
#include "../src/Core.h" #include "../src/Core.h"
USING_EIGEN_DATA_TYPES
using namespace std; using namespace std;
int main(int, char **) int main(int, char **)
{ {
EiMatrix<double,2,2> m; // 2x2 fixed-size matrix with uninitialized entries Matrix<double,2,2> m; // 2x2 fixed-size matrix with uninitialized entries
m(0,0) = 1; m(0,0) = 1;
m(0,1) = 2; m(0,1) = 2;
m(1,0) = 3; m(1,0) = 3;
@ -12,7 +14,7 @@ int main(int, char **)
cout << "Here is a 2x2 matrix m:" << endl << m << endl; cout << "Here is a 2x2 matrix m:" << endl << m << endl;
cout << "Let us now build a 4x4 matrix m2 by assembling together four 2x2 blocks." << endl; cout << "Let us now build a 4x4 matrix m2 by assembling together four 2x2 blocks." << endl;
EiMatrixXd m2(4,4); // dynamic matrix with initial size 4x4 and uninitialized entries MatrixXd m2(4,4); // dynamic matrix with initial size 4x4 and uninitialized entries
// notice how we are mixing fixed-size and dynamic-size types. // notice how we are mixing fixed-size and dynamic-size types.
cout << "In the top-left block, we put the matrix m shown above." << endl; cout << "In the top-left block, we put the matrix m shown above." << endl;

View File

@ -1,4 +1,4 @@
FILE(GLOB Eigen_SRCS "*.h") FILE(GLOB gen_SRCS "*.h")
SET(INCLUDE_INSTALL_DIR SET(INCLUDE_INSTALL_DIR
"${CMAKE_INSTALL_PREFIX}/include/eigen2" "${CMAKE_INSTALL_PREFIX}/include/eigen2"
@ -7,7 +7,7 @@ SET(INCLUDE_INSTALL_DIR
FORCE) FORCE)
INSTALL(FILES INSTALL(FILES
${Eigen_SRCS} ${gen_SRCS}
DESTINATION ${INCLUDE_INSTALL_DIR} DESTINATION ${INCLUDE_INSTALL_DIR}
) )

View File

@ -1,3 +1,10 @@
#include <iostream>
#include <complex>
#include <cassert>
namespace Eigen {
#include "Core/Util.h" #include "Core/Util.h"
#include "Core/Numeric.h" #include "Core/Numeric.h"
#include "Core/Object.h" #include "Core/Object.h"
@ -14,3 +21,5 @@
#include "Core/Trace.h" #include "Core/Trace.h"
#include "Core/Dot.h" #include "Core/Dot.h"
#include "Core/Random.h" #include "Core/Random.h"
} // namespace Eigen

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -26,18 +26,18 @@
#ifndef EI_BLOCK_H #ifndef EI_BLOCK_H
#define EI_BLOCK_H #define EI_BLOCK_H
template<typename MatrixType> class EiBlock template<typename MatrixType> class Block
: public EiObject<typename MatrixType::Scalar, EiBlock<MatrixType> > : public Object<typename MatrixType::Scalar, Block<MatrixType> >
{ {
public: public:
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef; typedef typename MatrixType::Ref MatRef;
friend class EiObject<Scalar, EiBlock<MatrixType> >; friend class Object<Scalar, Block<MatrixType> >;
static const int RowsAtCompileTime = EiDynamic, static const int RowsAtCompileTime = Dynamic,
ColsAtCompileTime = EiDynamic; ColsAtCompileTime = Dynamic;
EiBlock(const MatRef& matrix, Block(const MatRef& matrix,
int startRow, int endRow, int startRow, int endRow,
int startCol = 0, int endCol = 0) int startCol = 0, int endCol = 0)
: m_matrix(matrix), m_startRow(startRow), m_endRow(endRow), : m_matrix(matrix), m_startRow(startRow), m_endRow(endRow),
@ -47,15 +47,15 @@ template<typename MatrixType> class EiBlock
&& startCol >= 0 && startCol <= endCol && endCol < matrix.cols()); && startCol >= 0 && startCol <= endCol && endCol < matrix.cols());
} }
EiBlock(const EiBlock& other) Block(const Block& other)
: m_matrix(other.m_matrix), m_startRow(other.m_startRow), m_endRow(other.m_endRow), : m_matrix(other.m_matrix), m_startRow(other.m_startRow), m_endRow(other.m_endRow),
m_startCol(other.m_startCol), m_endCol(other.m_endCol) {} m_startCol(other.m_startCol), m_endCol(other.m_endCol) {}
EI_INHERIT_ASSIGNMENT_OPERATORS(EiBlock) EI_INHERIT_ASSIGNMENT_OPERATORS(Block)
private: private:
EiBlock& _ref() { return *this; } Block& _ref() { return *this; }
const EiBlock& _constRef() const { return *this; } const Block& _constRef() const { return *this; }
int _rows() const { return m_endRow - m_startRow + 1; } int _rows() const { return m_endRow - m_startRow + 1; }
int _cols() const { return m_endCol - m_startCol + 1; } int _cols() const { return m_endCol - m_startCol + 1; }
@ -75,10 +75,10 @@ template<typename MatrixType> class EiBlock
}; };
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
EiBlock<Derived> Block<Derived>
EiObject<Scalar, Derived>::block(int startRow, int endRow, int startCol, int endCol) Object<Scalar, Derived>::block(int startRow, int endRow, int startCol, int endCol)
{ {
return EiBlock<Derived>(static_cast<Derived*>(this)->ref(), startRow, endRow, startCol, endCol); return Block<Derived>(static_cast<Derived*>(this)->ref(), startRow, endRow, startCol, endCol);
} }
#endif // EI_BLOCK_H #endif // EI_BLOCK_H

View File

@ -1,6 +1,6 @@
FILE(GLOB Eigen_Core_SRCS "*.h") FILE(GLOB gen_Core_SRCS "*.h")
INSTALL(FILES INSTALL(FILES
${Eigen_Core_SRCS} ${gen_Core_SRCS}
DESTINATION ${INCLUDE_INSTALL_DIR}/Core DESTINATION ${INCLUDE_INSTALL_DIR}/Core
) )

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -26,31 +26,31 @@
#ifndef EI_COLUMN_H #ifndef EI_COLUMN_H
#define EI_COLUMN_H #define EI_COLUMN_H
template<typename MatrixType> class EiColumn template<typename MatrixType> class Column
: public EiObject<typename MatrixType::Scalar, EiColumn<MatrixType> > : public Object<typename MatrixType::Scalar, Column<MatrixType> >
{ {
public: public:
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef; typedef typename MatrixType::Ref MatRef;
friend class EiObject<Scalar, EiColumn<MatrixType> >; friend class Object<Scalar, Column<MatrixType> >;
static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime,
ColsAtCompileTime = 1; ColsAtCompileTime = 1;
EiColumn(const MatRef& matrix, int col) Column(const MatRef& matrix, int col)
: m_matrix(matrix), m_col(col) : m_matrix(matrix), m_col(col)
{ {
EI_CHECK_COL_RANGE(matrix, col); EI_CHECK_COL_RANGE(matrix, col);
} }
EiColumn(const EiColumn& other) Column(const Column& other)
: m_matrix(other.m_matrix), m_col(other.m_col) {} : m_matrix(other.m_matrix), m_col(other.m_col) {}
EI_INHERIT_ASSIGNMENT_OPERATORS(EiColumn) EI_INHERIT_ASSIGNMENT_OPERATORS(Column)
private: private:
EiColumn& _ref() { return *this; } Column& _ref() { return *this; }
const EiColumn& _constRef() const { return *this; } const Column& _constRef() const { return *this; }
int _rows() const { return m_matrix.rows(); } int _rows() const { return m_matrix.rows(); }
int _cols() const { return 1; } int _cols() const { return 1; }
@ -74,10 +74,10 @@ template<typename MatrixType> class EiColumn
}; };
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
EiColumn<Derived> Column<Derived>
EiObject<Scalar, Derived>::col(int i) Object<Scalar, Derived>::col(int i)
{ {
return EiColumn<Derived>(static_cast<Derived*>(this)->ref(), i); return Column<Derived>(static_cast<Derived*>(this)->ref(), i);
} }
#endif // EI_COLUMN_H #endif // EI_COLUMN_H

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -26,33 +26,33 @@
#ifndef EI_CONJUGATE_H #ifndef EI_CONJUGATE_H
#define EI_CONJUGATE_H #define EI_CONJUGATE_H
template<typename MatrixType> class EiConjugate template<typename MatrixType> class Conjugate
: public EiObject<typename MatrixType::Scalar, EiConjugate<MatrixType> > : public Object<typename MatrixType::Scalar, Conjugate<MatrixType> >
{ {
public: public:
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::ConstRef MatRef; typedef typename MatrixType::ConstRef MatRef;
friend class EiObject<Scalar, EiConjugate<MatrixType> >; friend class Object<Scalar, Conjugate<MatrixType> >;
static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime,
ColsAtCompileTime = MatrixType::ColsAtCompileTime; ColsAtCompileTime = MatrixType::ColsAtCompileTime;
EiConjugate(const MatRef& matrix) : m_matrix(matrix) {} Conjugate(const MatRef& matrix) : m_matrix(matrix) {}
EiConjugate(const EiConjugate& other) Conjugate(const Conjugate& other)
: m_matrix(other.m_matrix) {} : m_matrix(other.m_matrix) {}
EI_INHERIT_ASSIGNMENT_OPERATORS(EiConjugate) EI_INHERIT_ASSIGNMENT_OPERATORS(Conjugate)
private: private:
EiConjugate& _ref() { return *this; } Conjugate& _ref() { return *this; }
const EiConjugate& _constRef() const { return *this; } const Conjugate& _constRef() const { return *this; }
int _rows() const { return m_matrix.rows(); } int _rows() const { return m_matrix.rows(); }
int _cols() const { return m_matrix.cols(); } int _cols() const { return m_matrix.cols(); }
Scalar _read(int row, int col) const Scalar _read(int row, int col) const
{ {
return EiConj(m_matrix.read(row, col)); return Conj(m_matrix.read(row, col));
} }
protected: protected:
@ -60,10 +60,10 @@ template<typename MatrixType> class EiConjugate
}; };
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
EiConjugate<Derived> Conjugate<Derived>
EiObject<Scalar, Derived>::conjugate() const Object<Scalar, Derived>::conjugate() const
{ {
return EiConjugate<Derived>(static_cast<const Derived*>(this)->constRef()); return Conjugate<Derived>(static_cast<const Derived*>(this)->constRef());
} }
#endif // EI_CONJUGATE_H #endif // EI_CONJUGATE_H

View File

@ -1,20 +1,20 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2007 Michael Olbrich <michael.olbrich@gmx.net> // Copyright (C) 2007 Michael Olbrich <michael.olbrich@gmx.net>
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -27,7 +27,7 @@
#ifndef EI_COPYHELPER_H #ifndef EI_COPYHELPER_H
#define EI_COPYHELPER_H #define EI_COPYHELPER_H
template<int UnrollCount, int Rows> struct EiCopyHelperUnroller template<int UnrollCount, int Rows> struct CopyHelperUnroller
{ {
static const int col = (UnrollCount-1) / Rows; static const int col = (UnrollCount-1) / Rows;
static const int row = (UnrollCount-1) % Rows; static const int row = (UnrollCount-1) % Rows;
@ -35,12 +35,12 @@ template<int UnrollCount, int Rows> struct EiCopyHelperUnroller
template <typename Derived1, typename Derived2> template <typename Derived1, typename Derived2>
static void run(Derived1 &dst, const Derived2 &src) static void run(Derived1 &dst, const Derived2 &src)
{ {
EiCopyHelperUnroller<UnrollCount-1, Rows>::run(dst, src); CopyHelperUnroller<UnrollCount-1, Rows>::run(dst, src);
dst.write(row, col) = src.read(row, col); dst.write(row, col) = src.read(row, col);
} }
}; };
template<int Rows> struct EiCopyHelperUnroller<0, Rows> template<int Rows> struct CopyHelperUnroller<0, Rows>
{ {
template <typename Derived1, typename Derived2> template <typename Derived1, typename Derived2>
static void run(Derived1 &dst, const Derived2 &src) static void run(Derived1 &dst, const Derived2 &src)
@ -49,7 +49,7 @@ template<int Rows> struct EiCopyHelperUnroller<0, Rows>
} }
}; };
template<int Rows> struct EiCopyHelperUnroller<EiDynamic, Rows> template<int Rows> struct CopyHelperUnroller<Dynamic, Rows>
{ {
template <typename Derived1, typename Derived2> template <typename Derived1, typename Derived2>
static void run(Derived1 &dst, const Derived2 &src) static void run(Derived1 &dst, const Derived2 &src)
@ -61,10 +61,10 @@ template<int Rows> struct EiCopyHelperUnroller<EiDynamic, Rows>
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
template<typename OtherDerived> template<typename OtherDerived>
void EiObject<Scalar, Derived>::_copy_helper(const EiObject<Scalar, OtherDerived>& other) void Object<Scalar, Derived>::_copy_helper(const Object<Scalar, OtherDerived>& other)
{ {
if(SizeAtCompileTime != EiDynamic && SizeAtCompileTime <= EI_LOOP_UNROLLING_LIMIT) if(SizeAtCompileTime != Dynamic && SizeAtCompileTime <= EI_LOOP_UNROLLING_LIMIT)
EiCopyHelperUnroller<SizeAtCompileTime, RowsAtCompileTime>::run(*this, other); CopyHelperUnroller<SizeAtCompileTime, RowsAtCompileTime>::run(*this, other);
else else
for(int i = 0; i < rows(); i++) for(int i = 0; i < rows(); i++)
for(int j = 0; j < cols(); j++) for(int j = 0; j < cols(); j++)

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -27,26 +27,26 @@
#define EI_DOT_H #define EI_DOT_H
template<int Index, int Size, typename Derived1, typename Derived2> template<int Index, int Size, typename Derived1, typename Derived2>
struct EiDotUnroller struct DotUnroller
{ {
static void run(const Derived1 &v1, const Derived2& v2, typename Derived1::Scalar &dot) static void run(const Derived1 &v1, const Derived2& v2, typename Derived1::Scalar &dot)
{ {
EiDotUnroller<Index-1, Size, Derived1, Derived2>::run(v1, v2, dot); DotUnroller<Index-1, Size, Derived1, Derived2>::run(v1, v2, dot);
dot += v1[Index] * EiConj(v2[Index]); dot += v1[Index] * Conj(v2[Index]);
} }
}; };
template<int Size, typename Derived1, typename Derived2> template<int Size, typename Derived1, typename Derived2>
struct EiDotUnroller<0, Size, Derived1, Derived2> struct DotUnroller<0, Size, Derived1, Derived2>
{ {
static void run(const Derived1 &v1, const Derived2& v2, typename Derived1::Scalar &dot) static void run(const Derived1 &v1, const Derived2& v2, typename Derived1::Scalar &dot)
{ {
dot = v1[0] * EiConj(v2[0]); dot = v1[0] * Conj(v2[0]);
} }
}; };
template<int Index, typename Derived1, typename Derived2> template<int Index, typename Derived1, typename Derived2>
struct EiDotUnroller<Index, EiDynamic, Derived1, Derived2> struct DotUnroller<Index, Dynamic, Derived1, Derived2>
{ {
static void run(const Derived1 &v1, const Derived2& v2, typename Derived1::Scalar &dot) static void run(const Derived1 &v1, const Derived2& v2, typename Derived1::Scalar &dot)
{ {
@ -58,37 +58,37 @@ struct EiDotUnroller<Index, EiDynamic, Derived1, Derived2>
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
template<typename OtherDerived> template<typename OtherDerived>
Scalar EiObject<Scalar, Derived>::dot(const OtherDerived& other) const Scalar Object<Scalar, Derived>::dot(const OtherDerived& other) const
{ {
assert(IsVector && OtherDerived::IsVector && size() == other.size()); assert(IsVector && OtherDerived::IsVector && size() == other.size());
Scalar res; Scalar res;
if(SizeAtCompileTime != EiDynamic && SizeAtCompileTime <= 16) if(SizeAtCompileTime != Dynamic && SizeAtCompileTime <= 16)
EiDotUnroller<SizeAtCompileTime-1, SizeAtCompileTime, Derived, OtherDerived> DotUnroller<SizeAtCompileTime-1, SizeAtCompileTime, Derived, OtherDerived>
::run(*static_cast<const Derived*>(this), other, res); ::run(*static_cast<const Derived*>(this), other, res);
else else
{ {
res = (*this)[0] * EiConj(other[0]); res = (*this)[0] * Conj(other[0]);
for(int i = 1; i < size(); i++) for(int i = 1; i < size(); i++)
res += (*this)[i]* EiConj(other[i]); res += (*this)[i]* Conj(other[i]);
} }
return res; return res;
} }
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
typename EiNumTraits<Scalar>::Real EiObject<Scalar, Derived>::norm2() const typename NumTraits<Scalar>::Real Object<Scalar, Derived>::norm2() const
{ {
assert(IsVector); assert(IsVector);
return EiReal(dot(*this)); return Real(dot(*this));
} }
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
typename EiNumTraits<Scalar>::Real EiObject<Scalar, Derived>::norm() const typename NumTraits<Scalar>::Real Object<Scalar, Derived>::norm() const
{ {
return EiSqrt(norm2()); return Sqrt(norm2());
} }
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
EiScalarProduct<Derived> EiObject<Scalar, Derived>::normalized() const ScalarProduct<Derived> Object<Scalar, Derived>::normalized() const
{ {
return (*this) / norm(); return (*this) / norm();
} }

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -26,26 +26,26 @@
#ifndef EI_EVAL_H #ifndef EI_EVAL_H
#define EI_EVAL_H #define EI_EVAL_H
template<typename Expression> class EiEval template<typename Expression> class Eval
: public EiMatrix< typename Expression::Scalar, : public Matrix< typename Expression::Scalar,
Expression::RowsAtCompileTime, Expression::RowsAtCompileTime,
Expression::ColsAtCompileTime > Expression::ColsAtCompileTime >
{ {
public: public:
typedef typename Expression::Scalar Scalar; typedef typename Expression::Scalar Scalar;
typedef EiMatrix<Scalar, Expression::RowsAtCompileTime, Expression::ColsAtCompileTime> MatrixType; typedef Matrix<Scalar, Expression::RowsAtCompileTime, Expression::ColsAtCompileTime> MatrixType;
typedef Expression Base; typedef Expression Base;
friend class EiObject<Scalar, Expression>; friend class Object<Scalar, Expression>;
EI_INHERIT_ASSIGNMENT_OPERATORS(EiEval) EI_INHERIT_ASSIGNMENT_OPERATORS(Eval)
EiEval(const Expression& expression) : MatrixType(expression) {} Eval(const Expression& expression) : MatrixType(expression) {}
}; };
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
EiEval<Derived> EiObject<Scalar, Derived>::eval() const Eval<Derived> Object<Scalar, Derived>::eval() const
{ {
return EiEval<Derived>(*static_cast<const Derived*>(this)); return Eval<Derived>(*static_cast<const Derived*>(this));
} }
#endif // EI_EVAL_H #endif // EI_EVAL_H

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -28,13 +28,13 @@
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
template<typename OtherDerived> template<typename OtherDerived>
bool EiObject<Scalar, Derived>::isApprox(const OtherDerived& other) const bool Object<Scalar, Derived>::isApprox(const OtherDerived& other) const
{ {
if(IsVector) if(IsVector)
{ {
return((*this - other).norm2() return((*this - other).norm2()
<= std::min(norm2(), other.norm2()) <= std::min(norm2(), other.norm2())
* EiAbs2(EiNumTraits<Scalar>::epsilon())); * Abs2(NumTraits<Scalar>::epsilon()));
} }
else else
{ {
@ -46,11 +46,11 @@ bool EiObject<Scalar, Derived>::isApprox(const OtherDerived& other) const
} }
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
bool EiObject<Scalar, Derived>::isNegligble(const Scalar& other) const bool Object<Scalar, Derived>::isNegligble(const Scalar& other) const
{ {
if(IsVector) if(IsVector)
{ {
return(norm2() <= EiAbs2(other) * EiAbs2(EiNumTraits<Scalar>::epsilon())); return(norm2() <= Abs2(other) * Abs2(NumTraits<Scalar>::epsilon()));
} }
else else
{ {
@ -63,11 +63,11 @@ bool EiObject<Scalar, Derived>::isNegligble(const Scalar& other) const
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
template<typename OtherDerived> template<typename OtherDerived>
bool EiObject<Scalar, Derived>::isNegligble(const EiObject<Scalar, OtherDerived>& other) const bool Object<Scalar, Derived>::isNegligble(const Object<Scalar, OtherDerived>& other) const
{ {
if(IsVector) if(IsVector)
{ {
return(norm2() <= other.norm2() * EiAbs2(EiNumTraits<Scalar>::epsilon())); return(norm2() <= other.norm2() * Abs2(NumTraits<Scalar>::epsilon()));
} }
else else
{ {

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -33,18 +33,18 @@
#include "MatrixStorage.h" #include "MatrixStorage.h"
template<typename _Scalar, int _Rows, int _Cols> template<typename _Scalar, int _Rows, int _Cols>
class EiMatrix : public EiObject<_Scalar, EiMatrix<_Scalar, _Rows, _Cols> >, class Matrix : public Object<_Scalar, Matrix<_Scalar, _Rows, _Cols> >,
public EiMatrixStorage<_Scalar, _Rows, _Cols> public MatrixStorage<_Scalar, _Rows, _Cols>
{ {
public: public:
friend class EiObject<_Scalar, EiMatrix>; friend class Object<_Scalar, Matrix>;
typedef EiObject<_Scalar, EiMatrix> Base; typedef Object<_Scalar, Matrix> Base;
typedef EiMatrixStorage<_Scalar, _Rows, _Cols> Storage; typedef MatrixStorage<_Scalar, _Rows, _Cols> Storage;
typedef _Scalar Scalar; typedef _Scalar Scalar;
typedef EiMatrixRef<EiMatrix> Ref; typedef MatrixRef<Matrix> Ref;
typedef EiMatrixConstRef<EiMatrix> ConstRef; typedef MatrixConstRef<Matrix> ConstRef;
friend class EiMatrixRef<EiMatrix>; friend class MatrixRef<Matrix>;
friend class EiMatrixConstRef<EiMatrix>; friend class MatrixConstRef<Matrix>;
static const int RowsAtCompileTime = _Rows, ColsAtCompileTime = _Cols; static const int RowsAtCompileTime = _Rows, ColsAtCompileTime = _Cols;
@ -72,46 +72,46 @@ class EiMatrix : public EiObject<_Scalar, EiMatrix<_Scalar, _Rows, _Cols> >,
public: public:
template<typename OtherDerived> template<typename OtherDerived>
EiMatrix& operator=(const EiObject<Scalar, OtherDerived>& other) Matrix& operator=(const Object<Scalar, OtherDerived>& other)
{ {
resize(other.rows(), other.cols()); resize(other.rows(), other.cols());
return Base::operator=(other); return Base::operator=(other);
} }
EiMatrix& operator=(const EiMatrix& other) Matrix& operator=(const Matrix& other)
{ {
resize(other.rows(), other.cols()); resize(other.rows(), other.cols());
return Base::operator=(other); return Base::operator=(other);
} }
EI_INHERIT_ASSIGNMENT_OPERATOR(EiMatrix, +=) EI_INHERIT_ASSIGNMENT_OPERATOR(Matrix, +=)
EI_INHERIT_ASSIGNMENT_OPERATOR(EiMatrix, -=) EI_INHERIT_ASSIGNMENT_OPERATOR(Matrix, -=)
EI_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(EiMatrix, *=) EI_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Matrix, *=)
EI_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(EiMatrix, /=) EI_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Matrix, /=)
explicit EiMatrix(int rows = 1, int cols = 1) : Storage(rows, cols) {} explicit Matrix(int rows = 1, int cols = 1) : Storage(rows, cols) {}
template<typename OtherDerived> template<typename OtherDerived>
EiMatrix(const EiObject<Scalar, OtherDerived>& other) : Storage(other.rows(), other.cols()) Matrix(const Object<Scalar, OtherDerived>& other) : Storage(other.rows(), other.cols())
{ {
*this = other; *this = other;
} }
EiMatrix(const EiMatrix& other) : Storage(other.rows(), other.cols()) Matrix(const Matrix& other) : Storage(other.rows(), other.cols())
{ {
*this = other; *this = other;
} }
~EiMatrix() {} ~Matrix() {}
}; };
#define EI_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \ #define EI_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \
typedef EiMatrix<Type, Size, Size> EiMatrix##SizeSuffix##TypeSuffix; \ typedef Matrix<Type, Size, Size> Matrix##SizeSuffix##TypeSuffix; \
typedef EiMatrix<Type, Size, 1> EiVector##SizeSuffix##TypeSuffix; \ typedef Matrix<Type, Size, 1> Vector##SizeSuffix##TypeSuffix; \
typedef EiMatrix<Type, 1, Size> EiRowVector##SizeSuffix##TypeSuffix; typedef Matrix<Type, 1, Size> RowVector##SizeSuffix##TypeSuffix;
#define EI_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \ #define EI_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
EI_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \ EI_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \
EI_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \ EI_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \
EI_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \ EI_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \
EI_MAKE_TYPEDEFS(Type, TypeSuffix, EiDynamic, X) EI_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X)
EI_MAKE_TYPEDEFS_ALL_SIZES(int, i) EI_MAKE_TYPEDEFS_ALL_SIZES(int, i)
EI_MAKE_TYPEDEFS_ALL_SIZES(float, f) EI_MAKE_TYPEDEFS_ALL_SIZES(float, f)
@ -123,6 +123,25 @@ EI_MAKE_TYPEDEFS_ALL_SIZES(std::complex<double>, cd)
#undef EI_MAKE_TYPEDEFS_ALL_SIZES #undef EI_MAKE_TYPEDEFS_ALL_SIZES
#undef EI_MAKE_TYPEDEFS #undef EI_MAKE_TYPEDEFS
#define EI_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(Type, TypeSuffix, Size, SizeSuffix) \
using Eigen::Matrix##SizeSuffix##TypeSuffix; \
using Eigen::Vector##SizeSuffix##TypeSuffix; \
using Eigen::RowVector##SizeSuffix##TypeSuffix;
#define EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(Type, TypeSuffix) \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(Type, TypeSuffix, 2, 2) \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(Type, TypeSuffix, 3, 3) \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(Type, TypeSuffix, 4, 4) \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(Type, TypeSuffix, Dynamic, X)
#define EI_USING_MATRIX_TYPEDEFS \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(int, i) \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(float, f) \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(double, d) \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(std::complex<int>, ci) \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(std::complex<float>, cf) \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(std::complex<double>, cd)
#include "Eval.h" #include "Eval.h"
#include "MatrixOps.h" #include "MatrixOps.h"
#include "ScalarOps.h" #include "ScalarOps.h"

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -26,33 +26,33 @@
#ifndef EI_MATRIXOPS_H #ifndef EI_MATRIXOPS_H
#define EI_MATRIXOPS_H #define EI_MATRIXOPS_H
template<typename Lhs, typename Rhs> class EiSum template<typename Lhs, typename Rhs> class Sum
: public EiObject<typename Lhs::Scalar, EiSum<Lhs, Rhs> > : public Object<typename Lhs::Scalar, Sum<Lhs, Rhs> >
{ {
public: public:
typedef typename Lhs::Scalar Scalar; typedef typename Lhs::Scalar Scalar;
typedef typename Lhs::ConstRef LhsRef; typedef typename Lhs::ConstRef LhsRef;
typedef typename Rhs::ConstRef RhsRef; typedef typename Rhs::ConstRef RhsRef;
friend class EiObject<Scalar, EiSum>; friend class Object<Scalar, Sum>;
static const int RowsAtCompileTime = Lhs::RowsAtCompileTime, static const int RowsAtCompileTime = Lhs::RowsAtCompileTime,
ColsAtCompileTime = Rhs::ColsAtCompileTime; ColsAtCompileTime = Rhs::ColsAtCompileTime;
EiSum(const LhsRef& lhs, const RhsRef& rhs) Sum(const LhsRef& lhs, const RhsRef& rhs)
: m_lhs(lhs), m_rhs(rhs) : m_lhs(lhs), m_rhs(rhs)
{ {
assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols()); assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
} }
EiSum(const EiSum& other) Sum(const Sum& other)
: m_lhs(other.m_lhs), m_rhs(other.m_rhs) {} : m_lhs(other.m_lhs), m_rhs(other.m_rhs) {}
EI_INHERIT_ASSIGNMENT_OPERATORS(EiSum) EI_INHERIT_ASSIGNMENT_OPERATORS(Sum)
private: private:
const EiSum& _ref() const { return *this; } const Sum& _ref() const { return *this; }
const EiSum& _constRef() const { return *this; } const Sum& _constRef() const { return *this; }
int _rows() const { return m_lhs.rows(); } int _rows() const { return m_lhs.rows(); }
int _cols() const { return m_lhs.cols(); } int _cols() const { return m_lhs.cols(); }
@ -66,32 +66,32 @@ template<typename Lhs, typename Rhs> class EiSum
const RhsRef m_rhs; const RhsRef m_rhs;
}; };
template<typename Lhs, typename Rhs> class EiDifference template<typename Lhs, typename Rhs> class Difference
: public EiObject<typename Lhs::Scalar, EiDifference<Lhs, Rhs> > : public Object<typename Lhs::Scalar, Difference<Lhs, Rhs> >
{ {
public: public:
typedef typename Lhs::Scalar Scalar; typedef typename Lhs::Scalar Scalar;
typedef typename Lhs::ConstRef LhsRef; typedef typename Lhs::ConstRef LhsRef;
typedef typename Rhs::ConstRef RhsRef; typedef typename Rhs::ConstRef RhsRef;
friend class EiObject<Scalar, EiDifference>; friend class Object<Scalar, Difference>;
static const int RowsAtCompileTime = Lhs::RowsAtCompileTime, static const int RowsAtCompileTime = Lhs::RowsAtCompileTime,
ColsAtCompileTime = Rhs::ColsAtCompileTime; ColsAtCompileTime = Rhs::ColsAtCompileTime;
EiDifference(const LhsRef& lhs, const RhsRef& rhs) Difference(const LhsRef& lhs, const RhsRef& rhs)
: m_lhs(lhs), m_rhs(rhs) : m_lhs(lhs), m_rhs(rhs)
{ {
assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols()); assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
} }
EiDifference(const EiDifference& other) Difference(const Difference& other)
: m_lhs(other.m_lhs), m_rhs(other.m_rhs) {} : m_lhs(other.m_lhs), m_rhs(other.m_rhs) {}
EI_INHERIT_ASSIGNMENT_OPERATORS(EiDifference) EI_INHERIT_ASSIGNMENT_OPERATORS(Difference)
private: private:
const EiDifference& _ref() const { return *this; } const Difference& _ref() const { return *this; }
const EiDifference& _constRef() const { return *this; } const Difference& _constRef() const { return *this; }
int _rows() const { return m_lhs.rows(); } int _rows() const { return m_lhs.rows(); }
int _cols() const { return m_lhs.cols(); } int _cols() const { return m_lhs.cols(); }
@ -106,18 +106,18 @@ template<typename Lhs, typename Rhs> class EiDifference
}; };
template<int Index, int Size, typename Lhs, typename Rhs> template<int Index, int Size, typename Lhs, typename Rhs>
struct EiMatrixProductUnroller struct MatrixProductUnroller
{ {
static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, static void run(int row, int col, const Lhs& lhs, const Rhs& rhs,
typename Lhs::Scalar &res) typename Lhs::Scalar &res)
{ {
EiMatrixProductUnroller<Index-1, Size, Lhs, Rhs>::run(row, col, lhs, rhs, res); MatrixProductUnroller<Index-1, Size, Lhs, Rhs>::run(row, col, lhs, rhs, res);
res += lhs.read(row, Index) * rhs.read(Index, col); res += lhs.read(row, Index) * rhs.read(Index, col);
} }
}; };
template<int Size, typename Lhs, typename Rhs> template<int Size, typename Lhs, typename Rhs>
struct EiMatrixProductUnroller<0, Size, Lhs, Rhs> struct MatrixProductUnroller<0, Size, Lhs, Rhs>
{ {
static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, static void run(int row, int col, const Lhs& lhs, const Rhs& rhs,
typename Lhs::Scalar &res) typename Lhs::Scalar &res)
@ -127,7 +127,7 @@ struct EiMatrixProductUnroller<0, Size, Lhs, Rhs>
}; };
template<int Index, typename Lhs, typename Rhs> template<int Index, typename Lhs, typename Rhs>
struct EiMatrixProductUnroller<Index, EiDynamic, Lhs, Rhs> struct MatrixProductUnroller<Index, Dynamic, Lhs, Rhs>
{ {
static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, static void run(int row, int col, const Lhs& lhs, const Rhs& rhs,
typename Lhs::Scalar &res) typename Lhs::Scalar &res)
@ -140,40 +140,40 @@ struct EiMatrixProductUnroller<Index, EiDynamic, Lhs, Rhs>
} }
}; };
template<typename Lhs, typename Rhs> class EiMatrixProduct template<typename Lhs, typename Rhs> class MatrixProduct
: public EiObject<typename Lhs::Scalar, EiMatrixProduct<Lhs, Rhs> > : public Object<typename Lhs::Scalar, MatrixProduct<Lhs, Rhs> >
{ {
public: public:
typedef typename Lhs::Scalar Scalar; typedef typename Lhs::Scalar Scalar;
typedef typename Lhs::ConstRef LhsRef; typedef typename Lhs::ConstRef LhsRef;
typedef typename Rhs::ConstRef RhsRef; typedef typename Rhs::ConstRef RhsRef;
friend class EiObject<Scalar, EiMatrixProduct>; friend class Object<Scalar, MatrixProduct>;
static const int RowsAtCompileTime = Lhs::RowsAtCompileTime, static const int RowsAtCompileTime = Lhs::RowsAtCompileTime,
ColsAtCompileTime = Rhs::ColsAtCompileTime; ColsAtCompileTime = Rhs::ColsAtCompileTime;
EiMatrixProduct(const LhsRef& lhs, const RhsRef& rhs) MatrixProduct(const LhsRef& lhs, const RhsRef& rhs)
: m_lhs(lhs), m_rhs(rhs) : m_lhs(lhs), m_rhs(rhs)
{ {
assert(lhs.cols() == rhs.rows()); assert(lhs.cols() == rhs.rows());
} }
EiMatrixProduct(const EiMatrixProduct& other) MatrixProduct(const MatrixProduct& other)
: m_lhs(other.m_lhs), m_rhs(other.m_rhs) {} : m_lhs(other.m_lhs), m_rhs(other.m_rhs) {}
EI_INHERIT_ASSIGNMENT_OPERATORS(EiMatrixProduct) EI_INHERIT_ASSIGNMENT_OPERATORS(MatrixProduct)
private: private:
const EiMatrixProduct& _ref() const { return *this; } const MatrixProduct& _ref() const { return *this; }
const EiMatrixProduct& _constRef() const { return *this; } const MatrixProduct& _constRef() const { return *this; }
int _rows() const { return m_lhs.rows(); } int _rows() const { return m_lhs.rows(); }
int _cols() const { return m_rhs.cols(); } int _cols() const { return m_rhs.cols(); }
Scalar _read(int row, int col) const Scalar _read(int row, int col) const
{ {
Scalar res; Scalar res;
if(Lhs::ColsAtCompileTime != EiDynamic && Lhs::ColsAtCompileTime <= 16) if(Lhs::ColsAtCompileTime != Dynamic && Lhs::ColsAtCompileTime <= 16)
EiMatrixProductUnroller<Lhs::ColsAtCompileTime-1, Lhs::ColsAtCompileTime, LhsRef, RhsRef> MatrixProductUnroller<Lhs::ColsAtCompileTime-1, Lhs::ColsAtCompileTime, LhsRef, RhsRef>
::run(row, col, m_lhs, m_rhs, res); ::run(row, col, m_lhs, m_rhs, res);
else else
{ {
@ -190,30 +190,30 @@ template<typename Lhs, typename Rhs> class EiMatrixProduct
}; };
template<typename Scalar, typename Derived1, typename Derived2> template<typename Scalar, typename Derived1, typename Derived2>
EiSum<Derived1, Derived2> Sum<Derived1, Derived2>
operator+(const EiObject<Scalar, Derived1> &mat1, const EiObject<Scalar, Derived2> &mat2) operator+(const Object<Scalar, Derived1> &mat1, const Object<Scalar, Derived2> &mat2)
{ {
return EiSum<Derived1, Derived2>(mat1.constRef(), mat2.constRef()); return Sum<Derived1, Derived2>(mat1.constRef(), mat2.constRef());
} }
template<typename Scalar, typename Derived1, typename Derived2> template<typename Scalar, typename Derived1, typename Derived2>
EiDifference<Derived1, Derived2> Difference<Derived1, Derived2>
operator-(const EiObject<Scalar, Derived1> &mat1, const EiObject<Scalar, Derived2> &mat2) operator-(const Object<Scalar, Derived1> &mat1, const Object<Scalar, Derived2> &mat2)
{ {
return EiDifference<Derived1, Derived2>(mat1.constRef(), mat2.constRef()); return Difference<Derived1, Derived2>(mat1.constRef(), mat2.constRef());
} }
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
template<typename OtherDerived> template<typename OtherDerived>
EiMatrixProduct<Derived, OtherDerived> MatrixProduct<Derived, OtherDerived>
EiObject<Scalar, Derived>::lazyMul(const EiObject<Scalar, OtherDerived> &other) const Object<Scalar, Derived>::lazyMul(const Object<Scalar, OtherDerived> &other) const
{ {
return EiMatrixProduct<Derived, OtherDerived>(constRef(), other.constRef()); return MatrixProduct<Derived, OtherDerived>(constRef(), other.constRef());
} }
template<typename Scalar, typename Derived1, typename Derived2> template<typename Scalar, typename Derived1, typename Derived2>
EiEval<EiMatrixProduct<Derived1, Derived2> > Eval<MatrixProduct<Derived1, Derived2> >
operator*(const EiObject<Scalar, Derived1> &mat1, const EiObject<Scalar, Derived2> &mat2) operator*(const Object<Scalar, Derived1> &mat1, const Object<Scalar, Derived2> &mat2)
{ {
return mat1.lazyMul(mat2).eval(); return mat1.lazyMul(mat2).eval();
} }
@ -221,7 +221,7 @@ operator*(const EiObject<Scalar, Derived1> &mat1, const EiObject<Scalar, Derived
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
template<typename OtherDerived> template<typename OtherDerived>
Derived & Derived &
EiObject<Scalar, Derived>::operator+=(const EiObject<Scalar, OtherDerived>& other) Object<Scalar, Derived>::operator+=(const Object<Scalar, OtherDerived>& other)
{ {
return *this = *this + other; return *this = *this + other;
} }
@ -229,7 +229,7 @@ EiObject<Scalar, Derived>::operator+=(const EiObject<Scalar, OtherDerived>& othe
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
template<typename OtherDerived> template<typename OtherDerived>
Derived & Derived &
EiObject<Scalar, Derived>::operator-=(const EiObject<Scalar, OtherDerived> &other) Object<Scalar, Derived>::operator-=(const Object<Scalar, OtherDerived> &other)
{ {
return *this = *this - other; return *this = *this - other;
} }
@ -237,7 +237,7 @@ EiObject<Scalar, Derived>::operator-=(const EiObject<Scalar, OtherDerived> &othe
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
template<typename OtherDerived> template<typename OtherDerived>
Derived & Derived &
EiObject<Scalar, Derived>::operator*=(const EiObject<Scalar, OtherDerived> &other) Object<Scalar, Derived>::operator*=(const Object<Scalar, OtherDerived> &other)
{ {
return *this = *this * other; return *this = *this * other;
} }

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -26,18 +26,18 @@
#ifndef EI_MATRIXREF_H #ifndef EI_MATRIXREF_H
#define EI_MATRIXREF_H #define EI_MATRIXREF_H
template<typename MatrixType> class EiMatrixConstRef template<typename MatrixType> class MatrixConstRef
: public EiObject<typename MatrixType::Scalar, EiMatrixConstRef<MatrixType> > : public Object<typename MatrixType::Scalar, MatrixConstRef<MatrixType> >
{ {
public: public:
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
friend class EiObject<Scalar, EiMatrixConstRef>; friend class Object<Scalar, MatrixConstRef>;
EiMatrixConstRef(const MatrixType& matrix) : m_matrix(matrix) {} MatrixConstRef(const MatrixType& matrix) : m_matrix(matrix) {}
EiMatrixConstRef(const EiMatrixConstRef& other) : m_matrix(other.m_matrix) {} MatrixConstRef(const MatrixConstRef& other) : m_matrix(other.m_matrix) {}
~EiMatrixConstRef() {} ~MatrixConstRef() {}
EI_INHERIT_ASSIGNMENT_OPERATORS(EiMatrixConstRef) EI_INHERIT_ASSIGNMENT_OPERATORS(MatrixConstRef)
private: private:
int _rows() const { return m_matrix.rows(); } int _rows() const { return m_matrix.rows(); }
@ -51,18 +51,18 @@ template<typename MatrixType> class EiMatrixConstRef
const MatrixType& m_matrix; const MatrixType& m_matrix;
}; };
template<typename MatrixType> class EiMatrixRef template<typename MatrixType> class MatrixRef
: public EiObject<typename MatrixType::Scalar, EiMatrixRef<MatrixType> > : public Object<typename MatrixType::Scalar, MatrixRef<MatrixType> >
{ {
public: public:
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
friend class EiObject<Scalar, EiMatrixRef>; friend class Object<Scalar, MatrixRef>;
EiMatrixRef(MatrixType& matrix) : m_matrix(matrix) {} MatrixRef(MatrixType& matrix) : m_matrix(matrix) {}
EiMatrixRef(const EiMatrixRef& other) : m_matrix(other.m_matrix) {} MatrixRef(const MatrixRef& other) : m_matrix(other.m_matrix) {}
~EiMatrixRef() {} ~MatrixRef() {}
EI_INHERIT_ASSIGNMENT_OPERATORS(EiMatrixRef) EI_INHERIT_ASSIGNMENT_OPERATORS(MatrixRef)
private: private:
int _rows() const { return m_matrix.rows(); } int _rows() const { return m_matrix.rows(); }

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -29,7 +29,7 @@
template<typename Scalar, template<typename Scalar,
int RowsAtCompileTime, int RowsAtCompileTime,
int ColsAtCompileTime> int ColsAtCompileTime>
class EiMatrixStorage class MatrixStorage
{ {
protected: protected:
Scalar m_array[RowsAtCompileTime * ColsAtCompileTime]; Scalar m_array[RowsAtCompileTime * ColsAtCompileTime];
@ -44,18 +44,18 @@ class EiMatrixStorage
{ return ColsAtCompileTime; } { return ColsAtCompileTime; }
public: public:
EiMatrixStorage(int rows, int cols) MatrixStorage(int rows, int cols)
{ {
EI_UNUSED(rows); EI_UNUSED(rows);
EI_UNUSED(cols); EI_UNUSED(cols);
assert(RowsAtCompileTime > 0 && ColsAtCompileTime > 0); assert(RowsAtCompileTime > 0 && ColsAtCompileTime > 0);
} }
~EiMatrixStorage() {}; ~MatrixStorage() {};
}; };
template<typename Scalar, int ColsAtCompileTime> template<typename Scalar, int ColsAtCompileTime>
class EiMatrixStorage<Scalar, EiDynamic, ColsAtCompileTime> class MatrixStorage<Scalar, Dynamic, ColsAtCompileTime>
{ {
protected: protected:
int m_rows; int m_rows;
@ -79,18 +79,18 @@ class EiMatrixStorage<Scalar, EiDynamic, ColsAtCompileTime>
{ return ColsAtCompileTime; } { return ColsAtCompileTime; }
public: public:
EiMatrixStorage(int rows, int cols) : m_rows(rows) MatrixStorage(int rows, int cols) : m_rows(rows)
{ {
assert(m_rows > 0 && cols == ColsAtCompileTime); assert(m_rows > 0 && cols == ColsAtCompileTime);
m_array = new Scalar[m_rows * ColsAtCompileTime]; m_array = new Scalar[m_rows * ColsAtCompileTime];
} }
~EiMatrixStorage() ~MatrixStorage()
{ delete[] m_array; } { delete[] m_array; }
}; };
template<typename Scalar, int RowsAtCompileTime> template<typename Scalar, int RowsAtCompileTime>
class EiMatrixStorage<Scalar, RowsAtCompileTime, EiDynamic> class MatrixStorage<Scalar, RowsAtCompileTime, Dynamic>
{ {
protected: protected:
int m_cols; int m_cols;
@ -114,18 +114,18 @@ class EiMatrixStorage<Scalar, RowsAtCompileTime, EiDynamic>
{ return m_cols; } { return m_cols; }
public: public:
EiMatrixStorage(int rows, int cols) : m_cols(cols) MatrixStorage(int rows, int cols) : m_cols(cols)
{ {
assert(rows == RowsAtCompileTime && cols > 0); assert(rows == RowsAtCompileTime && cols > 0);
m_array = new Scalar[m_cols * RowsAtCompileTime]; m_array = new Scalar[m_cols * RowsAtCompileTime];
} }
~EiMatrixStorage() ~MatrixStorage()
{ delete[] m_array; } { delete[] m_array; }
}; };
template<typename Scalar> template<typename Scalar>
class EiMatrixStorage<Scalar, EiDynamic, EiDynamic> class MatrixStorage<Scalar, Dynamic, Dynamic>
{ {
protected: protected:
int m_rows, m_cols; int m_rows, m_cols;
@ -150,13 +150,13 @@ class EiMatrixStorage<Scalar, EiDynamic, EiDynamic>
{ return m_cols; } { return m_cols; }
public: public:
EiMatrixStorage(int rows, int cols) : m_rows(rows), m_cols(cols) MatrixStorage(int rows, int cols) : m_rows(rows), m_cols(cols)
{ {
assert(m_rows > 0 && m_cols > 0); assert(m_rows > 0 && m_cols > 0);
m_array = new Scalar[m_rows * m_cols]; m_array = new Scalar[m_rows * m_cols];
} }
~EiMatrixStorage() ~MatrixStorage()
{ delete[] m_array; } { delete[] m_array; }
}; };

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -26,35 +26,35 @@
#ifndef EI_MINOR_H #ifndef EI_MINOR_H
#define EI_MINOR_H #define EI_MINOR_H
template<typename MatrixType> class EiMinor template<typename MatrixType> class Minor
: public EiObject<typename MatrixType::Scalar, EiMinor<MatrixType> > : public Object<typename MatrixType::Scalar, Minor<MatrixType> >
{ {
public: public:
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef; typedef typename MatrixType::Ref MatRef;
friend class EiObject<Scalar, EiMinor<MatrixType> >; friend class Object<Scalar, Minor<MatrixType> >;
static const int static const int
RowsAtCompileTime = (MatrixType::RowsAtCompileTime != EiDynamic) ? RowsAtCompileTime = (MatrixType::RowsAtCompileTime != Dynamic) ?
MatrixType::RowsAtCompileTime - 1 : EiDynamic, MatrixType::RowsAtCompileTime - 1 : Dynamic,
ColsAtCompileTime = (MatrixType::ColsAtCompileTime != EiDynamic) ? ColsAtCompileTime = (MatrixType::ColsAtCompileTime != Dynamic) ?
MatrixType::ColsAtCompileTime - 1 : EiDynamic; MatrixType::ColsAtCompileTime - 1 : Dynamic;
EiMinor(const MatRef& matrix, Minor(const MatRef& matrix,
int row, int col = 0) int row, int col = 0)
: m_matrix(matrix), m_row(row), m_col(col) : m_matrix(matrix), m_row(row), m_col(col)
{ {
EI_CHECK_RANGES(matrix, row, col); EI_CHECK_RANGES(matrix, row, col);
} }
EiMinor(const EiMinor& other) Minor(const Minor& other)
: m_matrix(other.m_matrix), m_row(other.m_row), m_col(other.m_col) {} : m_matrix(other.m_matrix), m_row(other.m_row), m_col(other.m_col) {}
EI_INHERIT_ASSIGNMENT_OPERATORS(EiMinor) EI_INHERIT_ASSIGNMENT_OPERATORS(Minor)
private: private:
EiMinor& _ref() { return *this; } Minor& _ref() { return *this; }
const EiMinor& _constRef() const { return *this; } const Minor& _constRef() const { return *this; }
int _rows() const { return m_matrix.rows() - 1; } int _rows() const { return m_matrix.rows() - 1; }
int _cols() const { return m_matrix.cols() - 1; } int _cols() const { return m_matrix.cols() - 1; }
@ -74,10 +74,10 @@ template<typename MatrixType> class EiMinor
}; };
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
EiMinor<Derived> Minor<Derived>
EiObject<Scalar, Derived>::minor(int row, int col) Object<Scalar, Derived>::minor(int row, int col)
{ {
return EiMinor<Derived>(static_cast<Derived*>(this)->ref(), row, col); return Minor<Derived>(static_cast<Derived*>(this)->ref(), row, col);
} }
#endif // EI_MINOR_H #endif // EI_MINOR_H

View File

@ -1,20 +1,20 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -27,9 +27,9 @@
#ifndef EI_NUMERIC_H #ifndef EI_NUMERIC_H
#define EI_NUMERIC_H #define EI_NUMERIC_H
template<typename T> struct EiNumTraits; template<typename T> struct NumTraits;
template<> struct EiNumTraits<int> template<> struct NumTraits<int>
{ {
typedef int Real; typedef int Real;
typedef double FloatingPoint; typedef double FloatingPoint;
@ -54,7 +54,7 @@ template<> struct EiNumTraits<int>
} }
}; };
template<> struct EiNumTraits<float> template<> struct NumTraits<float>
{ {
typedef float Real; typedef float Real;
typedef float FloatingPoint; typedef float FloatingPoint;
@ -76,7 +76,7 @@ template<> struct EiNumTraits<float>
} }
}; };
template<> struct EiNumTraits<double> template<> struct NumTraits<double>
{ {
typedef double Real; typedef double Real;
typedef double FloatingPoint; typedef double FloatingPoint;
@ -98,17 +98,17 @@ template<> struct EiNumTraits<double>
} }
}; };
template<typename _Real> struct EiNumTraits<std::complex<_Real> > template<typename _Real> struct NumTraits<std::complex<_Real> >
{ {
typedef _Real Real; typedef _Real Real;
typedef std::complex<Real> Complex; typedef std::complex<Real> Complex;
typedef std::complex<double> FloatingPoint; typedef std::complex<double> FloatingPoint;
typedef typename EiNumTraits<Real>::FloatingPoint RealFloatingPoint; typedef typename NumTraits<Real>::FloatingPoint RealFloatingPoint;
static const bool IsComplex = true; static const bool IsComplex = true;
static const bool HasFloatingPoint = EiNumTraits<Real>::HasFloatingPoint; static const bool HasFloatingPoint = NumTraits<Real>::HasFloatingPoint;
static Real epsilon() { return EiNumTraits<Real>::epsilon(); } static Real epsilon() { return NumTraits<Real>::epsilon(); }
static Real real(const Complex& x) { return std::real(x); } static Real real(const Complex& x) { return std::real(x); }
static Real imag(const Complex& x) { return std::imag(x); } static Real imag(const Complex& x) { return std::imag(x); }
static Complex conj(const Complex& x) { return std::conj(x); } static Complex conj(const Complex& x) { return std::conj(x); }
@ -120,48 +120,48 @@ template<typename _Real> struct EiNumTraits<std::complex<_Real> >
{ return std::real(x) * std::real(x) + std::imag(x) * std::imag(x); } { return std::real(x) * std::real(x) + std::imag(x) * std::imag(x); }
static Complex rand() static Complex rand()
{ {
return Complex(EiNumTraits<Real>::rand(), EiNumTraits<Real>::rand()); return Complex(NumTraits<Real>::rand(), NumTraits<Real>::rand());
} }
}; };
template<typename T> typename EiNumTraits<T>::Real EiReal(const T& x) template<typename T> typename NumTraits<T>::Real Real(const T& x)
{ return EiNumTraits<T>::real(x); } { return NumTraits<T>::real(x); }
template<typename T> typename EiNumTraits<T>::Real EiImag(const T& x) template<typename T> typename NumTraits<T>::Real Imag(const T& x)
{ return EiNumTraits<T>::imag(x); } { return NumTraits<T>::imag(x); }
template<typename T> T EiConj(const T& x) template<typename T> T Conj(const T& x)
{ return EiNumTraits<T>::conj(x); } { return NumTraits<T>::conj(x); }
template<typename T> typename EiNumTraits<T>::FloatingPoint EiSqrt(const T& x) template<typename T> typename NumTraits<T>::FloatingPoint Sqrt(const T& x)
{ return EiNumTraits<T>::sqrt(x); } { return NumTraits<T>::sqrt(x); }
template<typename T> typename EiNumTraits<T>::RealFloatingPoint EiAbs(const T& x) template<typename T> typename NumTraits<T>::RealFloatingPoint Abs(const T& x)
{ return EiNumTraits<T>::abs(x); } { return NumTraits<T>::abs(x); }
template<typename T> typename EiNumTraits<T>::Real EiAbs2(const T& x) template<typename T> typename NumTraits<T>::Real Abs2(const T& x)
{ return EiNumTraits<T>::abs2(x); } { return NumTraits<T>::abs2(x); }
template<typename T> T EiRand() template<typename T> T Rand()
{ return EiNumTraits<T>::rand(); } { return NumTraits<T>::rand(); }
template<typename T> bool EiNegligible(const T& a, const T& b) template<typename T> bool Negligible(const T& a, const T& b)
{ {
return(EiAbs(a) <= EiAbs(b) * EiNumTraits<T>::epsilon()); return(Abs(a) <= Abs(b) * NumTraits<T>::epsilon());
} }
template<typename T> bool EiApprox(const T& a, const T& b) template<typename T> bool Approx(const T& a, const T& b)
{ {
if(EiNumTraits<T>::IsFloat) if(NumTraits<T>::IsFloat)
return(EiAbs(a - b) <= std::min(EiAbs(a), EiAbs(b)) * EiNumTraits<T>::epsilon()); return(Abs(a - b) <= std::min(Abs(a), Abs(b)) * NumTraits<T>::epsilon());
else else
return(a == b); return(a == b);
} }
template<typename T> bool EiLessThanOrApprox(const T& a, const T& b) template<typename T> bool LessThanOrApprox(const T& a, const T& b)
{ {
if(EiNumTraits<T>::IsFloat) if(NumTraits<T>::IsFloat)
return(a < b || EiApprox(a, b)); return(a < b || Approx(a, b));
else else
return(a <= b); return(a <= b);
} }

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -26,23 +26,23 @@
#ifndef EI_OBJECT_H #ifndef EI_OBJECT_H
#define EI_OBJECT_H #define EI_OBJECT_H
template<typename Scalar, typename Derived> class EiObject template<typename Scalar, typename Derived> class Object
{ {
static const int RowsAtCompileTime = Derived::RowsAtCompileTime, static const int RowsAtCompileTime = Derived::RowsAtCompileTime,
ColsAtCompileTime = Derived::ColsAtCompileTime; ColsAtCompileTime = Derived::ColsAtCompileTime;
template<typename OtherDerived> template<typename OtherDerived>
void _copy_helper(const EiObject<Scalar, OtherDerived>& other); void _copy_helper(const Object<Scalar, OtherDerived>& other);
public: public:
static const int SizeAtCompileTime static const int SizeAtCompileTime
= RowsAtCompileTime == EiDynamic || ColsAtCompileTime == EiDynamic = RowsAtCompileTime == Dynamic || ColsAtCompileTime == Dynamic
? EiDynamic : RowsAtCompileTime * ColsAtCompileTime; ? Dynamic : RowsAtCompileTime * ColsAtCompileTime;
static const bool IsVector = RowsAtCompileTime == 1 || ColsAtCompileTime == 1; static const bool IsVector = RowsAtCompileTime == 1 || ColsAtCompileTime == 1;
typedef typename EiForwardDecl<Derived>::Ref Ref; typedef typename ForwardDecl<Derived>::Ref Ref;
typedef typename EiForwardDecl<Derived>::ConstRef ConstRef; typedef typename ForwardDecl<Derived>::ConstRef ConstRef;
typedef typename EiNumTraits<Scalar>::Real RealScalar; typedef typename NumTraits<Scalar>::Real RealScalar;
int rows() const { return static_cast<const Derived *>(this)->_rows(); } int rows() const { return static_cast<const Derived *>(this)->_rows(); }
int cols() const { return static_cast<const Derived *>(this)->_cols(); } int cols() const { return static_cast<const Derived *>(this)->_cols(); }
@ -65,7 +65,7 @@ template<typename Scalar, typename Derived> class EiObject
} }
template<typename OtherDerived> template<typename OtherDerived>
Derived& operator=(const EiObject<Scalar, OtherDerived>& other) Derived& operator=(const Object<Scalar, OtherDerived>& other)
{ {
assert(rows() == other.rows() && cols() == other.cols()); assert(rows() == other.rows() && cols() == other.cols());
_copy_helper(other); _copy_helper(other);
@ -74,20 +74,20 @@ template<typename Scalar, typename Derived> class EiObject
//special case of the above template operator=. Strangely, g++ 4.1 failed to use //special case of the above template operator=. Strangely, g++ 4.1 failed to use
//that template when OtherDerived == Derived //that template when OtherDerived == Derived
Derived& operator=(const EiObject& other) Derived& operator=(const Object& other)
{ {
assert(rows() == other.rows() && cols() == other.cols()); assert(rows() == other.rows() && cols() == other.cols());
_copy_helper(other); _copy_helper(other);
return *static_cast<Derived*>(this); return *static_cast<Derived*>(this);
} }
EiRow<Derived> row(int i); Row<Derived> row(int i);
EiColumn<Derived> col(int i); Column<Derived> col(int i);
EiMinor<Derived> minor(int row, int col); Minor<Derived> minor(int row, int col);
EiBlock<Derived> block(int startRow, int endRow, int startCol, int endCol); Block<Derived> block(int startRow, int endRow, int startCol, int endCol);
EiTranspose<Derived> transpose(); Transpose<Derived> transpose();
EiConjugate<Derived> conjugate() const; Conjugate<Derived> conjugate() const;
EiTranspose<EiConjugate<Derived> > adjoint() const { return conjugate().transpose(); } Transpose<Conjugate<Derived> > adjoint() const { return conjugate().transpose(); }
Scalar trace() const; Scalar trace() const;
template<typename OtherDerived> template<typename OtherDerived>
@ -95,9 +95,9 @@ template<typename Scalar, typename Derived> class EiObject
RealScalar norm2() const; RealScalar norm2() const;
RealScalar norm() const; RealScalar norm() const;
EiScalarProduct<Derived> normalized() const; ScalarProduct<Derived> normalized() const;
static EiEval<EiRandom<Derived> > static Eval<Random<Derived> >
random(int rows = RowsAtCompileTime, int cols = ColsAtCompileTime); random(int rows = RowsAtCompileTime, int cols = ColsAtCompileTime);
template<typename OtherDerived> template<typename OtherDerived>
@ -106,15 +106,15 @@ template<typename Scalar, typename Derived> class EiObject
bool isNegligible(const OtherDerived& other) const; bool isNegligible(const OtherDerived& other) const;
template<typename OtherDerived> template<typename OtherDerived>
EiMatrixProduct<Derived, OtherDerived> MatrixProduct<Derived, OtherDerived>
lazyMul(const EiObject<Scalar, OtherDerived>& other) const EI_ALWAYS_INLINE; lazyMul(const Object<Scalar, OtherDerived>& other) const EI_ALWAYS_INLINE;
template<typename OtherDerived> template<typename OtherDerived>
Derived& operator+=(const EiObject<Scalar, OtherDerived>& other); Derived& operator+=(const Object<Scalar, OtherDerived>& other);
template<typename OtherDerived> template<typename OtherDerived>
Derived& operator-=(const EiObject<Scalar, OtherDerived>& other); Derived& operator-=(const Object<Scalar, OtherDerived>& other);
template<typename OtherDerived> template<typename OtherDerived>
Derived& operator*=(const EiObject<Scalar, OtherDerived>& other); Derived& operator*=(const Object<Scalar, OtherDerived>& other);
Derived& operator*=(const int& other); Derived& operator*=(const int& other);
Derived& operator*=(const float& other); Derived& operator*=(const float& other);
@ -150,13 +150,13 @@ template<typename Scalar, typename Derived> class EiObject
else return write(index, 0); else return write(index, 0);
} }
EiEval<Derived> eval() const EI_ALWAYS_INLINE; Eval<Derived> eval() const EI_ALWAYS_INLINE;
}; };
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
std::ostream & operator << std::ostream & operator <<
( std::ostream & s, ( std::ostream & s,
const EiObject<Scalar, Derived> & m ) const Object<Scalar, Derived> & m )
{ {
for( int i = 0; i < m.rows(); i++ ) for( int i = 0; i < m.rows(); i++ )
{ {

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -26,24 +26,24 @@
#ifndef EI_RANDOM_H #ifndef EI_RANDOM_H
#define EI_RANDOM_H #define EI_RANDOM_H
template<typename MatrixType> class EiRandom template<typename MatrixType> class Random
: public EiObject<typename MatrixType::Scalar, EiRandom<MatrixType> > : public Object<typename MatrixType::Scalar, Random<MatrixType> >
{ {
public: public:
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
friend class EiObject<Scalar, EiRandom<MatrixType> >; friend class Object<Scalar, Random<MatrixType> >;
static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime,
ColsAtCompileTime = MatrixType::ColsAtCompileTime; ColsAtCompileTime = MatrixType::ColsAtCompileTime;
EiRandom(int rows, int cols) : m_rows(rows), m_cols(cols) Random(int rows, int cols) : m_rows(rows), m_cols(cols)
{ {
assert(rows > 0 && cols > 0); assert(rows > 0 && cols > 0);
} }
private: private:
EiRandom& _ref() { return *this; } Random& _ref() { return *this; }
const EiRandom& _constRef() const { return *this; } const Random& _constRef() const { return *this; }
int _rows() const { return m_rows; } int _rows() const { return m_rows; }
int _cols() const { return m_cols; } int _cols() const { return m_cols; }
@ -51,7 +51,7 @@ template<typename MatrixType> class EiRandom
{ {
EI_UNUSED(row); EI_UNUSED(row);
EI_UNUSED(col); EI_UNUSED(col);
return EiRand<Scalar>(); return Rand<Scalar>();
} }
protected: protected:
@ -59,9 +59,9 @@ template<typename MatrixType> class EiRandom
}; };
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
EiEval<EiRandom<Derived> > EiObject<Scalar, Derived>::random(int rows, int cols) Eval<Random<Derived> > Object<Scalar, Derived>::random(int rows, int cols)
{ {
return EiRandom<Derived>(rows, cols).eval(); return Random<Derived>(rows, cols).eval();
} }
#endif // EI_RANDOM_H #endif // EI_RANDOM_H

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -26,37 +26,37 @@
#ifndef EI_ROW_H #ifndef EI_ROW_H
#define EI_ROW_H #define EI_ROW_H
template<typename MatrixType> class EiRow template<typename MatrixType> class Row
: public EiObject<typename MatrixType::Scalar, EiRow<MatrixType> > : public Object<typename MatrixType::Scalar, Row<MatrixType> >
{ {
public: public:
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef; typedef typename MatrixType::Ref MatRef;
friend class EiObject<Scalar, EiRow<MatrixType> >; friend class Object<Scalar, Row<MatrixType> >;
static const int RowsAtCompileTime = 1, static const int RowsAtCompileTime = 1,
ColsAtCompileTime = MatrixType::ColsAtCompileTime; ColsAtCompileTime = MatrixType::ColsAtCompileTime;
EiRow(const MatRef& matrix, int row) Row(const MatRef& matrix, int row)
: m_matrix(matrix), m_row(row) : m_matrix(matrix), m_row(row)
{ {
EI_CHECK_ROW_RANGE(matrix, row); EI_CHECK_ROW_RANGE(matrix, row);
} }
EiRow(const EiRow& other) Row(const Row& other)
: m_matrix(other.m_matrix), m_row(other.m_row) {} : m_matrix(other.m_matrix), m_row(other.m_row) {}
template<typename OtherDerived> template<typename OtherDerived>
EiRow& operator=(const EiObject<Scalar, OtherDerived>& other) Row& operator=(const Object<Scalar, OtherDerived>& other)
{ {
return EiObject<Scalar, EiRow<MatrixType> >::operator=(other); return Object<Scalar, Row<MatrixType> >::operator=(other);
} }
EI_INHERIT_ASSIGNMENT_OPERATORS(EiRow) EI_INHERIT_ASSIGNMENT_OPERATORS(Row)
private: private:
EiRow& _ref() { return *this; } Row& _ref() { return *this; }
const EiRow& _constRef() const { return *this; } const Row& _constRef() const { return *this; }
int _rows() const { return 1; } int _rows() const { return 1; }
int _cols() const { return m_matrix.cols(); } int _cols() const { return m_matrix.cols(); }
@ -79,10 +79,10 @@ template<typename MatrixType> class EiRow
}; };
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
EiRow<Derived> Row<Derived>
EiObject<Scalar, Derived>::row(int i) Object<Scalar, Derived>::row(int i)
{ {
return EiRow<Derived>(static_cast<Derived*>(this)->ref(), i); return Row<Derived>(static_cast<Derived*>(this)->ref(), i);
} }
#endif // EI_ROW_H #endif // EI_ROW_H

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -26,28 +26,28 @@
#ifndef EI_SCALAROPS_H #ifndef EI_SCALAROPS_H
#define EI_SCALAROPS_H #define EI_SCALAROPS_H
template<typename MatrixType> class EiScalarProduct template<typename MatrixType> class ScalarProduct
: public EiObject<typename MatrixType::Scalar, EiScalarProduct<MatrixType> > : public Object<typename MatrixType::Scalar, ScalarProduct<MatrixType> >
{ {
public: public:
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::ConstRef MatRef; typedef typename MatrixType::ConstRef MatRef;
friend class EiObject<typename MatrixType::Scalar, EiScalarProduct<MatrixType> >; friend class Object<typename MatrixType::Scalar, ScalarProduct<MatrixType> >;
static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime,
ColsAtCompileTime = MatrixType::ColsAtCompileTime; ColsAtCompileTime = MatrixType::ColsAtCompileTime;
EiScalarProduct(const MatRef& matrix, Scalar scalar) ScalarProduct(const MatRef& matrix, Scalar scalar)
: m_matrix(matrix), m_scalar(scalar) {} : m_matrix(matrix), m_scalar(scalar) {}
EiScalarProduct(const EiScalarProduct& other) ScalarProduct(const ScalarProduct& other)
: m_matrix(other.m_matrix), m_scalar(other.m_scalar) {} : m_matrix(other.m_matrix), m_scalar(other.m_scalar) {}
EI_INHERIT_ASSIGNMENT_OPERATORS(EiScalarProduct) EI_INHERIT_ASSIGNMENT_OPERATORS(ScalarProduct)
private: private:
const EiScalarProduct& _ref() const { return *this; } const ScalarProduct& _ref() const { return *this; }
const EiScalarProduct& _constRef() const { return *this; } const ScalarProduct& _constRef() const { return *this; }
int _rows() const { return m_matrix.rows(); } int _rows() const { return m_matrix.rows(); }
int _cols() const { return m_matrix.cols(); } int _cols() const { return m_matrix.cols(); }
@ -63,40 +63,40 @@ template<typename MatrixType> class EiScalarProduct
#define EI_MAKE_SCALAR_OPS(OtherScalar) \ #define EI_MAKE_SCALAR_OPS(OtherScalar) \
template<typename Scalar, typename Derived> \ template<typename Scalar, typename Derived> \
EiScalarProduct<Derived> \ ScalarProduct<Derived> \
operator*(const EiObject<Scalar, Derived>& matrix, \ operator*(const Object<Scalar, Derived>& matrix, \
OtherScalar scalar) \ OtherScalar scalar) \
{ \ { \
return EiScalarProduct<Derived>(matrix.constRef(), scalar); \ return ScalarProduct<Derived>(matrix.constRef(), scalar); \
} \ } \
\ \
template<typename Scalar, typename Derived> \ template<typename Scalar, typename Derived> \
EiScalarProduct<Derived> \ ScalarProduct<Derived> \
operator*(OtherScalar scalar, \ operator*(OtherScalar scalar, \
const EiObject<Scalar, Derived>& matrix) \ const Object<Scalar, Derived>& matrix) \
{ \ { \
return EiScalarProduct<Derived>(matrix.constRef(), scalar); \ return ScalarProduct<Derived>(matrix.constRef(), scalar); \
} \ } \
\ \
template<typename Scalar, typename Derived> \ template<typename Scalar, typename Derived> \
EiScalarProduct<Derived> \ ScalarProduct<Derived> \
operator/(const EiObject<Scalar, Derived>& matrix, \ operator/(const Object<Scalar, Derived>& matrix, \
OtherScalar scalar) \ OtherScalar scalar) \
{ \ { \
assert(EiNumTraits<Scalar>::HasFloatingPoint); \ assert(NumTraits<Scalar>::HasFloatingPoint); \
return matrix * (static_cast<Scalar>(1) / scalar); \ return matrix * (static_cast<Scalar>(1) / scalar); \
} \ } \
\ \
template<typename Scalar, typename Derived> \ template<typename Scalar, typename Derived> \
Derived & \ Derived & \
EiObject<Scalar, Derived>::operator*=(const OtherScalar &other) \ Object<Scalar, Derived>::operator*=(const OtherScalar &other) \
{ \ { \
return *this = *this * other; \ return *this = *this * other; \
} \ } \
\ \
template<typename Scalar, typename Derived> \ template<typename Scalar, typename Derived> \
Derived & \ Derived & \
EiObject<Scalar, Derived>::operator/=(const OtherScalar &other) \ Object<Scalar, Derived>::operator/=(const OtherScalar &other) \
{ \ { \
return *this = *this / other; \ return *this = *this / other; \
} }

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -26,16 +26,16 @@
#ifndef EI_TRACE_H #ifndef EI_TRACE_H
#define EI_TRACE_H #define EI_TRACE_H
template<int Index, int Rows, typename Derived> struct EiTraceUnroller template<int Index, int Rows, typename Derived> struct TraceUnroller
{ {
static void run(const Derived &mat, typename Derived::Scalar &trace) static void run(const Derived &mat, typename Derived::Scalar &trace)
{ {
EiTraceUnroller<Index-1, Rows, Derived>::run(mat, trace); TraceUnroller<Index-1, Rows, Derived>::run(mat, trace);
trace += mat(Index, Index); trace += mat(Index, Index);
} }
}; };
template<int Rows, typename Derived> struct EiTraceUnroller<0, Rows, Derived> template<int Rows, typename Derived> struct TraceUnroller<0, Rows, Derived>
{ {
static void run(const Derived &mat, typename Derived::Scalar &trace) static void run(const Derived &mat, typename Derived::Scalar &trace)
{ {
@ -43,7 +43,7 @@ template<int Rows, typename Derived> struct EiTraceUnroller<0, Rows, Derived>
} }
}; };
template<int Index, typename Derived> struct EiTraceUnroller<Index, EiDynamic, Derived> template<int Index, typename Derived> struct TraceUnroller<Index, Dynamic, Derived>
{ {
static void run(const Derived &mat, typename Derived::Scalar &trace) static void run(const Derived &mat, typename Derived::Scalar &trace)
{ {
@ -53,12 +53,12 @@ template<int Index, typename Derived> struct EiTraceUnroller<Index, EiDynamic, D
}; };
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
Scalar EiObject<Scalar, Derived>::trace() const Scalar Object<Scalar, Derived>::trace() const
{ {
assert(rows() == cols()); assert(rows() == cols());
Scalar res; Scalar res;
if(RowsAtCompileTime != EiDynamic && RowsAtCompileTime <= 16) if(RowsAtCompileTime != Dynamic && RowsAtCompileTime <= 16)
EiTraceUnroller<RowsAtCompileTime-1, RowsAtCompileTime, Derived> TraceUnroller<RowsAtCompileTime-1, RowsAtCompileTime, Derived>
::run(*static_cast<const Derived*>(this), res); ::run(*static_cast<const Derived*>(this), res);
else else
{ {

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -26,27 +26,27 @@
#ifndef EI_TRANSPOSE_H #ifndef EI_TRANSPOSE_H
#define EI_TRANSPOSE_H #define EI_TRANSPOSE_H
template<typename MatrixType> class EiTranspose template<typename MatrixType> class Transpose
: public EiObject<typename MatrixType::Scalar, EiTranspose<MatrixType> > : public Object<typename MatrixType::Scalar, Transpose<MatrixType> >
{ {
public: public:
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Ref MatRef; typedef typename MatrixType::Ref MatRef;
friend class EiObject<Scalar, EiTranspose<MatrixType> >; friend class Object<Scalar, Transpose<MatrixType> >;
static const int RowsAtCompileTime = MatrixType::ColsAtCompileTime, static const int RowsAtCompileTime = MatrixType::ColsAtCompileTime,
ColsAtCompileTime = MatrixType::RowsAtCompileTime; ColsAtCompileTime = MatrixType::RowsAtCompileTime;
EiTranspose(const MatRef& matrix) : m_matrix(matrix) {} Transpose(const MatRef& matrix) : m_matrix(matrix) {}
EiTranspose(const EiTranspose& other) Transpose(const Transpose& other)
: m_matrix(other.m_matrix) {} : m_matrix(other.m_matrix) {}
EI_INHERIT_ASSIGNMENT_OPERATORS(EiTranspose) EI_INHERIT_ASSIGNMENT_OPERATORS(Transpose)
private: private:
EiTranspose& _ref() { return *this; } Transpose& _ref() { return *this; }
const EiTranspose& _constRef() const { return *this; } const Transpose& _constRef() const { return *this; }
int _rows() const { return m_matrix.cols(); } int _rows() const { return m_matrix.cols(); }
int _cols() const { return m_matrix.rows(); } int _cols() const { return m_matrix.rows(); }
@ -65,10 +65,10 @@ template<typename MatrixType> class EiTranspose
}; };
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
EiTranspose<Derived> Transpose<Derived>
EiObject<Scalar, Derived>::transpose() Object<Scalar, Derived>::transpose()
{ {
return EiTranspose<Derived>(static_cast<Derived*>(this)->ref()); return Transpose<Derived>(static_cast<Derived*>(this)->ref());
} }
#endif // EI_TRANSPOSE_H #endif // EI_TRANSPOSE_H

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -26,12 +26,12 @@
#ifndef EI_UTIL_H #ifndef EI_UTIL_H
#define EI_UTIL_H #define EI_UTIL_H
#include <iostream>
#include <complex>
#include <cassert>
#undef minor #undef minor
#define USING_EIGEN_DATA_TYPES \
EI_USING_MATRIX_TYPEDEFS \
using Eigen::Matrix;
#define EI_UNUSED(x) (void)x #define EI_UNUSED(x) (void)x
#define EI_CHECK_RANGES(matrix, row, col) \ #define EI_CHECK_RANGES(matrix, row, col) \
assert(row >= 0 && row < (matrix).rows() && col >= 0 && col < (matrix).cols()) assert(row >= 0 && row < (matrix).rows() && col >= 0 && col < (matrix).cols())
@ -41,36 +41,36 @@
assert(col >= 0 && col < (matrix).cols()) assert(col >= 0 && col < (matrix).cols())
//forward declarations //forward declarations
template<typename _Scalar, int _Rows, int _Cols> class EiMatrix; template<typename _Scalar, int _Rows, int _Cols> class Matrix;
template<typename MatrixType> class EiMatrixRef; template<typename MatrixType> class MatrixRef;
template<typename MatrixType> class EiMatrixConstRef; template<typename MatrixType> class MatrixConstRef;
template<typename MatrixType> class EiRow; template<typename MatrixType> class Row;
template<typename MatrixType> class EiColumn; template<typename MatrixType> class Column;
template<typename MatrixType> class EiMinor; template<typename MatrixType> class Minor;
template<typename MatrixType> class EiBlock; template<typename MatrixType> class Block;
template<typename MatrixType> class EiTranspose; template<typename MatrixType> class Transpose;
template<typename MatrixType> class EiConjugate; template<typename MatrixType> class Conjugate;
template<typename Lhs, typename Rhs> class EiSum; template<typename Lhs, typename Rhs> class Sum;
template<typename Lhs, typename Rhs> class EiDifference; template<typename Lhs, typename Rhs> class Difference;
template<typename Lhs, typename Rhs> class EiMatrixProduct; template<typename Lhs, typename Rhs> class MatrixProduct;
template<typename MatrixType> class EiScalarProduct; template<typename MatrixType> class ScalarProduct;
template<typename MatrixType> class EiRandom; template<typename MatrixType> class Random;
template<typename ExpressionType> class EiEval; template<typename ExpressionType> class Eval;
template<typename T> struct EiForwardDecl template<typename T> struct ForwardDecl
{ {
typedef T Ref; typedef T Ref;
typedef T ConstRef; typedef T ConstRef;
}; };
template<typename _Scalar, int _Rows, int _Cols> template<typename _Scalar, int _Rows, int _Cols>
struct EiForwardDecl<EiMatrix<_Scalar, _Rows, _Cols> > struct ForwardDecl<Matrix<_Scalar, _Rows, _Cols> >
{ {
typedef EiMatrixRef<EiMatrix<_Scalar, _Rows, _Cols> > Ref; typedef MatrixRef<Matrix<_Scalar, _Rows, _Cols> > Ref;
typedef EiMatrixConstRef<EiMatrix<_Scalar, _Rows, _Cols> > ConstRef; typedef MatrixConstRef<Matrix<_Scalar, _Rows, _Cols> > ConstRef;
}; };
const int EiDynamic = -1; const int Dynamic = -1;
#define EI_LOOP_UNROLLING_LIMIT 25 #define EI_LOOP_UNROLLING_LIMIT 25
@ -86,20 +86,20 @@ const int EiDynamic = -1;
#define EI_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \ #define EI_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \
template<typename OtherScalar, typename OtherDerived> \ template<typename OtherScalar, typename OtherDerived> \
Derived& operator Op(const EiObject<OtherScalar, OtherDerived>& other) \ Derived& operator Op(const Object<OtherScalar, OtherDerived>& other) \
{ \ { \
return EiObject<Scalar, Derived>::operator Op(other); \ return Object<Scalar, Derived>::operator Op(other); \
} \ } \
Derived& operator Op(const Derived& other) \ Derived& operator Op(const Derived& other) \
{ \ { \
return EiObject<Scalar, Derived>::operator Op(other); \ return Object<Scalar, Derived>::operator Op(other); \
} }
#define EI_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \ #define EI_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \
template<typename Other> \ template<typename Other> \
Derived& operator Op(const Other& scalar) \ Derived& operator Op(const Other& scalar) \
{ \ { \
return EiObject<Scalar, Derived>::operator Op(scalar); \ return Object<Scalar, Derived>::operator Op(scalar); \
} }
#define EI_INHERIT_ASSIGNMENT_OPERATORS(Derived) \ #define EI_INHERIT_ASSIGNMENT_OPERATORS(Derived) \

View File

@ -15,6 +15,6 @@ QT4_AUTOMOC(${test_SRCS})
ADD_EXECUTABLE(test ${test_SRCS}) ADD_EXECUTABLE(test ${test_SRCS})
TARGET_LINK_LIBRARIES(test ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY}) TARGET_LINK_LIBRARIES(test ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY})
ADD_TEST(Eigen test) ADD_TEST(gen test)
ENDIF(BUILD_TESTS) ENDIF(BUILD_TESTS)

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -25,7 +25,7 @@
#include "main.h" #include "main.h"
EigenTest::EigenTest() genTest::genTest()
{ {
unsigned int t = (unsigned int) time( NULL ); unsigned int t = (unsigned int) time( NULL );
qDebug() << "Initializing random number generator with seed" qDebug() << "Initializing random number generator with seed"
@ -33,5 +33,5 @@ EigenTest::EigenTest()
srand(t); srand(t);
} }
QTEST_APPLESS_MAIN( EigenTest ) QTEST_APPLESS_MAIN( genTest )
#include "main.moc" #include "main.moc"

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -29,17 +29,19 @@
#include <QtTest/QtTest> #include <QtTest/QtTest>
#include "../src/Core.h" #include "../src/Core.h"
USING_EIGEN_DATA_TYPES
#include <cstdlib> #include <cstdlib>
#include <ctime> #include <ctime>
using namespace std; using namespace std;
class EigenTest : public QObject class genTest : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
EigenTest(); genTest();
private slots: private slots:
void testVectorOps(); void testVectorOps();
@ -47,7 +49,7 @@ class EigenTest : public QObject
void testMatrixManip(); void testMatrixManip();
}; };
template<typename T> inline typename EiNumTraits<T>::Real TestEpsilon(); template<typename T> inline typename Eigen::NumTraits<T>::Real TestEpsilon();
template<> inline int TestEpsilon<int>() { return 0; } template<> inline int TestEpsilon<int>() { return 0; }
template<> inline float TestEpsilon<float>() { return 1e-2f; } template<> inline float TestEpsilon<float>() { return 1e-2f; }
template<> inline double TestEpsilon<double>() { return 1e-4; } template<> inline double TestEpsilon<double>() { return 1e-4; }
@ -57,21 +59,21 @@ template<> inline double TestEpsilon<std::complex<double> >() { return TestEpsil
template<typename T> bool TestNegligible(const T& a, const T& b) template<typename T> bool TestNegligible(const T& a, const T& b)
{ {
return(EiAbs(a) <= EiAbs(b) * TestEpsilon<T>()); return(Abs(a) <= Abs(b) * TestEpsilon<T>());
} }
template<typename T> bool TestApprox(const T& a, const T& b) template<typename T> bool TestApprox(const T& a, const T& b)
{ {
if(EiNumTraits<T>::IsFloat) if(Eigen::NumTraits<T>::IsFloat)
return(EiAbs(a - b) <= std::min(EiAbs(a), EiAbs(b)) * TestEpsilon<T>()); return(Abs(a - b) <= std::min(Abs(a), Abs(b)) * TestEpsilon<T>());
else else
return(a == b); return(a == b);
} }
template<typename T> bool TestLessThanOrApprox(const T& a, const T& b) template<typename T> bool TestLessThanOrApprox(const T& a, const T& b)
{ {
if(EiNumTraits<T>::IsFloat) if(Eigen::NumTraits<T>::IsFloat)
return(a < b || EiApprox(a, b)); return(a < b || Approx(a, b));
else else
return(a <= b); return(a <= b);
} }

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -42,12 +42,12 @@ template<typename MatrixType> void matrixManip(const MatrixType& m)
a.minor(i, j) -= a.block(1, rows-1, 1, cols-1).eval(); a.minor(i, j) -= a.block(1, rows-1, 1, cols-1).eval();
} }
void EigenTest::testMatrixManip() void genTest::testMatrixManip()
{ {
matrixManip(EiMatrix<int, 2, 3>()); matrixManip(Matrix<int, 2, 3>());
matrixManip(EiMatrix<double, 3, 3>()); matrixManip(Matrix<double, 3, 3>());
matrixManip(EiMatrix<complex<float>, 4,3>()); matrixManip(Matrix<complex<float>, 4,3>());
matrixManip(EiMatrixXi(2, 2)); matrixManip(MatrixXi(2, 2));
matrixManip(EiMatrixXd(3, 5)); matrixManip(MatrixXd(3, 5));
matrixManip(EiMatrixXcf(4, 4)); matrixManip(MatrixXcf(4, 4));
} }

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -59,16 +59,16 @@ template<typename MatrixType1,
QVERIFY( (d * e).rows() == rows1 && (d * e).cols() == cols2 ); QVERIFY( (d * e).rows() == rows1 && (d * e).cols() == cols2 );
} }
void EigenTest::testMatrixOps() void genTest::testMatrixOps()
{ {
matrixOps(EiMatrix<float, 1, 1>(), EiMatrix<float, 1, 1>()); matrixOps(Matrix<float, 1, 1>(), Matrix<float, 1, 1>());
matrixOps(EiMatrix<int, 2, 3>(), EiMatrix<int, 3, 1>()); matrixOps(Matrix<int, 2, 3>(), Matrix<int, 3, 1>());
matrixOps(EiMatrix<double, 3, 3>(), EiMatrix<double, 3, 3>()); matrixOps(Matrix<double, 3, 3>(), Matrix<double, 3, 3>());
matrixOps(EiMatrix<complex<float>, 4,3>(), EiMatrix<complex<float>, 3,4>()); matrixOps(Matrix<complex<float>, 4,3>(), Matrix<complex<float>, 3,4>());
matrixOps(EiMatrixXf(1, 1), EiMatrixXf(1, 3)); matrixOps(MatrixXf(1, 1), MatrixXf(1, 3));
matrixOps(EiMatrixXi(2, 2), EiMatrixXi(2, 2)); matrixOps(MatrixXi(2, 2), MatrixXi(2, 2));
matrixOps(EiMatrixXd(3, 5), EiMatrixXd(5, 1)); matrixOps(MatrixXd(3, 5), MatrixXd(5, 1));
matrixOps(EiMatrixXcf(4, 4), EiMatrixXcf(4, 4)); matrixOps(MatrixXcf(4, 4), MatrixXcf(4, 4));
matrixOps(EiMatrixXd(3, 5), EiMatrix<double, 5, 1>()); matrixOps(MatrixXd(3, 5), Matrix<double, 5, 1>());
matrixOps(EiMatrix4cf(), EiMatrixXcf(4, 4)); matrixOps(Matrix4cf(), MatrixXcf(4, 4));
} }

View File

@ -1,19 +1,19 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of gen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. gen itself is part of the KDE project.
// //
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr> // Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
// //
// Eigen is free software; you can redistribute it and/or modify it under the // gen 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 // terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 or (at your option) any later version. // 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 // gen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details. // details.
// //
// You should have received a copy of the GNU General Public License along // 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 // with gen; if not, write to the Free Software Foundation, Inc., 51
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. // Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
// //
// As a special exception, if other files instantiate templates or use macros // As a special exception, if other files instantiate templates or use macros
@ -50,13 +50,13 @@ template<typename VectorType> void vectorOps(const VectorType& v)
a += (a + a).eval(); a += (a + a).eval();
} }
void EigenTest::testVectorOps() void genTest::testVectorOps()
{ {
vectorOps(EiVector2i()); vectorOps(Vector2i());
vectorOps(EiVector3d()); vectorOps(Vector3d());
vectorOps(EiVector4cf()); vectorOps(Vector4cf());
vectorOps(EiVectorXf(1)); vectorOps(VectorXf(1));
vectorOps(EiVectorXi(2)); vectorOps(VectorXi(2));
vectorOps(EiVectorXd(3)); vectorOps(VectorXd(3));
vectorOps(EiVectorXcf(4)); vectorOps(VectorXcf(4));
} }