aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/SparseCore/SparseUtil.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2011-12-22 14:01:06 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2011-12-22 14:01:06 +0100
commit2c03e6fccc274db665c6e4708f2cbde14813e826 (patch)
tree9b2ca1b7b59b7f1d6fb00f2f4d749d88ca890311 /Eigen/src/SparseCore/SparseUtil.h
parent7f0484502328c1ee0ed6a3916d7f3aa4417237c1 (diff)
evaluate 1D sparse expressions into SparseVector and make the sparse operator<< and dot honor nested types
Diffstat (limited to 'Eigen/src/SparseCore/SparseUtil.h')
-rw-r--r--Eigen/src/SparseCore/SparseUtil.h30
1 files changed, 26 insertions, 4 deletions
diff --git a/Eigen/src/SparseCore/SparseUtil.h b/Eigen/src/SparseCore/SparseUtil.h
index db9ae98e7..a03cdbd5b 100644
--- a/Eigen/src/SparseCore/SparseUtil.h
+++ b/Eigen/src/SparseCore/SparseUtil.h
@@ -103,17 +103,39 @@ template<typename Lhs, typename Rhs, int InnerSize = internal::traits<Lhs>::Cols
namespace internal {
+template<typename T,int Rows,int Cols> struct sparse_eval;
+
template<typename T> struct eval<T,Sparse>
-{
+ : public sparse_eval<T, traits<T>::RowsAtCompileTime,traits<T>::ColsAtCompileTime>
+{};
+
+template<typename T,int Cols> struct sparse_eval<T,1,Cols> {
typedef typename traits<T>::Scalar _Scalar;
- enum {
- _Flags = traits<T>::Flags
- };
+ enum { _Flags = traits<T>::Flags| RowMajorBit };
+ public:
+ typedef SparseVector<_Scalar, _Flags> type;
+};
+template<typename T,int Rows> struct sparse_eval<T,Rows,1> {
+ typedef typename traits<T>::Scalar _Scalar;
+ enum { _Flags = traits<T>::Flags & (~RowMajorBit) };
+ public:
+ typedef SparseVector<_Scalar, _Flags> type;
+};
+
+template<typename T,int Rows,int Cols> struct sparse_eval {
+ typedef typename traits<T>::Scalar _Scalar;
+ enum { _Flags = traits<T>::Flags };
public:
typedef SparseMatrix<_Scalar, _Flags> type;
};
+template<typename T> struct sparse_eval<T,1,1> {
+ typedef typename traits<T>::Scalar _Scalar;
+ public:
+ typedef Matrix<_Scalar, 1, 1> type;
+};
+
template<typename T> struct plain_matrix_type<T,Sparse>
{
typedef typename traits<T>::Scalar _Scalar;