Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork219
Closed
Description
Consider:
Rcpp::cppFunction("NumericMatrix fdiag(NumericMatrix x) { x.fill_diag(0.0); return x;}")
The issue arises with the.fill_diag()'sfill_diag__dispatch() method inMatrix.h primarily with a nonsymmetric matrix under either n > p or n < p.
Case 1: Nonsymmetric (n < p)
m1<-matrix(1:10,nrow=2,ncol=5,byrow=TRUE)fdiag(m1)
[,1] [,2] [,3] [,4] [,5][1,] 0 2 3 0 5[2,] 6 7 8 9 10Expected:
[,1] [,2] [,3] [,4] [,5][1,] 0 2 3 4 5[2,] 6 0 8 9 10Case 2: Nonsymmetric (n > p)
m3<-matrix(1:10,nrow=5,ncol=2,byrow=TRUE)fdiag(m3)
[,1] [,2][1,] 0 2[2,] 3 4[3,] 5 6[4,] 0 8[5,] 9 10Expected:
[,1] [,2][1,] 0 2[2,] 3 0[3,] 5 6[4,] 7 8[5,] 9 10Case 3: n = p
Though, the square matrix iteration works correctly.
m3<-matrix(1:9,nrow=3,ncol=3,byrow=TRUE)fdiag(m3)
[,1] [,2] [,3][1,] 0 2 3[2,] 4 0 6[3,] 7 8 0Metadata
Metadata
Assignees
Labels
No labels