From 861753b66e70b4071c5434cfe210e96dc4ab0f6d Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Sun, 24 May 2015 14:22:22 +0200 Subject: Container, Product and Num instances for CInt elements --- packages/base/src/C/vector-aux.c | 145 +++++++++++++++++++++++++++++++++++---- 1 file changed, 132 insertions(+), 13 deletions(-) (limited to 'packages/base/src/C') diff --git a/packages/base/src/C/vector-aux.c b/packages/base/src/C/vector-aux.c index 58afc49..b67275f 100644 --- a/packages/base/src/C/vector-aux.c +++ b/packages/base/src/C/vector-aux.c @@ -46,7 +46,7 @@ int sumF(KFVEC(x),FVEC(r)) { rp[0] = res; OK } - + int sumR(KDVEC(x),DVEC(r)) { DEBUGMSG("sumR"); REQUIRES(rn==1,BAD_SIZE); @@ -57,6 +57,15 @@ int sumR(KDVEC(x),DVEC(r)) { OK } +int sumI(KIVEC(x),IVEC(r)) { + REQUIRES(rn==1,BAD_SIZE); + int i; + int res = 0; + for (i = 0; i < xn; i++) res += xp[i]; + rp[0] = res; + OK +} + int sumQ(KQVEC(x),QVEC(r)) { DEBUGMSG("sumQ"); @@ -72,7 +81,7 @@ int sumQ(KQVEC(x),QVEC(r)) { rp[0] = res; OK } - + int sumC(KCVEC(x),CVEC(r)) { DEBUGMSG("sumC"); REQUIRES(rn==1,BAD_SIZE); @@ -98,7 +107,7 @@ int prodF(KFVEC(x),FVEC(r)) { rp[0] = res; OK } - + int prodR(KDVEC(x),DVEC(r)) { DEBUGMSG("prodR"); REQUIRES(rn==1,BAD_SIZE); @@ -109,6 +118,16 @@ int prodR(KDVEC(x),DVEC(r)) { OK } +int prodI(KIVEC(x),IVEC(r)) { + REQUIRES(rn==1,BAD_SIZE); + int i; + int res = 1; + for (i = 0; i < xn; i++) res *= xp[i]; + rp[0] = res; + OK +} + + int prodQ(KQVEC(x),QVEC(r)) { DEBUGMSG("prodQ"); @@ -126,7 +145,7 @@ int prodQ(KQVEC(x),QVEC(r)) { rp[0] = res; OK } - + int prodC(KCVEC(x),CVEC(r)) { DEBUGMSG("prodC"); REQUIRES(rn==1,BAD_SIZE); @@ -144,7 +163,7 @@ int prodC(KCVEC(x),CVEC(r)) { OK } - + double dnrm2_(integer*, const double*, integer*); double dasum_(integer*, const double*, integer*); @@ -189,8 +208,8 @@ double vector_min_index(KDVEC(x)) { } return r; } - -int toScalarR(int code, KDVEC(x), DVEC(r)) { + +int toScalarR(int code, KDVEC(x), DVEC(r)) { REQUIRES(rn==1,BAD_SIZE); DEBUGMSG("toScalarR"); double res; @@ -256,7 +275,7 @@ float vector_min_index_f(KFVEC(x)) { } -int toScalarF(int code, KFVEC(x), FVEC(r)) { +int toScalarF(int code, KFVEC(x), FVEC(r)) { REQUIRES(rn==1,BAD_SIZE); DEBUGMSG("toScalarF"); float res; @@ -275,10 +294,68 @@ int toScalarF(int code, KFVEC(x), FVEC(r)) { OK } +int vector_max_i(KIVEC(x)) { + int r = xp[0]; + int k; + for (k = 1; kr) { + r = xp[k]; + } + } + return r; +} + +int vector_min_i(KIVEC(x)) { + float r = xp[0]; + int k; + for (k = 1; kxp[r]) { + r = k; + } + } + return r; +} + +int vector_min_index_i(KIVEC(x)) { + int k, r = 0; + for (k = 1; k