Running 'backsolvetest.R' [166s]
  Running 'bdstest.R' [1s]
  Comparing 'bdstest.Rout' to 'bdstest.Rout.save' ... OK
  Running 'chtest.R' [168s]
  Running 'chtest2.R' [160s]
  Running 'corner.R' [170s]
  Running 'corner2.R' [169s]
  Running 'gtest.R' [159s]
  Running 'gtest2.R' [154s]
  Running 'matrix.R' [173s]
  Running 'nullr.R' [163s]
  Running 'reconcile.R' [1s]
  Comparing 'reconcile.Rout' to 'reconcile.Rout.save' ... OK
  Running 'tinv.R' [1s]
  Comparing 'tinv.Rout' to 'tinv.Rout.save' ... OK
Running the tests in 'tests/backsolvetest.R' failed.
Complete output:
  > library(bdsmatrix)
  
  Attaching package: 'bdsmatrix'
  
  The following object is masked from 'package:base':
  
      backsolve
  
  > #
  > # A test of the backsolve function
  > #
  > aeq <- function(x,y) all.equal(as.vector(x), as.vector(y))
  > 
  > tmat <- matrix(rep(1:5,5), 5, 5)
  > tmat <- tmat + t(tmat)
  > diag(tmat) <- diag(tmat) + 10
  > 
  > gt <- gchol(tmat)
  > g1 <- as.matrix(gt)
  > gd <- diag(sqrt(diag(gt)))
  > gc <- gd %*% t(g1)  #usual cholesky form
  > 
  > xmat <- cbind(1:5, 11:15)
  > 
  > s1 <- backsolve(gt, xmat, upper=TRUE)  #the default
  > aeq(gd %*% t(g1) %*% s1, xmat)
  [1] TRUE
  > all.equal(s1, backsolve(gc, xmat)) 
  [1] TRUE
  > 
  > s2 <- backsolve(gt, xmat, upper=FALSE)
  > aeq(g1 %*% gd %*% s2, xmat)
  [1] TRUE
  > all.equal(backsolve(gt,xmat, upper=F), backsolve(t(gc),xmat, upper=F)) 
  [1] TRUE
  > 
  > 
  > # Now for bdsmatrix objects
  > tmat <- bdsmatrix(c(3,2,2,4), 
  + 	      c(22,1,2,21,3,20,19,4,18,17,5,16,15,6,7, 8,14,9,10,13,11,12),
  + 	      matrix(c(1,0,1,1,0,0,1,1,0,1,0,10,0,
  +                        0,1,1,0,1,1,0,1,1,0,1,0,10), ncol=2))
  > dimnames(tmat) <- list(NULL, letters[1:13])
  > smat <- as.matrix(tmat)
  > 
  > gt <- gchol(tmat)
  > gs <- gchol(smat)
  > 
  > xmat <- cbind(1:13, 1:13*2 + 3)
  > 
  > s1 <- backsolve(gt, xmat)
  > s2 <- backsolve(gs, xmat)
  > s3 <- backsolve(gt, xmat, upper=FALSE)
  > s4 <- backsolve(gs, xmat, upper=FALSE)
  > 
  > aeq(s1, s2)
  [1] TRUE
  > aeq(s3, s4)
  [1] TRUE
  > 
  > g1 <- as.matrix(gt)
  > gd <- diag(sqrt(diag(gt)))
  > aeq(gd %*% t(g1) %*% s1, xmat)
  [1] TRUE
  > aeq(g1 %*% gd %*% s3, xmat)
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     0.46    0.07    0.51 
Running the tests in 'tests/chtest.R' failed.
Complete output:
  > #
  > # Test out the Cholesky 
  > #
  > library(bdsmatrix)
  
  Attaching package: 'bdsmatrix'
  
  The following object is masked from 'package:base':
  
      backsolve
  
  > aeq <- function(x,y) all.equal(as.vector(x), as.vector(y))
  > 
  > tmat <- bdsmatrix(c(3,2,2,4), 
  + 	      c(22,1,2,21,3,20,19,4,18,17,5,16,15,6,7, 8,14,9,10,13,11,12),
  + 	      matrix(c(1,0,1,1,0,0,1,1,0,1,0,10,0,
  +                        0,1,1,0,1,1,0,1,1,0,1,0,10), ncol=2))
  > dimnames(tmat) <- list(NULL, letters[1:13])
  > smat <- as.matrix(tmat)
  > yy <- c(30,35,42,56,34,45,32,37,78,56,40,52,39)
  > 
  > aeq(diag(tmat), diag(smat))
  [1] TRUE
  > zz <- seq(1,13,2)
  > aeq(as.matrix(tmat[zz,zz]), smat[zz,zz])
  [1] TRUE
  > 
  > ch0 <- chol(smat)
  > ch1 <- gchol(smat)
  > ch2 <- gchol(tmat)
  > # The gchol routines use the composition LDL', where L is lower triangular
  > #  with a diagonal of 1's, and D is diagonal.  chol() uses U'U where U is
  > #  upper trangular.  
  > # The as.matrix function returns L and the diag function returns D.
  > #  Convert and compare
  > aeq(diag(ch1), diag(ch2))
  [1] TRUE
  > temp <- as.matrix(ch2)
  > aeq(temp, as.matrix(ch1))
  [1] TRUE
  > temp3 <- temp %*% diag(sqrt(diag(ch2))) 
  > aeq(temp3, t(ch0))
  [1] TRUE
  > 
  > zz0 <- solve(smat, yy)
  > zz1 <- solve(ch1, yy)
  > zz2 <- solve(tmat, yy)
  > aeq(zz1, zz2)
  [1] TRUE
  > aeq(zz0, zz1)
  [1] TRUE
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.40    0.09    0.48 
Running the tests in 'tests/chtest2.R' failed.
Complete output:
  > #
  > # Inverse of the matrix:  
  > #
  > library(bdsmatrix)
  
  Attaching package: 'bdsmatrix'
  
  The following object is masked from 'package:base':
  
      backsolve
  
  > aeq <- function(x,y) all.equal(as.vector(x), as.vector(y))
  > 
  > tmat <- bdsmatrix(c(3,2,2,4), 
  + 	      c(22,1,2,21,3,20,19,4,18,17,5,16,15,6,7, 8,14,9,10,13,11,12),
  + 	      matrix(c(1,0,1,1,0,0,1,1,0,1,0,10,0,
  +                        0,1,1,0,1,1,0,1,1,0,1,0,10), ncol=2))
  > dimnames(tmat) <- list(NULL, letters[1:13])
  > 
  > smat <- as.matrix(tmat)
  > 
  > inv1 <- solve(smat)
  > inv2 <- as.matrix(solve(tmat)) # the result is a full, non-sparse matrix
  > aeq(inv1, inv2)
  [1] TRUE
  > 
  > inv3 <- solve(gchol(tmat))         #sparse version, not all parts will be there
  > inherits(inv3, 'bdsmatrix')         #This should be true
  [1] TRUE
  > aeq(inv3@blocksize, tmat@blocksize) # Should be the same shape at tmat
  [1] TRUE
  > inv3 <- as.matrix(inv3)		    # What is returned should be correct
  > aeq(inv1[1:3,1:3], inv3[1:3, 1:3])
  [1] TRUE
  > aeq(inv1[4:5,4:5], inv3[4:5, 4:5])
  [1] TRUE
  > aeq(inv1[6:7,6:7], inv3[6:7, 6:7])
  [1] TRUE
  > aeq(inv1[8:11,8:11], inv3[8:11, 8:11])
  [1] TRUE
  > aeq(inv1[,12:13], inv3[, 12:13])    # and rmat the same too
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     0.42    0.10    0.53 
Running the tests in 'tests/corner.R' failed.
Complete output:
  > #
  > # Test out the behavior of a 1x1 bds corner.
  > #  Actually, the problem that motivated this occurred whenever the
  > # rmat portion was larger than the block diagonal portion.
  > #
  > library(bdsmatrix)
  
  Attaching package: 'bdsmatrix'
  
  The following object is masked from 'package:base':
  
      backsolve
  
  > test1 <- bdsmatrix(blocksize=1, blocks=33, 
  +                    rmat=matrix(c(17,33,7,-1, -7,7,48,-7,
  +                                  1, -1, -7,4),4))
  > 
  > test2 <- bdsmatrix(blocksize=2, blocks=c(33,17,33),
  +                     rmat=matrix(c( -7,7,48,-7, 1, -1, -7,4),4))
  > all.equal(as.matrix(test1), as.matrix(test2))
  [1] TRUE
  > 
  > g1 <- gchol(test1)
  > g2 <- gchol(test2)
  > all.equal(as.matrix(g1), as.matrix(g2))
  [1] TRUE
  > 
  > s1 <- solve(g1, full=T)
  > s2 <- solve(g2, full=T)
  > all.equal(as.matrix(s1), as.matrix(s2))
  [1] TRUE
  > 
  > all.equal(solve(test1), solve(test2))
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     0.46    0.12    0.57 
Running the tests in 'tests/corner2.R' failed.
Complete output:
  > #
  > # Test out the Cholesky, special case of a null block corner 
  > # In this case there is no advantage to a bdsmatrix as it consists of only
  > #  the ordinary matrix part.  This case arises in coxme with an (x1+x2 | 1)
  > #  term, however, so it is nice to have it work instead of coding lots of
  > #  if/else logic in that code base.
  > #
  > library(bdsmatrix)
  
  Attaching package: 'bdsmatrix'
  
  The following object is masked from 'package:base':
  
      backsolve
  
  > aeq <- function(x,y) all.equal(as.vector(x), as.vector(y))
  > 
  > tmat <- bdsmatrix(c(3,2,2,4), 
  + 	      c(22,1,2,21,3,20,19,4,18,17,5,16,15,6,7, 8,14,9,10,13,11,12),
  + 	      matrix(c(1,0,1,1,0,0,1,1,0,1,0,10,0,
  +                        0,1,1,0,1,1,0,1,1,0,1,0,10), ncol=2))
  > dimnames(tmat) <- list(NULL, letters[1:13])
  > smat <- as.matrix(tmat)
  > tmat <- bdsmatrix(integer(0), numeric(0), rmat=smat)  
  > yy <- c(30,35,42,56,34,45,32,37,78,56,40,52,39)
  > 
  > aeq(diag(tmat), diag(smat))
  [1] TRUE
  > zz <- seq(1,13,2)
  > aeq(as.matrix(tmat[zz,zz]), smat[zz,zz])
  [1] TRUE
  > 
  > ch0 <- chol(smat)
  > ch1 <- gchol(smat)
  > ch2 <- gchol(tmat)
  > # The gchol routines use the composition LDL', where L is lower triangular
  > #  with a diagonal of 1's, and D is diagonal.  chol() uses U'U where U is
  > #  upper trangular.  
  > # The as.matrix function returns L and the diag function returns D.
  > #  Convert and compare
  > aeq(diag(ch1), diag(ch2))
  [1] TRUE
  > temp <- as.matrix(ch2)
  > aeq(temp, as.matrix(ch1))
  [1] TRUE
  > temp3 <- temp %*% diag(sqrt(diag(ch2))) 
  > aeq(temp3, t(ch0))
  [1] TRUE
  > 
  > zz0 <- solve(smat, yy)
  > zz1 <- solve(ch1, yy)
  > zz2 <- solve(tmat, yy)
  > aeq(zz1, zz2)
  [1] TRUE
  > aeq(zz0, zz1)
  [1] TRUE
  > 
  > inv1 <- solve(smat)
  > inv2 <- as.matrix(solve(tmat)) # the result is a full, non-sparse matrix
  > aeq(inv1, inv2)
  [1] TRUE
  > 
  > inv3 <- solve(gchol(tmat))
  > aeq(inv1, as.matrix(inv3))
  [1] TRUE
  > 
  > gmat <- gchol(tmat)
  > g2 <- as.matrix(gmat) %*% diag(sqrt(diag(gmat)))
  > aeq(1:13 %*% g2, 1:13 %*% gmat)  #vectors first
  [1] TRUE
  > aeq(g2 %*% 1:13, gmat %*% 1:13)
  [1] TRUE
  > temp <- matrix(runif(39), nrow=3)
  > aeq(temp %*% g2, temp %*% gmat)
  [1] TRUE
  > aeq(g2 %*% t(temp), gmat %*% t(temp))
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
      0.4     0.1     0.5 
