mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-05-12 07:49:02 +08:00
implement the missing outer product,
and attempt to workaround a gcc internal error
This commit is contained in:
parent
88147e0a91
commit
84a7659bef
@ -50,8 +50,8 @@ class GeneralProduct;
|
|||||||
template<int Rows, int Cols, int Depth> struct ei_product_type_selector;
|
template<int Rows, int Cols, int Depth> struct ei_product_type_selector;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
Large = Dynamic,
|
Large = Dynamic,
|
||||||
Small = -Dynamic
|
Small = Dynamic/2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum { OuterProduct, InnerProduct, UnrolledProduct, GemvProduct, GemmProduct };
|
enum { OuterProduct, InnerProduct, UnrolledProduct, GemvProduct, GemmProduct };
|
||||||
@ -63,9 +63,9 @@ template<typename Lhs, typename Rhs> struct ei_product_type
|
|||||||
Cols = Rhs::ColsAtCompileTime,
|
Cols = Rhs::ColsAtCompileTime,
|
||||||
Depth = EIGEN_ENUM_MIN(Lhs::ColsAtCompileTime,Rhs::RowsAtCompileTime),
|
Depth = EIGEN_ENUM_MIN(Lhs::ColsAtCompileTime,Rhs::RowsAtCompileTime),
|
||||||
|
|
||||||
value = ei_product_type_selector<(Rows>8 ? Large : Rows==1 ? 1 : Small),
|
value = ei_product_type_selector<(Rows>8 ? Large : (Rows==1 ? 1 : Small)),
|
||||||
(Cols>8 ? Large : Cols==1 ? 1 : Small),
|
(Cols>8 ? Large : (Cols==1 ? 1 : Small)),
|
||||||
(Depth>8 ? Large : Depth==1 ? 1 : Small)>::ret
|
(Depth>8 ? Large : (Depth==1 ? 1 : Small))>::ret
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -199,6 +199,7 @@ class GeneralProduct<Lhs, Rhs, InnerProduct>
|
|||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Implementation of Outer Vector Vector Product
|
* Implementation of Outer Vector Vector Product
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
template<int StorageOrder> struct ei_outer_product_selector;
|
||||||
|
|
||||||
template<typename Lhs, typename Rhs>
|
template<typename Lhs, typename Rhs>
|
||||||
struct ei_traits<GeneralProduct<Lhs,Rhs,OuterProduct> >
|
struct ei_traits<GeneralProduct<Lhs,Rhs,OuterProduct> >
|
||||||
@ -214,12 +215,32 @@ class GeneralProduct<Lhs, Rhs, OuterProduct>
|
|||||||
|
|
||||||
GeneralProduct(const Lhs& lhs, const Rhs& rhs) : Base(lhs,rhs) {}
|
GeneralProduct(const Lhs& lhs, const Rhs& rhs) : Base(lhs,rhs) {}
|
||||||
|
|
||||||
template<typename Dest> void addTo(Dest& dst, Scalar alpha) const
|
template<typename Dest> void addTo(Dest& dest, Scalar alpha) const
|
||||||
{
|
{
|
||||||
// TODO
|
ei_outer_product_selector<Dest::Flags&RowMajorBit>::run(*this, dest, alpha);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<> struct ei_outer_product_selector<ColMajor> {
|
||||||
|
template<typename ProductType, typename Dest>
|
||||||
|
static void run(const ProductType& prod, Dest& dest, typename ProductType::Scalar alpha) {
|
||||||
|
// FIXME make sure lhs is sequentially stored
|
||||||
|
const int cols = dest.cols();
|
||||||
|
for (int j=0; j<cols; ++j)
|
||||||
|
dest.col(j) += (alpha * prod.rhs().coeff(j)) * prod.lhs();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<> struct ei_outer_product_selector<RowMajor> {
|
||||||
|
template<typename ProductType, typename Dest>
|
||||||
|
static void run(const ProductType& prod, Dest& dest, typename ProductType::Scalar alpha) {
|
||||||
|
// FIXME make sure rhs is sequentially stored
|
||||||
|
const int rows = dest.rows();
|
||||||
|
for (int i=0; i<rows; ++i)
|
||||||
|
dest.row(i) += (alpha * prod.lhs().coeff(i)) * prod.rhs();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Implementation of General Matrix Vector Product
|
* Implementation of General Matrix Vector Product
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user