From 656919619fe4ce39776571d280fc402edeef795a Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Mon, 1 Oct 2007 06:23:05 +0000 Subject: [PATCH] - add copyright line for Michael Olbrich - some meta unrolling improvements --- src/internal/Object.h | 31 +++++++++++++++++-------------- src/internal/Util.h | 2 ++ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/internal/Object.h b/src/internal/Object.h index dd92e2915..bbd6458de 100644 --- a/src/internal/Object.h +++ b/src/internal/Object.h @@ -2,6 +2,7 @@ // for linear algebra. Eigen itself is part of the KDE project. // // Copyright (C) 2006-2007 Benoit Jacob +// Copyright (C) 2007 Michael Olbrich // // Eigen is free software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the Free Software @@ -28,16 +29,16 @@ #include "Util.h" -template class EiLoop +template class EiLoop { - static const int col = (Size-1) / Rows; - static const int row = (Size-1) % Rows; + static const int col = (UnrollCount-1) / Rows; + static const int row = (UnrollCount-1) % Rows; public: template static void copy(Derived1 &dst, const Derived2 &src) { - EiLoop::copy(dst, src); + EiLoop::copy(dst, src); dst.write(row, col) = src.read(row, col); } }; @@ -56,21 +57,23 @@ template class EiLoop<0, Rows> template class EiObject { static const int RowsAtCompileTime = Derived::RowsAtCompileTime, - ColsAtCompileTime = Derived::ColsAtCompileTime, - SizeAtCompileTime = RowsAtCompileTime*ColsAtCompileTime > 0 ? - RowsAtCompileTime*ColsAtCompileTime : 0; + ColsAtCompileTime = Derived::ColsAtCompileTime; + static const bool HasDynamicSize = RowsAtCompileTime != EiDynamic + && ColsAtCompileTime != EiDynamic; + static const int UnrollCount = HasDynamicSize ? + RowsAtCompileTime * ColsAtCompileTime : 0; template void _copy_helper(const EiObject& other) { - if ((RowsAtCompileTime != EiDynamic) && - (ColsAtCompileTime != EiDynamic) && - (SizeAtCompileTime <= 25)) - EiLoop::copy(*this, other); + if(HasDynamicSize + && RowsAtCompileTime <= EI_LOOP_UNROLLING_LIMIT + && ColsAtCompileTime <= EI_LOOP_UNROLLING_LIMIT) + EiLoop::copy(*this, other); else - for(int i = 0; i < rows(); i++) - for(int j = 0; j < cols(); j++) - write(i, j) = other.read(i, j); + for(int i = 0; i < rows(); i++) + for(int j = 0; j < cols(); j++) + write(i, j) = other.read(i, j); } public: diff --git a/src/internal/Util.h b/src/internal/Util.h index d00a309e4..60413a8af 100644 --- a/src/internal/Util.h +++ b/src/internal/Util.h @@ -69,6 +69,8 @@ struct EiForwardDecl > const int EiDynamic = -1; +#define EI_LOOP_UNROLLING_LIMIT 8 + #define EI_UNUSED(x) (void)x #ifdef __GNUC__