b140e5ee36cfb1fd39cb460d005126580c11ca7d
[valse.git] / test / test_EMGrank.R
1 library(valse)
2 testFolder = "data/"
3
4 # NOTE: R typing is really terrible. as.double as.matrix ...and so on; don't remove.
5
6 #get inputs
7 npmk = as.matrix(read.table(paste(testFolder,"dimensions",sep="")))
8 n = npmk[1]; p=npmk[2]; m=npmk[3]; k=npmk[4]
9 Pi = as.double(as.matrix(read.table(paste(testFolder,"Pi",sep="")))[,])
10 Rho = array(as.double(as.matrix(read.table(paste(testFolder,"Rho",sep="")))), dim=c(m,m,k))
11 mini = as.integer(as.matrix(read.table(paste(testFolder,"mini",sep="")))[1])
12 maxi = as.integer(as.matrix(read.table(paste(testFolder,"maxi",sep="")))[1])
13 X = matrix(as.double(as.matrix(read.table(paste(testFolder,"X",sep="")))), n,p)
14 Y = matrix(as.double(as.matrix(read.table(paste(testFolder,"Y",sep="")))), n,m)
15 eps = as.double(as.matrix(read.table(paste(testFolder,"eps",sep="")))[1])
16 rank = as.double(as.matrix(read.table(paste(testFolder,"rank",sep="")))[,])
17
18 #get outputs
19 phi = array(as.double(as.matrix(read.table(paste(testFolder,"phi",sep="")))), dim=c(p,m,k))
20 LLF = as.double(as.matrix(read.table(paste(testFolder,"LLF",sep="")))[1])
21
22 res = valse::EMGrank(Pi,Rho,mini,maxi,X,Y,eps,rank,fast=TRUE)
23
24 #compare outputs
25 nd=7 #number of digits
26 print( all(round(phi,nd) == round(res$phi,nd)) )
27 print( all(round(LLF,nd) == round(res$LLF,nd)) )