Title: | Invertible Transforms for Matrices |
---|---|
Description: | Provides composable invertible transforms for (sparse) matrices. |
Authors: | Alex Hayes [aut, cre, cph] |
Maintainer: | Alex Hayes <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0.9000 |
Built: | 2024-11-01 03:08:49 UTC |
Source: | https://github.com/rohelab/invertiforms |
A convenience function to create DoubleCenter S4 objects, which are useful for simultaneously row and column centering a matrix.
DoubleCenter(A) ## S4 method for signature 'DoubleCenter,sparseMatrix' transform(iform, A) ## S4 method for signature 'DoubleCenter,sparseLRMatrix' inverse_transform(iform, A) ## S4 method for signature 'DoubleCenter,vsp_fa' inverse_transform(iform, A)
DoubleCenter(A) ## S4 method for signature 'DoubleCenter,sparseMatrix' transform(iform, A) ## S4 method for signature 'DoubleCenter,sparseLRMatrix' inverse_transform(iform, A) ## S4 method for signature 'DoubleCenter,vsp_fa' inverse_transform(iform, A)
A |
A matrix to transform. |
iform |
An Invertiform object describing the transformation. |
DoubleCenter()
creates a DoubleCenter object.
transform()
returns the transformed matrix,
typically as a sparseLRMatrix::sparseLRMatrix.
inverse_transform()
returns the inverse transformed matrix,
typically as a sparseLRMatrix::sparseLRMatrix in most cases.
When possible reduces the sparseLRMatrix::sparseLRMatrix to a
Matrix::sparseMatrix()
.
library(igraph) library(igraphdata) data("karate", package = "igraphdata") A <- get.adjacency(karate) iform <- DoubleCenter(A) A_tilde <- transform(iform, A) A_recovered <- inverse_transform(iform, A_tilde) all.equal(A, A_recovered)
library(igraph) library(igraphdata) data("karate", package = "igraphdata") A <- get.adjacency(karate) iform <- DoubleCenter(A) A_tilde <- transform(iform, A) A_recovered <- inverse_transform(iform, A_tilde) all.equal(A, A_recovered)
Row and column centering transformation
row_means
numeric.
col_means
numeric.
overall_mean
numeric.
Apply the inverse of an invertible transformation
inverse_transform(iform, A)
inverse_transform(iform, A)
iform |
An Invertiform object describing the transformation. |
A |
A matrix to inverse transform. |
The inverse transformed matrix.
An abstract S4 class representing an invertible transformation
A convenience function to create NormalizedLaplacian S4 objects, which are useful for finding the normalized Laplacian of the adjacency matrix of a graph.
NormalizedLaplacian(A) ## S4 method for signature 'NormalizedLaplacian,sparseMatrix' transform(iform, A) ## S4 method for signature 'NormalizedLaplacian,sparseMatrix' inverse_transform(iform, A)
NormalizedLaplacian(A) ## S4 method for signature 'NormalizedLaplacian,sparseMatrix' transform(iform, A) ## S4 method for signature 'NormalizedLaplacian,sparseMatrix' inverse_transform(iform, A)
A |
A matrix to transform. |
iform |
An Invertiform object describing the transformation. |
We define the normalized Laplacian of an
graph adjacency matrix
as
where
and
When denotes the present of an edge from node
to node
, which is fairly standard notation,
denotes the (absolute) out-degree of node
and
denotes the (absolute) in-degree
of node
.
Note that this documentation renders most clearly at https://rohelab.github.io/invertiforms/.
NormalizedLaplacian()
creates a NormalizedLaplacian object.
transform()
returns the transformed matrix,
typically as a Matrix.
inverse_transform()
returns the inverse transformed matrix,
typically as a Matrix.
library(igraph) library(igraphdata) data("karate", package = "igraphdata") A <- get.adjacency(karate) iform <- NormalizedLaplacian(A) L <- transform(iform, A) A_recovered <- inverse_transform(iform, L) all.equal(A, A_recovered)
library(igraph) library(igraphdata) data("karate", package = "igraphdata") A <- get.adjacency(karate) iform <- NormalizedLaplacian(A) L <- transform(iform, A) A_recovered <- inverse_transform(iform, L) all.equal(A, A_recovered)
Normalized graph Laplacian transformation
rsA
numeric.
csA
numeric.
Construct and use the Perturbed Laplacian
PerturbedLaplacian(A, tau = NULL) ## S4 method for signature 'PerturbedLaplacian,sparseMatrix' transform(iform, A) ## S4 method for signature 'PerturbedLaplacian,sparseLRMatrix' inverse_transform(iform, A)
PerturbedLaplacian(A, tau = NULL) ## S4 method for signature 'PerturbedLaplacian,sparseMatrix' transform(iform, A) ## S4 method for signature 'PerturbedLaplacian,sparseLRMatrix' inverse_transform(iform, A)
A |
A matrix to transform. |
tau |
Additive regularizer for row and column sums of |
iform |
An Invertiform object describing the transformation. |
We define the perturbed Laplacian of an
graph adjacency matrix
as
where
and
When denotes the present of an edge from node
to node
, which is fairly standard notation,
denotes the (absolute) out-degree of node
and
denotes the (absolute) in-degree
of node
.
Note that this documentation renders more clearly at https://rohelab.github.io/invertiforms/.
PerturbedLaplacian()
creates a PerturbedLaplacian object.
transform()
returns the transformed matrix,
typically as a Matrix.
inverse_transform()
returns the inverse transformed matrix,
typically as a Matrix.
library(igraph) library(igraphdata) data("karate", package = "igraphdata") A <- get.adjacency(karate) iform <- PerturbedLaplacian(A) L <- transform(iform, A) L ## Not run: A_recovered <- inverse_transform(iform, L) all.equal(A, A_recovered) ## End(Not run)
library(igraph) library(igraphdata) data("karate", package = "igraphdata") A <- get.adjacency(karate) iform <- PerturbedLaplacian(A) L <- transform(iform, A) L ## Not run: A_recovered <- inverse_transform(iform, L) all.equal(A, A_recovered) ## End(Not run)
Perturbed graph Laplacian transformation
tau
numeric.
rsA
numeric.
csA
numeric.
tau_choice
character.
Construct and use the Regularized Laplacian
RegularizedLaplacian(A, tau_row = NULL, tau_col = NULL) ## S4 method for signature 'RegularizedLaplacian,Matrix' transform(iform, A) ## S4 method for signature 'RegularizedLaplacian,matrix' transform(iform, A) ## S4 method for signature 'RegularizedLaplacian,sparseLRMatrix' transform(iform, A) ## S4 method for signature 'RegularizedLaplacian,Matrix' inverse_transform(iform, A) ## S4 method for signature 'RegularizedLaplacian,matrix' inverse_transform(iform, A) ## S4 method for signature 'RegularizedLaplacian,vsp_fa' inverse_transform(iform, A)
RegularizedLaplacian(A, tau_row = NULL, tau_col = NULL) ## S4 method for signature 'RegularizedLaplacian,Matrix' transform(iform, A) ## S4 method for signature 'RegularizedLaplacian,matrix' transform(iform, A) ## S4 method for signature 'RegularizedLaplacian,sparseLRMatrix' transform(iform, A) ## S4 method for signature 'RegularizedLaplacian,Matrix' inverse_transform(iform, A) ## S4 method for signature 'RegularizedLaplacian,matrix' inverse_transform(iform, A) ## S4 method for signature 'RegularizedLaplacian,vsp_fa' inverse_transform(iform, A)
A |
A matrix to transform. |
tau_row |
Additive regularizer for row sums of |
tau_col |
Additive regularizer for column sums of |
iform |
An Invertiform object describing the transformation. |
We define the regularized Laplacian of an
graph adjacency matrix
as
where
and
When denotes the present of an edge from node
to node
, which is fairly standard notation,
denotes the (absolute) out-degree of node
and
denotes the (absolute) in-degree
of node
. Then
is an additive
out-degree regularizer and
is an
additive in-degree regularizer.
Note that this documentation renders more clearly at https://rohelab.github.io/invertiforms/.
RegularizedLaplacian()
creates a RegularizedLaplacian object.
transform()
returns the transformed matrix,
typically as a Matrix.
inverse_transform()
returns the inverse transformed matrix,
typically as a Matrix.
library(igraph) library(igraphdata) data("karate", package = "igraphdata") A <- get.adjacency(karate) iform <- RegularizedLaplacian(A) L <- transform(iform, A) L A_recovered <- inverse_transform(iform, L) all.equal(A, A_recovered)
library(igraph) library(igraphdata) data("karate", package = "igraphdata") A <- get.adjacency(karate) iform <- RegularizedLaplacian(A) L <- transform(iform, A) L A_recovered <- inverse_transform(iform, L) all.equal(A, A_recovered)
Regularized graph Laplacian transformation
tau_row
numeric.
tau_col
numeric.
rsA
numeric.
csA
numeric.
tau_choice_row
character.
tau_choice_col
character.
Apply an invertible transformation
transform(iform, A)
transform(iform, A)
iform |
An Invertiform object describing the transformation. |
A |
A matrix to transform. |
The transformed matrix.