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/Core (-6 / +5 lines)
Lines 276-291 using std::size_t; Link Here
276
#include "src/Core/arch/Default/Settings.h"
276
#include "src/Core/arch/Default/Settings.h"
277
277
278
#include "src/Core/Functors.h"
278
#include "src/Core/Functors.h"
279
#include "src/Core/DenseCoeffsBase.h"
279
#include "src/Core/DenseCoeffsBase.h"
280
#include "src/Core/DenseBase.h"
280
#include "src/Core/DenseBase.h"
281
#include "src/Core/MatrixBase.h"
281
#include "src/Core/MatrixBase.h"
282
#include "src/Core/EigenBase.h"
282
#include "src/Core/EigenBase.h"
283
283
284
#define EIGEN_ENABLE_EVALUATORS
285
#include "src/Core/Product.h"
286
#include "src/Core/CoreEvaluators.h"
287
#include "src/Core/AssignEvaluator.h"
288
284
#ifndef EIGEN_PARSED_BY_DOXYGEN // work around Doxygen bug triggered by Assign.h r814874
289
#ifndef EIGEN_PARSED_BY_DOXYGEN // work around Doxygen bug triggered by Assign.h r814874
285
                                // at least confirmed with Doxygen 1.5.5 and 1.5.6
290
                                // at least confirmed with Doxygen 1.5.5 and 1.5.6
286
  #include "src/Core/Assign.h"
291
  #include "src/Core/Assign.h"
287
#endif
292
#endif
288
293
289
#include "src/Core/util/BlasUtil.h"
294
#include "src/Core/util/BlasUtil.h"
290
#include "src/Core/DenseStorage.h"
295
#include "src/Core/DenseStorage.h"
291
#include "src/Core/NestByValue.h"
296
#include "src/Core/NestByValue.h"
Lines 345-366 using std::size_t; Link Here
345
#include "src/Core/Select.h"
350
#include "src/Core/Select.h"
346
#include "src/Core/VectorwiseOp.h"
351
#include "src/Core/VectorwiseOp.h"
347
#include "src/Core/Random.h"
352
#include "src/Core/Random.h"
348
#include "src/Core/Replicate.h"
353
#include "src/Core/Replicate.h"
349
#include "src/Core/Reverse.h"
354
#include "src/Core/Reverse.h"
350
#include "src/Core/ArrayBase.h"
355
#include "src/Core/ArrayBase.h"
351
#include "src/Core/ArrayWrapper.h"
356
#include "src/Core/ArrayWrapper.h"
352
357
353
#ifdef EIGEN_ENABLE_EVALUATORS
354
#include "src/Core/Product.h"
355
#include "src/Core/CoreEvaluators.h"
356
#include "src/Core/AssignEvaluator.h"
357
#endif 
358
359
} // namespace Eigen
358
} // namespace Eigen
360
359
361
#include "src/Core/GlobalFunctions.h"
360
#include "src/Core/GlobalFunctions.h"
362
361
363
#include "src/Core/util/ReenableStupidWarnings.h"
362
#include "src/Core/util/ReenableStupidWarnings.h"
364
363
365
#ifdef EIGEN2_SUPPORT
364
#ifdef EIGEN2_SUPPORT
366
#include "Eigen2Support"
365
#include "Eigen2Support"
(-)a/Eigen/src/Core/Assign.h (-1 / +1 lines)
Lines 503-519 EIGEN_STRONG_INLINE Derived& DenseBase<D Link Here
503
  EIGEN_STATIC_ASSERT_LVALUE(Derived)
503
  EIGEN_STATIC_ASSERT_LVALUE(Derived)
504
  EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived)
504
  EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived)
