summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/statisticsFunctions/center/dcentercola.c
blob: e92a1d2940a88f748446a1c4df6c29598be5ccbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ones.h>
#include "subtraction.h"
#include "matrixMultiplication.h"
#include "center.h"

void dcentercola (double* inp, int row, int col, double* out)
{

    double sum[row], xbar[row];
    for(int i = 0; i < row; i++)
	sum[i] = 0;


    for(int i = 0; i < row; i++)
    {
	for(int j = 0; j < col; j++)
	{
	    sum[i] +=  inp[i + j*row];
	}
    }


    for(int i = 0; i < row; i++)
	xbar[i] = sum[i]/col;

    double one[col];			// Creating a matrix of ones
    donesa(one,1,col);


    double prod[row*col];
    dmulma(xbar, row, 1, one, 1, col, prod);

    for(int i = 0; i< row*col; i++)
	out[i] = inp[i] - prod[i];   
}