From: Benjamin Auder Date: Tue, 7 Apr 2020 10:41:55 +0000 (+0200) Subject: Fix test/ folder: tests of C code run fine now X-Git-Url: https://git.auder.net/game/%7B%7B%20path%28%27fos_user_profile_show%27%29%20%7D%7D?a=commitdiff_plain;h=bb64f5cbaa3f0d4cc49a0325ca24d4f41f90ccc3;p=valse.git Fix test/ folder: tests of C code run fine now --- diff --git a/test/Makefile b/test/Makefile index 8b8697e..0c42206 100644 --- a/test/Makefile +++ b/test/Makefile @@ -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) diff --git a/test/helper.R b/test/helper.R index 8ec122b..21d00f2 100644 --- a/test/helper.R +++ b/test/helper.R @@ -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, π, meanX, β, covX, covY) + sample_IO = generateXY(n, ω, meanX, β, covX, covY) return (list(X=sample_IO$X,Y=sample_IO$Y)) } diff --git a/test/run.sh b/test/run.sh index 7e92929..9dac69c 100755 --- a/test/run.sh +++ b/test/run.sh @@ -33,5 +33,5 @@ echo -e "source('generateRunSaveTest_$algo.R');\n \ make test.$algo #3) Run it with valgrind! -#valgrind +#valgrind ./test.$algo