505
  EIGEN_STATIC_ASSERT(SameType,YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
505
  EIGEN_STATIC_ASSERT(SameType,YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
506
506
507
#ifdef EIGEN_DEBUG_ASSIGN
507
#ifdef EIGEN_DEBUG_ASSIGN
508
  internal::assign_traits<Derived, OtherDerived>::debug();
508
  internal::assign_traits<Derived, OtherDerived>::debug();
509
#endif
509
#endif
510
  eigen_assert(rows() == other.rows() && cols() == other.cols());
510
  eigen_assert(rows() == other.rows() && cols() == other.cols());
511
  internal::assign_impl<Derived, OtherDerived, int(SameType) ? int(internal::assign_traits<Derived, OtherDerived>::Traversal)
511
  internal::copy_using_evaluator_impl<Derived, OtherDerived, int(SameType) ? int(internal::assign_traits<Derived, OtherDerived>::Traversal)
512
                                                       : int(InvalidTraversal)>::run(derived(),other.derived());
512
                                                       : int(InvalidTraversal)>::run(derived(),other.derived());
513
#ifndef EIGEN_NO_DEBUG
513
#ifndef EIGEN_NO_DEBUG
514
  checkTransposeAliasing(other.derived());
514
  checkTransposeAliasing(other.derived());
515
#endif
515
#endif
516
  return derived();
516
  return derived();
517
}
517
}
518
518
519
namespace internal {
519
namespace internal {
(-)a/Eigen/src/Core/AssignEvaluator.h (-6 / +7 lines)
Lines 396-421 struct unaligned_copy_using_evaluator_im Link Here
396
396
397
template <>
397
template <>
398
struct unaligned_copy_using_evaluator_impl<false>
398
struct unaligned_copy_using_evaluator_impl<false>
399
{
399
{
400
  // MSVC must not inline this functions. If it does, it fails to optimize the
400
  // MSVC must not inline this functions. If it does, it fails to optimize the
401
  // packet access path.
401
  // packet access path.
402
#ifdef _MSC_VER
402
#ifdef _MSC_VER
403
  template <typename SrcEvaluatorType, typename DstEvaluatorType>
403
  template <typename SrcEvaluatorType, typename DstEvaluatorType>
404
  static EIGEN_DONT_INLINE void run(const SrcEvaluatorType& src, DstEvaluatorType& dst, 
404
  static EIGEN_DONT_INLINE void run(const SrcEvaluatorType& srcEvaluator, DstEvaluatorType& dstEvaluator, 
405
				    typename SrcEvaluatorType::Index start, typename SrcEvaluatorType::Index end)
405
				    typename SrcEvaluatorType::Index start, typename SrcEvaluatorType::Index end)
406
#else
406
#else
407
  template <typename SrcEvaluatorType, typename DstEvaluatorType>
407
  template <typename SrcEvaluatorType, typename DstEvaluatorType>
408
  static EIGEN_STRONG_INLINE void run(const SrcEvaluatorType& src, DstEvaluatorType& dst, 
408
  static EIGEN_STRONG_INLINE void run(const SrcEvaluatorType& srcEvaluator, DstEvaluatorType& dstEvaluator, 
409
				      typename SrcEvaluatorType::Index start, typename SrcEvaluatorType::Index end)
409
				      typename SrcEvaluatorType::Index start, typename SrcEvaluatorType::Index end)
410
#endif
410
#endif
411
  {
411
  {
412
    for (typename SrcEvaluatorType::Index index = start; index < end; ++index)
412
    for (typename SrcEvaluatorType::Index index = start; index < end; ++index)
413
      dst.copyCoeff(index, src);
413
      // TODO: Use copyCoeff ?
414
      dstEvaluator.coeffRef(index) = srcEvaluator.coeff(index);
414
  }
415
  }
415
};
416
};
416
417
417
template<typename DstXprType, typename SrcXprType>
418
template<typename DstXprType, typename SrcXprType>
418
struct copy_using_evaluator_impl<DstXprType, SrcXprType, LinearVectorizedTraversal, NoUnrolling>
419
struct copy_using_evaluator_impl<DstXprType, SrcXprType, LinearVectorizedTraversal, NoUnrolling>
419
{
420
{
420
  EIGEN_STRONG_INLINE static void run(const DstXprType &dst, const SrcXprType &src)
421
  EIGEN_STRONG_INLINE static void run(const DstXprType &dst, const SrcXprType &src)
421
  {
422
  {
Lines 429-455 struct copy_using_evaluator_impl<DstXprT Link Here
429
    const Index size = dst.size();
430
    const Index size = dst.size();
430
    typedef packet_traits<typename DstXprType::Scalar> PacketTraits;
431
    typedef packet_traits<typename DstXprType::Scalar> PacketTraits;
431
    enum {
432
    enum {
432
      packetSize = PacketTraits::size,
433
      packetSize = PacketTraits::size,
433
      dstIsAligned = int(copy_using_evaluator_traits<DstXprType,SrcXprType>::DstIsAligned),
434
      dstIsAligned = int(copy_using_evaluator_traits<DstXprType,SrcXprType>::DstIsAligned),
434
      dstAlignment = PacketTraits::AlignedOnScalar ? Aligned : dstIsAligned,
435
      dstAlignment = PacketTraits::AlignedOnScalar ? Aligned : dstIsAligned,
435
      srcAlignment = copy_using_evaluator_traits<DstXprType,SrcXprType>::JointAlignment
436
      srcAlignment = copy_using_evaluator_traits<DstXprType,SrcXprType>::JointAlignment
436
    };
437
    };
437
    const Index alignedStart = dstIsAligned ? 0 : first_aligned(&dst.coeffRef(0), size);
438
    const Index alignedStart = dstIsAligned ? 0 : first_aligned(&dstEvaluator.coeffRef(0), size);
438
    const Index alignedEnd = alignedStart + ((size-alignedStart)/packetSize)*packetSize;
439
    const Index alignedEnd = alignedStart + ((size-alignedStart)/packetSize)*packetSize;
439
440
440
    unaligned_copy_using_evaluator_impl<dstIsAligned!=0>::run(src,dst.const_cast_derived(),0,alignedStart);
441
    unaligned_copy_using_evaluator_impl<dstIsAligned!=0>::run(srcEvaluator, dstEvaluator, 0, alignedStart);
441
442
442
    for(Index index = alignedStart; index < alignedEnd; index += packetSize)
443
    for(Index index = alignedStart; index < alignedEnd; index += packetSize)
443
    {
444
    {
444
      dstEvaluator.template writePacket<dstAlignment>(index, srcEvaluator.template packet<srcAlignment>(index));
445
      dstEvaluator.template writePacket<dstAlignment>(index, srcEvaluator.template packet<srcAlignment>(index));
445
    }
446
    }
446
447
447
    unaligned_copy_using_evaluator_impl<>::run(src,dst.const_cast_derived(),alignedEnd,size);
448
    unaligned_copy_using_evaluator_impl<>::run(srcEvaluator, dstEvaluator, alignedEnd, size);
448
  }
449
  }
449
};
450
};
450
451
451
template<typename DstXprType, typename SrcXprType>
452
template<typename DstXprType, typename SrcXprType>
452
struct copy_using_evaluator_impl<DstXprType, SrcXprType, LinearVectorizedTraversal, CompleteUnrolling>
453
struct copy_using_evaluator_impl<DstXprType, SrcXprType, LinearVectorizedTraversal, CompleteUnrolling>
453
{
454
{
454
  typedef typename DstXprType::Index Index;
455
  typedef typename DstXprType::Index Index;
455
  EIGEN_STRONG_INLINE static void run(const DstXprType &dst, const SrcXprType &src)
456
  EIGEN_STRONG_INLINE static void run(const DstXprType &dst, const SrcXprType &src)
(-)a/test/evaluators.cpp (-15 / +18 lines)
Lines 44-74 void test_evaluators() Link Here
44
44
45
  VERIFY_IS_APPROX_EVALUATOR(w, RowVector2d::Zero());
45
  VERIFY_IS_APPROX_EVALUATOR(w, RowVector2d::Zero());
46
46
47
  VERIFY_IS_APPROX_EVALUATOR(w, RowVector2d::Constant(3));
47
  VERIFY_IS_APPROX_EVALUATOR(w, RowVector2d::Constant(3));
48
  
48
  
49
  // mix CwiseNullaryOp and transpose
49
  // mix CwiseNullaryOp and transpose
50
  VERIFY_IS_APPROX_EVALUATOR(w, Vector2d::Zero().transpose());
50
  VERIFY_IS_APPROX_EVALUATOR(w, Vector2d::Zero().transpose());
51
51
52
  {
52
  // This fails because there is no evaluator for GeneralProduct, which is the expression
53
    int s = internal::random<int>(1,100);
53
  // type produced by operator* acting on matrices.
54
    MatrixXf a(s,s), b(s,s), c(s,s), d(s,s);
54
  //
55
    a.setRandom();
55
  // {
56
    b.setRandom();
56
  //   int s = internal::random<int>(1,100);
57
    c.setRandom();
57
  //   MatrixXf a(s,s), b(s,s), c(s,s), d(s,s);
58
    d.setRandom();
58
  //   a.setRandom();
59
    VERIFY_IS_APPROX_EVALUATOR(d, (a + b));
59
  //   b.setRandom();
60
    VERIFY_IS_APPROX_EVALUATOR(d, (a + b).transpose());
60
  //   c.setRandom();
61
    VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b).transpose(), (a*b).transpose());
61
  //   d.setRandom();
62
    VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b) + prod(b,c), a*b + b*c);
62
  //   VERIFY_IS_APPROX_EVALUATOR(d, (a + b));
63
    
63
  //   VERIFY_IS_APPROX_EVALUATOR(d, (a + b).transpose());
64
//     copy_using_evaluator(d, a.transpose() + (a.transpose() * (b+b)));
64
  //   VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b).transpose(), (a*b).transpose());
65
//     cout << d << endl;
65
  //   VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b) + prod(b,c), a*b + b*c);
66
  }
