algebra.RdConvert between persistence landscapes and their vectorizations, and perform linear algebra on vectorized persistence landscapes.
pl_t(pl)
pl_to_vector(pl, num_levels = pl_num_levels(pl))
pl_to_matrix(...)
pl_from_vector(x, t_vals = NULL, drop_levels = FALSE)
pl_from_matrix(x, t_vals = NULL, drop_levels = FALSE)A persistence landscape as returned by pl_new().
Number of levels to vectorize; may me more or less than
pl_num_levels(pl).
Persistence landscapes or lists of persistence landscapes.
A numeric vector, optionally with an attribute "t_vals" whose
length divides that of x, but with no other attributes.
A numeric vector of equally-spaced values assumed to be the grid support of a discrete persistence landscape.
Logical; whether to omit levels that are empty in all PLs.
pl_t() returns a numeric vector containing the grid of a
discrete persistence landscape. pl_to_vector() returns a numeric
vector with a "t_vals" attribute to reconstruct the discrete
landscape. pl_to_matrix() returns a matrix of such vectorizations.
pl_from_vector() returns a persistence landscape with class
"Rcpp_PersistenceLandscape", and pl_from_matrix() returns a list of
such persistence landscapes.
pl_t() extracts the common grid of \(t\)-values, discretizing
exact landscapes on the fly.
pl_to_vector() pad/truncates levels and flattens a persistence landscape to a
numeric vector; the grid is stored in the "t_vals" attribute.
pl_to_matrix() – standardizes persistence landscapes by coordinating
resolution, limits, and level count across multiple landscapes and then bind
their vectorizations row-wise into a matrix (grid in "t_vals" attribute).
pl_from_vector() rebuilds one landscape from a flattened vector + grid,
optionally dropping empty levels.
pl_from_matrix() applies pl_from_vector() row-wise to turn a matrix
back into a list of landscapes.
arithmetic, analysis, inference for other landscape functions.
par(mfrow = c(2L, 2L), mar = rep(.5, 4))
# example PLs
x <- tdaunif::sample_klein_flat(60, ar = 2)
pd <- ripserr::vietoris_rips(x, dim = 1L, threshold = 2)
#> Warning: `dim` parameter has been deprecated; use `max_dim` instead.
pl_e <- pl_new(pd, degree = 1L, exact = TRUE)
pl_d <- pl_new(pd, degree = 1L, exact = FALSE, xmax = 2, xby = 0.05)
plot(pl_e, xaxt = "n", yaxt = "n")
plot(pl_d, xaxt = "n", yaxt = "n")
# vectorize PLs
vec_e <- pl_to_matrix(pl_e)
#> Error: New limits do not contain the support of this PL.
vec_d <- pl_to_matrix(pl_d)
length(vec_e)
#> Error: object 'vec_e' not found
attributes(vec_e)
#> Error: object 'vec_e' not found
length(vec_d)
#> [1] 369
attributes(vec_d)
#> $dim
#> [1] 1 369
#>
#> $t_vals
#> [1] 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70
#> [16] 0.75 0.80 0.85 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45
#> [31] 1.50 1.55 1.60 1.65 1.70 1.75 1.80 1.85 1.90 1.95 2.00
#>
# de-vectorized PL
pl_e_ <- pl_from_matrix(vec_e)
#> Error: object 'vec_e' not found
plot(pl_e_, xaxt = "n", yaxt = "n")
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'pl_e_' not found
pl_d_ <- pl_from_matrix(vec_d)
plot(pl_d_, xaxt = "n", yaxt = "n")
par(mfrow = c(1L, 1L), mar = c(5.1, 4.1, 4.1, 2.1))
# vectorize a list
pl_lst <- list(pl_e, pl_discretize(pl_delimit(pl_e, xby = 0.05)), pl_d)
#> Error: New limits do not contain the support of this PL.
m <- pl_to_matrix(pl_lst)
#> Error: object 'pl_lst' not found
# de-vectorize the matrix
pl_from_matrix(m)
#> Error: object 'm' not found
pl_from_matrix(m, drop_levels = TRUE)
#> Error: object 'm' not found