Running ‘test-AllKrigingConcistency.R’
  Running ‘test-KrigingCopy.R’
  Running ‘test-KrigingFit.R’
  Running ‘test-KrigingLeaveOneOut.R’
  Running ‘test-KrigingLeaveOneOut_3d.R’
  Running ‘test-KrigingLogLik.R’
  Running ‘test-KrigingLogLikGradHess.R’
  Running ‘test-KrigingMethods.R’
  Running ‘test-KrigingPredict.R’ [15s/14s]
  Running ‘test-KrigingSimulate.R’
  Running ‘test-KrigingUpdate.R’
  Running ‘test-KrigingUpdateSimulate.R’
  Running ‘test-LinearAlgebra.R’ [30m/15m]
  Running ‘test-NoiseKrigingFit.R’
  Running ‘test-NoiseKrigingLogLik.R’
  Running ‘test-NoiseKrigingMethods.R’
  Running ‘test-NoiseKrigingPredict.R’ [10s/10s]
  Running ‘test-NoiseKrigingSimulate.R’
  Running ‘test-NoiseKrigingUpdate.R’
  Running ‘test-NoiseKrigingUpdateSimulate.R’
  Running ‘test-NuggetKrigingFit.R’
  Running ‘test-NuggetKrigingLogLik.R’
  Running ‘test-NuggetKrigingLogMargPost.R’
  Running ‘test-NuggetKrigingMethods.R’
  Running ‘test-NuggetKrigingPredict.R’
  Running ‘test-NuggetKrigingSimulate.R’
  Running ‘test-NuggetKrigingUpdate.R’
  Running ‘test-NuggetKrigingUpdateSimulate.R’
  Running ‘test-RobustGaSP-Nugget.R’
  Running ‘test-RobustGaSP.R’
  Running ‘test-RobustGaSPtrendlinear.R’
  Running ‘test-RobustGaSPvsKrigingLMP.R’
  Running ‘test-RobustGaSPvsNuggetKrigingLMP.R’
  Running ‘test-SaveLoad.R’
  Running ‘test-asDiceKriging.R’ [12s/12s]
  Running ‘test-estimnone.R’
  Running ‘test-normalize.R’
  Running ‘test-rlibkriging-demo.R’
  Running ‘test-unstableLL.R’
