Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/wrappers.R View source: R/bigalgebra.R

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
double-precision valued `big.matrix`

objects, and A is a
scalar.

1 | ```
daxpy(A=1, X, Y)
``` |

`A` |
Optional numeric scalar value to scale the matrix |

`X` |
Requried to be either a native |

`Y` |
Optional native |

At least one of either `X`

or `Y`

must be a `big.matrix`

.
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 `X`

and `Y`

and on the value of the global option
`bigalgebra.mixed_arithmetic_returns_R_matrix`

.

If `X`

and `Y`

are both big matrices, or `Y`

is missing,
`options("bigalgebra.mixed_arithmetic_returns_R_matrix")`

is `FALSE`

,
then a `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

http://www.netlib.org/blas/daxpy.f

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()
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.