Learn R Programming

BigDataStatMeth (version 1.0.3)

bdQR_hdf5: QR Decomposition for HDF5-Stored Matrices

Description

Computes the QR decomposition of a matrix stored in an HDF5 file, factoring it into a product A = QR where Q is an orthogonal matrix and R is an upper triangular matrix. Results are stored back in the HDF5 file.

Usage

bdQR_hdf5(
  filename,
  group,
  dataset,
  outgroup = NULL,
  outdataset = NULL,
  thin = NULL,
  block_size = 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_Q

Character string with the full dataset path to the Q matrix (orthogonal matrix). Results are written to the HDF5 file as "Q.'outdataset'" within the specified group

ds_R

Character string with the full dataset path to the R matrix (upper triangular matrix). Results are written to the HDF5 file as "R.'outdataset'" within the specified group

Arguments

filename

Character string. Path to the HDF5 file containing the input matrix.

group

Character string. Path to the group containing the input dataset.

dataset

Character string. Name of the input dataset to decompose.

outgroup

Character string. Optional output group path where results will be stored. If not provided, results are stored in <input_group>/QRDec.

outdataset

Character string. Optional base name for output datasets. Results will be stored as Q.'outdataset' and R.'outdataset'.

thin

Logical. If TRUE, computes the reduced (thin) QR decomposition. If FALSE (default), computes the full decomposition.

block_size

Integer. Optional block size for blocked computation.

overwrite

Logical. If TRUE, allows overwriting existing datasets. Default is FALSE.

threads

Integer. Optional number of threads for parallel computation. If NULL, uses all available threads.

Details

This function performs QR decomposition on large matrices stored in HDF5 format, which is particularly useful for matrices too large to fit in memory. Features include:

  • Support for both thin and full QR decomposition

  • Blocked computation for improved performance

  • Parallel processing capabilities

  • Flexible output location specification

  • Optional overwriting of existing datasets

See Also

bdQR for QR decomposition of in-memory matrices

Examples

Run this code
if (FALSE) {
# Create a sample HDF5 file with a matrix
library(rhdf5)
A <- matrix(rnorm(1000), 100, 10)
h5createFile("example.h5")
h5write(A, "example.h5", "mygroup/mymatrix")

# Compute QR decomposition
bdQR_hdf5("example.h5", "mygroup", "mymatrix",
          outgroup = "mygroup/results",
          outdataset = "qr_result",
          thin = TRUE)
}

Run the code above in your browser using DataLab