diag: Extract or construct a diagonal for HDF5Matrix

View source: R/S3_matvec.R

diagR Documentation

Extract or construct a diagonal for HDF5Matrix

Description

Overrides base::diag() to dispatch on HDF5Matrix objects. For plain R matrices/vectors the call is forwarded to base::diag().

When x is an HDF5Matrix, extracts the diagonal as an in-memory numeric vector (length = min(nrow, ncol)).

Usage

diag(x, ...)

## Default S3 method:
diag(x, nrow, ncol, names = TRUE, ...)

## S3 method for class 'HDF5Matrix'
diag(x, ...)

Arguments

x

An HDF5Matrix or any object accepted by base::diag().

...

Ignored.

nrow

Passed to base::diag() for non-HDF5Matrix objects.

ncol

Passed to base::diag() for non-HDF5Matrix objects.

names

Passed to base::diag() for non-HDF5Matrix objects.

Value

For HDF5Matrix: numeric vector of diagonal elements. For plain R objects: result of base::diag().

See Also

diag


BigDataStatMeth documentation built on May 15, 2026, 1:07 a.m.