aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2015-06-19 15:38:19 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2015-06-19 15:38:19 +0200
commit0c8b0e007b282139b4d3ab8e74f287c8e5109d69 (patch)
treeac16b08787bf23face06d0be6454bc8f923a57f7 /Eigen
parent3f6aa4cd5d03bd9e6e41d2f997fa7bd9b98bd68e (diff)
Introduce a AliasFreeProduct option for Permutations and Transpositions
Diffstat (limited to 'Eigen')
-rw-r--r--Eigen/src/Core/PermutationMatrix.h16
-rw-r--r--Eigen/src/Core/Product.h2
-rw-r--r--Eigen/src/Core/ProductEvaluators.h37
-rw-r--r--Eigen/src/Core/Transpositions.h16
-rw-r--r--Eigen/src/Core/util/Constants.h2
-rw-r--r--Eigen/src/SparseCore/SparsePermutation.h8
6 files changed, 46 insertions, 35 deletions
diff --git a/Eigen/src/Core/PermutationMatrix.h b/Eigen/src/Core/PermutationMatrix.h
index 8cf989f2c..bfe6f899a 100644
--- a/Eigen/src/Core/PermutationMatrix.h
+++ b/Eigen/src/Core/PermutationMatrix.h
@@ -541,11 +541,11 @@ class PermutationWrapper : public PermutationBase<PermutationWrapper<_IndicesTyp
*/
template<typename MatrixDerived, typename PermutationDerived>
EIGEN_DEVICE_FUNC
-const Product<MatrixDerived, PermutationDerived, DefaultProduct>
+const Product<MatrixDerived, PermutationDerived, AliasFreeProduct>
operator*(const MatrixBase<MatrixDerived> &matrix,
const PermutationBase<PermutationDerived>& permutation)
{
- return Product<MatrixDerived, PermutationDerived, DefaultProduct>
+ return Product<MatrixDerived, PermutationDerived, AliasFreeProduct>
(matrix.derived(), permutation.derived());
}
@@ -553,11 +553,11 @@ operator*(const MatrixBase<MatrixDerived> &matrix,
*/
template<typename PermutationDerived, typename MatrixDerived>
EIGEN_DEVICE_FUNC
-const Product<PermutationDerived, MatrixDerived, DefaultProduct>
+const Product<PermutationDerived, MatrixDerived, AliasFreeProduct>
operator*(const PermutationBase<PermutationDerived> &permutation,
const MatrixBase<MatrixDerived>& matrix)
{
- return Product<PermutationDerived, MatrixDerived, DefaultProduct>
+ return Product<PermutationDerived, MatrixDerived, AliasFreeProduct>
(permutation.derived(), matrix.derived());
}
@@ -620,19 +620,19 @@ class Transpose<PermutationBase<Derived> >
/** \returns the matrix with the inverse permutation applied to the columns.
*/
template<typename OtherDerived> friend
- const Product<OtherDerived, Transpose, DefaultProduct>
+ const Product<OtherDerived, Transpose, AliasFreeProduct>
operator*(const MatrixBase<OtherDerived>& matrix, const Transpose& trPerm)
{
- return Product<OtherDerived, Transpose, DefaultProduct>(matrix.derived(), trPerm.derived());
+ return Product<OtherDerived, Transpose, AliasFreeProduct>(matrix.derived(), trPerm.derived());
}
/** \returns the matrix with the inverse permutation applied to the rows.
*/
template<typename OtherDerived>
- const Product<Transpose, OtherDerived, DefaultProduct>
+ const Product<Transpose, OtherDerived, AliasFreeProduct>
operator*(const MatrixBase<OtherDerived>& matrix) const
{
- return Product<Transpose, OtherDerived, DefaultProduct>(*this, matrix.derived());
+ return Product<Transpose, OtherDerived, AliasFreeProduct>(*this, matrix.derived());
}
const PermutationType& nestedExpression() const { return m_permutation; }
diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h
index 0739528f1..87340b88c 100644
--- a/Eigen/src/Core/Product.h
+++ b/Eigen/src/Core/Product.h
@@ -25,7 +25,7 @@ template<typename Lhs, typename Rhs, int Option, typename StorageKind> class Pro
* This class represents an expression of the product of two arbitrary matrices.
*
* The other template parameters are:
- * \tparam Option can be DefaultProduct or LazyProduct
+ * \tparam Option can be DefaultProduct, AliasFreeProduct, or LazyProduct
*
*/
diff --git a/Eigen/src/Core/ProductEvaluators.h b/Eigen/src/Core/ProductEvaluators.h
index 5765857ce..c12ebb5a0 100644
--- a/Eigen/src/Core/ProductEvaluators.h
+++ b/Eigen/src/Core/ProductEvaluators.h
@@ -90,13 +90,21 @@ struct evaluator_traits<Product<Lhs, Rhs, DefaultProduct> >
enum { AssumeAliasing = 1 };
};
+template<typename Lhs, typename Rhs>
+struct evaluator_traits<Product<Lhs, Rhs, AliasFreeProduct> >
+ : evaluator_traits_base<Product<Lhs, Rhs, AliasFreeProduct> >
+{
+ enum { AssumeAliasing = 0 };
+};
+
// This is the default evaluator implementation for products:
// It creates a temporary and call generic_product_impl
-template<typename Lhs, typename Rhs, int ProductTag, typename LhsShape, typename RhsShape>
-struct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, ProductTag, LhsShape, RhsShape, typename traits<Lhs>::Scalar, typename traits<Rhs>::Scalar>
- : public evaluator<typename Product<Lhs, Rhs, DefaultProduct>::PlainObject>::type
+template<typename Lhs, typename Rhs, int Options, int ProductTag, typename LhsShape, typename RhsShape>
+struct product_evaluator<Product<Lhs, Rhs, Options>, ProductTag, LhsShape, RhsShape, typename traits<Lhs>::Scalar,
+ typename enable_if<(Options==DefaultProduct || Options==AliasFreeProduct),typename traits<Rhs>::Scalar>::type>
+ : public evaluator<typename Product<Lhs, Rhs, Options>::PlainObject>::type
{
- typedef Product<Lhs, Rhs, DefaultProduct> XprType;
+ typedef Product<Lhs, Rhs, Options> XprType;
typedef typename XprType::PlainObject PlainObject;
typedef typename evaluator<PlainObject>::type Base;
enum {
@@ -128,10 +136,11 @@ protected:
};
// Dense = Product
-template< typename DstXprType, typename Lhs, typename Rhs, typename Scalar>
-struct Assignment<DstXprType, Product<Lhs,Rhs,DefaultProduct>, internal::assign_op<Scalar>, Dense2Dense, Scalar>
+template< typename DstXprType, typename Lhs, typename Rhs, int Options, typename Scalar>
+struct Assignment<DstXprType, Product<Lhs,Rhs,Options>, internal::assign_op<Scalar>, Dense2Dense,
+ typename enable_if<(Options==DefaultProduct || Options==AliasFreeProduct),Scalar>::type>
{
- typedef Product<Lhs,Rhs,DefaultProduct> SrcXprType;
+ typedef Product<Lhs,Rhs,Options> SrcXprType;
static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<Scalar> &)
{
// FIXME shall we handle nested_eval here?
@@ -140,10 +149,11 @@ struct Assignment<DstXprType, Product<Lhs,Rhs,DefaultProduct>, internal::assign_
};
// Dense += Product
-template< typename DstXprType, typename Lhs, typename Rhs, typename Scalar>
-struct Assignment<DstXprType, Product<Lhs,Rhs,DefaultProduct>, internal::add_assign_op<Scalar>, Dense2Dense, Scalar>
+template< typename DstXprType, typename Lhs, typename Rhs, int Options, typename Scalar>
+struct Assignment<DstXprType, Product<Lhs,Rhs,Options>, internal::add_assign_op<Scalar>, Dense2Dense,
+ typename enable_if<(Options==DefaultProduct || Options==AliasFreeProduct),Scalar>::type>
{
- typedef Product<Lhs,Rhs,DefaultProduct> SrcXprType;
+ typedef Product<Lhs,Rhs,Options> SrcXprType;
static void run(DstXprType &dst, const SrcXprType &src, const internal::add_assign_op<Scalar> &)
{
// FIXME shall we handle nested_eval here?
@@ -152,10 +162,11 @@ struct Assignment<DstXprType, Product<Lhs,Rhs,DefaultProduct>, internal::add_ass
};
// Dense -= Product
-template< typename DstXprType, typename Lhs, typename Rhs, typename Scalar>
-struct Assignment<DstXprType, Product<Lhs,Rhs,DefaultProduct>, internal::sub_assign_op<Scalar>, Dense2Dense, Scalar>
+template< typename DstXprType, typename Lhs, typename Rhs, int Options, typename Scalar>
+struct Assignment<DstXprType, Product<Lhs,Rhs,Options>, internal::sub_assign_op<Scalar>, Dense2Dense,
+ typename enable_if<(Options==DefaultProduct || Options==AliasFreeProduct),Scalar>::type>
{
- typedef Product<Lhs,Rhs,DefaultProduct> SrcXprType;
+ typedef Product<Lhs,Rhs,Options> SrcXprType;
static void run(DstXprType &dst, const SrcXprType &src, const internal::sub_assign_op<Scalar> &)
{
// FIXME shall we handle nested_eval here?
diff --git a/Eigen/src/Core/Transpositions.h b/Eigen/src/Core/Transpositions.h
index 0296882f6..3b1c1815d 100644
--- a/Eigen/src/Core/Transpositions.h
+++ b/Eigen/src/Core/Transpositions.h
@@ -334,11 +334,11 @@ class TranspositionsWrapper
*/
template<typename MatrixDerived, typename TranspositionsDerived>
EIGEN_DEVICE_FUNC
-const Product<MatrixDerived, TranspositionsDerived, DefaultProduct>
+const Product<MatrixDerived, TranspositionsDerived, AliasFreeProduct>
operator*(const MatrixBase<MatrixDerived> &matrix,
const TranspositionsBase<TranspositionsDerived>& transpositions)
{
- return Product<MatrixDerived, TranspositionsDerived, DefaultProduct>
+ return Product<MatrixDerived, TranspositionsDerived, AliasFreeProduct>
(matrix.derived(), transpositions.derived());
}
@@ -346,11 +346,11 @@ operator*(const MatrixBase<MatrixDerived> &matrix,
*/
template<typename TranspositionsDerived, typename MatrixDerived>
EIGEN_DEVICE_FUNC
-const Product<TranspositionsDerived, MatrixDerived, DefaultProduct>
+const Product<TranspositionsDerived, MatrixDerived, AliasFreeProduct>
operator*(const TranspositionsBase<TranspositionsDerived> &transpositions,
const MatrixBase<MatrixDerived>& matrix)
{
- return Product<TranspositionsDerived, MatrixDerived, DefaultProduct>
+ return Product<TranspositionsDerived, MatrixDerived, AliasFreeProduct>
(transpositions.derived(), matrix.derived());
}
@@ -381,19 +381,19 @@ class Transpose<TranspositionsBase<TranspositionsDerived> >
/** \returns the \a matrix with the inverse transpositions applied to the columns.
*/
template<typename OtherDerived> friend
- const Product<OtherDerived, Transpose, DefaultProduct>
+ const Product<OtherDerived, Transpose, AliasFreeProduct>
operator*(const MatrixBase<OtherDerived>& matrix, const Transpose& trt)
{
- return Product<OtherDerived, Transpose, DefaultProduct>(matrix.derived(), trt.derived());
+ return Product<OtherDerived, Transpose, AliasFreeProduct>(matrix.derived(), trt.derived());
}
/** \returns the \a matrix with the inverse transpositions applied to the rows.
*/
template<typename OtherDerived>
- const Product<Transpose, OtherDerived, DefaultProduct>
+ const Product<Transpose, OtherDerived, AliasFreeProduct>
operator*(const MatrixBase<OtherDerived>& matrix) const
{
- return Product<Transpose, OtherDerived, DefaultProduct>(*this, matrix.derived());
+ return Product<Transpose, OtherDerived, AliasFreeProduct>(*this, matrix.derived());
}
const TranspositionType& nestedExpression() const { return m_transpositions; }
diff --git a/Eigen/src/Core/util/Constants.h b/Eigen/src/Core/util/Constants.h
index 8d6089b2d..c5a0b0930 100644
--- a/Eigen/src/Core/util/Constants.h
+++ b/Eigen/src/Core/util/Constants.h
@@ -453,7 +453,7 @@ namespace Architecture
/** \internal \ingroup enums
* Enum used as template parameter in GeneralProduct. */
-enum { DefaultProduct=0, CoeffBasedProductMode, LazyCoeffBasedProductMode, LazyProduct, OuterProduct, InnerProduct, GemvProduct, GemmProduct };
+enum { DefaultProduct=0, LazyProduct, AliasFreeProduct, CoeffBasedProductMode, LazyCoeffBasedProductMode, OuterProduct, InnerProduct, GemvProduct, GemmProduct };
/** \internal \ingroup enums
* Enum used in experimental parallel implementation. */
diff --git a/Eigen/src/SparseCore/SparsePermutation.h b/Eigen/src/SparseCore/SparsePermutation.h
index b15128979..7b5eb4c22 100644
--- a/Eigen/src/SparseCore/SparsePermutation.h
+++ b/Eigen/src/SparseCore/SparsePermutation.h
@@ -90,10 +90,10 @@ template <int ProductTag> struct product_promote_storage_type<PermutationStorage
// whereas it should be correctly handled by traits<Product<> >::PlainObject
template<typename Lhs, typename Rhs, int ProductTag>
-struct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, ProductTag, PermutationShape, SparseShape, typename traits<Lhs>::Scalar, typename traits<Rhs>::Scalar>
+struct product_evaluator<Product<Lhs, Rhs, AliasFreeProduct>, ProductTag, PermutationShape, SparseShape, typename traits<Lhs>::Scalar, typename traits<Rhs>::Scalar>
: public evaluator<typename permutation_matrix_product<Rhs,OnTheRight,false,SparseShape>::ReturnType>::type
{
- typedef Product<Lhs, Rhs, DefaultProduct> XprType;
+ typedef Product<Lhs, Rhs, AliasFreeProduct> XprType;
typedef typename permutation_matrix_product<Rhs,OnTheRight,false,SparseShape>::ReturnType PlainObject;
typedef typename evaluator<PlainObject>::type Base;
@@ -109,10 +109,10 @@ protected:
};
template<typename Lhs, typename Rhs, int ProductTag>
-struct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, ProductTag, SparseShape, PermutationShape, typename traits<Lhs>::Scalar, typename traits<Rhs>::Scalar>
+struct product_evaluator<Product<Lhs, Rhs, AliasFreeProduct>, ProductTag, SparseShape, PermutationShape, typename traits<Lhs>::Scalar, typename traits<Rhs>::Scalar>
: public evaluator<typename permutation_matrix_product<Lhs,OnTheRight,false,SparseShape>::ReturnType>::type
{
- typedef Product<Lhs, Rhs, DefaultProduct> XprType;
+ typedef Product<Lhs, Rhs, AliasFreeProduct> XprType;
typedef typename permutation_matrix_product<Lhs,OnTheRight,false,SparseShape>::ReturnType PlainObject;
typedef typename evaluator<PlainObject>::type Base;