make Dumber and vector_simple even

This commit is contained in:
Connor Olding 2015-12-06 10:07:31 -08:00
parent 398a72ef13
commit f414ccc404
3 changed files with 53 additions and 70 deletions

View File

@ -71,7 +71,7 @@ struct mugi4 {
v2df sum = in + sumback1;
v2df pre = -fd.p0*sum;
v2df temp = tanh2<v2df>(pre/VT2);
v2df temp = tanh2<v2df>(pre/v2df(VT2));
s1.process<v2df>(fd, temp);
s2.process<v2df>(fd, s1.dout);
s3.process<v2df>(fd, s2.dout);

View File

@ -18,59 +18,65 @@ struct DumberBase {
DumberBase(const DumberBase &x)
{ v = x.v; }
inline DumberBase&
operator=(const DumberBase& v2) {
v = v2.v;
return *this;
}
friend inline DumberBase
operator-(const DumberBase &a)
{ return -a.v; }
inline DumberBase
operator-()
{ return -v; }
friend inline DumberBase
operator+(const DumberBase &a, const DumberBase &b)
{ return a.v + b.v; }
inline DumberBase
operator+(const DumberBase &v2)
{ return v + v2.v; }
friend inline DumberBase
operator-(const DumberBase &a, const DumberBase &b)
{ return a.v - b.v; }
inline DumberBase
operator-(const DumberBase &v2)
{ return v - v2.v; }
friend inline DumberBase
operator*(const DumberBase &a, const DumberBase &b)
{ return a.v*b.v; }
inline DumberBase
operator*(const DumberBase &v2)
{ return v*v2.v; }
friend inline DumberBase
operator/(const DumberBase &a, const DumberBase &b)
{ return a.v/b.v; }
inline DumberBase
operator/(const DumberBase &v2)
{ return v/v2.v; }
inline DumberBase &
operator+=(const DumberBase &a)
{ v += a.v; return *this; }
inline DumberBase&
operator+=(const DumberBase &v2)
{
v = v + v2.v;
return *this;
}
inline DumberBase &
operator-=(const DumberBase &a)
{ v -= a.v; return *this; }
inline DumberBase&
operator-=(const DumberBase &v2)
{
v = v - v2.v;
return *this;
}
inline DumberBase &
operator*=(const DumberBase &a)
{ v *= a.v; return *this; }
inline DumberBase&
operator*=(const DumberBase &v2)
{
v = v*v2.v;
return *this;
}
inline DumberBase &
operator/=(const DumberBase &a)
{ v /= a.v; return *this; }
inline DumberBase&
operator/=(const DumberBase &v2)
{
v = v/v2.v;
return *this;
}
friend inline DumberBase
operator&(const DumberBase &a, const DumberBase &b)
{ return a.v & b.v; }
friend inline DumberBase
operator|(const DumberBase &a, const DumberBase &b)
{ return a.v | b.v; }
friend inline DumberBase
operator^(const DumberBase &a, const DumberBase &b)
{ return a.v ^ b.v; }
friend inline DumberBase
operator<(const DumberBase &a, const DumberBase &b)
{ return a.v < b.v; }
friend inline DumberBase
operator>(const DumberBase &a, const DumberBase &b)
{ return a.v > b.v; }
friend inline DumberBase
operator==(const DumberBase &a, const DumberBase &b)
{ return a.v == b.v; }
};
TEMPLATE

View File

@ -1,3 +1,4 @@
// mostly via http://charm.cs.uiuc.edu/doxygen/charm/SSE-Double_8h-source.shtml
#include <emmintrin.h>
typedef __m128d _v2df;
typedef __m64 _v2sf;
@ -39,22 +40,6 @@ struct v2df {
sqrt(const v2df &a)
{ v2df c; c.v = _mm_sqrt_pd(a.v); return c; }
friend inline v2df
operator+(double a, const v2df &b)
{ v2df c; c.v = _mm_add_pd(_mm_set1_pd(a),b.v); return c; }
friend inline v2df
operator-(double a, const v2df &b)
{ v2df c; c.v = _mm_sub_pd(_mm_set1_pd(a),b.v); return c; }
friend inline v2df
operator*(double a, const v2df &b)
{ v2df c; c.v = _mm_mul_pd(_mm_set1_pd(a),b.v); return c; }
friend inline v2df
operator/(double a, const v2df &b)
{ v2df c; c.v = _mm_div_pd(_mm_set1_pd(a),b.v); return c; }
inline v2df &
operator+=(const v2df &a)
{ v = _mm_add_pd(v,a.v); return *this; }
@ -100,15 +85,7 @@ struct v2df {
{ v2df c; c.v = _mm_cmpeq_pd(a.v,b.v); return c; }
friend inline v2df
operator<(const v2df &a, double b)
{ v2df c; c.v = _mm_cmplt_pd(a.v,_mm_set1_pd(b)); return c; }
friend inline v2df
operator>(const v2df &a, double b)
{ v2df c; c.v = _mm_cmpgt_pd(a.v,_mm_set1_pd(b)); return c; }
friend inline v2df
max(const v2df &a, v2df &b)
max(const v2df &a, const v2df &b)
{ v2df c; c.v = _mm_max_pd(a.v,b.v); return c; }
inline double &