apply: Apply Functions Over Sparse Matrix Margins

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Apply functions to (the cross-pairs of) the rows or columns of a sparse matrix.

Usage

1
2
3
4
5

Arguments

x, y

a matrix in simple_triplet_matrix-form or, one of x and y, of class matrix.

FUN

the name of the function to be applied.

...

optional arguments to FUN.

Details

colapply_simple_triplet_matrix temporarily expands each column of x to dense vector representation and applies the function specified in FUN.

crossapply_simple_triplet_matrix temporarily expands each cross-pair of columns of x (and y) to dense vector representation and applies the function specified in FUN.

Note that if y = NULL then only the entries in the lower triangle and the diagonal are computed, assuming that FUN is symmetric.

Value

A vector (matrix) of length (dimensionality) of the margin(s) used. The type depends on the result of FUN.

Note that the result of colapply_simple_triplet_matrix is never simplified to matrix.

Author(s)

Christian Buchta

See Also

apply for dense-on-dense computations.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10

Example output

  A B
1 1 2
2 0 1
3 0 0
        A         B 
0.3333333 1.0000000 
     A B
[1,] 1 2
[2,] 0 1
[3,] 0 0
          A   B
A 0.3333333 0.5
B 0.5000000 1.0

slam documentation built on Jan. 8, 2022, 5:08 p.m.

Related to apply in slam...