Running the tests in 'tests/gtest.R' failed.
Complete output:
  > library(bdsmatrix)
  
  Attaching package: 'bdsmatrix'
  
  The following object is masked from 'package:base':
  
      backsolve
  
  > aeq <- function(x,y) all.equal(as.vector(x), as.vector(y))
  > 
  > tmat <- bdsmatrix(c(3,2,2,4), 
  + 	      c(22,1,2,21,3,20,19,4,18,17,5,16,15,6,7, 8,14,9,10,13,11,12),
  + 	      matrix(c(1,0,1,1,0,0,1,1,0,1,0,10,0,
  +                        0,1,1,0,1,1,0,1,1,0,1,0,10), ncol=2))
  > dimnames(tmat) <- list(NULL, letters[1:13])
  > 
  > smat <- as.matrix(tmat)
  > 
  > # Create a matrix that is symmetric, but not positive definite
  > #   The first one, temp, has column 6 redundant with cols 1-5
  > temp <- smat[c(1:5, 5:10), c(1:5, 5:10)]
  > ch1  <- gchol(temp)
  > aeq(diag(ch1)[6], 0)  # Check that it has a zero in the proper place
  [1] TRUE
  > ginv <- solve(ch1)    # see if I get a generalized inverse
  > aeq(temp %*% ginv %*% temp, temp)
  [1] TRUE
  > aeq(ginv %*% temp %*% ginv, ginv)
  [1] TRUE
  > 
  > # Now create one that is negative definite 
  > ch2 <- gchol(smat)
  > temp2 <- as.matrix(ch2)
  > temp3 <- diag(ch2) * rep(c(1, -1), length=nrow(smat))
  > xmat  <- temp2 %*% diag(temp3) %*% t(temp2)
  > xmat  <- (xmat + t(xmat))/2  #work out round-off errors
  > ch3 <- gchol(xmat)
  > 
  > aeq(diag(ch3), temp3)
  [1] TRUE
  > aeq(as.matrix(ch3), temp2)
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     0.40    0.06    0.45 
Running the tests in 'tests/gtest2.R' failed.
Complete output:
  > library(bdsmatrix)
  
  Attaching package: 'bdsmatrix'
  
  The following object is masked from 'package:base':
  
      backsolve
  
  > aeq <- function(x,y) all.equal(as.vector(x), as.vector(y))
  > 
  > #
  > # Test multiplication of a vector/matrix times a gchol
  > #
  > tmat <- bdsmatrix(c(3,2,2,4), 
  +               c(22,1,2,21,3,20,19,4,18,17,5,16,15,6,7, 8,14,9,10,13,11,12),
  +               matrix(c(1,0,1,1,0,0,1,1,0,1,0,10,0,
  +                        0,1,1,0,1,1,0,1,1,0,1,0,10), ncol=2))
  > dimnames(tmat) <- list(NULL, letters[1:13])
  > 
  > gmat <- gchol(tmat)
  > g2 <- as.matrix(gmat) %*% diag(sqrt(diag(gmat)))
  > 
  > 
  > aeq(1:13 %*% g2, 1:13 %*% gmat)  #vectors first
  [1] TRUE
  > aeq(g2 %*% 1:13, gmat %*% 1:13)
  [1] TRUE
  > 
  > temp <- matrix(runif(39), nrow=3)
  > aeq(temp %*% g2, temp %*% gmat)
  [1] TRUE
  > aeq(g2 %*% t(temp), gmat %*% t(temp))
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     0.42    0.07    0.50 
Running the tests in 'tests/matrix.R' failed.
Complete output:
  > library(bdsmatrix)
  
  Attaching package: 'bdsmatrix'
  
  The following object is masked from 'package:base':
  
      backsolve
  
  > aeq <- function(x,y) all.equal(as.vector(x), as.vector(y))
  > 
  > tmat <- bdsmatrix(c(3,2,2,4), 
  + 	      c(22,1,2,21,3,20,19,4,18,17,5,16,15,6,7, 8,14,9,10,13,11,12),
  + 	      matrix(c(1,0,1,1,0,0,1,1,0,1,0,10,0,
  +                        0,1,1,0,1,1,0,1,1,0,1,0,10), ncol=2))
  > dimnames(tmat) <- list(NULL, letters[1:13])
  > 
  > smat <- as.matrix(tmat)
  > yy <- c(30,35,42,56,34,45,32,37,78,56,40,52,39)
  > 
  > # matrix multiplication
  > zz <- runif(13)
  > aeq(zz%*% smat, zz%*% tmat)
  [1] TRUE
  > aeq(smat%*%zz, tmat%*% zz)
  [1] TRUE
  > 
  > xx <- matrix(1:39, ncol=3)
  > aeq(smat %*% zz, tmat %*% zz)
  [1] TRUE
  > aeq(t(xx) %*% smat, t(xx) %*% tmat)
  [1] TRUE
  > 
  > 
  > amat <- tmat
  > amat@offdiag <- pi
  > bmat <- as.matrix(amat)
  > 
  > aeq(zz%*% amat, zz%*% bmat)
  [1] TRUE
  > aeq(amat%*%zz, bmat%*% zz)
  [1] TRUE
  > 
  > 
  > # Solve the right-hand side wrt a matrix
  > yy2 <- cbind(yy, -yy, yy+3)
  > zz1 <- solve(smat, yy2)
  > zz2 <- solve(tmat, yy2)
  > aeq(zz1, zz2)
  [1] TRUE
  > aeq(zz2[,1], solve(tmat, yy))
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     0.39    0.09    0.46 
Running the tests in 'tests/nullr.R' failed.
Complete output:
  > #
  > # Make sure things work in the simpler case of no rmat component
  > #
  > library(bdsmatrix)
  
  Attaching package: 'bdsmatrix'
  
  The following object is masked from 'package:base':
  
      backsolve
  
  > aeq <- function(x,y) all.equal(as.vector(x), as.vector(y))
  > 
  > tmat <- bdsmatrix(blocksize= c(3,2,2,4), 
  +               blocks= c(22,1,2,21,3,20,19,4,18,17,5,16,15,6,7, 
  +                         8,14,9,10,13,11,12))
  > dimnames(tmat) <- list(NULL, letters[1:11])
  > smat <- as.matrix(tmat)
  > yy <- c(30,35,42,56,34,45,32,37,78,56,40)
  > 
  > aeq(diag(tmat), diag(smat))
  [1] TRUE
  > zz <- seq(1,11,2)
  > aeq(as.matrix(tmat[zz,zz]), smat[zz,zz])
  [1] TRUE
  > 
  > ch0 <- chol(smat)
  > ch1 <- gchol(smat)
  > ch2 <- gchol(tmat)
  > 
  > aeq(diag(ch1), diag(ch2))
  [1] TRUE
  > temp <- as.matrix(ch2)
  > aeq(temp, as.matrix(ch1))
  [1] TRUE
  > temp3 <- temp %*% diag(sqrt(diag(ch2))) 
  > aeq(temp3, t(ch0))
  [1] TRUE
  > 
  > zz0 <- solve(smat, yy)
  > zz1 <- solve(ch1, yy)
  > zz2 <- solve(tmat, yy)
  > aeq(zz1, zz2)
  [1] TRUE
  > aeq(zz0, zz1)
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     0.46    0.06    0.51