This function implements the function Y := A * X + Y where X and Y may be
either native double-precision valued R matrices or numeric vectors, or
big.matrix objects, and A is a
daxpy(A=1, X, Y)
Optional numeric scalar value to scale the matrix
Requried to be either a native R
Optional native R
At least one of either
Y must be a
All values must be of type
double (the only type presently supported
by the bigalgebra package).
This function is rarely necessary to use directly since the bigalgebra
package defines standard arithmetic operations and scalar multiplication.
It is more efficient to use
daxpy directly when both scaling and
matrix addition are required, in which case both operations are performed
in one step.
The output value depends on the classes of input values
and on the value of the global option
Y are both big matrices, or
Y is missing,
big.matrix is returned. The returned
big.matrix is backed
by a temporary file mapping that will be deleted when the returned result is
garbage collected by R (see the examples).
Otherwise, a standard R matrix is returned. The dimensional shape of the output
is taken from
X. If input
X is dimensionless (that is, lacks a
dimension attribute), then the output is a column vector.
Michael J. Kane
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
require(bigmemory) A = matrix(1, nrow=3, ncol=2) B = big.matrix(nrow=3, ncol=2, type='double', init=1) C = B + B # C is a new big matrix D = A + B # D defaults to a regular R matrix, to change this, set the option: # optons(bigalgebra.mixed_arithmetic_returns_R_matrix=FALSE) E = daxpy(A=1.0, X=B, Y=B) # Same kind of result as C print(C) print(D) print(E) # The C and E big.matrix file backings will be deleted when garbage collected: # (We enable debugging to see this explicitly) options(bigalgebra.DEBUG=TRUE) rm(C,E) gc()