bdgetDiagonal_hdf5

HDF5_ALGEBRA

1 Description

Retrieves the diagonal elements from a matrix stored in an HDF5 file.

2 Usage

bdgetDiagonal_hdf5(filename, group, dataset)

3 Arguments

Parameter Description
filename Character string. Path to the HDF5 file.
group Character string. Path to the group containing the dataset.
dataset Character string. Name of the dataset.

4 Value

Numeric vector containing diagonal elements.

5 Details

This function provides efficient access to matrix diagonal elements with: - Access features: - Direct diagonal access - Memory-efficient retrieval - Support for large matrices - Implementation features: - Safe HDF5 file operations - Memory-efficient implementation - Comprehensive error handling - Read-only access to files

The function opens the HDF5 file in read-only mode to ensure data safety.

6 Examples

Code
library(BigDataStatMeth)

# Create test matrix
X <- matrix(rnorm(100), 10, 10)
diag(X) <- 0.5

# Save to HDF5
bdCreate_hdf5_matrix("test.hdf5", X, "data", "matrix1",
                     overwriteFile = TRUE)

# Get diagonal
diag_elements <- bdgetDiagonal_hdf5("test.hdf5", "data", "matrix1")
print(diag_elements)

# Cleanup
if (file.exists("test.hdf5")) {
  file.remove("test.hdf5")
}

7 See Also