[linalg.algs.blas2]

# 29 Numerics library [[numerics]](./#numerics)

## 29.9 Basic linear algebra algorithms [[linalg]](linalg#algs.blas2)

### 29.9.14 BLAS 2 algorithms [linalg.algs.blas2]

#### [29.9.14.1](#gemv) General matrix-vector product [[linalg.algs.blas2.gemv]](linalg.algs.blas2.gemv)

[1](#gemv-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14218)

[*Note [1](#gemv-note-1)*:

These functions correspond to the BLAS function xGEMV[.](#gemv-1.sentence-1)

â *end note*]

[2](#gemv-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14223)

The following elements apply to all functions in [[linalg.algs.blas2.gemv]](#gemv "29.9.14.1 General matrix-vector product")[.](#gemv-2.sentence-1)

[3](#gemv-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14226)

*Mandates*: 

- [(3.1)](#gemv-3.1)

*possibly-multipliable*<decltype(A), decltype(x), decltype(y)>() is true, and

- [(3.2)](#gemv-3.2)

*possibly-addable*<decltype(x), decltype(y), decltype(z)>() is true for those overloads that take a z parameter[.](#gemv-3.sentence-1)

[4](#gemv-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14237)

*Preconditions*: 

- [(4.1)](#gemv-4.1)

*multipliable*(A,x,y) is true, and

- [(4.2)](#gemv-4.2)

*addable*(x,y,z) is true for those overloads that take a z parameter[.](#gemv-4.sentence-1)

[5](#gemv-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14246)

*Complexity*: O(x.extent(0)ÃA.extent(1))[.](#gemv-5.sentence-1)

[ð](#lib:matrix_vector_product)

`template<[in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec>
  void matrix_vector_product(InMat A, InVec x, OutVec y);
template<class ExecutionPolicy, [in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec>
  void matrix_vector_product(ExecutionPolicy&& exec, InMat A, InVec x, OutVec y);
`

[6](#gemv-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14259)

These functions perform an overwriting matrix-vector product[.](#gemv-6.sentence-1)

[7](#gemv-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14262)

*Effects*: Computes y=Ax[.](#gemv-7.sentence-1)

[*Example [1](#gemv-example-1)*: constexpr size_t num_rows = 5;constexpr size_t num_cols = 6;

// y = 3.0 * A * xvoid scaled_matvec_1(mdspan<double, extents<size_t, num_rows, num_cols>> A,
 mdspan<double, extents<size_t, num_cols>> x, mdspan<double, extents<size_t, num_rows>> y) { matrix_vector_product(scaled(3.0, A), x, y);}// z = 7.0 times the transpose of A, times yvoid scaled_transposed_matvec(mdspan<double, extents<size_t, num_rows, num_cols>> A,
 mdspan<double, extents<size_t, num_rows>> y, mdspan<double, extents<size_t, num_cols>> z) { matrix_vector_product(scaled(7.0, transposed(A)), y, z);} â *end example*]

[ð](#lib:matrix_vector_product_)

`  template<[in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec2, [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec>
    void matrix_vector_product(InMat A, InVec1 x, InVec2 y, OutVec z);
  template<class ExecutionPolicy,
           [in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec2, [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec>
    void matrix_vector_product(ExecutionPolicy&& exec,
                               InMat A, InVec1 x, InVec2 y, OutVec z);
`

[8](#gemv-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14297)

These functions perform an updating matrix-vector product[.](#gemv-8.sentence-1)

[9](#gemv-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14300)

*Effects*: Computes z=y+Ax[.](#gemv-9.sentence-1)

[10](#gemv-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14304)

*Remarks*: z may alias y[.](#gemv-10.sentence-1)

[*Example [2](#gemv-example-2)*: // y = 3.0 * A * x + 2.0 * yvoid scaled_matvec_2(mdspan<double, extents<size_t, num_rows, num_cols>> A,
 mdspan<double, extents<size_t, num_cols>> x, mdspan<double, extents<size_t, num_rows>> y) { matrix_vector_product(scaled(3.0, A), x, scaled(2.0, y), y);} â *end example*]

#### [29.9.14.2](#symv) Symmetric matrix-vector product [[linalg.algs.blas2.symv]](linalg.algs.blas2.symv)

[1](#symv-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14321)

[*Note [1](#symv-note-1)*:

These functions correspond to the BLAS functionsxSYMV and xSPMV[[bib]](bibliography#bib:blas2 "Bibliography")[.](#symv-1.sentence-1)

â *end note*]

[2](#symv-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14327)

The following elements apply to all functions in [[linalg.algs.blas2.symv]](#symv "29.9.14.2 Symmetric matrix-vector product")[.](#symv-2.sentence-1)

[3](#symv-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14330)

*Mandates*: 

- [(3.1)](#symv-3.1)

If InMat has layout_blas_packed layout,
then the layout's Triangle template argument has
the same type as the function's Triangle template argument;

- [(3.2)](#symv-3.2)

*compatible-static-extents*<decltype(A), decltype(A)>(0, 1) is true;

- [(3.3)](#symv-3.3)

*possibly-multipliable*<decltype(A), decltype(x), decltype(y)>() is true; and

- [(3.4)](#symv-3.4)

*possibly-addable*<decltype(x), decltype(y), decltype(z)>() is true for those overloads that take a z parameter[.](#symv-3.sentence-1)

[4](#symv-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14347)

*Preconditions*: 

- [(4.1)](#symv-4.1)

A.extent(0) equals A.extent(1),

- [(4.2)](#symv-4.2)

*multipliable*(A,x,y) is true, and

- [(4.3)](#symv-4.3)

*addable*(x,y,z) is true for those overloads that take a z parameter[.](#symv-4.sentence-1)

[5](#symv-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14359)

*Complexity*: O(x.extent(0)ÃA.extent(1))[.](#symv-5.sentence-1)

[ð](#lib:symmetric_matrix_vector_product)

`template<[in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec>
  void symmetric_matrix_vector_product(InMat A, Triangle t, InVec x, OutVec y);
template<class ExecutionPolicy,
         [in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec>
  void symmetric_matrix_vector_product(ExecutionPolicy&& exec,
                                       InMat A, Triangle t, InVec x, OutVec y);
`

[6](#symv-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14375)

These functions perform an overwriting symmetric matrix-vector product,
taking into account the Triangle parameter
that applies to the symmetric matrix A ([[linalg.general]](linalg.general "29.9.3 General"))[.](#symv-6.sentence-1)

[7](#symv-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14380)

*Effects*: Computes y=Ax[.](#symv-7.sentence-1)

[ð](#lib:symmetric_matrix_vector_product_)

`template<[in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec2, [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec>
  void symmetric_matrix_vector_product(InMat A, Triangle t, InVec1 x, InVec2 y, OutVec z);
template<class ExecutionPolicy,
         [in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec2, [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec>
  void symmetric_matrix_vector_product(ExecutionPolicy&& exec,
                                       InMat A, Triangle t, InVec1 x, InVec2 y, OutVec z);
`

[8](#symv-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14396)

These functions perform an updating symmetric matrix-vector product,
taking into account the Triangle parameter
that applies to the symmetric matrix A ([[linalg.general]](linalg.general "29.9.3 General"))[.](#symv-8.sentence-1)

[9](#symv-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14401)

*Effects*: Computes z=y+Ax[.](#symv-9.sentence-1)

[10](#symv-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14405)

*Remarks*: z may alias y[.](#symv-10.sentence-1)

#### [29.9.14.3](#hemv) Hermitian matrix-vector product [[linalg.algs.blas2.hemv]](linalg.algs.blas2.hemv)

[1](#hemv-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14412)

[*Note [1](#hemv-note-1)*:

These functions correspond to the BLAS functionsxHEMV and xHPMV[[bib]](bibliography#bib:blas2 "Bibliography")[.](#hemv-1.sentence-1)

â *end note*]

[2](#hemv-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14418)

The following elements apply to all functions in [[linalg.algs.blas2.hemv]](#hemv "29.9.14.3 Hermitian matrix-vector product")[.](#hemv-2.sentence-1)

[3](#hemv-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14421)

*Mandates*: 

- [(3.1)](#hemv-3.1)

If InMat has layout_blas_packed layout,
then the layout's Triangle template argument
has the same type as the function's Triangle template argument;

- [(3.2)](#hemv-3.2)

*compatible-static-extents*<decltype(A), decltype(A)>(0, 1) is true;

- [(3.3)](#hemv-3.3)

*possibly-multipliable*<decltype(A), decltype(x), decltype(y)>() is true; and

- [(3.4)](#hemv-3.4)

*possibly-addable*<decltype(x), decltype(y), decltype(z)>() is true for those overloads that take a z parameter[.](#hemv-3.sentence-1)

[4](#hemv-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14439)

*Preconditions*: 

- [(4.1)](#hemv-4.1)

A.extent(0) equals A.extent(1),

- [(4.2)](#hemv-4.2)

*multipliable*(A, x, y) is true, and

- [(4.3)](#hemv-4.3)

*addable*(x, y, z) is true for those overloads that take a z parameter[.](#hemv-4.sentence-1)

[5](#hemv-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14450)

*Complexity*: O(x.extent(0)ÃA.extent(1))[.](#hemv-5.sentence-1)

[ð](#lib:hermitian_matrix_vector_product)

`template<[in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec>
  void hermitian_matrix_vector_product(InMat A, Triangle t, InVec x, OutVec y);
template<class ExecutionPolicy,
         [in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec>
  void hermitian_matrix_vector_product(ExecutionPolicy&& exec,
                                       InMat A, Triangle t, InVec x, OutVec y);
`

[6](#hemv-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14465)

These functions perform an overwriting Hermitian matrix-vector product,
taking into account the Triangle parameter
that applies to the Hermitian matrix A ([[linalg.general]](linalg.general "29.9.3 General"))[.](#hemv-6.sentence-1)

[7](#hemv-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14470)

*Effects*: Computes y=Ax[.](#hemv-7.sentence-1)

[ð](#lib:hermitian_matrix_vector_product_)

`template<[in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec2, [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec>
  void hermitian_matrix_vector_product(InMat A, Triangle t, InVec1 x, InVec2 y, OutVec z);
template<class ExecutionPolicy,
         [in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec2, [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec>
  void hermitian_matrix_vector_product(ExecutionPolicy&& exec,
                                       InMat A, Triangle t, InVec1 x, InVec2 y, OutVec z);
`

[8](#hemv-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14486)

These functions perform an updating Hermitian matrix-vector product,
taking into account the Triangle parameter
that applies to the Hermitian matrix A ([[linalg.general]](linalg.general "29.9.3 General"))[.](#hemv-8.sentence-1)

[9](#hemv-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14491)

*Effects*: Computes z=y+Ax[.](#hemv-9.sentence-1)

[10](#hemv-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14495)

*Remarks*: z may alias y[.](#hemv-10.sentence-1)

#### [29.9.14.4](#trmv) Triangular matrix-vector product [[linalg.algs.blas2.trmv]](linalg.algs.blas2.trmv)

[1](#trmv-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14502)

[*Note [1](#trmv-note-1)*:

These functions correspond to the BLAS functionsxTRMV and xTPMV[[bib]](bibliography#bib:blas2 "Bibliography")[.](#trmv-1.sentence-1)

â *end note*]

[2](#trmv-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14508)

The following elements apply to all functions in [[linalg.algs.blas2.trmv]](#trmv "29.9.14.4 Triangular matrix-vector product")[.](#trmv-2.sentence-1)

[3](#trmv-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14511)

*Mandates*: 

- [(3.1)](#trmv-3.1)

If InMat has layout_blas_packed layout,
then the layout's Triangle template argument has
the same type as the function's Triangle template argument;

- [(3.2)](#trmv-3.2)

*compatible-static-extents*<decltype(A), decltype(A)>(0, 1) is true;

- [(3.3)](#trmv-3.3)

*compatible-static-extents*<decltype(A), decltype(y)>(0, 0) is true;

- [(3.4)](#trmv-3.4)

*compatible-static-extents*<decltype(A), decltype(x)>(0, 0) is true for those overloads that take an x parameter; and

- [(3.5)](#trmv-3.5)

*compatible-static-extents*<decltype(A), decltype(z)>(0, 0) is true for those overloads that take a z parameter[.](#trmv-3.sentence-1)

[4](#trmv-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14532)

*Preconditions*: 

- [(4.1)](#trmv-4.1)

A.extent(0) equals A.extent(1),

- [(4.2)](#trmv-4.2)

A.extent(0) equals y.extent(0),

- [(4.3)](#trmv-4.3)

A.extent(0) equals x.extent(0) for those overloads that take an x parameter, and

- [(4.4)](#trmv-4.4)

A.extent(0) equals z.extent(0) for those overloads that take a z parameter[.](#trmv-4.sentence-1)

[ð](#lib:triangular_matrix_vector_product)

`template<[in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, class DiagonalStorage, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec,
         [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec>
  void triangular_matrix_vector_product(InMat A, Triangle t, DiagonalStorage d, InVec x, OutVec y);
template<class ExecutionPolicy,
         [in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, class DiagonalStorage, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec,
         [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec>
  void triangular_matrix_vector_product(ExecutionPolicy&& exec,
                                        InMat A, Triangle t, DiagonalStorage d, InVec x, OutVec y);
`

[5](#trmv-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14559)

These functions perform
an overwriting triangular matrix-vector product,
taking into account the Triangle and DiagonalStorage parameters
that apply to the triangular matrix A ([[linalg.general]](linalg.general "29.9.3 General"))[.](#trmv-5.sentence-1)

[6](#trmv-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14565)

*Effects*: Computes y=Ax[.](#trmv-6.sentence-1)

[7](#trmv-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14569)

*Complexity*: O(x.extent(0)ÃA.extent(1))[.](#trmv-7.sentence-1)

[ð](#lib:triangular_matrix_vector_product_)

`template<[in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, class DiagonalStorage, [inout-vector](linalg.helpers.concepts#concept:inout-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutVec>
  void triangular_matrix_vector_product(InMat A, Triangle t, DiagonalStorage d, InOutVec y);
template<class ExecutionPolicy,
         [in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, class DiagonalStorage, [inout-vector](linalg.helpers.concepts#concept:inout-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutVec>
  void triangular_matrix_vector_product(ExecutionPolicy&& exec,
                                        InMat A, Triangle t, DiagonalStorage d, InOutVec y);
`

[8](#trmv-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14586)

These functions perform an in-place triangular matrix-vector product,
taking into account the Triangle and DiagonalStorage parameters
that apply to the triangular matrix A ([[linalg.general]](linalg.general "29.9.3 General"))[.](#trmv-8.sentence-1)

[*Note [2](#trmv-note-2)*:

Performing this operation in place hinders parallelization[.](#trmv-8.sentence-2)

However, other ExecutionPolicy specific optimizations,
such as vectorization, are still possible[.](#trmv-8.sentence-3)

â *end note*]

[9](#trmv-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14596)

*Effects*: Computes a vector yâ² such that yâ²=Ay,
and assigns each element of yâ² to the corresponding element of y[.](#trmv-9.sentence-1)

[10](#trmv-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14601)

*Complexity*: O(y.extent(0)ÃA.extent(1))[.](#trmv-10.sentence-1)

[ð](#lib:triangular_matrix_vector_product__)

`template<[in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, class DiagonalStorage,
         [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec2, [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec>
  void triangular_matrix_vector_product(InMat A, Triangle t, DiagonalStorage d,
                                        InVec1 x, InVec2 y, OutVec z);
template<class ExecutionPolicy, [in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, class DiagonalStorage,
         [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec2, [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec>
  void triangular_matrix_vector_product(ExecutionPolicy&& exec,
                                        InMat A, Triangle t, DiagonalStorage d,
                                        InVec1 x, InVec2 y, OutVec z);
`

[11](#trmv-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14620)

These functions perform an updating triangular matrix-vector product,
taking into account the Triangle and DiagonalStorage parameters
that apply to the triangular matrix A ([[linalg.general]](linalg.general "29.9.3 General"))[.](#trmv-11.sentence-1)

[12](#trmv-12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14625)

*Effects*: Computes z=y+Ax[.](#trmv-12.sentence-1)

[13](#trmv-13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14629)

*Complexity*: O(x.extent(0)ÃA.extent(1))[.](#trmv-13.sentence-1)

[14](#trmv-14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14633)

*Remarks*: z may alias y[.](#trmv-14.sentence-1)

#### [29.9.14.5](#trsv) Solve a triangular linear system [[linalg.algs.blas2.trsv]](linalg.algs.blas2.trsv)

[1](#trsv-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14640)

[*Note [1](#trsv-note-1)*:

These functions correspond to the BLAS functionsxTRSV and xTPSV[[bib]](bibliography#bib:blas2 "Bibliography")[.](#trsv-1.sentence-1)

â *end note*]

[2](#trsv-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14646)

The following elements apply to all functions in [[linalg.algs.blas2.trsv]](#trsv "29.9.14.5 Solve a triangular linear system")[.](#trsv-2.sentence-1)

[3](#trsv-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14649)

*Mandates*: 

- [(3.1)](#trsv-3.1)

If InMat has layout_blas_packed layout,
then the layout's Triangle template argument has
the same type as the function's Triangle template argument;

- [(3.2)](#trsv-3.2)

*compatible-static-extents*<decltype(A), decltype(A)>(0, 1) is true;

- [(3.3)](#trsv-3.3)

*compatible-static-extents*<decltype(A), decltype(b)>(0, 0) is true; and

- [(3.4)](#trsv-3.4)

*compatible-static-extents*<decltype(A), decltype(x)>(0, 0) is true for those overloads that take an x parameter[.](#trsv-3.sentence-1)

[4](#trsv-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14667)

*Preconditions*: 

- [(4.1)](#trsv-4.1)

A.extent(0) equals A.extent(1),

- [(4.2)](#trsv-4.2)

A.extent(0) equals b.extent(0), and

- [(4.3)](#trsv-4.3)

A.extent(0) equals x.extent(0) for those overloads that take an x parameter[.](#trsv-4.sentence-1)

[ð](#lib:triangular_matrix_vector_solve)

`  template<[in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, class DiagonalStorage,
           [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec, class BinaryDivideOp>
    void triangular_matrix_vector_solve(InMat A, Triangle t, DiagonalStorage d,
                                        InVec b, OutVec x, BinaryDivideOp divide);
  template<class ExecutionPolicy, [in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, class DiagonalStorage,
           [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec, class BinaryDivideOp>
    void triangular_matrix_vector_solve(ExecutionPolicy&& exec,
                                        InMat A, Triangle t, DiagonalStorage d,
                                        InVec b, OutVec x, BinaryDivideOp divide);
`

[5](#trsv-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14694)

These functions perform
a triangular solve,
taking into account the Triangle and DiagonalStorage parameters
that apply to the triangular matrix A ([[linalg.general]](linalg.general "29.9.3 General"))[.](#trsv-5.sentence-1)

[6](#trsv-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14700)

*Effects*: Computes a vector xâ² such that b=Axâ²,
and assigns each element of xâ² to the corresponding element of x[.](#trsv-6.sentence-1)

If no such xâ² exists,
then the elements of x are valid but unspecified[.](#trsv-6.sentence-2)

[7](#trsv-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14707)

*Complexity*: O(A.extent(1)Ãb.extent(0))[.](#trsv-7.sentence-1)

[ð](#lib:triangular_matrix_vector_solve_)

`template<[in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, class DiagonalStorage,
         [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec>
  void triangular_matrix_vector_solve(InMat A, Triangle t, DiagonalStorage d, InVec b, OutVec x);
`

[8](#trsv-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14720)

*Effects*: Equivalent to:triangular_matrix_vector_solve(A, t, d, b, x, divides<void>{});

[ð](#lib:triangular_matrix_vector_solve__)

`template<class ExecutionPolicy, [in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, class DiagonalStorage,
         [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, [out-vector](linalg.helpers.concepts#concept:out-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") OutVec>
  void triangular_matrix_vector_solve(ExecutionPolicy&& exec,
                                      InMat A, Triangle t, DiagonalStorage d, InVec b, OutVec x);
`

[9](#trsv-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14737)

*Effects*: Equivalent to:triangular_matrix_vector_solve(std::forward<ExecutionPolicy>(exec),
 A, t, d, b, x, divides<void>{});

[ð](#lib:triangular_matrix_vector_solve___)

`template<[in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, class DiagonalStorage,
         [inout-vector](linalg.helpers.concepts#concept:inout-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutVec, class BinaryDivideOp>
  void triangular_matrix_vector_solve(InMat A, Triangle t, DiagonalStorage d,
                                      InOutVec b, BinaryDivideOp divide);
template<class ExecutionPolicy, [in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, class DiagonalStorage,
         [inout-vector](linalg.helpers.concepts#concept:inout-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutVec, class BinaryDivideOp>
  void triangular_matrix_vector_solve(ExecutionPolicy&& exec,
                                      InMat A, Triangle t, DiagonalStorage d,
                                      InOutVec b, BinaryDivideOp divide);
`

[10](#trsv-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14760)

These functions perform an in-place triangular solve,
taking into account the Triangle and DiagonalStorage parameters
that apply to the triangular matrix A ([[linalg.general]](linalg.general "29.9.3 General"))[.](#trsv-10.sentence-1)

[*Note [2](#trsv-note-2)*:

Performing triangular solve in place hinders parallelization[.](#trsv-10.sentence-2)

However, other ExecutionPolicy specific optimizations,
such as vectorization, are still possible[.](#trsv-10.sentence-3)

â *end note*]

[11](#trsv-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14770)

*Effects*: Computes a vector xâ² such that b=Axâ²,
and assigns each element of xâ² to the corresponding element of b[.](#trsv-11.sentence-1)

If no such xâ² exists,
then the elements of b are valid but unspecified[.](#trsv-11.sentence-2)

[12](#trsv-12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14777)

*Complexity*: O(A.extent(1)Ãb.extent(0))[.](#trsv-12.sentence-1)

[ð](#lib:triangular_matrix_vector_solve____)

`template<[in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, class DiagonalStorage, [inout-vector](linalg.helpers.concepts#concept:inout-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutVec>
  void triangular_matrix_vector_solve(InMat A, Triangle t, DiagonalStorage d, InOutVec b);
`

[13](#trsv-13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14789)

*Effects*: Equivalent to:triangular_matrix_vector_solve(A, t, d, b, divides<void>{});

[ð](#lib:triangular_matrix_vector_solve_____)

`template<class ExecutionPolicy,
         [in-matrix](linalg.helpers.concepts#concept:in-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InMat, class Triangle, class DiagonalStorage, [inout-vector](linalg.helpers.concepts#concept:inout-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutVec>
  void triangular_matrix_vector_solve(ExecutionPolicy&& exec,
                                      InMat A, Triangle t, DiagonalStorage d, InOutVec b);
`

[14](#trsv-14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14806)

*Effects*: Equivalent to:triangular_matrix_vector_solve(std::forward<ExecutionPolicy>(exec),
 A, t, d, b, divides<void>{});

#### [29.9.14.6](#rank1) Rank-1 (outer product) update of a matrix [[linalg.algs.blas2.rank1]](linalg.algs.blas2.rank1)

[ð](#lib:matrix_rank_1_update)

`template<[in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec2, [inout-matrix](linalg.helpers.concepts#concept:inout-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutMat>
  void matrix_rank_1_update(InVec1 x, InVec2 y, InOutMat A);
template<class ExecutionPolicy, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec2, [inout-matrix](linalg.helpers.concepts#concept:inout-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutMat>
  void matrix_rank_1_update(ExecutionPolicy&& exec, InVec1 x, InVec2 y, InOutMat A);
`

[1](#rank1-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14826)

These functions perform a nonsymmetric nonconjugated rank-1 update[.](#rank1-1.sentence-1)

[*Note [1](#rank1-note-1)*:

These functions correspond to the BLAS functionsxGER (for real element types) andxGERU (for complex element types)[[bib]](bibliography#bib:blas2 "Bibliography")[.](#rank1-1.sentence-2)

â *end note*]

[2](#rank1-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14834)

*Mandates*: *possibly-multipliable*<InOutMat, InVec2, InVec1>() is true[.](#rank1-2.sentence-1)

[3](#rank1-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14839)

*Preconditions*: *multipliable*(A, y, x) is true[.](#rank1-3.sentence-1)

[4](#rank1-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14843)

*Effects*: Computes a matrix Aâ² such that Aâ²=A+xyT,
and assigns each element of Aâ² to the corresponding element of A[.](#rank1-4.sentence-1)

[5](#rank1-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14848)

*Complexity*: O(x.extent(0)Ãy.extent(0))[.](#rank1-5.sentence-1)

[ð](#lib:matrix_rank_1_update_)

`template<[in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec2, [inout-matrix](linalg.helpers.concepts#concept:inout-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutMat>
  void matrix_rank_1_update_c(InVec1 x, InVec2 y, InOutMat A);
template<class ExecutionPolicy, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec2, [inout-matrix](linalg.helpers.concepts#concept:inout-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutMat>
  void matrix_rank_1_update_c(ExecutionPolicy&& exec, InVec1 x, InVec2 y, InOutMat A);
`

[6](#rank1-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14862)

These functions perform a nonsymmetric conjugated rank-1 update[.](#rank1-6.sentence-1)

[*Note [2](#rank1-note-2)*:

These functions correspond to the BLAS functionsxGER (for real element types) andxGERC (for complex element types)[[bib]](bibliography#bib:blas2 "Bibliography")[.](#rank1-6.sentence-2)

â *end note*]

[7](#rank1-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14870)

*Effects*: 

- [(7.1)](#rank1-7.1)

For the overloads without an ExecutionPolicy argument,
equivalent to:matrix_rank_1_update(x, conjugated(y), A);

- [(7.2)](#rank1-7.2)

otherwise, equivalent to:matrix_rank_1_update(std::forward<ExecutionPolicy>(exec), x, conjugated(y), A);

#### [29.9.14.7](#symherrank1) Symmetric or Hermitian Rank-1 (outer product) update of a matrix [[linalg.algs.blas2.symherrank1]](linalg.algs.blas2.symherrank1)

[1](#symherrank1-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14889)

[*Note [1](#symherrank1-note-1)*:

These functions correspond to the BLAS functionsxSYR, xSPR, xHER, and xHPR[[bib]](bibliography#bib:blas2 "Bibliography")[.](#symherrank1-1.sentence-1)

They have overloads taking a scaling factor alpha,
because it would be impossible to express the updateA=AâxxT otherwise[.](#symherrank1-1.sentence-2)

â *end note*]

[2](#symherrank1-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14898)

The following elements apply to all functions in [[linalg.algs.blas2.symherrank1]](#symherrank1 "29.9.14.7 Symmetric or Hermitian Rank-1 (outer product) update of a matrix")[.](#symherrank1-2.sentence-1)

[3](#symherrank1-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14901)

*Mandates*: 

- [(3.1)](#symherrank1-3.1)

If InOutMat has layout_blas_packed layout,
then the layout's Triangle template argument has
the same type as the function's Triangle template argument;

- [(3.2)](#symherrank1-3.2)

*compatible-static-extents*<decltype(A), decltype(A)>(0, 1) is true; and

- [(3.3)](#symherrank1-3.3)

*compatible-static-extents*<decltype(A), decltype(x)>(0, 0) is true[.](#symherrank1-3.sentence-1)

[4](#symherrank1-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14916)

*Preconditions*: 

- [(4.1)](#symherrank1-4.1)

A.extent(0) equals A.extent(1), and

- [(4.2)](#symherrank1-4.2)

A.extent(0) equals x.extent(0)[.](#symherrank1-4.sentence-1)

[5](#symherrank1-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14925)

*Complexity*: O(x.extent(0)Ãx.extent(0))[.](#symherrank1-5.sentence-1)

[ð](#lib:symmetric_matrix_rank_1_update)

`template<class Scalar, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, [possibly-packed-inout-matrix](linalg.helpers.concepts#concept:possibly-packed-inout-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutMat, class Triangle>
  void symmetric_matrix_rank_1_update(Scalar alpha, InVec x, InOutMat A, Triangle t);
template<class ExecutionPolicy,
         class Scalar, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, [possibly-packed-inout-matrix](linalg.helpers.concepts#concept:possibly-packed-inout-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutMat, class Triangle>
  void symmetric_matrix_rank_1_update(ExecutionPolicy&& exec,
                                      Scalar alpha, InVec x, InOutMat A, Triangle t);
`

[6](#symherrank1-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14940)

These functions perform
a symmetric rank-1 update of the symmetric matrix A,
taking into account the Triangle parameter
that applies to A ([[linalg.general]](linalg.general "29.9.3 General"))[.](#symherrank1-6.sentence-1)

[7](#symherrank1-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14946)

*Effects*: Computes a matrix Aâ² such thatAâ²=A+Î±xxT, where the scalar Î± is alpha,
and assigns each element of Aâ² to the corresponding element of A[.](#symherrank1-7.sentence-1)

[ð](#lib:symmetric_matrix_rank_1_update_)

`template<[in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, [possibly-packed-inout-matrix](linalg.helpers.concepts#concept:possibly-packed-inout-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutMat, class Triangle>
  void symmetric_matrix_rank_1_update(InVec x, InOutMat A, Triangle t);
template<class ExecutionPolicy,
         [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, [possibly-packed-inout-matrix](linalg.helpers.concepts#concept:possibly-packed-inout-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutMat, class Triangle>
  void symmetric_matrix_rank_1_update(ExecutionPolicy&& exec, InVec x, InOutMat A, Triangle t);
`

[8](#symherrank1-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14963)

These functions perform
a symmetric rank-1 update of the symmetric matrix A,
taking into account the Triangle parameter
that applies to A ([[linalg.general]](linalg.general "29.9.3 General"))[.](#symherrank1-8.sentence-1)

[9](#symherrank1-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14969)

*Effects*: Computes a matrix Aâ² such that Aâ²=A+xxT and assigns each element of Aâ² to the corresponding element of A[.](#symherrank1-9.sentence-1)

[ð](#lib:hermitian_matrix_rank_1_update)

`template<class Scalar, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, [possibly-packed-inout-matrix](linalg.helpers.concepts#concept:possibly-packed-inout-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutMat, class Triangle>
  void hermitian_matrix_rank_1_update(Scalar alpha, InVec x, InOutMat A, Triangle t);
template<class ExecutionPolicy,
         class Scalar, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, [possibly-packed-inout-matrix](linalg.helpers.concepts#concept:possibly-packed-inout-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutMat, class Triangle>
  void hermitian_matrix_rank_1_update(ExecutionPolicy&& exec,
                                      Scalar alpha, InVec x, InOutMat A, Triangle t);
`

[10](#symherrank1-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14986)

These functions perform
a Hermitian rank-1 update of the Hermitian matrix A,
taking into account the Triangle parameter
that applies to A ([[linalg.general]](linalg.general "29.9.3 General"))[.](#symherrank1-10.sentence-1)

[11](#symherrank1-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L14992)

*Effects*: Computes Aâ² such thatAâ²=A+Î±xxH, where the scalar Î± is alpha,
and assigns each element of Aâ² to the corresponding element of A[.](#symherrank1-11.sentence-1)

[ð](#lib:hermitian_matrix_rank_1_update_)

`template<[in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, [possibly-packed-inout-matrix](linalg.helpers.concepts#concept:possibly-packed-inout-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutMat, class Triangle>
  void hermitian_matrix_rank_1_update(InVec x, InOutMat A, Triangle t);
template<class ExecutionPolicy,
         [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec, [possibly-packed-inout-matrix](linalg.helpers.concepts#concept:possibly-packed-inout-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutMat, class Triangle>
  void hermitian_matrix_rank_1_update(ExecutionPolicy&& exec, InVec x, InOutMat A, Triangle t);
`

[12](#symherrank1-12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L15009)

These functions perform
a Hermitian rank-1 update of the Hermitian matrix A,
taking into account the Triangle parameter
that applies to A ([[linalg.general]](linalg.general "29.9.3 General"))[.](#symherrank1-12.sentence-1)

[13](#symherrank1-13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L15015)

*Effects*: Computes a matrix Aâ² such that Aâ²=A+xxH and
assigns each element of Aâ² to the corresponding element of A[.](#symherrank1-13.sentence-1)

#### [29.9.14.8](#rank2) Symmetric and Hermitian rank-2 matrix updates [[linalg.algs.blas2.rank2]](linalg.algs.blas2.rank2)

[1](#rank2-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L15023)

[*Note [1](#rank2-note-1)*:

These functions correspond to the BLAS functionsxSYR2,xSPR2, xHER2 and xHPR2[[bib]](bibliography#bib:blas2 "Bibliography")[.](#rank2-1.sentence-1)

â *end note*]

[2](#rank2-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L15029)

The following elements apply to all functions in [[linalg.algs.blas2.rank2]](#rank2 "29.9.14.8 Symmetric and Hermitian rank-2 matrix updates")[.](#rank2-2.sentence-1)

[3](#rank2-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L15032)

*Mandates*: 

- [(3.1)](#rank2-3.1)

If InOutMat has layout_blas_packed layout,
then the layout's Triangle template argument has
the same type as the function's Triangle template argument;

- [(3.2)](#rank2-3.2)

*compatible-static-extents*<decltype(A), decltype(A)>(0, 1) is true; and

- [(3.3)](#rank2-3.3)

*possibly-multipliable*<decltype(A), decltype(x), decltype(y)>() is true[.](#rank2-3.sentence-1)

[4](#rank2-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L15047)

*Preconditions*: 

- [(4.1)](#rank2-4.1)

A.extent(0) equals A.extent(1), and

- [(4.2)](#rank2-4.2)

*multipliable*(A, x, y) is true[.](#rank2-4.sentence-1)

[5](#rank2-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L15056)

*Complexity*: O(x.extent(0)Ãy.extent(0))[.](#rank2-5.sentence-1)

[ð](#lib:symmetric_matrix_rank_2_update)

`template<[in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec2,
         [possibly-packed-inout-matrix](linalg.helpers.concepts#concept:possibly-packed-inout-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutMat, class Triangle>
  void symmetric_matrix_rank_2_update(InVec1 x, InVec2 y, InOutMat A, Triangle t);
template<class ExecutionPolicy, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec2,
         [possibly-packed-inout-matrix](linalg.helpers.concepts#concept:possibly-packed-inout-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutMat, class Triangle>
  void symmetric_matrix_rank_2_update(ExecutionPolicy&& exec,
                                      InVec1 x, InVec2 y, InOutMat A, Triangle t);
`

[6](#rank2-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L15072)

These functions perform
a symmetric rank-2 update of the symmetric matrix A,
taking into account the Triangle parameter
that applies to A ([[linalg.general]](linalg.general "29.9.3 General"))[.](#rank2-6.sentence-1)

[7](#rank2-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L15078)

*Effects*: Computes Aâ² such that Aâ²=A+xyT+yxT and
assigns each element of Aâ² to the corresponding element of A[.](#rank2-7.sentence-1)

[ð](#lib:hermitian_matrix_rank_2_update)

`template<[in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec2,
         [possibly-packed-inout-matrix](linalg.helpers.concepts#concept:possibly-packed-inout-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutMat, class Triangle>
  void hermitian_matrix_rank_2_update(InVec1 x, InVec2 y, InOutMat A, Triangle t);
template<class ExecutionPolicy, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec1, [in-vector](linalg.helpers.concepts#concept:in-vector "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InVec2,
         [possibly-packed-inout-matrix](linalg.helpers.concepts#concept:possibly-packed-inout-matrix "29.9.7.5 Argument concepts [linalg.helpers.concepts]") InOutMat, class Triangle>
  void hermitian_matrix_rank_2_update(ExecutionPolicy&& exec,
                                      InVec1 x, InVec2 y, InOutMat A, Triangle t);
`

[8](#rank2-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L15096)

These functions perform
a Hermitian rank-2 update of the Hermitian matrix A,
taking into account the Triangle parameter
that applies to A ([[linalg.general]](linalg.general "29.9.3 General"))[.](#rank2-8.sentence-1)

[9](#rank2-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L15102)

*Effects*: Computes Aâ² such that Aâ²=A+xyH+yxH and
assigns each element of Aâ² to the corresponding element of A[.](#rank2-9.sentence-1)
