diff --git a/Eigen/Core b/Eigen/Core index 102f23229..9e753a517 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -6,16 +6,27 @@ #include #include -#ifdef EIGEN_VECTORIZE -// it seems we cannot assume posix_memalign is defined in the stdlib header -extern "C" int posix_memalign (void **, size_t, size_t) throw (); -#endif - namespace Eigen { +/** \defgroup Core_Module Core module + * This is the main module of Eigen providing dense matrix and vector support with + * features equivalent to a BLAS library and much more... + * + * \code + * #include + * \endcode + * + * To speedup compilation, in header files you might only include the following file: + * \code + * #include + * \endcode + * which gives access to matrix and vector types as well as coefficient accessor operators. + */ + +#include "src/Core/util/Memory.h" #include "src/Core/NumTraits.h" #include "src/Core/MathFunctions.h" -#include "src/Core/DummyPacketMath.h" +#include "src/Core/GenericPacketMath.h" #if defined EIGEN_VECTORIZE_SSE #include "src/Core/arch/SSE/PacketMath.h" diff --git a/Eigen/Geometry b/Eigen/Geometry index d62723188..b5a80bd50 100644 --- a/Eigen/Geometry +++ b/Eigen/Geometry @@ -15,8 +15,8 @@ namespace Eigen { * - 2D and 3D rotations * - quaternions * - \ref MatrixBase::cross() "cross product" - * - \ref MatrixBase::someOrthognal() "orthognal vector generation" - * + * - \ref MatrixBase::unitOrthogonal() "orthognal vector generation" + * * \code * #include * \endcode diff --git a/Eigen/src/Array/PartialRedux.h b/Eigen/src/Array/PartialRedux.h index 3c511d5b9..27c315d6e 100644 --- a/Eigen/src/Array/PartialRedux.h +++ b/Eigen/src/Array/PartialRedux.h @@ -27,7 +27,7 @@ #define EIGEN_PARTIAL_REDUX_H /** \array_module \ingroup Array - * + * * \class PartialReduxExpr * * \brief Generic expression of a partially reduxed matrix @@ -69,7 +69,11 @@ struct ei_traits > template< typename MatrixType, typename MemberOp, int Direction> class PartialReduxExpr : ei_no_assignment_operator, +#ifndef EIGEN_PARSED_BY_DOXYGEN public MatrixBase > +#else + public MapBase +#endif { public: @@ -186,7 +190,7 @@ template class PartialRedux * * Example: \include PartialRedux_minCoeff.cpp * Output: \verbinclude PartialRedux_minCoeff.out - * + * * \sa MatrixBase::minCoeff() */ const typename ReturnType::Type minCoeff() const { return _expression(); } @@ -196,7 +200,7 @@ template class PartialRedux * * Example: \include PartialRedux_maxCoeff.cpp * Output: \verbinclude PartialRedux_maxCoeff.out - * + * * \sa MatrixBase::maxCoeff() */ const typename ReturnType::Type maxCoeff() const { return _expression(); } @@ -206,7 +210,7 @@ template class PartialRedux * * Example: \include PartialRedux_norm2.cpp * Output: \verbinclude PartialRedux_norm2.out - * + * * \sa MatrixBase::norm2() */ const typename ReturnType::Type norm2() const { return _expression(); } diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index 11583d042..4fb4794a4 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -88,7 +88,11 @@ struct ei_traits class Block +#ifndef EIGEN_PARSED_BY_DOXYGEN : public MatrixBase > +#else + : public MatrixBase +#endif { public: @@ -211,7 +215,11 @@ template class Block +#ifndef EIGEN_PARSED_BY_DOXYGEN : public MapBase > +#else + : public MapBase +#endif { public: diff --git a/Eigen/src/Core/CwiseBinaryOp.h b/Eigen/src/Core/CwiseBinaryOp.h index 2f506377f..da76ac100 100644 --- a/Eigen/src/Core/CwiseBinaryOp.h +++ b/Eigen/src/Core/CwiseBinaryOp.h @@ -76,7 +76,11 @@ struct ei_traits > template class CwiseBinaryOp : ei_no_assignment_operator, +#ifndef EIGEN_PARSED_BY_DOXYGEN public MatrixBase > +#else + public MatrixBase +#endif { public: @@ -183,7 +187,7 @@ MatrixBase::operator+=(const MatrixBase& other) * * Example: \include Cwise_product.cpp * Output: \verbinclude Cwise_product.out - * + * * \sa class CwiseBinaryOp, operator/(), square() */ template diff --git a/Eigen/src/Core/CwiseNullaryOp.h b/Eigen/src/Core/CwiseNullaryOp.h index caa86fa97..723340cef 100644 --- a/Eigen/src/Core/CwiseNullaryOp.h +++ b/Eigen/src/Core/CwiseNullaryOp.h @@ -60,7 +60,11 @@ struct ei_traits > template class CwiseNullaryOp : ei_no_assignment_operator, +#ifndef EIGEN_PARSED_BY_DOXYGEN public MatrixBase > +#else + public MatrixBase +#endif { public: diff --git a/Eigen/src/Core/CwiseUnaryOp.h b/Eigen/src/Core/CwiseUnaryOp.h index a50a9c30d..a6577a31e 100644 --- a/Eigen/src/Core/CwiseUnaryOp.h +++ b/Eigen/src/Core/CwiseUnaryOp.h @@ -63,7 +63,11 @@ struct ei_traits > template class CwiseUnaryOp : ei_no_assignment_operator, +#ifndef EIGEN_PARSED_BY_DOXYGEN public MatrixBase > +#else + public MatrixBase +#endif { public: diff --git a/Eigen/src/Core/DiagonalCoeffs.h b/Eigen/src/Core/DiagonalCoeffs.h index 9e2641039..83a11807e 100644 --- a/Eigen/src/Core/DiagonalCoeffs.h +++ b/Eigen/src/Core/DiagonalCoeffs.h @@ -60,7 +60,11 @@ struct ei_traits > }; template class DiagonalCoeffs - : public MatrixBase > +#ifndef EIGEN_PARSED_BY_DOXYGEN + : public MatrixBase > +#else + : public MatrixBase +#endif { public: diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h index 029e273e5..da7bf2dd4 100644 --- a/Eigen/src/Core/DiagonalMatrix.h +++ b/Eigen/src/Core/DiagonalMatrix.h @@ -56,7 +56,11 @@ struct ei_traits > template class DiagonalMatrix : ei_no_assignment_operator, - public MatrixBase > +#ifndef EIGEN_PARSED_BY_DOXYGEN + public MatrixBase > +#else + public MatrixBase +#endif { public: diff --git a/Eigen/src/Core/DiagonalProduct.h b/Eigen/src/Core/DiagonalProduct.h index 4ee3c46c3..83ca8d1b3 100644 --- a/Eigen/src/Core/DiagonalProduct.h +++ b/Eigen/src/Core/DiagonalProduct.h @@ -61,7 +61,11 @@ struct ei_traits > }; template class Product : ei_no_assignment_operator, +#ifndef EIGEN_PARSED_BY_DOXYGEN public MatrixBase > +#else + public MatrixBase +#endif { typedef typename ei_traits::_LhsNested _LhsNested; typedef typename ei_traits::_RhsNested _RhsNested; diff --git a/Eigen/src/Core/Flagged.h b/Eigen/src/Core/Flagged.h index a6abe617b..4dbcbd56d 100644 --- a/Eigen/src/Core/Flagged.h +++ b/Eigen/src/Core/Flagged.h @@ -55,7 +55,11 @@ struct ei_traits > }; template class Flagged +#ifndef EIGEN_PARSED_BY_DOXYGEN : public MatrixBase > +#else + : public MatrixBase +#endif { public: diff --git a/Eigen/src/Core/DummyPacketMath.h b/Eigen/src/Core/GenericPacketMath.h similarity index 59% rename from Eigen/src/Core/DummyPacketMath.h rename to Eigen/src/Core/GenericPacketMath.h index 313001f2f..7bf4d4c29 100644 --- a/Eigen/src/Core/DummyPacketMath.h +++ b/Eigen/src/Core/GenericPacketMath.h @@ -2,6 +2,7 @@ // for linear algebra. Eigen itself is part of the KDE project. // // Copyright (C) 2008 Gael Guennebaud +// Copyright (C) 2006-2008 Benoit Jacob // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -22,88 +23,95 @@ // License and a copy of the GNU General Public License along with // Eigen. If not, see . -#ifndef EIGEN_DUMMY_PACKET_MATH_H -#define EIGEN_DUMMY_PACKET_MATH_H +#ifndef EIGEN_GENERIC_PACKET_MATH_H +#define EIGEN_GENERIC_PACKET_MATH_H + +/** \internal + * \file GenericPacketMath.h + * + * Default implementation for types not supported by the vectorization. + * In practice these functions are provided to make easier the writting + * of generic vectorized code. + */ -// Default implementation for types not supported by the vectorization. -// In practice these functions are provided to make easier the writting -// of generic vectorized code. However, at runtime, they should never be -// called, TODO so sould we raise an assertion or not ? /** \internal \returns a + b (coeff-wise) */ -template inline Packet +template inline Packet ei_padd(const Packet& a, const Packet& b) { return a+b; } /** \internal \returns a - b (coeff-wise) */ -template inline Packet +template inline Packet ei_psub(const Packet& a, const Packet& b) { return a-b; } /** \internal \returns a * b (coeff-wise) */ -template inline Packet +template inline Packet ei_pmul(const Packet& a, const Packet& b) { return a*b; } /** \internal \returns a / b (coeff-wise) */ -template inline Packet +template inline Packet ei_pdiv(const Packet& a, const Packet& b) { return a/b; } /** \internal \returns the min of \a a and \a b (coeff-wise) */ -template inline Packet +template inline Packet ei_pmin(const Packet& a, const Packet& b) { return std::min(a, b); } /** \internal \returns the max of \a a and \a b (coeff-wise) */ -template inline Packet +template inline Packet ei_pmax(const Packet& a, const Packet& b) { return std::max(a, b); } /** \internal \returns a packet version of \a *from, from must be 16 bytes aligned */ -template inline typename ei_packet_traits::type +template inline typename ei_packet_traits::type ei_pload(const Scalar* from) { return *from; } /** \internal \returns a packet version of \a *from, (un-aligned load) */ -template inline typename ei_packet_traits::type +template inline typename ei_packet_traits::type ei_ploadu(const Scalar* from) { return *from; } /** \internal \returns a packet with constant coefficients \a a, e.g.: (a,a,a,a) */ -template inline typename ei_packet_traits::type +template inline typename ei_packet_traits::type ei_pset1(const Scalar& a) { return a; } /** \internal copy the packet \a from to \a *to, \a to must be 16 bytes aligned */ -template inline void ei_pstore(Scalar* to, const Packet& from) +template inline void ei_pstore(Scalar* to, const Packet& from) { (*to) = from; } /** \internal copy the packet \a from to \a *to, (un-aligned store) */ -template inline void ei_pstoreu(Scalar* to, const Packet& from) +template inline void ei_pstoreu(Scalar* to, const Packet& from) { (*to) = from; } /** \internal \returns the first element of a packet */ -template inline typename ei_unpacket_traits::type ei_pfirst(const Packet& a) +template inline typename ei_unpacket_traits::type ei_pfirst(const Packet& a) { return a; } /** \internal \returns a packet where the element i contains the sum of the packet of \a vec[i] */ -template inline Packet +template inline Packet ei_preduxp(const Packet* vecs) { return vecs[0]; } /** \internal \returns the sum of the elements of \a a*/ -template inline typename ei_unpacket_traits::type ei_predux(const Packet& a) +template inline typename ei_unpacket_traits::type ei_predux(const Packet& a) { return a; } -//////////// - +/*************************************************************************** +* The following functions might not have to be overwritten for vectorized types +***************************************************************************/ /** \internal \returns a * b + c (coeff-wise) */ -template inline Packet +template inline Packet ei_pmadd(const Packet& a, const Packet& b, const Packet& c) { return ei_padd(ei_pmul(a, b),c); } -/** \internal \returns a packet version of \a *from. If LoadMode equals Aligned, \a from must be 16 bytes aligned */ -template inline typename ei_packet_traits::type ei_ploadt(const Scalar* from) +/** \internal \returns a packet version of \a *from. + * \If LoadMode equals Aligned, \a from must be 16 bytes aligned */ +template +inline typename ei_packet_traits::type ei_ploadt(const Scalar* from) { if(LoadMode == Aligned) return ei_pload(from); @@ -111,8 +119,10 @@ template inline typename ei_packet_traits inline void ei_pstoret(Scalar* to, const Packet& from) +/** \internal copy the packet \a from to \a *to. + * If StoreMode equals Aligned, \a to must be 16 bytes aligned */ +template +inline void ei_pstoret(Scalar* to, const Packet& from) { if(LoadMode == Aligned) ei_pstore(to, from); @@ -120,21 +130,7 @@ template inline void ei_pstoret ei_pstoreu(to, from); } -/** \internal \returns the number of elements which have to be skipped such that data are aligned */ -template -inline static int ei_alignmentOffset(const Scalar* ptr, int maxOffset) -{ - typedef typename ei_packet_traits::type Packet; - const int PacketSize = ei_packet_traits::size; - const int PacketAlignedMask = PacketSize-1; - const bool Vectorized = PacketSize>1; - return Vectorized - ? std::min( (PacketSize - ((size_t(ptr)/sizeof(Scalar)) & PacketAlignedMask)) - & PacketAlignedMask, maxOffset) - : 0; -} - -/** \internal specialization of ei_palign() */ +/** \internal default implementation of ei_palign() allowing partial specialization */ template struct ei_palign_impl { @@ -150,5 +146,5 @@ inline void ei_palign(PacketType& first, const PacketType& second) ei_palign_impl::run(first,second); } -#endif // EIGEN_DUMMY_PACKET_MATH_H +#endif // EIGEN_GENERIC_PACKET_MATH_H diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h index 7dfaac273..4da6b942a 100644 --- a/Eigen/src/Core/Map.h +++ b/Eigen/src/Core/Map.h @@ -57,7 +57,11 @@ struct ei_traits > : public ei_traits }; template class Map +#ifndef EIGEN_PARSED_BY_DOXYGEN : public MapBase > +#else + : public MapBase +#endif { public: diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index e5d06d21c..fb531c1e8 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -96,7 +96,12 @@ struct ei_traits -class Matrix : public MatrixBase > +class Matrix +#ifndef EIGEN_PARSED_BY_DOXYGEN + : public MatrixBase > +#else + : public MatrixBase +#endif { public: EIGEN_GENERIC_PUBLIC_INTERFACE(Matrix) @@ -369,6 +374,8 @@ class Matrix : public MatrixBase class ei_matrix_storage; -template struct ei_aligned_array -{ - EIGEN_ALIGN_128 T array[Size]; -}; - -template struct ei_aligned_array -{ - T array[Size]; -}; - -template -inline T* ei_aligned_malloc(size_t size) -{ - #ifdef EIGEN_VECTORIZE - if (ei_packet_traits::size>1) - { - void* ptr; - if (posix_memalign(&ptr, 16, size*sizeof(T))==0) - return static_cast(ptr); - else - return 0; - } - else - #endif - return new T[size]; -} - -template -inline void ei_aligned_free(T* ptr) -{ - #ifdef EIGEN_VECTORIZE - if (ei_packet_traits::size>1) - free(ptr); - else - #endif - delete[] ptr; -} - // purely fixed-size matrix template class ei_matrix_storage { diff --git a/Eigen/src/Core/Minor.h b/Eigen/src/Core/Minor.h index 9e87c9b9b..70e358741 100644 --- a/Eigen/src/Core/Minor.h +++ b/Eigen/src/Core/Minor.h @@ -58,7 +58,11 @@ struct ei_traits > }; template class Minor +#ifndef EIGEN_PARSED_BY_DOXYGEN : public MatrixBase > +#else + : public MatrixBase +#endif { public: diff --git a/Eigen/src/Core/NestByValue.h b/Eigen/src/Core/NestByValue.h index 86d8795cd..198e9df78 100644 --- a/Eigen/src/Core/NestByValue.h +++ b/Eigen/src/Core/NestByValue.h @@ -52,7 +52,11 @@ struct ei_traits > }; template class NestByValue +#ifndef EIGEN_PARSED_BY_DOXYGEN : public MatrixBase > +#else + : public MatrixBase +#endif { public: diff --git a/Eigen/src/Core/Part.h b/Eigen/src/Core/Part.h index 4d39c4c08..61c8507ef 100644 --- a/Eigen/src/Core/Part.h +++ b/Eigen/src/Core/Part.h @@ -59,7 +59,11 @@ struct ei_traits > }; template class Part +#ifndef EIGEN_PARSED_BY_DOXYGEN : public MatrixBase > +#else + : public MatrixBase +#endif { public: diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index f18bc1e4a..3132d4e46 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -168,7 +168,11 @@ struct ei_traits > }; template class Product : ei_no_assignment_operator, +#ifndef EIGEN_PARSED_BY_DOXYGEN public MatrixBase > +#else + public MatrixBase +#endif { public: diff --git a/Eigen/src/Core/Swap.h b/Eigen/src/Core/Swap.h index 835fa61b2..f1918c12b 100644 --- a/Eigen/src/Core/Swap.h +++ b/Eigen/src/Core/Swap.h @@ -46,7 +46,11 @@ struct ei_traits > }; template class SwapWrapper +#ifndef EIGEN_PARSED_BY_DOXYGEN : public MatrixBase > +#else + : public MatrixBase +#endif { public: diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index dba19f025..5f8b263da 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -57,7 +57,11 @@ struct ei_traits > }; template class Transpose +#ifndef EIGEN_PARSED_BY_DOXYGEN : public MatrixBase > +#else + : public MatrixBase +#endif { public: diff --git a/Eigen/src/Core/util/Constants.h b/Eigen/src/Core/util/Constants.h index 3be6aba92..3090dad19 100644 --- a/Eigen/src/Core/util/Constants.h +++ b/Eigen/src/Core/util/Constants.h @@ -29,6 +29,7 @@ const int Dynamic = 10000; /** \defgroup flags + * \ingroup Core_Module * * These are the possible bits which can be OR'ed to constitute the flags of a matrix or * expression. diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index ae2041875..e3429e146 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -153,16 +153,4 @@ _EIGEN_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::MatrixBase) #define EIGEN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b) #define EIGEN_ENUM_MAX(a,b) (((int)a >= (int)b) ? (int)a : (int)b) -/* ei_alloc_stack(TYPE,SIZE) allocates sizeof(TYPE)*SIZE bytes on the stack if sizeof(TYPE)*SIZE is smaller - * than EIGEN_STACK_ALLOCATION_LIMIT. Otherwise the memory is allocated using the operator new. - * Data allocated with ei_alloc_stack must be freed calling ei_free_stack(PTR,TYPE,SIZE) - */ -#ifdef __linux__ -# define ei_alloc_stack(TYPE,SIZE) ((sizeof(TYPE)*(SIZE)>16000000) ? new TYPE[SIZE] : (TYPE*)alloca(sizeof(TYPE)*(SIZE))) -# define ei_free_stack(PTR,TYPE,SIZE) if (sizeof(TYPE)*SIZE>16000000) delete[] PTR -#else -# define ei_alloc_stack(TYPE,SIZE) new TYPE[SIZE] -# define ei_free_stack(PTR,TYPE,SIZE) delete[] PTR -#endif - #endif // EIGEN_MACROS_H diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h new file mode 100644 index 000000000..24ae4b509 --- /dev/null +++ b/Eigen/src/Core/util/Memory.h @@ -0,0 +1,109 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. Eigen itself is part of the KDE project. +// +// Copyright (C) 2008 Gael Guennebaud +// Copyright (C) 2006-2008 Benoit Jacob +// +// Eigen is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 3 of the License, or (at your option) any later version. +// +// Alternatively, you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License and a copy of the GNU General Public License along with +// Eigen. If not, see . + +#ifndef EIGEN_MEMORY_H +#define EIGEN_MEMORY_H + +#ifdef EIGEN_VECTORIZE +// it seems we cannot assume posix_memalign is defined in the stdlib header +extern "C" int posix_memalign (void **, size_t, size_t) throw (); +#endif + +/** \internal + * Static array automatically aligned if the total byte size is a multiple of 16 + */ +template struct ei_aligned_array +{ + EIGEN_ALIGN_128 T array[Size]; +}; + +template struct ei_aligned_array +{ + T array[Size]; +}; + +/** \internal allocates \a size * sizeof(\a T) bytes with a 16 bytes based alignement */ +template +inline T* ei_aligned_malloc(size_t size) +{ + #ifdef EIGEN_VECTORIZE + if (ei_packet_traits::size>1) + { + void* ptr; + if (posix_memalign(&ptr, 16, size*sizeof(T))==0) + return static_cast(ptr); + else + return 0; + } + else + #endif + return new T[size]; +} + +/** \internal free memory allocated with ei_aligned_malloc */ +template +inline void ei_aligned_free(T* ptr) +{ + #ifdef EIGEN_VECTORIZE + if (ei_packet_traits::size>1) + free(ptr); + else + #endif + delete[] ptr; +} + +/** \internal \returns the number of elements which have to be skipped such that data are 16 bytes aligned */ +template +inline static int ei_alignmentOffset(const Scalar* ptr, int maxOffset) +{ + typedef typename ei_packet_traits::type Packet; + const int PacketSize = ei_packet_traits::size; + const int PacketAlignedMask = PacketSize-1; + const bool Vectorized = PacketSize>1; + return Vectorized + ? std::min( (PacketSize - ((size_t(ptr)/sizeof(Scalar)) & PacketAlignedMask)) + & PacketAlignedMask, maxOffset) + : 0; +} + +/** \internal + * ei_alloc_stack(TYPE,SIZE) allocates sizeof(TYPE)*SIZE bytes on the stack if sizeof(TYPE)*SIZE is + * smaller than EIGEN_STACK_ALLOCATION_LIMIT. Otherwise the memory is allocated using the operator new. + * Data allocated with ei_alloc_stack \b must be freed calling ei_free_stack(PTR,TYPE,SIZE). + * \code + * float * data = ei_alloc_stack(float,array.size()); + * // ... + * ei_free_stack(data,float,array.size()); + * \endcode + */ +#ifdef __linux__ +# define ei_alloc_stack(TYPE,SIZE) ((sizeof(TYPE)*(SIZE)>16000000) ? new TYPE[SIZE] : (TYPE*)alloca(sizeof(TYPE)*(SIZE))) +# define ei_free_stack(PTR,TYPE,SIZE) if (sizeof(TYPE)*SIZE>16000000) delete[] PTR +#else +# define ei_alloc_stack(TYPE,SIZE) new TYPE[SIZE] +# define ei_free_stack(PTR,TYPE,SIZE) delete[] PTR +#endif + +#endif // EIGEN_MEMORY_H diff --git a/Eigen/src/Regression/Regression.h b/Eigen/src/Regression/Regression.h index 88e4e8921..b03799f49 100644 --- a/Eigen/src/Regression/Regression.h +++ b/Eigen/src/Regression/Regression.h @@ -76,17 +76,17 @@ * Let's now describe precisely the parameters: * @param numPoints the number of points * @param points the array of pointers to the points on which to perform the linear regression - * @param retCoefficients pointer to the vector in which to store the result. - This vector must be of the same type and size as the - data points. The meaning of its coords is as follows. - For brevity, let \f$n=Size\f$, - \f$r_i=retCoefficients[i]\f$, - and \f$f=funcOfOthers\f$. Denote by - \f$x_0,\ldots,x_{n-1}\f$ - the n coordinates in the n-dimensional space. - Then the result equation is: - \f[ x_f = r_0 x_0 + \cdots + r_{f-1}x_{f-1} - + r_{f+1}x_{f+1} + \cdots + r_{n-1}x_{n-1} + r_n. \f] + * @param result pointer to the vector in which to store the result. + This vector must be of the same type and size as the + data points. The meaning of its coords is as follows. + For brevity, let \f$n=Size\f$, + \f$r_i=retCoefficients[i]\f$, + and \f$f=funcOfOthers\f$. Denote by + \f$x_0,\ldots,x_{n-1}\f$ + the n coordinates in the n-dimensional space. + Then the result equation is: + \f[ x_f = r_0 x_0 + \cdots + r_{f-1}x_{f-1} + + r_{f+1}x_{f+1} + \cdots + r_{n-1}x_{n-1} + r_n. \f] * @param funcOfOthers Determines which coord to express as a function of the others. Coords are numbered starting from 0, so that a value of 0 means \f$x\f$, 1 means \f$y\f$, @@ -183,7 +183,7 @@ void fitHyperplane(int numPoints, VectorType diff = (*(points[i]) - mean).conjugate(); covMat += diff * diff.adjoint(); } - + // now we just have to pick the eigen vector with smallest eigen value SelfAdjointEigenSolver eig(covMat); result->start(size) = eig.eigenvectors().col(0); diff --git a/Eigen/src/Sparse/HashMatrix.h b/Eigen/src/Sparse/HashMatrix.h index 992486f5a..0017d1998 100644 --- a/Eigen/src/Sparse/HashMatrix.h +++ b/Eigen/src/Sparse/HashMatrix.h @@ -42,7 +42,12 @@ struct ei_traits > // TODO reimplement this class using custom linked lists template -class HashMatrix : public SparseMatrixBase > +class HashMatrix +#ifndef EIGEN_PARSED_BY_DOXYGEN + : public SparseMatrixBase > +#else + : public SparseMatrixBase +#endif { public: EIGEN_GENERIC_PUBLIC_INTERFACE(HashMatrix) diff --git a/Eigen/src/Sparse/LinkedVectorMatrix.h b/Eigen/src/Sparse/LinkedVectorMatrix.h index 969aee57b..2ffb1d930 100644 --- a/Eigen/src/Sparse/LinkedVectorMatrix.h +++ b/Eigen/src/Sparse/LinkedVectorMatrix.h @@ -52,7 +52,12 @@ struct LinkedVectorChunk }; template -class LinkedVectorMatrix : public SparseMatrixBase > +class LinkedVectorMatrix +#ifndef EIGEN_PARSED_BY_DOXYGEN + : public SparseMatrixBase > +#else + : public SparseMatrixBase +#endif { public: EIGEN_GENERIC_PUBLIC_INTERFACE(LinkedVectorMatrix) diff --git a/Eigen/src/Sparse/SparseMatrix.h b/Eigen/src/Sparse/SparseMatrix.h index dbc436f80..acf0e10b2 100644 --- a/Eigen/src/Sparse/SparseMatrix.h +++ b/Eigen/src/Sparse/SparseMatrix.h @@ -52,7 +52,12 @@ struct ei_traits > template -class SparseMatrix : public SparseMatrixBase > +class SparseMatrix +#ifndef EIGEN_PARSED_BY_DOXYGEN + : public SparseMatrixBase > +#else + : public SparseMatrixBase +#endif { public: EIGEN_GENERIC_PUBLIC_INTERFACE(SparseMatrix) @@ -92,7 +97,7 @@ class SparseMatrix : public SparseMatrixBase > return m_data.value(end-1); // ^^ optimization: let's first check if it is the last coefficient // (very common in high level algorithms) - + const int* r = std::lower_bound(&m_data.index(start),&m_data.index(end),inner); const int id = r-&m_data.index(0); return ((*r==inner) && (id > }; template class Product : ei_no_assignment_operator, +#ifndef EIGEN_PARSED_BY_DOXYGEN public MatrixBase > +#else + public MatrixBase +#endif { public: diff --git a/doc/CustomizingEigen.dox b/doc/CustomizingEigen.dox index 74108c999..75981b891 100644 --- a/doc/CustomizingEigen.dox +++ b/doc/CustomizingEigen.dox @@ -4,7 +4,7 @@ namespace Eigen {

