aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-03-31 17:24:09 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-03-31 17:24:09 +0000
commite74fbfb2bc13dee268950361a957aea73bcefc21 (patch)
tree5f059fd5ca63f1cf370235cee4c2490036db2f70 /Eigen/src/Core
parentcff5e3ce9c1e09553125bce464b9c80f8bc2eb76 (diff)
- remove Eval/EvalOMP (moving them to a disabled/ subdir in order
to preserve SVN history). They are made useless by the new ei_eval_unless_lazy. - introduce a generic Eval member typedef so one can do e.g. T t; U u; Product<T, U>::Eval m; m = t*u;
Diffstat (limited to 'Eigen/src/Core')
-rw-r--r--Eigen/src/Core/Eval.h109
-rw-r--r--Eigen/src/Core/EvalOMP.h132
-rw-r--r--Eigen/src/Core/ForwardDeclarations.h8
-rw-r--r--Eigen/src/Core/MatrixBase.h6
-rw-r--r--Eigen/src/Core/Util.h8
5 files changed, 18 insertions, 245 deletions
diff --git a/Eigen/src/Core/Eval.h b/Eigen/src/Core/Eval.h
deleted file mode 100644
index 23e35a96a..000000000
--- a/Eigen/src/Core/Eval.h
+++ /dev/null
@@ -1,109 +0,0 @@
-// This file is part of Eigen, a lightweight C++ template library
-// for linear algebra. Eigen itself is part of the KDE project.
-//
-// Copyright (C) 2006-2008 Benoit Jacob <jacob@math.jussieu.fr>
-//
-// 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 <http://www.gnu.org/licenses/>.
-
-#ifndef EIGEN_EVAL_H
-#define EIGEN_EVAL_H
-
-/** \class Eval
- *
- * \brief Evaluation of an expression
- *
- * The template parameter Expression is the type of the expression that we are evaluating.
- *
- * This class is the return
- * type of MatrixBase::eval() and most of the time this is the only way it
- * is used.
- *
- * However, if you want to write a function returning an evaluation of an expression, you
- * will need to use this class.
- *
- * Here is an example illustrating this:
- * \include class_Eval.cpp
- * Output: \verbinclude class_Eval.out
- *
- * \sa MatrixBase::eval()
- */
-template<typename ExpressionType>
-struct ei_traits<Eval<ExpressionType> >
-{
- typedef typename ExpressionType::Scalar Scalar;
- enum {
- RowsAtCompileTime = ExpressionType::RowsAtCompileTime,
- ColsAtCompileTime = ExpressionType::ColsAtCompileTime,
- MaxRowsAtCompileTime = ExpressionType::MaxRowsAtCompileTime,
- MaxColsAtCompileTime = ExpressionType::MaxColsAtCompileTime,
- Flags = ExpressionType::Flags & ~LazyBit
- };
-};
-
-template<typename ExpressionType> class Eval : ei_no_assignment_operator,
- public Matrix< typename ExpressionType::Scalar,
- ExpressionType::RowsAtCompileTime,
- ExpressionType::ColsAtCompileTime,
- ExpressionType::Flags,
- ExpressionType::MaxRowsAtCompileTime,
- ExpressionType::MaxColsAtCompileTime>
-{
- public:
-
- /** The actual matrix type to evaluate to. This type can be used independently
- * of the rest of this class to get the actual matrix type to evaluate and store
- * the value of an expression.
- *
- * Here is an example illustrating this:
- * \include Eval_MatrixType.cpp
- * Output: \verbinclude Eval_MatrixType.out
- */
- typedef Matrix<typename ExpressionType::Scalar,
- ExpressionType::RowsAtCompileTime,
- ExpressionType::ColsAtCompileTime,
- ExpressionType::Flags,
- ExpressionType::MaxRowsAtCompileTime,
- ExpressionType::MaxColsAtCompileTime> MatrixType;
-
- _EIGEN_GENERIC_PUBLIC_INTERFACE(Eval, MatrixType)
-
- explicit Eval(const ExpressionType& expr) : MatrixType(expr) {}
-};
-
-/** Evaluates *this, which can be any expression, and returns the obtained matrix.
- *
- * A common use case for this is the following. In an expression-templates library
- * like Eigen, the coefficients of an expression are only computed as they are
- * accessed, they are not computed when the expression itself is constructed. This is
- * usually a good thing, as this "lazy evaluation" improves performance, but can also
- * in certain cases lead to wrong results and/or to redundant computations. In such
- * cases, one can restore the classical immediate-evaluation behavior by calling eval().
- *
- * Example: \include MatrixBase_eval.cpp
- * Output: \verbinclude MatrixBase_eval.out
- *
- * \sa class Eval */
-template<typename Derived>
-const typename ei_eval_unless_lazy<Derived>::Type MatrixBase<Derived>::eval() const
-{
- return typename ei_eval_unless_lazy<Derived>::Type(derived());
-}
-
-#endif // EIGEN_EVAL_H
diff --git a/Eigen/src/Core/EvalOMP.h b/Eigen/src/Core/EvalOMP.h
deleted file mode 100644
index 32398b6be..000000000
--- a/Eigen/src/Core/EvalOMP.h
+++ /dev/null
@@ -1,132 +0,0 @@
-// 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 <g.gael@free.fr>
-// Copyright (C) 2006-2008 Benoit Jacob <jacob@math.jussieu.fr>
-//
-// 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 <http://www.gnu.org/licenses/>.
-
-#ifndef EIGEN_EVAL_OMP_H
-#define EIGEN_EVAL_OMP_H
-
-/** \class EvalOMP
- *
- * \brief Parallel evaluation of an expression using OpenMP
- *
- * The template parameter Expression is the type of the expression that we are evaluating.
- *
- * This class is the return type of MatrixBase::evalOMP() and most of the time this is the
- * only way it is used.
- *
- * Note that if OpenMP is not enabled, then this class is equivalent to Eval.
- *
- * \sa MatrixBase::evalOMP(), class Eval, MatrixBase::eval()
- */
-template<typename ExpressionType>
-struct ei_traits<EvalOMP<ExpressionType> >
-{
- typedef typename ExpressionType::Scalar Scalar;
- enum {
- RowsAtCompileTime = ExpressionType::RowsAtCompileTime,
- ColsAtCompileTime = ExpressionType::ColsAtCompileTime,
- MaxRowsAtCompileTime = ExpressionType::MaxRowsAtCompileTime,
- MaxColsAtCompileTime = ExpressionType::MaxColsAtCompileTime,
- Flags = ExpressionType::Flags & ~LazyBit
- };
-};
-
-template<typename ExpressionType> class EvalOMP : ei_no_assignment_operator,
- public Matrix< typename ExpressionType::Scalar,
- ExpressionType::RowsAtCompileTime,
- ExpressionType::ColsAtCompileTime,
- ExpressionType::Flags,
- ExpressionType::MaxRowsAtCompileTime,
- ExpressionType::MaxColsAtCompileTime>
-{
- public:
-
- /** The actual matrix type to evaluate to. This type can be used independently
- * of the rest of this class to get the actual matrix type to evaluate and store
- * the value of an expression.
- */
- typedef Matrix<typename ExpressionType::Scalar,
- ExpressionType::RowsAtCompileTime,
- ExpressionType::ColsAtCompileTime,
- ExpressionType::Flags,
- ExpressionType::MaxRowsAtCompileTime,
- ExpressionType::MaxColsAtCompileTime> MatrixType;
-
- _EIGEN_GENERIC_PUBLIC_INTERFACE(EvalOMP, MatrixType)
-
- #ifdef _OPENMP
- explicit EvalOMP(const ExpressionType& other)
- : MatrixType(other.rows(), other.cols())
- {
- #ifdef __INTEL_COMPILER
- #pragma omp parallel default(none) shared(other)
- #else
- #pragma omp parallel default(none)
- #endif
- {
- if (this->cols()>this->rows())
- {
- #pragma omp for
- for(int j = 0; j < this->cols(); j++)
- for(int i = 0; i < this->rows(); i++)
- this->coeffRef(i, j) = other.coeff(i, j);
- }
- else
- {
- #pragma omp for
- for(int i = 0; i < this->rows(); i++)
- for(int j = 0; j < this->cols(); j++)
- this->coeffRef(i, j) = other.coeff(i, j);
- }
- }
- }
- #else
- explicit EvalOMP(const ExpressionType& other) : MatrixType(other) {}
- #endif
-};
-
-/** Evaluates *this in a parallel fashion using OpenMP and returns the obtained matrix.
- *
- * Of course, it only makes sense to call this function for complex expressions, and/or
- * large matrices (>32x32), \b and if there is no outer loop which can be parallelized.
- *
- * It is the responsibility of the user manage the OpenMP parameters, for instance:
- * \code
- * #include <omp.h>
- * // ...
- * omp_set_num_threads(omp_get_num_procs());
- * \endcode
- * You also need to enable OpenMP on your compiler (e.g., -fopenmp) during both compilation and linking.
- *
- * Note that if OpenMP is not enabled, then evalOMP() is equivalent to eval().
- *
- * \sa class EvalOMP, eval()
- */
-template<typename Derived>
-const EvalOMP<Derived> MatrixBase<Derived>::evalOMP() const
-{
- return EvalOMP<Derived>(*static_cast<const Derived*>(this));
-}
-
-#endif // EIGEN_EVAL_OMP_H
diff --git a/Eigen/src/Core/ForwardDeclarations.h b/Eigen/src/Core/ForwardDeclarations.h
index 3c9d9db70..58e1bf353 100644
--- a/Eigen/src/Core/ForwardDeclarations.h
+++ b/Eigen/src/Core/ForwardDeclarations.h
@@ -86,11 +86,17 @@ template<typename T, bool value> struct ei_conditional_eval
template<typename T> struct ei_conditional_eval<T, true>
{
- typedef Eval<T> Type;
+ typedef Matrix<typename ei_traits<T>::Scalar,
+ ei_traits<T>::RowsAtCompileTime,
+ ei_traits<T>::ColsAtCompileTime,
+ ei_traits<T>::Flags,
+ ei_traits<T>::MaxRowsAtCompileTime,
+ ei_traits<T>::MaxColsAtCompileTime> Type;
};
template<typename T> struct ei_eval_unless_lazy
{
typedef typename ei_conditional_eval<T, !(ei_traits<T>::Flags & LazyBit)>::Type Type;
};
+
#endif // EIGEN_FORWARDDECLARATIONS_H
diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h
index e1caa4c48..7f8283e9f 100644
--- a/Eigen/src/Core/MatrixBase.h
+++ b/Eigen/src/Core/MatrixBase.h
@@ -356,8 +356,10 @@ template<typename Derived> class MatrixBase
template<typename NewType>
const CwiseUnaryOp<ei_scalar_cast_op<NewType>, Derived> cast() const;
- const typename ei_eval_unless_lazy<Derived>::Type eval() const EIGEN_ALWAYS_INLINE;
- const EvalOMP<Derived> evalOMP() const EIGEN_ALWAYS_INLINE;
+ const typename ei_eval_unless_lazy<Derived>::Type eval() const EIGEN_ALWAYS_INLINE
+ {
+ return typename ei_eval_unless_lazy<Derived>::Type(derived());
+ }
template<typename OtherDerived>
void swap(const MatrixBase<OtherDerived>& other);
diff --git a/Eigen/src/Core/Util.h b/Eigen/src/Core/Util.h
index ae9624aa1..9aaac9ae2 100644
--- a/Eigen/src/Core/Util.h
+++ b/Eigen/src/Core/Util.h
@@ -117,7 +117,13 @@ enum { RowsAtCompileTime = Base::RowsAtCompileTime, \
SizeAtCompileTime = Base::SizeAtCompileTime, \
MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
IsVectorAtCompileTime = Base::IsVectorAtCompileTime, \
- Flags = Base::Flags };
+ Flags = Base::Flags }; \
+typedef Matrix<Scalar, \
+ RowsAtCompileTime, \
+ ColsAtCompileTime, \
+ Flags, \
+ MaxRowsAtCompileTime, \
+ MaxColsAtCompileTime> Eval;
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
_EIGEN_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::MatrixBase<Derived>) \