Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lower_tri / upper_tri non-functional #641

Closed
coatless opened this issue Jan 31, 2017 · 2 comments
Closed

lower_tri / upper_tri non-functional #641

coatless opened this issue Jan 31, 2017 · 2 comments

Comments

@coatless
Copy link
Contributor

Both the lower_tri and upper_tri sugar functions are non-functional for two reasons:

  1. Neither function returns a Matrix as CTRP's base is VectorBase instead of MatrixBase.
  2. Attempting to store the result in a LogicalVector leads the R process to hang.

After glancing at the source, it appears as if both of functions were DOA and should not have been pushed back with Rcpp 0.8.3. Though, this remark is made in light of the fact that there are no unit tests governing these functions.


The following will hang your R session

Rcpp::cppFunction('
LogicalVector test(NumericMatrix x){
return upper_tri(x);
}')
x <- matrix(1:4, 4, 5)
test(x)

Example of desired output:

(x <- matrix(1:4, 4, 5))
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    1    1    1    1    1
#> [2,]    2    2    2    2    2
#> [3,]    3    3    3    3    3
#> [4,]    4    4    4    4    4
lower.tri(x)
#>       [,1]  [,2]  [,3]  [,4]  [,5]
#> [1,] FALSE FALSE FALSE FALSE FALSE
#> [2,]  TRUE FALSE FALSE FALSE FALSE
#> [3,]  TRUE  TRUE FALSE FALSE FALSE
#> [4,]  TRUE  TRUE  TRUE FALSE FALSE
@eddelbuettel
Copy link
Member

Ewww. Vote for disabling these until fixed. Doesn't even work for symmetric matrices.

@nathan-russell
Copy link
Contributor

I think I have a fix; just putting together unit tests now.

eddelbuettel added a commit that referenced this issue Jan 31, 2017
Fixes for upper_tri and lower_tri with unit tests (closes #641)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants