Fix test/ folder: tests of C code run fine now
authorBenjamin Auder <benjamin.auder@somewhere>
Tue, 7 Apr 2020 10:41:55 +0000 (12:41 +0200)
committerBenjamin Auder <benjamin.auder@somewhere>
Tue, 7 Apr 2020 10:41:55 +0000 (12:41 +0200)
test/Makefile
test/helper.R
test/run.sh

index 8b8697e..0c42206 100644 (file)
@@ -3,9 +3,9 @@ CFLAGS = -g -std=gnu99 -Wno-implicit-function-declaration
 LDFLAGS = -lm -lgsl -lcblas
 TEST_LDFLAGS = -L. libvalse_core.so
 LIB = libvalse_core.so
-LIB_SRC = $(wildcard ../pkg/src/sources/*.c)
+LIB_SRC = ../pkg/src/EMGLLF.c ../pkg/src/EMGrank.c
 LIB_OBJ = $(LIB_SRC:.c=.o)
-INCLUDES = -I../pkg/src/sources
+INCLUDES = -I../pkg/src
 TESTS = test.EMGLLF test.EMGrank
 
 all: $(LIB) $(TESTS)
@@ -23,7 +23,7 @@ test.EMGrank: $(LIB) test.EMGrank.o test_utils.o
        $(CC) -fPIC -o $@ -c $< $(CFLAGS) $(INCLUDES)
 
 clean:
-       rm -f *.o ../pkg/src/sources/*.o
+       rm -f *.o ../pkg/src/*.o
 
 cclean: clean
        rm -f *.so ../pkg/src/*.so $(TESTS)
index 8ec122b..21d00f2 100644 (file)
@@ -11,19 +11,20 @@ generateXYdefault = function(n, p, m, k)
 {
        meanX = rep(0, p)
        covX = diag(p)
-       covY = array(dim=c(m,m,k))
-       for(r in 1:k)
-               covY[,,r] = diag(m)
-       π = rep(1./k,k)
+       covY = diag(m)
+       ω = rep(1./k,k)
        #initialize beta to a random number of non-zero random value
        β = array(0, dim=c(p,m,k))
        for (j in 1:p)
        {
                nonZeroCount = sample(1:m, 1)
-               β[j,1:nonZeroCount,] = matrix(runif(nonZeroCount*k), ncol=k)
+               if (nonZeroCount >= 2)
+                       β[j,1:nonZeroCount,] = matrix(runif(nonZeroCount*k), ncol=k)
+               else
+                       β[j,1,] = runif(k)
        }
 
-       sample_IO = generateXY(n, Ï\80, meanX, β, covX, covY)
+       sample_IO = generateXY(n, Ï\89, meanX, β, covX, covY)
        return (list(X=sample_IO$X,Y=sample_IO$Y))
 }
 
index 7e92929..9dac69c 100755 (executable)
@@ -33,5 +33,5 @@ echo -e "source('generateRunSaveTest_$algo.R');\n \
 make test.$algo
 
 #3) Run it with valgrind!
-#valgrind 
+#valgrind
 ./test.$algo