library(BigDataStatMeth)
# Create test matrices
N <- 1000
M <- 1000
fn <- "test_temp.hdf5"
set.seed(555)
Y <- matrix(rnorm(N*M), N, M)
X <- matrix(rnorm(N), N, 1)
Ycp <- crossprod(Y)
# Compare with in-memory solution
resm <- bdSolve(Ycp, X)
resr <- solve(Ycp, X)
all.equal(resm, resr)
# Save matrices to HDF5
bdCreate_hdf5_matrix(filename = fn,
object = Ycp,
group = "data",
dataset = "A",
transp = FALSE,
overwriteFile = TRUE,
overwriteDataset = TRUE,
unlimited = FALSE)
bdCreate_hdf5_matrix(filename = fn,
object = X,
group = "data",
dataset = "B",
transp = FALSE,
overwriteFile = FALSE,
overwriteDataset = TRUE,
unlimited = FALSE)
# Solve using HDF5-stored matrices
bdSolve_hdf5(filename = fn,
groupA = "data",
datasetA = "A",
groupB = "data",
datasetB = "B",
outgroup = "Solved",
outdataset = "A_B",
overwrite = TRUE)
# Cleanup
if (file.exists(fn)) {
file.remove(fn)
}bdSolve_hdf5
bdSolve_hdf5
HDF5_ALGEBRA
1 Description
Solves the linear system AX = B where matrices A and B are stored in HDF5 format. The solution X is written back to the HDF5 file.
2 Usage
bdSolve_hdf5(filename, groupA, datasetA, groupB, datasetB, outgroup = NULL, outdataset = NULL, overwrite = NULL)3 Arguments
| Parameter | Description |
|---|---|
filename |
String. Path to the HDF5 file. |
groupA |
String. Group containing matrix A. |
datasetA |
String. Dataset name for matrix A. |
groupB |
String. Group containing matrix B. |
datasetB |
String. Dataset name for matrix B. |
outgroup |
Optional string. Output group name (defaults to “Solved”). |
outdataset |
Optional string. Output dataset name (defaults to “A_B”). |
overwrite |
Logical. Whether to overwrite existing results. |
4 Value
List with components. If an error occurs, all string values are returned as empty strings (““):
fn: Character string with the HDF5 filenameds: Character string with the full dataset path to the solution of the linear system (group/dataset)
5 Details
This function provides an HDF5-based implementation for solving large linear systems. Key features: - HDF5 Integration: - Efficient reading of input matrices - Memory-efficient processing - Direct output to HDF5 format - Implementation Features: - Automatic solver selection - Support for large matrices - Flexible output options - Memory-efficient processing
The function handles: - Data validation - Memory management - Error handling - HDF5 file operations
6 Examples
7 See Also
- bdSolve for in-memory matrix solving
- bdCreate_hdf5_matrix for creating HDF5 matrices