bdWriteDiagonal_hdf5

bdWriteDiagonal_hdf5

HDF5_ALGEBRA

1 Description

Updates the diagonal elements of a matrix stored in an HDF5 file.

2 Usage

bdWriteDiagonal_hdf5(diagonal, filename, group, dataset)

3 Arguments

Parameter Description
diagonal Numeric vector. New diagonal elements to write.
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 to modify.

4 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 diagonal elements written (group/dataset)

5 Details

This function provides efficient diagonal modification capabilities with: - Write features: - Direct diagonal access - Type checking and validation - Support for large matrices - Implementation features: - Safe HDF5 file operations - Memory-efficient implementation - Comprehensive error handling - Type conversion support

The function validates input types and dimensions before modification.

6 Examples

Code
library(BigDataStatMeth)

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

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

# Create new diagonal
new_diag <- seq(1, 10)

# Update diagonal
bdWriteDiagonal_hdf5(new_diag, "test.hdf5", "data", "matrix1")

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

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

7 See Also