Skip to content

Commit

Permalink
solved pinv bug
Browse files Browse the repository at this point in the history
  • Loading branch information
markvanderloo committed Feb 5, 2016
1 parent 8ac3ae1 commit 78079d2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/NEWS
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version 0.1.0.1
- bugfix: pinv crashed on matrices with a single s.v.
- bugfix: eliminate would sometimes report the wrong number of equalities
- bugfix: eliminate sometimes crashed because of a mismatch in colnames of history matrix

Expand Down
2 changes: 1 addition & 1 deletion pkg/R/pinv.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pinv <- function(A, eps=1e-8){
d <- L$d
i <- abs(d) > eps
d[i] <- 1/d[i]
L$v %*% diag(d) %*% t(L$u)
L$v %*% diag(d, nrow=length(d)) %*% t(L$u)
}


Expand Down
7 changes: 7 additions & 0 deletions pkg/tests/testthat/test_pinv.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@ test_that("Computing pseudoinverse",{
expect_equal(pinv(A),Aplus55/55)
})

test_that("bugfixes",{
# this crashed because there's only one s.v. and 'diag'
# reacts differently when presented a single number.
pinv(matrix(c(1,-1,0,0,0)))

})

0 comments on commit 78079d2

Please sign in to comment.