Converts a base R matrix or Matrix::dgeMatrix to an
adgeMatrix with the specified backend, policy, and precision.
This is the primary user-facing constructor for dense amatrix
objects.
Usage
adgeMatrix(
x,
mode = NULL,
backend = NULL,
preferred_backend = NULL,
policy = NULL,
precision = NULL
)Arguments
- x
A base R
matrix,dgeMatrix, or anydenseMatrixcoercible todgeMatrix.- mode
Single string shortcut accepted by
.amatrix_resolve_mode(); used to setbackend,policy, andprecisiontogether. PassNULLto use the individual arguments instead. In particular,mode = "fast"requests reduced precision and prefers an available fast-capable accelerator automatically, with CPU fallback when none is available.- backend
Alias for
preferred_backend; ignored whenpreferred_backendis non-NULL.- preferred_backend
Single string naming the preferred compute backend, e.g.
"cpu","mlx", or"metal".- policy
Single string; one of
"auto","cpu","mlx","metal","arrayfire","opencl".- precision
Single string;
"strict"for full double-precision accuracy or"fast"to allow reduced precision on GPU backends.
Examples
m <- matrix(1:6, nrow = 2)
A <- adgeMatrix(m)
A
#> An amatrix dense matrix [cpu|policy=auto|precision=strict]
#> 2 x 3 Matrix of class "adgeMatrix"
#> [,1] [,2] [,3]
#> [1,] 1 3 5
#> [2,] 2 4 6