[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Toon-members] TooN TooN.h internal/operators.hh
From: |
Edward Rosten |
Subject: |
[Toon-members] TooN TooN.h internal/operators.hh |
Date: |
Mon, 18 Jan 2010 12:15:32 +0000 |
CVSROOT: /cvsroot/toon
Module name: TooN
Changes by: Edward Rosten <edrosten> 10/01/18 12:15:32
Modified files:
. : TooN.h
internal : operators.hh
Log message:
Better size decuction, so that a Vector<Resizable> is never generated.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/TooN.h?cvsroot=toon&r1=1.58&r2=1.59
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/operators.hh?cvsroot=toon&r1=1.46&r2=1.47
Patches:
Index: TooN.h
===================================================================
RCS file: /cvsroot/toon/TooN/TooN.h,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -b -r1.58 -r1.59
--- TooN.h 11 Jan 2010 14:59:12 -0000 1.58
+++ TooN.h 18 Jan 2010 12:15:31 -0000 1.59
@@ -252,6 +252,29 @@
static const int Dynamic = -1;
static const int Resizable = -0x7fffffff;
+ namespace Internal
+ {
+ template<int i, int j> struct SimpleSizer{static const int
size=i;};
+ template<int i> struct SimpleSizer<Dynamic, i>{static const int
size=i;};
+ template<int i> struct SimpleSizer<i, Dynamic>{static const int
size=i;};
+ template<> struct SimpleSizer<Dynamic, Dynamic> {static
const int size=-1;};
+
+ template<int i> struct IsStatic
+ {
+ static const bool is = (i!=Dynamic && i != Resizable);
+ };
+
+ //Choose an output size, given a pair of input sizes. Be static
if possible.
+ template<int i, int j=i> struct Sizer{
+ static const int size=SimpleSizer<Sizer<i>::size,
Sizer<j>::size>::size;
+ };
+
+ //Choose an output size, given an input size. Be static if
possible.
+ //Otherwise be dynamic. Never generate a resizable vector.
+ template<int i> struct Sizer<i,i>{
+ static const int size = IsStatic<i>::is?i:Dynamic;
+ };
+ }
///All TooN classes default to using this precision for computations
and storage.
typedef double DefaultPrecision;
Index: internal/operators.hh
===================================================================
RCS file: /cvsroot/toon/TooN/internal/operators.hh,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- internal/operators.hh 11 Jan 2010 14:59:12 -0000 1.46
+++ internal/operators.hh 18 Jan 2010 12:15:31 -0000 1.47
@@ -86,12 +86,6 @@
template<class P1, class P2> struct Return { typedef typename
DivideType<P1,P2>::type Type;};
};
-
- //Output size, given input size. Be static if possible.
- template<int i, int j> struct Sizer{static const int size=i;};
- template<int i> struct Sizer<-1, i>{static const int size=i;};
- template<int i> struct Sizer<i, -1>{static const int size=i;};
- template<> struct Sizer<-1, -1> {static const int size=-1;};
};
//////////////////////////////////////////////////////////////////////////////////////////////
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Toon-members] TooN TooN.h internal/operators.hh,
Edward Rosten <=