diff options
Diffstat (limited to '2.3-1/src/c/statisticsFunctions/median')
-rw-r--r-- | 2.3-1/src/c/statisticsFunctions/median/dmediana.c | 16 | ||||
-rw-r--r-- | 2.3-1/src/c/statisticsFunctions/median/smediana.c | 16 | ||||
-rw-r--r-- | 2.3-1/src/c/statisticsFunctions/median/u16mediana.c | 16 | ||||
-rw-r--r-- | 2.3-1/src/c/statisticsFunctions/median/zmediana.c | 16 |
4 files changed, 36 insertions, 28 deletions
diff --git a/2.3-1/src/c/statisticsFunctions/median/dmediana.c b/2.3-1/src/c/statisticsFunctions/median/dmediana.c index cb2463c5..8b37fd16 100644 --- a/2.3-1/src/c/statisticsFunctions/median/dmediana.c +++ b/2.3-1/src/c/statisticsFunctions/median/dmediana.c @@ -17,7 +17,9 @@ double dmediana(double *in, int size) { - double a; double fin; + double a; double fin; double in_copy[size]; +for(int i=0; i< size; i++) + in_copy[i]= in[i]; for (int i = 0; i < size; ++i) @@ -28,15 +30,15 @@ double dmediana(double *in, int size) { - if (in[i] > in[j]) + if (in_copy[i] > in_copy[j]) { - a = in[i]; + a = in_copy[i]; - in[i] = in[j]; + in_copy[i] = in_copy[j]; - in[j] = a; + in_copy[j] = a; } @@ -47,11 +49,11 @@ double dmediana(double *in, int size) if(size%2 ==0) { - fin= (in[size/2]+ in[(size/2)-1])/2; + fin= (in_copy[size/2]+ in_copy[(size/2)-1])/2; } else { - fin= in[(size-1)/2]; + fin= in_copy[(size-1)/2]; } return fin; diff --git a/2.3-1/src/c/statisticsFunctions/median/smediana.c b/2.3-1/src/c/statisticsFunctions/median/smediana.c index 9e86b77e..0d427e10 100644 --- a/2.3-1/src/c/statisticsFunctions/median/smediana.c +++ b/2.3-1/src/c/statisticsFunctions/median/smediana.c @@ -17,8 +17,10 @@ float smediana(float *in, int size) { - float a; float fin; + float a; float fin; float in_copy[size]; +for(int i=0; i< size; i++) + in_copy[i]= in[i]; for (int i = 0; i < size; ++i) @@ -28,15 +30,15 @@ float smediana(float *in, int size) { - if (in[i] > in[j]) + if (in_copy[i] > in_copy[j]) { - a = in[i]; + a = in_copy[i]; - in[i] = in[j]; + in_copy[i] = in_copy[j]; - in[j] = a; + in_copy[j] = a; } @@ -46,11 +48,11 @@ float smediana(float *in, int size) if(size%2 ==0) { - fin= (in[size/2]+ in[(size/2)-1])/2; + fin= (in_copy[size/2]+ in_copy[(size/2)-1])/2; } else { - fin= in[(size-1)/2]; + fin= in_copy[(size-1)/2]; } return fin; diff --git a/2.3-1/src/c/statisticsFunctions/median/u16mediana.c b/2.3-1/src/c/statisticsFunctions/median/u16mediana.c index b45c5302..85cfedce 100644 --- a/2.3-1/src/c/statisticsFunctions/median/u16mediana.c +++ b/2.3-1/src/c/statisticsFunctions/median/u16mediana.c @@ -17,8 +17,10 @@ uint16 u16mediana(uint16 *in, int size) { - uint16 a; uint16 fin; + uint16 a; uint16 fin; uint16 in_copy[size]; +for(int i=0; i< size; i++) + in_copy[i]= in[i]; for (int i = 0; i < size; ++i) @@ -28,15 +30,15 @@ uint16 u16mediana(uint16 *in, int size) { - if (in[i] > in[j]) + if (in_copy[i] > in_copy[j]) { - a = in[i]; + a = in_copy[i]; - in[i] = in[j]; + in_copy[i] = in_copy[j]; - in[j] = a; + in_copy[j] = a; } @@ -46,11 +48,11 @@ uint16 u16mediana(uint16 *in, int size) if(size%2 ==0) { - fin= (in[size/2]+ in[(size/2)-1])/2; + fin= (in_copy[size/2]+ in_copy[(size/2)-1])/2; } else { - fin= in[(size-1)/2]; + fin= in_copy[(size-1)/2]; } return fin; diff --git a/2.3-1/src/c/statisticsFunctions/median/zmediana.c b/2.3-1/src/c/statisticsFunctions/median/zmediana.c index 32726e77..36804562 100644 --- a/2.3-1/src/c/statisticsFunctions/median/zmediana.c +++ b/2.3-1/src/c/statisticsFunctions/median/zmediana.c @@ -21,8 +21,10 @@ doubleComplex zmediana(doubleComplex *in, int size) { - doubleComplex a; doubleComplex fin; doubleComplex middle; + doubleComplex a; doubleComplex fin; doubleComplex middle; doubleComplex in_copy[size]; +for(int i=0; i< size; i++) + in_copy[i]= in[i]; for (int i = 0; i < size; ++i) @@ -32,15 +34,15 @@ doubleComplex zmediana(doubleComplex *in, int size) { - if (zabss(in[i]) > zabss(in[j])) + if (zabss(in_copy[i]) > zabss(in_copy[j])) { - a = in[i]; + a = in_copy[i]; - in[i] = in[j]; + in_copy[i] = in_copy[j]; - in[j] = a; + in_copy[j] = a; } @@ -52,12 +54,12 @@ doubleComplex zmediana(doubleComplex *in, int size) if(size%2 ==0) { - middle= zadds(in[size/2], in[(size/2)-1]); + middle= zadds(in_copy[size/2], in_copy[(size/2)-1]); fin= zrdivs(middle, DoubleComplex(2,0)); } else { - fin= in[(size-1)/2]; + fin= in_copy[(size-1)/2]; } return fin; |