diff options
-rw-r--r-- | scilab2c/src/elementaryFunctions/includes/pow.h | 8 | ||||
-rw-r--r-- | scilab2c/src/elementaryFunctions/pow/cpowa.c | 9 | ||||
-rw-r--r-- | scilab2c/src/elementaryFunctions/pow/dpowa.c | 9 | ||||
-rw-r--r-- | scilab2c/src/elementaryFunctions/pow/spowa.c | 9 | ||||
-rw-r--r-- | scilab2c/src/elementaryFunctions/pow/testDoublePow.c | 18 | ||||
-rw-r--r-- | scilab2c/src/elementaryFunctions/pow/testFloatPow.c | 17 | ||||
-rw-r--r-- | scilab2c/src/elementaryFunctions/pow/zpowa.c | 9 |
7 files changed, 56 insertions, 23 deletions
diff --git a/scilab2c/src/elementaryFunctions/includes/pow.h b/scilab2c/src/elementaryFunctions/includes/pow.h index 26206c9b..ea32d962 100644 --- a/scilab2c/src/elementaryFunctions/includes/pow.h +++ b/scilab2c/src/elementaryFunctions/includes/pow.h @@ -23,12 +23,12 @@ floatComplex cpows(floatComplex value, floatComplex expand); doubleComplex zpows(doubleComplex value, doubleComplex expand); -void spowa(float *value, int size, float expand, float *out); +void spowa(float *value, int size, float* expand, float *out); -void dpowa(double *value, int size, double expand, double *out); +void dpowa(double *value, int size, double* expand, double *out); -void cpowa(floatComplex *value, int size, floatComplex expand, floatComplex *out); +void cpowa(floatComplex *value, int size, floatComplex* expand, floatComplex *out); -void zpowa(doubleComplex *value, int size, doubleComplex expand, doubleComplex *out); +void zpowa(doubleComplex *value, int size, doubleComplex* expand, doubleComplex *out); #endif /* !__POW_H__ */ diff --git a/scilab2c/src/elementaryFunctions/pow/cpowa.c b/scilab2c/src/elementaryFunctions/pow/cpowa.c index 1c02b5d0..c5a87327 100644 --- a/scilab2c/src/elementaryFunctions/pow/cpowa.c +++ b/scilab2c/src/elementaryFunctions/pow/cpowa.c @@ -12,9 +12,14 @@ #include "pow.h" -void cpowa(floatComplex* x, int size, floatComplex power, floatComplex *out) { +void cpowa(floatComplex* x, int size, floatComplex* power, floatComplex *out) { + /* + Computes Scilab x.^power + Computes power element by element + x and power must have same size + */ int i = 0; for (i = 0; i < size; ++i) { - out[i] = cpows(x[i], power); + out[i] = cpows(x[i], power[i]); } } diff --git a/scilab2c/src/elementaryFunctions/pow/dpowa.c b/scilab2c/src/elementaryFunctions/pow/dpowa.c index 454d38de..64e0ca9e 100644 --- a/scilab2c/src/elementaryFunctions/pow/dpowa.c +++ b/scilab2c/src/elementaryFunctions/pow/dpowa.c @@ -12,9 +12,14 @@ #include "pow.h" -void dpowa(double* x, int size, double power, double *out) { +void dpowa(double* x, int size, double* power, double *out) { + /* + Computes Scilab x.^power + Computes power element by element + x and power must have same size + */ int i = 0; for (i = 0; i < size; ++i) { - out[i] = dpows(x[i], power); + out[i] = dpows(x[i], power[i]); } } diff --git a/scilab2c/src/elementaryFunctions/pow/spowa.c b/scilab2c/src/elementaryFunctions/pow/spowa.c index e731b025..3ff43ecf 100644 --- a/scilab2c/src/elementaryFunctions/pow/spowa.c +++ b/scilab2c/src/elementaryFunctions/pow/spowa.c @@ -12,9 +12,14 @@ #include "pow.h" -void spowa(float* x, int size, float y, float *out) { +void spowa(float* x, int size, float* y, float *out) { + /* + Computes Scilab x.^power + Computes power element by element + x and power must have same size + */ int i = 0; for (i = 0; i < size; ++i) { - out[i] = spows(x[i], y); + out[i] = spows(x[i], y[i]); } } diff --git a/scilab2c/src/elementaryFunctions/pow/testDoublePow.c b/scilab2c/src/elementaryFunctions/pow/testDoublePow.c index 4149b300..57707f2a 100644 --- a/scilab2c/src/elementaryFunctions/pow/testDoublePow.c +++ b/scilab2c/src/elementaryFunctions/pow/testDoublePow.c @@ -463,14 +463,20 @@ void zpowsTest(void) { void dpowaTest(void) { double in1[]=SOURCE; - double in2=EXPAND; + double in2[200]; + double ZERO[200]={0}; + double ONE[200]; double res[]=RESULT; double out1[200],out2[200],out3[200]; int i; - + + for (i=0;i<200;i++) { + in2[i]=EXPAND; + ONE[i]=1; + } dpowa(in1,200,in2,out1); - dpowa(in1,200,0,out2); - dpowa(in1,200,1,out3); + dpowa(in1,200,ZERO,out2); + dpowa(in1,200,ONE,out3); for (i=0;i<200;i++){ assert(( (fabs(out1[i]-res[i]))/(fabs(out1[i])) )<1e-15); assert(( (fabs(out2[i]-1))/(fabs(out2[i])) )<1e-16); @@ -481,13 +487,13 @@ void dpowaTest(void) { void zpowaTest(void) { double in1R[]=ZSOURCER; double in1I[]=ZSOURCEI; - doubleComplex in2=ZEXPAND; + doubleComplex in2[200]; double resR[]=ZRESULTR; double resI[]=ZRESULTI; doubleComplex *in1,out[200]; int i; - + for (i=0;i<200;i++) in2[i]=ZEXPAND; in1=DoubleComplexMatrix(in1R,in1I,200); zpowa(in1,200,in2,out); diff --git a/scilab2c/src/elementaryFunctions/pow/testFloatPow.c b/scilab2c/src/elementaryFunctions/pow/testFloatPow.c index 42931f8e..52ce4542 100644 --- a/scilab2c/src/elementaryFunctions/pow/testFloatPow.c +++ b/scilab2c/src/elementaryFunctions/pow/testFloatPow.c @@ -464,14 +464,20 @@ void cpowsTest(void) { void spowaTest(void) { float in1[]=SOURCE; - float in2=EXPAND; + float in2[200]; + float ZERO[200]={0}; + float ONE[200]; float res[]=RESULT; float out1[200],out2[200],out3[200]; int i; + for (i=0;i<200;i++) { + in2[i]=EXPAND; + ONE[i]=1; + } spowa(in1,200,in2,out1); - spowa(in1,200,0,out2); - spowa(in1,200,1,out3); + spowa(in1,200,ZERO,out2); + spowa(in1,200,ONE,out3); for (i=0;i<200;i++){ assert(( (fabs(out1[i]-res[i]))/(fabs(out1[i])) )<1e-6); assert(( (fabs(out2[i]-1))/(fabs(out2[i])) )<1e-16); @@ -482,12 +488,13 @@ void spowaTest(void) { void cpowaTest(void) { float in1R[]=CSOURCER; float in1I[]=CSOURCEI; - floatComplex in2=CEXPAND; + floatComplex in2[200]; float resR[]=CRESULTR; float resI[]=CRESULTI; floatComplex *in1, out[200]; int i; - + + for (i=0;i<200;i++) in2[i]=CEXPAND; in1=FloatComplexMatrix(in1R,in1I,200); cpowa(in1,200,in2,out); diff --git a/scilab2c/src/elementaryFunctions/pow/zpowa.c b/scilab2c/src/elementaryFunctions/pow/zpowa.c index afde3f49..ace264de 100644 --- a/scilab2c/src/elementaryFunctions/pow/zpowa.c +++ b/scilab2c/src/elementaryFunctions/pow/zpowa.c @@ -12,9 +12,14 @@ #include "pow.h" -void zpowa(doubleComplex* x, int size, doubleComplex y, doubleComplex *out) { +void zpowa(doubleComplex* x, int size, doubleComplex* y, doubleComplex *out) { + /* + Computes Scilab x.^power + Computes power element by element + x and power must have same size + */ int i = 0; for (i = 0; i < size; ++i) { - out[i] = zpows(x[i], y); + out[i] = zpows(x[i], y[i]); } } |