\donttest{
tmp <- tempfile(fileext = ".h5")
M <- hdf5_create_matrix(tmp, "data/M", data = matrix(rnorm(10000), 100, 100))
d <- hdf5_create_matrix(tmp, "data/d", data = matrix(rnorm(10000), 100, 100))
R1 <- diag_op(M, d, "*") # scale each column
R2 <- M * d # same via operator auto-dispatch
hdf5_close_all()
unlink(tmp)
}diag_op
diag_op
MATRIX_UTILS
1 Description
Applies an element-wise binary operation between an HDF5Matrix and a diagonal vector (a 1-row or 1-column HDF5Matrix). The vector is broadcast across each row of the matrix.
The standard arithmetic operators (+, -, *, /) dispatch automatically to this function when one operand is a 1-row or 1-column HDF5Matrix.
2 Usage
diag_op(x, diag, op = "+", ...)3 Arguments
| Parameter | Description |
|---|---|
x |
An (matrix, ). |
diag |
An with one row or one column. |
op |
Character. One of , , , . |
outgroup |
Character or . HDF5 group where the result is stored. Default . |
outdataset |
Character or . Dataset name for the result. |
4 Value
A new .