From: Benjamin Auder <benjamin.auder@somewhere>
Date: Fri, 13 Jan 2017 12:55:21 +0000 (+0100)
Subject: write test.EMGrank.c
X-Git-Url: https://git.auder.net/variants/Chakart/doc/scripts/pieces/css/%3C?a=commitdiff_plain;h=150fa42cf4cea378c7c18f5b78ec85f5fd151a4d;p=valse.git

write test.EMGrank.c
---

diff --git a/src/test/test.EMGLLF.c b/src/test/test.EMGLLF.c
index 1720641..8f6b2b1 100644
--- a/src/test/test.EMGLLF.c
+++ b/src/test/test.EMGLLF.c
@@ -4,10 +4,6 @@
 
 int main(int argc, char** argv)
 {
-	////////////
-	// INPUTS //
-	////////////
-
 	int* dimensions = readArray_int("dimensions");
 	int n = dimensions[0];
 	int p = dimensions[1];
@@ -15,6 +11,10 @@ int main(int argc, char** argv)
 	int k = dimensions[3];
 	free(dimensions);
 
+	////////////
+	// INPUTS //
+	////////////
+
 	float* phiInit = readArray_real("phiInit");
 	float* rhoInit = readArray_real("rhoInit");
 	float* piInit = readArray_real("piInit");
diff --git a/src/test/test.EMGrank.c b/src/test/test.EMGrank.c
index c6edbc2..59a68d0 100644
--- a/src/test/test.EMGrank.c
+++ b/src/test/test.EMGrank.c
@@ -1,64 +1,33 @@
 #include "EMGrank.h"
-#include "ioutils.h"
+#include "utils.h"
 
 int main(int argc, char** argv)
 {
-	// read dimensions
-	const int nbDims = 4;
-	int* dimensions = readArray_int("dimensions",&nbDims,1);
+	int* dimensions = readArray_int("dimensions");
 	int n = dimensions[0];
 	int p = dimensions[1];
 	int m = dimensions[2];
 	int k = dimensions[3];
 	free(dimensions);
-	int lengthOne = 1;
 
 	////////////
 	// INPUTS //
 	////////////
 
-	// Rho
-	const int dimRho[] = {m, m, k};
-	float* Rho = readArray_real("Rho",dimRho,3);
-
-	// Pi
-	float* Pi = readArray_real("Pi",&k,1);
-
-	// min number of iterations
-	int* pmini = readArray_int("mini",&lengthOne,1);
-	int mini = *pmini;
-	free(pmini);
-
-	// max number of iterations
-	int* pmaxi = readArray_int("maxi",&lengthOne,1);
-	int maxi = *pmaxi;
-	free(pmaxi);
-
-	// X
-	const int dimX[] = {n, p};
-	float* X = readArray_real("X",dimX, 2);
-
-	// Y
-	const int dimY[] = {n, m};
-	float* Y = readArray_real("Y",dimY, 2);
-
-	// tau
-	float* ptau = readArray_real("tau",&lengthOne,1);
-	float tau = *ptau;
-	free(ptau);
-
-	// tau
-	int* rank = readArray_int("rank",&k,1);
+	float* Rho = readArray_real("Rho");
+	float* Pi = readArray_real("Pi");
+	int mini = read_int("mini");
+	int maxi = read_int("maxi");
+	float* X = readArray_real("X");
+	float* Y = readArray_real("Y");
+	float tau = read_real("tau");
+	int* rank = readArray_int("rank");
 
 	/////////////
 	// OUTPUTS //
 	/////////////
 
-	// phi
-	const int dimPhi[] = {p, m, k};
-	float* phi = (float*)malloc(dimPhi[0]*dimPhi[1]*dimPhi[2]*sizeof(float));
-
-	// LLF
+	float* phi = (float*)malloc(p*m*k*sizeof(float));
 	float* LLF = (float*)malloc(1*sizeof(float));
 
 	//////////////////////////
@@ -68,25 +37,24 @@ int main(int argc, char** argv)
 	EMGrank(Pi,Rho,mini,maxi,X,Y,tau,rank,
 		phi,LLF,
 		n,p,m,k);
-	
-	// free input pointers
+
 	free(Rho);
 	free(Pi);
 	free(X);
 	free(Y);
 	free(rank);
-	
+
 	// Compare to reference outputs
-	float* ref_phi = readArray_real("phi",dimPhi, 3);
-	compareArray_real("phi", phi, ref_phi, dimPhi[0]*dimPhi[1]*dimPhi[2]);
+	float* ref_phi = readArray_real("phi");
+	compareArray_real("phi", phi, ref_phi, p*m*k);
 	free(phi);
 	free(ref_phi);
-	
+
 	// LLF
-	float* ref_LLF = readArray_real("LLF",&lengthOne,1);
+	float* ref_LLF = readArray_real("LLF");
 	compareArray_real("LLF", LLF, ref_LLF, 1);
 	free(LLF);
 	free(ref_LLF);
-	
+
 	return 0;
 }