summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2013-02-04 23:51:37 -0500
committerErik Schnetter <schnetter@gmail.com>2013-02-04 23:51:37 -0500
commit43d26c25c6bbdefcca43278de42bf0ae524adb72 (patch)
tree0843fe20e528a770520f6d1aae0b8e33cf0bf8b3
parent82803ea5e87bf83a02f26e0e7aa73bdb503f73d9 (diff)
downloadvecmathlib-43d26c25c6bbdefcca43278de42bf0ae524adb72.zip
vecmathlib-43d26c25c6bbdefcca43278de42bf0ae524adb72.tar.gz
Provide intvec_t::iota()
-rw-r--r--vec_double.h1
-rw-r--r--vec_double_sse2.h1
-rw-r--r--vec_float.h1
-rw-r--r--vec_float_avx.h1
-rw-r--r--vec_float_sse2.h1
-rw-r--r--vec_pseudo.h6
6 files changed, 11 insertions, 0 deletions
diff --git a/vec_double.h b/vec_double.h
index 8559e28..2392756 100644
--- a/vec_double.h
+++ b/vec_double.h
@@ -117,6 +117,7 @@ namespace vecmathlib {
//intvec(vector_t x): v(x) {}
intvec(int_t a): v(a) {}
intvec(int_t const* as): v(as[0]) {}
+ static intvec iota() { return intvec(I(0)); }
operator ivector_t() const { return v; }
int_t operator[](int n) const { return v; }
diff --git a/vec_double_sse2.h b/vec_double_sse2.h
index fd82ec0..40c789e 100644
--- a/vec_double_sse2.h
+++ b/vec_double_sse2.h
@@ -157,6 +157,7 @@ namespace vecmathlib {
intvec(ivector_t x): v(x) {}
intvec(int_t a): v(_mm_set1_epi64x(a)) {}
intvec(int_t const* as): v(_mm_set_epi64x(as[1], as[0])) {}
+ static intvec iota() { return _mm_set_epi64x(1, 0); }
operator ivector_t() const { return v; }
int_t operator[](int n) const { return ((int_t const*)&v)[n]; }
diff --git a/vec_float.h b/vec_float.h
index 5457ec7..5424b05 100644
--- a/vec_float.h
+++ b/vec_float.h
@@ -117,6 +117,7 @@ namespace vecmathlib {
//intvec(vector_t x): v(x) {}
intvec(int_t a): v(a) {}
intvec(int_t const* as): v(as[0]) {}
+ static intvec iota() { return intvec(I(0)); }
operator ivector_t() const { return v; }
int_t operator[](int n) const { return v; }
diff --git a/vec_float_avx.h b/vec_float_avx.h
index b7f6150..e015255 100644
--- a/vec_float_avx.h
+++ b/vec_float_avx.h
@@ -159,6 +159,7 @@ namespace vecmathlib {
intvec(int_t a): v(_mm256_set1_epi32(a)) {}
intvec(int_t const* as): v(_mm256_set_epi32(as[7], as[6], as[5], as[4],
as[3], as[2], as[1], as[0])) {}
+ static intvec iota() { return _mm256_set_epi32(7, 6, 5, 4, 3, 2, 1, 0); }
operator ivector_t() const { return v; }
int_t operator[](int n) const
diff --git a/vec_float_sse2.h b/vec_float_sse2.h
index f105cc5..38c42b3 100644
--- a/vec_float_sse2.h
+++ b/vec_float_sse2.h
@@ -160,6 +160,7 @@ namespace vecmathlib {
intvec(ivector_t x): v(x) {}
intvec(int_t a): v(_mm_set1_epi32(a)) {}
intvec(int_t const* as): v(_mm_set_epi32(as[3], as[2], as[1], as[0])) {}
+ static intvec iota() { return _mm_set_epi32(3, 2, 1, 0); }
operator ivector_t() const { return v; }
int_t operator[](int n) const
diff --git a/vec_pseudo.h b/vec_pseudo.h
index 2df14f0..caff0f7 100644
--- a/vec_pseudo.h
+++ b/vec_pseudo.h
@@ -149,6 +149,12 @@ namespace vecmathlib {
// intpseudovec& operator=(intpseudovec const& x) { return v=x.v, *this; }
intpseudovec(int_t a) { for (int d=0; d<size; ++d) v[d]=a; }
intpseudovec(int_t const* as) { for (int d=0; d<size; ++d) v[d]=as[d]; }
+ static intpseudovec iota()
+ {
+ intpseudovec res;
+ for (int d=0; d<size; ++d) res.v[d]=d;
+ return res;
+ }
int_t operator[](int n) const { return v[n]; }
intpseudovec& set_elt(int n, int_t a) { return v[n]=a, *this; }
OpenPOWER on IntegriCloud