66
  //   
67
  //   copy_using_evaluator(d, a.transpose() + (a.transpose() * (b+b)));
68
  //   cout << d << endl;
69
  // }
67
  
70
  
68
  // this does not work because Random is eval-before-nested: 
71
  // this does not work because Random is eval-before-nested: 
69
  // copy_using_evaluator(w, Vector2d::Random().transpose());
72
  // copy_using_evaluator(w, Vector2d::Random().transpose());
70
  
73
  
71
  // test CwiseUnaryOp
74
  // test CwiseUnaryOp
72
  VERIFY_IS_APPROX_EVALUATOR(v2, 3 * v);
75
  VERIFY_IS_APPROX_EVALUATOR(v2, 3 * v);
73
  VERIFY_IS_APPROX_EVALUATOR(w, (3 * v).transpose());
76
  VERIFY_IS_APPROX_EVALUATOR(w, (3 * v).transpose());
74
  VERIFY_IS_APPROX_EVALUATOR(b, (a + 3).transpose());
77
  VERIFY_IS_APPROX_EVALUATOR(b, (a + 3).transpose());
(-)a/test/main.h (-1 / +3 lines)
Lines 251-267 inline bool test_isApprox(const long dou Link Here
251
inline bool test_isMuchSmallerThan(const long double& a, const long double& b)
251
inline bool test_isMuchSmallerThan(const long double& a, const long double& b)
252
{ return internal::isMuchSmallerThan(a, b, test_precision<long double>()); }
252
{ return internal::isMuchSmallerThan(a, b, test_precision<long double>()); }
253
inline bool test_isApproxOrLessThan(const long double& a, const long double& b)
253
inline bool test_isApproxOrLessThan(const long double& a, const long double& b)
254
{ return internal::isApproxOrLessThan(a, b, test_precision<long double>()); }
254
{ return internal::isApproxOrLessThan(a, b, test_precision<long double>()); }
255
255
256
template<typename Type1, typename Type2>
256
template<typename Type1, typename Type2>
257
inline bool test_isApprox(const Type1& a, const Type2& b)
257
inline bool test_isApprox(const Type1& a, const Type2& b)
258
{
258
{
259
  return a.isApprox(b, test_precision<typename Type1::Scalar>());
259
  typename internal::eval<Type1>::type a_eval(a);
260
  typename internal::eval<Type2>::type b_eval(b);
261
  return a_eval.isApprox(b_eval, test_precision<typename Type1::Scalar>());
260
}
262
}
261
263
262
// The idea behind this function is to compare the two scalars a and b where
264
// The idea behind this function is to compare the two scalars a and b where
263
// the scalar ref is a hint about the expected order of magnitude of a and b.
265
// the scalar ref is a hint about the expected order of magnitude of a and b.
264
// Therefore, if for some reason a and b are very small compared to ref,
266
// Therefore, if for some reason a and b are very small compared to ref,
265
// we won't issue a false negative.
267
// we won't issue a false negative.
266
// This test could be: abs(a-b) <= eps * ref
268
// This test could be: abs(a-b) <= eps * ref
267
// However, it seems that simply comparing a+ref and b+ref is more sensitive to true error.
269
// However, it seems that simply comparing a+ref and b+ref is more sensitive to true error.

Return to bug 99