From ae27623c007fff1b077136cc43b6ada1dbd4163b Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Fri, 17 Nov 2023 01:17:08 +0100 Subject: [PATCH] format synopsis --- source/numerics.tex | 2191 ++++++++++++------------------------------- 1 file changed, 607 insertions(+), 1584 deletions(-) diff --git a/source/numerics.tex b/source/numerics.tex index d049c339e9..04085dcecd 100644 --- a/source/numerics.tex +++ b/source/numerics.tex @@ -10406,1609 +10406,632 @@ \pnum Subclause \ref{linalg} defines basic linear algebra algorithms. The algorithms that access the elements of arrays -view those elements through \tcode{mdspan}\iref{mdspan}. +view those elements through \tcode{mdspan}\iref{views.multidim}. \rSec2[linalg.syn]{Header \tcode{} synopsis} \begin{codeblock} namespace std::linalg { -// [linalg.tags.order], storage order tags -struct column_major_t; -inline constexpr column_major_t column_major; -struct row_major_t; -inline constexpr row_major_t row_major; + // \ref{linalg.tags.order}, storage order tags + struct column_major_t; + inline constexpr column_major_t column_major; + struct row_major_t; + inline constexpr row_major_t row_major; -// [linalg.tags.triangle], triangle tags -struct upper_triangle_t; -inline constexpr upper_triangle_t upper_triangle; -struct lower_triangle_t; -inline constexpr lower_triangle_t lower_triangle; + // \ref{linalg.tags.triangle}, triangle tags + struct upper_triangle_t; + inline constexpr upper_triangle_t upper_triangle; + struct lower_triangle_t; + inline constexpr lower_triangle_t lower_triangle; -// [linalg.tags.diagonal], diagonal tags -struct implicit_unit_diagonal_t; -inline constexpr implicit_unit_diagonal_t implicit_unit_diagonal; -struct explicit_diagonal_t; -inline constexpr explicit_diagonal_t explicit_diagonal; + // \ref{linalg.tags.diagonal}, diagonal tags + struct implicit_unit_diagonal_t; + inline constexpr implicit_unit_diagonal_t implicit_unit_diagonal; + struct explicit_diagonal_t; + inline constexpr explicit_diagonal_t explicit_diagonal; -// [linalg.layout.packed], class template layout_blas_packed -template -class layout_blas_packed; + // \ref{linalg.layout.packed}, class template layout_blas_packed + template + class layout_blas_packed; -// [linalg.helpers], exposition-only helpers + // \ref{linalg.helpers}, exposition-only helpers -// [linalg.helpers.concepts], linear algebra argument concepts + // \ref{linalg.helpers.concepts}, linear algebra argument concepts + template + constexpr bool @\defexposconcept{is-mdspan}@ = @\seebelow@; // \expos -template -constexpr bool is-mdspan = see below; // exposition only + template + concept @\defexposconcept{in-vector}@ = @\seebelow@; // \expos -template -concept in-vector = see below; // exposition only + template + concept @\defexposconcept{out-vector}@ = @\seebelow@; // \expos -template -concept out-vector = see below; // exposition only + template + concept @\defexposconcept{inout-vector}@ = @\seebelow@; // \expos -template -concept inout-vector = see below; // exposition only + template + concept @\defexposconcept{in-matrix}@ = @\seebelow@; // \expos -template -concept in-matrix = see below; // exposition only + template + concept @\defexposconcept{out-matrix}@ = @\seebelow@; // \expos -template -concept out-matrix = see below; // exposition only + template + concept @\defexposconcept{inout-matrix}@ = @\seebelow@; // \expos -template -concept inout-matrix = see below; // exposition only + template + concept @\defexposconcept{possibly-packed-inout-matrix}@ = @\seebelow@; // \expos -template -concept possibly-packed-inout-matrix = see below; // exposition only + template + concept @\defexposconcept{in-object}@ = @\seebelow@; // \expos -template -concept in-object = see below; // exposition only + template + concept @\defexposconcept{out-object}@ = @\seebelow@; // \expos -template -concept out-object = see below; // exposition only + template + concept @\defexposconcept{inout-object}@ = @\seebelow@; // \expos -template -concept inout-object = see below; // exposition only - -// [linalg.scaled], scaled in-place transformation - -// [linalg.scaled.scaledaccessor], class template scaled_accessor -template -class scaled_accessor; - -// [linalg.scaled.scaled], function template scaled -template -constexpr auto scaled( - ScalingFactor alpha, - mdspan x); - -// [linalg.conj], conjugated in-place transformation - -// [linalg.conj.conjugatedaccessor], class template conjugated_accessor -template -class conjugated_accessor; - -// [linalg.conj.conjugated], function template conjugated -template -constexpr auto conjugated( - mdspan a); - -// [linalg.transp], transpose in-place transformation - -// [linalg.transp.layout.transpose], class template layout_transpose -template -class layout_transpose; - -// [linalg.transp.transposed], function template transposed -template -constexpr auto transposed( - mdspan a); - -// [linalg.conjtransposed], -// conjugated transpose in-place transformation -template -constexpr auto conjugate_transposed( - mdspan a); - -// [linalg.algs.blas1], BLAS 1 algorithms - -// [linalg.algs.blas1.givens], Givens rotations - -// [linalg.algs.blas1.givens.lartg], compute Givens rotation - -template -struct setup_givens_rotation_result { - Real c; - Real s; - Real r; -}; -template -struct setup_givens_rotation_result> { - Real c; - complex s; - complex r; -}; - -template -setup_givens_rotation_result -setup_givens_rotation(Real a, Real b) noexcept; - -template -setup_givens_rotation_result> -setup_givens_rotation(complex a, complex b) noexcept; - -// [linalg.algs.blas1.givens.rot], apply computed Givens rotation -template -void apply_givens_rotation( - InOutVec1 x, - InOutVec2 y, - Real c, - Real s); -template -void apply_givens_rotation( - ExecutionPolicy&& exec, - InOutVec1 x, - InOutVec2 y, - Real c, - Real s); -template -void apply_givens_rotation( - InOutVec1 x, - InOutVec2 y, - Real c, - complex s); -template -void apply_givens_rotation( - ExecutionPolicy&& exec, - InOutVec1 x, - InOutVec2 y, - Real c, - complex s); - -// [linalg.algs.blas1.swap], swap elements -template -void swap_elements(InOutObj1 x, - InOutObj2 y); -template -void swap_elements(ExecutionPolicy&& exec, - InOutObj1 x, - InOutObj2 y); - -// [linalg.algs.blas1.scal], multiply elements by scalar -template -void scale(Scalar alpha, - InOutObj x); -template -void scale(ExecutionPolicy&& exec, - Scalar alpha, - InOutObj x); - -// [linalg.algs.blas1.copy], copy elements -template -void copy(InObj x, - OutObj y); -template -void copy(ExecutionPolicy&& exec, - InObj x, - OutObj y); - -// [linalg.algs.blas1.add], add elementwise -template -void add(InObj1 x, - InObj2 y, - OutObj z); -template -void add(ExecutionPolicy&& exec, - InObj1 x, - InObj2 y, - OutObj z); - -// [linalg.algs.blas1.dot], -// dot product of two vectors - -// [linalg.algs.blas1.dot.dotu], -// nonconjugated dot product of two vectors -template -T dot(InVec1 v1, - InVec2 v2, - Scalar init); -template -T dot(ExecutionPolicy&& exec, - InVec1 v1, - InVec2 v2, - Scalar init); -template -auto dot(InVec1 v1, - InVec2 v2); -template -auto dot(ExecutionPolicy&& exec, - InVec1 v1, - InVec2 v2); - -// [linalg.algs.blas1.dot.dotc], -// conjugated dot product of two vectors -template -Scalar dotc(InVec1 v1, - InVec2 v2, - Scalar init); -template -Scalar dotc(ExecutionPolicy&& exec, - InVec1 v1, - InVec2 v2, - Scalar init); -template -auto dotc(InVec1 v1, - InVec2 v2); -template -auto dotc(ExecutionPolicy&& exec, - InVec1 v1, - InVec2 v2); - -// [linalg.algs.blas1.ssq], -// Scaled sum of squares of a vector's elements -template -struct sum_of_squares_result { - Scalar scaling_factor; - Scalar scaled_sum_of_squares; -}; -template -sum_of_squares_result vector_sum_of_squares( - InVec v, - sum_of_squares_result init); -template -sum_of_squares_result vector_sum_of_squares( - ExecutionPolicy&& exec, - InVec v, - sum_of_squares_result init); - -// [linalg.algs.blas1.nrm2], -// Euclidean norm of a vector -template -Scalar vector_two_norm(InVec v, - Scalar init); -template -Scalar vector_two_norm(ExecutionPolicy&& exec, - InVec v, - Scalar init); -template -auto vector_two_norm(InVec v); -template -auto vector_two_norm(ExecutionPolicy&& exec, - InVec v); - -// [linalg.algs.blas1.asum], -// sum of absolute values of vector elements -template -Scalar vector_abs_sum(InVec v, - Scalar init); -template -Scalar vector_abs_sum(ExecutionPolicy&& exec, - InVec v, - Scalar init); -template -auto vector_abs_sum(InVec v); -template -auto vector_abs_sum(ExecutionPolicy&& exec, - InVec v); - -// [linalg.algs.blas1.iamax], -// index of maximum absolute value of vector elements -template -typename InVec::extents_type vector_idx_abs_max(InVec v); -template -typename InVec::extents_type vector_idx_abs_max( - ExecutionPolicy&& exec, - InVec v); - -// [linalg.algs.blas1.matfrobnorm], -// Frobenius norm of a matrix -template -Scalar matrix_frob_norm(InMat A, - Scalar init); -template -Scalar matrix_frob_norm( - ExecutionPolicy&& exec, - InMat A, - Scalar init); -template -auto matrix_frob_norm( - InMat A); -template -auto matrix_frob_norm( - ExecutionPolicy&& exec, - InMat A); - -// [linalg.algs.blas1.matonenorm], -// One norm of a matrix -template -Scalar matrix_one_norm( - InMat A, - Scalar init); -template -Scalar matrix_one_norm( - ExecutionPolicy&& exec, - InMat A, - Scalar init); -template -auto matrix_one_norm( - InMat A); -template -auto matrix_one_norm( - ExecutionPolicy&& exec, - InMat A); - -// [linalg.algs.blas1.matinfnorm], -// Infinity norm of a matrix -template -Scalar matrix_inf_norm( - InMat A, - Scalar init); -template -Scalar matrix_inf_norm( - ExecutionPolicy&& exec, - InMat A, - Scalar init); -template -auto matrix_inf_norm( - InMat A); -template -auto matrix_inf_norm( - ExecutionPolicy&& exec, - InMat A); - -// [linalg.algs.blas2], BLAS 2 algorithms - -// [linalg.algs.blas2.gemv], -// general matrix-vector product -template -void matrix_vector_product(InMat A, - InVec x, - OutVec y); -template -void matrix_vector_product(ExecutionPolicy&& exec, - InMat A, - InVec x, - OutVec y); -template -void matrix_vector_product(InMat A, - InVec1 x, - InVec2 y, - OutVec z); -template -void matrix_vector_product(ExecutionPolicy&& exec, - InMat A, - InVec1 x, - InVec2 y, - OutVec z); - -// [linalg.algs.blas2.symv], -// symmetric matrix-vector product -template -void symmetric_matrix_vector_product(InMat A, - Triangle t, - InVec x, - OutVec y); -template -void symmetric_matrix_vector_product(ExecutionPolicy&& exec, - InMat A, - Triangle t, - InVec x, - OutVec y); -template -void symmetric_matrix_vector_product( - InMat A, - Triangle t, - InVec1 x, - InVec2 y, - OutVec z); - -template -void symmetric_matrix_vector_product( - ExecutionPolicy&& exec, - InMat A, - Triangle t, - InVec1 x, - InVec2 y, - OutVec z); - -// [linalg.algs.blas2.hemv], -// Hermitian matrix-vector product -template -void hermitian_matrix_vector_product(InMat A, - Triangle t, - InVec x, - OutVec y); -template -void hermitian_matrix_vector_product(ExecutionPolicy&& exec, - InMat A, - Triangle t, - InVec x, - OutVec y); -template -void hermitian_matrix_vector_product(InMat A, - Triangle t, - InVec1 x, - InVec2 y, - OutVec z); - -template -void hermitian_matrix_vector_product(ExecutionPolicy&& exec, - InMat A, - Triangle t, - InVec1 x, - InVec2 y, - OutVec z); - -// [linalg.algs.blas2.trmv], -// Triangular matrix-vector product - -// Overwriting triangular matrix-vector product -template -void triangular_matrix_vector_product( - InMat A, - Triangle t, - DiagonalStorage d, - InVec x, - OutVec y); -template -void triangular_matrix_vector_product( - ExecutionPolicy&& exec, - InMat A, - Triangle t, - DiagonalStorage d, - InVec x, - OutVec y); - -// In-place triangular matrix-vector product -template -void triangular_matrix_vector_product( - InMat A, - Triangle t, - DiagonalStorage d, - InOutVec y); -template -void triangular_matrix_vector_product( - ExecutionPolicy&& exec, - InMat A, - Triangle t, - DiagonalStorage d, - InOutVec y); - -// Updating triangular matrix-vector product -template -void triangular_matrix_vector_product(InMat A, - Triangle t, - DiagonalStorage d, - InVec1 x, - InVec2 y, - OutVec z); -template -void triangular_matrix_vector_product(ExecutionPolicy&& exec, - InMat A, - Triangle t, - DiagonalStorage d, - InVec1 x, - InVec2 y, - OutVec z); - -// [linalg.algs.blas2.trsv], -// Solve a triangular linear system - -// Solve a triangular linear system, not in place -template -void triangular_matrix_vector_solve( - InMat A, - Triangle t, - DiagonalStorage d, - InVec b, - OutVec x, - BinaryDivideOp divide); -template -void triangular_matrix_vector_solve( - ExecutionPolicy&& exec, - InMat A, - Triangle t, - DiagonalStorage d, - InVec b, - OutVec x, - BinaryDivideOp divide); -template -void triangular_matrix_vector_solve( - InMat A, - Triangle t, - DiagonalStorage d, - InVec b, - OutVec x); -template -void triangular_matrix_vector_solve( - ExecutionPolicy&& exec, - InMat A, - Triangle t, - DiagonalStorage d, - InVec b, - OutVec x); - -// Solve a triangular linear system, in place -template -void triangular_matrix_vector_solve( - InMat A, - Triangle t, - DiagonalStorage d, - InOutVec b, - BinaryDivideOp divide); -template -void triangular_matrix_vector_solve( - ExecutionPolicy&& exec, - InMat A, - Triangle t, - DiagonalStorage d, - InOutVec b, - BinaryDivideOp divide); -template -void triangular_matrix_vector_solve( - InMat A, - Triangle t, - DiagonalStorage d, - InOutVec b); -template -void triangular_matrix_vector_solve( - ExecutionPolicy&& exec, - InMat A, - Triangle t, - DiagonalStorage d, - InOutVec b); - -// [linalg.algs.blas2.rank1], -// nonsymmetric rank-1 matrix update -template -void matrix_rank_1_update( - InVec1 x, - InVec2 y, - InOutMat A); -template -void matrix_rank_1_update( - ExecutionPolicy&& exec, - InVec1 x, - InVec2 y, - InOutMat A); - -template -void matrix_rank_1_update_c( - InVec1 x, - InVec2 y, - InOutMat A); -template -void matrix_rank_1_update_c( - ExecutionPolicy&& exec, - InVec1 x, - InVec2 y, - InOutMat A); - -// [linalg.algs.blas2.symherrank1], -// symmetric or Hermitian rank-1 matrix update -template -void symmetric_matrix_rank_1_update( - InVec x, - InOutMat A, - Triangle t); -template -void symmetric_matrix_rank_1_update( - ExecutionPolicy&& exec, - InVec x, - InOutMat A, - Triangle t); -template -void symmetric_matrix_rank_1_update( - Scalar alpha, - InVec x, - InOutMat A, - Triangle t); -template -void symmetric_matrix_rank_1_update( - ExecutionPolicy&& exec, - Scalar alpha, - InVec x, - InOutMat A, - Triangle t); - -template -void hermitian_matrix_rank_1_update( - InVec x, - InOutMat A, - Triangle t); -template -void hermitian_matrix_rank_1_update( - ExecutionPolicy&& exec, - InVec x, - InOutMat A, - Triangle t); -template -void hermitian_matrix_rank_1_update( - Scalar alpha, - InVec x, - InOutMat A, - Triangle t); -template -void hermitian_matrix_rank_1_update( - ExecutionPolicy&& exec, - Scalar alpha, - InVec x, - InOutMat A, - Triangle t); - -// [linalg.algs.blas2.rank2], -// Symmetric and Hermitian rank-2 matrix updates - -// symmetric rank-2 matrix update -template -void symmetric_matrix_rank_2_update( - InVec1 x, - InVec2 y, - InOutMat A, - Triangle t); -template -void symmetric_matrix_rank_2_update( - ExecutionPolicy&& exec, - InVec1 x, - InVec2 y, - InOutMat A, - Triangle t); - -// Hermitian rank-2 matrix update -template -void hermitian_matrix_rank_2_update( - InVec1 x, - InVec2 y, - InOutMat A, - Triangle t); -template -void hermitian_matrix_rank_2_update( - ExecutionPolicy&& exec, - InVec1 x, - InVec2 y, - InOutMat A, - Triangle t); - -// [linalg.algs.blas3], BLAS 3 algorithms - -// [linalg.algs.blas3.gemm], -// general matrix-matrix product -template -void matrix_product(InMat1 A, - InMat2 B, - OutMat C); -template -void matrix_product(ExecutionPolicy&& exec, - InMat1 A, - InMat2 B, - OutMat C); -template -void matrix_product(InMat1 A, - InMat2 B, - InMat3 E, - OutMat C); -template -void matrix_product(ExecutionPolicy&& exec, - InMat1 A, - InMat2 B, - InMat3 E, - OutMat C); - -// [linalg.algs.blas3.xxmm], -// symmetric, Hermitian, and triangular matrix-matrix product - -template -void symmetric_matrix_product( - InMat1 A, - Triangle t, - InMat2 B, - OutMat C); -template -void symmetric_matrix_product( - ExecutionPolicy&& exec, - InMat1 A, - Triangle t, - InMat2 B, - OutMat C); - -template -void hermitian_matrix_product( - InMat1 A, - Triangle t, - InMat2 B, - OutMat C); -template -void hermitian_matrix_product( - ExecutionPolicy&& exec, - InMat1 A, - Triangle t, - InMat2 B, - OutMat C); - -template -void triangular_matrix_product( - InMat1 A, - Triangle t, - DiagonalStorage d, - InMat2 B, - OutMat C); -template -void triangular_matrix_product( - ExecutionPolicy&& exec, - InMat1 A, - Triangle t, - DiagonalStorage d, - InMat2 B, - OutMat C); - -template -void symmetric_matrix_product( - InMat1 A, - InMat2 B, - Triangle t, - OutMat C); -template -void symmetric_matrix_product( - ExecutionPolicy&& exec, - InMat1 A, - InMat2 B, - Triangle t, - OutMat C); - -template -void hermitian_matrix_product( - InMat1 A, - InMat2 B, - Triangle t, - OutMat C); -template -void hermitian_matrix_product( - ExecutionPolicy&& exec, - InMat1 A, - InMat2 B, - Triangle t, - OutMat C); - -template -void triangular_matrix_product( - InMat1 A, - InMat2 B, - Triangle t, - DiagonalStorage d, - OutMat C); -template -void triangular_matrix_product( - ExecutionPolicy&& exec, - InMat1 A, - InMat2 B, - Triangle t, - DiagonalStorage d, - OutMat C); - -template -void symmetric_matrix_product( - InMat1 A, - Triangle t, - InMat2 B, - InMat3 E, - OutMat C); -template -void symmetric_matrix_product( - ExecutionPolicy&& exec, - InMat1 A, - Triangle t, - InMat2 B, - InMat3 E, - OutMat C); - -template -void hermitian_matrix_product( - InMat1 A, - Triangle t, - InMat2 B, - InMat3 E, - OutMat C); -template -void hermitian_matrix_product( - ExecutionPolicy&& exec, - InMat1 A, - Triangle t, - InMat2 B, - InMat3 E, - OutMat C); - -template -void triangular_matrix_product( - InMat1 A, - Triangle t, - DiagonalStorage d, - InMat2 B, - InMat3 E, - OutMat C); -template -void triangular_matrix_product( - ExecutionPolicy&& exec, - InMat1 A, - Triangle t, - DiagonalStorage d, - InMat2 B, - InMat3 E, - OutMat C); - -template -void symmetric_matrix_product( - InMat1 A, - InMat2 B, - Triangle t, - InMat3 E, - OutMat C); -template -void symmetric_matrix_product( - ExecutionPolicy&& exec, - InMat1 A, - InMat2 B, - Triangle t, - InMat3 E, - OutMat C); - -template -void hermitian_matrix_product( - InMat1 A, - InMat2 B, - Triangle t, - InMat3 E, - OutMat C); -template -void hermitian_matrix_product( - ExecutionPolicy&& exec, - InMat1 A, - InMat2 B, - Triangle t, - InMat3 E, - OutMat C); - -template -void triangular_matrix_product( - InMat1 A, - InMat2 B, - Triangle t, - DiagonalStorage d, - InMat3 E, - OutMat C); -template -void triangular_matrix_product( - ExecutionPolicy&& exec, - InMat1 A, - InMat2 B, - Triangle t, - DiagonalStorage d, - InMat3 E, - OutMat C); - -// [linalg.algs.blas3.trmm], -// in-place triangular matrix-matrix product - -template -void triangular_matrix_left_product( - InMat A, - Triangle t, - DiagonalStorage d, - InOutMat C); -template -void triangular_matrix_left_product( - ExecutionPolicy&& exec, - InMat A, - Triangle t, - DiagonalStorage d, - InOutMat C); - -template -void triangular_matrix_right_product( - InMat A, - Triangle t, - DiagonalStorage d, - InOutMat C); -template -void triangular_matrix_right_product( - ExecutionPolicy&& exec, - InMat A, - Triangle t, - DiagonalStorage d, - InOutMat C); - -// [linalg.algs.blas3.rankk], -// rank-k update of a symmetric or Hermitian matrix - -// rank-k symmetric matrix update -template -void symmetric_matrix_rank_k_update( - Scalar alpha, - InMat A, - InOutMat C, - Triangle t); -template -void symmetric_matrix_rank_k_update( - ExecutionPolicy&& exec, - Scalar alpha, - InMat A, - InOutMat C, - Triangle t); - -template -void symmetric_matrix_rank_k_update( - InMat A, - InOutMat C, - Triangle t); -template -void symmetric_matrix_rank_k_update( - ExecutionPolicy&& exec, - InMat A, - InOutMat C, - Triangle t); - -// rank-k Hermitian matrix update -template -void hermitian_matrix_rank_k_update( - Scalar alpha, - InMat A, - InOutMat C, - Triangle t); -template -void hermitian_matrix_rank_k_update( - ExecutionPolicy&& exec, - Scalar alpha, - InMat A, - InOutMat C, - Triangle t); - -template -void hermitian_matrix_rank_k_update( - InMat A, - InOutMat C, - Triangle t); -template -void hermitian_matrix_rank_k_update( - ExecutionPolicy&& exec, - InMat A, - InOutMat C, - Triangle t); - -// [linalg.algs.blas3.rank2k], -// rank-2k update of a symmetric or Hermitian matrix - -// rank-2k symmetric matrix update -template -void symmetric_matrix_rank_2k_update( - InMat1 A, - InMat2 B, - InOutMat C, - Triangle t); -template -void symmetric_matrix_rank_2k_update( - ExecutionPolicy&& exec, - InMat1 A, - InMat2 B, - InOutMat C, - Triangle t); - -// rank-2k Hermitian matrix update -template -void hermitian_matrix_rank_2k_update( - InMat1 A, - InMat2 B, - InOutMat C, - Triangle t); -template -void hermitian_matrix_rank_2k_update( - ExecutionPolicy&& exec, - InMat1 A, - InMat2 B, - InOutMat C, - Triangle t); - -// [linalg.algs.blas3.trsm], -// solve multiple triangular linear systems - -// solve multiple triangular systems on the left, not-in-place -template -void triangular_matrix_matrix_left_solve( - InMat1 A, - Triangle t, - DiagonalStorage d, - InMat2 B, - OutMat X, - BinaryDivideOp divide); -template -void triangular_matrix_matrix_left_solve( - ExecutionPolicy&& exec, - InMat1 A, - Triangle t, - DiagonalStorage d, - InMat2 B, - OutMat X, - BinaryDivideOp divide); -template -void triangular_matrix_matrix_left_solve( - InMat1 A, - Triangle t, - DiagonalStorage d, - InMat2 B, - OutMat X); -template -void triangular_matrix_matrix_left_solve( - ExecutionPolicy&& exec, - InMat1 A, - Triangle t, - DiagonalStorage d, - InMat2 B, - OutMat X); - -// solve multiple triangular systems on the right, not-in-place -template -void triangular_matrix_matrix_right_solve( - InMat1 A, - Triangle t, - DiagonalStorage d, - InMat2 B, - OutMat X, - BinaryDivideOp divide); -template -void triangular_matrix_matrix_right_solve( - ExecutionPolicy&& exec, - InMat1 A, - Triangle t, - DiagonalStorage d, - InMat2 B, - OutMat X, - BinaryDivideOp divide); -template -void triangular_matrix_matrix_right_solve( - InMat1 A, - Triangle t, - DiagonalStorage d, - InMat2 B, - OutMat X); -template -void triangular_matrix_matrix_right_solve( - ExecutionPolicy&& exec, - InMat1 A, - Triangle t, - DiagonalStorage d, - InMat2 B, - OutMat X); - -// solve multiple triangular systems on the left, in-place -template -void triangular_matrix_matrix_left_solve( - InMat A, - Triangle t, - DiagonalStorage d, - InOutMat B, - BinaryDivideOp divide); -template -void triangular_matrix_matrix_left_solve( - ExecutionPolicy&& exec, - InMat A, - Triangle t, - DiagonalStorage d, - InOutMat B, - BinaryDivideOp divide); -template -void triangular_matrix_matrix_left_solve( - InMat A, - Triangle t, - DiagonalStorage d, - InOutMat B); -template -void triangular_matrix_matrix_left_solve( - ExecutionPolicy&& exec, - InMat A, - Triangle t, - DiagonalStorage d, - InOutMat B); - -// solve multiple triangular systems on the right, in-place -template -void triangular_matrix_matrix_right_solve( - InMat A, - Triangle t, - DiagonalStorage d, - InOutMat B, - BinaryDivideOp divide); -template -void triangular_matrix_matrix_right_solve( - ExecutionPolicy&& exec, - InMat A, - Triangle t, - DiagonalStorage d, - InOutMat B, - BinaryDivideOp divide); -template -void triangular_matrix_matrix_right_solve( - InMat A, - Triangle t, - DiagonalStorage d, - InOutMat B); -template -void triangular_matrix_matrix_right_solve( - ExecutionPolicy&& exec, - InMat A, - Triangle t, - DiagonalStorage d, - InOutMat B); + // \ref{linalg.scaled}, scaled in-place transformation + + // \ref{linalg.scaled.scaledaccessor}, class template \tcode{scaled_accessor} + template + class scaled_accessor; + + // \ref{linalg.scaled.scaled}, function template \tcode{scaled} + template + constexpr auto scaled(ScalingFactor alpha, mdspan x); + + // \ref{linalg.conj}, conjugated in-place transformation + + // \ref{linalg.conj.conjugatedaccessor}, class template \tcode{conjugated_accessor} + template + class conjugated_accessor; + + // \ref{linalg.conj.conjugated}, function template \tcode{conjugated} + template + constexpr auto conjugated(mdspan a); + + // \ref{linalg.transp}, transpose in-place transformation + + // \ref{linalg.transp.layout.transpose}, class template \tcode{layout_transpose} + template + class layout_transpose; + + // \ref{linalg.transp.transposed}, function template \tcode{transposed} + template + constexpr auto transposed(mdspan a); + + // \ref{linalg.conjtransposed}, conjugated transpose in-place transformation + template + constexpr auto conjugate_transposed(mdspan a); + + // \ref{linalg.algs.blas1}, BLAS 1 algorithms + + // \ref{linalg.algs.blas1.givens}, Givens rotations + + // \ref{linalg.algs.blas1.givens.lartg}, compute Givens rotation + + template + struct setup_givens_rotation_result { + Real c; + Real s; + Real r; + }; + template + struct setup_givens_rotation_result> { + Real c; + complex s; + complex r; + }; + + template + setup_givens_rotation_result setup_givens_rotation(Real a, Real b) noexcept; + + template + setup_givens_rotation_result> + setup_givens_rotation(complex a, complex b) noexcept; + + // \ref{linalg.algs.blas1.givens.rot}, apply computed Givens rotation + template + void apply_givens_rotation(InOutVec1 x, InOutVec2 y, Real c, Real s); + template + void apply_givens_rotation(ExecutionPolicy&& exec, + InOutVec1 x, InOutVec2 y, Real c, Real s); + template + void apply_givens_rotation(InOutVec1 x, InOutVec2 y, Real c, complex s); + template + void apply_givens_rotation(ExecutionPolicy&& exec, + InOutVec1 x, InOutVec2 y, Real c, complex s); + + // \ref{linalg.algs.blas1.swap}, swap elements + template + void swap_elements(InOutObj1 x, InOutObj2 y); + template + void swap_elements(ExecutionPolicy&& exec, + InOutObj1 x, InOutObj2 y); + + // \ref{linalg.algs.blas1.scal}, multiply elements by scalar + template + void scale(Scalar alpha, InOutObj x); + template + void scale(ExecutionPolicy&& exec, + Scalar alpha, InOutObj x); + + // \ref{linalg.algs.blas1.copy}, copy elements + template + void copy(InObj x, OutObj y); + template + void copy(ExecutionPolicy&& exec, + InObj x, OutObj y); + + // \ref{linalg.algs.blas1.add}, add elementwise + template + void add(InObj1 x, InObj2 y, OutObj z); + template + void add(ExecutionPolicy&& exec, + InObj1 x, InObj2 y, OutObj z); + + // \ref{linalg.algs.blas1.dot}, dot product of two vectors + + // \ref{linalg.algs.blas1.dot.dotu}, nonconjugated dot product of two vectors + template + T dot(InVec1 v1, InVec2 v2, Scalar init); + template + T dot(ExecutionPolicy&& exec, + InVec1 v1, InVec2 v2, Scalar init); + template + auto dot(InVec1 v1, InVec2 v2); + template + auto dot(ExecutionPolicy&& exec, + InVec1 v1, InVec2 v2); + + // \ref{linalg.algs.blas1.dot.dotc}, conjugated dot product of two vectors + template + Scalar dotc(InVec1 v1, InVec2 v2, Scalar init); + template + Scalar dotc(ExecutionPolicy&& exec, + InVec1 v1, InVec2 v2, Scalar init); + template + auto dotc(InVec1 v1, InVec2 v2); + template + auto dotc(ExecutionPolicy&& exec, + InVec1 v1, InVec2 v2); + + // \ref{linalg.algs.blas1.ssq}, scaled sum of squares of a vector's elements + template + struct sum_of_squares_result { + Scalar scaling_factor; + Scalar scaled_sum_of_squares; + }; + template + sum_of_squares_result + vector_sum_of_squares(InVec v, sum_of_squares_result init); + template + sum_of_squares_result + vector_sum_of_squares(ExecutionPolicy&& exec, + InVec v, sum_of_squares_result init); + + // \ref{linalg.algs.blas1.nrm2}, Euclidean norm of a vector + template + Scalar vector_two_norm(InVec v, Scalar init); + template + Scalar vector_two_norm(ExecutionPolicy&& exec, InVec v, Scalar init); + template + auto vector_two_norm(InVec v); + template + auto vector_two_norm(ExecutionPolicy&& exec, InVec v); + + // \ref{linalg.algs.blas1.asum}, sum of absolute values of vector elements + template + Scalar vector_abs_sum(InVec v, Scalar init); + template + Scalar vector_abs_sum(ExecutionPolicy&& exec, InVec v, Scalar init); + template + auto vector_abs_sum(InVec v); + template + auto vector_abs_sum(ExecutionPolicy&& exec, InVec v); + + // \ref{linalg.algs.blas1.iamax}, index of maximum absolute value of vector elements + template + typename InVec::extents_type vector_idx_abs_max(InVec v); + template + typename InVec::extents_type vector_idx_abs_max(ExecutionPolicy&& exec, InVec v); + + // \ref{linalg.algs.blas1.matfrobnorm}, Frobenius norm of a matrix + template + Scalar matrix_frob_norm(InMat A, Scalar init); + template + Scalar matrix_frob_norm(ExecutionPolicy&& exec, InMat A, Scalar init); + template + auto matrix_frob_norm(InMat A); + template + auto matrix_frob_norm(ExecutionPolicy&& exec, InMat A); + + // \ref{linalg.algs.blas1.matonenorm}, one norm of a matrix + template + Scalar matrix_one_norm(InMat A, Scalar init); + template + Scalar matrix_one_norm(ExecutionPolicy&& exec, InMat A, Scalar init); + template + auto matrix_one_norm(InMat A); + template + auto matrix_one_norm(ExecutionPolicy&& exec, InMat A); + + // \ref{linalg.algs.blas1.matinfnorm}, infinity norm of a matrix + template + Scalar matrix_inf_norm(InMat A, Scalar init); + template + Scalar matrix_inf_norm(ExecutionPolicy&& exec, InMat A, Scalar init); + template + auto matrix_inf_norm(InMat A); + template + auto matrix_inf_norm(ExecutionPolicy&& exec, InMat A); + + // \ref{linalg.algs.blas2}, BLAS 2 algorithms + + // \ref{linalg.algs.blas2.gemv}, general matrix-vector product + template + void matrix_vector_product(InMat A, InVec x, OutVec y); + template + void matrix_vector_product(ExecutionPolicy&& exec, + InMat A, InVec x, OutVec y); + template + void matrix_vector_product(InMat A, InVec1 x, InVec2 y, OutVec z); + template + void matrix_vector_product(ExecutionPolicy&& exec, + InMat A, InVec1 x, InVec2 y, OutVec z); + + // \ref{linalg.algs.blas2.symv}, symmetric matrix-vector product + template + void symmetric_matrix_vector_product(InMat A, Triangle t, InVec x, OutVec y); + template + void symmetric_matrix_vector_product(ExecutionPolicy&& exec, + InMat A, Triangle t, InVec x, OutVec y); + template + void symmetric_matrix_vector_product(InMat A, Triangle t, InVec1 x, InVec2 y, OutVec z); + + template + void symmetric_matrix_vector_product(ExecutionPolicy&& exec, + InMat A, Triangle t, InVec1 x, InVec2 y, OutVec z); + + // \ref{linalg.algs.blas2.hemv}, Hermitian matrix-vector product + template + void hermitian_matrix_vector_product(InMat A, Triangle t, InVec x, OutVec y); + template + void hermitian_matrix_vector_product(ExecutionPolicy&& exec, + InMat A, Triangle t, InVec x, OutVec y); + template + void hermitian_matrix_vector_product(InMat A, Triangle t, InVec1 x, InVec2 y, OutVec z); + + template + void hermitian_matrix_vector_product(ExecutionPolicy&& exec, + InMat A, Triangle t, InVec1 x, InVec2 y, OutVec z); + + // \ref{linalg.algs.blas2.trmv}, triangular matrix-vector product + + // Overwriting triangular matrix-vector product + template + void triangular_matrix_vector_product(InMat A, Triangle t, DiagonalStorage d, InVec x, OutVec y); + template + void triangular_matrix_vector_product(ExecutionPolicy&& exec, + InMat A, Triangle t, DiagonalStorage d, InVec x, OutVec y); + + // In-place triangular matrix-vector product + template + void triangular_matrix_vector_product(InMat A, Triangle t, DiagonalStorage d, InOutVec y); + template + void triangular_matrix_vector_product(ExecutionPolicy&& exec, + InMat A, Triangle t, DiagonalStorage d, InOutVec y); + + // Updating triangular matrix-vector product + template + void triangular_matrix_vector_product(InMat A, Triangle t, DiagonalStorage d, + InVec1 x, InVec2 y, OutVec z); + template + void triangular_matrix_vector_product(ExecutionPolicy&& exec, + InMat A, Triangle t, DiagonalStorage d, + InVec1 x, InVec2 y, OutVec z); + + // \ref{linalg.algs.blas2.trsv}, solve a triangular linear system + + // Solve a triangular linear system, not in place + template + void triangular_matrix_vector_solve(InMat A, Triangle t, DiagonalStorage d, + InVec b, OutVec x, BinaryDivideOp divide); + template + void triangular_matrix_vector_solve(ExecutionPolicy&& exec, + InMat A, Triangle t, DiagonalStorage d, + InVec b, OutVec x, BinaryDivideOp divide); + template + void triangular_matrix_vector_solve(InMat A, Triangle t, DiagonalStorage d, + InVec b, OutVec x); + template + void triangular_matrix_vector_solve(ExecutionPolicy&& exec, + InMat A, Triangle t, DiagonalStorage d, + InVec b, OutVec x); + + // Solve a triangular linear system, in place + template + void triangular_matrix_vector_solve(InMat A, Triangle t, DiagonalStorage d, + InOutVec b, BinaryDivideOp divide); + template + void triangular_matrix_vector_solve(ExecutionPolicy&& exec, + InMat A, Triangle t, DiagonalStorage d, + InOutVec b, BinaryDivideOp divide); + template + void triangular_matrix_vector_solve(InMat A, Triangle t, DiagonalStorage d, InOutVec b); + template + void triangular_matrix_vector_solve(ExecutionPolicy&& exec, + InMat A, Triangle t, DiagonalStorage d, InOutVec b); + + // \ref{linalg.algs.blas2.rank1}, // nonsymmetric rank-1 matrix update + template + void matrix_rank_1_update(InVec1 x, InVec2 y, InOutMat A); + template + void matrix_rank_1_update(ExecutionPolicy&& exec, + InVec1 x, InVec2 y, InOutMat A); + + template + void matrix_rank_1_update_c(InVec1 x, InVec2 y, InOutMat A); + template + void matrix_rank_1_update_c(ExecutionPolicy&& exec, + InVec1 x, InVec2 y, InOutMat A); + + // \ref{linalg.algs.blas2.symherrank1}, symmetric or Hermitian rank-1 matrix update + template + void symmetric_matrix_rank_1_update(InVec x, InOutMat A, Triangle t); + template + void symmetric_matrix_rank_1_update(ExecutionPolicy&& exec, + InVec x, InOutMat A, Triangle t); + template + void symmetric_matrix_rank_1_update(Scalar alpha, InVec x, InOutMat A, Triangle t); + template + void symmetric_matrix_rank_1_update(ExecutionPolicy&& exec, + Scalar alpha, InVec x, InOutMat A, Triangle t); + + template + void hermitian_matrix_rank_1_update(InVec x, InOutMat A, Triangle t); + template + void hermitian_matrix_rank_1_update(ExecutionPolicy&& exec, + InVec x, InOutMat A, Triangle t); + template + void hermitian_matrix_rank_1_update(Scalar alpha, InVec x, InOutMat A, Triangle t); + template + void hermitian_matrix_rank_1_update(ExecutionPolicy&& exec, + Scalar alpha, InVec x, InOutMat A, Triangle t); + + // \ref{linalg.algs.blas2.rank2}, symmetric and Hermitian rank-2 matrix updates + + // symmetric rank-2 matrix update + template + void symmetric_matrix_rank_2_update(InVec1 x, InVec2 y, InOutMat A, Triangle t); + template + void symmetric_matrix_rank_2_update(ExecutionPolicy&& exec, + InVec1 x, InVec2 y, InOutMat A, Triangle t); + + // Hermitian rank-2 matrix update + template + void hermitian_matrix_rank_2_update(InVec1 x, InVec2 y, InOutMat A, Triangle t); + template + void hermitian_matrix_rank_2_update(ExecutionPolicy&& exec, + InVec1 x, InVec2 y, InOutMat A, Triangle t); + + // \ref{linalg.algs.blas3}, BLAS 3 algorithms + + // \ref{linalg.algs.blas3.gemm}, general matrix-matrix product + template + void matrix_product(InMat1 A, InMat2 B, OutMat C); + template + void matrix_product(ExecutionPolicy&& exec, + InMat1 A, InMat2 B, OutMat C); + template + void matrix_product(InMat1 A, InMat2 B, InMat3 E, OutMat C); + template + void matrix_product(ExecutionPolicy&& exec, + InMat1 A, InMat2 B, InMat3 E, OutMat C); + + // \ref{linalg.algs.blas3.xxmm}, symmetric, Hermitian, and triangular matrix-matrix product + + template + void symmetric_matrix_product(InMat1 A, Triangle t, InMat2 B, OutMat C); + template + void symmetric_matrix_product(ExecutionPolicy&& exec, + InMat1 A, Triangle t, InMat2 B, OutMat C); + + template + void hermitian_matrix_product(InMat1 A, Triangle t, InMat2 B, OutMat C); + template + void hermitian_matrix_product(ExecutionPolicy&& exec, + InMat1 A, Triangle t, InMat2 B, OutMat C); + + template + void triangular_matrix_product(InMat1 A, Triangle t, DiagonalStorage d, InMat2 B, OutMat C); + template + void triangular_matrix_product(ExecutionPolicy&& exec, + InMat1 A, Triangle t, DiagonalStorage d, InMat2 B, OutMat C); + + template + void symmetric_matrix_product(InMat1 A, InMat2 B, Triangle t, OutMat C); + template + void symmetric_matrix_product(ExecutionPolicy&& exec, + InMat1 A, InMat2 B, Triangle t, OutMat C); + + template + void hermitian_matrix_product(InMat1 A, InMat2 B, Triangle t, OutMat C); + template + void hermitian_matrix_product(ExecutionPolicy&& exec, + InMat1 A, InMat2 B, Triangle t, OutMat C); + + template + void triangular_matrix_product(InMat1 A, InMat2 B, Triangle t, DiagonalStorage d, OutMat C); + template + void triangular_matrix_product(ExecutionPolicy&& exec, + InMat1 A, InMat2 B, Triangle t, DiagonalStorage d, OutMat C); + + template + void symmetric_matrix_product(InMat1 A, Triangle t, InMat2 B, InMat3 E, OutMat C); + template + void symmetric_matrix_product(ExecutionPolicy&& exec, + InMat1 A, Triangle t, InMat2 B, InMat3 E, OutMat C); + + template + void hermitian_matrix_product(InMat1 A, Triangle t, InMat2 B, InMat3 E, OutMat C); + template + void hermitian_matrix_product(ExecutionPolicy&& exec, + InMat1 A, Triangle t, InMat2 B, InMat3 E, OutMat C); + + template + void triangular_matrix_product(InMat1 A, Triangle t, DiagonalStorage d, InMat2 B, InMat3 E, OutMat C); + template + void triangular_matrix_product(ExecutionPolicy&& exec, + InMat1 A, Triangle t, DiagonalStorage d, InMat2 B, InMat3 E, OutMat C); + + template + void symmetric_matrix_product(InMat1 A, InMat2 B, Triangle t, InMat3 E, OutMat C); + template + void symmetric_matrix_product(ExecutionPolicy&& exec, + InMat1 A, InMat2 B, Triangle t, InMat3 E, OutMat C); + + template + void hermitian_matrix_product(InMat1 A, InMat2 B, Triangle t, InMat3 E, OutMat C); + template + void hermitian_matrix_product(ExecutionPolicy&& exec, + InMat1 A, InMat2 B, Triangle t, InMat3 E, OutMat C); + + template + void triangular_matrix_product(InMat1 A, InMat2 B, Triangle t, DiagonalStorage d, InMat3 E, OutMat C); + template + void triangular_matrix_product(ExecutionPolicy&& exec, + InMat1 A, InMat2 B, Triangle t, DiagonalStorage d, InMat3 E, OutMat C); + + // \ref{linalg.algs.blas3.trmm}, in-place triangular matrix-matrix product + + template + void triangular_matrix_left_product(InMat A, Triangle t, DiagonalStorage d, InOutMat C); + template + void triangular_matrix_left_product(ExecutionPolicy&& exec, + InMat A, Triangle t, DiagonalStorage d, InOutMat C); + + template + void triangular_matrix_right_product(InMat A, Triangle t, DiagonalStorage d, InOutMat C); + template + void triangular_matrix_right_product(ExecutionPolicy&& exec, + InMat A, Triangle t, DiagonalStorage d, InOutMat C); + + // \ref{linalg.algs.blas3.rankk}, rank-k update of a symmetric or Hermitian matrix + + // rank-k symmetric matrix update + template + void symmetric_matrix_rank_k_update(Scalar alpha, InMat A, InOutMat C, Triangle t); + template + void symmetric_matrix_rank_k_update(ExecutionPolicy&& exec, + Scalar alpha, InMat A, InOutMat C, Triangle t); + + template + void symmetric_matrix_rank_k_update(InMat A, InOutMat C, Triangle t); + template + void symmetric_matrix_rank_k_update(ExecutionPolicy&& exec, + InMat A, InOutMat C, Triangle t); + + // rank-k Hermitian matrix update + template + void hermitian_matrix_rank_k_update(Scalar alpha, InMat A, InOutMat C, Triangle t); + template + void hermitian_matrix_rank_k_update(ExecutionPolicy&& exec, + Scalar alpha, InMat A, InOutMat C, Triangle t); + + template + void hermitian_matrix_rank_k_update(InMat A, InOutMat C, Triangle t); + template + void hermitian_matrix_rank_k_update(ExecutionPolicy&& exec, + InMat A, InOutMat C, Triangle t); + + // \ref{linalg.algs.blas3.rank2k}, rank-2k update of a symmetric or Hermitian matrix + + // rank-2k symmetric matrix update + template + void symmetric_matrix_rank_2k_update(InMat1 A, InMat2 B, InOutMat C, Triangle t); + template + void symmetric_matrix_rank_2k_update(ExecutionPolicy&& exec, + InMat1 A, InMat2 B, InOutMat C, Triangle t); + + // rank-2k Hermitian matrix update + template + void hermitian_matrix_rank_2k_update(InMat1 A, InMat2 B, InOutMat C, Triangle t); + template + void hermitian_matrix_rank_2k_update(ExecutionPolicy&& exec, + InMat1 A, InMat2 B, InOutMat C, Triangle t); + + // \ref{linalg.algs.blas3.trsm}, solve multiple triangular linear systems + + // solve multiple triangular systems on the left, not-in-place + template + void triangular_matrix_matrix_left_solve(InMat1 A, Triangle t, DiagonalStorage d, InMat2 B, OutMat X, BinaryDivideOp divide); + template + void triangular_matrix_matrix_left_solve(ExecutionPolicy&& exec, InMat1 A, Triangle t, DiagonalStorage d, InMat2 B, OutMat X, BinaryDivideOp divide); + template + void triangular_matrix_matrix_left_solve(InMat1 A, Triangle t, DiagonalStorage d, InMat2 B, OutMat X); + template + void triangular_matrix_matrix_left_solve(ExecutionPolicy&& exec, InMat1 A, Triangle t, DiagonalStorage d, InMat2 B, OutMat X); + + // solve multiple triangular systems on the right, not-in-place + template + void triangular_matrix_matrix_right_solve(InMat1 A, Triangle t, DiagonalStorage d, InMat2 B, OutMat X, BinaryDivideOp divide); + template + void triangular_matrix_matrix_right_solve(ExecutionPolicy&& exec, InMat1 A, Triangle t, DiagonalStorage d, InMat2 B, OutMat X, BinaryDivideOp divide); + template + void triangular_matrix_matrix_right_solve(InMat1 A, Triangle t, DiagonalStorage d, InMat2 B, OutMat X); + template + void triangular_matrix_matrix_right_solve(ExecutionPolicy&& exec, InMat1 A, Triangle t, DiagonalStorage d, InMat2 B, OutMat X); + + // solve multiple triangular systems on the left, in-place + template + void triangular_matrix_matrix_left_solve(InMat A, Triangle t, DiagonalStorage d, InOutMat B, BinaryDivideOp divide); + template + void triangular_matrix_matrix_left_solve(ExecutionPolicy&& exec, InMat A, Triangle t, DiagonalStorage d, InOutMat B, BinaryDivideOp divide); + template + void triangular_matrix_matrix_left_solve(InMat A, Triangle t, DiagonalStorage d, InOutMat B); + template + void triangular_matrix_matrix_left_solve(ExecutionPolicy&& exec, InMat A, Triangle t, DiagonalStorage d, InOutMat B); + + // solve multiple triangular systems on the right, in-place + template + void triangular_matrix_matrix_right_solve(InMat A, Triangle t, DiagonalStorage d, InOutMat B, BinaryDivideOp divide); + template + void triangular_matrix_matrix_right_solve(ExecutionPolicy&& exec, InMat A, Triangle t, DiagonalStorage d, InOutMat B, BinaryDivideOp divide); + template + void triangular_matrix_matrix_right_solve(InMat A, Triangle t, DiagonalStorage d, InOutMat B); + template + void triangular_matrix_matrix_right_solve(ExecutionPolicy&& exec, InMat A, Triangle t, DiagonalStorage d, InOutMat B); +} \end{codeblock}