x <- rnorm(2, sd=c(1,1e12))
x <- c(x, sum(x))
A <- matrix(c(1, 0, 1,
0, 1e24, 1e24,
1, 1e24, 1e24), 3, 3)
stopifnot(all.equal(
xTAx_qrssolve(x,A),
structure(drop(x%*%sginv(A)%*%x), rank = 2L, nullity = 1L)
))
x <- rnorm(2, sd=c(1,1e12))
x <- c(x, rnorm(1, sd=1e12))
A <- matrix(c(1, 0, 1,
0, 1e24, 1e24,
1, 1e24, 1e24), 3, 3)
stopifnot(try(xTAx_qrssolve(x,A), silent=TRUE) ==
"Error in xTAx_qrssolve(x, A) : x is not in the span of A\n")
Run the code above in your browser using DataLab