diff options
author | Brijeshcr | 2017-08-01 16:18:48 +0530 |
---|---|---|
committer | Brijeshcr | 2017-08-01 16:18:48 +0530 |
commit | e47a705e2a330fc6745ad406d04d63075df65492 (patch) | |
tree | 2cb948b94da3e1e6ccdbc726f00cc6d85e19affe /src/c/statisticsFunctions/moment | |
parent | 4dbbef28f20d66f4d838a991e74311c921227ea2 (diff) | |
download | Scilab2C_fossee_old-e47a705e2a330fc6745ad406d04d63075df65492.tar.gz Scilab2C_fossee_old-e47a705e2a330fc6745ad406d04d63075df65492.tar.bz2 Scilab2C_fossee_old-e47a705e2a330fc6745ad406d04d63075df65492.zip |
Added Moment
Diffstat (limited to 'src/c/statisticsFunctions/moment')
-rw-r--r-- | src/c/statisticsFunctions/moment/dmomentcola.c | 18 | ||||
-rw-r--r-- | src/c/statisticsFunctions/moment/dmomentrowa.c | 18 | ||||
-rw-r--r-- | src/c/statisticsFunctions/moment/dmoments.c | 17 | ||||
-rw-r--r-- | src/c/statisticsFunctions/moment/smomentcola.c | 18 | ||||
-rw-r--r-- | src/c/statisticsFunctions/moment/smomentrowa.c | 18 | ||||
-rw-r--r-- | src/c/statisticsFunctions/moment/smoments.c | 17 | ||||
-rw-r--r-- | src/c/statisticsFunctions/moment/zmomentcola.c | 20 | ||||
-rw-r--r-- | src/c/statisticsFunctions/moment/zmomentrowa.c | 20 | ||||
-rw-r--r-- | src/c/statisticsFunctions/moment/zmoments.c | 22 |
9 files changed, 168 insertions, 0 deletions
diff --git a/src/c/statisticsFunctions/moment/dmomentcola.c b/src/c/statisticsFunctions/moment/dmomentcola.c new file mode 100644 index 0000000..538328e --- /dev/null +++ b/src/c/statisticsFunctions/moment/dmomentcola.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "moment.h" + +void dmomentcola (double* inp, int row, int col, double ord, double* out) +{ + double vect[col]; + for(int i = 0; i < row ; i++) + { + for(int j = 0; j < col ; j++) + { + vect[j] = inp[i + j*row]; + } + out[i] = dmoments(vect, col, ord); + } + +} diff --git a/src/c/statisticsFunctions/moment/dmomentrowa.c b/src/c/statisticsFunctions/moment/dmomentrowa.c new file mode 100644 index 0000000..811aac3 --- /dev/null +++ b/src/c/statisticsFunctions/moment/dmomentrowa.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "moment.h" + +void dmomentrowa (double* inp, int row, int col, double ord, double* out) +{ + double vect[row]; + for(int i = 0; i < col ; i++) + { + for(int j = 0; j < row ; j++) + { + vect[j] = inp[j + i*row]; + } + out[i] = dmoments(vect, row, ord); + } + +} diff --git a/src/c/statisticsFunctions/moment/dmoments.c b/src/c/statisticsFunctions/moment/dmoments.c new file mode 100644 index 0000000..b9d8564 --- /dev/null +++ b/src/c/statisticsFunctions/moment/dmoments.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "moment.h" + + +double dmoments (double* inp, int size, double ord) +{ + double sum = 0; + + for(int i = 0; i < size; i++) + { + sum = sum + pow(inp[i], ord); + } + + return sum/size; +} diff --git a/src/c/statisticsFunctions/moment/smomentcola.c b/src/c/statisticsFunctions/moment/smomentcola.c new file mode 100644 index 0000000..4255782 --- /dev/null +++ b/src/c/statisticsFunctions/moment/smomentcola.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "moment.h" + +void smomentcola (float* inp, int row, int col, double ord, float* out) +{ + float vect[col]; + for(int i = 0; i < row ; i++) + { + for(int j = 0; j < col ; j++) + { + vect[j] = inp[i + j*row]; + } + out[i] = smoments(vect, col, ord); + } + +} diff --git a/src/c/statisticsFunctions/moment/smomentrowa.c b/src/c/statisticsFunctions/moment/smomentrowa.c new file mode 100644 index 0000000..574ebe7 --- /dev/null +++ b/src/c/statisticsFunctions/moment/smomentrowa.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "moment.h" + +void smomentrowa (float* inp, int row, int col, double ord, float* out) +{ + float vect[row]; + for(int i = 0; i < col ; i++) + { + for(int j = 0; j < row ; j++) + { + vect[j] = inp[j + i*row]; + } + out[i] = smoments(vect, row, ord); + } + +} diff --git a/src/c/statisticsFunctions/moment/smoments.c b/src/c/statisticsFunctions/moment/smoments.c new file mode 100644 index 0000000..aee9dc9 --- /dev/null +++ b/src/c/statisticsFunctions/moment/smoments.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "moment.h" + + +float smoments (float* inp, int size, double ord) +{ + float sum = 0; + + for(int i = 0; i < size; i++) + { + sum = sum + pow(inp[i], ord); + } + + return sum/size; +} diff --git a/src/c/statisticsFunctions/moment/zmomentcola.c b/src/c/statisticsFunctions/moment/zmomentcola.c new file mode 100644 index 0000000..2b3cebb --- /dev/null +++ b/src/c/statisticsFunctions/moment/zmomentcola.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "moment.h" +#include "doubleComplex.h" +#include "floatComplex.h" + +void zmomentcola (doubleComplex* inp, int row, int col, double ord, doubleComplex* out) +{ + double vect[col]; + for(int i = 0; i < row ; i++) + { + for(int j = 0; j < col ; j++) + { + vect[j] = inp[i + j*row]; + } + out[i] = zmoments(vect, col, ord); + } + +} diff --git a/src/c/statisticsFunctions/moment/zmomentrowa.c b/src/c/statisticsFunctions/moment/zmomentrowa.c new file mode 100644 index 0000000..e1e1b47 --- /dev/null +++ b/src/c/statisticsFunctions/moment/zmomentrowa.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "moment.h" +#include "doubleComplex.h" +#include "floatComplex.h" + +void zmomentrowa (doubleComplex* inp, int row, int col, double ord, doubleComplex* out) +{ + doubleComplex vect[row]; + for(int i = 0; i < col ; i++) + { + for(int j = 0; j < row ; j++) + { + vect[j] = inp[j + i*row]; + } + out[i] = zmoments(vect, row, ord); + } + +} diff --git a/src/c/statisticsFunctions/moment/zmoments.c b/src/c/statisticsFunctions/moment/zmoments.c new file mode 100644 index 0000000..1b84737 --- /dev/null +++ b/src/c/statisticsFunctions/moment/zmoments.c @@ -0,0 +1,22 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "moment.h" +#include "doubleComplex.h" +#include "floatComplex.h" +#include "pow.h" +#include "addition.h" +#include "division.h" + + +doubleComplex zmoments (doubleComplex* inp, int size, double ord) +{ + doubleComplex sum = DoubleComplex(0,0); + + for(int i = 0; i < size; i++) + { + sum = zadds(sum,zpows(inp[i], ord)); + } + + return zrdivs(sum,size); +} |