({{, SYMV[ul,α,a,x,β,y] 
computes the symmetric matrix-vector multiplication α a.x+β y and resets y to the result.}})

OpenersNotesSection(Spacer1)Details

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

The following arguments must be given:

The matrix is assumed symmetric, and only the upper or lower triangular part of a is used.

The upper/lower triangular string ul may be specified as:

Dimensions of the matrix and vector arguments must be such that the dot product and addition are well defined.

OpenersPrimaryExamplesSection(Spacer1)Examples  (10)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Load the BLAS package:

Needs["LinearAlgebra`BLAS`"]

Compute a.x+2y and save it in y:

y={-2,1};
a={{1,3},{3,4}};
x={1,2};
SYMV["U",1,a,x,2,y];
y

OpenersExampleSection1(Spacer1)Scope  (4)

Real symmetric matrix and vectors:

y={2.3,1.2,3.9};
a={{2.1,0,1.4},{3.5,2.4,0.4},{0,2.7,1.3}};
x={0,1.2,-1.3};
SYMV["U",2,a,x,1,y];
y

Complex symmetric matrix and vectors:

y={2.3+3.I,1.2 I};
a={{2.1,1.4 I},{1.4 I,0.4}};
x={1.2,-1.3-2.I};
SYMV["U",2,a,x,1,y];
y

Arbitrary-precision symmetric matrix and vectors:

y={-2`20,1};
a={{1`20,3},{3,4}};
x={1`20,2};
SYMV["U",-1,a,x,2,y];
y

Symbolic symmetric matrix and vectors:

y={y1,y2};
a={{m11,m12},{m12,m22}};
x={x1,x2};
SYMV["U",α,a,x,β,y];
y

OpenersExampleSection3(Spacer1)Properties & Relations  (3)

SYMV["U",α,a,x,β,y] is equivalent to y=α a.x+β y if a is symmetric:

y=y1=RandomReal[1,{5}];
a=RandomReal[1,{5,5}]; 
a=(a+Transpose[a])/2.; (* symmetrize a *)
x=RandomReal[1,{5}];
SYMV["U",3,a,x,-2,y];
y==3 a.x-2 y1

For a symmetric matrix, using the upper or lower triangular part generally produces the same result:

y = y1= {v,w};
x={s,t};
a={{1,2},{2,1}};
SYMV["U",α,a,x,β,y]
y

SYMV["L",α,a,x,β,y1]
y1

SYMV works with a non-symmetric matrices:

y=yU=yL=RandomReal[1,{5}];
x=RandomReal[1,{5}];
a=RandomReal[1,{5,5}];
SYMV["U",3,a,x,-2,yU];
yU

However, the upper and lower parts give different results:

SYMV["L",3,a,x,-2,yL];
yL

The effective computation of yU is the following:

sa=Block[{lta=LowerTriangularize[a,-1]},lta+Transpose[lta]+DiagonalMatrix[Diagonal[a]]];
yU==3 sa.x-2 y

OpenersExampleSection4(Spacer1)Possible Issues  (2)

The last argument must be a symbol:

a={{1,3},{3,4}};
x={1,2};
SYMV["U",1,a,x,2,{1,2}]

The last argument must be initialized to a vector:

Clear[y];
a={{1,3},{3,4}};
x={1,2};
SYMV["U",1,a,x,2,y]

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