Learn R Programming

BigDataStatMeth (version 1.0.3)

bdCheckMatrix_hdf5: Check Matrix Suitability for Eigenvalue Decomposition with Spectra

Description

Checks whether a matrix stored in HDF5 format is suitable for eigenvalue decomposition using Spectra. The function verifies that the matrix is square and optionally checks for symmetry to recommend the best solver type.

Usage

bdCheckMatrix_hdf5(
  filename,
  group = NULL,
  dataset = NULL,
  check_symmetry = NULL,
  tolerance = NULL,
  sample_size = NULL
)

Value

A list with matrix properties and suitability assessment.

Arguments

filename

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

group

Character string. Path to the group containing the dataset.

dataset

Character string. Name of the dataset to check.

check_symmetry

Logical. Whether to check if the matrix is symmetric (default = TRUE).

tolerance

Numeric. Tolerance for symmetry checking (default = 1e-12).

sample_size

Integer. Number of elements to sample for large matrices (default = 1000).

Examples

Run this code
if (FALSE) {
# Check matrix suitability
check_result <- bdEigen_check_matrix("data.h5", "matrices", "my_matrix")

if (check_result$suitable_for_eigen) {
  # Use appropriate solver based on recommendation
  if (check_result$recommended_solver == "symmetric") {
    result <- bdEigen_hdf5("data.h5", "matrices", "my_matrix", which = "LA")
  } else {
    result <- bdEigen_hdf5("data.h5", "matrices", "my_matrix", which = "LM")
  }
} else {
  cat("Matrix is not suitable for eigendecomposition\n")
}
}

Run the code above in your browser using DataLab