View source: R/S3_diagonal.R View source: R/S3_arithmetic.R
| Ops.HDF5Matrix | R Documentation |
Standard R arithmetic operators applied element-wise to HDF5Matrix
objects stored on disk. Both operands must be HDF5Matrix objects
with identical dimensions.
## S3 method for class 'HDF5Matrix'
Ops(e1, e2)
e1 |
An |
e2 |
An |
Supported operators:
+Element-wise addition
-Element-wise subtraction
*Element-wise multiplication (Hadamard product)
/Element-wise division. Division by zero produces
NaN or Inf, matching base R behaviour.
All operations use block-wise processing and optional OpenMP parallelisation,
controlled via hdf5matrix_options.
Performance settings:
Global options set via hdf5matrix_options are applied.
For explicit control use the R6 methods directly:
A$add(B, paral = TRUE, threads = 4).
A new HDF5Matrix containing the result, stored in the same
HDF5 file as e1 under a temporary dataset name.
hdf5matrix_options for global performance settings,
HDF5Matrix for R6 methods with explicit parameters
fn <- tempfile(fileext = ".h5")
A_hdf5 <- hdf5_create_matrix(fn, "data/A", data = matrix(1:12, 3, 4))
B_hdf5 <- hdf5_create_matrix(fn, "data/B", data = matrix(2, 3, 4))
C <- A_hdf5 + B_hdf5
D <- A_hdf5 - B_hdf5
E <- A_hdf5 * B_hdf5
G <- A_hdf5 / B_hdf5
all.equal(as.matrix(C), matrix(1:12, 3, 4) + 2)
hdf5_close_all()
unlink(fn)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.