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