[Gridflow-cvs] [svn] commit: r6566 - in /trunk/src: numop1.cxx numop2.cxx

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Mon Feb 7 15:50:32 EST 2011


Author: matju
Date: Mon Feb  7 15:50:16 2011
New Revision: 6566

Log:
numop2 weight becomes numop1

Modified:
    trunk/src/numop1.cxx
    trunk/src/numop2.cxx

Modified: trunk/src/numop1.cxx
==============================================================================
--- trunk/src/numop1.cxx (original)
+++ trunk/src/numop1.cxx Mon Feb  7 15:50:16 2011
@@ -22,6 +22,16 @@
 #include "gridflow.hxx.fcs"
 #include <math.h>
 #include <complex>
+
+static inline uint64 weight(uint64 x) {uint64 k;
+	k=0x5555555555555555ULL; x = (x&k) + ((x>> 1)&k); //(2**64-1)/(2**2**0-1)
+	k=0x3333333333333333ULL; x = (x&k) + ((x>> 2)&k); //(2**64-1)/(2**2**1-1)
+	k=0x0f0f0f0f0f0f0f0fULL; x = (x&k) + ((x>> 4)&k); //(2**64-1)/(2**2**2-1)
+	k=0x00ff00ff00ff00ffULL; x = (x&k) + ((x>> 8)&k); //(2**64-1)/(2**2**3-1)
+	k=0x0000ffff0000ffffULL; x = (x&k) + ((x>>16)&k); //(2**64-1)/(2**2**4-1)
+	k=0x00000000ffffffffULL; x = (x&k) + ((x>>32)&k); //(2**64-1)/(2**2**5-1)
+	return x;
+}
 
 template <class T> class Op {
 public:
@@ -104,6 +114,8 @@
 DEF_OP(finite, finite(a))
 DEF_OP(isnan, isnan(a))
 
+DEF_OP(weight,weight((uint64)a & (0xFFFFFFFFFFFFFFFFULL>>(64-sizeof(T)*8))),0,false,false)
+
 #define NaN (0/0.f)
 
 #ifndef __WIN32__
@@ -128,6 +140,8 @@
 	DECL_OP_FLOAT(exp,  "exp"),   DECL_VOP_FLOAT(cx_exp,  "C.exp",  2),
 	DECL_OP_FLOAT(log,  "log"),   DECL_VOP_FLOAT(cx_log,  "C.log",  2),
 	DECL_OP_FLOAT(log,  "ln"),    DECL_VOP_FLOAT(cx_log,  "C.ln",   2),
+// moved from numop2 at 9.12
+	DECL_OP_NOFOLD_NOFLOAT(weight,"weight",OP_COMM),
 // introduced at 9.12
 	DECL_OP(unary_minus, "unary-"),
 	DECL_OP(unary_plus,  "unary+"),

Modified: trunk/src/numop2.cxx
==============================================================================
--- trunk/src/numop2.cxx (original)
+++ trunk/src/numop2.cxx Mon Feb  7 15:50:16 2011
@@ -27,16 +27,6 @@
 #include <complex>
 #include <assert.h>
 //using namespace std;
-
-static inline uint64 weight(uint64 x) {uint64 k;
-	k=0x5555555555555555ULL; x = (x&k) + ((x>> 1)&k); //(2**64-1)/(2**2**0-1)
-	k=0x3333333333333333ULL; x = (x&k) + ((x>> 2)&k); //(2**64-1)/(2**2**1-1)
-	k=0x0f0f0f0f0f0f0f0fULL; x = (x&k) + ((x>> 4)&k); //(2**64-1)/(2**2**2-1)
-	k=0x00ff00ff00ff00ffULL; x = (x&k) + ((x>> 8)&k); //(2**64-1)/(2**2**3-1)
-	k=0x0000ffff0000ffffULL; x = (x&k) + ((x>>16)&k); //(2**64-1)/(2**2**4-1)
-	k=0x00000000ffffffffULL; x = (x&k) + ((x>>32)&k); //(2**64-1)/(2**2**5-1)
-	return x;
-}
 
 #ifdef PASS1
 NumberType number_type_table[] = {
@@ -231,7 +221,6 @@
 DEF_OP(avg,         (a+b)/2, 0, false, false)
 DEF_OPF(hypot, floor(sqrt(a*a+b*b)), sqrt(a*a+b*b), 0, false, false)
 //DEF_OP(erf,"erf*", 0)
-DEF_OP(weight,weight((uint64)(a^b) & (0xFFFFFFFFFFFFFFFFULL>>(64-sizeof(T)*8))),0,false,false)
 #define BITS(T) (sizeof(T)*8)
 DEF_OP(rol,((uint64)a<<b)|((uint64)a>>(T)((-b)&(BITS(T)-1))),0,false,false)
 DEF_OP(ror,((uint64)a>>b)|((uint64)a<<(T)((-b)&(BITS(T)-1))),0,false,false)
@@ -356,7 +345,6 @@
 	DECL_OP(avg,   "avg",  OP_COMM),
 	DECL_OP(hypot, "hypot",OP_COMM), // huh, almost OP_ASSOC
 	//DECL_OP_NOFOLD(erf,"erf*", 0),
-	DECL_OP_NOFOLD_NOFLOAT(weight,"weight",OP_COMM),
 	DECL_OP_NOFOLD_NOFLOAT(rol,"rol",0),
 	DECL_OP_NOFOLD_NOFLOAT(ror,"ror",0),
 	DECL_OP_NOFOLD_FLOAT(atan2,"atan2", 0),



More information about the Gridflow-cvs mailing list