show.Rd
A methods::show()
S4 method for persistence landscape objects,
used for base::print()
.
# S4 method for Rcpp_PersistenceLandscape
show(object)
A PersistenceLandscape object.
Rcpp_PersistenceLandscape for the exported C++ class and
landscape()
for the R wrapper.
# double matrix
pl <- new(
PersistenceLandscape,
cbind(c(0, 0, 1, 2), c(1.5, 2.5, 3.5, 4.5)),
TRUE,
0, 10, .01
)
pl$isExact()
#> [1] TRUE
pl$xMin()
#> [1] 0
pl$xMax()
#> [1] 10
pl$xBy()
#> [1] 0.01
pl$getInternal()
#> [[1]]
#> [,1] [,2]
#> [1,] -Inf 0.00
#> [2,] 0.00 0.00
#> [3,] 1.25 1.25
#> [4,] 1.75 0.75
#> [5,] 2.25 1.25
#> [6,] 2.75 0.75
#> [7,] 3.25 1.25
#> [8,] 4.50 0.00
#> [9,] Inf 0.00
#>
#> [[2]]
#> [,1] [,2]
#> [1,] -Inf 0.00
#> [2,] 0.00 0.00
#> [3,] 0.75 0.75
#> [4,] 1.25 0.25
#> [5,] 1.75 0.75
#> [6,] 2.25 0.25
#> [7,] 2.75 0.75
#> [8,] 3.50 0.00
#> [9,] Inf 0.00
#>
#> [[3]]
#> [,1] [,2]
#> [1,] -Inf 0.00
#> [2,] 1.00 0.00
#> [3,] 1.25 0.25
#> [4,] 1.50 0.00
#> [5,] 2.00 0.00
#> [6,] 2.25 0.25
#> [7,] 2.50 0.00
#> [8,] Inf 0.00
#>
print(pl)
#> Persistence landscape (exact format) of 3 levels over (0,10)
summary(pl)
#> Internal representation: exact
#> Number of levels: 3
#> Representation limits: ( 0 , 4.5 )
#> Landscape range: ( 0 , 1.25 )
#> Magnitude: 4.187
#> Integral: 5.25
dim(pl$discretize()$getInternal())
#> [1] 3 1001 2
length(as.vector(pl))
#> [1] 3003
as.data.frame(pl)
#> level x fx
#> 1.1 1 -Inf 0.00
#> 1.2 1 0.00 0.00
#> 1.3 1 1.25 1.25
#> 1.4 1 1.75 0.75
#> 1.5 1 2.25 1.25
#> 1.6 1 2.75 0.75
#> 1.7 1 3.25 1.25
#> 1.8 1 4.50 0.00
#> 1.9 1 Inf 0.00
#> 2.1 2 -Inf 0.00
#> 2.2 2 0.00 0.00
#> 2.3 2 0.75 0.75
#> 2.4 2 1.25 0.25
#> 2.5 2 1.75 0.75
#> 2.6 2 2.25 0.25
#> 2.7 2 2.75 0.75
#> 2.8 2 3.50 0.00
#> 2.9 2 Inf 0.00
#> 3.1 3 -Inf 0.00
#> 3.2 3 1.00 0.00
#> 3.3 3 1.25 0.25
#> 3.4 3 1.50 0.00
#> 3.5 3 2.00 0.00
#> 3.6 3 2.25 0.25
#> 3.7 3 2.50 0.00
#> 3.8 3 Inf 0.00
pl2 <- pl$scale(2)
pl2$getInternal()
#> [[1]]
#> [,1] [,2]
#> [1,] -Inf 0.0
#> [2,] 0.00 0.0
#> [3,] 1.25 2.5
#> [4,] 1.75 1.5
#> [5,] 2.25 2.5
#> [6,] 2.75 1.5
#> [7,] 3.25 2.5
#> [8,] 4.50 0.0
#> [9,] Inf 0.0
#>
#> [[2]]
#> [,1] [,2]
#> [1,] -Inf 0.0
#> [2,] 0.00 0.0
#> [3,] 0.75 1.5
#> [4,] 1.25 0.5
#> [5,] 1.75 1.5
#> [6,] 2.25 0.5
#> [7,] 2.75 1.5
#> [8,] 3.50 0.0
#> [9,] Inf 0.0
#>
#> [[3]]
#> [,1] [,2]
#> [1,] -Inf 0.0
#> [2,] 1.00 0.0
#> [3,] 1.25 0.5
#> [4,] 1.50 0.0
#> [5,] 2.00 0.0
#> [6,] 2.25 0.5
#> [7,] 2.50 0.0
#> [8,] Inf 0.0
#>
pl3 <- pl$add(pl2)
pl3$getInternal()
#> [[1]]
#> [,1] [,2]
#> [1,] -Inf 0.00
#> [2,] 0.00 0.00
#> [3,] 1.25 3.75
#> [4,] 1.75 2.25
#> [5,] 2.25 3.75
#> [6,] 2.75 2.25
#> [7,] 3.25 3.75
#> [8,] 4.50 0.00
#> [9,] Inf 0.00
#>
#> [[2]]
#> [,1] [,2]
#> [1,] -Inf 0.00
#> [2,] 0.00 0.00
#> [3,] 0.75 2.25
#> [4,] 1.25 0.75
#> [5,] 1.75 2.25
#> [6,] 2.25 0.75
#> [7,] 2.75 2.25
#> [8,] 3.50 0.00
#> [9,] Inf 0.00
#>
#> [[3]]
#> [,1] [,2]
#> [1,] -Inf 0.00
#> [2,] 1.00 0.00
#> [3,] 1.25 0.75
#> [4,] 1.50 0.00
#> [5,] 2.00 0.00
#> [6,] 2.25 0.75
#> [7,] 2.50 0.00
#> [8,] Inf 0.00
#>
# integer matrix
pl <- new(
PersistenceLandscape,
cbind(c(0L, 0L, 1L, 2L), c(2L, 3L, 4L, 5L)),
TRUE,
0, 10, .01
)
pl$getInternal()
#> [[1]]
#> [,1] [,2]
#> [1,] -Inf 0.0
#> [2,] 0.0 0.0
#> [3,] 1.5 1.5
#> [4,] 2.0 1.0
#> [5,] 2.5 1.5
#> [6,] 3.0 1.0
#> [7,] 3.5 1.5
#> [8,] 5.0 0.0
#> [9,] Inf 0.0
#>
#> [[2]]
#> [,1] [,2]
#> [1,] -Inf 0.0
#> [2,] 0.0 0.0
#> [3,] 1.0 1.0
#> [4,] 1.5 0.5
#> [5,] 2.0 1.0
#> [6,] 2.5 0.5
#> [7,] 3.0 1.0
#> [8,] 4.0 0.0
#> [9,] Inf 0.0
#>
#> [[3]]
#> [,1] [,2]
#> [1,] -Inf 0.0
#> [2,] 1.0 0.0
#> [3,] 1.5 0.5
#> [4,] 2.0 0.0
#> [5,] 2.5 0.5
#> [6,] 3.0 0.0
#> [7,] Inf 0.0
#>
print(pl)
#> Persistence landscape (exact format) of 3 levels over (0,10)
# discrete landscape
pl <- new(
PersistenceLandscape,
cbind(c(0, 0, 1, 2), c(1.5, 2.5, 3.5, 4.5)),
FALSE,
0, 5, .5
)
pl$xBy()
#> [1] 0.5
pl$getInternal()
#> , , 1
#>
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11]
#> [1,] 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
#> [2,] 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
#> [3,] 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
#> [4,] 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
#>
#> , , 2
#>
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11]
#> [1,] 0 0.5 1.0 1.0 1.0 1.0 1.0 1 0.5 0 0
#> [2,] 0 0.5 0.5 0.5 0.5 0.5 0.5 0 0.0 0 0
#> [3,] 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0.0 0 0
#> [4,] 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0.0 0 0
#>
print(pl)
#> Persistence landscape (discrete format) of 4 levels over (0,5)
dim(pl$discretize()$getInternal())
#> Warning: PL is already discrete.
#> [1] 4 11 2
length(as.vector(pl))
#> Warning: PL is already discrete.
#> [1] 44
as.data.frame(pl)
#> level x fx
#> 1.1 1 0.0 0.0
#> 1.2 1 0.5 0.5
#> 1.3 1 1.0 1.0
#> 1.4 1 1.5 1.0
#> 2.1 2 2.0 1.0
#> 2.2 2 2.5 1.0
#> 2.3 2 3.0 1.0
#> 2.4 2 3.5 1.0
#> 3.1 3 4.0 0.5
#> 3.2 3 4.5 0.0
#> 3.3 3 5.0 0.0
#> 3.4 3 0.0 0.0
#> 4.1 4 0.5 0.5
#> 4.2 4 1.0 0.5
#> 4.3 4 1.5 0.5
#> 4.4 4 2.0 0.5
#> 5.1 5 2.5 0.5
#> 5.2 5 3.0 0.5
#> 5.3 5 3.5 0.0
#> 5.4 5 4.0 0.0
#> 6.1 6 4.5 0.0
#> 6.2 6 5.0 0.0
#> 6.3 6 0.0 0.0
#> 6.4 6 0.5 0.0
#> 7.1 7 1.0 0.0
#> 7.2 7 1.5 0.0
#> 7.3 7 2.0 0.0
#> 7.4 7 2.5 0.0
#> 8.1 8 3.0 0.0
#> 8.2 8 3.5 0.0
#> 8.3 8 4.0 0.0
#> 8.4 8 4.5 0.0
#> 9.1 9 5.0 0.0
#> 9.2 9 0.0 0.0
#> 9.3 9 0.5 0.0
#> 9.4 9 1.0 0.0
#> 10.1 10 1.5 0.0
#> 10.2 10 2.0 0.0
#> 10.3 10 2.5 0.0
#> 10.4 10 3.0 0.0
#> 11.1 11 3.5 0.0
#> 11.2 11 4.0 0.0
#> 11.3 11 4.5 0.0
#> 11.4 11 5.0 0.0
pl2 <- pl$scale(2)
pl2$isExact()
#> [1] FALSE
pl2$xBy()
#> [1] 0.5
pl2$getInternal()
#> , , 1
#>
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11]
#> [1,] 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
#> [2,] 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
#> [3,] 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
#> [4,] 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
#>
#> , , 2
#>
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11]
#> [1,] 0 1 2 2 2 2 2 2 1 0 0
#> [2,] 0 1 1 1 1 1 1 0 0 0 0
#> [3,] 0 0 0 0 0 0 0 0 0 0 0
#> [4,] 0 0 0 0 0 0 0 0 0 0 0
#>
show(pl2)
#> Persistence landscape (discrete format) of 4 levels over (0,5)
(pl3 <- pl$add(pl2))
#> Persistence landscape (discrete format) of 4 levels over (0,5)
pl3$getInternal()
#> , , 1
#>
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11]
#> [1,] 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
#> [2,] 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
#> [3,] 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
#> [4,] 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
#>
#> , , 2
#>
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11]
#> [1,] 0 1.5 3.0 3.0 3.0 3.0 3.0 3 1.5 0 0
#> [2,] 0 1.5 1.5 1.5 1.5 1.5 1.5 0 0.0 0 0
#> [3,] 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0.0 0 0
#> [4,] 0 0.0 0.0 0.0 0.0 0.0 0.0 0 0.0 0 0
#>
pl3$xBy()
#> [1] 0.5