Customizing Eigen

-Eigen2 can be extended in several way, for instance, by defining global methods, \link ExtendingMatrixBase by adding custom methods to MatrixBase \endlink, etc. +Eigen2 can be extended in several way, for instance, by defining global methods, \ref ExtendingMatrixBase "by adding custom methods to MatrixBase", etc. \section ExtendingMatrixBase Extending MatrixBase diff --git a/doc/Mainpage.dox b/doc/Mainpage.dox index d03d1d47f..d703358ea 100644 --- a/doc/Mainpage.dox +++ b/doc/Mainpage.dox @@ -2,11 +2,17 @@ namespace Eigen { o /** \mainpage Eigen -This is the API documentation for Eigen. +
\b Overview + | \ref TutorialCore "Core features" + | \ref TutorialGeometry "Geometry" + | \ref TutorialAdvancedLinearAlgebra "Advanced linear algebra" +
+ +This is the API documentation for Eigen. Most of the API is available as methods in MatrixBase, so this is a good starting point for browsing. Also have a look at Matrix, as a few methods and the matrix constructors are there. Other notable classes for the Eigen API are Cwise, which contains the methods for doing certain coefficient-wise operations, and Part. -For a first contact with Eigen, the best place is to have a look at the \ref QuickStartGuide "quick start guide". Then, it is enough to look at Matrix, MatrixBase, and Cwise. In fact, except for advanced use, the only class that you'll have to explicitly name in your program, i.e. of which you'll explicitly contruct objects, is Matrix. For instance, vectors are handled as a special case of Matrix with one column. Typedefs are provided, e.g. Vector2f is a typedef for Matrix. Finally, you might also have look at the \ref ExampleList "the list of selected examples". +For a first contact with Eigen, the best place is to have a look at the \ref TutorialCore "tutorial". Then, it is enough to look at Matrix, MatrixBase, and Cwise. In fact, except for advanced use, the only class that you'll have to explicitly name in your program, i.e. of which you'll explicitly contruct objects, is Matrix. For instance, vectors are handled as a special case of Matrix with one column. Typedefs are provided, e.g. Vector2f is a typedef for Matrix. Finally, you might also have look at the \ref ExampleList "the list of selected examples". Most of the other classes are just return types for MatrixBase methods. diff --git a/doc/QuickStartGuide.dox b/doc/QuickStartGuide.dox index da9be60d2..50abf8b4d 100644 --- a/doc/QuickStartGuide.dox +++ b/doc/QuickStartGuide.dox @@ -1,34 +1,31 @@ namespace Eigen { -/** \page QuickStartGuide +/** \page TutorialCore Tutorial 1/3 - Core features + \ingroup Tutorial -

Quick start guide

+
\ref index "Overview" + | \b Core \b features + | \ref TutorialGeometry "Geometry" + | \ref TutorialAdvancedLinearAlgebra "Advanced linear algebra" +
\b Table \b of \b contents - - Core features (Chapter I) - - \ref SimpleExampleFixedSize - - \ref SimpleExampleDynamicSize - - \ref MatrixTypes - - \ref MatrixInitialization - - \ref BasicLinearAlgebra - - \ref Reductions - - \ref SubMatrix - - \ref MatrixTransformations - - \ref TriangularMatrix - - \ref Performance - - \ref Geometry (Chapter II) - - \ref AdvancedLinearAlgebra (Chapter III) - - \ref LinearSolvers - - \ref LU - - \ref Cholesky - - \ref QR - - \ref EigenProblems + - \ref TutorialCoreSimpleExampleFixedSize + - \ref TutorialCoreSimpleExampleDynamicSize + - \ref TutorialCoreMatrixTypes + - \ref TutorialCoreMatrixInitialization + - \ref TutorialCoreBasicLinearAlgebra + - \ref TutorialCoreReductions + - \ref TutorialCoreSubMatrix + - \ref TutorialCoreMatrixTransformations + - \ref TutorialCoreTriangularMatrix + - \ref TutorialCorePerformance -
+\n
-\section SimpleExampleFixedSize Simple example with fixed-size matrices and vectors +\section TutorialCoreSimpleExampleFixedSize Simple example with fixed-size matrices and vectors By fixed-size, we mean that the number of rows and columns are known at compile-time. In this case, Eigen avoids dynamic memory allocation and unroll loops. This is useful for very small sizes (typically up to 4x4). @@ -40,7 +37,9 @@ output: \include Tutorial_simple_example_fixed_size.out -top\section SimpleExampleDynamicSize Simple example with dynamic-size matrices and vectors + + +top\section TutorialCoreSimpleExampleDynamicSize Simple example with dynamic-size matrices and vectors Dynamic-size means that the number of rows and columns are not known at compile-time. In this case, they are stored as runtime variables and the arrays are dynamically allocated. @@ -57,7 +56,7 @@ output: -top\section MatrixTypes Matrix and vector types +top\section TutorialCoreMatrixTypes Matrix and vector types In Eigen, all kinds of dense matrices and vectors are represented by the template class Matrix. In most cases you can simply use one of the \ref matrixtypedefs "several convenient typedefs". @@ -66,7 +65,7 @@ The template class Matrix takes a number of template parameters, but for now it \code Matrix \endcode \li \c Scalar is the scalar type, i.e. the type of the coefficients. That is, if you want a vector of floats, choose \c float here. -\li \c RowsAtCompileTime and \c ColsAtCompileTime are the number of rows and columns of the matrix as known at compile-time. +\li \c RowsAtCompileTime and \c ColsAtCompileTime are the number of rows and columns of the matrix as known at compile-time. For example, \c Vector3d is a typedef for \code Matrix \endcode @@ -76,8 +75,10 @@ What if the matrix has dynamic-size i.e. the number of rows or cols isn't known -top\section MatrixInitialization Matrix and vector creation and initialization +top\section TutorialCoreMatrixInitialization Matrix and vector creation and initialization + +\subsection TutorialPredefMat PredefinedMatrix Eigen offers several methods to create or set matrices with coefficients equals to either a constant value, the identity matrix or even random values: @@ -138,6 +139,16 @@ x.setRandom(size); \endcode + +
Basis vectors \link MatrixBase::Unit [details]\endlink
\code +Vector3f::UnixX() // 1 0 0 +Vector3f::UnixY() // 0 1 0 +Vector3f::UnixZ() // 0 0 1 +\endcode\code +VectorXf::Unit(size,i) +VectorXf::Unit(4,1) == Vector4f(0,1,0,0) + == Vector4f::UnitY() +\endcode
Here is an usage example: @@ -159,7 +170,25 @@ v = 6 6 6 \endcode -Eigen also offer a comma initializer syntax which allows to set all the coefficients of a matrix to specific values: + + +\subsection TutorialMap Map +Any memory buffer can be mapped as an Eigen's expression: +
+\code +std::vector stlarray(10); +Map(&stlarray[0], stlarray.size()).setOnes(); +int data[4] = 1, 2, 3, 4; +Matrix2i mat2x2(data); +MatrixXi mat2x2 = Map(data); +MatrixXi mat2x2 = Map(data,2,2); +\endcode +
+ + + +\subsection TutorialCommaInit CommaInitializer +Eigen also offer a comma initializer syntax which allows you to set all the coefficients of a matrix to specific values: @@ -177,16 +206,16 @@ output: \verbinclude Tutorial_commainit_02.out
\include Tutorial_commainit_01.cpp
-

\b Side \b note: here .finished() is used to get the actual matrix object once the comma initialization +\b Side \b note: here .finished() is used to get the actual matrix object once the comma initialization of our temporary submatrix is done. Note that despite the appearant complexity of such an expression -Eigen's comma initializer usually yields to very optimized code without any overhead.

+Eigen's comma initializer usually yields to very optimized code without any overhead. -top\section BasicLinearAlgebra Basic Linear Algebra +top\section TutorialCoreBasicLinearAlgebra Basic Linear Algebra In short all mathematically well defined operators can be used right away as in the following example: \code @@ -221,7 +250,7 @@ outer product\code mat = vec1 * vec2.transpose();\endcode -\link MatrixBase::cross() cross product \endcode\code +\link MatrixBase::cross() cross product \endlink\code #include vec3 = vec1.cross(vec2);\endcode @@ -287,18 +316,18 @@ mat3 = mat1.cwise().abs2(mat2); -

\b Side \b note: If you feel the \c .cwise() syntax is too verbose for your taste and don't bother to have non mathematical operator directly available feel free to extend MatrixBase as described \ref ExtendingMatrixBase "here".

+\b Side \b note: If you feel the \c .cwise() syntax is too verbose for your taste and don't bother to have non mathematical operator directly available feel free to extend MatrixBase as described \ref ExtendingMatrixBase "here". -top\section Reductions Reductions +top\section TutorialCoreReductions Reductions Eigen provides several several reduction methods such as: -\link Cwise::minCoeff() minCoeff() \endlink, \link Cwise::maxCoeff() maxCoeff() \endlink, -\link Cwise::sum() sum() \endlink, \link Cwise::trace() trace() \endlink, -\link Cwise::norm() norm() \endlink, \link Cwise::norm2() norm2() \endlink, -\link Cwise::all() all() \endlink,and \link Cwise::any() any() \endlink. +\link MatrixBase::minCoeff() minCoeff() \endlink, \link MatrixBase::maxCoeff() maxCoeff() \endlink, +\link MatrixBase::sum() sum() \endlink, \link MatrixBase::trace() trace() \endlink, +\link MatrixBase::norm() norm() \endlink, \link MatrixBase::norm2() norm2() \endlink, +\link MatrixBase::all() all() \endlink,and \link MatrixBase::any() any() \endlink. All reduction operations can be done matrix-wise, \link MatrixBase::colwise() column-wise \endlink or \link MatrixBase::rowwise() row-wise \endlink. Usage example: @@ -316,13 +345,13 @@ mat = 2 7 8 \endcode -

\b Side \b note: The all() and any() functions are especially useful in combinaison with coeff-wise comparison operators (\ref CwiseAll "example").

+\b Side \b note: The all() and any() functions are especially useful in combinaison with coeff-wise comparison operators (\ref CwiseAll "example"). -top\section SubMatrix Sub matrices +top\section TutorialCoreSubMatrix Sub matrices Read-write access to a \link MatrixBase::col(int) column \endlink or a \link MatrixBase::row(int) row \endlink of a matrix: @@ -383,7 +412,7 @@ Read-write access to sub-matrices: -top\section MatrixTransformations Matrix transformations +top\section TutorialCoreMatrixTransformations Matrix transformations
@@ -411,11 +440,11 @@ mat3x3 = mat4x4.minor(i,j);\endcode
-top\section TriangularMatrix Dealing with triangular matrices +top\section TutorialCoreTriangularMatrix Dealing with triangular matrices todo -top\section Performance Notes on performances +top\section TutorialCorePerformance Notes on performances
\code @@ -447,17 +476,70 @@ m4 = m4 * m4.transpose().eval();\endcode forces immediate evaluation of the transpose
-top\section Geometry Geometry features +*/ -maybe a second chapter for that -top\section AdvancedLinearAlgebra Advanced Linear Algebra -Again, let's do another chapter for that -\subsection LinearSolvers Solving linear problems -\subsection LU LU -\subsection Cholesky Cholesky -\subsection QR QR -\subsection EigenProblems Eigen value problems + + + + +/** \page TutorialGeometry Tutorial 2/3 - Geometry + \ingroup Tutorial + +
\ref index "Overview" + | \ref TutorialCore "Core features" + | \b Geometry + | \ref TutorialAdvancedLinearAlgebra "Advanced linear algebra" +
+ +\b Table \b of \b contents + - \ref TutorialGeoRotations + - \ref TutorialGeoTransformation + +top\section TutorialGeoRotations 2D and 3D Rotations + +todo + +top\section TutorialGeoTransformation 2D and 3D Transformations + +todo + +*/ + + + + + +/** \page TutorialAdvancedLinearAlgebra Tutorial 3/3 - Advanced linear algebra + \ingroup Tutorial + +
\ref index "Overview" + | \ref TutorialCore "Core features" + | \ref TutorialGeometry "Geometry" + | \b Advanced \b linear \b algebra +
+ +\b Table \b of \b contents + - \ref TutorialAdvLinearSolvers + - \ref TutorialAdvLU + - \ref TutorialAdvCholesky + - \ref TutorialAdvQR + - \ref TutorialAdvEigenProblems + +\section TutorialAdvLinearSolvers Solving linear problems +todo + +top\section TutorialAdvLU LU +todo + +top\section TutorialAdvCholesky Cholesky +todo + +top\section TutorialAdvQR QR +todo + +top\section TutorialAdvEigenProblems Eigen value problems +todo */ diff --git a/doc/eigendoxy.css b/doc/eigendoxy.css index 825cc4fc1..b64c49ae9 100644 --- a/doc/eigendoxy.css +++ b/doc/eigendoxy.css @@ -451,10 +451,17 @@ A.top { A.top:hover, A.logo:hover { background-color: transparent;font-weight : bolder; } -P.note { +SPAN.note { font-size: 7pt; } +DIV.navigation { + min-height : 64px; +/* background : url("Eigen_Silly_Professor_64x64.png") no-repeat left; */ + padding-left : 80px; + padding-top : 5px; +} + TABLE.noborder { border-bottom-style : none; border-left-style : none; @@ -496,5 +503,10 @@ TABLE.tutorial_code TD { vertical-align: middle; } +DIV.eimainmenu { + text-align: center; +/* border-top: solid; */ +/* border-bottom: solid; */ +} diff --git a/doc/eigendoxy_header.html.in b/doc/eigendoxy_header.html.in index d676645b9..f016a614d 100644 --- a/doc/eigendoxy_header.html.in +++ b/doc/eigendoxy_header.html.in @@ -7,4 +7,4 @@ \ No newline at end of file + style="position:absolute; border:none" /> \ No newline at end of file diff --git a/doc/eigendoxy_tabs.css b/doc/eigendoxy_tabs.css index 1423133bf..00a02138c 100644 --- a/doc/eigendoxy_tabs.css +++ b/doc/eigendoxy_tabs.css @@ -2,13 +2,9 @@ DIV.tabs { - position: absolute; - right: 10pt; - left: 0px; - background : url("tab_b.gif") repeat-x bottom; - margin-bottom : 4px; - margin-left : 100px; - margin-top : -2em; + float: left; + width:100%; + background : url("tab_b.gif") repeat-x bottom; } DIV.tabs UL