This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
View | Details | Raw Unified | Return to bug 99 | Differences between
and this patch

Collapse All | Expand All

(-)a/Eigen/src/Core/Array.h (+9 lines)
Lines 41-56 Link Here
41
  */
41
  */
42
namespace internal {
42
namespace internal {
43
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
43
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
44
struct traits<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > : traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
44
struct traits<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > : traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
45
{
45
{
46
  typedef ArrayXpr XprKind;
46
  typedef ArrayXpr XprKind;
47
  typedef ArrayBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > XprBase;
47
  typedef ArrayBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > XprBase;
48
};
48
};
49
50
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
51
struct evaluator<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
52
{
53
  typedef Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> xpr_type;
54
  typedef xpr_type type;
55
  const type& result;
56
  evaluator(const xpr_type& xpr) : result(xpr) {}
57
};
49
}
58
}
50
59
51
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
60
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
52
class Array
61
class Array
53
  : public PlainObjectBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
62
  : public PlainObjectBase<Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
54
{
63
{
55
  public:
64
  public:
56
65
(-)a/Eigen/src/Core/ArrayWrapper.h (+22 lines)
Lines 38-53 Link Here
38
38
39
namespace internal {
39
namespace internal {
40
template<typename ExpressionType>
40
template<typename ExpressionType>
41
struct traits<ArrayWrapper<ExpressionType> >
41
struct traits<ArrayWrapper<ExpressionType> >
42
  : public traits<typename remove_all<typename ExpressionType::Nested>::type >
42
  : public traits<typename remove_all<typename ExpressionType::Nested>::type >
43
{
43
{
44
  typedef ArrayXpr XprKind;
44
  typedef ArrayXpr XprKind;
45
};
45
};
46
47
template<typename ExpressionType>
48
struct evaluator<ArrayWrapper<ExpressionType> >
49
{
50
  typedef ArrayWrapper<ExpressionType> xpr_type;
51
  typedef ArrayWrapper<typename evaluator<ExpressionType>::type> type;
52
  type result;
53
  evaluator(const xpr_type& xpr) : result(xpr.nestedXpr()) {}
54
};
46
}
55
}
47
56
48
template<typename ExpressionType>
57
template<typename ExpressionType>
49
class ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> >
58
class ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> >
50
{
59
{
51
  public:
60
  public:
52
    typedef ArrayBase<ArrayWrapper> Base;
61
    typedef ArrayBase<ArrayWrapper> Base;
53
    EIGEN_DENSE_PUBLIC_INTERFACE(ArrayWrapper)
62
    EIGEN_DENSE_PUBLIC_INTERFACE(ArrayWrapper)
Lines 104-119 class ArrayWrapper : public ArrayBase<Ar Link Here
104
    inline void writePacket(Index index, const PacketScalar& x)
113
    inline void writePacket(Index index, const PacketScalar& x)
105
    {
114
    {
106
      m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
115
      m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
107
    }
116
    }
108
117
109
    template<typename Dest>
118
    template<typename Dest>
110
    inline void evalTo(Dest& dst) const { dst = m_expression; }
119
    inline void evalTo(Dest& dst) const { dst = m_expression; }
111
120
121
    const NestedExpressionType nestedXpr() const { return m_expression; }
122
112
  protected:
123
  protected:
113
    const NestedExpressionType m_expression;
124
    const NestedExpressionType m_expression;
114
};
125
};
115
126
116
/** \class MatrixWrapper
127
/** \class MatrixWrapper
117
  * \ingroup Core_Module
128
  * \ingroup Core_Module
118
  *
129
  *
119
  * \brief Expression of an array as a mathematical vector or matrix
130
  * \brief Expression of an array as a mathematical vector or matrix
Lines 126-141 class ArrayWrapper : public ArrayBase<Ar Link Here
126
137
127
namespace internal {
138
namespace internal {
128
template<typename ExpressionType>
139
template<typename ExpressionType>
129
struct traits<MatrixWrapper<ExpressionType> >
140
struct traits<MatrixWrapper<ExpressionType> >
130
 : public traits<typename remove_all<typename ExpressionType::Nested>::type >
141
 : public traits<typename remove_all<typename ExpressionType::Nested>::type >
131
{
142
{
132
  typedef MatrixXpr XprKind;
143
  typedef MatrixXpr XprKind;
133
};
144
};
145
146
template<typename ExpressionType>
147
struct evaluator<MatrixWrapper<ExpressionType> >
148
{
149
  typedef MatrixWrapper<ExpressionType> xpr_type;
150
  typedef MatrixWrapper<typename evaluator<ExpressionType>::type> type;
151
  type result;
152
  evaluator(const xpr_type& xpr) : result(xpr.nestedXpr()) {}
153
};
134
}
154
}
135
155
136
template<typename ExpressionType>
156
template<typename ExpressionType>
137
class MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> >
157
class MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> >
138
{
158
{
139
  public:
159
  public:
140
    typedef MatrixBase<MatrixWrapper<ExpressionType> > Base;
160
    typedef MatrixBase<MatrixWrapper<ExpressionType> > Base;
141
    EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper)
161
    EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper)
Lines 189-201 class MatrixWrapper : public MatrixBase< Link Here
189
    }
209
    }
190
210
191
    template<int LoadMode>
211
    template<int LoadMode>
192
    inline void writePacket(Index index, const PacketScalar& x)
212
    inline void writePacket(Index index, const PacketScalar& x)
193
    {
213
    {
194
      m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
214
      m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
195
    }
215
    }
196
216
217
    const NestedExpressionType nestedXpr() const { return m_expression; }
218
197
  protected:
219
  protected:
198
    const NestedExpressionType m_expression;
220
    const NestedExpressionType m_expression;
199
};
221
};
200
222
201
#endif // EIGEN_ARRAYWRAPPER_H
223
#endif // EIGEN_ARRAYWRAPPER_H
(-)a/Eigen/src/Core/Assign.h (-4 / +21 lines)
Lines 513-554 EIGEN_STRONG_INLINE Derived& DenseBase<D Link Here
513
  checkTransposeAliasing(other.derived());
513
  checkTransposeAliasing(other.derived());
514
#endif
514
#endif
515
  return derived();
515
  return derived();
516
}
516
}
517
517
518
namespace internal {
518
namespace internal {
519
519
520
template<typename Derived, typename OtherDerived,
520
template<typename Derived, typename OtherDerived,
521
         bool NeedEvaluator = !is_same<OtherDerived, typename evaluator<OtherDerived>::type >::value,
521
         bool EvalBeforeAssigning = (int(OtherDerived::Flags) & EvalBeforeAssigningBit) != 0,
522
         bool EvalBeforeAssigning = (int(OtherDerived::Flags) & EvalBeforeAssigningBit) != 0,
522
         bool NeedToTranspose = Derived::IsVectorAtCompileTime
523
         bool NeedToTranspose = Derived::IsVectorAtCompileTime
523
                && OtherDerived::IsVectorAtCompileTime
524
                && OtherDerived::IsVectorAtCompileTime
524
                && ((int(Derived::RowsAtCompileTime) == 1 && int(OtherDerived::ColsAtCompileTime) == 1)
525
                && ((int(Derived::RowsAtCompileTime) == 1 && int(OtherDerived::ColsAtCompileTime) == 1)
525
                      |  // FIXME | instead of || to please GCC 4.4.0 stupid warning "suggest parentheses around &&".
526
                      |  // FIXME | instead of || to please GCC 4.4.0 stupid warning "suggest parentheses around &&".
526
                         // revert to || as soon as not needed anymore.
527
                         // revert to || as soon as not needed anymore.
527
                    (int(Derived::ColsAtCompileTime) == 1 && int(OtherDerived::RowsAtCompileTime) == 1))
528
                    (int(Derived::ColsAtCompileTime) == 1 && int(OtherDerived::RowsAtCompileTime) == 1))
528
                && int(Derived::SizeAtCompileTime) != 1>
529
                && int(Derived::SizeAtCompileTime) != 1>
529
struct assign_selector;
530
struct assign_selector;
530
531
531
template<typename Derived, typename OtherDerived>
532
template<typename Derived, typename OtherDerived>
532
struct assign_selector<Derived,OtherDerived,false,false> {
533
struct assign_selector<Derived,OtherDerived,false,false,false> {
533
  EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.derived()); }
534
  EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.derived()); }
534
};
535
};
535
template<typename Derived, typename OtherDerived>
536
template<typename Derived, typename OtherDerived>
536
struct assign_selector<Derived,OtherDerived,true,false> {
537
struct assign_selector<Derived,OtherDerived,false,true,false> {
537
  EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.eval()); }
538
  EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.eval()); }
538
};
539
};
539
template<typename Derived, typename OtherDerived>
540
template<typename Derived, typename OtherDerived>
540
struct assign_selector<Derived,OtherDerived,false,true> {
541
struct assign_selector<Derived,OtherDerived,false,false,true> {
541
  EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.transpose()); }
542
  EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.transpose()); }
542
};
543
};
543
template<typename Derived, typename OtherDerived>
544
template<typename Derived, typename OtherDerived>
544
struct assign_selector<Derived,OtherDerived,true,true> {
545
struct assign_selector<Derived,OtherDerived,false,true,true> {
545
  EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.transpose().eval()); }
546
  EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(other.transpose().eval()); }
546
};
547
};
548
template<typename Derived, typename OtherDerived>
549
struct assign_selector<Derived,OtherDerived,true,false,false> {
550
  EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(evaluator<OtherDerived>(other).result); }
551
};
552
template<typename Derived, typename OtherDerived>
553
struct assign_selector<Derived,OtherDerived,true,true,false> {
554
  EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(evaluator<OtherDerived>(other).result.eval()); }
555
};
556
template<typename Derived, typename OtherDerived>
557
struct assign_selector<Derived,OtherDerived,true,false,true> {
558
  EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(evaluator<OtherDerived>(other.transpose()).result); }
559
};
560
template<typename Derived, typename OtherDerived>
561
struct assign_selector<Derived,OtherDerived,true,true,true> {
562
  EIGEN_STRONG_INLINE static Derived& run(Derived& dst, const OtherDerived& other) { return dst.lazyAssign(evaluator<OtherDerived>(other.transpose()).result.eval()); }
563
};
547
564
548
} // end namespace internal
565
} // end namespace internal
549
566
550
template<typename Derived>
567
template<typename Derived>
551
template<typename OtherDerived>
568
template<typename OtherDerived>
552
EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator=(const DenseBase<OtherDerived>& other)
569
EIGEN_STRONG_INLINE Derived& DenseBase<Derived>::operator=(const DenseBase<OtherDerived>& other)
553
{
570
{
554
  return internal::assign_selector<Derived,OtherDerived>::run(derived(), other.derived());
571
  return internal::assign_selector<Derived,OtherDerived>::run(derived(), other.derived());
(-)a/Eigen/src/Core/Matrix.h (+10 lines)
Lines 125-140 struct traits<Matrix<_Scalar, _Rows, _Co Link Here
125
    MaxColsAtCompileTime = _MaxCols,
125
    MaxColsAtCompileTime = _MaxCols,
126
    Flags = compute_matrix_flags<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::ret,
126
    Flags = compute_matrix_flags<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::ret,
127
    CoeffReadCost = NumTraits<Scalar>::ReadCost,
127
    CoeffReadCost = NumTraits<Scalar>::ReadCost,
128
    Options = _Options,
128
    Options = _Options,
129
    InnerStrideAtCompileTime = 1,
129
    InnerStrideAtCompileTime = 1,
130
    OuterStrideAtCompileTime = (Options&RowMajor) ? ColsAtCompileTime : RowsAtCompileTime
130
    OuterStrideAtCompileTime = (Options&RowMajor) ? ColsAtCompileTime : RowsAtCompileTime
131
  };
131
  };
132
};
132
};
133
134
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
135
struct evaluator<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
136
{
137
  typedef Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> xpr_type;
138
  typedef xpr_type type;
139
  const type& result;
140
  evaluator(const xpr_type& xpr) : result(xpr) {}
141
};
142
133
}
143
}
134
144
135
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
145
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
136
class Matrix
146
class Matrix
137
  : public PlainObjectBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
147
  : public PlainObjectBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
138
{
148
{
139
  public:
149
  public:
140
150
(-)a/Eigen/src/Core/PlainObjectBase.h (-1 / +1 lines)
Lines 478-494 class PlainObjectBase : public internal: Link Here
478
    template<typename OtherDerived>
478
    template<typename OtherDerived>
479
    EIGEN_STRONG_INLINE Derived& _set_noalias(const DenseBase<OtherDerived>& other)
479
    EIGEN_STRONG_INLINE Derived& _set_noalias(const DenseBase<OtherDerived>& other)
480
    {
480
    {
481
      // I don't think we need this resize call since the lazyAssign will anyways resize
481
      // I don't think we need this resize call since the lazyAssign will anyways resize
482
      // and lazyAssign will be called by the assign selector.
482
      // and lazyAssign will be called by the assign selector.
483
      //_resize_to_match(other);
483
      //_resize_to_match(other);
484
      // the 'false' below means to enforce lazy evaluation. We don't use lazyAssign() because
484
      // the 'false' below means to enforce lazy evaluation. We don't use lazyAssign() because
485
      // it wouldn't allow to copy a row-vector into a column-vector.
485
      // it wouldn't allow to copy a row-vector into a column-vector.
486
      return internal::assign_selector<Derived,OtherDerived,false>::run(this->derived(), other.derived());
486
      return internal::assign_selector<Derived,OtherDerived,!internal::is_same<OtherDerived, typename internal::evaluator<OtherDerived>::type>::value,false>::run(this->derived(), other.derived());
487
    }
487
    }
488
488
489
    template<typename T0, typename T1>
489
    template<typename T0, typename T1>
490
    EIGEN_STRONG_INLINE void _init2(Index rows, Index cols, typename internal::enable_if<Base::SizeAtCompileTime!=2,T0>::type* = 0)
490
    EIGEN_STRONG_INLINE void _init2(Index rows, Index cols, typename internal::enable_if<Base::SizeAtCompileTime!=2,T0>::type* = 0)
491
    {
491
    {
492
      eigen_assert(rows >= 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
492
      eigen_assert(rows >= 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
493
             && cols >= 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
493
             && cols >= 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
494
      m_storage.resize(rows*cols,rows,cols);
494
      m_storage.resize(rows*cols,rows,cols);
(-)a/Eigen/src/Core/Transpose.h (+9 lines)
Lines 55-70 struct traits<Transpose<MatrixType> > : Link Here
55
    MaxRowsAtCompileTime = MatrixType::MaxColsAtCompileTime,
55
    MaxRowsAtCompileTime = MatrixType::MaxColsAtCompileTime,
56
    MaxColsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
56
    MaxColsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
57
    Flags = int(_MatrixTypeNested::Flags & ~NestByRefBit) ^ RowMajorBit,
57
    Flags = int(_MatrixTypeNested::Flags & ~NestByRefBit) ^ RowMajorBit,
58
    CoeffReadCost = _MatrixTypeNested::CoeffReadCost,
58
    CoeffReadCost = _MatrixTypeNested::CoeffReadCost,
59
    InnerStrideAtCompileTime = inner_stride_at_compile_time<MatrixType>::ret,
59
    InnerStrideAtCompileTime = inner_stride_at_compile_time<MatrixType>::ret,
60
    OuterStrideAtCompileTime = outer_stride_at_compile_time<MatrixType>::ret
60
    OuterStrideAtCompileTime = outer_stride_at_compile_time<MatrixType>::ret
61
  };
61
  };
62
};
62
};
63
64
template<typename ExpressionType>
65
struct evaluator<Transpose<ExpressionType> >
66
{
67
  typedef Transpose<ExpressionType> xpr_type;
68
  typedef Transpose<typename evaluator<ExpressionType>::type> type;
69
  type result;
70
  evaluator(const xpr_type& xpr) : result(xpr.nestedExpression()) {}
71
};
63
}
72
}
64
73
65
template<typename MatrixType, typename StorageKind> class TransposeImpl;
74
template<typename MatrixType, typename StorageKind> class TransposeImpl;
66
75
67
template<typename MatrixType> class Transpose
76
template<typename MatrixType> class Transpose
68
  : public TransposeImpl<MatrixType,typename internal::traits<MatrixType>::StorageKind>
77
  : public TransposeImpl<MatrixType,typename internal::traits<MatrixType>::StorageKind>
69
{
78
{
70
  public:
79
  public:
(-)a/Eigen/src/Core/util/ForwardDeclarations.h (+4 lines)
Lines 22-43 Link Here
22
// You should have received a copy of the GNU Lesser General Public
22
// You should have received a copy of the GNU Lesser General Public
23
// License and a copy of the GNU General Public License along with
23
// License and a copy of the GNU General Public License along with
24
// Eigen. If not, see <http://www.gnu.org/licenses/>.
24
// Eigen. If not, see <http://www.gnu.org/licenses/>.
25
25
26
#ifndef EIGEN_FORWARDDECLARATIONS_H
26
#ifndef EIGEN_FORWARDDECLARATIONS_H
27
#define EIGEN_FORWARDDECLARATIONS_H
27
#define EIGEN_FORWARDDECLARATIONS_H
28
28
29
namespace internal {
29
namespace internal {
30
30
template<typename T> struct traits;
31
template<typename T> struct traits;
31
32
32
template<typename Derived> struct has_direct_access
33
template<typename Derived> struct has_direct_access
33
{
34
{
34
  enum { ret = (traits<Derived>::Flags & DirectAccessBit) ? 1 : 0 };
35
  enum { ret = (traits<Derived>::Flags & DirectAccessBit) ? 1 : 0 };
35
};
36
};
37
38
template<typename T> struct evaluator {};
39
36
} // end namespace internal
40
} // end namespace internal
37
41
38
template<typename T> struct NumTraits;
42
template<typename T> struct NumTraits;
39
43
40
template<typename Derived> struct EigenBase;
44
template<typename Derived> struct EigenBase;
41
template<typename Derived> class DenseBase;
45
template<typename Derived> class DenseBase;
42
template<typename Derived,
46
template<typename Derived,
43
         AccessorLevels Level = (internal::traits<Derived>::Flags & DirectAccessBit) ? DirectAccessors
47
         AccessorLevels Level = (internal::traits<Derived>::Flags & DirectAccessBit) ? DirectAccessors

Return to bug 99