({{, AXPY[α,x,y] 
computes the vector y+αx and resets y to the result.}})

OpenersNotesSection(Spacer1)Details

To use AXPY, you first need to load the BLAS Package using (RefLink[Needs, paclet:ref/Needs])["LinearAlgebra`BLAS`"].

The following arguments must be given:

Dimensions of the vector arguments must be such that the addition is well defined.

OpenersPrimaryExamplesSection(Spacer1)Examples  (8)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Load the BLAS package:

Needs["LinearAlgebra`BLAS`"]

Compute y=2{1,2,3}+y:

y={-1,2,1};
AXPY[2,{1,2,3},y];
y

OpenersExampleSection1(Spacer1)Scope  (4)

Real vectors:

y={3.2,-1.6,2.9};
AXPY[2.2,{-1.5,-2.4,4.1},y];
y

Complex vectors:

z={1.2+0.4 I, 2.1-1.1 I};
AXPY[2.5,{-I,2.3},z];
z

Arbitrary-precision vectors:

y={-1`20,2,1};
AXPY[2`20,{1,2,3},y];
y

Symbolic vectors:

s={a,b,c};
AXPY[β,{d,e,f},s];
s

OpenersExampleSection3(Spacer1)Properties & Relations  (1)

AXPY[α,x,y] is equivalent to αx+y assigned to y:

y1=y=RandomReal[1,{5}];
x=RandomReal[1,{5}];
α=RandomReal[1];
AXPY[α,x,y];
y==y1+α x

OpenersExampleSection4(Spacer1)Possible Issues  (2)

The third argument must be a symbol:

AXPY[2,{1,2,3},{-1,2,1}]

If the third argument is not initialized, an error message is issued:

AXPY[2,{1,2,3},w]

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Basic Linear Algebra Subroutines, paclet:LowLevelLinearAlgebra/guide/BLASGuide])}})}})