bdCheckMatrix_hdf5

HDF5_IO_MANAGEMENT

1 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.

2 Usage

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

3 Arguments

Parameter Description
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).

4 Value

A list with matrix properties and suitability assessment.

5 Examples

Code
# 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")
}