X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=pkg%2Fsrc%2Ffunctions.c;h=f251eb349fe2be411b05273753ea0b7ebc617ab2;hb=9a6881ed8a16c31a3dbe995e3b1af76c1db6b5a0;hp=0d632d3828216727b97e7cc676496e57ad0e87ec;hpb=cbd88fe5729bf206a784238a2637aa60e697fcdc;p=morpheus.git diff --git a/pkg/src/functions.c b/pkg/src/functions.c index 0d632d3..f251eb3 100644 --- a/pkg/src/functions.c +++ b/pkg/src/functions.c @@ -1,55 +1,112 @@ #include -//index matrix (by columns) +// Index matrix (by columns) int mi(int i, int j, int d1, int d2) { - return j*d1+i; + return j*d1 + i; } -//index 3-tensor (by columns, matrices ordered by last dim) +// Index 3-tensor (by columns, matrices ordered by last dim) int ti(int i, int j, int k, int d1, int d2, int d3) { - return k*d1*d2 + j*d1 + i; + return k*d1*d2 + j*d1 + i; } -// Emprical cross-moment of order 2 between X size nxd and Y size n +// Empirical cross-moment of order 2 between X size nxd and Y size n void Moments_M2(double* X, double* Y, int* pn, int* pd, double* M2) { - int n=*pn, d=*pd; - //double* M2 = (double*)calloc(d*d,sizeof(double)); - - // M2 = E[Y*X^*2] - E[Y*e^*2] = E[Y (X^*2 - I)] - for (int j=0; j + +// W = 1/N sum( t(g(Zi,theta)) g(Zi,theta) ) +// with g(Zi, theta) = i-th contribution to all moments (size dim) - real moments +void Compute_Omega(double* X, double* Y, double* M, int* pn, int* pd, double* W) +{ + int n=*pn, d=*pd; + int dim = d + d*d + d*d*d; + //double* W = (double*)malloc(dim*dim*sizeof(double)); + + // (Re)Initialize W: + for (int j=0; j