Learn R Programming

BigDataStatMeth (version 1.0.3)

bdWriteDiagonal_hdf5: Write Matrix Diagonal to HDF5

Description

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

Usage

bdWriteDiagonal_hdf5(diagonal, filename, group, dataset)

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)

Arguments

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.

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.

References

  • The HDF Group. (2000-2010). HDF5 User's Guide.

See Also

  • bdgetDiagonal_hdf5 for reading diagonal elements

  • bdCreate_hdf5_matrix for creating HDF5 matrices

Examples

Run this code
if (FALSE) {
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")
}
}

Run the code above in your browser using DataLab