Running the tests in ‘tests/test-LinearAlgebra.R’ failed.
Complete output:
  > library(testthat)
  >  Sys.setenv('OMP_THREAD_LIMIT'=2)
  >  library(rlibkriging)
  
  Attaching package: 'rlibkriging'
  
  The following objects are masked from 'package:base':
  
      load, save
  
  > 
  > ##library(rlibkriging, lib.loc="bindings/R/Rlibs")
  > ##library(testthat)
  > default_rcond_checked = rlibkriging:::linalg_chol_rcond_checked()
  > default_num_nugget = rlibkriging:::linalg_get_num_nugget()
  > 
  > context("LinearAlgebra")
  > 
  > # pack=list.files(file.path("bindings","R"),pattern = ".tar.gz",full.names = T)
  > # install.packages(pack,repos=NULL)
  > # #library(rlibkriging)
  > ##library(rlibkriging, lib.loc="bindings/R/Rlibs")
  > ##library(testthat)
  > 
  > #######################################################################
  > 
  > set.seed(123)
  > n = 100
  > X = matrix(rnorm(n*n),n,n)
  > 
  > X1 = t(X) %*% X - .001*diag(n) # will be pos def
  > 
  > L1 = t(chol(X1))
  > 
  > L1_lk = rlibkriging:::linalg_chol_safe(X1)
  > 
  > test_that(desc="Chol R/lK is almost the same", expect_equal(L1, L1_lk, tol=1e-10))
  Test passed 😸
  > 
  > X2 = t(X) %*% X - .01*diag(n) # will not be pos def
  > 
  > L2 = NULL
  > try(L2 <- t(chol(X2)))
  Error in chol.default(X2) : 
    the leading minor of order 100 is not positive
  > 
  > test_that(desc="Chol without nugget does not pass", expect_null(L2))
  Test passed 🎊
  > 
  > rlibkriging:::linalg_set_num_nugget(0.001)
  > rlibkriging:::linalg_set_chol_warning(TRUE)
  > L2_lk = NULL
  > L2_lk = rlibkriging:::linalg_chol_safe(X2)
  [WARNING] Added 6 numerical nugget to force Cholesky decomposition
  > rlibkriging:::linalg_set_num_nugget(1e-15) # default setup
  > 
  > test_that(desc="Chol with nugget passes", expect_false(is.null(L2_lk)))
  Test passed 😸
  > 
  > test_that(desc="Chol with nugget is close to be good",
  +     expect_equal(L2_lk %*% t(L2_lk) - 6*0.001*diag(n), X2, tol=1e-10))
  Test passed 🥳
  > 
  > #######################################################################
  > 
  > rlibkriging:::linalg_set_num_nugget(0) # force NA when chol fails
  > 
  > rcond_chol = function(X) {
  +     rlibkriging:::linalg_rcond_chol(chol(X))
  + }
  > rcond_approx_chol = function(X) {
  +     rlibkriging:::linalg_rcond_approx_chol(chol(X))
  + }
  > rcond = function(X) {
  +     1/kappa(X, norm='1')
  + }
  > 
  > set.seed(123)
  > r = array(NA, 100)
  > r_chol = array(NA,length(r))
  > ra_chol = array(NA,length(r))
  > for (i in 1:length(r)) {
  +     n = 100
  +     X = matrix(rnorm(n*n),n,n)
  +     X = t(X) %*% X + n*rnorm(1,0,1)*diag(n)
  +     try(r[i] <- rcond((X)))
  +     try(r_chol[i] <- rcond_chol((X)))
  +     try(ra_chol[i] <- rcond_approx_chol((X)))
  + }
  Error in chol.default(X) : the leading minor of order 30 is not positive
  Error in chol.default(X) : the leading minor of order 30 is not positive
  Error in chol.default(X) : the leading minor of order 10 is not positive
  Error in chol.default(X) : the leading minor of order 10 is not positive
  Error in chol.default(X) : the leading minor of order 55 is not positive
  Error in chol.default(X) : the leading minor of order 55 is not positive
  Error in chol.default(X) : the leading minor of order 45 is not positive
  Error in chol.default(X) : the leading minor of order 45 is not positive
  Error in chol.default(X) : the leading minor of order 2 is not positive
  Error in chol.default(X) : the leading minor of order 2 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 72 is not positive
  Error in chol.default(X) : the leading minor of order 72 is not positive
  Error in chol.default(X) : the leading minor of order 2 is not positive
  Error in chol.default(X) : the leading minor of order 2 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 14 is not positive
  Error in chol.default(X) : the leading minor of order 14 is not positive
  Error in chol.default(X) : the leading minor of order 52 is not positive
  Error in chol.default(X) : the leading minor of order 52 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 11 is not positive
  Error in chol.default(X) : the leading minor of order 11 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 3 is not positive
  Error in chol.default(X) : the leading minor of order 3 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 33 is not positive
  Error in chol.default(X) : the leading minor of order 33 is not positive
  Error in chol.default(X) : the leading minor of order 19 is not positive
  Error in chol.default(X) : the leading minor of order 19 is not positive
  Error in chol.default(X) : the leading minor of order 2 is not positive
  Error in chol.default(X) : the leading minor of order 2 is not positive
  Error in chol.default(X) : the leading minor of order 75 is not positive
  Error in chol.default(X) : the leading minor of order 75 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 42 is not positive
  Error in chol.default(X) : the leading minor of order 42 is not positive
  Error in chol.default(X) : the leading minor of order 48 is not positive
  Error in chol.default(X) : the leading minor of order 48 is not positive
  Error in chol.default(X) : the leading minor of order 44 is not positive
  Error in chol.default(X) : the leading minor of order 44 is not positive
  Error in chol.default(X) : the leading minor of order 50 is not positive
  Error in chol.default(X) : the leading minor of order 50 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 44 is not positive
  Error in chol.default(X) : the leading minor of order 44 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 5 is not positive
  Error in chol.default(X) : the leading minor of order 5 is not positive
  Error in chol.default(X) : the leading minor of order 54 is not positive
  Error in chol.default(X) : the leading minor of order 54 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 11 is not positive
  Error in chol.default(X) : the leading minor of order 11 is not positive
  Error in chol.default(X) : the leading minor of order 16 is not positive
  Error in chol.default(X) : the leading minor of order 16 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 28 is not positive
  Error in chol.default(X) : the leading minor of order 28 is not positive
  Error in chol.default(X) : the leading minor of order 5 is not positive
  Error in chol.default(X) : the leading minor of order 5 is not positive
  Error in chol.default(X) : the leading minor of order 75 is not positive
  Error in chol.default(X) : the leading minor of order 75 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 47 is not positive
  Error in chol.default(X) : the leading minor of order 47 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 7 is not positive
  Error in chol.default(X) : the leading minor of order 7 is not positive
  Error in chol.default(X) : the leading minor of order 16 is not positive
  Error in chol.default(X) : the leading minor of order 16 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 6 is not positive
  Error in chol.default(X) : the leading minor of order 6 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 2 is not positive
  Error in chol.default(X) : the leading minor of order 2 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 1 is not positive
  Error in chol.default(X) : the leading minor of order 3 is not positive
  Error in chol.default(X) : the leading minor of order 3 is not positive
  Error in chol.default(X) : the leading minor of order 2 is not positive
  Error in chol.default(X) : the leading minor of order 2 is not positive
  > 
  > plot(log10(r),log10(r_chol),col='red',ylim=range(c(range(log10(r_chol),na.rm=T),range(log10(ra_chol),na.rm=T))))
  > points(log10(r),log10(ra_chol),col='orange')
  > abline(a=0,b=1)
  > 
  > rlibkriging:::linalg_set_num_nugget(1e-15) # default setup
  > 
  > #######################################################################
  > 
  > n = 1000
  > R = matrix(rnorm(n*n),n,n)
  > R = t(R) %*% R
  > 
  > ## we just want a covar (sym pos def) matrix
  > no = n-30
  > Roo = R[1:no,1:no]
  > Too = t(chol(Roo))