diff options
Diffstat (limited to '2.3-1/src/c/statisticsFunctions/median/zmediana.c')
-rw-r--r-- | 2.3-1/src/c/statisticsFunctions/median/zmediana.c | 16 |
1 files changed, 9 insertions, 7 deletions
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; |