Learn R Programming

BigDataStatMeth (version 2.0.3)

bdpseudoinv_hdf5: Compute Matrix Pseudoinverse (HDF5-Stored)

Description

Computes the Moore-Penrose pseudoinverse of a matrix stored in HDF5 format and writes the result back to HDF5.

Usage

bdpseudoinv_hdf5(
  filename,
  group,
  dataset,
  outgroup = NULL,
  outdataset = NULL,
  overwrite = NULL,
  threads = NULL
)

Value

List with components. If an error occurs, all string values are returned as empty strings (""):

fn

Character string with the HDF5 filename

ds

Character string with the full dataset path to the pseudoinverse matrix (group/dataset)

Arguments

filename

String. Path to the HDF5 file.

group

String. Group containing the input matrix.

dataset

String. Dataset name for the input matrix.

outgroup

Optional string. Output group name (defaults to "PseudoInverse").

outdataset

Optional string. Output dataset name (defaults to input dataset name).

overwrite

Logical. Whether to overwrite existing results.

threads

Optional integer. Number of threads for parallel computation.

Details

This function reads the complete input dataset into memory, computes the pseudoinverse via a direct LAPACK SVD, and writes the full result to HDF5. The computation is HDF5-backed for input and output, but it is not block-wise: both the input matrix and its pseudoinverse must fit in available RAM during the computation. For matrices that exceed available memory, this function is not currently suitable.

Key features:

  • HDF5 Integration:

    • Reads the complete input matrix in a single call

    • Direct output to HDF5 format

  • Implementation Features:

    • SVD-based computation via direct LAPACK calls

    • Parallel processing support for the singular-value scaling step

    • Flexible output options

The function handles:

  • Data validation

  • Error handling

  • HDF5 file operations

References

  • Golub, G. H., & Van Loan, C. F. (2013). Matrix Computations, 4th Edition. Johns Hopkins University Press.

  • The HDF Group. (2000-2010). HDF5 User's Guide.

See Also

  • bdpseudoinv for in-memory computation

  • bdCreate_hdf5_matrix for creating HDF5 matrices

Examples

Run this code
# \donttest{
    fn <- tempfile(fileext = ".h5")
    X <- matrix(c(1,2,3,2,4,6), 2, 3)
    hdf5_create_matrix(fn, "data/X", data = X)

    bdpseudoinv_hdf5(filename = fn,
                     group = "data",
                     dataset = "X",
                     outgroup = "results",
                     outdataset = "X_pinv",
                     overwrite = TRUE)
    hdf5_close_all()
    unlink(fn)
# }

Run the code above in your browser using DataLab