Commit | Line | Data |
---|---|---|
3453829e BA |
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 | phiInit = array(as.double(as.matrix(read.table(paste(testFolder,"phiInit",sep="")))), dim=c(p,m,k)) | |
10 | rhoInit = array(as.double(as.matrix(read.table(paste(testFolder,"rhoInit",sep="")))), dim=c(m,m,k)) | |
11 | piInit = as.double(as.matrix(read.table(paste(testFolder,"piInit",sep="")))[,]) | |
12 | gamInit = matrix(as.double(as.matrix(read.table(paste(testFolder,"gamInit",sep="")))), n,k) | |
13 | mini = as.integer(as.matrix(read.table(paste(testFolder,"mini",sep="")))[1]) | |
14 | maxi = as.integer(as.matrix(read.table(paste(testFolder,"maxi",sep="")))[1]) | |
15 | gamma = as.double(as.matrix(read.table(paste(testFolder,"gamma",sep="")))[1]) | |
16 | lambda = as.double(as.matrix(read.table(paste(testFolder,"lambda",sep="")))[1]) | |
17 | X = matrix(as.double(as.matrix(read.table(paste(testFolder,"X",sep="")))), n,p) | |
18 | Y = matrix(as.double(as.matrix(read.table(paste(testFolder,"Y",sep="")))), n,m) | |
19 | eps = as.double(as.matrix(read.table(paste(testFolder,"eps",sep="")))[1]) | |
20 | ||
21 | #get outputs | |
22 | phi = array(as.double(as.matrix(read.table(paste(testFolder,"phi",sep="")))), dim=c(p,m,k)) | |
23 | rho = array(as.double(as.matrix(read.table(paste(testFolder,"rho",sep="")))), dim=c(m,m,k)) | |
24 | pi = as.double(as.matrix(read.table(paste(testFolder,"pi",sep="")))[,]) | |
25 | llh = as.double(as.matrix(read.table(paste(testFolder,"llh",sep="")))[1]) | |
26 | S = array(as.double(as.matrix(read.table(paste(testFolder,"S",sep="")))), dim=c(p,m,k)) | |
27 | affec = as.double(as.matrix(read.table(paste(testFolder,"affec",sep="")))[,]) | |
28 | ||
29 | res = valse::EMGLLF( | |
30 | phiInit,rhoInit,piInit,gamInit,mini,maxi,gamma,lambda,X,Y,eps,fast=TRUE) | |
31 | ||
32 | #compare outputs | |
33 | nd=7 #number of digits | |
34 | print( all(round(phi,nd) == round(res$phi,nd)) ) | |
35 | print( all(round(rho,nd) == round(res$rho,nd)) ) | |
36 | print( all(round(pi,nd) == round(res$pi,nd)) ) | |
37 | print( all(round(llh,nd) == round(res$llh,nd)) ) | |
38 | print( all(round(S,nd) == round(res$S,nd)) ) | |
39 | print( all(affec == res$affec) ) |