Skip to content

lower_tri / upper_tri non-functional #641

@coatless

Description

@coatless

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions