<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <meta charset="utf-8">
  <meta name="generator" content="mpark/wg21">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
  <meta name="dcterms.date" content="2023-11-10">
  <title>A free function linear algebra interface based on the BLAS</title>
  <style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
  <style>
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ background-color: #f6f8fa; }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span { } 
code span.al { color: #ff0000; } 
code span.an { } 
code span.at { } 
code span.bn { color: #9f6807; } 
code span.bu { color: #9f6807; } 
code span.cf { color: #00607c; } 
code span.ch { color: #9f6807; } 
code span.cn { } 
code span.co { color: #008000; font-style: italic; } 
code span.cv { color: #008000; font-style: italic; } 
code span.do { color: #008000; } 
code span.dt { color: #00607c; } 
code span.dv { color: #9f6807; } 
code span.er { color: #ff0000; font-weight: bold; } 
code span.ex { } 
code span.fl { color: #9f6807; } 
code span.fu { } 
code span.im { } 
code span.in { color: #008000; } 
code span.kw { color: #00607c; } 
code span.op { color: #af1915; } 
code span.ot { } 
code span.pp { color: #6f4e37; } 
code span.re { } 
code span.sc { color: #9f6807; } 
code span.ss { color: #9f6807; } 
code span.st { color: #9f6807; } 
code span.va { } 
code span.vs { color: #9f6807; } 
code span.wa { color: #008000; font-weight: bold; } 
code.diff {color: #898887}
code.diff span.va {color: #00AA00}
code.diff span.st {color: #bf0303}
</style>
  <style type="text/css">
body {
margin: 5em;
font-family: serif;

hyphens: auto;
line-height: 1.35;
}
div.wrapper {
max-width: 60em;
margin: auto;
}
ul {
list-style-type: none;
padding-left: 2em;
margin-top: -0.2em;
margin-bottom: -0.2em;
}
a {
text-decoration: none;
color: #4183C4;
}
a.hidden_link {
text-decoration: none;
color: inherit;
}
li {
margin-top: 0.6em;
margin-bottom: 0.6em;
}
h1, h2, h3, h4 {
position: relative;
line-height: 1;
}
a.self-link {
position: absolute;
top: 0;
left: calc(-1 * (3.5rem - 26px));
width: calc(3.5rem - 26px);
height: 2em;
text-align: center;
border: none;
transition: opacity .2s;
opacity: .5;
font-family: sans-serif;
font-weight: normal;
font-size: 83%;
}
a.self-link:hover { opacity: 1; }
a.self-link::before { content: "§"; }
ul > li:before {
content: "\2014";
position: absolute;
margin-left: -1.5em;
}
:target { background-color: #C9FBC9; }
:target .codeblock { background-color: #C9FBC9; }
:target ul { background-color: #C9FBC9; }
.abbr_ref { float: right; }
.folded_abbr_ref { float: right; }
:target .folded_abbr_ref { display: none; }
:target .unfolded_abbr_ref { float: right; display: inherit; }
.unfolded_abbr_ref { display: none; }
.secnum { display: inline-block; min-width: 35pt; }
.header-section-number { display: inline-block; min-width: 35pt; }
.annexnum { display: block; }
div.sourceLinkParent {
float: right;
}
a.sourceLink {
position: absolute;
opacity: 0;
margin-left: 10pt;
}
a.sourceLink:hover {
opacity: 1;
}
a.itemDeclLink {
position: absolute;
font-size: 75%;
text-align: right;
width: 5em;
opacity: 0;
}
a.itemDeclLink:hover { opacity: 1; }
span.marginalizedparent {
position: relative;
left: -5em;
}
li span.marginalizedparent { left: -7em; }
li ul > li span.marginalizedparent { left: -9em; }
li ul > li ul > li span.marginalizedparent { left: -11em; }
li ul > li ul > li ul > li span.marginalizedparent { left: -13em; }
div.footnoteNumberParent {
position: relative;
left: -4.7em;
}
a.marginalized {
position: absolute;
font-size: 75%;
text-align: right;
width: 5em;
}
a.enumerated_item_num {
position: relative;
left: -3.5em;
display: inline-block;
margin-right: -3em;
text-align: right;
width: 3em;
}
div.para { margin-bottom: 0.6em; margin-top: 0.6em; text-align: justify; }
div.section { text-align: justify; }
div.sentence { display: inline; }
span.indexparent {
display: inline;
position: relative;
float: right;
right: -1em;
}
a.index {
position: absolute;
display: none;
}
a.index:before { content: "⟵"; }

a.index:target {
display: inline;
}
.indexitems {
margin-left: 2em;
text-indent: -2em;
}
div.itemdescr {
margin-left: 3em;
}
.bnf {
font-family: serif;
margin-left: 40pt;
margin-top: 0.5em;
margin-bottom: 0.5em;
}
.ncbnf {
font-family: serif;
margin-top: 0.5em;
margin-bottom: 0.5em;
margin-left: 40pt;
}
.ncsimplebnf {
font-family: serif;
font-style: italic;
margin-top: 0.5em;
margin-bottom: 0.5em;
margin-left: 40pt;
background: inherit; 
}
span.textnormal {
font-style: normal;
font-family: serif;
white-space: normal;
display: inline-block;
}
span.rlap {
display: inline-block;
width: 0px;
}
span.descr { font-style: normal; font-family: serif; }
span.grammarterm { font-style: italic; }
span.term { font-style: italic; }
span.terminal { font-family: monospace; font-style: normal; }
span.nonterminal { font-style: italic; }
span.tcode { font-family: monospace; font-style: normal; }
span.textbf { font-weight: bold; }
span.textsc { font-variant: small-caps; }
a.nontermdef { font-style: italic; font-family: serif; }
span.emph { font-style: italic; }
span.techterm { font-style: italic; }
span.mathit { font-style: italic; }
span.mathsf { font-family: sans-serif; }
span.mathrm { font-family: serif; font-style: normal; }
span.textrm { font-family: serif; }
span.textsl { font-style: italic; }
span.mathtt { font-family: monospace; font-style: normal; }
span.mbox { font-family: serif; font-style: normal; }
span.ungap { display: inline-block; width: 2pt; }
span.textit { font-style: italic; }
span.texttt { font-family: monospace; }
span.tcode_in_codeblock { font-family: monospace; font-style: normal; }
span.phantom { color: white; }

span.math { font-style: normal; }
span.mathblock {
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 1.2em;
margin-bottom: 1.2em;
text-align: center;
}
span.mathalpha {
font-style: italic;
}
span.synopsis {
font-weight: bold;
margin-top: 0.5em;
display: block;
}
span.definition {
font-weight: bold;
display: block;
}
.codeblock {
margin-left: 1.2em;
line-height: 127%;
}
.outputblock {
margin-left: 1.2em;
line-height: 127%;
}
div.itemdecl {
margin-top: 2ex;
}
code.itemdeclcode {
white-space: pre;
display: block;
}
span.textsuperscript {
vertical-align: super;
font-size: smaller;
line-height: 0;
}
.footnotenum { vertical-align: super; font-size: smaller; line-height: 0; }
.footnote {
font-size: small;
margin-left: 2em;
margin-right: 2em;
margin-top: 0.6em;
margin-bottom: 0.6em;
}
div.minipage {
display: inline-block;
margin-right: 3em;
}
div.numberedTable {
text-align: center;
margin: 2em;
}
div.figure {
text-align: center;
margin: 2em;
}
table {
border: 1px solid black;
border-collapse: collapse;
margin-left: auto;
margin-right: auto;
margin-top: 0.8em;
text-align: left;
hyphens: none; 
}
td, th {
padding-left: 1em;
padding-right: 1em;
vertical-align: top;
}
td.empty {
padding: 0px;
padding-left: 1px;
}
td.left {
text-align: left;
}
td.right {
text-align: right;
}
td.center {
text-align: center;
}
td.justify {
text-align: justify;
}
td.border {
border-left: 1px solid black;
}
tr.rowsep, td.cline {
border-top: 1px solid black;
}
tr.even, tr.odd {
border-bottom: 1px solid black;
}
tr.capsep {
border-top: 3px solid black;
border-top-style: double;
}
tr.header {
border-bottom: 3px solid black;
border-bottom-style: double;
}
th {
border-bottom: 1px solid black;
}
span.centry {
font-weight: bold;
}
div.table {
display: block;
margin-left: auto;
margin-right: auto;
text-align: center;
width: 90%;
}
span.indented {
display: block;
margin-left: 2em;
margin-bottom: 1em;
margin-top: 1em;
}
ol.enumeratea { list-style-type: none; background: inherit; }
ol.enumerate { list-style-type: none; background: inherit; }

code.sourceCode > span { display: inline; }

div#refs p { padding-left: 32px; text-indent: -32px; }
</style>
  <link href="data:image/vnd.microsoft.icon;base64,AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAAAEAAAACAAAAABACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AIJEAACCRAAAgkQAAIJEAACCRAAAgkQAVoJEAN6CRADegkQAWIJEAACCRAAAgkQAAIJEAACCRAAA////AP///wCCRAAAgkQAAIJEAACCRAAsgkQAvoJEAP+CRAD/gkQA/4JEAP+CRADAgkQALoJEAACCRAAAgkQAAP///wD///8AgkQAAIJEABSCRACSgkQA/IJEAP99PQD/dzMA/3czAP99PQD/gkQA/4JEAPyCRACUgkQAFIJEAAD///8A////AHw+AFiBQwDqgkQA/4BBAP9/PxP/uZd6/9rJtf/bybX/upd7/39AFP+AQQD/gkQA/4FDAOqAQgBc////AP///wDKklv4jlEa/3o7AP+PWC//8+3o///////////////////////z7un/kFox/35AAP+GRwD/mVYA+v///wD///8A0Zpk+NmibP+0d0T/8evj///////+/fv/1sKz/9bCs//9/fr//////+/m2/+NRwL/nloA/5xYAPj///8A////ANKaZPjRmGH/5cKh////////////k149/3UwAP91MQD/lmQ//86rhv+USg3/m1YA/5hSAP+bVgD4////AP///wDSmmT4zpJY/+/bx///////8+TV/8mLT/+TVx//gkIA/5lVAP+VTAD/x6B//7aEVv/JpH7/s39J+P///wD///8A0ppk+M6SWP/u2sf///////Pj1f/Nj1T/2KFs/8mOUv+eWhD/lEsA/8aee/+0glT/x6F7/7J8Rvj///8A////ANKaZPjRmGH/48Cf///////+/v7/2qt//82PVP/OkFX/37KJ/86siv+USg7/mVQA/5hRAP+bVgD4////AP///wDSmmT40ppk/9CVXP/69O////////7+/v/x4M//8d/P//7+/f//////9u7n/6tnJf+XUgD/nFgA+P///wD///8A0ppk+NKaZP/RmWL/1qNy//r07///////////////////////+vXw/9akdP/Wnmn/y5FY/6JfFvj///8A////ANKaZFTSmmTo0ppk/9GYYv/Ql1//5cWm//Hg0P/x4ND/5cWm/9GXYP/RmGH/0ppk/9KaZOjVnmpY////AP///wDSmmQA0ppkEtKaZI7SmmT60ppk/9CWX//OkVb/zpFW/9CWX//SmmT/0ppk/NKaZJDSmmQS0ppkAP///wD///8A0ppkANKaZADSmmQA0ppkKtKaZLrSmmT/0ppk/9KaZP/SmmT/0ppkvNKaZCrSmmQA0ppkANKaZAD///8A////ANKaZADSmmQA0ppkANKaZADSmmQA0ppkUtKaZNzSmmTc0ppkVNKaZADSmmQA0ppkANKaZADSmmQA////AP5/AAD4HwAA4AcAAMADAACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAMADAADgBwAA+B8AAP5/AAAoAAAAIAAAAEAAAAABACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AP///wCCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRAAAgkQAAIJEAAyCRACMgkQA6oJEAOqCRACQgkQAEIJEAACCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRAAA////AP///wD///8A////AIJEAACCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRABigkQA5oJEAP+CRAD/gkQA/4JEAP+CRADqgkQAZoJEAACCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRAAAgkQAAIJEAAD///8A////AP///wD///8AgkQAAIJEAACCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRAA4gkQAwoJEAP+CRAD/gkQA/4JEAP+CRAD/gkQA/4JEAP+CRAD/gkQAxIJEADyCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRAAAgkQAAP///wD///8A////AP///wCCRAAAgkQAAIJEAACCRAAAgkQAAIJEAACCRAAWgkQAmIJEAP+CRAD/gkQA/4JEAP+CRAD/gkQA/4JEAP+CRAD/gkQA/4JEAP+CRAD/gkQA/4JEAJyCRAAYgkQAAIJEAACCRAAAgkQAAIJEAACCRAAA////AP///wD///8A////AIJEAACCRAAAgkQAAIJEAACCRAAAgkQAdIJEAPCCRAD/gkQA/4JEAP+CRAD/gkQA/4JEAP+CRAD/gkQA/4JEAP+CRAD/gkQA/4JEAP+CRAD/gkQA/4JEAPSCRAB4gkQAAIJEAACCRAAAgkQAAIJEAAD///8A////AP///wD///8AgkQAAIJEAACCRAAAgkQASoJEANKCRAD/gkQA/4JEAP+CRAD/g0YA/39AAP9zLgD/bSQA/2shAP9rIQD/bSQA/3MuAP9/PwD/g0YA/4JEAP+CRAD/gkQA/4JEAP+CRADUgkQAToJEAACCRAAAgkQAAP///wD///8A////AP///wB+PwAAgkUAIoJEAKiCRAD/gkQA/4JEAP+CRAD/hEcA/4BBAP9sIwD/dTAA/5RfKv+viF7/vp56/76ee/+wiF7/lWAr/3YxAP9sIwD/f0AA/4RHAP+CRAD/gkQA/4JEAP+CRAD/gkQArIJEACaBQwAA////AP///wD///8A////AIBCAEBzNAD6f0EA/4NFAP+CRAD/gkQA/4VIAP92MwD/bSUA/6N1Tv/ezsL/////////////////////////////////38/D/6V3Uv9uJgD/dTEA/4VJAP+CRAD/gkQA/4JEAP+BQwD/fUAA/4FDAEj///8A////AP///wD///8AzJRd5qBlKf91NgD/dDUA/4JEAP+FSQD/cy4A/3YyAP/PuKP//////////////////////////////////////////////////////9K7qP94NQD/ciwA/4VJAP+CRAD/fkEA/35BAP+LSwD/mlYA6v///wD///8A////AP///wDdpnL/4qx3/8KJUv+PUhf/cTMA/3AsAP90LgD/4dK+/////////////////////////////////////////////////////////////////+TYxf91MAD/dTIA/31CAP+GRwD/llQA/6FcAP+gWwD8////AP///wD///8A////ANGZY/LSm2X/4ap3/92mcP+wdT3/byQA/8mwj////////////////////////////////////////////////////////////////////////////+LYxv9zLgP/jUoA/59bAP+hXAD/nFgA/5xYAPL///8A////AP///wD///8A0ppk8tKaZP/RmWL/1p9q/9ubXv/XqXj////////////////////////////7+fD/vZyG/6BxS/+gcUr/vJuE//r37f//////////////////////3MOr/5dQBf+dVQD/nVkA/5xYAP+cWAD/nFgA8v///wD///8A////AP///wDSmmTy0ppk/9KaZP/SmWP/yohJ//jo2P//////////////////////4NTG/4JDFf9lGAD/bSQA/20kAP9kGAD/fz8S/+Xb0f//////5NG9/6txN/+LOgD/m1QA/51aAP+cWAD/m1cA/5xYAP+cWADy////AP///wD///8A////ANKaZPLSmmT/0ppk/8+TWf/Unmv//v37//////////////////////+TWRr/VwsA/35AAP+ERgD/g0UA/4JGAP9lHgD/kFga/8KXX/+TRwD/jT4A/49CAP+VTQD/n10A/5xYAP+OQQD/lk4A/55cAPL///8A////AP///wD///8A0ppk8tKaZP/SmmT/y4tO/92yiP//////////////////////8NnE/8eCQP+rcTT/ez0A/3IyAP98PgD/gEMA/5FSAP+USwD/jj8A/5lUAP+JNwD/yqV2/694Mf+HNQD/jkAA/82rf/+laBj/jT4A8v///wD///8A////AP///wDSmmTy0ppk/9KaZP/LiUr/4byY///////////////////////gupX/0I5P/+Wuev/Lklz/l1sj/308AP+QSwD/ol0A/59aAP+aVQD/k0oA/8yoh///////+fXv/6pwO//Lp3v///////Pr4f+oay7y////AP///wD///8A////ANKaZPLSmmT/0ppk/8uJSv/hvJj//////////////////////+G7l//Jhkb/0ppk/96nc//fqXX/x4xO/6dkFP+QSQD/llEA/5xXAP+USgD/yaOA///////38uv/qG05/8ijdv//////8efb/6ZpLPL///8A////AP///wD///8A0ppk8tKaZP/SmmT/zIxO/9yxh///////////////////////7dbA/8iEQf/Sm2X/0Zlj/9ScZv/eqHf/2KJv/7yAQf+XTgD/iToA/5lSAP+JNgD/yKFv/611LP+HNQD/jT8A/8qmeP+kZRT/jT4A8v///wD///8A////AP///wDSmmTy0ppk/9KaZP/Pk1n/1J5q//78+//////////////////+/fv/1aFv/8iEQv/Tm2b/0ppl/9GZY//Wn2z/1pZc/9eldf/Bl2b/kUcA/4w9AP+OQAD/lUwA/59eAP+cWQD/jT8A/5ZOAP+eXADy////AP///wD///8A////ANKaZPLSmmT/0ppk/9KZY//KiEn/8d/P///////////////////////47+f/05tm/8iCP//KiEj/yohJ/8eCP//RmGH//vfy///////n1sP/rXQ7/4k4AP+TTAD/nVoA/5xYAP+cVwD/nFgA/5xYAPL///8A////AP///wD///8A0ppk8tKaZP/SmmT/0ptl/8uLTf/aq37////////////////////////////+/fz/6c2y/961jv/etY7/6Myx//78+v//////////////////////3MWv/5xXD/+ORAD/mFQA/51ZAP+cWAD/nFgA8v///wD///8A////AP///wDSmmTy0ppk/9KaZP/SmmT/0ppk/8mFRP/s1b//////////////////////////////////////////////////////////////////////////////+PD/0JFU/7NzMv+WUQD/kUsA/5tXAP+dWQDy////AP///wD///8A////ANKaZP/SmmT/0ppk/9KaZP/Sm2X/z5NZ/8yMT//z5NX/////////////////////////////////////////////////////////////////9Ofa/8yNUP/UmGH/36p5/8yTWv+qaSD/kksA/5ROAPz///8A////AP///wD///8A0ppk5NKaZP/SmmT/0ppk/9KaZP/TnGf/zY9T/82OUv/t1sD//////////////////////////////////////////////////////+7Yw//OkFX/zI5R/9OcZ//SmmP/26V0/9ymdf/BhUf/ol8R6P///wD///8A////AP///wDSmmQ80ppk9tKaZP/SmmT/0ppk/9KaZP/TnGj/zpFW/8qJSv/dson/8uHS//////////////////////////////////Lj0//etIv/y4lL/86QVf/TnGj/0ppk/9KaZP/RmWP/05xn/9ymdfjUnWdC////AP///wD///8A////ANKaZADSmmQc0ppkotKaZP/SmmT/0ppk/9KaZP/Tm2b/0Zli/8qJSf/NjlH/16Z3/+G8mP/myKr/5siq/+G8mP/Xp3f/zY5S/8qISf/RmGH/05tm/9KaZP/SmmT/0ppk/9KaZP/SmmSm0pljINWdaQD///8A////AP///wD///8A0ppkANKaZADSmmQA0ppkQtKaZMrSmmT/0ppk/9KaZP/SmmT/0ptl/9GYYf/Nj1P/y4lL/8qISP/KiEj/y4lK/82PU//RmGH/0ptl/9KaZP/SmmT/0ppk/9KaZP/SmmTO0ppkRtKaZADSmmQA0ppkAP///wD///8A////AP///wDSmmQA0ppkANKaZADSmmQA0ppkANKaZGzSmmTu0ppk/9KaZP/SmmT/0ppk/9KaZP/SmmT/0ppk/9KaZP/SmmT/0ppk/9KaZP/SmmT/0ppk/9KaZP/SmmTw0ppkcNKaZADSmmQA0ppkANKaZADSmmQA////AP///wD///8A////ANKaZADSmmQA0ppkANKaZADSmmQA0ppkANKaZBLSmmSQ0ppk/9KaZP/SmmT/0ppk/9KaZP/SmmT/0ppk/9KaZP/SmmT/0ppk/9KaZP/SmmT/0ppklNKaZBTSmmQA0ppkANKaZADSmmQA0ppkANKaZAD///8A////AP///wD///8A0ppkANKaZADSmmQA0ppkANKaZADSmmQA0ppkANKaZADSmmQy0ppkutKaZP/SmmT/0ppk/9KaZP/SmmT/0ppk/9KaZP/SmmT/0ppkvtKaZDbSmmQA0ppkANKaZADSmmQA0ppkANKaZADSmmQA0ppkAP///wD///8A////AP///wDSmmQA0ppkANKaZADSmmQA0ppkANKaZADSmmQA0ppkANKaZADSmmQA0ppkXNKaZODSmmT/0ppk/9KaZP/SmmT/0ppk5NKaZGDSmmQA0ppkANKaZADSmmQA0ppkANKaZADSmmQA0ppkANKaZADSmmQA////AP///wD///8A////ANKaZADSmmQA0ppkANKaZADSmmQA0ppkANKaZADSmmQA0ppkANKaZADSmmQA0ppkBtKaZIbSmmTo0ppk6tKaZIrSmmQK0ppkANKaZADSmmQA0ppkANKaZADSmmQA0ppkANKaZADSmmQA0ppkANKaZAD///8A////AP/8P///+B///+AH//+AAf//AAD//AAAP/AAAA/gAAAHwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA+AAAAfwAAAP/AAAP/8AAP//gAH//+AH///4H////D//" rel="icon">
  <!--[if lt IE 9]>
    <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
  <![endif]-->
  
</head>
<body>
<div class="wrapper">
<header id="title-block-header">
<h1 class="title" style="text-align:center">A free function linear
algebra interface based on the BLAS</h1>

<table style="border:none;float:right">
  <tbody><tr>
    <td>Document #: </td>
    <td>P1673</td>
  </tr>
  <tr>
    <td>Date: </td>
    <td>2023-11-10</td>
  </tr>
  <tr>
    <td style="vertical-align:top">Project: </td>
    <td>Programming Language C++<br>
      LEWG<br>
    </td>
  </tr>
  <tr>
    <td style="vertical-align:top">Reply-to: </td>
    <td>
      Mark Hoemmen<br>&lt;<a href="mailto:mhoemmen@nvidia.com" class="email">mhoemmen@nvidia.com</a>&gt;<br>
      Daisy Hollman<br>&lt;<a href="mailto:cpp@dsh.fyi" class="email">cpp@dsh.fyi</a>&gt;<br>
      Christian Trott<br>&lt;<a href="mailto:crtrott@sandia.gov" class="email">crtrott@sandia.gov</a>&gt;<br>
      Daniel Sunderland<br>&lt;<a href="mailto:dansunderland@gmail.com" class="email">dansunderland@gmail.com</a>&gt;<br>
      Nevin Liber<br>&lt;<a href="mailto:nliber@anl.gov" class="email">nliber@anl.gov</a>&gt;<br>
      Alicia Klinvex<br>&lt;<a href="mailto:alicia.klinvex@unnpp.gov" class="email">alicia.klinvex@unnpp.gov</a>&gt;<br>
      Li-Ta Lo<br>&lt;<a href="mailto:ollie@lanl.gov" class="email">ollie@lanl.gov</a>&gt;<br>
      Damien Lebrun-Grandie<br>&lt;<a href="mailto:lebrungrandt@ornl.gov" class="email">lebrungrandt@ornl.gov</a>&gt;<br>
      Graham Lopez<br>&lt;<a href="mailto:glopez@nvidia.com" class="email">glopez@nvidia.com</a>&gt;<br>
      Peter Caday<br>&lt;<a href="mailto:peter.caday@intel.com" class="email">peter.caday@intel.com</a>&gt;<br>
      Sarah Knepper<br>&lt;<a href="mailto:sarah.knepper@intel.com" class="email">sarah.knepper@intel.com</a>&gt;<br>
      Piotr Luszczek<br>&lt;<a href="mailto:luszczek@icl.utk.edu" class="email">luszczek@icl.utk.edu</a>&gt;<br>
      Timothy Costa<br>&lt;<a href="mailto:tcosta@nvidia.com" class="email">tcosta@nvidia.com</a>&gt;<br>
    </td>
  </tr>
</tbody></table>

</header>
<div style="clear:both">
<div id="TOC" role="doc-toc">
<h1 id="toctitle">Contents</h1>
<ul>
<li><a href="#authors-and-contributors" id="toc-authors-and-contributors"><span class="toc-section-number">1</span> Authors and contributors</a>
<ul>
<li><a href="#authors" id="toc-authors"><span class="toc-section-number">1.1</span> Authors</a></li>
<li><a href="#contributors" id="toc-contributors"><span class="toc-section-number">1.2</span> Contributors</a></li>
</ul></li>
<li><a href="#revision-history" id="toc-revision-history"><span class="toc-section-number">2</span> Revision history</a></li>
<li><a href="#purpose-of-this-paper" id="toc-purpose-of-this-paper"><span class="toc-section-number">3</span>
Purpose of this paper</a></li>
<li><a href="#overview-of-contents" id="toc-overview-of-contents"><span class="toc-section-number">4</span> Overview of contents</a></li>
<li><a href="#why-include-dense-linear-algebra-in-the-c-standard-library" id="toc-why-include-dense-linear-algebra-in-the-c-standard-library"><span class="toc-section-number">5</span> Why include dense linear algebra in
the C++ Standard Library?</a></li>
<li><a href="#why-base-a-c-linear-algebra-library-on-the-blas" id="toc-why-base-a-c-linear-algebra-library-on-the-blas"><span class="toc-section-number">6</span> Why base a C++ linear algebra
library on the BLAS?</a></li>
<li><a href="#criteria-for-including-algorithms" id="toc-criteria-for-including-algorithms"><span class="toc-section-number">7</span> Criteria for including
algorithms</a>
<ul>
<li><a href="#criteria-for-all-the-algorithms" id="toc-criteria-for-all-the-algorithms"><span class="toc-section-number">7.1</span> Criteria for all the
algorithms</a></li>
<li><a href="#criteria-for-including-blas-1-algorithms-coexistence-with-ranges" id="toc-criteria-for-including-blas-1-algorithms-coexistence-with-ranges"><span class="toc-section-number">7.2</span> Criteria for including BLAS 1
algorithms; coexistence with ranges</a>
<ul>
<li><a href="#low-risk-of-syntactic-collision-with-ranges" id="toc-low-risk-of-syntactic-collision-with-ranges"><span class="toc-section-number">7.2.1</span> Low risk of syntactic collision
with ranges</a></li>
<li><a href="#minimal-overlap-with-ranges-is-justified-by-user-convenience" id="toc-minimal-overlap-with-ranges-is-justified-by-user-convenience"><span class="toc-section-number">7.2.2</span> Minimal overlap with ranges is
justified by user convenience</a></li>
</ul></li>
</ul></li>
<li><a href="#notation-and-conventions" id="toc-notation-and-conventions"><span class="toc-section-number">8</span> Notation and conventions</a>
<ul>
<li><a href="#the-blas-uses-fortran-terms" id="toc-the-blas-uses-fortran-terms"><span class="toc-section-number">8.1</span> The BLAS uses Fortran
terms</a></li>
<li><a href="#we-call-subroutines-functions" id="toc-we-call-subroutines-functions"><span class="toc-section-number">8.2</span> We call “subroutines”
functions</a></li>
<li><a href="#element-types-and-blas-function-name-prefix" id="toc-element-types-and-blas-function-name-prefix"><span class="toc-section-number">8.3</span> Element types and BLAS function
name prefix</a></li>
</ul></li>
<li><a href="#what-we-exclude-from-the-design" id="toc-what-we-exclude-from-the-design"><span class="toc-section-number">9</span> What we exclude from the design</a>
<ul>
<li><a href="#most-functions-not-in-the-reference-blas" id="toc-most-functions-not-in-the-reference-blas"><span class="toc-section-number">9.1</span> Most functions not in the
Reference BLAS</a></li>
<li><a href="#lapack-or-related-functionality" id="toc-lapack-or-related-functionality"><span class="toc-section-number">9.2</span> LAPACK or related
functionality</a></li>
<li><a href="#extended-precision-blas" id="toc-extended-precision-blas"><span class="toc-section-number">9.3</span> Extended-precision BLAS</a></li>
<li><a href="#arithmetic-operators-and-associated-expression-templates" id="toc-arithmetic-operators-and-associated-expression-templates"><span class="toc-section-number">9.4</span> Arithmetic operators and
associated expression templates</a></li>
<li><a href="#banded-matrix-layouts" id="toc-banded-matrix-layouts"><span class="toc-section-number">9.5</span> Banded matrix layouts</a></li>
<li><a href="#tensors" id="toc-tensors"><span class="toc-section-number">9.6</span> Tensors</a></li>
<li><a href="#explicit-support-for-asynchronous-return-of-scalar-values" id="toc-explicit-support-for-asynchronous-return-of-scalar-values"><span class="toc-section-number">9.7</span> Explicit support for asynchronous
return of scalar values</a></li>
</ul></li>
<li><a href="#design-justification" id="toc-design-justification"><span class="toc-section-number">10</span> Design justification</a>
<ul>
<li><a href="#we-do-not-require-using-the-blas-library-or-any-particular-back-end" id="toc-we-do-not-require-using-the-blas-library-or-any-particular-back-end"><span class="toc-section-number">10.1</span> We do not require using the BLAS
library or any particular “back-end”</a></li>
<li><a href="#why-use-mdspan" id="toc-why-use-mdspan"><span class="toc-section-number">10.2</span> Why use <code>mdspan</code>?</a>
<ul>
<li><a href="#view-of-a-multidimensional-array" id="toc-view-of-a-multidimensional-array"><span class="toc-section-number">10.2.1</span> View of a multidimensional
array</a></li>
<li><a href="#ease-of-use" id="toc-ease-of-use"><span class="toc-section-number">10.2.2</span> Ease of use</a></li>
<li><a href="#blas-and-mdspan-are-low-level" id="toc-blas-and-mdspan-are-low-level"><span class="toc-section-number">10.2.3</span> BLAS and <code>mdspan</code>
are low level</a></li>
<li><a href="#hook-for-future-expansion" id="toc-hook-for-future-expansion"><span class="toc-section-number">10.2.4</span> Hook for future
expansion</a></li>
<li><a href="#generic-enough-to-replace-a-multidimensional-array-concept" id="toc-generic-enough-to-replace-a-multidimensional-array-concept"><span class="toc-section-number">10.2.5</span> Generic enough to replace a
“multidimensional array concept”</a></li>
</ul></li>
<li><a href="#function-argument-aliasing-and-zero-scalar-multipliers" id="toc-function-argument-aliasing-and-zero-scalar-multipliers"><span class="toc-section-number">10.3</span> Function argument aliasing and
zero scalar multipliers</a></li>
<li><a href="#support-for-different-matrix-layouts" id="toc-support-for-different-matrix-layouts"><span class="toc-section-number">10.4</span> Support for different matrix
layouts</a></li>
<li><a href="#interpretation-of-lower-upper-triangular" id="toc-interpretation-of-lower-upper-triangular"><span class="toc-section-number">10.5</span> Interpretation of “lower / upper
triangular”</a>
<ul>
<li><a href="#triangle-refers-to-what-part-of-the-matrix-is-accessed" id="toc-triangle-refers-to-what-part-of-the-matrix-is-accessed"><span class="toc-section-number">10.5.1</span> Triangle refers to what part of
the matrix is accessed</a></li>
<li><a href="#blas-applies-uplo-to-original-matrix-we-apply-triangle-to-transformed-matrix" id="toc-blas-applies-uplo-to-original-matrix-we-apply-triangle-to-transformed-matrix"><span class="toc-section-number">10.5.2</span> BLAS applies UPLO to original
matrix; we apply Triangle to transformed matrix</a></li>
<li><a href="#summary" id="toc-summary"><span class="toc-section-number">10.5.3</span> Summary</a></li>
</ul></li>
<li><a href="#norms-and-infinity-norms-for-vectors-and-matrices-of-complex-numbers" id="toc-norms-and-infinity-norms-for-vectors-and-matrices-of-complex-numbers"><span class="toc-section-number">10.6</span> 1-norms and infinity-norms for
vectors and matrices of complex numbers</a>
<ul>
<li><a href="#summary-1" id="toc-summary-1"><span class="toc-section-number">10.6.1</span> Summary</a></li>
<li><a href="#vectors" id="toc-vectors"><span class="toc-section-number">10.6.2</span> Vectors</a></li>
<li><a href="#matrices" id="toc-matrices"><span class="toc-section-number">10.6.3</span> Matrices</a></li>
</ul></li>
<li><a href="#over--and-underflow-wording-for-vector-2-norm" id="toc-over--and-underflow-wording-for-vector-2-norm"><span class="toc-section-number">10.7</span> Over- and underflow wording for
vector 2-norm</a></li>
<li><a href="#constraining-matrix-and-vector-element-types-and-scalars" id="toc-constraining-matrix-and-vector-element-types-and-scalars"><span class="toc-section-number">10.8</span> Constraining matrix and vector
element types and scalars</a>
<ul>
<li><a href="#introduction" id="toc-introduction"><span class="toc-section-number">10.8.1</span> Introduction</a></li>
<li><a href="#value-type-constraints-do-not-suffice-to-describe-algorithm-behavior" id="toc-value-type-constraints-do-not-suffice-to-describe-algorithm-behavior"><span class="toc-section-number">10.8.2</span> Value type constraints do not
suffice to describe algorithm behavior</a></li>
<li><a href="#associativity-is-too-strict" id="toc-associativity-is-too-strict"><span class="toc-section-number">10.8.3</span> Associativity is too
strict</a></li>
<li><a href="#generalizing-associativity-helps-little" id="toc-generalizing-associativity-helps-little"><span class="toc-section-number">10.8.4</span> Generalizing associativity
helps little</a></li>
<li><a href="#categories-of-qoi-enhancements" id="toc-categories-of-qoi-enhancements"><span class="toc-section-number">10.8.5</span> Categories of QoI
enhancements</a></li>
<li><a href="#properties-of-textbook-algorithm-descriptions" id="toc-properties-of-textbook-algorithm-descriptions"><span class="toc-section-number">10.8.6</span> Properties of textbook
algorithm descriptions</a></li>
<li><a href="#reordering-sums-and-creating-temporaries" id="toc-reordering-sums-and-creating-temporaries"><span class="toc-section-number">10.8.7</span> Reordering sums and creating
temporaries</a></li>
<li><a href="#textbook-algorithm-description-in-semiring-terms" id="toc-textbook-algorithm-description-in-semiring-terms"><span class="toc-section-number">10.8.8</span> “Textbook” algorithm
description in semiring terms</a></li>
<li><a href="#summary-2" id="toc-summary-2"><span class="toc-section-number">10.8.9</span> Summary</a></li>
</ul></li>
<li><a href="#fix-issues-with-complex-and-support-user-defined-complex-number-types" id="toc-fix-issues-with-complex-and-support-user-defined-complex-number-types"><span class="toc-section-number">10.9</span> Fix issues with
<code>complex</code>, and support user-defined complex number types</a>
<ul>
<li><a href="#motivation-and-summary-of-solution" id="toc-motivation-and-summary-of-solution"><span class="toc-section-number">10.9.1</span> Motivation and summary of
solution</a></li>
<li><a href="#why-users-define-their-own-complex-number-types" id="toc-why-users-define-their-own-complex-number-types"><span class="toc-section-number">10.9.2</span> Why users define their own
complex number types</a></li>
<li><a href="#why-users-want-to-conjugate-matrices-of-real-numbers" id="toc-why-users-want-to-conjugate-matrices-of-real-numbers"><span class="toc-section-number">10.9.3</span> Why users want to “conjugate”
matrices of real numbers</a></li>
<li><a href="#effects-of-conjs-real-to-complex-change" id="toc-effects-of-conjs-real-to-complex-change"><span class="toc-section-number">10.9.4</span> Effects of <code>conj</code>’s
real-to-complex change</a></li>
<li><a href="#lewg-feedback-on-r8-solution" id="toc-lewg-feedback-on-r8-solution"><span class="toc-section-number">10.9.5</span> LEWG feedback on R8
solution</a></li>
<li><a href="#sg6s-response-to-lewgs-r8-feedback" id="toc-sg6s-response-to-lewgs-r8-feedback"><span class="toc-section-number">10.9.6</span> SG6’s response to LEWG’s R8
feedback</a></li>
<li><a href="#current-solution" id="toc-current-solution"><span class="toc-section-number">10.9.7</span> Current solution</a></li>
</ul></li>
<li><a href="#support-for-division-with-noncommutative-multiplication" id="toc-support-for-division-with-noncommutative-multiplication"><span class="toc-section-number">10.10</span> Support for division with
noncommutative multiplication</a></li>
<li><a href="#packed-layouts-triangle-must-match-functions-triangle" id="toc-packed-layouts-triangle-must-match-functions-triangle"><span class="toc-section-number">10.11</span> Packed layout’s Triangle must
match function’s Triangle</a>
<ul>
<li><a href="#summary-3" id="toc-summary-3"><span class="toc-section-number">10.11.1</span> Summary</a></li>
<li><a href="#when-do-packed-formats-show-up-in-practice" id="toc-when-do-packed-formats-show-up-in-practice"><span class="toc-section-number">10.11.2</span> When do packed formats show up
in practice?</a></li>
<li><a href="#what-the-blas-does" id="toc-what-the-blas-does"><span class="toc-section-number">10.11.3</span> What the BLAS does</a></li>
<li><a href="#p1673s-interpretation-of-the-blas" id="toc-p1673s-interpretation-of-the-blas"><span class="toc-section-number">10.11.4</span> P1673’s interpretation of the
BLAS</a></li>
</ul></li>
</ul></li>
<li><a href="#future-work" id="toc-future-work"><span class="toc-section-number">11</span> Future work</a>
<ul>
<li><a href="#batched-linear-algebra" id="toc-batched-linear-algebra"><span class="toc-section-number">11.1</span> Batched linear algebra</a></li>
</ul></li>
<li><a href="#data-structures-and-utilities-borrowed-from-other-proposals" id="toc-data-structures-and-utilities-borrowed-from-other-proposals"><span class="toc-section-number">12</span> Data structures and utilities
borrowed from other proposals</a>
<ul>
<li><a href="#mdspan" id="toc-mdspan"><span class="toc-section-number">12.1</span> <code>mdspan</code></a></li>
<li><a href="#new-mdspan-layouts-in-this-proposal" id="toc-new-mdspan-layouts-in-this-proposal"><span class="toc-section-number">12.2</span> New <code>mdspan</code> layouts
in this proposal</a></li>
</ul></li>
<li><a href="#implementation-experience" id="toc-implementation-experience"><span class="toc-section-number">13</span> Implementation experience</a></li>
<li><a href="#interoperable-with-other-linear-algebra-proposals" id="toc-interoperable-with-other-linear-algebra-proposals"><span class="toc-section-number">14</span> Interoperable with other linear
algebra proposals</a></li>
<li><a href="#acknowledgments" id="toc-acknowledgments"><span class="toc-section-number">15</span> Acknowledgments</a></li>
<li><a href="#references" id="toc-references"><span class="toc-section-number">16</span> References</a>
<ul>
<li><a href="#references-by-coathors" id="toc-references-by-coathors"><span class="toc-section-number">16.1</span> References by coathors</a></li>
<li><a href="#other-references" id="toc-other-references"><span class="toc-section-number">16.2</span> Other references</a></li>
</ul></li>
<li><a href="#dummy-heading-to-align-wording-numbering" id="toc-dummy-heading-to-align-wording-numbering"><span class="toc-section-number">17</span> Dummy Heading To Align Wording
Numbering</a></li>
<li><a href="#dummy-heading-to-align-wording-numbering-1" id="toc-dummy-heading-to-align-wording-numbering-1"><span class="toc-section-number">18</span> Dummy Heading To Align Wording
Numbering</a></li>
<li><a href="#dummy-heading-to-align-wording-numbering-2" id="toc-dummy-heading-to-align-wording-numbering-2"><span class="toc-section-number">19</span> Dummy Heading To Align Wording
Numbering</a></li>
<li><a href="#dummy-heading-to-align-wording-numbering-3" id="toc-dummy-heading-to-align-wording-numbering-3"><span class="toc-section-number">20</span> Dummy Heading To Align Wording
Numbering</a></li>
<li><a href="#dummy-heading-to-align-wording-numbering-4" id="toc-dummy-heading-to-align-wording-numbering-4"><span class="toc-section-number">21</span> Dummy Heading To Align Wording
Numbering</a></li>
<li><a href="#dummy-heading-to-align-wording-numbering-5" id="toc-dummy-heading-to-align-wording-numbering-5"><span class="toc-section-number">22</span> Dummy Heading To Align Wording
Numbering</a></li>
<li><a href="#dummy-heading-to-align-wording-numbering-6" id="toc-dummy-heading-to-align-wording-numbering-6"><span class="toc-section-number">23</span> Dummy Heading To Align Wording
Numbering</a></li>
<li><a href="#dummy-heading-to-align-wording-numbering-7" id="toc-dummy-heading-to-align-wording-numbering-7"><span class="toc-section-number">24</span> Dummy Heading To Align Wording
Numbering</a></li>
<li><a href="#dummy-heading-to-align-wording-numbering-8" id="toc-dummy-heading-to-align-wording-numbering-8"><span class="toc-section-number">25</span> Dummy Heading To Align Wording
Numbering</a></li>
<li><a href="#dummy-heading-to-align-wording-numbering-9" id="toc-dummy-heading-to-align-wording-numbering-9"><span class="toc-section-number">26</span> Dummy Heading To Align Wording
Numbering</a></li>
<li><a href="#dummy-heading-to-align-wording-numbering-10" id="toc-dummy-heading-to-align-wording-numbering-10"><span class="toc-section-number">27</span> Dummy Heading To Align Wording
Numbering</a></li>
<li><a href="#dummy-heading-to-align-wording-numbering-11" id="toc-dummy-heading-to-align-wording-numbering-11"><span class="toc-section-number">28</span> Dummy Heading To Align Wording
Numbering</a>
<ul>
<li><a href="#dummy-heading-to-align-wording-numbering-12" id="toc-dummy-heading-to-align-wording-numbering-12"><span class="toc-section-number">28.1</span> Dummy Heading To Align Wording
Numbering</a></li>
<li><a href="#dummy-heading-to-align-wording-numbering-13" id="toc-dummy-heading-to-align-wording-numbering-13"><span class="toc-section-number">28.2</span> Dummy Heading To Align Wording
Numbering</a></li>
<li><a href="#dummy-heading-to-align-wording-numbering-14" id="toc-dummy-heading-to-align-wording-numbering-14"><span class="toc-section-number">28.3</span> Dummy Heading To Align Wording
Numbering</a></li>
<li><a href="#dummy-heading-to-align-wording-numbering-15" id="toc-dummy-heading-to-align-wording-numbering-15"><span class="toc-section-number">28.4</span> Dummy Heading To Align Wording
Numbering</a></li>
<li><a href="#dummy-heading-to-align-wording-numbering-16" id="toc-dummy-heading-to-align-wording-numbering-16"><span class="toc-section-number">28.5</span> Dummy Heading To Align Wording
Numbering</a></li>
<li><a href="#dummy-heading-to-align-wording-numbering-17" id="toc-dummy-heading-to-align-wording-numbering-17"><span class="toc-section-number">28.6</span> Dummy Heading To Align Wording
Numbering</a></li>
<li><a href="#dummy-heading-to-align-wording-numbering-18" id="toc-dummy-heading-to-align-wording-numbering-18"><span class="toc-section-number">28.7</span> Dummy Heading To Align Wording
Numbering</a></li>
<li><a href="#wording" id="toc-wording"><span class="toc-section-number">28.8</span> Wording</a></li>
<li><a href="#basic-linear-algebra-algorithms-linalg" id="toc-basic-linear-algebra-algorithms-linalg"><span class="toc-section-number">28.9</span> Basic linear algebra algorithms
[linalg]</a>
<ul>
<li><a href="#overview-linalg.overview" id="toc-overview-linalg.overview"><span class="toc-section-number">28.9.1</span> Overview
[linalg.overview]</a></li>
<li><a href="#header-linalg-synopsis-linalg.syn" id="toc-header-linalg-synopsis-linalg.syn"><span class="toc-section-number">28.9.2</span> Header
<code>&lt;linalg&gt;</code> synopsis [linalg.syn]</a></li>
<li><a href="#general-linalg.general" id="toc-general-linalg.general"><span class="toc-section-number">28.9.3</span> General
[linalg.general]</a></li>
<li><a href="#requirements-linalg.reqs" id="toc-requirements-linalg.reqs"><span class="toc-section-number">28.9.4</span> Requirements
[linalg.reqs]</a></li>
<li><a href="#tag-classes-linalg.tags" id="toc-tag-classes-linalg.tags"><span class="toc-section-number">28.9.5</span> Tag classes
[linalg.tags]</a></li>
<li><a href="#layouts-for-packed-matrix-types-linalg.layout.packed" id="toc-layouts-for-packed-matrix-types-linalg.layout.packed"><span class="toc-section-number">28.9.6</span> Layouts for packed matrix types
[linalg.layout.packed]</a></li>
<li><a href="#exposition-only-helpers-linalg.helpers" id="toc-exposition-only-helpers-linalg.helpers"><span class="toc-section-number">28.9.7</span> Exposition-only helpers
[linalg.helpers]</a></li>
<li><a href="#scaled-in-place-transformation-linalg.scaled" id="toc-scaled-in-place-transformation-linalg.scaled"><span class="toc-section-number">28.9.8</span> Scaled in-place transformation
[linalg.scaled]</a></li>
<li><a href="#conjugated-in-place-transformation-linalg.conj" id="toc-conjugated-in-place-transformation-linalg.conj"><span class="toc-section-number">28.9.9</span> Conjugated in-place
transformation [linalg.conj]</a></li>
<li><a href="#transpose-in-place-transformation-linalg.transp" id="toc-transpose-in-place-transformation-linalg.transp"><span class="toc-section-number">28.9.10</span> Transpose in-place
transformation [linalg.transp]</a></li>
<li><a href="#conjugate-transpose-in-place-transform-linalg.conjtransposed" id="toc-conjugate-transpose-in-place-transform-linalg.conjtransposed"><span class="toc-section-number">28.9.11</span> Conjugate transpose in-place
transform [linalg.conjtransposed]</a></li>
<li><a href="#algorithm-requirements-based-on-template-parameter-name-linalg.algs.reqs" id="toc-algorithm-requirements-based-on-template-parameter-name-linalg.algs.reqs"><span class="toc-section-number">28.9.12</span> Algorithm Requirements based
on template parameter name [linalg.algs.reqs]</a></li>
<li><a href="#blas-1-algorithms-linalg.algs.blas1" id="toc-blas-1-algorithms-linalg.algs.blas1"><span class="toc-section-number">28.9.13</span> BLAS 1 algorithms
[linalg.algs.blas1]</a></li>
<li><a href="#blas-2-algorithms-linalg.algs.blas2" id="toc-blas-2-algorithms-linalg.algs.blas2"><span class="toc-section-number">28.9.14</span> BLAS 2 algorithms
[linalg.algs.blas2]</a></li>
<li><a href="#blas-3-algorithms-linalg.algs.blas3" id="toc-blas-3-algorithms-linalg.algs.blas3"><span class="toc-section-number">28.9.15</span> BLAS 3 algorithms
[linalg.algs.blas3]</a></li>
</ul></li>
</ul></li>
<li><a href="#examples" id="toc-examples"><span class="toc-section-number">29</span> Examples</a>
<ul>
<li><a href="#cholesky-factorization" id="toc-cholesky-factorization"><span class="toc-section-number">29.1</span> Cholesky factorization</a></li>
<li><a href="#solve-linear-system-using-cholesky-factorization" id="toc-solve-linear-system-using-cholesky-factorization"><span class="toc-section-number">29.2</span> Solve linear system using
Cholesky factorization</a></li>
<li><a href="#compute-qr-factorization-of-a-tall-skinny-matrix" id="toc-compute-qr-factorization-of-a-tall-skinny-matrix"><span class="toc-section-number">29.3</span> Compute QR factorization of a
tall skinny matrix</a></li>
</ul></li>
</ul>
</div>
<h1 data-number="1" id="authors-and-contributors"><span class="header-section-number">1</span> Authors and contributors<a href="#authors-and-contributors" class="self-link"></a></h1>
<h2 data-number="1.1" id="authors"><span class="header-section-number">1.1</span> Authors<a href="#authors" class="self-link"></a></h2>
<ul>
<li><p>Mark Hoemmen (mhoemmen@nvidia.com) (NVIDIA)</p></li>
<li><p>Daisy Hollman (cpp@dsh.fyi) (Google)</p></li>
<li><p>Christian Trott (crtrott@sandia.gov) (Sandia National
Laboratories)</p></li>
<li><p>Daniel Sunderland (dansunderland@gmail.com)</p></li>
<li><p>Nevin Liber (nliber@anl.gov) (Argonne National
Laboratory)</p></li>
<li><p>Alicia Klinvex (alicia.klinvex@unnpp.gov) (Naval Nuclear
Laboratory)</p></li>
<li><p>Li-Ta Lo (ollie@lanl.gov) (Los Alamos National
Laboratory)</p></li>
<li><p>Damien Lebrun-Grandie (lebrungrandt@ornl.gov) (Oak Ridge National
Laboratories)</p></li>
<li><p>Graham Lopez (glopez@nvidia.com) (NVIDIA)</p></li>
<li><p>Peter Caday (peter.caday@intel.com) (Intel)</p></li>
<li><p>Sarah Knepper (sarah.knepper@intel.com) (Intel)</p></li>
<li><p>Piotr Luszczek (luszczek@icl.utk.edu) (University of
Tennessee)</p></li>
<li><p>Timothy Costa (tcosta@nvidia.com) (NVIDIA)</p></li>
</ul>
<h2 data-number="1.2" id="contributors"><span class="header-section-number">1.2</span> Contributors<a href="#contributors" class="self-link"></a></h2>
<ul>
<li><p>Zach Laine (particular thanks for R12 review and
suggestions)</p></li>
<li><p>Chip Freitag (chip.freitag@amd.com) (AMD)</p></li>
<li><p>Bryce Adelstein Lelbach (brycelelbach@gmail.com)
(NVIDIA)</p></li>
<li><p>Srinath Vadlamani (Srinath.Vadlamani@arm.com) (ARM)</p></li>
<li><p>Rene Vanoostrum (Rene.Vanoostrum@amd.com) (AMD)</p></li>
</ul>
<h1 data-number="2" id="revision-history"><span class="header-section-number">2</span> Revision history<a href="#revision-history" class="self-link"></a></h1>
<ul>
<li><p>Revision 0 (pre-Cologne) submitted 2019-06-17</p>
<ul>
<li>Received feedback in Cologne from SG6, LEWGI, and (???).</li>
</ul></li>
<li><p>Revision 1 (pre-Belfast) to be submitted 2019-10-07</p>
<ul>
<li><p>Account for Cologne 2019 feedback</p>
<ul>
<li><p>Make interface more consistent with existing Standard
algorithms</p></li>
<li><p>Change <code>dot</code>, <code>dotc</code>,
<code>vector_norm2</code>, and <code>vector_abs_sum</code> to imitate
<code>reduce</code>, so that they return their result, instead of taking
an output parameter. Users may set the result type via optional
<code>init</code> parameter.</p></li>
</ul></li>
<li><p>Minor changes to “expression template” classes, based on
implementation experience</p></li>
<li><p>Briefly address LEWGI request of exploring concepts for input
arguments.</p></li>
<li><p>Lazy ranges style API was NOT explored.</p></li>
</ul></li>
<li><p>Revision 2 (pre-Cologne) to be submitted 2020-01-13</p>
<ul>
<li><p>Add “Future work” section.</p></li>
<li><p>Remove “Options and votes” section (which were addressed in SG6,
SG14, and LEWGI).</p></li>
<li><p>Remove <code>basic_mdarray</code> overloads.</p></li>
<li><p>Remove batched linear algebra operations.</p></li>
<li><p>Remove over- and underflow requirement for
<code>vector_norm2</code>.</p></li>
<li><p><em>Mandate</em> any extent compatibility checks that can be done
at compile time.</p></li>
<li><p>Add missing functions
<code>{symmetric,hermitian}_matrix_rank_k_update</code> and
<code>triangular_matrix_{left,right}_product</code>.</p></li>
<li><p>Remove <code>packed_view</code> function.</p></li>
<li><p>Fix wording for
<code>{conjugate,transpose,conjugate_transpose}_view</code>, so that
implementations may optimize the return type. Make sure that
<code>transpose_view</code> of a <code>layout_blas_packed</code> matrix
returns a <code>layout_blas_packed</code> matrix with opposite
<code>Triangle</code> and <code>StorageOrder</code>.</p></li>
<li><p>Remove second template parameter <code>T</code> from
<code>accessor_conjugate</code>.</p></li>
<li><p>Make <code>scaled_scalar</code> and
<code>conjugated_scalar</code> exposition only.</p></li>
<li><p>Add in-place overloads of
<code>triangular_matrix_matrix_{left,right}_solve</code>,
<code>triangular_matrix_{left,right}_product</code>, and
<code>triangular_matrix_vector_solve</code>.</p></li>
<li><p>Add <code>alpha</code> overloads to
<code>{symmetric,hermitian}_matrix_rank_{1,k}_update</code>.</p></li>
<li><p>Add Cholesky factorization and solve examples.</p></li>
</ul></li>
<li><p>Revision 3 (electronic) to be submitted 2021-04-15</p>
<ul>
<li><p>Per LEWG request, add a section on our investigation of
constraining template parameters with concepts, in the manner of P1813R0
with the numeric algorithms. We concluded that we disagree with the
approach of P1813R0, and that the Standard’s current
<em>GENERALIZED_SUM</em> approach better expresses numeric algorithms’
behavior.</p></li>
<li><p>Update references to the current revision of P0009
(<code>mdspan</code>).</p></li>
<li><p>Per LEWG request, introduce <code>std::linalg</code> namespace
and put everything in there.</p></li>
<li><p>Per LEWG request, replace the <code>linalg_</code> prefix with
the aforementioned namespace. We renamed <code>linalg_add</code> to
<code>add</code>, <code>linalg_copy</code> to <code>copy</code>, and
<code>linalg_swap</code> to <code>swap_elements</code>.</p></li>
<li><p>Per LEWG request, do not use <code>_view</code> as a suffix, to
avoid confusion with “views” in the sense of Ranges. We renamed
<code>conjugate_view</code> to <code>conjugated</code>,
<code>conjugate_transpose_view</code> to
<code>conjugate_transposed</code>, <code>scaled_view</code> to
<code>scaled</code>, and <code>transpose_view</code> to
<code>transposed</code>.</p></li>
<li><p>Change wording from “then implementations will use
<code>T</code>’s precision or greater for intermediate terms in the
sum,” to “then intermediate terms in the sum use <code>T</code>’s
precision or greater.” Thanks to Jens Maurer for this suggestion (and
many others!).</p></li>
<li><p>Before, a Note on <code>vector_norm2</code> said, “We recommend
that implementers document their guarantees regarding overflow and
underflow of <code>vector_norm2</code> for floating-point return types.”
Implementations always document “implementation-defined behavior” per
<strong>[defs.impl.defined]</strong>. (Thanks to Jens Maurer for
pointing out that “We recommend…” does not belong in the Standard.)
Thus, we changed this from a Note to normative wording in Remarks: “If
either <code>in_vector_t::element_type</code> or <code>T</code> are
floating-point types or complex versions thereof, then any guarantees
regarding overflow and underflow of <code>vector_norm2</code> are
implementation-defined.”</p></li>
<li><p>Define return types of the <code>dot</code>, <code>dotc</code>,
<code>vector_norm2</code>, and <code>vector_abs_sum</code> overloads
with <code>auto</code> return type.</p></li>
<li><p>Remove the explicitly stated constraint on <code>add</code> and
<code>copy</code> that the rank of the array arguments be no more than
2. This is redundant, because we already impose this via the existing
constraints on template parameters named <code>in_object*_t</code>,
<code>inout_object*_t</code>, or <code>out_object*_t</code>. If we later
wish to relax this restriction, then we only have to do so in one
place.</p></li>
<li><p>Add <code>vector_sum_of_squares</code>. First, this gives
implementers a path to implementing <code>vector_norm2</code> in a way
that achieves the over/underflow guarantees intended by the BLAS
Standard. Second, this is a useful algorithm in itself for parallelizing
vector 2-norm computation.</p></li>
<li><p>Add <code>matrix_frob_norm</code>, <code>matrix_one_norm</code>,
and <code>matrix_inf_norm</code> (thanks to coauthor Piotr
Luszczek).</p></li>
<li><p>Address LEWG request for us to investigate support for GPU
memory. See section “Explicit support for asynchronous return of scalar
values.”</p></li>
<li><p>Add <code>ExecutionPolicy</code> overloads of the in-place
versions of <code>triangular_matrix_vector_solve</code>,
<code>triangular_matrix_left_product</code>,
<code>triangular_matrix_right_product</code>,
<code>triangular_matrix_matrix_left_solve</code>, and
<code>triangular_matrix_matrix_right_solve</code>.</p></li>
</ul></li>
<li><p>Revision 4 (electronic), to be submitted 2021-08-15</p>
<ul>
<li><p>Update authors’ contact info.</p></li>
<li><p>Rebase atop P2299R3, which in turn sits atop P0009R12. Make any
needed fixes due to these changes. (P1673R3 was based on P0009R10,
without P2299.) Update P0009 references to point to the latest version
(R12).</p></li>
<li><p>Fix requirements for
<code>{symmetric,hermitian}_matrix_{left,right}_product</code>.</p></li>
<li><p>Change <code>SemiRegular&lt;Scalar&gt;</code> to
<code>semiregular&lt;Scalar&gt;</code>.</p></li>
<li><p>Make <code>Real</code> requirements refer to
<strong>[complex.numbers.general]</strong>, rather than explicitly
listing allowed types. Remove redundant constraints on
<code>Real</code>.</p></li>
<li><p>In <strong>[linalg.algs.reqs]</strong>, clarify that “unique
layout” for output matrix, vector, or object types means
<code>is_always_unique()</code> equals <code>true</code>.</p></li>
<li><p>Change file format from Markdown to Bikeshed.</p></li>
<li><p>Impose requirements on the types on which algorithms compute, and
on the algorithms themselves (e.g., what rearrangements are permitted).
Add a section explaining how we came up with the requirements. Lift the
requirements into a new higher-level section that applies to the entire
contents of [linalg], not just to
<strong>[linalg.algs]</strong>.</p></li>
<li><p>Add “Overview of contents” section.</p></li>
<li><p>In the last review, LEWG had asked us to consider using
exposition-only concepts and <code>requires</code> clauses to express
requirements more clearly. We decided not to do so, because we did not
think it would add clarity.</p></li>
<li><p>Add more examples.</p></li>
</ul></li>
<li><p>Revision 5 (electronic), to be submitted 2021-10-15</p>
<ul>
<li>P0009R13 (to be submitted 2021-10-15) changes <code>mdspan</code> to
use <code>operator[]</code> instead of <code>operator()</code> as the
array access operator. Revision 5 of P1673 adopts this change, and is
“rebased” atop P1673R5.</li>
</ul></li>
<li><p>Revision 6 (electronic), to be submitted 2021-12-15</p>
<ul>
<li><p>Update references to P0009 (P0009R14) and P2128
(P2128R6).</p></li>
<li><p>Fix typos in <code>*rank_2k</code> descriptions.</p></li>
<li><p>Remove references to any <code>mdspan</code> rank greater than 2.
(These were left over from earlier versions of the proposal that
included “batched” operations.)</p></li>
<li><p>Fix <code>vector_sum_of_squares</code> name in BLAS comparison
table.</p></li>
<li><p>Replace “Requires” with “Preconditions,” per new wording
guidelines.</p></li>
<li><p>Remove all overloads of
<code>symmetric_matrix_rank_k_update</code> and
<code>hermitian_matrix_rank_k_update</code> that do not take an
<code>alpha</code> parameter. This prevents ambiguity between overloads
that take <code>ExecutionPolicy&amp;&amp;</code> but not
<code>alpha</code>, and overloads that take <code>alpha</code> but not
<code>ExecutionPolicy&amp;&amp;</code>.</p></li>
<li><p>Harmonize with the implementation, by adding
<code>operator+</code>, <code>operator*</code>, and comparison operators
to <code>conjugated_scalar</code>.</p></li>
</ul></li>
<li><p>Revision 7 (electronic), to be submitted 2022-04-15</p>
<ul>
<li><p>Update author affiliations and e-mail addresses</p></li>
<li><p>Update proposal references</p></li>
<li><p>Fix typo observed
<a href="https://github.com/kokkos/stdBLAS/issues/158">here</a></p></li>
<li><p>Add missing <code>ExecutionPolicy</code> overload of in-place
<code>triangular_matrix_vector_product</code>; issue was observed
<a href="https://github.com/kokkos/stdBLAS/issues/150">here</a></p></li>
<li><p>Fix mixed-up order of <code>sum_of_squares_result</code>
aggregate initialization arguments in <code>vector_norm2</code>
note</p></li>
<li><p>Fill in missing parts of <code>matrix_frob_norm</code> and
<code>vector_norm2</code> specification, addressing
<a href="https://github.com/kokkos/stdBLAS/issues/143">this
issue</a></p></li>
</ul></li>
<li><p>Revision 8 (electronic), to be submitted 2022-05-15</p>
<ul>
<li><p>Fix <code>Triangle</code> and <code>R[0,0]</code> in Cholesky
TSQR example</p></li>
<li><p>Explain why we apply <code>Triangle</code> to the possibly
transformed input matrix, while the BLAS applies <code>UPLO</code> to
the original input matrix</p></li>
<li><p>Optimize <code>transposed</code> for all known layouts, so as to
avoid use of <code>layout_transpose</code> when not needed; fix
computation of strides for transposed layouts</p></li>
<li><p>Fix matrix extents in constraints and mandates for
<code>symmetric_matrix_rank_k_update</code> and
<code>hermitian_matrix_rank_k_update</code> (thanks to Mikołaj Zuzek
(NexGen Analytics, <code>mikolaj.zuzek@ng-analytics.com</code>) for
reporting the issue)</p></li>
<li><p>Resolve vagueness in <code>const</code>ness of return type of
<code>transposed</code></p></li>
<li><p>Resolve vagueness in <code>const</code>ness of return type of
<code>scaled</code>, and make its element type the type of the product,
rather than forcing it back to the input <code>mdspan</code>’s element
type</p></li>
<li><p>Remove <code>decay</code> member function from
<code>accessor_conjugate</code> and <code>accessor_scaled</code>, as it
is no longer part of <code>mdspan</code>’s accessor policy
requirements</p></li>
<li><p>Make sure <code>accessor_conjugate</code> and
<code>conjugated</code> work correctly for user-defined complex types,
introduce <em><code>conj-if-needed</code></em> to simplify wording, and
resolve vagueness in <code>const</code>ness of return type of
<code>conjugated</code>. Make sure that
<em><code>conj-if-needed</code></em> works for custom types where
<code>conj</code> is not type-preserving. (Thanks to Yu You (NVIDIA,
yuyou@nvidia.com) and Phil Miller (Intense Computing,
<code>phil.miller@intensecomputing.com</code>) for helpful
discussions.)</p></li>
<li><p>Fix typo in <code>givens_rotation_setup</code> for complex
numbers, and other typos (thanks to Phil Miller for reporting the
issue)</p></li>
</ul></li>
<li><p>Revision 9 (electronic), to be submitted 2022-06-15</p>
<ul>
<li><p>Apply to-be-submitted P0009R17 changes (see P2553 in particular)
to all layouts, accessors, and examples in this proposal.</p></li>
<li><p>Improve
<code>triangular_matrix_matrix_{left,right}_solve()</code> “mathematical
expression of the algorithm” wording.</p></li>
<li><p><code>layout_blas_packed</code>: Fix
<code>required_span_size()</code> and <code>operator()</code>
wording</p></li>
<li><p>Make sure all definitions of lower and upper triangle are
consistent.</p></li>
<li><p>Changes to <code>layout_transpose</code>:</p>
<ul>
<li><p>Make
<code>layout_transpose::mapping(const nested_mapping_type&amp;)</code>
constructor <code>explicit</code>, to avoid inadvertent
transposition.</p></li>
<li><p>Remove the following Constraint on
<code>layout_transpose::mapping</code>: “for all specializations
<code>E</code> of <code>extents</code> with <code>E::rank()</code> equal
to 2,
<code>typename Layout::template mapping&lt;E&gt;::is_always_unique()</code>
is <code>true</code>.” (This Constraint was not correct, because the
underlying mapping is allowed to be nonunique.)</p></li>
<li><p>Make <code>layout_transpose::mapping::stride</code> wording
independent of <code>rank()</code> equals 2 constraint, to improve
consistency with rest of <code>layout_transpose</code> wording.</p></li>
</ul></li>
<li><p>Changes to <code>scaled</code> and <code>conjugated</code>:</p>
<ul>
<li><p>Include and specify all the needed overloaded arithmetic
operators for <code>scaled_scalar</code> and
<code>conjugated_scalar</code>, and fix <code>accessor_scaled</code> and
<code>accessor_conjugate</code> accordingly.</p></li>
<li><p>Simplify <code>scaled</code> to ensure preservation of order of
operations.</p></li>
<li><p>Add missing <code>nested_accessor()</code> to
<code>accessor_scaled</code>.</p></li>
<li><p>Add hidden friends <code>abs</code>, <code>real</code>,
<code>imag</code>, and <code>conj</code> to common subclass of
<code>scaled_scalar</code> and <code>conjugated_scalar</code>. Add
wording to algorithms that use <code>abs</code>, <code>real</code>,
and/or <code>imag</code>, to indicate that these functions are to be
found by unqualified lookup. (Algorithms that use conjugation already
use <em><code>conj-if-needed</code></em> in their wording.)</p></li>
</ul></li>
<li><p>Changes suggested by SG6 small group review on 2022/06/09</p>
<ul>
<li><p>Make existing exposition-only function
<em><code>conj-if-needed</code></em> use <code>conj</code> if it can
find it via unqualified (ADL-only) lookup, otherwise be the identity.
Make it a function object instead of a function, to prevent ADL
issues.</p></li>
<li><p>Algorithms that mathematically need to do division can now
distinguish left division and right division (for the case of
noncommutative multiplication), by taking an optional
<code>BinaryDivideOp</code> binary function object parameter. If none is
given, binary <code>operator/</code> is used.</p></li>
</ul></li>
<li><p>Changes suggested by LEWG review of P1673R8 on 2022/05/24</p>
<ul>
<li><p>LEWG asked us to add a section to the paper explaining why we
don’t define an interface for customization of the “back-end” optimized
BLAS operations. This section already existed, but we rewrote it to
improve clarity. Please see the section titled “We do not require using
the BLAS library or any particular ‘back-end’.”</p></li>
<li><p>LEWG asked us to add a section to the paper showing how BLAS 1
and ranges algorithms would coexist. We added this section, titled
“Criteria for including BLAS 1 algorithms; coexistence with
ranges.”</p></li>
<li><p>Address LEWG feedback to defer support for custom complex number
types (but see above SG6 small group response).</p></li>
</ul></li>
<li><p>Fix P1674 links to point to R2.</p></li>
</ul></li>
<li><p>Revision 10 (electronic), submitted 2022-10-15</p>
<ul>
<li><p>Revise <code>scaled</code> and <code>conjugated</code>
wording.</p></li>
<li><p>Make all matrix view functions <code>constexpr</code>.</p></li>
<li><p>Rebase atop P2642R1. Remove wording saying that we rebase atop
P0009R17. (We don’t need that any more, because P0009 was merged into
the current C++ draft.)</p></li>
<li><p>Remove <code>layout_blas_general</code>, as it has been replaced
with the layouts proposed by P2642 (<code>layout_left_padded</code> and
<code>layout_right_padded</code>).</p></li>
<li><p>Update <code>layout_blas_packed</code> to match mdspan’s other
layout mappings in the current C++ Standard draft.</p></li>
<li><p>Update accessors to match mdspan’s other accessors in the current
C++ Standard draft.</p></li>
<li><p>Update non-wording to reflect current status of
<code>mdspan</code> (voted into C++ Standard draft) and
<code>submdspan</code> (P2630).</p></li>
</ul></li>
<li><p>Revision 11, to be submitted 2023-01-15</p>
<ul>
<li><p>Remove requirement that <code>in_{vector,matrix,object}*_t</code>
have unique layout.</p></li>
<li><p>Change from name-based requirements
(<code>in_{vector,matrix,object}*_t</code>) to exposition-only concepts.
(This is our interpretation of LEWG’s Kona 2022/11/10 request to
“explore expressing constraints with concepts instead of named type
requirements” (see
https://github.com/cplusplus/papers/issues/557#issuecomment-1311054803).)
Add new section for exposition-only concepts and traits.</p></li>
<li><p>Add new exposition-only concept
<em><code>possibly-packed-inout-matrix</code></em> to constrain
symmetric and Hermitian update algorithms. These may write either to a
unique-layout mdspan or to a <code>layout_blas_packed</code> mdspan
(whose layout is nonunique).</p></li>
<li><p>Remove Constraints made redundant by the new exposition-only
concepts.</p></li>
<li><p>Remove unnecessary constraint on all algorithms that input
<code>mdspan</code> parameter(s) have unique layout.</p></li>
<li><p>Remove the requirement that vector / matrix / object template
parameters may deduce a <code>const</code> lvalue reference or a
(non-<code>const</code>) rvalue reference to an <code>mdspan</code>. The
new exposition-only concepts make this unnecessary.</p></li>
<li><p>Fix <code>dot</code> Remarks to include both vector
types.</p></li>
<li><p>Fix wording of several functions and examples to use
<code>mdspan</code>’s <code>value_type</code> alias instead of its
(potentially cv-qualified) <code>element_type</code> alias. This
includes <code>dot</code>, <code>vector_sum_of_squares</code>,
<code>vector_norm2</code>, <code>vector_abs_sum</code>,
<code>matrix_frob_norm</code>, <code>matrix_one_norm</code>,
<code>matrix_inf_norm</code>, and the QR factorization example.</p></li>
<li><p>Make <code>matrix_vector_product</code> template parameter order
consistent with parameter order.</p></li>
<li><p>Follow LEWG guidance to simplify Effects and Constraints (e.g.,
removing wording referring to the “the mathematical expression for the
algorithm”) (as a kind of expression-implying constraints) by describing
them mathematically (in math font). This is our interpretation of the
“hand wavy do math” poll option that received a majority of votes at
Kona on 2022/11/10 (see
https://github.com/cplusplus/papers/issues/557#issuecomment-1311054803).
Revise <strong>[linalg.reqs.val]</strong> accordingly.</p></li>
<li><p>Change <code>matrix_one_norm</code> Precondition (that the result
of <code>abs</code> of a matrix element is convertible to
<code>T</code>) to a Constraint.</p></li>
<li><p>Change <code>vector_abs_sum</code> Precondition (that the result
of <code>init + abs(v[i])</code> is convertible to <code>T</code>) to a
Constraint.</p></li>
<li><p>Reformat entire document to use Pandoc instead of Bikeshed. This
made it possible to add paragraph numbers and fix exposition-only
italics.</p></li>
<li><p>In <em><code>conjugated-scalar</code></em>, make
<em><code>conjugatable</code></em><code>&lt;ReferenceValue&gt;</code> a
Constraint instead of a Mandate.</p></li>
<li><p>Delete “If an algorithm in <em>[linalg.algs]</em> accesses the
elements of an <em><code>out-vector</code></em>,
<em><code>out-matrix</code></em>, or <em><code>out-object</code></em>,
it will do so in write-only fashion.” This would prevent implementations
from, e.g., zero-initializing the elements and then updating them with
<code>+=</code>.</p></li>
<li><p>Rebase atop P2642R2 (updating from R1).</p></li>
<li><p>Add <code>explicit</code> defaulted default constructors to all
the tag types, in imitation of <code>in_place_t</code>.</p></li>
<li><p>If two objects refer to the same matrix or vector, we no longer
say that they must have the same layout. First, “same layout” doesn’t
have to mean the same type. For example, a
<code>layout_stride::mapping</code> instance may represent the same
layout as a <code>layout_left::mapping</code> instance. Second, the two
objects can’t represent “the same matrix” or “the same vector” if they
have different layout mappings (in the mathematical sense, not in the
type sense).</p></li>
<li><p>Make sure that all updating methods say that the input(s) can be
the same as the output (not all inputs, just the ones for which that
makes sense – e.g., for the matrix-vector product <span class="math inline"><em>z</em> = <em>y</em> + <em>A</em><em>x</em></span>,
<code>y</code> and <code>z</code> can refer to the same vector, but not
<code>x</code> and <code>z</code>).</p></li>
<li><p>Change <code>givens_rotation_setup</code> to return outputs in
the new <code>givens_rotation_setup_result</code> struct, instead of as
output parameters.</p></li>
</ul></li>
<li><p>Revision 12 to be submitted 2023/03/15</p>
<ul>
<li><p>Change “complex version(s) thereof” to “specialization(s) of
<code>complex</code>”</p></li>
<li><p>Remove Note (“conjugation is self-annihilating”) repeating the
contents of a note a few lines before</p></li>
<li><p>Remove Notes with editorial or tutorial content</p></li>
<li><p>Remove outdated wildcard name-based requirements
language</p></li>
<li><p>Remove Notes that incorrectly stated that the input matrix was
symmetric or Hermitian (it’s not necessarily symmetric or Hermitian;
it’s just interpreted that way)</p></li>
<li><p>Remove implementation freedom Notes</p></li>
<li><p>Update non-wording text referring to P1467 (which was voted into
C++23)</p></li>
<li><p>Change “the following requirement(s)” to “the following
element(s),” as a “requirement” is a kind of element</p></li>
<li><p>Change “algorithm or method” to “function”</p></li>
<li><p>Change Preconditions elements that should be something else
(generally Mandates) to that something else</p></li>
<li><p>In some cases where it makes sense, use
<code>extents::operator==</code> in elements, instead of comparing
<code>extent(r)</code> for each r</p></li>
<li><p>For <code>vector_sum_of_squares</code>, remove last remnants of
R10 “mathematical expression of the algorithm” wording</p></li>
<li><p>Add section <em>[linalg.general]</em> (“General”) that explains
mathematical notation, the interpretation of <code>Triangle t</code>
parameters, and that calls to <code>abs</code>, <code>conj</code>,
<code>imag</code>, and <code>real</code> are unqualified. Move the
definitions of lower triangle, upper triangle, and diagonal from
<em>[linalg.tags.triangle]</em> into <em>[linalg.general]</em>. Move the
definitions of implicit unit diagonal and explicit diagonal from
<em>[linalg.tags.diagonal]</em> into <em>[linalg.general]</em>. Remove
Remarks on <code>Triangle</code> and <code>DiagonalStorage</code> and
definitions of <span class="math inline"><em>A</em><sup><em>T</em></sup></span> and <span class="math inline"><em>A</em><sup><em>H</em></sup></span> that
<em>[linalg.general]</em> makes redundant.</p></li>
<li><p>Replace “<em>Effects:</em> Equivalent to: <code>return X;</code>”
with “<em>Returns:</em> <code>X</code>”. Fix formatting of multiple
<em>Returns:</em> cases. Change “name(s) the type” to “is” or
“be.”</p></li>
<li><p>In <em>[linalg.tags.order]</em>, add missing forward
reference.</p></li>
<li><p>Replace “if applicable” with hopefully canonical
wording.</p></li>
<li><p>Audit complexity elements and revise their wording.</p></li>
<li><p>Nonwording: Update reference to P2128 to reflect its adoption
into C++23, and remove outdated future work.</p></li>
<li><p>Nonwording: Add implementation experience section.</p></li>
<li><p>Nonwording: Update P1385 reference from R6 to R7, and move the
“interoperable with other linear algebra proposals” section to a more
fitting place.</p></li>
<li><p>Remove <code>reference</code> from the list of linear algebra
value types in <em>[linalg.reqs.val]</em>.</p></li>
<li><p>Add feature test macro <code>__cpp_lib_linalg</code>.</p></li>
<li><p>Remove “Throws: Nothing” from <code>givens_rotation_setup</code>
because it doesn’t need to be explicitly stated, and make all overloads
<code>noexcept</code>.</p></li>
<li><p><code>transposed</code> no longer returns a read-only
<code>mdspan</code>.</p></li>
<li><p>Remove <code>const</code> from by-value parameters, and pass
linear algebra value types by value, including
<code>complex</code>.</p></li>
<li><p>Rename <code>vector_norm2</code> to
<code>vector_two_norm</code>.</p></li>
<li><p><code>symmetric_matrix_rank_k_update</code> and
<code>hermitian_matrix_rank_k_update</code> (“the BLAS 3
<code>*_update</code> functions”) now have overloads that do not take an
<code>alpha</code> scaling parameter.</p></li>
<li><p>Change
<code>{symmetric,hermitian,triangular}_matrix_{left,right}_product</code>
to <code>{symmetric,hermitian,triangular}_matrix_product</code>.
Distinguish the left and right cases by order of the <code>A, t</code>
and <code>B</code> (or <code>C</code>, in the case of in-place
<code>triangular_matrix_product</code>) parameters. NOTE: As a result,
<code>triangular_matrix_product</code> (for the in-place right product
case) is now an exception to the rule that output or in/out parameters
appear last.</p></li>
<li><p>In <em><code>[in]out-{matrix,vector,object}</code></em>, instead
of checking if the element type is const, check if the element type can
be assigned to the reference type.</p></li>
<li><p>Split <em>[linalg.reqs.val]</em> into two sections: requirements
on linear algebra value types (same label) and algorithm and class
requirements <em>[linalg.reqs.alg]</em>.</p></li>
<li><p>In wording of <em><code>conj-if-needed</code></em>, add missing
definition of the type <code>T</code>.</p></li>
<li><p>Add exposition-only <em><code>real-if-needed</code></em> and
<em><code>imag-if-needed</code></em>, and use them to make
<code>vector_abs_sum</code> behave the same for custom complex types as
for <code>std::complex</code>.</p></li>
<li><p>Fix two design issues with <code>idx_abs_max</code>.</p>
<ol type="1">
<li><p>For the complex case, make it behave like the BLAS’s ICAMAX or
IZAMAX, by using <em><code>abs-if-needed</code></em><code>(</code>
<em><code>real-if-needed</code></em> <code>(z[k])) +</code>
<em><code>abs-if-needed</code></em><code>(</code>
<em><code>imag-if-needed</code></em> <code>(z[k]))</code> as the element
absolute value definition for complex numbers, instead of
<code>abs(z[k])</code>.</p></li>
<li><p>Make <code>idx_abs_max</code> behave the same for custom complex
types as for <code>std::complex</code>.</p></li>
</ol></li>
<li><p>Simplify wording for <em><code>proxy-reference</code></em>’s
hidden friends <code>real</code>, <code>imag</code>, and
<code>conj</code>, so that they just defer to the corresponding
<em><code>*-if-needed</code></em> exposition-only functions, rather than
duplicating the wording of those functions.</p></li>
<li><p>Add exposition-only function <em><code>abs-if-needed</code></em>
to address <code>std::abs</code> not being defined for unsigned integer
types (which manifests as an ambiguous lookup compiler error). Simplify
wording for <em><code>proxy-reference</code></em>’s hidden friend
<code>abs</code> to defer to <em><code>abs-if-needed</code></em>. Use
<em><code>abs-if-needed</code></em> instead of <code>abs</code>
throughout P1673.</p></li>
<li><p>Change remarks about aliasing (e.g., “<span class="math inline"><em>y</em></span> and <span class="math inline"><em>z</em></span> may refer to the same vector”) to
say “object” instead of “vector” or “matrix.”</p></li>
<li><p>For in-place overwriting triangular matrix-matrix {left, right}
product, restore the “left” and “right” in their names, and always put
the input/output parameter at the end. (This restores
<code>triangular_matrix_left_product</code> and
<code>triangular_matrix_right_product</code> for only the in-place
overwriting case. See above changes for this revision.)</p></li>
<li><p>Add Demmel 2002 reference to the (C++ Standard)
Bibliography.</p></li>
<li><p>Rephrase <em>[linalg.reqs.val]</em> to use “The type T must”
language, and add <em><code>real-if-needed</code></em> and
<em><code>imag-if-needed</code></em> to the list of expressions
there.</p></li>
<li><p>Rephase <em>[linalg.reqs.alg]</em> to make it more like
<code>sort</code>, e.g., not making it explicitly a constraint that
certain expressions are well formed.</p></li>
<li><p>Add to <em>[linalg.reqs.val]</em> that a value-initialized object
of linear algebra value type acts as the additive identity.</p></li>
<li><p>Define what it means for two mdspan to “alias” each other.
Instead of saying that two things may refer to the same object, say that
they may alias.</p></li>
<li><p>Change the name of the <code>T init</code> parameters and the
template parameter of <code>sum_of_squares_result</code> to allow
simplification of <em>[linalg.reqs.val]</em>.</p></li>
<li><p>Delete Note explaining BLAS 1, 2, and 3.</p></li>
</ul></li>
<li><p>Revision 13 - running revision for LWG review</p>
<ul>
<li><p>make <code>scaled_accessor::reference</code>
<code>const element_type</code></p></li>
<li><p>add converting, default and copy ctor to
<code>scaled_accessor</code></p></li>
<li><p>rename <code>accessor_conjugate</code> to
<code>conjugated_accessor</code></p></li>
<li><p>rename <code>accessor_scaled</code> to
<code>scaled_accessor</code></p></li>
<li><p>rename <code>givens_rotation_setup</code> to
<code>setup_givens_rotation</code></p></li>
<li><p>rename <code>givens_rotation_apply</code> to
<code>apply_givens_rotation</code></p></li>
<li><p>fix example for <code>scaled</code></p></li>
<li><p>implement helper functions for algorithm mandates and
preconditions and apply it to gemv</p></li>
<li><p>fix hanging sections throughout</p></li>
<li><p>use stable tags instead of “in this clause”</p></li>
<li><p>make linalg-reqs-flpt a note</p></li>
<li><p>fix linalg.algs.reqs constraint -&gt; precondition</p></li>
<li><p>fix unary plus and well formed</p></li>
<li><p>remove <em><code>proxy-reference</code></em> ,
<em><code>scaled_scalar</code></em> and
<em><code>conjugated_scalar</code></em></p></li>
<li><p>Redo <code>conjugated</code> to simply rely on deduction guide
for <code>mdspan</code></p></li>
<li><p>fix numbering via dummy sections</p></li>
<li><p>Define what it means for two mdspan to “overlap” each other.
Replace “shall view a disjoint set of elements of” wording (was
[linalg.concepts] 3 in R12) with “shall not overlap.” “Alias” retains
its R12 meaning (view the same elements in the same order). This lets us
retain existing use of “alias” in describing algorithms.</p></li>
<li><p>rename <code>idx_abs_max</code> to
<code>vector_idx_abs_max</code></p></li>
<li><p>make “may alias” a transitive verb phrase, and put all such
wording expressions in the form “Output may alias Input”</p></li>
<li><p>fix <code>matrix_rank_1_update*</code> wording (rename template
parameters to <code>InOutMat</code>, and fix Effects so that the
algorithms are updating; use new “Computes” wording)</p></li>
<li><p>make sure all Effects-equivalent-to that use the execution policy
use <code>std::forward&lt;ExecutionPolicy&gt;(exec)</code>, instead of
passing <code>exec</code> directly</p></li>
<li><p>change [linalg.alg.*] stable names to [linalg.algs.*], for
consistency</p></li>
<li><p>fix stable names for BLAS 2 rank-1 symmetric and Hermitian
updates</p></li>
<li><p>Remove any wording (e.g., for <code>transposed</code>) that
depends on P2642 (padded mdspan layouts). We can restore and correct
that wording later.</p></li>
<li><p>Fix [linalg.algs.reqs] 1 by changing “type requirements” to
“Constraints.” Add the Constraint that ExecutionPolicy is an execution
policy. Remove the requirement that the algorithms that take
<code>ExecutionPolicy</code> are parallel algorithms, because that would
be circular with <strong>[algorithms.parallel]</strong> 2 (“A
<em>parallel algorithm</em> is a function template listed in this
document with a template parameter named
<code>ExecutionPolicy</code>”).</p></li>
<li><p>make <code>layout_blas_packed::mapping::operator()</code> take
exactly two parameters, rather than a pack</p></li>
<li><p>for default <code>BinaryDivideOp</code>, replace lambda with
<code>divides&lt;void&gt;{}</code></p></li>
<li><p>add definitions of the “rows” and “columns” of a matrix to
[linalg.general], so that [linalg.tags.order] can refer to rows and
columns</p></li>
<li><p><code>layout_blas_packed::mapping::operator()</code>: Pass input
parameters through <em><code>index-cast</code></em> before using them in
the formulas.</p></li>
<li><p>remove spurious return value from
<code>layout_blas_packed::mapping::stride</code> (the case where the
Precondition would have been violated anyway)</p></li>
<li><p>Move exposition-only helpers
<em><code>transpose-extents</code></em> and
<em><code>transpose-extents-t</code></em> to the new section
[linalg.transp.helpers]. Redefine
<em><code>transpose-extents-t</code></em> in terms of
<em><code>transpose-extents</code></em>, rather than the other way
around.</p></li>
<li><p>For <code>triangular_*</code>, <code>symmetric_*</code>, and
<code>hermitian_*</code> functions that take a <code>Triangle</code>
parameter and an <code>mdspan</code> with
<code>layout_blas_packed</code> layout, change the requirement that the
layout’s <code>Triangle</code> match the function’s
<code>Triangle</code> parameter, from a Constraint to a Mandate. This
should not result in ambiguous overloads, since <code>Triangle</code> is
already Constrained to be <code>upper_triangle_t</code> or
<code>lower_triangle_t</code>. Add a nonwording section explaining this
design choice.</p></li>
<li><p>Add <code>triangle_type</code> and
<code>storage_order_type</code> public type aliases to
<code>layout_blas_packed</code>.</p></li>
<li><p>Fix <code>layout_blas_packed</code> requirements so that wording
of <code>operator()</code> and other members doesn’t need to consider
overflow.</p></li>
<li><p>Add <em><code>possibly-packed-inout-matrix</code></em> to the
list of concepts in [linalg.helpers.concepts] 3 that forbid overlap
unless explicitly permitted.</p></li>
<li><p>Make sure that Complexity clauses use a math multiplication
symbol instead of code-font <code>*</code>. (The latter would cause
unwarranted overflow issues, especially for BLAS 3 functions.)</p></li>
<li><p>Many more wording fixes based on LWG review</p></li>
</ul></li>
</ul>
<h1 data-number="3" id="purpose-of-this-paper"><span class="header-section-number">3</span> Purpose of this paper<a href="#purpose-of-this-paper" class="self-link"></a></h1>
<p>This paper proposes a C++ Standard Library dense linear algebra
interface based on the dense Basic Linear Algebra Subroutines (BLAS).
This corresponds to a subset of the <a href="http://www.netlib.org/blas/blast-forum/blas-report.pdf">BLAS
Standard</a>. Our proposal implements the following classes of
algorithms on arrays that represent matrices and vectors:</p>
<ul>
<li><p>elementwise vector sums;</p></li>
<li><p>multiplying all elements of a vector or matrix by a
scalar;</p></li>
<li><p>2-norms and 1-norms of vectors;</p></li>
<li><p>vector-vector, matrix-vector, and matrix-matrix products
(contractions);</p></li>
<li><p>low-rank updates of a matrix;</p></li>
<li><p>triangular solves with one or more “right-hand side” vectors;
and</p></li>
<li><p>generating and applying plane (Givens) rotations.</p></li>
</ul>
<p>Our algorithms work with most of the matrix storage formats that the
BLAS Standard supports:</p>
<ul>
<li><p>“general” dense matrices, in column-major or row-major
format;</p></li>
<li><p>symmetric or Hermitian (for complex numbers only) dense matrices,
stored either as general dense matrices, or in a packed format;
and</p></li>
<li><p>dense triangular matrices, stored either as general dense
matrices or in a packed format.</p></li>
</ul>
<p>Our proposal also has the following distinctive characteristics.</p>
<ul>
<li><p>It uses free functions, not arithmetic operator
overloading.</p></li>
<li><p>The interface is designed in the spirit of the C++ Standard
Library’s algorithms.</p></li>
<li><p>It uses <code>mdspan</code> (adopted into C++23), a
multidimensional array view, to represent matrices and vectors.</p></li>
<li><p>The interface permits optimizations for matrices and vectors with
small compile-time dimensions; the standard BLAS interface does
not.</p></li>
<li><p>Each of our proposed operations supports all element types for
which that operation makes sense, unlike the BLAS, which only supports
four element types.</p></li>
<li><p>Our operations permit “mixed-precision” computation with matrices
and vectors that have different element types. This subsumes most
functionality of the Mixed-Precision BLAS specification, comprising
Chapter 4 of the
<a href="http://www.netlib.org/blas/blast-forum/blas-report.pdf">BLAS
Standard</a>.</p></li>
<li><p>Like the C++ Standard Library’s algorithms, our operations take
an optional execution policy argument. This is a hook to support
parallel execution and hierarchical parallelism.</p></li>
<li><p>Unlike the BLAS, our proposal can be expanded to support
“batched” operations (see P2901) with almost no interface differences.
This will support machine learning and other applications that need to
do many small matrix or vector operations at once.</p></li>
</ul>
<p>Here are some examples of what this proposal offers. In these
examples, we ignore <code>std::</code> namespace qualification for
anything in our proposal or for <code>mdspan</code>. We start with a
“hello world” that scales the elements of a 1-D <code>mdspan</code> by a
constant factor, first sequentially, then in parallel.</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>  <span class="kw">constexpr</span> <span class="dt">size_t</span> N <span class="op">=</span> <span class="dv">40</span>;</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a>  std<span class="op">::</span>vector<span class="op">&lt;</span><span class="dt">double</span><span class="op">&gt;</span> x_vec<span class="op">(</span>N<span class="op">)</span>;</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a>  mdspan x<span class="op">(</span>x_vec<span class="op">.</span>data<span class="op">()</span>, N<span class="op">)</span>;</span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a>  <span class="cf">for</span><span class="op">(</span><span class="dt">size_t</span> i <span class="op">=</span> <span class="dv">0</span>; i <span class="op">&lt;</span> N; <span class="op">++</span>i<span class="op">)</span> <span class="op">{</span></span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a>    x<span class="op">[</span>i<span class="op">]</span> <span class="op">=</span> <span class="dt">double</span><span class="op">(</span>i<span class="op">)</span>;</span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a>  linalg<span class="op">::</span>scale<span class="op">(</span><span class="fl">2.0</span>, x<span class="op">)</span>; <span class="co">// x = 2.0 * x</span></span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a>  linalg<span class="op">::</span>scale<span class="op">(</span>std<span class="op">::</span>execution<span class="op">::</span>par_unseq, <span class="fl">3.0</span>, x<span class="op">)</span>;</span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a>  <span class="cf">for</span><span class="op">(</span><span class="dt">size_t</span> i <span class="op">=</span> <span class="dv">0</span>; i <span class="op">&lt;</span> N; <span class="op">++</span>i<span class="op">)</span> <span class="op">{</span></span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a>    <span class="ot">assert</span><span class="op">(</span>x<span class="op">[</span>i<span class="op">]</span> <span class="op">==</span> <span class="fl">6.0</span> <span class="op">*</span> <span class="dt">double</span><span class="op">(</span>i<span class="op">))</span>;</span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span></code></pre></div>
<p>Here is a matrix-vector product example. It illustrates the
<code>scaled</code> function that makes our interface more concise,
while still permitting the BLAS’ performance optimization of fusing
computations with multiplications by a scalar. It also shows the ability
to exploit dimensions known at compile time, and to mix compile-time and
run-time dimensions arbitrarily.</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">size_t</span> N <span class="op">=</span> <span class="dv">40</span>;</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">size_t</span> M <span class="op">=</span> <span class="dv">20</span>;</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>std<span class="op">::</span>vector<span class="op">&lt;</span><span class="dt">double</span><span class="op">&gt;</span> A_vec<span class="op">(</span>N<span class="op">*</span>M<span class="op">)</span>;</span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a>std<span class="op">::</span>vector<span class="op">&lt;</span><span class="dt">double</span><span class="op">&gt;</span> x_vec<span class="op">(</span>M<span class="op">)</span>;</span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a>std<span class="op">::</span>array<span class="op">&lt;</span><span class="dt">double</span>, N<span class="op">&gt;</span> y_vec<span class="op">(</span>N<span class="op">)</span>;</span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a>mdspan A<span class="op">(</span>A_vec<span class="op">.</span>data<span class="op">()</span>, N, M<span class="op">)</span>;</span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a>mdspan x<span class="op">(</span>x_vec<span class="op">.</span>data<span class="op">()</span>, M<span class="op">)</span>;</span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a>mdspan y<span class="op">(</span>y_vec<span class="op">.</span>data<span class="op">()</span>, N<span class="op">)</span>;</span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span><span class="op">(</span><span class="dt">int</span> i <span class="op">=</span> <span class="dv">0</span>; i <span class="op">&lt;</span> A<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>; <span class="op">++</span>i<span class="op">)</span> <span class="op">{</span></span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a>  <span class="cf">for</span><span class="op">(</span><span class="dt">int</span> j <span class="op">=</span> <span class="dv">0</span>; j <span class="op">&lt;</span> A<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span>; <span class="op">++</span>j<span class="op">)</span> <span class="op">{</span></span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a>    A<span class="op">[</span>i,j<span class="op">]</span> <span class="op">=</span> <span class="fl">100.0</span> <span class="op">*</span> i <span class="op">+</span> j;</span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span><span class="op">(</span><span class="dt">int</span> j <span class="op">=</span> <span class="dv">0</span>; j <span class="op">&lt;</span> x<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>; <span class="op">++</span>j<span class="op">)</span> <span class="op">{</span></span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a>  x<span class="op">[</span>i<span class="op">]</span> <span class="op">=</span> <span class="fl">1.0</span> <span class="op">*</span> j;</span>
<span id="cb2-19"><a href="#cb2-19" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span>
<span id="cb2-20"><a href="#cb2-20" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span><span class="op">(</span><span class="dt">int</span> i <span class="op">=</span> <span class="dv">0</span>; i <span class="op">&lt;</span> y<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>; <span class="op">++</span>i<span class="op">)</span> <span class="op">{</span></span>
<span id="cb2-21"><a href="#cb2-21" aria-hidden="true" tabindex="-1"></a>  y<span class="op">[</span>i<span class="op">]</span> <span class="op">=</span> <span class="op">-</span><span class="fl">1.0</span> <span class="op">*</span> i;</span>
<span id="cb2-22"><a href="#cb2-22" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span>
<span id="cb2-23"><a href="#cb2-23" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-24"><a href="#cb2-24" aria-hidden="true" tabindex="-1"></a>linalg<span class="op">::</span>matrix_vector_product<span class="op">(</span>A, x, y<span class="op">)</span>; <span class="co">// y = A * x</span></span>
<span id="cb2-25"><a href="#cb2-25" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-26"><a href="#cb2-26" aria-hidden="true" tabindex="-1"></a><span class="co">// y = 0.5 * y + 2 * A * x</span></span>
<span id="cb2-27"><a href="#cb2-27" aria-hidden="true" tabindex="-1"></a>linalg<span class="op">::</span>matrix_vector_product<span class="op">(</span>std<span class="op">::</span>execution<span class="op">::</span>par,</span>
<span id="cb2-28"><a href="#cb2-28" aria-hidden="true" tabindex="-1"></a>  linalg<span class="op">::</span>scaled<span class="op">(</span><span class="fl">2.0</span>, A<span class="op">)</span>, x,</span>
<span id="cb2-29"><a href="#cb2-29" aria-hidden="true" tabindex="-1"></a>  linalg<span class="op">::</span>scaled<span class="op">(</span><span class="fl">0.5</span>, y<span class="op">)</span>, y<span class="op">)</span>;</span></code></pre></div>
<p>This example illustrates the ability to perform mixed-precision
computations, and the ability to compute on subviews of a matrix or
vector by using <code>submdspan</code> (P2630, adopted into the C++26
draft). (<code>submdspan</code> was separated from the rest of P0009 as
a way to avoid delaying the adoption of P0009 into C++23. The reference
implementation of <code>mdspan</code> includes
<code>submdspan</code>.)</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">size_t</span> M <span class="op">=</span> <span class="dv">40</span>;</span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a>std<span class="op">::</span>vector<span class="op">&lt;</span><span class="dt">float</span><span class="op">&gt;</span> A_vec<span class="op">(</span>M<span class="op">*</span><span class="dv">8</span><span class="op">*</span><span class="dv">4</span><span class="op">)</span>;</span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a>std<span class="op">::</span>vector<span class="op">&lt;</span><span class="dt">double</span><span class="op">&gt;</span> x_vec<span class="op">(</span>M<span class="op">*</span><span class="dv">4</span><span class="op">)</span>;</span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a>std<span class="op">::</span>vector<span class="op">&lt;</span><span class="dt">double</span><span class="op">&gt;</span> y_vec<span class="op">(</span>M<span class="op">*</span><span class="dv">8</span><span class="op">)</span>;</span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a>mdspan<span class="op">&lt;</span><span class="dt">float</span>, extents<span class="op">&lt;</span><span class="dt">size_t</span>, dynamic_extent, <span class="dv">8</span>, <span class="dv">4</span><span class="op">&gt;&gt;</span> A<span class="op">(</span>A_vec<span class="op">.</span>data<span class="op">()</span>, M<span class="op">)</span>;</span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a>mdspan<span class="op">&lt;</span><span class="dt">double</span>, extents<span class="op">&lt;</span><span class="dt">size_t</span>, <span class="dv">4</span>, dynamic_extent<span class="op">&gt;&gt;</span> x<span class="op">(</span>x_vec<span class="op">.</span>data<span class="op">()</span>, M<span class="op">)</span>;</span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a>mdspan<span class="op">&lt;</span><span class="dt">double</span>, extents<span class="op">&lt;</span><span class="dt">size_t</span>, dynamic_extent, <span class="dv">8</span><span class="op">&gt;&gt;</span> y<span class="op">(</span>y_vec<span class="op">.</span>data<span class="op">()</span>, M<span class="op">)</span>;</span>
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span><span class="op">(</span><span class="dt">size_t</span> m <span class="op">=</span> <span class="dv">0</span>; m <span class="op">&lt;</span> A<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>; <span class="op">++</span>m<span class="op">)</span> <span class="op">{</span></span>
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a>  <span class="cf">for</span><span class="op">(</span><span class="dt">size_t</span> i <span class="op">=</span> <span class="dv">0</span>; i <span class="op">&lt;</span> A<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span>; <span class="op">++</span>i<span class="op">)</span> <span class="op">{</span></span>
<span id="cb3-13"><a href="#cb3-13" aria-hidden="true" tabindex="-1"></a>    <span class="cf">for</span><span class="op">(</span><span class="dt">size_t</span> j <span class="op">=</span> <span class="dv">0</span>; j <span class="op">&lt;</span> A<span class="op">.</span>extent<span class="op">(</span><span class="dv">2</span><span class="op">)</span>; <span class="op">++</span>j<span class="op">)</span> <span class="op">{</span></span>
<span id="cb3-14"><a href="#cb3-14" aria-hidden="true" tabindex="-1"></a>      A<span class="op">[</span>m,i,j<span class="op">]</span> <span class="op">=</span> <span class="fl">1000.0</span> <span class="op">*</span> m <span class="op">+</span> <span class="fl">100.0</span> <span class="op">*</span> i <span class="op">+</span> j;</span>
<span id="cb3-15"><a href="#cb3-15" aria-hidden="true" tabindex="-1"></a>    <span class="op">}</span></span>
<span id="cb3-16"><a href="#cb3-16" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb3-17"><a href="#cb3-17" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span>
<span id="cb3-18"><a href="#cb3-18" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span><span class="op">(</span><span class="dt">size_t</span> i <span class="op">=</span> <span class="dv">0</span>; i <span class="op">&lt;</span> x<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>; <span class="op">++</span>i<span class="op">)</span> <span class="op">{</span></span>
<span id="cb3-19"><a href="#cb3-19" aria-hidden="true" tabindex="-1"></a>  <span class="cf">for</span><span class="op">(</span><span class="dt">size_t</span> m <span class="op">=</span> <span class="dv">0</span>; m <span class="op">&lt;</span> x<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span>; <span class="op">++</span>m<span class="op">)</span> <span class="op">{</span></span>
<span id="cb3-20"><a href="#cb3-20" aria-hidden="true" tabindex="-1"></a>    x<span class="op">[</span>i,m<span class="op">]</span> <span class="op">=</span> <span class="fl">33.</span> <span class="op">*</span> i <span class="op">+</span> <span class="fl">0.33</span> <span class="op">*</span> m;</span>
<span id="cb3-21"><a href="#cb3-21" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb3-22"><a href="#cb3-22" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span>
<span id="cb3-23"><a href="#cb3-23" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span><span class="op">(</span><span class="dt">size_t</span> m <span class="op">=</span> <span class="dv">0</span>; m <span class="op">&lt;</span> y<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>; <span class="op">++</span>m<span class="op">)</span> <span class="op">{</span></span>
<span id="cb3-24"><a href="#cb3-24" aria-hidden="true" tabindex="-1"></a>  <span class="cf">for</span><span class="op">(</span><span class="dt">size_t</span> i <span class="op">=</span> <span class="dv">0</span>; i <span class="op">&lt;</span> y<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span>; <span class="op">++</span>i<span class="op">)</span> <span class="op">{</span></span>
<span id="cb3-25"><a href="#cb3-25" aria-hidden="true" tabindex="-1"></a>    y<span class="op">[</span>m,i<span class="op">]</span> <span class="op">=</span> <span class="fl">33.</span> <span class="op">*</span> m <span class="op">+</span> <span class="fl">0.33</span> <span class="op">*</span> i;</span>
<span id="cb3-26"><a href="#cb3-26" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb3-27"><a href="#cb3-27" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span>
<span id="cb3-28"><a href="#cb3-28" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-29"><a href="#cb3-29" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span><span class="op">(</span><span class="dt">size_t</span> m <span class="op">=</span> <span class="dv">0</span>; m <span class="op">&lt;</span> M; <span class="op">++</span>m<span class="op">)</span> <span class="op">{</span></span>
<span id="cb3-30"><a href="#cb3-30" aria-hidden="true" tabindex="-1"></a>  <span class="kw">auto</span> A_m <span class="op">=</span> submdspan<span class="op">(</span>A, m, full_extent, full_extent<span class="op">)</span>;</span>
<span id="cb3-31"><a href="#cb3-31" aria-hidden="true" tabindex="-1"></a>  <span class="kw">auto</span> x_m <span class="op">=</span> submdspan<span class="op">(</span>x, full_extent, m<span class="op">)</span>;</span>
<span id="cb3-32"><a href="#cb3-32" aria-hidden="true" tabindex="-1"></a>  <span class="kw">auto</span> y_m <span class="op">=</span> submdspan<span class="op">(</span>y, m, full_extent<span class="op">)</span>;</span>
<span id="cb3-33"><a href="#cb3-33" aria-hidden="true" tabindex="-1"></a>  <span class="co">// y_m = A * x_m</span></span>
<span id="cb3-34"><a href="#cb3-34" aria-hidden="true" tabindex="-1"></a>  linalg<span class="op">::</span>matrix_vector_product<span class="op">(</span>A_m, x_m, y_m<span class="op">)</span>;</span>
<span id="cb3-35"><a href="#cb3-35" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<h1 data-number="4" id="overview-of-contents"><span class="header-section-number">4</span> Overview of contents<a href="#overview-of-contents" class="self-link"></a></h1>
<p>Section
<a href="#why-include-dense-linear-algebra-in-the-c-standard-library"><span class="secno">5</span></a> motivates considering <em>any</em> dense
linear algebra proposal for the C++ Standard Library.</p>
<p>Section
<a href="#why-base-a-c-linear-algebra-library-on-the-blas"><span class="secno">6</span></a> shows why we chose the BLAS as a starting
point for our proposed library. The BLAS is an existing standard with
decades of use, a rich set of functions, and many optimized
implementations.</p>
<p>Section <a href="#criteria-for-including-algorithms"><span class="secno">7</span></a> lists what we consider general criteria for
including algorithms in the C++ Standard Library. We rely on these
criteria to justify the algorithms in this proposal.</p>
<p>Section <a href="#notation-and-conventions"><span class="secno">8</span></a> describes BLAS notation and conventions in
C++ terms. Understanding this will give readers context for algorithms,
and show how our proposed algorithms expand on BLAS functionality.</p>
<p>Section <a href="#what-we-exclude-from-the-design"><span class="secno">9</span></a> lists functionality that we intentionally
exclude from our proposal. We imitate the BLAS in aiming to be a set of
“performance primitives” on which external libraries or applications may
build a more complete linear algebra solution.</p>
<p>Section <a href="#design-justification"><span class="secno">10</span></a> elaborates on our design justification. This
section explains</p>
<ul>
<li><p>why we use <code>mdspan</code> to represent matrix and vector
parameters;</p></li>
<li><p>how we translate the BLAS’ Fortran-centric idioms into
C++;</p></li>
<li><p>how the BLAS’ different “matrix types” map to different
algorithms, rather than different <code>mdspan</code> layouts;</p></li>
<li><p>how we express quality-of-implementation recommendations about
avoiding undue overflow and underflow;</p></li>
<li><p>how we impose requirements on algorithms’ behavior and on the
various value types that algorithms encounter;</p></li>
<li><p>how we support for user-defined complex number types and address
type preservation and domain issues with <code>std::abs</code>,
<code>std::conj</code>, <code>std::real</code>, and
<code>std::imag</code>;</p></li>
<li><p>how we support division for triangular solves, for value types
with noncommutative multiplication; and</p></li>
<li><p>how we address consistency between
<code>layout_blas_packed</code> having a <code>Triangle</code> template
parameter, and functions also taking a <code>Triangle</code>
parameter.</p></li>
</ul>
<p>Section <a href="#future-work"><span class="secno">11</span></a>
lists future work, that is, ways future proposals could build on this
one.</p>
<p>Section
<a href="#data-structures-and-utilities-borrowed-from-other-proposals"><span class="secno">12</span></a> gives the data structures and utilities from
other proposals on which we depend. In particular, we rely heavily on
<code>mdspan</code> (adopted into C++23), and add custom layouts and
accessors.</p>
<p>Section <a href="#implementation-experience"><span class="secno">13</span></a> briefly summarizes the existing
implementations of this proposal.</p>
<p>Section
<a href="#interoperable-with-other-linear-algebra-proposals"><span class="secno">14</span></a> explains how this proposal is interoperable
with other linear algebra proposals currently under WG21 review. In
particular, we believe this proposal is complementary to P1385, and the
authors of P1385 have expressed the same view.</p>
<p>Section <a href="#acknowledgments"><span class="secno">15</span></a>
credits funding agencies and contributors.</p>
<p>Section <a href="#references"><span class="secno">16</span></a> is
our bibliography.</p>
<p>Section <a href="#wording"><span class="secno">17</span></a> is where
readers will find the normative wording we propose.</p>
<p>Finally, Section <a href="#examples"><span class="secno">18</span></a> gives some more elaborate examples of linear
algebra algorithms that use our proposal. The examples show how
<code>mdspan</code>’s features let users easily describe “submatrices”
with <code>submdspan</code>, proposed in P2630 as a follow-on to mdspan.
(The reference implementation of <code>mdspan</code> includes
<code>submdspan</code>.) This integrates naturally with “block”
factorizations of matrices. The resulting notation is concise, yet still
computes in place, without unnecessary copies of any part of the
matrix.</p>
<p>Here is a table that maps between Reference BLAS function name, and
algorithm or function name in our proposal. The mapping is not always
one to one. “N/A” in the “BLAS name(s)” field means that the function is
not in the BLAS.</p>
<table>
<tbody><tr>
<th>
BLAS name(s)
</th>
<th>
Our name(s)
</th>
</tr>
<tr>
<td>
xLARTG
</td>
<td>
<code>setup_givens_rotation</code>
</td>
</tr>
<tr>
<td>
xROT
</td>
<td>
<code>apply_givens_rotation</code>
</td>
</tr>
<tr>
<td>
xSWAP
</td>
<td>
<code>swap_elements</code>
</td>
</tr>
<tr>
<td>
xSCAL
</td>
<td>
<code>scale</code>, <code>scaled</code>
</td>
</tr>
<tr>
<td>
xCOPY
</td>
<td>
<code>copy</code>
</td>
</tr>
<tr>
<td>
xAXPY
</td>
<td>
<code>add</code>, <code>scaled</code>
</td>
</tr>
<tr>
<td>
xDOT, xDOTU
</td>
<td>
<code>dot</code>
</td>
</tr>
<tr>
<td>
xDOTC
</td>
<td>
<code>dotc</code>
</td>
</tr>
<tr>
<td>
N/A
</td>
<td>
<code>vector_sum_of_squares</code>
</td>
</tr>
<tr>
<td>
xNRM2
</td>
<td>
<code>vector_two_norm</code>
</td>
</tr>
<tr>
<td>
xASUM
</td>
<td>
<code>vector_abs_sum</code>
</td>
</tr>
<tr>
<td>
xIAMAX
</td>
<td>
<code>vector_idx_abs_max</code>
</td>
</tr>
<tr>
<td>
N/A
</td>
<td>
<code>matrix_frob_norm</code>
</td>
</tr>
<tr>
<td>
N/A
</td>
<td>
<code>matrix_one_norm</code>
</td>
</tr>
<tr>
<td>
N/A
</td>
<td>
<code>matrix_inf_norm</code>
</td>
</tr>
<tr>
<td>
xGEMV
</td>
<td>
<code>matrix_vector_product</code>
</td>
</tr>
<tr>
<td>
xSYMV
</td>
<td>
<code>symmetric_matrix_vector_product</code>
</td>
</tr>
<tr>
<td>
xHEMV
</td>
<td>
<code>hermitian_matrix_vector_product</code>
</td>
</tr>
<tr>
<td>
xTRMV
</td>
<td>
<code>triangular_matrix_vector_product</code>
</td>
</tr>
<tr>
<td>
xTRSV
</td>
<td>
<code>triangular_matrix_vector_solve</code>
</td>
</tr>
<tr>
<td>
xGER, xGERU
</td>
<td>
<code>matrix_rank_1_update</code>
</td>
</tr>
<tr>
<td>
xGERC
</td>
<td>
<code>matrix_rank_1_update_c</code>
</td>
</tr>
<tr>
<td>
xSYR
</td>
<td>
<code>symmetric_matrix_rank_1_update</code>
</td>
</tr>
<tr>
<td>
xHER
</td>
<td>
<code>hermitian_matrix_rank_1_update</code>
</td>
</tr>
<tr>
<td>
xSYR2
</td>
<td>
<code>symmetric_matrix_rank_2_update</code>
</td>
</tr>
<tr>
<td>
xHER2
</td>
<td>
<code>hermitian_matrix_rank_2_update</code>
</td>
</tr>
<tr>
<td>
xGEMM
</td>
<td>
<code>matrix_product</code>
</td>
</tr>
<tr>
<td>
xSYMM
</td>
<td>
<code>symmetric_matrix_product</code>
</td>
</tr>
<tr>
<td>
xHEMM
</td>
<td>
<code>hermitian_matrix_product</code>
</td>
</tr>
<tr>
<td>
xTRMM
</td>
<td>
<code>triangular_matrix_product</code>
</td>
</tr>
<tr>
<td>
xSYRK
</td>
<td>
<code>symmetric_matrix_rank_k_update</code>
</td>
</tr>
<tr>
<td>
xHERK
</td>
<td>
<code>hermitian_matrix_rank_k_update</code>
</td>
</tr>
<tr>
<td>
xSYR2K
</td>
<td>
<code>symmetric_matrix_rank_2k_update</code>
</td>
</tr>
<tr>
<td>
xHER2K
</td>
<td>
<code>hermitian_matrix_rank_2k_update</code>
</td>
</tr>
<tr>
<td>
xTRSM
</td>
<td>
<code>triangular_matrix_matrix_{left,right}_solve</code>
</td>
</tr>
</tbody></table>
<h1 data-number="5" id="why-include-dense-linear-algebra-in-the-c-standard-library"><span class="header-section-number">5</span> Why include dense linear algebra
in the C++ Standard Library?<a href="#why-include-dense-linear-algebra-in-the-c-standard-library" class="self-link"></a></h1>
<ol type="1">
<li><p>“Direction for ISO C++” (P0939R4) explicitly calls out “Linear
Algebra” as a potential priority for C++23.</p></li>
<li><p>C++ applications in “important application areas” (see P0939R4)
have depended on linear algebra for a long time.</p></li>
<li><p>Linear algebra is like <code>sort</code>: obvious algorithms are
slow, and the fastest implementations call for hardware-specific
tuning.</p></li>
<li><p>Dense linear algebra is core functionality for most of linear
algebra, and can also serve as a building block for tensor
operations.</p></li>
<li><p>The C++ Standard Library includes plenty of “mathematical
functions.” Linear algebra operations like matrix-matrix multiply are at
least as broadly useful.</p></li>
<li><p>The set of linear algebra operations in this proposal are derived
from a well-established, standard set of algorithms that has changed
very little in decades. It is one of the strongest possible examples of
standardizing existing practice that anyone could bring to C++.</p></li>
<li><p>This proposal follows in the footsteps of many recent successful
incorporations of existing standards into C++, including the UTC and TAI
standard definitions from the International Telecommunications Union,
the time zone database standard from the International Assigned Numbers
Authority, and the ongoing effort to integrate the ISO unicode
standard.</p></li>
</ol>
<p>Linear algebra has had wide use in C++ applications for nearly three
decades (see P1417R0 for a historical survey). For much of that time,
many third-party C++ libraries for linear algebra have been available.
Many different subject areas depend on linear algebra, including machine
learning, data mining, web search, statistics, computer graphics,
medical imaging, geolocation and mapping, engineering, and physics-based
simulations.</p>
<p>“Directions for ISO C++” (P0939R4) not only lists “Linear Algebra”
explicitly as a potential C++23 priority, it also offers the following
in support of adding linear algebra to the C++ Standard Library.</p>
<ul>
<li><p>P0939R4 calls out “Support for demanding applications” in
“important application areas, such as medical, finance, automotive, and
games (e.g., key libraries…)” as an “area of general concern” that “we
should not ignore.” All of these areas depend on linear
algebra.</p></li>
<li><p>“Is my proposal essential for some important application domain?”
Many large and small private companies, science and engineering
laboratories, and academics in many different fields all depend on
linear algebra.</p></li>
<li><p>“We need better support for modern hardware”: Modern hardware
spends many of its cycles in linear algebra. For decades, hardware
vendors, some represented at WG21 meetings, have provided and continue
to provide features specifically to accelerate linear algebra
operations. Some of them even implement specific linear algebra
operations directly in hardware. Examples include NVIDIA’s
<a href="https://www.nvidia.com/en-us/data-center/tensorcore/">Tensor
Cores</a> and Cerebras’
<a href="https://www.cerebras.net/product/#chip">Wafer Scale Engine</a>.
Several large computer system vendors offer optimized linear algebra
libraries based on or closely resembling the BLAS. These include AMD’s
BLIS, ARM’s Performance Libraries, Cray’s LibSci, Intel’s Math Kernel
Library (MKL), IBM’s Engineering and Scientific Subroutine Library
(ESSL), and NVIDIA’s cuBLAS.</p></li>
</ul>
<p>Obvious algorithms for some linear algebra operations like dense
matrix-matrix multiply are asymptotically slower than less-obvious
algorithms. (For details, please refer to a survey one of us coauthored,
<a href="https://doi.org/10.1017/S0962492914000038"> “Communication
lower bounds and optimal algorithms for numerical linear algebra.”</a>)
Furthermore, writing the fastest dense matrix-matrix multiply depends on
details of a specific computer architecture. This makes such operations
comparable to <code>sort</code> in the C++ Standard Library: worth
standardizing, so that Standard Library implementers can get them right
and hardware vendors can optimize them. In fact, almost all C++ linear
algebra libraries end up calling non-C++ implementations of these
algorithms, especially the implementations in optimized BLAS libraries
(see below). In this respect, linear algebra is also analogous to
standard library features like <code>random_device</code>: often
implemented directly in assembly or even with special hardware, and thus
an essential component of allowing no room for another language “below”
C++ (see P0939R4) and Stroustrup’s “The Design and Evolution of
C++”).</p>
<p>Dense linear algebra is the core component of most algorithms and
applications that use linear algebra, and the component that is most
widely shared over different application areas. For example, tensor
computations end up spending most of their time in optimized dense
linear algebra functions. Sparse matrix computations get best
performance when they spend as much time as possible in dense linear
algebra.</p>
<p>The C++ Standard Library includes many
<a href="https://eel.is/c++draft/sf.cmath">“mathematical special
functions”</a> (<strong>[sf.cmath]</strong>), like incomplete elliptic
integrals, Bessel functions, and other polynomials and functions named
after various mathematicians. Any of them comes with its own theory and
set of applications for which robust and accurate implementations are
indispensible. We think that linear algebra operations are at least as
broadly useful, and in many cases significantly more so.</p>
<h1 data-number="6" id="why-base-a-c-linear-algebra-library-on-the-blas"><span class="header-section-number">6</span> Why base a C++ linear algebra
library on the BLAS?<a href="#why-base-a-c-linear-algebra-library-on-the-blas" class="self-link"></a></h1>
<ol type="1">
<li><p>The BLAS is a standard that codifies decades of existing
practice.</p></li>
<li><p>The BLAS separates “performance primitives” for hardware experts
to tune, from mathematical operations that rely on those primitives for
good performance.</p></li>
<li><p>Benchmarks reward hardware and system vendors for providing
optimized BLAS implementations.</p></li>
<li><p>Writing a fast BLAS implementation for common element types is
nontrivial, but well understood.</p></li>
<li><p>Optimized third-party BLAS implementations with liberal software
licenses exist.</p></li>
<li><p>Building a C++ interface on top of the BLAS is a straightforward
exercise, but has pitfalls for unaware developers.</p></li>
</ol>
<p>Linear algebra has had a cross-language standard, the Basic Linear
Algebra Subroutines (BLAS), since 2002. The Standard came out of a
<a href="http://www.netlib.org/blas/blast-forum/">standardization
process</a> that started in 1995 and held meetings three times a year
until 1999. Participants in the process came from industry, academia,
and government research laboratories. The dense linear algebra subset of
the BLAS codifies forty years of evolving practice, and has existed in
recognizable form since 1990 (see P1417R0).</p>
<p>The BLAS interface was specifically designed as the distillation of
the “computer science” or performance-oriented parts of linear algebra
algorithms. It cleanly separates operations most critical for
performance, from operations whose implementation takes expertise in
mathematics and rounding-error analysis. This gives vendors
opportunities to add value, without asking for expertise outside the
typical required skill set of a Standard Library implementer.</p>
<p>Well-established benchmarks such as the
<a href="https://www.top500.org/project/linpack/">LINPACK benchmark</a>,
reward computer hardware vendors for optimizing their BLAS
implementations. Thus, many vendors provide an optimized BLAS library
for their computer architectures. Writing fast BLAS-like operations is
not trivial, and depends on computer architecture. However, it is a
well-understood problem whose solutions could be parameterized for a
variety of computer architectures. See, for example,
<a href="https://doi.org/10.1145/1356052.1356053">Goto and van de Geijn
2008</a>. There are optimized third-party BLAS implementations for
common architectures, like
<a href="http://math-atlas.sourceforge.net/">ATLAS</a> and
<a href="https://www.tacc.utexas.edu/research-development/tacc-software/gotoblas2">GotoBLAS</a>.
A (slow but correct)
<a href="http://www.netlib.org/blas/#_reference_blas_version_3_8_0">reference
implementation of the BLAS</a> exists and it has a liberal software
license for easy reuse.</p>
<p>We have experience in the exercise of wrapping a C or Fortran BLAS
implementation for use in portable C++ libraries. We describe this
exercise in detail in our paper “Evolving a Standard C++ Linear Algebra
Library from the BLAS” <a href="https://wg21.link/p1674">(P1674)</a>. It
is straightforward for vendors, but has pitfalls for developers. For
example, Fortran’s application binary interface (ABI) differs across
platforms in ways that can cause run-time errors (even incorrect
results, not just crashing). Historical examples of vendors’ C BLAS
implementations have also had ABI issues that required work-arounds.
This dependence on ABI details makes availability in a standard C++
library valuable.</p>
<h1 data-number="7" id="criteria-for-including-algorithms"><span class="header-section-number">7</span> Criteria for including
algorithms<a href="#criteria-for-including-algorithms" class="self-link"></a></h1>
<h2 data-number="7.1" id="criteria-for-all-the-algorithms"><span class="header-section-number">7.1</span> Criteria for all the
algorithms<a href="#criteria-for-all-the-algorithms" class="self-link"></a></h2>
<p>We include algorithms in our proposal based on the following
criteria, ordered by decreasing importance. Many of our algorithms
satisfy multiple criteria.</p>
<ol type="1">
<li><p>Getting the desired asymptotic run time is nontrivial</p></li>
<li><p>Opportunity for vendors to provide hardware-specific
optimizations</p></li>
<li><p>Opportunity for vendors to provide quality-of-implementation
improvements, especially relating to accuracy or reproducibility with
respect to floating-point rounding error</p></li>
<li><p>User convenience (familiar name, or tedious to
implement)</p></li>
</ol>
<p>Regarding (1), “nontrivial” means “at least for novices to the
field.” Dense matrix-matrix multiply is a good example. Getting close to
the asymptotic lower bound on the number of memory reads and writes
matters a lot for performance, and calls for a nonintuitive loop
reordering. An analogy to the current C++ Standard Library is
<code>sort</code>, where intuitive algorithms that many humans use are
not asymptotically optimal.</p>
<p>Regarding (2), a good example is copying multidimensional arrays. The
<a href="https://github.com/kokkos/kokkos">Kokkos library</a> spends
about 2500 lines of code on multidimensional array copy, yet still
relies on system libraries for low-level optimizations. An analogy to
the current C++ Standard Library is <code>copy</code> or even
<code>memcpy</code>.</p>
<p>Regarding (3), accurate floating-point summation is nontrivial.
Well-meaning compiler optimizations might defeat even simple technqiues,
like compensated summation. The most obvious way to compute a vector’s
Euclidean norm (square root of sum of squares) can cause overflow or
underflow, even when the exact answer is much smaller than the overflow
threshold, or larger than the underflow threshold. Some users care
deeply about sums, even parallel sums, that always get the same answer,
despite rounding error. This can help debugging, for example. It is
possible to make floating-point sums completely independent of parallel
evaluation order. See e.g., the
<a href="https://bebop.cs.berkeley.edu/reproblas/">ReproBLAS</a> effort.
Naming these algorithms and providing <code>ExecutionPolicy</code>
customization hooks gives vendors a chance to provide these
improvements. An analogy to the current C++ Standard Library is
<code>hypot</code>, whose language in the C++ Standard alludes to the
tighter POSIX requirements.</p>
<p>Regarding (4), the C++ Standard Library is not entirely minimalist.
One example is <code>std::string::contains</code>. Existing Standard
Library algorithms already offered this functionality, but a member
<code>contains</code> function is easy for novices to find and use, and
avoids the tedium of comparing the result of <code>find</code> to
<code>npos</code>.</p>
<p>The BLAS exists mainly for the first two reasons. It includes
functions that were nontrivial for compilers to optimize in its time,
like scaled elementwise vector sums, as well as functions that generally
require human effort to optimize, like matrix-matrix multiply.</p>
<h2 data-number="7.2" id="criteria-for-including-blas-1-algorithms-coexistence-with-ranges"><span class="header-section-number">7.2</span> Criteria for including BLAS 1
algorithms; coexistence with ranges<a href="#criteria-for-including-blas-1-algorithms-coexistence-with-ranges" class="self-link"></a></h2>
<p>The BLAS developed in three “levels”: 1, 2, and 3. BLAS 1 includes
“vector-vector” operations like dot products, norms, and vector
addition. BLAS 2 includes “matrix-vector” operations like matrix-vector
products and outer products. BLAS 3 includes “matrix-matrix” operations
like matrix-matrix products and triangular solve with multiple
“right-hand side” vectors. The BLAS level coincides with the number of
nested loops in a naïve sequential implementation of the operation.
Increasing level also comes with increasing potential for data reuse.
For history of the BLAS “levels” and a bibliography, see
<a href="https://wg21.link/p1417">P1417</a>.</p>
<p>We mention this here because some reviewers have asked how the
algorithms in our proposal would coexist with the existing ranges
algorithms in the C++ Standard Library. (Ranges was a feature added to
the C++ Standard Library in C++20.) This question actually encloses two
questions.</p>
<ol type="1">
<li><p>Will our proposed algorithms syntactically collide with existing
ranges algorithms?</p></li>
<li><p>How much overlap do our proposed algorithms have with the
existing ranges algorithms? (That is, do we really need these new
algorithms?)</p></li>
</ol>
<h3 data-number="7.2.1" id="low-risk-of-syntactic-collision-with-ranges"><span class="header-section-number">7.2.1</span> Low risk of syntactic
collision with ranges<a href="#low-risk-of-syntactic-collision-with-ranges" class="self-link"></a></h3>
<p>We think there is low risk of our proposal colliding syntactically
with existing ranges algorithms, for the following reasons.</p>
<ul>
<li><p>We propose our algorithms in a new namespace
<code>std::linalg</code>.</p></li>
<li><p>None of the algorithms we propose share names with any existing
ranges algorithms.</p></li>
<li><p>We take care not to use <code>_view</code> as a suffix, in order
to avoid confusion or name collisions with “views” in the sense of
ranges.</p></li>
<li><p>We specifically do not use the names <code>transpose</code> or
<code>transpose_view</code>, since LEWG has advised us that ranges
algorithms may want to claim these names. (One could imagine
“transposing” a range of ranges.)</p></li>
<li><p>We constrain our algorithms only to take vector and matrix
parameters as <code>mdspan</code>. <code>mdspan</code> is not currently
a range, and there are currently no proposals in flight that would make
it a range. Changing <code>mdspan</code> of arbitrary rank to be a range
would require a design for multidimensional iterators. P0009’s coauthors
have not proposed a design, and it has proven challenging to get
compilers to optimize any existing design for multidimensional
iterators.</p></li>
</ul>
<h3 data-number="7.2.2" id="minimal-overlap-with-ranges-is-justified-by-user-convenience"><span class="header-section-number">7.2.2</span> Minimal overlap with ranges
is justified by user convenience<a href="#minimal-overlap-with-ranges-is-justified-by-user-convenience" class="self-link"></a></h3>
<p>The rest of this section answers the second question. The BLAS 2 and
3 algorithms require multiple nested loops, and high-performing
implementations generally need intermediate storage. This would make it
unnatural and difficult to express them in terms of ranges. Only the
BLAS 1 algorithms in our proposal might have a reasonable translation to
ranges algorithms. There, we limit ourselves to the BLAS 1 algorithms in
what follows.</p>
<p>Any rank-1 <code>mdspan</code> <code>x</code> can be translated into
the following range:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> x_range <span class="op">=</span> views<span class="op">::</span>iota<span class="op">(</span><span class="dt">size_t</span><span class="op">(</span><span class="dv">0</span><span class="op">)</span>, x<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">))</span> <span class="op">|</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a>    views<span class="op">::</span>transform<span class="op">([</span>x<span class="op">]</span> <span class="op">(</span><span class="kw">auto</span> k<span class="op">)</span> <span class="op">{</span> <span class="cf">return</span> x<span class="op">[</span>k<span class="op">]</span>; <span class="op">})</span>;</span></code></pre></div>
<p>with specializations possible for <code>mdspan</code> whose layout
mapping’s range is a contiguous or fixed-stride set of offsets. However,
just because code <em>could</em> be written in a certain way doesn’t
mean that it <em>should</em> be. We have ranges even though the language
has <code>for</code> loops; we don’t need to step in the Turing tar-pit
on purpose (see Perlis 1982). Thus, we will analyze the BLAS 1
algorithms in this proposal in the context of the previous section’s
four general criteria.</p>
<p>Our proposal would add 61 new unique names to the C++ Standard
Library. Of those, 16 are BLAS 1 algorithms, while 24 are BLAS 2 and 3
algorithms. The 16 BLAS 1 algorithms fall into three categories.</p>
<ol type="1">
<li><p>Optimization hooks, like <code>copy</code>. As with
<code>memcpy</code>, the fastest implementation may depend closely on
the computer architecture, and may differ significantly from a
straightforward implementation. Some of these algorithms, like
<code>copy</code>, can operate on multidimensional arrays as well,
though it is traditional to list them as BLAS 1 algorithms.</p></li>
<li><p>Floating-point quality-of-implementation hooks, like
<code>vector_sum_of_squares</code>. These give vendors opportunities to
avoid preventable floating-point underflow and overflow (as with
<code>hypot</code>), improve accuracy, and reduce or even avoid parallel
nondeterminism and order dependence of floating-point sums.</p></li>
<li><p>Uncomplicated elementwise algorithms like <code>add</code>,
<code>idx_abs_max</code>, and <code>scale</code>.</p></li>
</ol>
<p>We included the first category mainly because of Criterion (2)
“Opportunity for vendors to provide hardware-specific optimizations,”
and the second mainly because of Criterion (3) (“Opportunity for vendors
to provide quality-of-implementation improvements”). Fast
implementations of algorithms in the first category are not likely to be
simple uses of ranges algorithms.</p>
<p>Algorithms in the second category could be presented as ranges
algorithms, as <code>mdspan</code> algorithms, or as both. The
“iterating over elements” part of those algorithms is not the most
challenging part of their implementation, nor is it what makes an
implementation “high quality.”</p>
<p>Algorithms in the third category could be replaced with a few lines
of C++ that use ranges algorithms. For example, here is a parallel
implementation of <code>idx_abs_max</code>, with simplifications for
exposition. (It omits template parameters’ constraints, uses
<code>std::abs</code> instead of <em><code>abs-if-needed</code></em>,
and does not address the complex number case. Here is a
<a href="https://godbolt.org/z/7eW9ExsKM">Compiler Explorer link</a> to
a working example.)</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Element, <span class="kw">class</span> Extents,</span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">class</span> Layout, <span class="kw">class</span> Accessor<span class="op">&gt;</span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="kw">typename</span> Extents<span class="op">::</span>size_type idx_abs_max<span class="op">(</span></span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a>  std<span class="op">::</span>mdspan<span class="op">&lt;</span>Element, Extents, Layout, Accessor<span class="op">&gt;</span> x<span class="op">)</span></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a>  <span class="kw">auto</span> theRange <span class="op">=</span> std<span class="op">::</span>views<span class="op">::</span>iota<span class="op">(</span><span class="dt">size_t</span><span class="op">(</span><span class="dv">0</span><span class="op">)</span>, x<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">))</span> <span class="op">|</span></span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a>    std<span class="op">::</span>views<span class="op">::</span>transform<span class="op">([=]</span> <span class="op">(</span><span class="kw">auto</span> k<span class="op">)</span> <span class="op">{</span> <span class="cf">return</span> std<span class="op">::</span>abs<span class="op">(</span>x<span class="op">[</span>k<span class="op">])</span>; <span class="op">})</span>;</span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a>  <span class="kw">auto</span> iterOfMax <span class="op">=</span></span>
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a>    std<span class="op">::</span>max_element<span class="op">(</span>std<span class="op">::</span>execution<span class="op">::</span>par_unseq, theRange<span class="op">.</span>begin<span class="op">()</span>, theRange<span class="op">.</span>end<span class="op">())</span>;</span>
<span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a>  <span class="kw">auto</span> indexOfMax <span class="op">=</span> std<span class="op">::</span>ranges<span class="op">::</span>distance<span class="op">(</span>theRange<span class="op">.</span>begin<span class="op">()</span>, iterOfMax<span class="op">)</span>;</span>
<span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a>  <span class="co">// In GCC 12.1, the return type is __int128.</span></span>
<span id="cb5-12"><a href="#cb5-12" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> <span class="kw">static_cast</span><span class="op">&lt;</span><span class="kw">typename</span> Extents<span class="op">::</span>size_type<span class="op">&gt;(</span>indexOfMax<span class="op">)</span>;</span>
<span id="cb5-13"><a href="#cb5-13" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<p>Even though the algorithms in the third category could be implemented
straightforwardly with ranges, we provide them because of Criterion 4
(“User convenience”). Criterion (4) applies to all the algorithms in
this proposal, and particularly to the BLAS 1 algorithms. Matrix
algorithm developers need BLAS 1 and 2 as well as BLAS 3, because matrix
algorithms tend to decompose into vector algorithms. This is true even
of so-called “block” matrix algorithms that have been optimized to use
matrix-matrix operations wherever possible, in order to improve memory
locality. Demmel et al.&nbsp;1987 (p.&nbsp;4) explains.</p>
<blockquote>
<p>Block algorithms generally require an unblocked version of the same
algorithm to be available to operate on a single block. Therefore, the
development of the software will fall naturally into two phases: first,
develop unblocked versions of the routines, calling the Level 2 BLAS
wherever possible; then develop blocked versions where possible, calling
the Level 3 BLAS.</p>
</blockquote>
<p>Dongarra et al.&nbsp;1990 (pp.&nbsp;12-15) outlines this development process
for the specific example of Cholesky factorization. The Cholesky
factorization algorithm (on p.&nbsp;14) spends most of its time (for a
sufficiently large input matrix) in matrix-matrix multiplies
(<code>DGEMM</code>), rank-k symmetric matrices updates
(<code>DSYRK</code>, a special case of matrix-matrix multiply), and
triangular solves with multiple “right-hand side” vectors
(<code>DTRSM</code>). However, it still needs an “unblocked” Cholesky
factorization as the blocked factorization’s “base case.” This is called
<code>DLLT</code> in Dongarra et al.&nbsp;1990 (p.&nbsp;15), and it uses
<code>DDOT</code>, <code>DSCAL</code> (both BLAS2), and
<code>DGEMV</code> (BLAS 2). In the case of Cholesky factorization, it’s
possible to express the “unblocked” case without using BLAS 1 or 2
operations, by using recursion. This is the approach that LAPACK takes
with the blocked Cholesky factorization
<a href="https://www.netlib.org/lapack/explore-html/d1/d7a/group__double_p_ocomputational_ga2f55f604a6003d03b5cd4a0adcfb74d6.html"><code>DPOTRF</code></a>
and its unblocked base case
<a href="https://www.netlib.org/lapack/explore-html/d1/d7a/group__double_p_ocomputational_gad0718d061dc53c8b0fec6dc3710fab33.html"><code>DPOTRF2</code></a>.
However, even a recursive formulation of most matrix factorizations
needs to use BLAS 1 or 2 operations. For example, the unblocked base
case
<a href="https://www.netlib.org/lapack/explore-html/dd/d9a/group__double_g_ecomputational_gabdd3af29e9f6bbaf4b352341a1e8b464.html"><code>DGETRF2</code></a>
of LAPACK’s blocked LU factorization
<a href="https://www.netlib.org/lapack/explore-html/d3/d6a/dgetrf_8f_source.html"><code>DGETRF</code></a>
needs to invoke vector-vector operations like <code>DSCAL</code>.</p>
<p>In summary, matrix algorithm developers need vector algorithms,
because matrix algorithms decompose into vector algorithms. If our
proposal lacked BLAS 1 algorithms, even simple ones like
<code>add</code> and <code>scale</code>, matrix algorithm developers
would end up writing them anyway.</p>
<h1 data-number="8" id="notation-and-conventions"><span class="header-section-number">8</span> Notation and conventions<a href="#notation-and-conventions" class="self-link"></a></h1>
<h2 data-number="8.1" id="the-blas-uses-fortran-terms"><span class="header-section-number">8.1</span> The BLAS uses Fortran terms<a href="#the-blas-uses-fortran-terms" class="self-link"></a></h2>
<p>The BLAS’ “native” language is Fortran. It has a C binding as well,
but the BLAS Standard and documentation use Fortran terms. Where
applicable, we will call out relevant Fortran terms and highlight
possibly confusing differences with corresponding C++ ideas. Our paper
<a href="https://wg21.link/p1674">P1674</a> (“Evolving a Standard C++
Linear Algebra Library from the BLAS”) goes into more detail on these
issues.</p>
<h2 data-number="8.2" id="we-call-subroutines-functions"><span class="header-section-number">8.2</span> We call “subroutines”
functions<a href="#we-call-subroutines-functions" class="self-link"></a></h2>
<p>Like Fortran, the BLAS distinguishes between functions that return a
value, and subroutines that do not return a value. In what follows, we
will refer to both as “BLAS functions” or “functions.”</p>
<h2 data-number="8.3" id="element-types-and-blas-function-name-prefix"><span class="header-section-number">8.3</span> Element types and BLAS function
name prefix<a href="#element-types-and-blas-function-name-prefix" class="self-link"></a></h2>
<p>The BLAS implements functionality for four different matrix, vector,
or scalar element types:</p>
<ul>
<li><p><code>REAL</code> (<code>float</code> in C++ terms)</p></li>
<li><p><code>DOUBLE PRECISION</code> (<code>double</code> in C++
terms)</p></li>
<li><p><code>COMPLEX</code> (<code>complex&lt;float&gt;</code> in C++
terms)</p></li>
<li><p><code>DOUBLE COMPLEX</code> (<code>complex&lt;double&gt;</code>
in C++ terms)</p></li>
</ul>
<p>The BLAS’ Fortran 77 binding uses a function name prefix to
distinguish functions based on element type:</p>
<ul>
<li><p><code>S</code> for <code>REAL</code> (“single”)</p></li>
<li><p><code>D</code> for <code>DOUBLE PRECISION</code></p></li>
<li><p><code>C</code> for <code>COMPLEX</code></p></li>
<li><p><code>Z</code> for <code>DOUBLE COMPLEX</code></p></li>
</ul>
<p>For example, the four BLAS functions <code>SAXPY</code>,
<code>DAXPY</code>, <code>CAXPY</code>, and <code>ZAXPY</code> all
perform the vector update <code>Y = Y + ALPHA*X</code> for vectors
<code>X</code> and <code>Y</code> and scalar <code>ALPHA</code>, but for
different vector and scalar element types.</p>
<p>The convention is to refer to all of these functions together as
<code>xAXPY</code>. In general, a lower-case <code>x</code> is a
placeholder for all data type prefixes that the BLAS provides. For most
functions, the <code>x</code> is a prefix, but for a few functions like
<code>IxAMAX</code>, the data type “prefix” is not the first letter of
the function name. (<code>IxAMAX</code> is a Fortran function that
returns <code>INTEGER</code>, and therefore follows the old Fortran
implicit naming rule that integers start with <code>I</code>,
<code>J</code>, etc.) Other examples include the vector 2-norm functions
<code>SCNRM2</code> and <code>DZNRM2</code>, where the first letter
indicates the return type and the second letter indicates the vector
element type.</p>
<p>Not all BLAS functions exist for all four data types. These come in
three categories:</p>
<ol type="1">
<li><p>The BLAS provides only real-arithmetic (<code>S</code> and
<code>D</code>) versions of the function, since the function only makes
mathematical sense in real arithmetic.</p></li>
<li><p>The complex-arithmetic versions perform a different mathematical
operation than the real-arithmetic versions, so they have a different
base name.</p></li>
<li><p>The complex-arithmetic versions offer a choice between
nonconjugated or conjugated operations.</p></li>
</ol>
<p>As an example of the second category, the BLAS functions
<code>SASUM</code> and <code>DASUM</code> compute the sums of absolute
values of a vector’s elements. Their complex counterparts
<code>CSASUM</code> and <code>DZASUM</code> compute the sums of absolute
values of real and imaginary components of a vector <code>v</code>, that
is, the sum of <span class="math inline">|ℜ(<em>v</em><sub><em>i</em></sub>)| + |ℑ(<em>v</em><sub><em>i</em></sub>)|</span>
for all <code>i</code> in the domain of <code>v</code>. This operation
is still useful as a vector norm, but it requires fewer arithmetic
operations.</p>
<p>Examples of the third category include the following:</p>
<ul>
<li><p>nonconjugated dot product <code>xDOTU</code> and conjugated dot
product <code>xDOTC</code>; and</p></li>
<li><p>rank-1 symmetric (<code>xGERU</code>) vs.&nbsp;Hermitian
(<code>xGERC</code>) matrix update.</p></li>
</ul>
<p>The conjugate transpose and the (nonconjugated) transpose are the
same operation in real arithmetic (if one considers real arithmetic
embedded in complex arithmetic), but differ in complex arithmetic.
Different applications have different reasons to want either. The C++
Standard includes complex numbers, so a Standard linear algebra library
needs to respect the mathematical structures that go along with complex
numbers.</p>
<h1 data-number="9" id="what-we-exclude-from-the-design"><span class="header-section-number">9</span> What we exclude from the design<a href="#what-we-exclude-from-the-design" class="self-link"></a></h1>
<h2 data-number="9.1" id="most-functions-not-in-the-reference-blas"><span class="header-section-number">9.1</span> Most functions not in the
Reference BLAS<a href="#most-functions-not-in-the-reference-blas" class="self-link"></a></h2>
<p>The BLAS Standard includes functionality that appears neither in the
<a href="http://www.netlib.org/lapack/explore-html/d1/df9/group__blas.html">Reference
BLAS</a> library, nor in the classic BLAS “level” 1, 2, and 3 papers.
(For history of the BLAS “levels” and a bibliography, see P1417R0. For a
paper describing functions not in the Reference BLAS, see “An updated
set of basic linear algebra subprograms (BLAS),” listed in “Other
references” below.) For example, the BLAS Standard has</p>
<ul>
<li><p>several new dense functions, like a fused vector update and dot
product;</p></li>
<li><p>sparse linear algebra functions, like sparse matrix-vector
multiply and an interface for constructing sparse matrices; and</p></li>
<li><p>extended- and mixed-precision dense functions (though we subsume
some of their functionality; see below).</p></li>
</ul>
<p>Our proposal only includes core Reference BLAS functionality, for the
following reasons:</p>
<ol type="1">
<li><p>Vendors who implement a new component of the C++ Standard Library
will want to see and test against an existing reference
implementation.</p></li>
<li><p>Many applications that use sparse linear algebra also use dense,
but not vice versa.</p></li>
<li><p>The Sparse BLAS interface is a stateful interface that is not
consistent with the dense BLAS, and would need more extensive redesign
to translate into a modern C++ idiom. See discussion in
P1417R0.</p></li>
<li><p>Our proposal subsumes some dense mixed-precision functionality
(see below).</p></li>
</ol>
<p>We have included vector sum-of-squares and matrix norms as
exceptions, for the same reason that we include vector 2-norm: to expose
hooks for quality-of-implementation improvements that avoid underflow or
overflow when computing with floating-point values.</p>
<h2 data-number="9.2" id="lapack-or-related-functionality"><span class="header-section-number">9.2</span> LAPACK or related
functionality<a href="#lapack-or-related-functionality" class="self-link"></a></h2>
<p>The <a href="http://www.netlib.org/lapack/">LAPACK</a> Fortran
library implements solvers for the following classes of mathematical
problems:</p>
<ul>
<li><p>linear systems,</p></li>
<li><p>linear least-squares problems, and</p></li>
<li><p>eigenvalue and singular value problems.</p></li>
</ul>
<p>It also provides matrix factorizations and related linear algebra
operations. LAPACK deliberately relies on the BLAS for good performance;
in fact, LAPACK and the BLAS were designed together. See history
presented in P1417R0.</p>
<p>Several C++ libraries provide slices of LAPACK functionality. Here is
a brief, noninclusive list, in alphabetical order, of some libraries
actively being maintained:</p>
<ul>
<li><a href="http://arma.sourceforge.net/">Armadillo</a>,</li>
<li><a href="https://github.com/boostorg/ublas">Boost.uBLAS</a>,</li>
<li><a href="http://eigen.tuxfamily.org/index.php?title=Main_Page">Eigen</a>,</li>
<li><a href="http://www.simunova.com/de/mtl4/">Matrix Template
Library</a>, and</li>
<li><a href="https://github.com/trilinos/Trilinos/">Trilinos</a>.</li>
</ul>
<p><a href="https://wg21.link/p1417r0">P1417R0</a> gives some history of
C++ linear algebra libraries. The authors of this proposal have <a href="https://www.icl.utk.edu/files/publications/2017/icl-utk-1031-2017.pdf">designed</a>,
<a href="https://github.com/kokkos/kokkos-kernels">written</a>, and <a href="https://github.com/trilinos/Trilinos/tree/master/packages/teuchos/numerics/src">maintained</a>
LAPACK wrappers in C++. Some authors have LAPACK founders as PhD
advisors. Nevertheless, we have excluded LAPACK-like functionality from
this proposal, for the following reasons:</p>
<ol type="1">
<li><p>LAPACK is a Fortran library, unlike the BLAS, which is a
multilanguage standard.</p></li>
<li><p>We intend to support more general element types, beyond the four
that LAPACK supports. It’s much more straightforward to make a C++ BLAS
work for general element types, than to make LAPACK algorithms work
generically.</p></li>
</ol>
<p>First, unlike the BLAS, LAPACK is a Fortran library, not a standard.
LAPACK was developed concurrently with the “level 3” BLAS functions, and
the two projects share contributors. Nevertheless, only the BLAS and not
LAPACK got standardized. Some vendors supply LAPACK implementations with
some optimized functions, but most implementations likely depend heavily
on “reference” LAPACK. There have been a few efforts by LAPACK
contributors to develop C++ LAPACK bindings, from <a href="https://math.nist.gov/lapack++/">Lapack++</a> in pre-templates C++
circa 1993, to the recent <a href="https://www.icl.utk.edu/files/publications/2017/icl-utk-1031-2017.pdf">“C++
API for BLAS and LAPACK”</a>. (The latter shares coauthors with this
proposal.) However, these are still just C++ bindings to a Fortran
library. This means that if vendors had to supply C++ functionality
equivalent to LAPACK, they would either need to start with a Fortran
compiler, or would need to invest a lot of effort in a C++
reimplementation. Mechanical translation from Fortran to C++ introduces
risk, because many LAPACK functions depend critically on details of
floating-point arithmetic behavior.</p>
<p>Second, we intend to permit use of matrix or vector element types
other than just the four types that the BLAS and LAPACK support. This
includes “short” floating-point types, fixed-point types, integers, and
user-defined arithmetic types. Doing this is easier for BLAS-like
operations than for the much more complicated numerical algorithms in
LAPACK. LAPACK strives for a “generic” design (see Jack Dongarra
interview summary in P1417R0), but only supports two real floating-point
types and two complex floating-point types. Directly translating LAPACK
source code into a “generic” version could lead to pitfalls. Many LAPACK
algorithms only make sense for number systems that aim to approximate
real numbers (or their complex extentions). Some LAPACK functions output
error bounds that rely on properties of floating-point arithmetic.</p>
<p>For these reasons, we have left LAPACK-like functionality for future
work. It would be natural for a future LAPACK-like C++ library to build
on our proposal.</p>
<h2 data-number="9.3" id="extended-precision-blas"><span class="header-section-number">9.3</span> Extended-precision BLAS<a href="#extended-precision-blas" class="self-link"></a></h2>
<p>Our interface subsumes some functionality of the Mixed-Precision BLAS
specification (Chapter 4 of the BLAS Standard). For example, users may
multiply two 16-bit floating-point matrices (assuming that a 16-bit
floating-point type exists) and accumulate into a 32-bit floating-point
matrix, just by providing a 32-bit floating-point matrix as output.
Users may specify the precision of a dot product result. If it is
greater than the input vectors’ element type precisions (e.g.,
<code>double</code> vs.&nbsp;<code>float</code>), then this effectively
performs accumulation in higher precision. Our proposal imposes semantic
requirements on some functions, like <code>vector_two_norm</code>, to
behave in this way.</p>
<p>However, we do not include the “Extended-Precision BLAS” in this
proposal. The BLAS Standard lets callers decide at run time whether to
use extended precision floating-point arithmetic for internal
evaluations. We could support this feature at a later time.
Implementations of our interface also have the freedom to use more
accurate evaluation methods than typical BLAS implementations. For
example, it is possible to make floating-point sums completely <a href="https://bebop.cs.berkeley.edu/reproblas/">independent of parallel
evaluation order</a>.</p>
<h2 data-number="9.4" id="arithmetic-operators-and-associated-expression-templates"><span class="header-section-number">9.4</span> Arithmetic operators and
associated expression templates<a href="#arithmetic-operators-and-associated-expression-templates" class="self-link"></a></h2>
<p>Our proposal omits arithmetic operators on matrices and vectors. We
do so for the following reasons:</p>
<ol type="1">
<li><p>We propose a low-level, minimal interface.</p></li>
<li><p><code>operator*</code> could have multiple meanings for matrices
and vectors. Should it mean elementwise product (like
<code>valarray</code>) or matrix product? Should libraries reinterpret
“vector times vector” as a dot product (row vector times column vector)?
We prefer to let a higher-level library decide this, and make everything
explicit at our lower level.</p></li>
<li><p>Arithmetic operators require defining the element type of the
vector or matrix returned by an expression. Functions let users specify
this explicitly, and even let users use different output types for the
same input types in different expressions.</p></li>
<li><p>Arithmetic operators may require allocation of temporary matrix
or vector storage. This prevents use of nonowning data
structures.</p></li>
<li><p>Arithmetic operators strongly suggest expression templates. These
introduce problems such as dangling references and aliasing.</p></li>
</ol>
<p>Our goal is to propose a low-level interface. Other libraries, such
as that proposed by <a href="https://wg21.link/p1385">P1385</a>, could
use our interface to implement overloaded arithmetic for matrices and
vectors. A constrained, function-based, BLAS-like interface builds
incrementally on the many years of BLAS experience.</p>
<p>Arithmetic operators on matrices and vectors would require the
library, not necessarily the user, to specify the element type of an
expression’s result. This gets tricky if the terms have mixed element
types. For example, what should the element type of the result of the
vector sum <code>x + y</code> be, if <code>x</code> has element type
<code>complex&lt;float&gt;</code> and <code>y</code> has element type
<code>double</code>? It’s tempting to use <code>common_type_t</code>,
but <code>common_type_t&lt;complex&lt;float&gt;, double&gt;</code> is
<code>complex&lt;float&gt;</code>. This loses precision. Some users may
want <code>complex&lt;double&gt;</code>; others may want
<code>complex&lt;long double&gt;</code> or something else, and others
may want to choose different types in the same program.</p>
<p>P1385 lets users customize the return type of such arithmetic
expressions. However, different algorithms may call for the same
expression with the same inputs to have different output types. For
example, iterative refinement of linear systems <code>Ax=b</code> can
work either with an extended-precision intermediate residual vector
<code>r = b - A*x</code>, or with a residual vector that has the same
precision as the input linear system. Each choice produces a different
algorithm with different convergence characteristics, per-iteration run
time, and memory requirements. Thus, our library lets users specify the
result element type of linear algebra operations explicitly, by calling
a named function that takes an output argument explicitly, rather than
an arithmetic operator.</p>
<p>Arithmetic operators on matrices or vectors may also need to allocate
temporary storage. Users may not want that. When LAPACK’s developers
switched from Fortran 77 to a subset of Fortran 90, their users rejected
the option of letting LAPACK functions allocate temporary storage on
their own. Users wanted to control memory allocation. Also, allocating
storage precludes use of nonowning input data structures like
<code>mdspan</code>, that do not know how to allocate.</p>
<p>Arithmetic expressions on matrices or vectors strongly suggest
expression templates, as a way to avoid allocation of temporaries and to
fuse computational kernels. They do not <em>require</em> expression
templates. For example, <code>valarray</code> offers overloaded
operators for vector arithmetic, but the Standard lets implementers
decide whether to use expression templates. However, all of the current
C++ linear algebra libraries that we mentioned above have some form of
expression templates for overloaded arithmetic operators, so users will
expect this and rely on it for good performance. This was, indeed, one
of the major complaints about initial implementations of
<code>valarray</code>: its lack of mandate for expression templates
meant that initial implementations were slow, and thus users did not
want to rely on it. (See Josuttis 1999, p.&nbsp;547, and Vandevoorde and
Josuttis 2003, p.&nbsp;342, for a summary of the history. Fortran has an
analogous issue, in which (under certain conditions) it is
implementation defined whether the run-time environment needs to copy
noncontiguous slices of an array into contiguous temporary storage.)</p>
<p>Expression templates work well, but have issues. Our papers
<a href="https://wg21.link/p1417r0">P1417R0</a> and “Evolving a Standard
C++ Linear Algebra Library from the BLAS”
<a href="https://wg21.link/p1674">(P1674)</a> give more detail on these
concerns. A particularly troublesome one is that C++ <code>auto</code>
type deduction makes it easy for users to capture expressions before the
expression templates system has the chance to evaluate them and write
the result into the output. For matrices and vectors with container
semantics, this makes it easy to create dangling references. Users might
not realize that they need to assign expressions to named types before
actual work and storage happen. <a href="https://eigen.tuxfamily.org/dox/TopicPitfalls.html">Eigen’s
documentation</a> describes this common problem.</p>
<p>Our <code>scaled</code>, <code>conjugated</code>,
<code>transposed</code>, and <code>conjugate_transposed</code> functions
make use of one aspect of expression templates, namely modifying the
<code>mdspan</code> array access operator. However, we intend these
functions for use only as in-place modifications of arguments of a
function call. Also, when modifying <code>mdspan</code>, these functions
merely view the same data that their input <code>mdspan</code> views.
They introduce no more potential for dangling references than
<code>mdspan</code> itself. The use of views like <code>mdspan</code> is
self-documenting; it tells users that they need to take responsibility
for scope of the viewed data.</p>
<h2 data-number="9.5" id="banded-matrix-layouts"><span class="header-section-number">9.5</span> Banded matrix layouts<a href="#banded-matrix-layouts" class="self-link"></a></h2>
<p>This proposal omits banded matrix types. It would be easy to add the
required layouts and specializations of algorithms later. The packed and
unpacked symmetric and triangular layouts in this proposal cover the
major concerns that would arise in the banded case, like nonstrided and
nonunique layouts, and matrix types that forbid access to some
multi-indices in the Cartesian product of extents.</p>
<h2 data-number="9.6" id="tensors"><span class="header-section-number">9.6</span> Tensors<a href="#tensors" class="self-link"></a></h2>
<p>We exclude tensors from this proposal, for the following reasons.
First, tensor libraries naturally build on optimized dense linear
algebra libraries like the BLAS, so a linear algebra library is a good
first step. Second, <code>mdspan</code> has natural use as a low-level
representation of dense tensors, so we are already partway there. Third,
even simple tensor operations that naturally generalize the BLAS have
infintely many more cases than linear algebra. It’s not clear to us
which to optimize. Fourth, even though linear algebra is a special case
of tensor algebra, users of linear algebra have different interface
expectations than users of tensor algebra. Thus, it makes sense to have
two separate interfaces.</p>
<h2 data-number="9.7" id="explicit-support-for-asynchronous-return-of-scalar-values"><span class="header-section-number">9.7</span> Explicit support for
asynchronous return of scalar values<a href="#explicit-support-for-asynchronous-return-of-scalar-values" class="self-link"></a></h2>
<p>After we presented revision 2 of this paper, LEWG asked us to
consider support for discrete graphics processing units (GPUs). GPUs
have two features of interest here. First, they might have memory that
is not accessible from ordinary C++ code, but could be accessed in a
standard algorithm (or one of our proposed algorithms) with the right
implementation-specific <code>ExecutionPolicy</code>. (For instance, a
policy could say “run this algorithm on the GPU.”) Second, they might
execute those algorithms asynchronously. That is, they might write to
output arguments at some later time after the algorithm invocation
returns. This would imply different interfaces in some cases. For
instance, a hypothetical asynchronous vector 2-norm might write its
scalar result via a pointer to GPU memory, instead of returning the
result “on the CPU.”</p>
<p>Nothing in principle prevents <code>mdspan</code> from viewing memory
that is inaccessible from ordinary C++ code. This is a major feature of
the <code>Kokkos::View</code> class from the <a href="https://github.com/kokkos/kokkos">Kokkos library</a>, and
<code>Kokkos::View</code> directly inspired <code>mdspan</code>. The C++
Standard does not currently define how such memory behaves, but
implementations could define its behavior and make it work with
<code>mdspan</code>. This would, in turn, let implementations define our
algorithms to operate on such memory efficiently, if given the right
implementation-specific <code>ExecutionPolicy</code>.</p>
<p>Our proposal excludes algorithms that might write to their output
arguments at some time after the algorithm returns. First, LEWG insisted
that our proposed algorithms that compute a scalar result, like
<code>vector_two_norm</code>, return that result in the manner of
<code>reduce</code>, rather than writing the result to an output
reference or pointer. (Previous revisions of our proposal used the
latter interface pattern.) Second, it’s not clear whether writing a
scalar result to a pointer is the right interface for asynchronous
algorithms. Follow-on proposals to <a href="https://wg21.link/p0443R14">Executors (P0443R14)</a> include
asynchronous algorithms, but none of these suggest returning results
asynchronously by pointer. Our proposal deliberately imitates the
existing standard algorithms. Right now, we have no standard
asynchronous algorithms to imitate.</p>
<h1 data-number="10" id="design-justification"><span class="header-section-number">10</span> Design justification<a href="#design-justification" class="self-link"></a></h1>
<p>We take a step-wise approach. We begin with core BLAS dense linear
algebra functionality. We then deviate from that only as much as
necessary to get algorithms that behave as much as reasonable like the
existing C++ Standard Library algorithms. Future work or collaboration
with other proposals could implement a higher-level interface.</p>
<p>Please refer to our papers “Evolving a Standard C++ Linear Algebra
Library from the BLAS” <a href="https://wg21.link/p1674">(P1674)</a> and
“Historical lessons for C++ linear algebra library standardization”
<a href="https://wg21.link/p1417">(P1417)</a> They will give details and
references for many of the points that we summarize here.</p>
<h2 data-number="10.1" id="we-do-not-require-using-the-blas-library-or-any-particular-back-end"><span class="header-section-number">10.1</span> We do not require using the
BLAS library or any particular “back-end”<a href="#we-do-not-require-using-the-blas-library-or-any-particular-back-end" class="self-link"></a></h2>
<p>Our proposal is inspired by and extends the dense BLAS interface. A
natural implementation might look like this:</p>
<ol type="1">
<li><p>wrap an existing C or Fortran BLAS library,</p></li>
<li><p>hope that the BLAS library is optimized, and then</p></li>
<li><p>extend the wrapper to include straightforward Standard C++
implementations of P1673’s algorithms for matrix and vector value types
and data layouts that the BLAS does not support.</p></li>
</ol>
<p>P1674 describes the process of writing such an implementation.
However, P1673 does not require implementations to wrap the BLAS. In
particular, P1673 does not specify a “back-end” C-style interface that
would let users or implementers “swap out” different BLAS libraries.
Here are some reasons why we made this choice.</p>
<p>First, it’s possible to write an optimized implementation entirely in
Standard C++, without calling external C or Fortran functions. For
example, one can write a cache-blocked matrix-matrix multiply
implementation entirely in Standard C++.</p>
<p>Second, different vendors may have their own libraries that support
matrix and vector value types and/or layouts beyond what the standard
dense BLAS supports. For example, they may have C functions for
mixed-precision matrix-matrix multiply, like BLIS’ <code>bli_gemm</code>
<a href="https://github.com/flame/blis/blob/master/examples/oapi/11gemm_md.c">(example
here)</a>, or NVIDIA’s <code>cublasGemmEx</code>
<a href="https://docs.nvidia.com/cuda/cublas/index.html#cublas-GemmEx">(example
here)</a>.</p>
<p>Third, just because a C or Fortran BLAS library can be found, doesn’t
mean that it’s optimized at all or optimized well. For example, many
Linux distributions have a BLAS software package that is built by
compiling the Reference BLAS. This will give poor performance for BLAS 3
operations. Even “optimized” vendor BLAS libraries may not optimize all
cases. Release notes even for recent versions show performance
improvements.</p>
<p>In summary: While a natural way to implement this proposal would be
to wrap an existing C or Fortran BLAS library, we do not want to require
this. Thus, we do not specify a “back-end” C-style interface.</p>
<h2 data-number="10.2" id="why-use-mdspan"><span class="header-section-number">10.2</span> Why use <code>mdspan</code>?<a href="#why-use-mdspan" class="self-link"></a></h2>
<h3 data-number="10.2.1" id="view-of-a-multidimensional-array"><span class="header-section-number">10.2.1</span> View of a multidimensional
array<a href="#view-of-a-multidimensional-array" class="self-link"></a></h3>
<p>The BLAS operates on what C++ programmers might call views of
multidimensional arrays. Users of the BLAS can store their data in
whatever data structures they like, and handle their allocation and
lifetime as they see fit, as long as the data have a BLAS-compatible
memory layout.</p>
<p>The corresponding C++ data structure is <code>mdspan</code>. This
class encapsulates the large number of pointer and integer arguments
that BLAS functions take, that represent views of matrices and vectors.
Using <code>mdspan</code> in the C++ interface reduce the number of
arguments and avoids common errors, like mixing up the order of
arguments. It supports all the array memory layouts that the BLAS
supports, including row major and column major. It also expresses the
same data ownership model that the BLAS expresses. Users may manage
allocation and deallocation however they wish. In addition,
<code>mdspan</code> lets our algorithms exploit any dimensions known at
compile time.</p>
<h3 data-number="10.2.2" id="ease-of-use"><span class="header-section-number">10.2.2</span> Ease of use<a href="#ease-of-use" class="self-link"></a></h3>
<p>The <code>mdspan</code> class’ layout and accessor policies let us
simplify our interfaces, by encapsulating transpose, conjugate, and
scalar arguments. Features of <code>mdspan</code> make implementing
BLAS-like algorithms much less error prone and easier to read. These
include its encapsulation of matrix indexing and its built-in “slicing”
capabilities via <code>submdspan</code>.</p>
<h3 data-number="10.2.3" id="blas-and-mdspan-are-low-level"><span class="header-section-number">10.2.3</span> BLAS and <code>mdspan</code>
are low level<a href="#blas-and-mdspan-are-low-level" class="self-link"></a></h3>
<p>The BLAS is low level; it imposes no mathematical meaning on
multidimensional arrays. This gives users the freedom to develop
mathematical libraries with the semantics they want. Similarly,
<code>mdspan</code> is just a view of a multidimensional array; it has
no mathematical meaning on its own.</p>
<p>We mention this because “matrix,” “vector,” and “tensor” are
mathematical ideas that mean more than just arrays of numbers. This is
more than just a theoretical concern. Some BLAS functions operate on
“triangular,” “symmetric,” or “Hermitian” matrices, but they do not
assert that a matrix has any of these mathematical properties. Rather,
they only read only one side of the matrix (the lower or upper
triangle), and compute as if the other side of the matrix satisfies the
mathematical property. A key feature of the BLAS and libraries that
build on it, like LAPACK, is that they can operate on the matrix’s data
in place. These operations change both the matrix’s mathematical
properties and its representation in memory. For example, one might have
an N x N array representing a matrix that is symmetric in theory, but
computed and stored in a way that might not result in exactly symmetric
data. In order to solve linear systems with this matrix, one might give
the array to LAPACK’s <code>xSYTRF</code> to compute an <span class="math inline"><em>L</em><em>D</em><em>L</em><sup><em>T</em></sup></span>
factorization, asking <code>xSYTRF</code> only to access the array’s
lower triangle. If <code>xSYTRF</code> finishes successfully, it has
overwritten the lower triangle of its input with a representation of
both the lower triangular factor L and the block diagonal matrix D, as
computed assuming that the matrix is the sum of the lower triangle and
the transpose of the lower triangle. The resulting N x N array no longer
represents a symmetric matrix. Rather, it contains part of the
representation of a <span class="math inline"><em>L</em><em>D</em><em>L</em><sup><em>T</em></sup></span>
factorization of the matrix. The upper triangle still contains the
original input matrix’s data. One may then solve linear systems by
giving <code>xSYTRS</code> the lower triangle, along with other output
of <code>xSYTRF</code>.</p>
<p>The point of this example is that a “symmetric matrix class” is the
wrong way to model this situation. There’s an N x N array, whose
mathematical interpretation changes with each in-place operation
performed on it. The low-level <code>mdspan</code> data structure
carries no mathematical properties in itself, so it models this
situation better.</p>
<h3 data-number="10.2.4" id="hook-for-future-expansion"><span class="header-section-number">10.2.4</span> Hook for future expansion<a href="#hook-for-future-expansion" class="self-link"></a></h3>
<p>The <code>mdspan</code> class treats its layout as an extension
point. This lets our interface support layouts beyond what the BLAS
Standard permits. The accessor extension point offers us a hook for
future expansion to support heterogeneous memory spaces. (This is a key
feature of <code>Kokkos::View</code>, the data structure that inspired
<code>mdspan</code>.) In addition, using <code>mdspan</code> has made it
easier for us to propose an efficient “batched” interface in our
separate proposal <a href="https://wg21.link/p2901">P2901</a>, with
almost no interface differences.</p>
<h3 data-number="10.2.5" id="generic-enough-to-replace-a-multidimensional-array-concept"><span class="header-section-number">10.2.5</span> Generic enough to replace a
“multidimensional array concept”<a href="#generic-enough-to-replace-a-multidimensional-array-concept" class="self-link"></a></h3>
<p>Our functions differ from the C++ Standard algorithms, in that they
take a concrete type <code>mdspan</code> with template parameters,
rather than any of an open set of types that satisfy some concept. LEWGI
requested in the 2019 Cologne meeting that we explore using a concept
instead of <code>mdspan</code> to define the arguments for the linear
algebra functions. This would mean that instead of having our functions
take <code>mdspan</code> parameters, the functions would be generic on
one or more suitably constrained multidimensional array types. The
constraints would form a “multidimensional array concept.”</p>
<p>We investigated this option, and rejected it, for the following
reasons. First, our proposal uses enough features of <code>mdspan</code>
that any concept generally applicable to all functions we propose would
replicate almost the entire definition of <code>mdspan</code>. This
proposal refers to almost all of <code>mdspan</code>’s features,
including <code>extents</code>, layouts, and accessors. The
<code>conjugated</code>, <code>scaled</code>, and
<code>transposed</code> functions in this proposal depend specifically
on custom layouts and accessors. These features make the algorithms have
more functionality than their C or Fortran BLAS equivalents, while
reducing the number of parameters that the algorithms take. They also
make the interface more consistent, in that each <code>mdspan</code>
parameter of a function behaves as itself and is not otherwise
“modified” by other parameters. Second, conversely, we think that
<code>mdspan</code>’s potential for customization gives it the power to
represent any reasonable multidimensional array view. Thus,
<code>mdspan</code> “is the concept.” Third, this proposal could support
any reasonable multidimensional array type, if the type just made it
convertible to <code>mdspan</code>, for example via a general
customization point <code>get_mdspan</code> that returns an
<code>mdspan</code> that views the array’s elements. Fourth, a
multidimensional array concept would only have value if nearly all
multidimensional arrays “in the wild” had the same interface, and if
that were actually the interface we wanted. However, the adoption of
<a href="https://wg21.link/p2128r6">P2128R6</a> into C++23 makes
<code>operator[]</code> the preferred multidimensional array access
operator. As the discussion in P2128 points out, <code>operator[]</code>
not supporting multiple parameters before C++23 meant that different
multidimensional array classes exposed array access with different
syntax. While many of them used the function call operator
<code>operator()</code>, <code>mdspan</code> quite deliberately does
not. P2128 explains why it’s a bad idea for a multidimensional array
type to support both <code>operator()</code> and
<code>operator[]</code>. Thus, a hypothetical multidimensional array
concept could not represent both pre-C++23 and post-C++23
multidimensional arrays. After further discussion at the 2019 Belfast
meeting, LEWGI accepted our position that it is reasonable for our
algorithms to take the concrete (yet highly customizable) type
<code>mdspan</code>, instead of template parameters constrained by a
multidimensional array concept.</p>
<h2 data-number="10.3" id="function-argument-aliasing-and-zero-scalar-multipliers"><span class="header-section-number">10.3</span> Function argument aliasing and
zero scalar multipliers<a href="#function-argument-aliasing-and-zero-scalar-multipliers" class="self-link"></a></h2>
<p>Summary:</p>
<ol type="1">
<li><p>The BLAS Standard forbids aliasing any input (read-only) argument
with any output (write-only or read-and-write) argument.</p></li>
<li><p>The BLAS uses <code>INTENT(INOUT)</code> (read-and-write)
arguments to express “updates” to a vector or matrix. By contrast, C++
Standard algorithms like <code>transform</code> take input and output
iterator ranges as different parameters, but may let input and output
ranges be the same.</p></li>
<li><p>The BLAS uses the values of scalar multiplier arguments (“alpha”
or “beta”) of vectors or matrices at run time, to decide whether to
treat the vectors or matrices as write only. This matters both for
performance and semantically, assuming IEEE floating-point
arithmetic.</p></li>
<li><p>We decide separately, based on the category of BLAS function, how
to translate <code>INTENT(INOUT)</code> arguments into a C++ idiom:</p>
<ol type="a">
<li><p>For triangular solve and triangular multiply, in-place behavior
is essential for computing matrix factorizations in place, without
requiring extra storage proportional to the input matrix’s dimensions.
However, in-place functions may hinder implementations’ use of some
forms of parallelism. Thus, we have both not-in-place and in-place
overloads. Both take an optional <code>ExecutionPolicy&amp;&amp;</code>,
as some forms of parallelism (e.g., vectorization) may still be
effective with in-place operations.</p></li>
<li><p>Else, if the BLAS function unconditionally updates (like
<code>xGER</code>), we retain read-and-write behavior for that
argument.</p></li>
<li><p>Else, if the BLAS function uses a scalar <code>beta</code>
argument to decide whether to read the output argument as well as write
to it (like <code>xGEMM</code>), we provide two versions: a write-only
version (as if <code>beta</code> is zero), and a read-and-write version
(as if <code>beta</code> is nonzero).</p></li>
</ol></li>
</ol>
<p>For a detailed analysis, please see our paper “Evolving a Standard
C++ Linear Algebra Library from the BLAS”
<a href="https://wg21.link/p1674">(P1674)</a>.</p>
<h2 data-number="10.4" id="support-for-different-matrix-layouts"><span class="header-section-number">10.4</span> Support for different matrix
layouts<a href="#support-for-different-matrix-layouts" class="self-link"></a></h2>
<p>Summary:</p>
<ol type="1">
<li><p>The dense BLAS supports several different dense matrix “types.”
Type is a mixture of “storage format” (e.g., packed, banded) and
“mathematical property” (e.g., symmetric, Hermitian,
triangular).</p></li>
<li><p>Some “types” can be expressed as custom <code>mdspan</code>
layouts. Other types actually represent algorithmic constraints: for
instance, what entries of the matrix the algorithm is allowed to
access.</p></li>
<li><p>Thus, a C++ BLAS wrapper cannot overload on matrix “type” simply
by overloading on <code>mdspan</code> specialization. The wrapper must
use different function names, tags, or some other way to decide what the
matrix type is.</p></li>
</ol>
<p>For more details, including a list and description of the matrix
“types” that the dense BLAS supports, please see our paper “Evolving a
Standard C++ Linear Algebra Library from the BLAS”
<a href="https://wg21.link/p1674">(P1674)</a>.</p>
<p>A C++ linear algebra library has a few possibilities for
distinguishing the matrix “type”:</p>
<ol type="1">
<li><p>It could imitate the BLAS, by introducing different function
names, if the layouts and accessors do not sufficiently describe the
arguments.</p></li>
<li><p>It could introduce a hierarchy of higher-level classes for
representing linear algebra objects, use <code>mdspan</code> (or
something like it) underneath, and write algorithms to those
higher-level classes.</p></li>
<li><p>It could use the layout and accessor types in <code>mdspan</code>
simply as tags to indicate the matrix “type.” Algorithms could
specialize on those tags.</p></li>
</ol>
<p>We have chosen Approach 1. Our view is that a BLAS-like interface
should be as low-level as possible. Approach 2 is more like a “Matlab in
C++”; a library that implements this could build on our proposal’s
lower-level library. Approach 3 <em>sounds</em> attractive. However,
most BLAS matrix “types” do not have a natural representation as
layouts. Trying to hack them in would pollute <code>mdspan</code> – a
simple class meant to be easy for the compiler to optimize – with extra
baggage for representing what amounts to sparse matrices. We think that
BLAS matrix “type” is better represented with a higher-level library
that builds on our proposal.</p>
<h2 data-number="10.5" id="interpretation-of-lower-upper-triangular"><span class="header-section-number">10.5</span> Interpretation of “lower /
upper triangular”<a href="#interpretation-of-lower-upper-triangular" class="self-link"></a></h2>
<h3 data-number="10.5.1" id="triangle-refers-to-what-part-of-the-matrix-is-accessed"><span class="header-section-number">10.5.1</span> Triangle refers to what part
of the matrix is accessed<a href="#triangle-refers-to-what-part-of-the-matrix-is-accessed" class="self-link"></a></h3>
<p>The triangular, symmetric, and Hermitian algorithms in this proposal
all take a <code>Triangle</code> tag that specifies whether the
algorithm should access the upper or lower triangle of the matrix. This
has the same function as the <code>UPLO</code> argument of the
corresponding BLAS routines. The upper or lower triangular argument only
refers to what part of the matrix the algorithm will access. The “other
triangle” of the matrix need not contain useful data. For example, with
the symmetric algorithms, <code>A[j, i]</code> need not equal
<code>A[i, j]</code> for any <code>i</code> and <code>j</code> in the
domain of <code>A</code> with <code>i</code> not equal to
<code>j</code>. The algorithm just accesses one triangle and interprets
the other triangle as the result of flipping the accessed triangle over
the diagonal.</p>
<p>This “interpretation” approach to representing triangular matrices is
critical for matrix factorizations. For example, LAPACK’s LU
factorization (<code>xGETRF</code>) overwrites a matrix A with both its
L (lower triangular, implicitly represented diagonal of all ones) and U
(upper triangular, explicitly stored diagonal) factors. Solving linear
systems Ax=b with this factorization, as LAPACK’s <code>xGETRS</code>
routine does, requires solving first a linear system with the upper
triangular matrix U, and then solving a linear system with the lower
triangular matrix L. If the BLAS required that the “other triangle” of a
triangular matrix had all zero elements, then LU factorization would
require at least twice the storage. For symmetric and Hermitian
matrices, only accessing the matrix’s elements nonredundantly ensures
that the matrix remains mathematically symmetric resp. Hermitian, even
in the presence of rounding error.</p>
<h3 data-number="10.5.2" id="blas-applies-uplo-to-original-matrix-we-apply-triangle-to-transformed-matrix"><span class="header-section-number">10.5.2</span> BLAS applies UPLO to
original matrix; we apply Triangle to transformed matrix<a href="#blas-applies-uplo-to-original-matrix-we-apply-triangle-to-transformed-matrix" class="self-link"></a></h3>
<p>The BLAS routines that take an <code>UPLO</code> argument generally
also take a <code>TRANS</code> argument. The <code>TRANS</code> argument
says whether to apply the matrix, its transpose, or its conjugate
transpose. The BLAS applies the <code>UPLO</code> argument to the
“original” matrix, not to the transposed matrix. For example, if
<code>TRANS='T'</code> or <code>TRANS='C'</code>, <code>UPLO='U'</code>
means the routine will access the upper triangle of the matrix, not the
upper triangle of the matrix’s transpose.</p>
<p>Our proposal takes the opposite approach. It applies
<code>Triangle</code> to the input matrix, which may be the result of a
transformation such as <code>transposed</code> or
<code>conjugate_transposed</code>. For example, if <code>Triangle</code>
is <code>upper_triangle_t</code>, the algorithm will always access the
matrix for <code>i,j</code> in its domain with <code>i</code> ≤
<code>j</code> (or <code>i</code> strictly less than <code>j</code>, if
the algorithm takes a <code>Diagonal</code> tag and
<code>Diagonal</code> is <code>implicit_unit_diagonal_t</code>). If the
input matrix is <code>transposed(A)</code> for a
<code>layout_left</code> <code>mdspan</code> <code>A</code>, this means
that the algorithm will access the upper triangle of
<code>transposed(A)</code>, which is actually the <em>lower</em>
triangle of <code>A</code>.</p>
<p>We took this approach because our interface permits arbitrary
layouts, with possibly arbitrary nesting of layout transformations. This
comes from <code>mdspan</code>’s design itself, not even necessarily
from our proposal. For example, users might define
<code>antitranspose(A)</code>, that flips indices over the antidiagonal
(the “other diagonal” that goes from the lower left to the upper right
of the matrix, instead of from the upper left to the lower right).
Layout transformations need not even be one-to-one, because layouts
themselves need not be (hence <code>is_unique</code>). Since it’s not
possible to “undo” a general layout, there’s no way to get back to the
“original matrix.”</p>
<p>Our approach, while not consistent with the BLAS, is internally
consistent. <code>Triangle</code> always has a clear meaning, no matter
what transformations users apply to the input. Layout transformations
like <code>transposed</code> have the same interpretation for all the
matrix algorithms, whether for general, triangular, symmetric, or
Hermitian matrices. This interpretation is consistent with the standard
meaning of <code>mdspan</code> layouts.</p>
<p>C BLAS implementations already apply layout transformations like this
so that they can use an existing column-major Fortran BLAS to implement
operations on matrices with different layouts. For example, the
transpose of an <code>M</code> x <code>N</code> <code>layout_left</code>
matrix is just the same data, viewed as an <code>N</code> x
<code>M</code> <code>layout_right</code> matrix. Thus,
<code>transposed</code> is consistent with current practice. In fact,
<code>transposed</code> need not use a special
<code>layout_transpose</code>, if it knows how to reinterpret the input
layout.</p>
<h3 data-number="10.5.3" id="summary"><span class="header-section-number">10.5.3</span> Summary<a href="#summary" class="self-link"></a></h3>
<ol type="1">
<li><p>BLAS applies <code>UPLO</code> to the original matrix, before any
transposition. Our proposal applies <code>Triangle</code> to the
transformed matrix, after any transposition.</p></li>
<li><p>Our approach is the only reasonable way to handle the full
generality of user-defined layouts and layout transformations.</p></li>
</ol>
<h2 data-number="10.6" id="norms-and-infinity-norms-for-vectors-and-matrices-of-complex-numbers"><span class="header-section-number">10.6</span> 1-norms and infinity-norms for
vectors and matrices of complex numbers<a href="#norms-and-infinity-norms-for-vectors-and-matrices-of-complex-numbers" class="self-link"></a></h2>
<h3 data-number="10.6.1" id="summary-1"><span class="header-section-number">10.6.1</span> Summary<a href="#summary-1" class="self-link"></a></h3>
<p>We define complex 1-norms and infinity-norms for matrices using the
magnitude of each element, but for vectors using the sum of absolute
values of the real and imaginary components of each element.</p>
<p>We do so because the BLAS exists for the implementation of algorithms
to solve linear systems, linear least-squares problems, and eigenvalue
problems. The BLAS does not aim to provide a complete set of
mathematical operations. Every function in the BLAS exists because some
LINPACK or LAPACK algorithm needs it.</p>
<p>For vectors, we use the sum of absolute values of the components
because</p>
<ul>
<li><p>this more accurately expresses the condition number of the sum of
the vector’s elements,</p></li>
<li><p>it results in a tighter error bound, and</p></li>
<li><p>it avoids a square root per element, with potentially the
additional cost of preventing undue underflow or overflow (as
<code>hypot</code> implementations do).</p></li>
</ul>
<p>The resulting functions are not actually norms in the mathematical
sense, so their names <code>vector_abs_sum</code> and
<code>vector_idx_abs_max</code> do not include the word “norm.”</p>
<p>For matrices, we use the magnitude because the only reason LAPACK
ever actually <em>computes</em> matrix 1-norms or infinity-norms is for
estimating the condition number of a matrix. For this case, LAPACK
actually needs to compute the “true” matrix 1-norm (and infinity-norm),
that uses the magnitude.</p>
<h3 data-number="10.6.2" id="vectors"><span class="header-section-number">10.6.2</span> Vectors<a href="#vectors" class="self-link"></a></h3>
<p>The 1-norm of a vector of real numbers is the sum of the absolute
values of the vector’s elements. The infinity-norm of a vector of real
numbers is the maximum of the absolute values of the vector’s elements.
Both of these are useful for analyzing rounding errors when solving
common linear algebra problems. For example, the 1-norm of a vector
expresses the condition number of the sum of the vector’s elements (see
Higham 2002, Section 4.2), while the infinity-norm expresses the
normwise backward error of the computed solution vector when solving a
linear system using Gaussian elimination (see LAPACK Users’ Guide).</p>
<p>The straightforward extension of both of these definitions for
vectors of complex numbers would be to replace “absolute value” with
“magnitude.” C++ suggests this by defining <code>std::abs</code> for
complex arguments as the magnitude. However, the BLAS instead uses the
sum of the absolute values of the real and imaginary components of each
element. For example, the BLAS functions <code>SASUM</code> and
<code>DASUM</code> compute the actual 1-norm <span class="math inline">∑<sub><em>i</em></sub>|<em>v</em><sub><em>i</em></sub>|</span>
of their length-<span class="math inline"><em>n</em></span> input vector
of real elements <span class="math inline"><em>v</em></span>, while
their complex counterparts <code>CSASUM</code> and <code>DZASUM</code>
compute <span class="math inline">∑<sub><em>i</em></sub>|ℜ(<em>z</em><sub><em>i</em></sub>)| + |ℑ(<em>z</em><sub><em>i</em></sub>)|</span>
for their length <span class="math inline"><em>n</em></span> input
vector of complex elements <span class="math inline"><em>z</em></span>.
Likewise, the real BLAS functions <code>ISAMAX</code> and
<code>IDAMAX</code> find <span class="math inline">max<sub><em>i</em></sub>|<em>v</em><sub><em>i</em></sub>|</span>,
while their complex counterparts <code>ICAMAX</code> and
<code>IZAMAX</code> find <span class="math inline">max<sub><em>i</em></sub>|ℜ(<em>z</em><sub><em>i</em></sub>)| + |ℑ(<em>z</em><sub><em>i</em></sub>)|</span>.</p>
<p>This definition of <code>CSASUM</code> and <code>DZASUM</code>
accurately expresses the condition number of the sum of a complex
vector’s elements. This is because complex numbers are added
componentwise, so summing a complex vector componentwise is really like
summing two real vectors separately. Thus, it is the logical
generalization of the vector 1-norm.</p>
<p>Annex A.1 of the BLAS Standard (p.&nbsp;173) explains that this is also a
performance optimization, to avoid the expense of one square root per
vector element. Computing the magnitude is equivalent to two-parameter
<code>hypot</code>. Thus, for the same reason, high-quality
implementations of magnitude for floating-point arguments may do extra
work besides the square root, to prevent undue underflow or
overflow.</p>
<p>This approach also results in tighter error bounds. We mentioned
above how adding complex numbers sums their real and imaginary parts
separately. Thus, the rounding error committed by the sum can be
considered as a two-component vector. For a vector <span class="math inline"><em>x</em></span> of length 2, <span class="math inline">∥<em>x</em>∥<sub>1</sub>≤</span> sqrt(2) <span class="math inline">∥<em>x</em>∥<sub>2</sub></span> and <span class="math inline">∥<em>x</em>∥<sub>2</sub> ≤ ∥<em>x</em>∥<sub>1</sub></span>
(see LAPACK Users’ Guide), so using the “1-norm” <span class="math inline">|ℜ(<em>z</em>)| + |ℑ(<em>z</em>)|</span> of a
complex number <span class="math inline"><em>z</em></span>, instead of
the “2-norm” <span class="math inline">|<em>z</em>|</span>, gives a
tighter error bound.</p>
<p>This is why P1673’s <code>vector_abs_sum</code> (vector 1-norm) and
<code>vector_idx_abs_max</code> (vector infinity-norm) functions use
<span class="math inline">|ℜ(<em>z</em>)| + |ℑ(<em>z</em>)|</span>
instead of <span class="math inline">|<em>z</em>|</span> for the
“absolute value” of each vector element.</p>
<p>One disadvantage of these definitions is that the resulting
quantities are not actually norms. This is because they do not preserve
scaling factors. For magnitude, <span class="math inline">|<em>α</em><em>z</em>|</span> equals <span class="math inline">|<em>α</em>||<em>z</em>|</span> for any real number
<span class="math inline"><em>α</em></span> and complex number <span class="math inline"><em>z</em></span>. However, <span class="math inline">|<em>α</em>ℜ(<em>z</em>)| + |<em>α</em>ℑ(<em>z</em>)|</span>
does not equal <span class="math inline"><em>α</em>(|ℜ(<em>z</em>)|+|ℑ(<em>z</em>)|)</span>
in general. As a result, the names of the functions
<code>vector_abs_sum</code> and <code>vector_idx_abs_max</code> do not
include the word “norm.”</p>
<h3 data-number="10.6.3" id="matrices"><span class="header-section-number">10.6.3</span> Matrices<a href="#matrices" class="self-link"></a></h3>
<p>The 1-norm <span class="math inline">∥<em>A</em>∥<sub>1</sub></span>
of a matrix <span class="math inline"><em>A</em></span> is <span class="math inline"><em>m</em><em>a</em><em>x</em><sub>∥<em>x</em>∥<sub>1</sub></sub>∥<em>A</em><em>x</em>∥<sub>1</sub></span>
for all vectors <span class="math inline"><em>x</em></span> with the
same number of elements as A has columns. The infinity-norm <span class="math inline">∥<em>A</em>∥<sub>∞</sub></span> of a matrix <span class="math inline"><em>A</em></span> is <span class="math inline"><em>m</em><em>a</em><em>x</em><sub>∥<em>x</em>∥<sub>∞</sub></sub>∥<em>A</em><em>x</em>∥<sub>∞</sub></span>
for all vectors <span class="math inline"><em>x</em></span> with the
same number of elements as A has columns. The 1-norm is the
infinity-norm of the transpose, and vice versa.</p>
<p>Given that these norms are defined using the corresponding vector
norms, it would seem reasonable to use the BLAS’s optimizations for
vectors of complex numbers. However, the BLAS exists to serve LINPACK
and its successor, LAPACK (see P1417 for citations and a summary of the
history). Thus, looking at what LAPACK actually computes would be the
best guide. LAPACK uses matrix 1-norms and infinity-norms in two
different ways.</p>
<p>First, <em>equilibration</em> reduces errors when solving linear
systems using Gaussian elimination. It does so by scaling rows and
columns to minimize the matrix’s <em>condition number</em> <span class="math inline">∥<em>A</em>∥<sub>1</sub>∥<em>A</em><sup>−1</sup>∥<sub>1</sub></span>
(or <span class="math inline">∥<em>A</em>∥<sub>∞</sub>∥<em>A</em><sup>−1</sup>∥<sub>∞</sub></span>;
minimizing one minimizes the other). This effectively tries to make the
maximum absolute value of each row and column of the matrix as close to
1 as possible. (We say “close to 1,” because LAPACK equilibrates using
scaling factors that are powers of two, to prevent rounding error in
binary floating-point arithmetic.) LAPACK performs equilibration with
the routines <code>xyzEQU</code>, where <code>x</code> represents the
matrix’s element type and the two letters <code>yz</code> represent the
kind of matrix (e.g., <code>GE</code> for a general dense nonsymmetric
matrix). The complex versions of these routines use <span class="math inline">|ℜ(<em>A</em><sub><em>i</em><em>j</em></sub>)| + |ℑ(<em>A</em><sub><em>i</em><em>j</em></sub>)|</span>
for the “absolute value” of each matrix element <span class="math inline"><em>A</em><sub><em>i</em><em>j</em></sub></span>.
This aligns mathematically with how LAPACK measures errors when solving
a linear system <span class="math inline"><em>A</em><em>x</em> = <em>b</em></span>.</p>
<p>Second, <em>condition number estimation</em> estimates the condition
number of a matrix <span class="math inline"><em>A</em></span>. LAPACK
relies on the 1-norm condition number <span class="math inline">∥<em>A</em>∥<sub>1</sub>∥<em>A</em><sup>−1</sup>∥<sub>1</sub></span>
to estimate errors for nearly all of its computations. LAPACK’s
<code>xyzCON</code> routines perform condition number estimation. It
turns out that the complex versions of these routines require the “true”
1-norm that uses the magnitude of each matrix element (as explained in
Higham 1988).</p>
<p>LAPACK only ever actually <em>computes</em> matrix 1-norms or
infinity-norms when it estimates the matrix condition number. Thus,
LAPACK actually needs to compute the “true” matrix 1-norm (and
infinity-norm). This is why P1673 defines <code>matrix_one_norm</code>
and <code>matrix_inf_norm</code> to return the “true” matrix 1-norm
resp. infinity-norm.</p>
<h2 data-number="10.7" id="over--and-underflow-wording-for-vector-2-norm"><span class="header-section-number">10.7</span> Over- and underflow wording
for vector 2-norm<a href="#over--and-underflow-wording-for-vector-2-norm" class="self-link"></a></h2>
<p>SG6 recommended to us at Belfast 2019 to change the special overflow
/ underflow wording for <code>vector_two_norm</code> to imitate the BLAS
Standard more closely. The BLAS Standard does say something about
overflow and underflow for vector 2-norms. We reviewed this wording and
conclude that it is either a nonbinding quality of implementation (QoI)
recommendation, or too vaguely stated to translate directly into C++
Standard wording. Thus, we removed our special overflow / underflow
wording. However, the BLAS Standard clearly expresses the intent that
implementations document their underflow and overflow guarantees for
certain functions, like vector 2-norms. The C++ Standard requires
documentation of “implementation-defined behavior.” Therefore, we added
language to our proposal that makes “any guarantees regarding overflow
and underflow” of those certain functions “implementation-defined.”</p>
<p>Previous versions of this paper asked implementations to compute
vector 2-norms “without undue overflow or underflow at intermediate
stages of the computation.” “Undue” imitates existing C++ Standard
wording for <code>hypot</code>. This wording hints at the stricter
requirements in F.9 (normative, but optional) of the C Standard for math
library functions like <code>hypot</code>, without mandating those
requirements. In particular, paragraph 9 of F.9 says:</p>
<blockquote>
<p>Whether or when library functions raise an undeserved “underflow”
floating-point exception is unspecified. Otherwise, as implied by F.7.6,
the <strong>&lt;math.h&gt;</strong> functions do not raise spurious
floating-point exceptions (detectable by the user) [including the
“overflow” exception discussed in paragraph 6], other than the “inexact”
floating-point exception.</p>
</blockquote>
<p>However, these requirements are for math library functions like
<code>hypot</code>, not for general algorithms that return
floating-point values. SG6 did not raise a concern that we should treat
<code>vector_two_norm</code> like a math library function; their concern
was that we imitate the BLAS Standard’s wording.</p>
<p>The BLAS Standard says of several operations, including vector
2-norm: “Here are the exceptional routines where we ask for particularly
careful implementations to avoid unnecessary over/underflows, that could
make the output unnecessarily inaccurate or unreliable” (p.&nbsp;35).</p>
<p>The BLAS Standard does not define phrases like “unnecessary
over/underflows.” The likely intent is to avoid naïve implementations
that simply add up the squares of the vector elements. These would
overflow even if the norm in exact arithmetic is significantly less than
the overflow threshold. The POSIX Standard (IEEE Std 1003.1-2017)
analogously says that <code>hypot</code> must “take precautions against
overflow during intermediate steps of the computation.”</p>
<p>The phrase “precautions against overflow” is too vague for us to
translate into a requirement. The authors likely meant to exclude naïve
implementations, but not require implementations to know whether a
result computed in exact arithmetic would overflow or underflow. The
latter is a special case of computing floating-point sums exactly, which
is costly for vectors of arbitrary length. While it would be a useful
feature, it is difficult enough that we do not want to require it,
especially since the BLAS Standard itself does not. The implementation
of vector 2-norms in the Reference BLAS included with LAPACK 3.10.0
partitions the running sum of squares into three different accumulators:
one for big values (that might cause the sum to overflow without
rescaling), one for small values (that might cause the sum to underflow
without rescaling), and one for the remaining “medium” values. (See
Anderson 2017.) Earlier implementations merely rescaled by the current
maximum absolute value of all the vector entries seen thus far. (See
Blue 1978.) Implementations could also just compute the sum of squares
in a straightforward loop, then check floating-point status flags for
underflow or overflow, and recompute if needed.</p>
<p>For all of the functions listed on p.&nbsp;35 of the BLAS Standard as
needing “particularly careful implementations,” <em>except</em> vector
norm, the BLAS Standard has an “Advice to implementors” section with
extra accuracy requirements. The BLAS Standard does have an “Advice to
implementors” section for matrix norms (see Section 2.8.7, p.&nbsp;69), which
have similar over- and underflow concerns as vector norms. However, the
Standard merely states that “[h]igh-quality implementations of these
routines should be accurate” and should document their accuracy, and
gives examples of “accurate implementations” in LAPACK.</p>
<p>The BLAS Standard never defines what “Advice to implementors” means.
However, the BLAS Standard shares coauthors and audience with the
Message Passing Interface (MPI) Standard, which defines “Advice to
implementors” as “primarily commentary to implementors” and permissible
to skip (see e.g., MPI 3.0, Section 2.1, p.&nbsp;9). We thus interpret
“Advice to implementors” in the BLAS Standard as a nonbinding quality of
implementation (QoI) recommendation.</p>
<h2 data-number="10.8" id="constraining-matrix-and-vector-element-types-and-scalars"><span class="header-section-number">10.8</span> Constraining matrix and vector
element types and scalars<a href="#constraining-matrix-and-vector-element-types-and-scalars" class="self-link"></a></h2>
<h3 data-number="10.8.1" id="introduction"><span class="header-section-number">10.8.1</span> Introduction<a href="#introduction" class="self-link"></a></h3>
<p>The BLAS only accepts four different types of scalars and matrix and
vector elements. In C++ terms, these correspond to <code>float</code>,
<code>double</code>, <code>complex&lt;float&gt;</code>, and
<code>complex&lt;double&gt;</code>. The algorithms we propose generalize
the BLAS by accepting any matrix, vector, or scalar element types that
make sense for each algorithm. Those may be built-in types, like
floating-point numbers or integers, or they may be custom types. Those
custom types might not behave like conventional real or complex numbers.
For example, quaternions have noncommutative multiplication
(<code>a * b</code> might not equal <code>b * a</code>), polynomials in
one variable over a field lack division, and some types might not even
have subtraction defined. Nevertheless, many BLAS operations would make
sense for all of these types.</p>
<p>“Constraining matrix and vector element types and scalars” means
defining how these types must behave in order for our algorithms to make
sense. This includes both syntactic and semantic constraints. We have
three goals:</p>
<ol type="1">
<li><p>to help implementers implement our algorithms correctly;</p></li>
<li><p>to give implementers the freedom to make quality of
implementation (QoI) enhancements, for both performance and accuracy;
and</p></li>
<li><p>to help users understand what types they may use with our
algorithms.</p></li>
</ol>
<p>The whole point of the BLAS was to identify key operations for
vendors to optimize. Thus, performance is a major concern. “Accuracy”
here refers to either to rounding error or to approximation error (for
matrix or vector element types where either makes sense).</p>
<h3 data-number="10.8.2" id="value-type-constraints-do-not-suffice-to-describe-algorithm-behavior"><span class="header-section-number">10.8.2</span> Value type constraints do
not suffice to describe algorithm behavior<a href="#value-type-constraints-do-not-suffice-to-describe-algorithm-behavior" class="self-link"></a></h3>
<p>LEWG’s 2020 review of P1673R2 asked us to investigate
conceptification of its algorithms. “Conceptification” here refers to an
effort like that of P1813R0 (“A Concept Design for the Numeric
Algorithms”), to come up with concepts that could be used to constrain
the template parameters of numeric algorithms like <code>reduce</code>
or <code>transform</code>. (We are not referring to LEWGI’s request for
us to consider generalizing our algorithm’s parameters from
<code>mdspan</code> to a hypothetical multidimensional array concept. We
discuss that above, in the “Why use <code>mdspan</code>?” section.) The
numeric algorithms are relevant to P1673 because many of the algorithms
proposed in P1673 look like generalizations of <code>reduce</code> or
<code>transform</code>. We intend for our algorithms to be generic on
their matrix and vector element types, so these questions matter a lot
to us.</p>
<p>We agree that it is useful to set constraints that make it possible
to reason about correctness of algorithms. However, we do not think
constraints on value types suffice for this purpose. First, requirements
like associativity are too strict to be useful for practical types.
Second, what we really want to do is describe the behavior of
algorithms, regardless of value types’ semantics. “The algorithm may
reorder sums” means something different than “addition on the terms in
the sum is associative.”</p>
<h3 data-number="10.8.3" id="associativity-is-too-strict"><span class="header-section-number">10.8.3</span> Associativity is too
strict<a href="#associativity-is-too-strict" class="self-link"></a></h3>
<p>P1813R0 requires associative addition for many algorithms, such as
<code>reduce</code>. However, many practical arithmetic systems that
users might like to use with algorithms like <code>reduce</code> have
non-associative addition. These include</p>
<ul>
<li><p>systems with rounding;</p></li>
<li><p>systems with an “infinity”: e.g., if 10 is Inf, 3 + 8 - 7 could
be either Inf or 4; and</p></li>
<li><p>saturating arithmetic: e.g., if 10 saturates, 3 + 8 - 7 could be
either 3 or 4.</p></li>
</ul>
<p>Note that the latter two arithmetic systems have nothing to do with
rounding error. With saturating integer arithmetic, parenthesizing a sum
in different ways might give results that differ by as much as the
saturation threshold. It’s true that many non-associative arithmetic
systems behave “associatively enough” that users don’t fear
parallelizing sums. However, a concept with an exact property (like
“commutative semigroup”) isn’t the right match for “close enough,” just
like <code>operator==</code> isn’t the right match for describing
“nearly the same.” For some number systems, a rounding error bound might
be more appropriate, or guarantees on when underflow or overflow may
occur (as in POSIX’s <code>hypot</code>).</p>
<p>The problem is a mismatch between the requirement we want to express
– that “the algorithm may reparenthesize addition” – and the constraint
that “addition is associative.” The former describes the algorithm’s
behavior, while the latter describes the types used with that algorithm.
Given the huge variety of possible arithmetic systems, an approach like
the Standard’s use of <em>GENERALIZED_SUM</em> to describe
<code>reduce</code> and its kin seems more helpful. If the Standard
describes an algorithm in terms of <em>GENERALIZED_SUM</em>, then that
tells the caller what the algorithm might do. The caller then takes
responsibility for interpreting the algorithm’s results.</p>
<p>We think this is important both for adding new algorithms (like those
in this proposal) and for defining behavior of an algorithm with respect
to different <code>ExecutionPolicy</code> arguments. (For instance,
<code>execution::par_unseq</code> could imply that the algorithm might
change the order of terms in a sum, while <code>execution::par</code>
need not. Compare to <code>MPI_Op_create</code>’s <code>commute</code>
parameter, that affects the behavior of algorithms like
<code>MPI_Reduce</code> when used with the resulting user-defined
reduction operator.)</p>
<h3 data-number="10.8.4" id="generalizing-associativity-helps-little"><span class="header-section-number">10.8.4</span> Generalizing associativity
helps little<a href="#generalizing-associativity-helps-little" class="self-link"></a></h3>
<p>Suppose we accept that associativity and related properties are not
useful for describing our proposed algorithms. Could there be a
generalization of associativity that <em>would</em> be useful? P1813R0’s
most general concept is a <code>magma</code>. Mathematically, a
<em>magma</em> is a set M with a binary operation ×, such that if a and
b are in M, then a × b is in M. The operation need not be associative or
commutative. While this seems almost too general to be useful, there are
two reasons why even a magma is too specific for our proposal.</p>
<ol type="1">
<li><p>A magma only assumes one set, that is, one type. This does not
accurately describe what the algorithms do, and it excludes useful
features like mixed precision and types that use expression
templates.</p></li>
<li><p>A magma is too specific, because algorithms are useful even if
the binary operation is not closed.</p></li>
</ol>
<p>First, even for simple linear algebra operations that “only” use plus
and times, there is no one “set M” over which plus and times operate.
There are actually three operations: plus, times, and assignment. Each
operation may have completely heterogeneous input(s) and output. The
sets (types) that may occur vary from algorithm to algorithm, depending
on the input type(s), and the algebraic expression(s) that the algorithm
is allowed to use. We might need several different concepts to cover all
the expressions that algorithms use, and the concepts would end up being
less useful to users than the expressions themselves.</p>
<p>For instance, consider the Level 1 BLAS “AXPY” function. This
computes <code>y[i] = alpha * x[i] + y[i]</code> elementwise. What type
does the expression <code>alpha * x[i] + y[i]</code> have? It doesn’t
need to have the same type as <code>y[i]</code>; it just needs to be
assignable to <code>y[i]</code>. The types of <code>alpha</code>,
<code>x[i]</code>, and <code>y[i]</code> could all differ. As a simple
example, <code>alpha</code> might be <code>int</code>, <code>x[i]</code>
might be <code>float</code>, and <code>y[i]</code> might be
<code>double</code>. The types of <code>x[i]</code> and
<code>y[i]</code> might be more complicated; e.g., <code>x[i]</code>
might be a polynomial with <code>double</code> coefficients, and
<code>y[i]</code> a polynomial with <code>float</code> coefficients. If
those polynomials use expression templates, then slightly different sum
expressions involving <code>x[i]</code> and/or <code>y[i]</code> (e.g.,
<code>alpha * x[i] + y[i]</code>, <code>x[i] + y[i]</code>, or
<code>y[i] + x[i]</code>) might all have different types, all of which
differ from value type of <code>x</code> or <code>y</code>. All of these
types must be assignable and convertible to the output value type.</p>
<p>We could try to describe this with a concept that expresses a sum
type. The sum type would include all the types that might show up in the
expression. However, we do not think this would improve clarity over
just the expression itself. Furthermore, different algorithms may need
different expressions, so we would need multiple concepts, one for each
expression. Why not just use the expressions to describe what the
algorithms can do?</p>
<p>Second, the magma concept is not helpful even if we only had one set
M, because our algorithms would still be useful even if binary
operations were not closed over that set. For example, consider a
hypothetical user-defined rational number type, where plus and times
throw if representing the result of the operation would take more than a
given fixed amount of memory. Programmers might handle this exception by
falling back to different algorithms. Neither plus or times on this type
would satisfy the magma requirement, but the algorithms would still be
useful for such a type. One could consider the magma requirement
satisfied in a purely syntactic sense, because of the return type of
plus and times. However, saying that would not accurately express the
type’s behavior.</p>
<p>This point returns us to the concerns we expressed earlier about
assuming associativity. “Approximately associative” or “usually
associative” are not useful concepts without further refinement. The way
to refine these concepts usefully is to describe the behavior of a type
fully, e.g., the way that IEEE 754 describes the behavior of
floating-point numbers. However, algorithms rarely depend on all the
properties in a specification like IEEE 754. The problem, again, is that
we need to describe what algorithms do – e.g., that they can rearrange
terms in a sum – not how the types that go into the algorithms
behave.</p>
<p>In summary:</p>
<ul>
<li><p>Many useful types have nonassociative or even non-closed
arithmetic.</p></li>
<li><p>Lack of (e.g.,) associativity is not just a rounding error
issue.</p></li>
<li><p>It can be useful to let algorithms do things like reparenthesize
sums or products, even for types that are not associative.</p></li>
<li><p>Permission for an algorithm to reparenthesize sums is not the
same as a concept constraining the terms in the sum.</p></li>
<li><p>We can and do use existing Standard language, like
<em>GENERALIZED_SUM</em>, for expressing permissions that algorithms
have.</p></li>
</ul>
<p>In the sections that follow, we will describe a different way to
constrain the matrix and vector element types and scalars in our
algorithms. We will start by categorizing the different quality of
implementation (QoI) enhancements that implementers might like to make.
These enhancements call for changing algorithms in different ways. We
will distinguish textbook from non-textbook ways of changing algorithms,
explain that we only permit non-textbook changes for floating-point
types, then develop constraints on types that permit textbook
changes.</p>
<h3 data-number="10.8.5" id="categories-of-qoi-enhancements"><span class="header-section-number">10.8.5</span> Categories of QoI
enhancements<a href="#categories-of-qoi-enhancements" class="self-link"></a></h3>
<p>An important goal of constraining our algorithms is to give
implementers the freedom to make QoI enhancements. We categorize QoI
enhancements in three ways:</p>
<ol type="1">
<li><p>those that depend entirely on the computer architecture;</p></li>
<li><p>those that might have architecture-dependent parameters, but
could otherwise be written in an architecture-independent way;
and</p></li>
<li><p>those that diverge from a textbook description of the algorithm,
and depend on element types having properties more specific than what
that description requires.</p></li>
</ol>
<p>An example of Category (1) would be special hardware instructions
that perform matrix-matrix multiplications on small, fixed-size blocks.
The hardware might only support a few types, such as integers,
fixed-point reals, or floating-point types. Implementations might use
these instructions for the entire algorithm, if the problem sizes and
element types match the instruction’s requirements. They might also use
these instructions to solve subproblems. In either case, these
instructions might reorder sums or create temporary values.</p>
<p>Examples of Category (2) include blocking to increase cache or
translation lookaside buffer (TLB) reuse, or using SIMD instructions
(given the Parallelism TS’ inclusion of SIMD). Many of these
optimizations relate to memory locality or parallelism. For an overview,
see (Goto 2008) or Section 2.6 of (Demmel 1997). All such optimizations
reorder sums and create temporary values.</p>
<p>Examples of Category (3) include Strassen’s algorithm for matrix
multiplication. The textbook formulation of matrix multiplication only
uses additions and multiplies, but Strassen’s algorithm also performs
subtractions. A common feature of Category (3) enhancements is that
their implementation diverges from a “textbook description of the
algorithm” in ways beyond just reordering sums. As a “textbook,” we
recommend either (Strang 2016), or the concise mathematical description
of operations in the BLAS Standard. In the next section, we will list
properties of textbook descriptions, and explain some ways in which QoI
enhancements might fail to adhere to those properties.</p>
<h3 data-number="10.8.6" id="properties-of-textbook-algorithm-descriptions"><span class="header-section-number">10.8.6</span> Properties of textbook
algorithm descriptions<a href="#properties-of-textbook-algorithm-descriptions" class="self-link"></a></h3>
<p>“Textbook descriptions” of the algorithms we propose tend to have the
following properties. For each property, we give an example of a
“non-textbook” algorithm, and how it assumes something extra about the
matrix’s element type.</p>
<ol type="a">
<li><p>They compute floating-point sums straightforwardly (possibly
reordered, or with temporary intermediate values), rather than using any
of several algorithms that improve accuracy (e.g., compensated
summation) or even make the result independent of evaluation order (see
Demmel 2013). All such non-straightforward algorithms depend on
properties of floating-point arithmetic. We will define below what
“possibly reordered, or with temporary intermediate values”
means.</p></li>
<li><p>They use only those arithmetic operations on the matrix and
vector element types that the textbook description of the algorithm
requires, even if using other kinds of arithmetic operations would
improve performance or give an asymptotically faster algorithm.</p></li>
<li><p>They use exact algorithms (not considering rounding error),
rather than approximations (that would not be exact even if computing
with real numbers).</p></li>
<li><p>They do not use parallel algorithms that would give an
asymptotically faster parallelization in the theoretical limit of
infinitely many available parallel processing units, at the cost of
likely unacceptable rounding error in floating-point
arithmetic.</p></li>
</ol>
<p>As an example of (b), the textbook matrix multiplication algorithm
only adds or multiplies the matrices’ elements. In contrast, Strassen’s
algorithm for matrix-matrix multiply subtracts as well as adds and
multiplies the matrices’ elements. Use of subtraction assumes that
arbitrary elements have an additive inverse, but the textbook matrix
multiplication algorithm makes sense even for element types that lack
additive inverses for all elements. Also, use of subtractions changes
floating-point rounding behavior, though that change is understood and
often considered acceptable (see Demmel 2007).</p>
<p>As an example of (c), the textbook substitution algorithm for solving
triangular linear systems is exact. In contrast, one can approximate
triangular solve with a stationary iteration. (See, e.g., Section 5 of
(Chow 2015). That paper concerns the sparse matrix case; we cite it
merely as an example of an approximate algorithm, not as a
recommendation for dense triangular solve.) Approximation only makes
sense for element types that have enough precision for the approximation
to be accurate. If the approximation checks convergence, than the
algorithm also requires less-than comparison of absolute values of
differences.</p>
<p>Multiplication by the reciprocal of a number, rather than division by
that number, could fit into (b) or (c). As an example of (c),
implementations for hardware where floating-point division is slow
compared with multiplication could use an approximate reciprocal
multiplication to implement division.</p>
<p>As an example of (d), the textbook substitution algorithm for solving
triangular linear systems has data dependencies that limit its
theoretical parallelism. In contrast, one can solve a triangular linear
system by building all powers of the matrix in parallel, then solving
the linear system as with a Krylov subspace method. This approach is
exact for real numbers, but commits too much rounding error to be useful
in practice for all but the smallest linear systems. In fact, the
algorithm requires that the matrix’s element type have precision
exponential in the matrix’s dimension.</p>
<p>Many of these non-textbook algorithms rely on properties of
floating-point arithmetic. Strassen’s algorithm makes sense for unsigned
integer types, but it could lead to unwarranted and unexpected overflow
for signed integer types. Thus, we think it best to limit implementers
to textbook algorithms, unless all matrix and vector element types are
floating-point types. We always forbid non-textbook algorithms of type
(d). If all matrix and vector element types are floating-point types, we
permit non-textbook algorithms of Types (a), (b), and (c), under two
conditions:</p>
<ol type="1">
<li><p>they satisfy the complexity requirements; and</p></li>
<li><p>they result in a <em>logarithmically stable</em> algorithm, in
the sense of (Demmel 2007).</p></li>
</ol>
<p>We believe that Condition (2) is a reasonable interpretation of
Section 2.7 of the BLAS Standard. This says that “no particular
computational order is mandated by the function specifications. In other
words, any algorithm that produces results ‘close enough’ to the usual
algorithms presented in a standard book on matrix computations is
acceptable.” Examples of what the BLAS Standard considers “acceptable”
include Strassen’s algorithm, and implementing matrix multiplication as
<code>C = (alpha * A) * B + (beta * C)</code>,
<code>C = alpha * (A * B) + (beta * C)</code>, or
<code>C = A * (alpha * B) + (beta * C)</code>.</p>
<p>“Textbook algorithms” includes optimizations commonly found in BLAS
implementations. This includes any available hardware acceleration, as
well as the locality and parallelism optimizations we describe below.
Thus, we think restricting generic implementations to textbook
algorithms will not overly limit implementers.</p>
<p>Acceptance of P1467 (“Extended floating-point types and standard
names”) into C++23 means that the set of floating-point types has grown.
Before P1467, this set had three members: <code>float</code>,
<code>double</code>, and <code>long double</code>. After P1467, it
includes implementation-specific types, such as short or
extended-precision floats. This change may require implementers to look
carefully at the definition of logarithmically stable before making
certain algorithmic choices, especially for short floats.</p>
<h3 data-number="10.8.7" id="reordering-sums-and-creating-temporaries"><span class="header-section-number">10.8.7</span> Reordering sums and creating
temporaries<a href="#reordering-sums-and-creating-temporaries" class="self-link"></a></h3>
<p>Even textbook descriptions of linear algebra algorithms presume the
freedom to reorder sums and create temporary values. Optimizations for
memory locality and parallelism depend on this. This freedom imposes
requirements on algorithms’ matrix and vector element types.</p>
<p>We could get this freedom either by limiting our proposal to the
Standard’s current arithmetic types, or by forbidding reordering and
temporaries for types other than arithmetic types. However, doing so
would unnecessarily prevent straightforward optimizations for small and
fast types that act just like arithmetic types. This includes so-called
“short floats” such as bfloat16 or binary16, extended-precision
floating-point numbers, and fixed-point reals. Some of these types may
be implementation defined, and others may be user-specified. We intend
to permit implementers to optimize for these types as well. This
motivates us to describe our algorithms’ type requirements in a generic
way.</p>
<h4 data-number="10.8.7.1" id="special-case-only-one-element-type"><span class="header-section-number">10.8.7.1</span> Special case: Only one
element type<a href="#special-case-only-one-element-type" class="self-link"></a></h4>
<p>We find it easier to think about type requirements by starting with
the assumption that all element and scalar types in algorithms are the
same. One can then generalize to input element type(s) that might differ
from the output element type and/or scalar result type.</p>
<p>Optimizations for memory locality and parallelism both create
temporary values, and change the order of sums. For example,
reorganizing matrix data to reduce stride involves making a temporary
copy of a subset of the matrix, and accumulating partial sums into the
temporary copy. Thus, both kinds of optimizations impose a common set of
requirements and assumptions on types. Let <code>value_type</code> be
the output <code>mdspan</code>’s <code>value_type</code>.
Implementations may:</p>
<ol type="1">
<li><p>create arbitrarily many objects of type <code>value_type</code>,
value-initializing them or direct-initializing them with any existing
object of that type;</p></li>
<li><p>perform sums in any order; or</p></li>
<li><p>replace any value with the sum of that value and a
value-initialized <code>value_type</code> object.</p></li>
</ol>
<p>Assumption (1) implies that the output value type is
<code>semiregular</code>. Contrast with
<strong>[algorithms.parallel.exec]</strong>: “Unless otherwise stated,
implementations may make arbitrary copies of elements of type
<code>T</code>, from sequences where
<code>is_trivially_copy_constructible_v&lt;T&gt;</code> and
<code>is_trivially_destructible_v&lt;T&gt;</code> are true.” We omit the
trivially constructible and destructible requirements here and permit
any <code>semiregular</code> type. Linear algebra algorithms assume
mathematical properties that let us impose more specific requirements
than general parallel algorithms. Nevertheless, implementations may want
to enable optimizations that create significant temporary storage only
if the value type is trivially constructible, trivially destructible,
and not too large.</p>
<p>Regarding Assumption (2): The freedom to compute sums in any order is
not necessarily a type constraint. Rather, it’s a right that the
algorithm claims, regardless of whether the type’s addition is
associative or commutative. For example, floating-point sums are not
associative, yet both parallelization and customary linear algebra
optimizations rely on reordering sums. See the above “Value type
constraints do not suffice to describe algorithm behavior” section for a
more detailed explanation.</p>
<p>Regarding Assumption (3), we do not actually say that
value-initialization produces a two-sided additive identity. What
matters is what the algorithm’s implementation may do, not whether the
type actually behaves in this way.</p>
<h4 data-number="10.8.7.2" id="general-case-multiple-input-element-types"><span class="header-section-number">10.8.7.2</span> General case: Multiple
input element types<a href="#general-case-multiple-input-element-types" class="self-link"></a></h4>
<p>An important feature of P1673 is the ability to compute with mixed
matrix or vector element types. For instance,
<code>add(y, scaled(alpha, x), z)</code> implements the operation z = y
+ alpha*x, an elementwise scaled vector sum. The element types of the
vectors x, y, and z could be all different, and could differ from the
type of alpha.</p>
<h5 data-number="10.8.7.2.1" id="accumulate-into-output-value-type"><span class="header-section-number">10.8.7.2.1</span> Accumulate into output
value type<a href="#accumulate-into-output-value-type" class="self-link"></a></h5>
<p>Generic algorithms would use the output <code>mdspan</code>’s
<code>value_type</code> to accumulate partial sums, and for any
temporary results. This is the analog of <code>std::reduce</code>’s
scalar result type <code>T</code>. Implementations for floating-point
types might accumulate into higher-precision temporaries, or use other
ways to increase accuracy when accumulating partial sums, but the output
<code>mdspan</code>’s <code>value_type</code> would still control
accumulation behavior in general.</p>
<h5 data-number="10.8.7.2.2" id="proxy-references-or-expression-templates"><span class="header-section-number">10.8.7.2.2</span> Proxy references or
expression templates<a href="#proxy-references-or-expression-templates" class="self-link"></a></h5>
<ol type="1">
<li><p>Proxy references: The input and/or output <code>mdspan</code>
might have an accessor with a <code>reference</code> type other than
<code>element_type&amp;</code>. For example, the output
<code>mdspan</code> might have a value type <code>value_type</code>, but
its <code>reference</code> type might be
<code>atomic_ref&lt;value_type&gt;</code>.</p></li>
<li><p>Expression templates: The element types themselves might have
arithmetic operations that defer the actual computation until the
expression is assigned. These “expression template” types typically hold
some kind of reference or pointer to their input arguments.</p></li>
</ol>
<p>Neither proxy references nor expression template types are
<code>semiregular</code>, because they behave like references, not like
values. However, we can still require that their underlying value type
be <code>semiregular</code>. For instance, the possiblity of proxy
references just means that we need to use the output
<code>mdspan</code>‘s <code>value_type</code> when constructing or
value-initializing temporary values, rather than trying to deduce the
value type from the type of an expression that indexes into the output
<code>mdspan</code>. Expression templates just mean that we need to use
the output <code>mdspan</code>’s <code>value_type</code> to construct or
value-initialize temporaries, rather than trying to deduce the
temporaries’ type from the right-hand side of the expression.</p>
<p>The <code>z = y + alpha*x</code> example above shows that some of the
algorithms we propose have multiple terms in a sum on the right-hand
side of the expression that defines the algorithm. If algorithms have
permission to rearrange the order of sums, then they need to be able to
break up such expressions into separate terms, even if some of those
expressions are expression templates.</p>
<h3 data-number="10.8.8" id="textbook-algorithm-description-in-semiring-terms"><span class="header-section-number">10.8.8</span> “Textbook” algorithm
description in semiring terms<a href="#textbook-algorithm-description-in-semiring-terms" class="self-link"></a></h3>
<p>As we explain in the “Value type constraints do not suffice to
describe algorithm behavior” section above, we deliberately constrain
matrix and vector element types to require associative addition. This
means that we do not, for instance, define concepts like “ring” or
“group.” We cannot even speak of a single set of values that would
permit defining things like a “ring” or “group.” This is because our
algorithms must handle mixed value types, expression templates, and
proxy references. However, it may still be helpful to use mathematical
language to explain what we mean by “a textbook description of the
algorithm.”</p>
<p>Most of the algorithms we propose only depend on addition and
multiplication. We describe these algorithms as if working on elements
of a <em>semiring</em> with possibly noncommutative multiplication. The
only difference between a semiring and a ring is that a semiring does
not require all elements to have an additive inverse. That is, addition
is allowed, but not subtraction. Implementers may apply any mathematical
transformation to the expressions that would give the same result for
any semiring.</p>
<h4 data-number="10.8.8.1" id="why-a-semiring"><span class="header-section-number">10.8.8.1</span> Why a semiring?<a href="#why-a-semiring" class="self-link"></a></h4>
<p>We use a semiring because</p>
<ol type="1">
<li><p>we generally want to reorder terms in sums, but we do not want to
order terms in products; and</p></li>
<li><p>we do not want to assume that subtraction works.</p></li>
</ol>
<p>The first is because linear algebra computations are useful for
matrix or vector element types with noncommutative multiplication, such
as quaternions or matrices. The second is because algebra operations
might be useful for signed integers, where a formulation using
subtraction risks unexpected undefined behavior.</p>
<h4 data-number="10.8.8.2" id="semirings-and-testing"><span class="header-section-number">10.8.8.2</span> Semirings and testing<a href="#semirings-and-testing" class="self-link"></a></h4>
<p>It’s important that implementers be able to test our proposed
algorithms for custom element types, not just the built-in arithmetic
types. We don’t want to require hypothetical “exact real arithmetic”
types that take particular expertise to implement. Instead, we propose
testing with simple classes built out of unsigned integers. This section
is not part of our Standard Library proposal, but we include it to give
guidance to implementers and to show that it’s feasible to test our
proposal.</p>
<h4 data-number="10.8.8.3" id="commutative-multiplication"><span class="header-section-number">10.8.8.3</span> Commutative
multiplication<a href="#commutative-multiplication" class="self-link"></a></h4>
<p>C++ unsigned integers implement commutative rings. (Rings always have
commutative addition; a “commutative ring” has commutative
multiplication as well.) We may transform (say) <code>uint32_t</code>
into a commutative semiring by wrapping it in a class that does not
provide unary or binary <code>operator-</code>. Adding a “tag” template
parameter to this class would let implementers build tests for mixed
element types.</p>
<h4 data-number="10.8.8.4" id="noncommutative-multiplication"><span class="header-section-number">10.8.8.4</span> Noncommutative
multiplication<a href="#noncommutative-multiplication" class="self-link"></a></h4>
<p>The semiring of 2x2 matrices with element type a commutative semiring
is itself a semiring, but with noncommutative multiplication. This is a
good way to build a noncommutative semiring for testing.</p>
<h3 data-number="10.8.9" id="summary-2"><span class="header-section-number">10.8.9</span> Summary<a href="#summary-2" class="self-link"></a></h3>
<ul>
<li><p>Constraining the matrix and vector element types and scalar types
in our functions gives implementers the freedom to make QoI enhancements
without risking correctness.</p></li>
<li><p>We think describing algorithms’ behavior and implementation
freedom is more useful than mathematical concepts like “ring.” For
example, we permit implementations to reorder sums, but this does not
mean that they assume sums are associative. This is why we do not define
a hierarchy of number concepts.</p></li>
<li><p>We categorize different ways that implementers might like to
change algorithms, list categories we exclude and categories we permit,
and use the permitted categories to derive constraints on the types of
matrix and vector elements and scalar results.</p></li>
<li><p>We explain how a semiring is a good way to talk about
implementation freedom, even though we do not think it is a good way to
constrain types. We then use the semiring description to explain how
implementers can test generic algorithms.</p></li>
</ul>
<h2 data-number="10.9" id="fix-issues-with-complex-and-support-user-defined-complex-number-types"><span class="header-section-number">10.9</span> Fix issues with
<code>complex</code>, and support user-defined complex number types<a href="#fix-issues-with-complex-and-support-user-defined-complex-number-types" class="self-link"></a></h2>
<h3 data-number="10.9.1" id="motivation-and-summary-of-solution"><span class="header-section-number">10.9.1</span> Motivation and summary of
solution<a href="#motivation-and-summary-of-solution" class="self-link"></a></h3>
<p>The BLAS provides functionality specifically for vectors and matrices
of complex numbers. Built into the BLAS is the assumption that the
complex conjugate of a real number is just the number. This makes it
possible to write algorithms that are generic on whether the vector or
matrix value type is real or complex. For example, such generic
algorithms can use the “conjugate transpose” for both cases. P1673 users
may thus want to apply <code>conjugate_transposed</code> to matrices of
arbitrary value types.</p>
<p>The BLAS also needs to distinguish between complex and real value
types, because some BLAS functions behave differently for each. For
example, for real numbers, the BLAS functions <code>SASUM</code> and
<code>DASUM</code> compute the sum of absolute values of the vector’s
elements. For complex numbers, the corresponding BLAS functions
<code>SCASUM</code> and <code>DZASUM</code> compute the sum of absolute
values of the real and imaginary components, rather than the sum of
magnitudes. This is an optimization to avoid square roots (as Appendix
A.1 of the BLAS Standard explains), but it is well founded in the theory
of accuracy of matrix factorizations.</p>
<p>The C++ Standard’s functions <code>conj</code>, <code>real</code>,
and <code>imag</code> return the complex conjugate, real part, and
imaginary part of a complex number, respectively. They also have
overloads for arithmetic types that give the expected mathematical
behavior: the conjugate or real part of a real number is the number
itself, and the imaginary part of a real number is zero. Thus, it would
make sense for P1673 to use these functions to express generic
algorithms with complex or real numbers. However, these functions have
three issues that preclude their direct use in P1673’s algorithms.</p>
<ol type="1">
<li><p>The existing overloads of these functions in the <code>std</code>
namespace do not always preserve the type of their argument. For
arguments of arithmetic type, <code>conj</code> returns
<code>complex</code>. For arguments of integral type, <code>real</code>
and <code>imag</code> always return <code>double</code>. The resulting
value type change is mathematically unexpected in generic algorithms,
can cause information loss for 64-bit integers, and can hinder use of an
optimized BLAS.</p></li>
<li><p>Users sometimes need to define their own “custom” complex number
types instead of using specializations of <code>complex</code>, but
users cannot overload functions in the <code>std</code> namespace for
these types.</p></li>
<li><p>How does P1673 tell if a user-defined type represents a complex
number?</p></li>
</ol>
<p>Libraries such as Kokkos address Issue (2) by defining
<code>conj</code>, <code>real</code>, and <code>imag</code> functions in
the library’s namespace (not <code>std</code>). Generic code then can
rely on argument-dependent lookup (ADL) by invoking these functions
without namespace qualification. The library’s functions help make the
custom complex type “interface-compatible” with
<code>std::complex</code>. This ADL solution long predates any more
elaborate customization point technique. In our experience, many
mathematical libraries use this approach.</p>
<p>This common practice suggests a way for P1673 to solve the other
issues as well. A user-defined type represents a complex number if and
only if it has ADL-findable <code>conj</code>, <code>real</code>, and
<code>imag</code> functions. This means that P1673 can “wrap” these
functions to make them behave as mathematically expected for any value
type. These “wrappers” can also adjust the behavior of
<code>std::conj</code>, <code>std::real</code>, and
<code>std::imag</code> for arithmetic types.</p>
<p>P1673 defines these wrappers as the exposition-only functions
<em><code>conj-if-needed</code></em>,
<em><code>real-if-needed</code></em>, and
<em><code>imag-if-needed</code></em>.</p>
<h3 data-number="10.9.2" id="why-users-define-their-own-complex-number-types"><span class="header-section-number">10.9.2</span> Why users define their own
complex number types<a href="#why-users-define-their-own-complex-number-types" class="self-link"></a></h3>
<p>Users define their own complex number types for three reasons.</p>
<ol type="1">
<li><p>The Standard only permits <code>complex&lt;R&gt;</code> if
<code>R</code> is a floating-point type.</p></li>
<li><p><code>complex&lt;R&gt;</code> only has <code>sizeof(R)</code>
alignment, not <code>2 * sizeof(R)</code>.</p></li>
<li><p>Some C++ extensions cannot use <code>complex&lt;R&gt;</code>,
because they require annotations on a type’s member functions.</p></li>
</ol>
<p>First, the C++ Standard currently permits
<code>complex&lt;R&gt;</code> only if <code>R</code> is a floating-point
type. Before adoption of P1467 into C++23, this meant that
<code>R</code> could only be <code>float</code>, <code>double</code>, or
<code>long double</code>. Even after adoption of P1467, implementations
are not required to provide other floating-point types. This prevents
use of other types in portable C++, such as</p>
<ul>
<li><p>“short” low-precision floating-point or fixed-point number types
that are critical for performance of machine learning and signal
processing applications;</p></li>
<li><p>signed integers (the resulting complex numbers represent the
<em>Gaussian integers</em>);</p></li>
<li><p>extended-precision floating-point types that can improve the
accuracy of floating-point sums, reduce parallel nondeterminism, and
make sums less dependent on evaluation order; and</p></li>
<li><p>custom number types such as “bigfloats” (arbitrary-precision
floating-point types) or fractions of integers.</p></li>
</ul>
<p>Second, the Standard explicitly specifies that
<code>complex&lt;R&gt;</code> has the same alignment as
<code>R[2]</code>. That is, it is aligned to <code>sizeof(R)</code>.
Some systems would give better parallel or vectorized performance if
complex numbers were aligned to <code>2 * sizeof(R)</code>. Some C++
extensions define their own complex number types partly for this reason.
Software libraries that use these custom complex number types tempt
users to alias between <code>complex&lt;R&gt;</code> and these custom
types, which would have the same bit representation except for
alignment. This has led to crashes or worse in software projects that
the authors have worked on. Third, some C++ extensions cannot use
<code>complex</code>, because they require types’ member functions to
have special annotations, in order to compile code to make use of
accelerator hardware.</p>
<p>These issues have led several software libraries and C++ extensions
to define their own complex number types. These include CUDA, Kokkos,
and Thrust. The SYCL standard is contemplating adding a custom complex
number type. One of the authors wrote <code>Kokkos::complex</code> circa
2014 to make it possible to build and run Trilinos’ linear solvers with
such C++ extensions.</p>
<h3 data-number="10.9.3" id="why-users-want-to-conjugate-matrices-of-real-numbers"><span class="header-section-number">10.9.3</span> Why users want to
“conjugate” matrices of real numbers<a href="#why-users-want-to-conjugate-matrices-of-real-numbers" class="self-link"></a></h3>
<p>It’s possible to describe many linear algebra algorithms in a way
that works for both complex and real numbers, by treating conjugation as
the identity for real numbers. This makes the “conjugate transpose” just
the transpose for a matrix of real numbers. Matlab takes this approach,
by defining the single quote operator to take the conjugate transpose if
its argument is complex, and the transpose if its argument is real. The
Fortran BLAS also supports this, by letting users specify the
<code>'Conjugate Transpose'</code> (<code>TRANSA='C'</code>) even for
real routines like <code>DGEMM</code> (double-precision general
matrix-matrix multiply). Krylov subspace methods in Trilinos’ Anasazi
and Belos packages also follow a Matlab-like generic approach.</p>
<p>Even though we think it should be possible to write “generic” (real
or complex) linear algebra code using <code>conjugate_transposed</code>,
we still need to distinguish between symmetric and Hermitian matrix
algorithms. This is because symmetric does <em>not</em> mean the same
thing as Hermitian for matrices of complex numbers. For example, a
matrix whose off-diagonal elements are all <code>3 + 4i</code> is
symmetric, but not Hermitian. Complex symmetric matrices are useful in
practice, for example when modeling damped vibrations (Craven 1969).</p>
<h3 data-number="10.9.4" id="effects-of-conjs-real-to-complex-change"><span class="header-section-number">10.9.4</span> Effects of
<code>conj</code>’s real-to-complex change<a href="#effects-of-conjs-real-to-complex-change" class="self-link"></a></h3>
<p>The fact that <code>conj</code> for arithmetic-type arguments returns
<code>complex</code> may complicate or prevent implementers from using
an existing optimized BLAS library. If the user calls
<code>matrix_product</code> with matrices all of value type
<code>double</code>, use of the (mathematically harmless)
<code>conjugate_transposed</code> function would make one matrix have
value type <code>complex&lt;double&gt;</code>. Implementations could
undo this value type change for known layouts and accessors, but would
need to revert to generic code otherwise.</p>
<p>For example, suppose that a custom real value type
<code>MyReal</code> has arithmetic operators defined to permit all
needed mixed-type expressions with <code>double</code>, where
<code>double</code> times <code>MyReal</code> and <code>MyReal</code>
times <code>double</code> both “promote” to <code>MyReal</code>. Users
may then call <code>matrix_product(A, B, C)</code> with <code>A</code>
having value type <code>double</code>, <code>B</code> having value type
<code>MyReal</code>, and <code>C</code> having a value type
<code>MyReal</code>. However,
<code>matrix_product(conjugate_transposed(A), B, C)</code> would not
compile, due to
<code>complex&lt;decltype(declval&lt;double&gt;() * declval&lt;MyReal&gt;())&gt;</code>
not being well formed.</p>
<h3 data-number="10.9.5" id="lewg-feedback-on-r8-solution"><span class="header-section-number">10.9.5</span> LEWG feedback on R8
solution<a href="#lewg-feedback-on-r8-solution" class="self-link"></a></h3>
<p>In R8 of this paper, we proposed an exposition-only function
<em><code>conj-if-needed</code></em>. For arithmetic types, it would be
the identity function. This would fix Issue (1). For all other types, it
would call <code>conj</code> through argument-dependent lookup (ADL),
just like how <code>iter_swap</code> calls <code>swap</code>. This would
fix Issue (2). However, it would force users who define custom
<em>real</em> number types to define a trivial <code>conj</code> (in
their own namespace) for their type. The alternative would be to make
<em><code>conj-if-needed</code></em> the identity if it could not find
<code>conj</code> via ADL lookup. However, that would cause silently
incorrect results for users who define a custom complex number type, but
forget or misspell <code>conj</code>.</p>
<p>When reviewing R8, LEWG expressed a preference for a different
solution.</p>
<ol type="1">
<li><p>Temporarily change P1673 to permit use of <code>conjugated</code>
and <code>conjugate_transposed</code> only for value types that are
either <code>complex</code> or arithmetic types. Add a Note that reminds
readers to look out for Steps (2) and (3) below.</p></li>
<li><p>Write a separate paper which introduces a user-visible
customization point, provisionally named <code>conjugate</code>. The
paper could use any of various proposed library-only customization point
mechanisms, such as the customization point objects used by ranges or
<code>tag_invoke</code> (see
<a href="https://wg21.link/p1895r0">P1895R0</a>, with the expectation
that LEWG and perhaps also EWG (see e.g.,
<a href="https://wg21.link/P2547">P2547</a>) may express a preference
for a different mechanism.</p></li>
<li><p>If LEWG accepts the <code>conjugate</code> customization point,
then change P1673 again to use <code>conjugate</code> (thus replacing
R8’s <em><code>conj-if-needed</code></em>). This would thus reintroduce
support for custom complex numbers.</p></li>
</ol>
<h3 data-number="10.9.6" id="sg6s-response-to-lewgs-r8-feedback"><span class="header-section-number">10.9.6</span> SG6’s response to LEWG’s R8
feedback<a href="#sg6s-response-to-lewgs-r8-feedback" class="self-link"></a></h3>
<p>SG6 small group (there was no quorum) reviewed P1673 on 2022/06/09,
after LEWG’s R8 review on 2022/05/24. SG6 small group expressed the
following:</p>
<ul>
<li><p>Being able to write <code>conjugated(A)</code> or
<code>conjugate_transposed(A)</code> for a matrix or vector
<code>A</code> of user-defined types is reasonably integral to the
proposal. We generically oppose deferring it based on the hope that
we’ll be able to specify it in a nicer way in the future, with some new
customization point syntax.</p></li>
<li><p>A simple, teachable rule: Do ADL-ONLY lookup (preventing finding
<code>std::conj</code> for primitive types) for <code>conj</code> (as
with ranges); if you find something you use it, and if you don’t, you do
nothing (conjugation is the identity). (“Primitives aren’t that
special.”) Benefit is that custom real types work out of the
box.</p></li>
<li><p>The alternative: specify that if users choose to use
<code>conjugated</code> or <code>conjugate_transposed</code> with a
user-defined type, then they MUST supply the <code>conj</code>
ADL-findable thing, else ill-formed. This is a safety mechanism that may
not have been considered previously by LEWG. (Make primitives special,
to regain safety. The cost is that custom real types need to have a
<code>conj</code> ADL-findable, if users use <code>conjugated</code> or
<code>conjugate_transposed</code>.)</p></li>
</ul>
<h3 data-number="10.9.7" id="current-solution"><span class="header-section-number">10.9.7</span> Current solution<a href="#current-solution" class="self-link"></a></h3>
<p>We have adopted SG6 small group’s recommendation, with a slight
wording modification to make it obvious that the conjugate of an
arithmetic type returns the same type as its input.</p>
<p>We propose an exposition-only function object
<em><code>conj-if-needed</code></em>. For arithmetic types, it behaves
as the identity function. If it can call <code>conj</code> through
ADL-only (unqualified) lookup, it does so. Otherwise, it again behaves
as the identity function.</p>
<p>We take the same approach to fix the issues discussed above with
<code>real</code> and <code>imag</code>. That is, we define
exposition-only functions <em><code>real-if-needed</code></em> and
<em><code>imag-if-needed</code></em>. These assume that any
non-arithmetic type without ADL-findable <code>real</code> resp.
<code>imag</code> is a non-complex type.</p>
<p>This approach has the following advantages.</p>
<ol type="1">
<li><p>Most custom number types, noncomplex or complex, will work “out
of the box.” Existing custom complex number types likely already have
ADL-findable <code>conj</code>, <code>real</code>, and
<code>imag</code>. If they do not, then users can define them.</p></li>
<li><p>It ensures type preservation for arithmetic types.</p></li>
<li><p>It uses existing C++ idioms and interfaces for complex
numbers.</p></li>
<li><p>It does not depend on a future customization point syntax or
library convention.</p></li>
</ol>
<h2 data-number="10.10" id="support-for-division-with-noncommutative-multiplication"><span class="header-section-number">10.10</span> Support for division with
noncommutative multiplication<a href="#support-for-division-with-noncommutative-multiplication" class="self-link"></a></h2>
<p>An important feature of this proposal is its support for value types
that have noncommutative multiplication. Examples include square
matrices with a fixed number of rows and columns, and quaternions and
their generalizations. Most of the algorithms in this proposal only add
or multiply arbitrary value types, so preserving the order of
multiplication arguments is straightforward. The various triangular
solve algorithms are an exception, because they need to perform
divisions as well.</p>
<p>If multiplication commutes and if a type has division, then the
division x ÷ y is just x times (the multiplicative inverse of y),
assuming that the multiplicative inverse of y exists. However, if
multiplication does not commute, “x times (the multiplicative inverse of
y)” need not equal “(the multiplicative inverse of y) times x.” The C++
binary <code>operator/</code> does not give callers a way to distinguish
between these two cases.</p>
<p>This suggests four ways to express “ordered division.”</p>
<ol type="1">
<li><p>Explicitly divide one by the quotient: <code>x * (1/y)</code>, or
<code>(1/y) * x</code></p></li>
<li><p>Like (2), but instead of using literal <code>1</code>, get “one”
as a <code>value_type</code> input to the algorithm:
<code>x * (one/y)</code>, or <code>(one/y) * x</code></p></li>
<li><p><code>inverse</code> as a unary callable input to the algorithm:
<code>x * inverse(y)</code>, or <code>inverse(y) * x</code></p></li>
<li><p><code>divide</code> as a binary callable input to the algorithm:
<code>divide(x, y)</code>, or <code>divide(y, x)</code></p></li>
</ol>
<p>Both SG6 small group (in its review of this proposal on 2022/06/09)
and the authors prefer Way (4), the <code>divide</code> binary callable
input. The binary callable would be optional, and ordinary binary
<code>operator/</code> would be used as the default. This would imitate
existing Standard Library algorithms like <code>reduce</code>, with its
optional <code>BinaryOp</code> that defaults to addition. For
mixed-precision computation, <code>std::divides&lt;void&gt;{}</code> or
the equivalent
<code>[](const auto&amp; x, const auto&amp; y) { return x / y; }</code>
should work just fine. Users should avoid specifying <code>T</code>
other than <code>void</code> in <code>std::divides&lt;T&gt;</code> for
mixed-precision computation, as <code>std::divides&lt;T&gt;</code> would
coerce both its arguments to <code>T</code> and then force the division
result to be <code>T</code> as well. Way (4) also preserves the original
rounding behavior for types with commutative multiplication.</p>
<p>The main disadvantage of the other approaches is that they would
change rounding behavior for floating-point types. They also require two
operations – computing an inverse, and multiplication – rather than one.
“Ordered division” may actually be the operation users want, and the
“inverse” might be just a byproduct. This is the case for square
matrices, where users often “compute an inverse” only because they want
to solve a linear system. Each of the other approaches has its own other
disadvantages.</p>
<ul>
<li><p>Way (1) would assume that an overloaded
<code>operator/(int, value_type)</code> exists, and that the literal
<code>1</code> behaves like a multiplicative identity. In practice, not
all custom number types may have defined mixed arithmetic with
<code>int</code>.</p></li>
<li><p>Way (2) would complicate the interface. Users might make the
mistake of passing in literal <code>1</code> (of type <code>int</code>)
or <code>1.0</code> (of type <code>double</code>) as the value of one,
thus leading to Way (1)’s issues.</p></li>
<li><p>Way (3) would again complicate the interface. Users would be
tempted to use <code>[](const auto&amp; y) { return 1 / y; }</code> as
the inverse function, thus leading back to Way (1)’s issues.</p></li>
</ul>
<h2 data-number="10.11" id="packed-layouts-triangle-must-match-functions-triangle"><span class="header-section-number">10.11</span> Packed layout’s Triangle must
match function’s Triangle<a href="#packed-layouts-triangle-must-match-functions-triangle" class="self-link"></a></h2>
<h3 data-number="10.11.1" id="summary-3"><span class="header-section-number">10.11.1</span> Summary<a href="#summary-3" class="self-link"></a></h3>
<ul>
<li><p>P1673 <code>symmetric_*</code>, <code>hermitian_*</code>, and
<code>triangular_*</code> functions always take <code>Triangle</code>
(and <code>DiagonalStorage</code>, if applicable) parameters so that the
functions always have the same signature, regardless of
<code>mdspan</code> layout.</p></li>
<li><p>For symmetric or Hermitian algorithms, mismatching the mdspan
layout’s Triangle and the function’s Triangle would have no
effect.</p></li>
<li><p>For triangular algorithms, mismatch would have an effect that
users likely would not want. (It means “use the other triangle,” which
is zero.) Thus, it’s reasonable to make mismatch an error.</p></li>
<li><p>In practice, users aren’t likely to encounter a triangular packed
matrix in isolation. Such matrices usually occur in context of symmetric
or Hermitian packed matrices. A common user error might thus be
mismatching the Triangles for both symmetric or Hermitian functions, and
triangular functions. The first is harmless; the second is likely an
error.</p></li>
<li><p>Therefore, we recommend</p>
<ol type="1">
<li><p>retaining the <code>Triangle</code> (and
<code>DiagonalStorage</code>, if applicable) parameters;</p></li>
<li><p>making it a Mandate that the layout’s <code>Triangle</code> match
the function’s <code>Triangle</code> parameter, for <em>all</em> the
functions (not just the <code>triangular_*</code> ones).</p></li>
</ol></li>
</ul>
<h3 data-number="10.11.2" id="when-do-packed-formats-show-up-in-practice"><span class="header-section-number">10.11.2</span> When do packed formats show
up in practice?<a href="#when-do-packed-formats-show-up-in-practice" class="self-link"></a></h3>
<p>Users aren’t likely to encounter a triangular packed matrix in
isolation. It generally comes as an in-place transformation (e.g.,
factorization) of a symmetric or Hermitian packed matrix. For example,
LAPACK’s <code>DSPTRF</code> (Double-precision Symmetric Packed
TRiangular Factorization) computes a symmetric <span class="math inline"><em>L</em><em>D</em><em>L</em><sup><em>T</em></sup></span>
(or <span class="math inline"><em>U</em><em>D</em><em>U</em><sup><em>T</em></sup></span>)
factorization in place, overwriting the input symmetric packed matrix
<span class="math inline"><em>A</em></span>. LAPACK’s
<code>DSPTRS</code> (Double-precision Symmetric Packed TRiangular Solve)
then uses the result of <code>DSPTRF</code> to solve a linear system.
<code>DSPTRF</code> overwrites <span class="math inline"><em>A</em></span> with the triangle <span class="math inline"><em>L</em></span> (if <span class="math inline"><em>A</em></span> uses lower triangle storage, or
<span class="math inline"><em>U</em></span>, if <span class="math inline"><em>A</em></span> uses upper triangle storage). This
is an idiom for which the BLAS was designed: factorizations typically
overwrite their input, and thus reinterpret the input’s “data structure”
on the fly.</p>
<h3 data-number="10.11.3" id="what-the-blas-does"><span class="header-section-number">10.11.3</span> What the BLAS does<a href="#what-the-blas-does" class="self-link"></a></h3>
<p>For a summary of the BLAS’ packed storage formats, please refer to
the <a href="https://www.netlib.org/lapack/lug/node123.html">“Packed
Storage”</a> section of the <em>LAPACK Users’ Guide</em>, Third Edition
(1999).</p>
<p>BLAS routines for packed storage have only a single argument,
<code>UPLO</code>. This describes both whether the caller is storing the
upper or lower triangle, and the triangle of the matrix on which the
routine will operate. (Packed BLAS formats always store the diagonal
explicitly; they don’t have the analog of <code>DiagonalStorage</code>.)
An example of a BLAS triangular packed routine is <code>DTPMV</code>,
Double-precision (D) Triangular Packed (TP) Matrix-Vector (MV)
product.</p>
<p>BLAS packed formats don’t represent metadata explicitly; the caller
is responsible for knowing whether they are storing the upper or lower
triangle. Getting the <code>UPLO</code> argument wrong makes the matrix
wrong. For example, suppose that the matrix is 4 x 4, and the user’s
array input for the matrix is [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]. If the
user is storing the upper triangle (in column-major order, as the
Fortran BLAS requires), then the matrix looks like this.</p>
<table>
<tbody><tr>
<td>
1
</td>
<td>
2
</td>
<td>
4
</td>
<td>
7
</td>
</tr>
<tr>
<td>
</td>
<td>
3
</td>
<td>
5
</td>
<td>
8
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
6
</td>
<td>
9
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
10
</td>
</tr>
</tbody></table>
<p>Mismatching the <code>UPLO</code> argument (by passing in
<code>'Lower triangle'</code> instead of <code>'Upper triangle'</code>)
would result in an entirely wrong matrix – not even the transpose. Note
how the diagonal elements differ, for instance.</p>
<table>
<tbody><tr>
<td>
1
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
2
</td>
<td>
5
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
3
</td>
<td>
6
</td>
<td>
8
</td>
<td>
</td>
</tr>
<tr>
<td>
4
</td>
<td>
7
</td>
<td>
9
</td>
<td>
10
</td>
</tr>
</tbody></table>
<p>This would be incorrect for triangular, symmetric, or Hermitian
matrices.</p>
<h3 data-number="10.11.4" id="p1673s-interpretation-of-the-blas"><span class="header-section-number">10.11.4</span> P1673’s interpretation of
the BLAS<a href="#p1673s-interpretation-of-the-blas" class="self-link"></a></h3>
<p>P1673 offers packed formats that encode the <code>Triangle</code>.
This means that the <code>mdspan</code> alone conveys the data
structure. P1673 retains the function’s separate <code>Triangle</code>
parameter so that the function’s signature doesn’t change based on the
<code>mdspan</code>’s layout. P1673 requires that the function’s
Triangle match the mdspan’s Triangle.</p>
<p>If P1673 were to permit mismatching the two Triangles, how would the
function reasonably interpret the user’s intent? For triangular matrices
with explicit diagonal, mismatch would mean multiplying by or solving
with a zero triangle matrix. For triangular matrices with implicit unit
diagonal, mismatch would mean multiplying by or solving with a diagonal
matrix of ones – that is, the identity matrix. Users wouldn’t want to do
either one of those.</p>
<p>For symmetric matrices, mismatch has no effect; the
<code>mdspan</code> layout’s <code>Triangle</code> rules. For example,
the lower triangle of an upper triangle storage format is just the upper
triangle again. For Hermitian matrices, again, mismatch has no effect.
For example, suppose that the following is the lower triangle
representation of a complex-valued Hermitian matrix (where <span class="math inline"><em>i</em></span> is the imaginary unit).</p>
<table>
<tbody><tr>
<td>
<span class="math inline">1 + 1<em>i</em></span>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
<span class="math inline">2 + 2<em>i</em></span>
</td>
<td>
<span class="math inline">4 + 4<em>i</em></span>
</td>
<td>
</td>
</tr>
<tr>
<td>
<span class="math inline">3 + 3<em>i</em></span>
</td>
<td>
<span class="math inline">5 + 5<em>i</em></span>
</td>
<td>
<span class="math inline">6 + 6<em>i</em></span>
</td>
</tr>
</tbody></table>
<p>If the user asks the function to operate on the upper triangle of
this matrix, that would imply the following.</p>
<table>
<tbody><tr>
<td>
<span class="math inline">1 + 1<em>i</em></span>
</td>
<td>
<span class="math inline">2 − 2<em>i</em></span>
</td>
<td>
<span class="math inline">3 − 3<em>i</em></span>
</td>
</tr>
<tr>
<td>
</td>
<td>
<span class="math inline">4 + 4<em>i</em></span>
</td>
<td>
<span class="math inline">5 − 5<em>i</em></span>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
<span class="math inline">6 + 6<em>i</em></span>
</td>
</tr>
</tbody></table>
<p>(Note that the imaginary parts now have negative sign. The matrix is
Hermitian, so <code>A[j,i]</code> equals <code>conj(A[i,j])</code>.)
That’s just the “other triangle” of the matrix. These are Hermitian
algorithms, so they will interpret the “other triangle of the other
triangle” in a way that restores the original matrix. Even though the
user never stores the original matrix, it would look like this
mathematically.</p>
<table>
<tbody><tr>
<td>
<span class="math inline">1 + 1<em>i</em></span>
</td>
<td>
<span class="math inline">2 − 2<em>i</em></span>
</td>
<td>
<span class="math inline">3 − 3<em>i</em></span>
</td>
</tr>
<tr>
<td>
<span class="math inline">2 + 2<em>i</em></span>
</td>
<td>
<span class="math inline">4 + 4<em>i</em></span>
</td>
<td>
<span class="math inline">5 − 5<em>i</em></span>
</td>
</tr>
<tr>
<td>
<span class="math inline">3 + 3<em>i</em></span>
</td>
<td>
<span class="math inline">5 + 5<em>i</em></span>
</td>
<td>
<span class="math inline">6 + 6<em>i</em></span>
</td>
</tr>
</tbody></table>
<h1 data-number="11" id="future-work"><span class="header-section-number">11</span> Future work<a href="#future-work" class="self-link"></a></h1>
<h2 data-number="11.1" id="batched-linear-algebra"><span class="header-section-number">11.1</span> Batched linear algebra<a href="#batched-linear-algebra" class="self-link"></a></h2>
<p>We have submitted a separate proposal,
<a href="https://wg21.link/p2901">P2901</a>, that adds “batched”
versions of linear algebra functions to this proposal. “Batched” linear
algebra functions solve many independent problems all at once, in a
single function call. For discussion, please see also Section 6.2 of our
background paper <a href="https://wg21.link/p1417r0">P1417R0</a>.
Batched interfaces have the following advantages.</p>
<ul>
<li><p>They expose more parallelism and vectorization opportunities for
many small linear algebra operations.</p></li>
<li><p>They are useful for many different fields, including machine
learning.</p></li>
<li><p>Hardware vendors currently offer both hardware features and
optimized software libraries to support batched linear algebra.</p></li>
<li><p>There is an ongoing <a href="http://icl.utk.edu/bblas/">interface
standardization effort</a>, in which we participate.</p></li>
</ul>
<p>The <code>mdspan</code> data structure makes it easy to represent a
batch of linear algebra objects, and to optimize their data layout.</p>
<p>With few exceptions, the extension of this proposal to support
batched operations will not require new functions or interface changes.
Only the requirements on functions will change. Output arguments can
have an additional rank; if so, then the leftmost extent will refer to
the batch dimension. Input arguments may also have an additional rank to
match; if they do not, the function will use (“broadcast”) the same
input argument for all the output arguments in the batch.</p>
<h1 data-number="12" id="data-structures-and-utilities-borrowed-from-other-proposals"><span class="header-section-number">12</span> Data structures and utilities
borrowed from other proposals<a href="#data-structures-and-utilities-borrowed-from-other-proposals" class="self-link"></a></h1>
<h2 data-number="12.1" id="mdspan"><span class="header-section-number">12.1</span> <code>mdspan</code><a href="#mdspan" class="self-link"></a></h2>
<p>This proposal depends on <code>mdspan</code>, a feature proposed by
P0009 and follow-on papers, and voted into C++23. The
<code>mdspan</code> class template views the elements of a
multidimensional array. The rank (number of dimensions) is fixed at
compile time. Users may specify some dimensions at run time and others
at compile time; the type of the <code>mdspan</code> expresses this.
<code>mdspan</code> also has two customization points:</p>
<ul>
<li><p><code>Layout</code> expresses the array’s memory layout: e.g.,
row-major (C++ style), column-major (Fortran style), or strided. We use
a custom <code>Layout</code> later in this paper to implement a
“transpose view” of an existing <code>mdspan</code>.</p></li>
<li><p><code>Accessor</code> defines the storage handle
(<code>data_handle_type</code>) stored in the <code>mdspan</code>, as
well as the reference type returned by its access operator. This is an
extension point for modifying how access happens, for example by using
<code>atomic_ref</code> to get atomic access to every element. We use
custom <code>Accessor</code>s later in this paper to implement “scaled
views” and “conjugated views” of an existing
<code>mdspan</code>.</p></li>
</ul>
<h2 data-number="12.2" id="new-mdspan-layouts-in-this-proposal"><span class="header-section-number">12.2</span> New <code>mdspan</code>
layouts in this proposal<a href="#new-mdspan-layouts-in-this-proposal" class="self-link"></a></h2>
<p>Our proposal uses the layout mapping policy of <code>mdspan</code> in
order to represent different matrix and vector data layouts. The current
C++ Standard draft includes three layouts: <code>layout_left</code>,
<code>layout_right</code>, and <code>layout_stride</code>.
<a href="https://wg21.link/p2642">P2642</a> proposes two more:
<code>layout_left_padded</code> and <code>layout_right_padded</code>.
These two layouts represent exactly the data layout assumed by the
General (GE) matrix type in the BLAS’ C and Fortran bindings. They have
has two advantages.</p>
<ol type="1">
<li><p>Unlike <code>layout_left</code> and <code>layout_right</code>,
any “submatrix” (subspan of consecutive rows and consecutive columns) of
a matrix with <code>layout_left_padded</code> resp.
<code>layout_right_padded</code> layout also has
<code>layout_left_padded</code> resp. <code>layout_right_padded</code>
layout.</p></li>
<li><p>Unlike <code>layout_stride</code>, the two layouts always have
compile-time unit stride in one of the matrix’s two extents.</p></li>
</ol>
<p>BLAS functions call the possibly nonunit stride of the matrix the
“leading dimension” of that matrix. For example, a BLAS function
argument corresponding to the leading dimension of the matrix
<code>A</code> is called <code>LDA</code>, for “leading dimension of the
matrix A.”</p>
<p>This proposal introduces a new layout,
<code>layout_blas_packed</code>. This describes the layout used by the
BLAS’ Symmetric Packed (SP), Hermitian Packed (HP), and Triangular
Packed (TP) “types.” The <code>layout_blas_packed</code> class has a
“tag” template parameter that controls its properties; see below.</p>
<p>We do not include layouts for unpacked “types,” such as Symmetric
(SY), Hermitian (HE), and Triangular (TR). Our paper
<a href="https://wg21.link/p1674">P1674</a>. explains our reasoning. In
summary: Their actual layout – the arrangement of matrix elements in
memory – is the same as General. The only differences are constraints on
what entries of the matrix algorithms may access, and assumptions about
the matrix’s mathematical properties. Trying to express those
constraints or assumptions as “layouts” or “accessors” violates the
spirit (and sometimes the law) of <code>mdspan</code>. We address these
different matrix types with different function names.</p>
<p>The packed matrix “types” do describe actual arrangements of matrix
elements in memory that are not the same as in General. This is why we
provide <code>layout_blas_packed</code>. Note that
<code>layout_blas_packed</code> is the first addition to the existing
layouts that is neither always unique, nor always strided.</p>
<p>Algorithms cannot be written generically if they permit output
arguments with nonunique layouts. Nonunique output arguments require
specialization of the algorithm to the layout, since there’s no way to
know generically at compile time what indices map to the same matrix
element. Thus, we will impose the following rule: Any
<code>mdspan</code> output argument to our functions must always have
unique layout (<code>is_always_unique()</code> is <code>true</code>),
unless otherwise specified.</p>
<p>Some of our functions explicitly require outputs with specific
nonunique layouts. This includes low-rank updates to symmetric or
Hermitian matrices.</p>
<h1 data-number="13" id="implementation-experience"><span class="header-section-number">13</span> Implementation experience<a href="#implementation-experience" class="self-link"></a></h1>
<p>As far as the authors know, there are currently two implementations
of the proposal:</p>
<ul>
<li><p>the <a href="https://github.com/kokkos/stdBLAS/">reference
implementation</a> written and maintained by the authors and others,
and</p></li>
<li><p>an implementation by NVIDIA, which was released as part of their
HPC SDK, and which uses NVIDIA libraries such as cuBLAS to accelerate
many of the algorithms.</p></li>
</ul>
<p>This proposal depends on <code>mdspan</code> (adopted into C++23),
<code>submdspan</code> (P2630, adopted into the current C++ draft), and
(indirectly) on the padded <code>mdspan</code> layouts in P2642. The
<a href="https://github.com/kokkos/mdspan/">reference implementation of
<code>mdspan</code>,</a> written and maintained by the authors and
others, includes implementations of all these features.</p>
<h1 data-number="14" id="interoperable-with-other-linear-algebra-proposals"><span class="header-section-number">14</span> Interoperable with other linear
algebra proposals<a href="#interoperable-with-other-linear-algebra-proposals" class="self-link"></a></h1>
<p>We believe this proposal is complementary to P1385, a proposal for a
C++ Standard linear algebra library that introduces matrix and vector
classes with overloaded arithmetic operators. The P1385 authors and we
have expressed together in a joint paper,
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1891r0.pdf">P1891</a>,
that P1673 and P1385 “are orthogonal. They are not competing papers; …
there is no overlap of functionality.”</p>
<p>We designed P1673 in part as a natural foundation or implementation
layer for existing libraries with similar design and goals as P1385. Our
view is that a free function interface like P1673’s clearly separates
algorithms from data structures, and more naturally allows for a richer
set of operations such as what the BLAS provides. Our paper
<a href="https://wg21.link/p1674">P1674</a> explains why we think our
proposal is a minimal C++ “respelling” of the BLAS.</p>
<p>A natural extension of the present proposal would include accepting
P1385’s matrix and vector objects as input for the algorithms proposed
here. A straightforward way to do that would be for P1385’s matrix and
vector objects to make views of their data available as
<code>mdspan</code>.</p>
<h1 data-number="15" id="acknowledgments"><span class="header-section-number">15</span> Acknowledgments<a href="#acknowledgments" class="self-link"></a></h1>
<p>Sandia National Laboratories is a multimission laboratory managed and
operated by National Technology &amp; Engineering Solutions of Sandia,
LLC, a wholly owned subsidiary of Honeywell International, Inc., for the
U.S. Department of Energy’s National Nuclear Security Administration
under contract DE-NA0003525.</p>
<p>Special thanks to Bob Steagall and Guy Davidson for boldly leading
the charge to add linear algebra to the C++ Standard Library, and for
many fruitful discussions. Thanks also to Andrew Lumsdaine for his
pioneering efforts and history lessons. In addition, I very much
appreciate feedback from Davis Herring on constraints wording.</p>
<h1 data-number="16" id="references"><span class="header-section-number">16</span> References<a href="#references" class="self-link"></a></h1>
<h2 data-number="16.1" id="references-by-coathors"><span class="header-section-number">16.1</span> References by coathors<a href="#references-by-coathors" class="self-link"></a></h2>
<ul>
<li><p>G. Ballard, E. Carson, J. Demmel, M. Hoemmen, N. Knight, and O.
Schwartz, <a href="https://doi.org/10.1017/S0962492914000038">“Communication lower
bounds and optimal algorithms for numerical linear algebra,”</a>,
<em>Acta Numerica</em>, Vol. 23, May 2014, pp.&nbsp;1-155.</p></li>
<li><p>G. Davidson, M. Hoemmen, D. S. Hollman, B. Steagall, and C.
Trott, <a href="https://wg21.link/p1891r0">P1891R0</a>,
Oct.&nbsp;2019.</p></li>
<li><p>M. Hoemmen, D. S. Hollman, and C. Trott, “Evolving a Standard C++
Linear Algebra Library from the BLAS,”
<a href="https://wg21.link/p1674r2">P1674R2</a>, May 2022.</p></li>
<li><p>M. Hoemmen, J. Badwaik, M. Brucher, A. Iliopoulos, and J.
Michopoulos, “Historical lessons for C++ linear algebra library
standardization,” <a href="https://wg21.link/p1417r0">P1417R0</a>,
Jan.&nbsp;2019.</p></li>
<li><p>M. Hoemmen, D. S. Hollman, C. Jabot, I. Muerte, and C. Trott,
“Multidimensional subscript operator,”
<a href="https://wg21.link/p2128r6">P2128R6</a>, Sep.&nbsp;2021.</p></li>
<li><p>M. Hoemmen, K. Liegeois, and C. Trott, “Extending Linear Algebra
Support to Batched Operations,”
<a href="https://wg21.link/p2901r0">P2901R0</a>, May 2023.</p></li>
<li><p>D. S. Hollman, C. Kohlhoff, B. A. Lelbach, J. Hoberock, G. Brown,
and M. Dominiak, “A General Property Customization Mechanism,”
<a href="https://wg21.link/p1393r0">P1393R0</a>, Jan.&nbsp;2019.</p></li>
<li><p>C. Trott, D. S. Hollman, D. Lebrun-Grandie, M. Hoemmen, D.
Sunderland, H. C. Edwards, B. A. Lelbach, M. Bianco, B. Sander, A.
Iliopoulos, J. Michopoulos, and N. Liber, “<code>mdspan</code>,”
<a href="https://wg21.link/p0009r18">P0009R18</a>, Jul.&nbsp;2022.</p></li>
<li><p>C. Trott, D. S. Hollman, M. Hoemmen, D. Sunderland, and D.
Lebrun-Grandie, “<code>mdarray</code>: An Owning Multidimensional Array
Analog of <code>mdspan</code>”,
<a href="https://wg21.link/p1684r5">P1684R5</a>, May 2023.</p></li>
<li><p>C. Trott, D. Lebrun-Grandie, M. Hoemmen, and N. Liber,
“<code>submdspan</code>,”
<a href="https://wg21.link/p2630r4">P2630R4</a>, Jul.&nbsp;2023.</p></li>
</ul>
<h2 data-number="16.2" id="other-references"><span class="header-section-number">16.2</span> Other references<a href="#other-references" class="self-link"></a></h2>
<ul>
<li><p>E. Anderson, “Algorithm 978: Safe Scaling in the Level 1 BLAS,”
<em>ACM Transactions on Mathematical Software</em>, Vol. 44, pp.&nbsp;1-28,
2017.</p></li>
<li><p>E. Anderson et al., <a href="https://netlib.org/lapack/lug/lapack_lug.html"><em>LAPACK Users’
Guide</em></a>, Third Edition, SIAM, 1999.</p></li>
<li><p><a href="http://netlib.org/blas/blast-forum/blas-report.pdf">“Basic Linear
Algebra Subprograms Technical (BLAST) Forum Standard,”</a>
<em>International Journal of High Performance Applications and
Supercomputing</em>, Vol. 16, No.&nbsp;1, Spring 2002.</p></li>
<li><p>L. S. Blackford, J. Demmel, J. Dongarra, I. Duff, S. Hammarling,
G. Henry, M. Heroux, L. Kaufman, A. Lumsdaine, A. Petitet, R. Pozo, K.
Remington, and R. C. Whaley, <a href="https://doi.org/10.1145/567806.567807">“An updated set of basic
linear algebra subprograms (BLAS),”</a> <em>ACM Transactions on
Mathematical Software</em>, Vol. 28, No.&nbsp;2, Jun.&nbsp;2002,
pp.&nbsp;135-151.</p></li>
<li><p>J. L. Blue, “A Portable Fortran Program to Find the Euclidean
Norm of a Vector,” <em>ACM Transactions on Mathematical Software</em>,
Vol. 4, pp.&nbsp;15-23, 1978.</p></li>
<li><p>B. D. Craven,
<a href="https://doi.org/10.1017/S1446788700007588">“Complex symmetric
matrices”</a>, <em>Journal of the Australian Mathematical Society</em>,
Vol. 10, No.&nbsp;3-4, Nov.&nbsp;1969, pp.&nbsp;341–354.</p></li>
<li><p>E. Chow and A. Patel, “Fine-Grained Parallel Incomplete LU
Factorization”, <em>SIAM J. Sci. Comput.</em>, Vol. 37, No.&nbsp;2,
C169-C193, 2015.</p></li>
<li><p>G. Davidson and B. Steagall, “A proposal to add linear algebra
support to the C++ standard library,”
<a href="https://wg21.link/p1385r7">P1385R7</a>, Oct.&nbsp;2022.</p></li>
<li><p>B. Dawes, H. Hinnant, B. Stroustrup, D. Vandevoorde, and M. Wong,
“Direction for ISO C++,”
<a href="https://wg21.link/p0939r4">P0939R4</a>, Oct.&nbsp;2019.</p></li>
<li><p>J. Demmel, “Applied Numerical Linear Algebra,” Society for
Industrial and Applied Mathematics, Philadelphia, PA, 1997, ISBN
0-89871-389-7.</p></li>
<li><p>J. Demmel, I. Dumitriu, and O. Holtz, “Fast linear algebra is
stable,” <em>Numerische Mathematik</em> 108 (59-91), 2007.</p></li>
<li><p>J. Demmel and H. D. Nguyen, “Fast Reproducible Floating-Point
Summation,” 2013 IEEE 21st Symposium on Computer Arithmetic, 2013,
pp.&nbsp;163-172, doi: 10.1109/ARITH.2013.9.</p></li>
<li><p>J. Dongarra, J. Du Croz, S. Hammarling, and I. Duff,
<a href="https://dl.acm.org/doi/10.1145/77626.79170">“A set of level 3
basic linear algebra subprograms,”</a> <em>ACM Transactions on
Mathematical Software</em>, Vol. 16, No.&nbsp;1, pp.&nbsp;1-17,
Mar.&nbsp;1990.</p></li>
<li><p>J. Dongarra, R. Pozo, and D. Walker, “LAPACK++: A Design Overview
of Object-Oriented Extensions for High Performance Linear Algebra,” in
Proceedings of Supercomputing ’93, IEEE Computer Society Press, 1993,
pp.&nbsp;162-171.</p></li>
<li><p>M. Gates, P. Luszczek, A. Abdelfattah, J. Kurzak, J. Dongarra, K.
Arturov, C. Cecka, and C. Freitag,
<a href="https://www.icl.utk.edu/files/publications/2017/icl-utk-1031-2017.pdf">“C++
API for BLAS and LAPACK,”</a> SLATE Working Notes, Innovative Computing
Laboratory, University of Tennessee Knoxville, Feb.&nbsp;2018.</p></li>
<li><p>K. Goto and R. A. van de Geijn, <a href="https://doi.org/10.1145/1356052.1356053">“Anatomy of
high-performance matrix multiplication,”</a>, <em>ACM Transactions on
Mathematical Software</em>, Vol. 34, No.&nbsp;3, pp.&nbsp;1-25, May 2008.</p></li>
<li><p>N. J. Higham, <em>Accuracy and Stability of Numerical
Algorithms</em>, Second Edition, SIAM, 2022.</p></li>
<li><p>N. J. Higham, <a href="https://doi.org/10.1145/50063.214386">“FORTRAN codes for
estimating the one-norm of a real or complex matrix, with applications
to condition estimation,”</a> <em>ACM Transactions on Mathematical
Software</em>, Vol. 14, No.&nbsp;4, pp.&nbsp;381-396, Dec.&nbsp;1988.</p></li>
<li><p>N. A. Josuttis, “The C++ Standard Library: A Tutorial and
Reference,” Addison-Wesley, 1999.</p></li>
<li><p>M. Kretz, “Data-Parallel Vector Types &amp; Operations,”
<a href="https://wg21.link/p0214r9">P0214R9</a>, Mar.&nbsp;2018.</p></li>
<li><p>A. J. Perlis, “Epigrams on programming,” SIGPLAN Notices, Vol.
17, No.&nbsp;9, pp.&nbsp;7-13, 1982.</p></li>
<li><p>G. Strang, “Introduction to Linear Algebra,” 5th Edition,
Wellesley - Cambridge Press, 2016, ISBN 978-0-9802327-7-6, x+574
pages.</p></li>
<li><p>D. Vandevoorde and N. A. Josuttis, “C++ Templates: The Complete
Guide,” Addison-Wesley Professional, 2003.</p></li>
</ul>
<h1 data-number="17" id="dummy-heading-to-align-wording-numbering"><span class="header-section-number">17</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering" class="self-link"></a></h1>
<h1 data-number="18" id="dummy-heading-to-align-wording-numbering-1"><span class="header-section-number">18</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering-1" class="self-link"></a></h1>
<h1 data-number="19" id="dummy-heading-to-align-wording-numbering-2"><span class="header-section-number">19</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering-2" class="self-link"></a></h1>
<h1 data-number="20" id="dummy-heading-to-align-wording-numbering-3"><span class="header-section-number">20</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering-3" class="self-link"></a></h1>
<h1 data-number="21" id="dummy-heading-to-align-wording-numbering-4"><span class="header-section-number">21</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering-4" class="self-link"></a></h1>
<h1 data-number="22" id="dummy-heading-to-align-wording-numbering-5"><span class="header-section-number">22</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering-5" class="self-link"></a></h1>
<h1 data-number="23" id="dummy-heading-to-align-wording-numbering-6"><span class="header-section-number">23</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering-6" class="self-link"></a></h1>
<h1 data-number="24" id="dummy-heading-to-align-wording-numbering-7"><span class="header-section-number">24</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering-7" class="self-link"></a></h1>
<h1 data-number="25" id="dummy-heading-to-align-wording-numbering-8"><span class="header-section-number">25</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering-8" class="self-link"></a></h1>
<h1 data-number="26" id="dummy-heading-to-align-wording-numbering-9"><span class="header-section-number">26</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering-9" class="self-link"></a></h1>
<h1 data-number="27" id="dummy-heading-to-align-wording-numbering-10"><span class="header-section-number">27</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering-10" class="self-link"></a></h1>
<h1 data-number="28" id="dummy-heading-to-align-wording-numbering-11"><span class="header-section-number">28</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering-11" class="self-link"></a></h1>
<h2 data-number="28.1" id="dummy-heading-to-align-wording-numbering-12"><span class="header-section-number">28.1</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering-12" class="self-link"></a></h2>
<h2 data-number="28.2" id="dummy-heading-to-align-wording-numbering-13"><span class="header-section-number">28.2</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering-13" class="self-link"></a></h2>
<h2 data-number="28.3" id="dummy-heading-to-align-wording-numbering-14"><span class="header-section-number">28.3</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering-14" class="self-link"></a></h2>
<h2 data-number="28.4" id="dummy-heading-to-align-wording-numbering-15"><span class="header-section-number">28.4</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering-15" class="self-link"></a></h2>
<h2 data-number="28.5" id="dummy-heading-to-align-wording-numbering-16"><span class="header-section-number">28.5</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering-16" class="self-link"></a></h2>
<h2 data-number="28.6" id="dummy-heading-to-align-wording-numbering-17"><span class="header-section-number">28.6</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering-17" class="self-link"></a></h2>
<h2 data-number="28.7" id="dummy-heading-to-align-wording-numbering-18"><span class="header-section-number">28.7</span> Dummy Heading To Align Wording
Numbering<a href="#dummy-heading-to-align-wording-numbering-18" class="self-link"></a></h2>
<p>The preceding headings just push the automatic numbering of the
document generator so that “Wording” is in the place of 28.8 Numbers</p>
<h2 data-number="28.8" id="wording"><span class="header-section-number">28.8</span> Wording<a href="#wording" class="self-link"></a></h2>
<blockquote>
<p>Text in blockquotes is not proposed wording, but rather instructions
for generating proposed wording. The � character is used to denote a
placeholder section number which the editor shall determine.</p>
<p>In the Bibliography, add the following reference:</p>
</blockquote>
<p>J. Demmel, I. Dumitriu, and O. Holtz, “Fast linear algebra is
stable,” <em>Numerische Mathematik</em> 108 (59-91), 2007.</p>
<blockquote>
<p>In [algorithms.parallel.defns] modify paragraph 3.1:</p>
</blockquote>
<ul>
<li><span class="marginalizedparent"><a class="marginalized">(3.1)</a></span> All
operations of the categories of the iterators <span class="add" style="color: #00AA00"><ins>or <span><code>mdspan</code></span>
types</ins></span> that the algorithm is instantiated with.</li>
</ul>
<blockquote>
<p>In [algorithms.parallel.user] modify paragraph 1:</p>
</blockquote>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
Unless otherwise specified, function objects passed into parallel
algorithms as objects of type <code>Predicate</code>,
<code>BinaryPredicate</code>, <code>Compare</code>,
<code>UnaryOperation</code>, <code>BinaryOperation</code>,
<code>BinaryOperation1</code>, <code>BinaryOperation2</code><span class="add" style="color: #00AA00"><ins>,
<span><code>BinaryDivideOp</code></span></ins></span> and the operators
used by the analogous overloads to these parallel algorithms that are
formed by an invocation with the specified default predicate or
operation (where applicable) shall not directly or indirectly modify
objects via their arguments, nor shall they rely on the identity of the
provided objects.</p>
<blockquote>
<p>In [headers], add the header <code>&lt;linalg&gt;</code> to
[tab:headers.cpp].</p>
</blockquote>
<blockquote>
<p>In [diff.cpp23] add a new subsection</p>
</blockquote>
<p>Clause 16: library introduction [diff.cpp23.library]</p>
<p><strong>Affected subclause</strong>: 16.4.2.3</p>
<p><strong>Change</strong>: New headers</p>
<p><strong>Rationale</strong>: New functionality.</p>
<p><strong>Effect on original feature:</strong> The following C++
headers are new: <code>&lt;linalg&gt;</code>. Valid C++2023 code that
includes headers with these names may be invalid in this revision of
C++.</p>
<blockquote>
<p>In <em>[version.syn]</em>, add</p>
</blockquote>
<div class="sourceCode" id="cb6"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#define __cpp_lib_linalg </span>YYYYMML<span class="pp"> </span><span class="co">// also in &lt;linalg&gt;</span></span></code></pre></div>
<blockquote>
<p>Adjust the placeholder value as needed so as to denote this
proposal’s date of adoption.</p>
<p>At the end of Table � (“Numerics library summary”) in
<em>[numerics.general]</em>, add the following: [linalg], Linear
algebra, <code>&lt;linalg&gt;</code>.</p>
<p>At the end of <em>[numerics]</em> (after subsection 28.8
<em>[numbers]</em>), add all the material that follows.</p>
</blockquote>
<h2 data-number="28.9" id="basic-linear-algebra-algorithms-linalg"><span class="header-section-number">28.9</span> Basic linear algebra
algorithms [linalg]<a href="#basic-linear-algebra-algorithms-linalg" class="self-link"></a></h2>
<h3 data-number="28.9.1" id="overview-linalg.overview"><span class="header-section-number">28.9.1</span> Overview [linalg.overview]<a href="#overview-linalg.overview" class="self-link"></a></h3>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
Subclause [linalg] defines basic linear algebra algorithms. The
algorithms that access the elements of arrays view those elements
through <code>mdspan</code> [mdspan].</p>
<h3 data-number="28.9.2" id="header-linalg-synopsis-linalg.syn"><span class="header-section-number">28.9.2</span> Header
<code>&lt;linalg&gt;</code> synopsis [linalg.syn]<a href="#header-linalg-synopsis-linalg.syn" class="self-link"></a></h3>
<div class="sourceCode" id="cb7"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="kw">namespace</span> std<span class="op">::</span>linalg <span class="op">{</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.tags.order], storage order tags</span></span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> column_major_t;</span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a><span class="kw">inline</span> <span class="kw">constexpr</span> column_major_t column_major;</span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> row_major_t;</span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a><span class="kw">inline</span> <span class="kw">constexpr</span> row_major_t row_major;</span>
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.tags.triangle], triangle tags</span></span>
<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> upper_triangle_t;</span>
<span id="cb7-10"><a href="#cb7-10" aria-hidden="true" tabindex="-1"></a><span class="kw">inline</span> <span class="kw">constexpr</span> upper_triangle_t upper_triangle;</span>
<span id="cb7-11"><a href="#cb7-11" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> lower_triangle_t;</span>
<span id="cb7-12"><a href="#cb7-12" aria-hidden="true" tabindex="-1"></a><span class="kw">inline</span> <span class="kw">constexpr</span> lower_triangle_t lower_triangle;</span>
<span id="cb7-13"><a href="#cb7-13" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-14"><a href="#cb7-14" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.tags.diagonal], diagonal tags</span></span>
<span id="cb7-15"><a href="#cb7-15" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> implicit_unit_diagonal_t;</span>
<span id="cb7-16"><a href="#cb7-16" aria-hidden="true" tabindex="-1"></a><span class="kw">inline</span> <span class="kw">constexpr</span> implicit_unit_diagonal_t implicit_unit_diagonal;</span>
<span id="cb7-17"><a href="#cb7-17" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> explicit_diagonal_t;</span>
<span id="cb7-18"><a href="#cb7-18" aria-hidden="true" tabindex="-1"></a><span class="kw">inline</span> <span class="kw">constexpr</span> explicit_diagonal_t explicit_diagonal;</span>
<span id="cb7-19"><a href="#cb7-19" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-20"><a href="#cb7-20" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.layout.packed], class template layout_blas_packed</span></span>
<span id="cb7-21"><a href="#cb7-21" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Triangle,</span>
<span id="cb7-22"><a href="#cb7-22" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> StorageOrder<span class="op">&gt;</span></span>
<span id="cb7-23"><a href="#cb7-23" aria-hidden="true" tabindex="-1"></a><span class="kw">class</span> layout_blas_packed;</span>
<span id="cb7-24"><a href="#cb7-24" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-25"><a href="#cb7-25" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.helpers], exposition-only helpers</span></span>
<span id="cb7-26"><a href="#cb7-26" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-27"><a href="#cb7-27" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.helpers.concepts], linear algebra argument concepts</span></span>
<span id="cb7-28"><a href="#cb7-28" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-29"><a href="#cb7-29" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb7-30"><a href="#cb7-30" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">bool</span> <em>is-mdspan</em> <span class="op">=</span> <em>see below</em>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb7-31"><a href="#cb7-31" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-32"><a href="#cb7-32" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb7-33"><a href="#cb7-33" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>in-vector</em> <span class="op">=</span> <em>see below</em>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb7-34"><a href="#cb7-34" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-35"><a href="#cb7-35" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb7-36"><a href="#cb7-36" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>out-vector</em> <span class="op">=</span> <em>see below</em>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb7-37"><a href="#cb7-37" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-38"><a href="#cb7-38" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb7-39"><a href="#cb7-39" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>inout-vector</em> <span class="op">=</span> <em>see below</em>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb7-40"><a href="#cb7-40" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-41"><a href="#cb7-41" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb7-42"><a href="#cb7-42" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>in-matrix</em> <span class="op">=</span> <em>see below</em>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb7-43"><a href="#cb7-43" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-44"><a href="#cb7-44" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb7-45"><a href="#cb7-45" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>out-matrix</em> <span class="op">=</span> <em>see below</em>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb7-46"><a href="#cb7-46" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-47"><a href="#cb7-47" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb7-48"><a href="#cb7-48" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>inout-matrix</em> <span class="op">=</span> <em>see below</em>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb7-49"><a href="#cb7-49" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-50"><a href="#cb7-50" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb7-51"><a href="#cb7-51" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>possibly-packed-inout-matrix</em> <span class="op">=</span> <em>see below</em>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb7-52"><a href="#cb7-52" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-53"><a href="#cb7-53" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb7-54"><a href="#cb7-54" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>in-object</em> <span class="op">=</span> <em>see below</em>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb7-55"><a href="#cb7-55" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-56"><a href="#cb7-56" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb7-57"><a href="#cb7-57" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>out-object</em> <span class="op">=</span> <em>see below</em>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb7-58"><a href="#cb7-58" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-59"><a href="#cb7-59" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb7-60"><a href="#cb7-60" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>inout-object</em> <span class="op">=</span> <em>see below</em>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb7-61"><a href="#cb7-61" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-62"><a href="#cb7-62" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.scaled], scaled in-place transformation</span></span>
<span id="cb7-63"><a href="#cb7-63" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-64"><a href="#cb7-64" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.scaled.scaledaccessor], class template scaled_accessor</span></span>
<span id="cb7-65"><a href="#cb7-65" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ScalingFactor,</span>
<span id="cb7-66"><a href="#cb7-66" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> NestedAccessor<span class="op">&gt;</span></span>
<span id="cb7-67"><a href="#cb7-67" aria-hidden="true" tabindex="-1"></a><span class="kw">class</span> scaled_accessor;</span>
<span id="cb7-68"><a href="#cb7-68" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-69"><a href="#cb7-69" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.scaled.scaled], function template scaled</span></span>
<span id="cb7-70"><a href="#cb7-70" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ScalingFactor,</span>
<span id="cb7-71"><a href="#cb7-71" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> ElementType,</span>
<span id="cb7-72"><a href="#cb7-72" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Extents,</span>
<span id="cb7-73"><a href="#cb7-73" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Layout,</span>
<span id="cb7-74"><a href="#cb7-74" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Accessor<span class="op">&gt;</span></span>
<span id="cb7-75"><a href="#cb7-75" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="kw">auto</span> scaled<span class="op">(</span></span>
<span id="cb7-76"><a href="#cb7-76" aria-hidden="true" tabindex="-1"></a>  ScalingFactor alpha,</span>
<span id="cb7-77"><a href="#cb7-77" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span>ElementType, Extents, Layout, Accessor<span class="op">&gt;</span> x<span class="op">)</span>;</span>
<span id="cb7-78"><a href="#cb7-78" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-79"><a href="#cb7-79" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.conj], conjugated in-place transformation</span></span>
<span id="cb7-80"><a href="#cb7-80" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-81"><a href="#cb7-81" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.conj.conjugatedaccessor], class template conjugated_accessor</span></span>
<span id="cb7-82"><a href="#cb7-82" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> NestedAccessor<span class="op">&gt;</span></span>
<span id="cb7-83"><a href="#cb7-83" aria-hidden="true" tabindex="-1"></a><span class="kw">class</span> conjugated_accessor;</span>
<span id="cb7-84"><a href="#cb7-84" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-85"><a href="#cb7-85" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.conj.conjugated], function template conjugated</span></span>
<span id="cb7-86"><a href="#cb7-86" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ElementType,</span>
<span id="cb7-87"><a href="#cb7-87" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Extents,</span>
<span id="cb7-88"><a href="#cb7-88" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Layout,</span>
<span id="cb7-89"><a href="#cb7-89" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Accessor<span class="op">&gt;</span></span>
<span id="cb7-90"><a href="#cb7-90" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="kw">auto</span> conjugated<span class="op">(</span></span>
<span id="cb7-91"><a href="#cb7-91" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span>ElementType, Extents, Layout, Accessor<span class="op">&gt;</span> a<span class="op">)</span>;</span>
<span id="cb7-92"><a href="#cb7-92" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-93"><a href="#cb7-93" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.transp], transpose in-place transformation</span></span>
<span id="cb7-94"><a href="#cb7-94" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-95"><a href="#cb7-95" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.transp.layout.transpose], class template layout_transpose</span></span>
<span id="cb7-96"><a href="#cb7-96" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Layout<span class="op">&gt;</span></span>
<span id="cb7-97"><a href="#cb7-97" aria-hidden="true" tabindex="-1"></a><span class="kw">class</span> layout_transpose;</span>
<span id="cb7-98"><a href="#cb7-98" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-99"><a href="#cb7-99" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.transp.transposed], function template transposed</span></span>
<span id="cb7-100"><a href="#cb7-100" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ElementType,</span>
<span id="cb7-101"><a href="#cb7-101" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Extents,</span>
<span id="cb7-102"><a href="#cb7-102" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Layout,</span>
<span id="cb7-103"><a href="#cb7-103" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Accessor<span class="op">&gt;</span></span>
<span id="cb7-104"><a href="#cb7-104" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="kw">auto</span> transposed<span class="op">(</span></span>
<span id="cb7-105"><a href="#cb7-105" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span>ElementType, Extents, Layout, Accessor<span class="op">&gt;</span> a<span class="op">)</span>;</span>
<span id="cb7-106"><a href="#cb7-106" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-107"><a href="#cb7-107" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.conjtransposed],</span></span>
<span id="cb7-108"><a href="#cb7-108" aria-hidden="true" tabindex="-1"></a><span class="co">// conjugated transpose in-place transformation</span></span>
<span id="cb7-109"><a href="#cb7-109" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ElementType,</span>
<span id="cb7-110"><a href="#cb7-110" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Extents,</span>
<span id="cb7-111"><a href="#cb7-111" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Layout,</span>
<span id="cb7-112"><a href="#cb7-112" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Accessor<span class="op">&gt;</span></span>
<span id="cb7-113"><a href="#cb7-113" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="kw">auto</span> conjugate_transposed<span class="op">(</span></span>
<span id="cb7-114"><a href="#cb7-114" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span>ElementType, Extents, Layout, Accessor<span class="op">&gt;</span> a<span class="op">)</span>;</span>
<span id="cb7-115"><a href="#cb7-115" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-116"><a href="#cb7-116" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas1], BLAS 1 algorithms</span></span>
<span id="cb7-117"><a href="#cb7-117" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-118"><a href="#cb7-118" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas1.givens], Givens rotations</span></span>
<span id="cb7-119"><a href="#cb7-119" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-120"><a href="#cb7-120" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas1.givens.lartg], compute Givens rotation</span></span>
<span id="cb7-121"><a href="#cb7-121" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-122"><a href="#cb7-122" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Real<span class="op">&gt;</span></span>
<span id="cb7-123"><a href="#cb7-123" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> setup_givens_rotation_result <span class="op">{</span></span>
<span id="cb7-124"><a href="#cb7-124" aria-hidden="true" tabindex="-1"></a>  Real c;</span>
<span id="cb7-125"><a href="#cb7-125" aria-hidden="true" tabindex="-1"></a>  Real s;</span>
<span id="cb7-126"><a href="#cb7-126" aria-hidden="true" tabindex="-1"></a>  Real r;</span>
<span id="cb7-127"><a href="#cb7-127" aria-hidden="true" tabindex="-1"></a><span class="op">}</span>;</span>
<span id="cb7-128"><a href="#cb7-128" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Real<span class="op">&gt;</span></span>
<span id="cb7-129"><a href="#cb7-129" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> setup_givens_rotation_result<span class="op">&lt;</span>complex<span class="op">&lt;</span>Real<span class="op">&gt;&gt;</span> <span class="op">{</span></span>
<span id="cb7-130"><a href="#cb7-130" aria-hidden="true" tabindex="-1"></a>  Real c;</span>
<span id="cb7-131"><a href="#cb7-131" aria-hidden="true" tabindex="-1"></a>  complex<span class="op">&lt;</span>Real<span class="op">&gt;</span> s;</span>
<span id="cb7-132"><a href="#cb7-132" aria-hidden="true" tabindex="-1"></a>  complex<span class="op">&lt;</span>Real<span class="op">&gt;</span> r;</span>
<span id="cb7-133"><a href="#cb7-133" aria-hidden="true" tabindex="-1"></a><span class="op">}</span>;</span>
<span id="cb7-134"><a href="#cb7-134" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-135"><a href="#cb7-135" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Real<span class="op">&gt;</span></span>
<span id="cb7-136"><a href="#cb7-136" aria-hidden="true" tabindex="-1"></a>setup_givens_rotation_result<span class="op">&lt;</span>Real<span class="op">&gt;</span></span>
<span id="cb7-137"><a href="#cb7-137" aria-hidden="true" tabindex="-1"></a>setup_givens_rotation<span class="op">(</span>Real a, Real b<span class="op">)</span> <span class="kw">noexcept</span>;</span>
<span id="cb7-138"><a href="#cb7-138" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-139"><a href="#cb7-139" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Real<span class="op">&gt;</span></span>
<span id="cb7-140"><a href="#cb7-140" aria-hidden="true" tabindex="-1"></a>setup_givens_rotation_result<span class="op">&lt;</span>complex<span class="op">&lt;</span>Real<span class="op">&gt;&gt;</span></span>
<span id="cb7-141"><a href="#cb7-141" aria-hidden="true" tabindex="-1"></a>setup_givens_rotation<span class="op">(</span>complex<span class="op">&lt;</span>Real<span class="op">&gt;</span> a, complex<span class="op">&lt;</span>Real<span class="op">&gt;</span> b<span class="op">)</span> <span class="kw">noexcept</span>;</span>
<span id="cb7-142"><a href="#cb7-142" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-143"><a href="#cb7-143" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas1.givens.rot], apply computed Givens rotation</span></span>
<span id="cb7-144"><a href="#cb7-144" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>inout-vector</em> InOutVec1,</span>
<span id="cb7-145"><a href="#cb7-145" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec2,</span>
<span id="cb7-146"><a href="#cb7-146" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Real<span class="op">&gt;</span></span>
<span id="cb7-147"><a href="#cb7-147" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> apply_givens_rotation<span class="op">(</span></span>
<span id="cb7-148"><a href="#cb7-148" aria-hidden="true" tabindex="-1"></a>  InOutVec1 x,</span>
<span id="cb7-149"><a href="#cb7-149" aria-hidden="true" tabindex="-1"></a>  InOutVec2 y,</span>
<span id="cb7-150"><a href="#cb7-150" aria-hidden="true" tabindex="-1"></a>  Real c,</span>
<span id="cb7-151"><a href="#cb7-151" aria-hidden="true" tabindex="-1"></a>  Real s<span class="op">)</span>;</span>
<span id="cb7-152"><a href="#cb7-152" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-153"><a href="#cb7-153" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec1,</span>
<span id="cb7-154"><a href="#cb7-154" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec2,</span>
<span id="cb7-155"><a href="#cb7-155" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Real<span class="op">&gt;</span></span>
<span id="cb7-156"><a href="#cb7-156" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> apply_givens_rotation<span class="op">(</span></span>
<span id="cb7-157"><a href="#cb7-157" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-158"><a href="#cb7-158" aria-hidden="true" tabindex="-1"></a>  InOutVec1 x,</span>
<span id="cb7-159"><a href="#cb7-159" aria-hidden="true" tabindex="-1"></a>  InOutVec2 y,</span>
<span id="cb7-160"><a href="#cb7-160" aria-hidden="true" tabindex="-1"></a>  Real c,</span>
<span id="cb7-161"><a href="#cb7-161" aria-hidden="true" tabindex="-1"></a>  Real s<span class="op">)</span>;</span>
<span id="cb7-162"><a href="#cb7-162" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>inout-vector</em> InOutVec1,</span>
<span id="cb7-163"><a href="#cb7-163" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec2,</span>
<span id="cb7-164"><a href="#cb7-164" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Real<span class="op">&gt;</span></span>
<span id="cb7-165"><a href="#cb7-165" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> apply_givens_rotation<span class="op">(</span></span>
<span id="cb7-166"><a href="#cb7-166" aria-hidden="true" tabindex="-1"></a>  InOutVec1 x,</span>
<span id="cb7-167"><a href="#cb7-167" aria-hidden="true" tabindex="-1"></a>  InOutVec2 y,</span>
<span id="cb7-168"><a href="#cb7-168" aria-hidden="true" tabindex="-1"></a>  Real c,</span>
<span id="cb7-169"><a href="#cb7-169" aria-hidden="true" tabindex="-1"></a>  complex<span class="op">&lt;</span>Real<span class="op">&gt;</span> s<span class="op">)</span>;</span>
<span id="cb7-170"><a href="#cb7-170" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-171"><a href="#cb7-171" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec1,</span>
<span id="cb7-172"><a href="#cb7-172" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec2,</span>
<span id="cb7-173"><a href="#cb7-173" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Real<span class="op">&gt;</span></span>
<span id="cb7-174"><a href="#cb7-174" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> apply_givens_rotation<span class="op">(</span></span>
<span id="cb7-175"><a href="#cb7-175" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-176"><a href="#cb7-176" aria-hidden="true" tabindex="-1"></a>  InOutVec1 x,</span>
<span id="cb7-177"><a href="#cb7-177" aria-hidden="true" tabindex="-1"></a>  InOutVec2 y,</span>
<span id="cb7-178"><a href="#cb7-178" aria-hidden="true" tabindex="-1"></a>  Real c,</span>
<span id="cb7-179"><a href="#cb7-179" aria-hidden="true" tabindex="-1"></a>  complex<span class="op">&lt;</span>Real<span class="op">&gt;</span> s<span class="op">)</span>;</span>
<span id="cb7-180"><a href="#cb7-180" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-181"><a href="#cb7-181" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas1.swap], swap elements</span></span>
<span id="cb7-182"><a href="#cb7-182" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>inout-object</em> InOutObj1,</span>
<span id="cb7-183"><a href="#cb7-183" aria-hidden="true" tabindex="-1"></a>         <em>inout-object</em> InOutObj2<span class="op">&gt;</span></span>
<span id="cb7-184"><a href="#cb7-184" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> swap_elements<span class="op">(</span>InOutObj1 x,</span>
<span id="cb7-185"><a href="#cb7-185" aria-hidden="true" tabindex="-1"></a>                   InOutObj2 y<span class="op">)</span>;</span>
<span id="cb7-186"><a href="#cb7-186" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-187"><a href="#cb7-187" aria-hidden="true" tabindex="-1"></a>         <em>inout-object</em> InOutObj1,</span>
<span id="cb7-188"><a href="#cb7-188" aria-hidden="true" tabindex="-1"></a>         <em>inout-object</em> InOutObj2<span class="op">&gt;</span></span>
<span id="cb7-189"><a href="#cb7-189" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> swap_elements<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-190"><a href="#cb7-190" aria-hidden="true" tabindex="-1"></a>                   InOutObj1 x,</span>
<span id="cb7-191"><a href="#cb7-191" aria-hidden="true" tabindex="-1"></a>                   InOutObj2 y<span class="op">)</span>;</span>
<span id="cb7-192"><a href="#cb7-192" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-193"><a href="#cb7-193" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas1.scal], multiply elements by scalar</span></span>
<span id="cb7-194"><a href="#cb7-194" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Scalar,</span>
<span id="cb7-195"><a href="#cb7-195" aria-hidden="true" tabindex="-1"></a>         <em>inout-object</em> InOutObj<span class="op">&gt;</span></span>
<span id="cb7-196"><a href="#cb7-196" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> scale<span class="op">(</span>Scalar alpha,</span>
<span id="cb7-197"><a href="#cb7-197" aria-hidden="true" tabindex="-1"></a>           InOutObj x<span class="op">)</span>;</span>
<span id="cb7-198"><a href="#cb7-198" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-199"><a href="#cb7-199" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar,</span>
<span id="cb7-200"><a href="#cb7-200" aria-hidden="true" tabindex="-1"></a>         <em>inout-object</em> InOutObj<span class="op">&gt;</span></span>
<span id="cb7-201"><a href="#cb7-201" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> scale<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-202"><a href="#cb7-202" aria-hidden="true" tabindex="-1"></a>           Scalar alpha,</span>
<span id="cb7-203"><a href="#cb7-203" aria-hidden="true" tabindex="-1"></a>           InOutObj x<span class="op">)</span>;</span>
<span id="cb7-204"><a href="#cb7-204" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-205"><a href="#cb7-205" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas1.copy], copy elements</span></span>
<span id="cb7-206"><a href="#cb7-206" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-object</em> InObj,</span>
<span id="cb7-207"><a href="#cb7-207" aria-hidden="true" tabindex="-1"></a>         <em>out-object</em> OutObj<span class="op">&gt;</span></span>
<span id="cb7-208"><a href="#cb7-208" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> copy<span class="op">(</span>InObj x,</span>
<span id="cb7-209"><a href="#cb7-209" aria-hidden="true" tabindex="-1"></a>          OutObj y<span class="op">)</span>;</span>
<span id="cb7-210"><a href="#cb7-210" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-211"><a href="#cb7-211" aria-hidden="true" tabindex="-1"></a>         <em>in-object</em> InObj,</span>
<span id="cb7-212"><a href="#cb7-212" aria-hidden="true" tabindex="-1"></a>         <em>out-object</em> OutObj<span class="op">&gt;</span></span>
<span id="cb7-213"><a href="#cb7-213" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> copy<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-214"><a href="#cb7-214" aria-hidden="true" tabindex="-1"></a>          InObj x,</span>
<span id="cb7-215"><a href="#cb7-215" aria-hidden="true" tabindex="-1"></a>          OutObj y<span class="op">)</span>;</span>
<span id="cb7-216"><a href="#cb7-216" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-217"><a href="#cb7-217" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas1.add], add elementwise</span></span>
<span id="cb7-218"><a href="#cb7-218" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-object</em> InObj1,</span>
<span id="cb7-219"><a href="#cb7-219" aria-hidden="true" tabindex="-1"></a>         <em>in-object</em> InObj2,</span>
<span id="cb7-220"><a href="#cb7-220" aria-hidden="true" tabindex="-1"></a>         <em>out-object</em> OutObj<span class="op">&gt;</span></span>
<span id="cb7-221"><a href="#cb7-221" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> add<span class="op">(</span>InObj1 x,</span>
<span id="cb7-222"><a href="#cb7-222" aria-hidden="true" tabindex="-1"></a>         InObj2 y,</span>
<span id="cb7-223"><a href="#cb7-223" aria-hidden="true" tabindex="-1"></a>         OutObj z<span class="op">)</span>;</span>
<span id="cb7-224"><a href="#cb7-224" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-225"><a href="#cb7-225" aria-hidden="true" tabindex="-1"></a>         <em>in-object</em> InObj1,</span>
<span id="cb7-226"><a href="#cb7-226" aria-hidden="true" tabindex="-1"></a>         <em>in-object</em> InObj2,</span>
<span id="cb7-227"><a href="#cb7-227" aria-hidden="true" tabindex="-1"></a>         <em>out-object</em> OutObj<span class="op">&gt;</span></span>
<span id="cb7-228"><a href="#cb7-228" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> add<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-229"><a href="#cb7-229" aria-hidden="true" tabindex="-1"></a>         InObj1 x,</span>
<span id="cb7-230"><a href="#cb7-230" aria-hidden="true" tabindex="-1"></a>         InObj2 y,</span>
<span id="cb7-231"><a href="#cb7-231" aria-hidden="true" tabindex="-1"></a>         OutObj z<span class="op">)</span>;</span>
<span id="cb7-232"><a href="#cb7-232" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-233"><a href="#cb7-233" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas1.dot],</span></span>
<span id="cb7-234"><a href="#cb7-234" aria-hidden="true" tabindex="-1"></a><span class="co">// dot product of two vectors</span></span>
<span id="cb7-235"><a href="#cb7-235" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-236"><a href="#cb7-236" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas1.dot.dotu],</span></span>
<span id="cb7-237"><a href="#cb7-237" aria-hidden="true" tabindex="-1"></a><span class="co">// nonconjugated dot product of two vectors</span></span>
<span id="cb7-238"><a href="#cb7-238" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec1,</span>
<span id="cb7-239"><a href="#cb7-239" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-240"><a href="#cb7-240" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb7-241"><a href="#cb7-241" aria-hidden="true" tabindex="-1"></a>T dot<span class="op">(</span>InVec1 v1,</span>
<span id="cb7-242"><a href="#cb7-242" aria-hidden="true" tabindex="-1"></a>      InVec2 v2,</span>
<span id="cb7-243"><a href="#cb7-243" aria-hidden="true" tabindex="-1"></a>      Scalar init<span class="op">)</span>;</span>
<span id="cb7-244"><a href="#cb7-244" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-245"><a href="#cb7-245" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb7-246"><a href="#cb7-246" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-247"><a href="#cb7-247" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb7-248"><a href="#cb7-248" aria-hidden="true" tabindex="-1"></a>T dot<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-249"><a href="#cb7-249" aria-hidden="true" tabindex="-1"></a>      InVec1 v1,</span>
<span id="cb7-250"><a href="#cb7-250" aria-hidden="true" tabindex="-1"></a>      InVec2 v2,</span>
<span id="cb7-251"><a href="#cb7-251" aria-hidden="true" tabindex="-1"></a>      Scalar init<span class="op">)</span>;</span>
<span id="cb7-252"><a href="#cb7-252" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec1,</span>
<span id="cb7-253"><a href="#cb7-253" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2<span class="op">&gt;</span></span>
<span id="cb7-254"><a href="#cb7-254" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> dot<span class="op">(</span>InVec1 v1,</span>
<span id="cb7-255"><a href="#cb7-255" aria-hidden="true" tabindex="-1"></a>         InVec2 v2<span class="op">)</span>;</span>
<span id="cb7-256"><a href="#cb7-256" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-257"><a href="#cb7-257" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb7-258"><a href="#cb7-258" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2<span class="op">&gt;</span></span>
<span id="cb7-259"><a href="#cb7-259" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> dot<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-260"><a href="#cb7-260" aria-hidden="true" tabindex="-1"></a>         InVec1 v1,</span>
<span id="cb7-261"><a href="#cb7-261" aria-hidden="true" tabindex="-1"></a>         InVec2 v2<span class="op">)</span>;</span>
<span id="cb7-262"><a href="#cb7-262" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-263"><a href="#cb7-263" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas1.dot.dotc],</span></span>
<span id="cb7-264"><a href="#cb7-264" aria-hidden="true" tabindex="-1"></a><span class="co">// conjugated dot product of two vectors</span></span>
<span id="cb7-265"><a href="#cb7-265" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec1,</span>
<span id="cb7-266"><a href="#cb7-266" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-267"><a href="#cb7-267" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb7-268"><a href="#cb7-268" aria-hidden="true" tabindex="-1"></a>Scalar dotc<span class="op">(</span>InVec1 v1,</span>
<span id="cb7-269"><a href="#cb7-269" aria-hidden="true" tabindex="-1"></a>            InVec2 v2,</span>
<span id="cb7-270"><a href="#cb7-270" aria-hidden="true" tabindex="-1"></a>            Scalar init<span class="op">)</span>;</span>
<span id="cb7-271"><a href="#cb7-271" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-272"><a href="#cb7-272" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb7-273"><a href="#cb7-273" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-274"><a href="#cb7-274" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb7-275"><a href="#cb7-275" aria-hidden="true" tabindex="-1"></a>Scalar dotc<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-276"><a href="#cb7-276" aria-hidden="true" tabindex="-1"></a>            InVec1 v1,</span>
<span id="cb7-277"><a href="#cb7-277" aria-hidden="true" tabindex="-1"></a>            InVec2 v2,</span>
<span id="cb7-278"><a href="#cb7-278" aria-hidden="true" tabindex="-1"></a>            Scalar init<span class="op">)</span>;</span>
<span id="cb7-279"><a href="#cb7-279" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec1,</span>
<span id="cb7-280"><a href="#cb7-280" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2<span class="op">&gt;</span></span>
<span id="cb7-281"><a href="#cb7-281" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> dotc<span class="op">(</span>InVec1 v1,</span>
<span id="cb7-282"><a href="#cb7-282" aria-hidden="true" tabindex="-1"></a>          InVec2 v2<span class="op">)</span>;</span>
<span id="cb7-283"><a href="#cb7-283" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-284"><a href="#cb7-284" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb7-285"><a href="#cb7-285" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2<span class="op">&gt;</span></span>
<span id="cb7-286"><a href="#cb7-286" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> dotc<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-287"><a href="#cb7-287" aria-hidden="true" tabindex="-1"></a>          InVec1 v1,</span>
<span id="cb7-288"><a href="#cb7-288" aria-hidden="true" tabindex="-1"></a>          InVec2 v2<span class="op">)</span>;</span>
<span id="cb7-289"><a href="#cb7-289" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-290"><a href="#cb7-290" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas1.ssq],</span></span>
<span id="cb7-291"><a href="#cb7-291" aria-hidden="true" tabindex="-1"></a><span class="co">// Scaled sum of squares of a vector's elements</span></span>
<span id="cb7-292"><a href="#cb7-292" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb7-293"><a href="#cb7-293" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> sum_of_squares_result <span class="op">{</span></span>
<span id="cb7-294"><a href="#cb7-294" aria-hidden="true" tabindex="-1"></a>  Scalar scaling_factor;</span>
<span id="cb7-295"><a href="#cb7-295" aria-hidden="true" tabindex="-1"></a>  Scalar scaled_sum_of_squares;</span>
<span id="cb7-296"><a href="#cb7-296" aria-hidden="true" tabindex="-1"></a><span class="op">}</span>;</span>
<span id="cb7-297"><a href="#cb7-297" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec,</span>
<span id="cb7-298"><a href="#cb7-298" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb7-299"><a href="#cb7-299" aria-hidden="true" tabindex="-1"></a>sum_of_squares_result<span class="op">&lt;</span>Scalar<span class="op">&gt;</span> vector_sum_of_squares<span class="op">(</span></span>
<span id="cb7-300"><a href="#cb7-300" aria-hidden="true" tabindex="-1"></a>  InVec v,</span>
<span id="cb7-301"><a href="#cb7-301" aria-hidden="true" tabindex="-1"></a>  sum_of_squares_result<span class="op">&lt;</span>Scalar<span class="op">&gt;</span> init<span class="op">)</span>;</span>
<span id="cb7-302"><a href="#cb7-302" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-303"><a href="#cb7-303" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-304"><a href="#cb7-304" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb7-305"><a href="#cb7-305" aria-hidden="true" tabindex="-1"></a>sum_of_squares_result<span class="op">&lt;</span>Scalar<span class="op">&gt;</span> vector_sum_of_squares<span class="op">(</span></span>
<span id="cb7-306"><a href="#cb7-306" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-307"><a href="#cb7-307" aria-hidden="true" tabindex="-1"></a>  InVec v,</span>
<span id="cb7-308"><a href="#cb7-308" aria-hidden="true" tabindex="-1"></a>  sum_of_squares_result<span class="op">&lt;</span>Scalar<span class="op">&gt;</span> init<span class="op">)</span>;</span>
<span id="cb7-309"><a href="#cb7-309" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-310"><a href="#cb7-310" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas1.nrm2],</span></span>
<span id="cb7-311"><a href="#cb7-311" aria-hidden="true" tabindex="-1"></a><span class="co">// Euclidean norm of a vector</span></span>
<span id="cb7-312"><a href="#cb7-312" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec,</span>
<span id="cb7-313"><a href="#cb7-313" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb7-314"><a href="#cb7-314" aria-hidden="true" tabindex="-1"></a>Scalar vector_two_norm<span class="op">(</span>InVec v,</span>
<span id="cb7-315"><a href="#cb7-315" aria-hidden="true" tabindex="-1"></a>                       Scalar init<span class="op">)</span>;</span>
<span id="cb7-316"><a href="#cb7-316" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-317"><a href="#cb7-317" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-318"><a href="#cb7-318" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb7-319"><a href="#cb7-319" aria-hidden="true" tabindex="-1"></a>Scalar vector_two_norm<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-320"><a href="#cb7-320" aria-hidden="true" tabindex="-1"></a>                       InVec v,</span>
<span id="cb7-321"><a href="#cb7-321" aria-hidden="true" tabindex="-1"></a>                       Scalar init<span class="op">)</span>;</span>
<span id="cb7-322"><a href="#cb7-322" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec<span class="op">&gt;</span></span>
<span id="cb7-323"><a href="#cb7-323" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> vector_two_norm<span class="op">(</span>InVec v<span class="op">)</span>;</span>
<span id="cb7-324"><a href="#cb7-324" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-325"><a href="#cb7-325" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec<span class="op">&gt;</span></span>
<span id="cb7-326"><a href="#cb7-326" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> vector_two_norm<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-327"><a href="#cb7-327" aria-hidden="true" tabindex="-1"></a>                     InVec v<span class="op">)</span>;</span>
<span id="cb7-328"><a href="#cb7-328" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-329"><a href="#cb7-329" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas1.asum],</span></span>
<span id="cb7-330"><a href="#cb7-330" aria-hidden="true" tabindex="-1"></a><span class="co">// sum of absolute values of vector elements</span></span>
<span id="cb7-331"><a href="#cb7-331" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec,</span>
<span id="cb7-332"><a href="#cb7-332" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb7-333"><a href="#cb7-333" aria-hidden="true" tabindex="-1"></a>Scalar vector_abs_sum<span class="op">(</span>InVec v,</span>
<span id="cb7-334"><a href="#cb7-334" aria-hidden="true" tabindex="-1"></a>                      Scalar init<span class="op">)</span>;</span>
<span id="cb7-335"><a href="#cb7-335" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-336"><a href="#cb7-336" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-337"><a href="#cb7-337" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb7-338"><a href="#cb7-338" aria-hidden="true" tabindex="-1"></a>Scalar vector_abs_sum<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-339"><a href="#cb7-339" aria-hidden="true" tabindex="-1"></a>                      InVec v,</span>
<span id="cb7-340"><a href="#cb7-340" aria-hidden="true" tabindex="-1"></a>                      Scalar init<span class="op">)</span>;</span>
<span id="cb7-341"><a href="#cb7-341" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec<span class="op">&gt;</span></span>
<span id="cb7-342"><a href="#cb7-342" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> vector_abs_sum<span class="op">(</span>InVec v<span class="op">)</span>;</span>
<span id="cb7-343"><a href="#cb7-343" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-344"><a href="#cb7-344" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec<span class="op">&gt;</span></span>
<span id="cb7-345"><a href="#cb7-345" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> vector_abs_sum<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-346"><a href="#cb7-346" aria-hidden="true" tabindex="-1"></a>                    InVec v<span class="op">)</span>;</span>
<span id="cb7-347"><a href="#cb7-347" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-348"><a href="#cb7-348" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas1.iamax],</span></span>
<span id="cb7-349"><a href="#cb7-349" aria-hidden="true" tabindex="-1"></a><span class="co">// index of maximum absolute value of vector elements</span></span>
<span id="cb7-350"><a href="#cb7-350" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec<span class="op">&gt;</span></span>
<span id="cb7-351"><a href="#cb7-351" aria-hidden="true" tabindex="-1"></a><span class="kw">typename</span> InVec<span class="op">::</span>extents_type vector_idx_abs_max<span class="op">(</span>InVec v<span class="op">)</span>;</span>
<span id="cb7-352"><a href="#cb7-352" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-353"><a href="#cb7-353" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec<span class="op">&gt;</span></span>
<span id="cb7-354"><a href="#cb7-354" aria-hidden="true" tabindex="-1"></a><span class="kw">typename</span> InVec<span class="op">::</span>extents_type vector_idx_abs_max<span class="op">(</span></span>
<span id="cb7-355"><a href="#cb7-355" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-356"><a href="#cb7-356" aria-hidden="true" tabindex="-1"></a>  InVec v<span class="op">)</span>;</span>
<span id="cb7-357"><a href="#cb7-357" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-358"><a href="#cb7-358" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas1.matfrobnorm],</span></span>
<span id="cb7-359"><a href="#cb7-359" aria-hidden="true" tabindex="-1"></a><span class="co">// Frobenius norm of a matrix</span></span>
<span id="cb7-360"><a href="#cb7-360" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-361"><a href="#cb7-361" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb7-362"><a href="#cb7-362" aria-hidden="true" tabindex="-1"></a>Scalar matrix_frob_norm<span class="op">(</span>InMat A,</span>
<span id="cb7-363"><a href="#cb7-363" aria-hidden="true" tabindex="-1"></a>  Scalar init<span class="op">)</span>;</span>
<span id="cb7-364"><a href="#cb7-364" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-365"><a href="#cb7-365" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-366"><a href="#cb7-366" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb7-367"><a href="#cb7-367" aria-hidden="true" tabindex="-1"></a>Scalar matrix_frob_norm<span class="op">(</span></span>
<span id="cb7-368"><a href="#cb7-368" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-369"><a href="#cb7-369" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-370"><a href="#cb7-370" aria-hidden="true" tabindex="-1"></a>  Scalar init<span class="op">)</span>;</span>
<span id="cb7-371"><a href="#cb7-371" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat<span class="op">&gt;</span></span>
<span id="cb7-372"><a href="#cb7-372" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> matrix_frob_norm<span class="op">(</span></span>
<span id="cb7-373"><a href="#cb7-373" aria-hidden="true" tabindex="-1"></a>  InMat A<span class="op">)</span>;</span>
<span id="cb7-374"><a href="#cb7-374" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-375"><a href="#cb7-375" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat<span class="op">&gt;</span></span>
<span id="cb7-376"><a href="#cb7-376" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> matrix_frob_norm<span class="op">(</span></span>
<span id="cb7-377"><a href="#cb7-377" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-378"><a href="#cb7-378" aria-hidden="true" tabindex="-1"></a>  InMat A<span class="op">)</span>;</span>
<span id="cb7-379"><a href="#cb7-379" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-380"><a href="#cb7-380" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas1.matonenorm],</span></span>
<span id="cb7-381"><a href="#cb7-381" aria-hidden="true" tabindex="-1"></a><span class="co">// One norm of a matrix</span></span>
<span id="cb7-382"><a href="#cb7-382" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-383"><a href="#cb7-383" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb7-384"><a href="#cb7-384" aria-hidden="true" tabindex="-1"></a>Scalar matrix_one_norm<span class="op">(</span></span>
<span id="cb7-385"><a href="#cb7-385" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-386"><a href="#cb7-386" aria-hidden="true" tabindex="-1"></a>  Scalar init<span class="op">)</span>;</span>
<span id="cb7-387"><a href="#cb7-387" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-388"><a href="#cb7-388" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-389"><a href="#cb7-389" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb7-390"><a href="#cb7-390" aria-hidden="true" tabindex="-1"></a>Scalar matrix_one_norm<span class="op">(</span></span>
<span id="cb7-391"><a href="#cb7-391" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-392"><a href="#cb7-392" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-393"><a href="#cb7-393" aria-hidden="true" tabindex="-1"></a>  Scalar init<span class="op">)</span>;</span>
<span id="cb7-394"><a href="#cb7-394" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat<span class="op">&gt;</span></span>
<span id="cb7-395"><a href="#cb7-395" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> matrix_one_norm<span class="op">(</span></span>
<span id="cb7-396"><a href="#cb7-396" aria-hidden="true" tabindex="-1"></a>  InMat A<span class="op">)</span>;</span>
<span id="cb7-397"><a href="#cb7-397" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-398"><a href="#cb7-398" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat<span class="op">&gt;</span></span>
<span id="cb7-399"><a href="#cb7-399" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> matrix_one_norm<span class="op">(</span></span>
<span id="cb7-400"><a href="#cb7-400" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-401"><a href="#cb7-401" aria-hidden="true" tabindex="-1"></a>  InMat A<span class="op">)</span>;</span>
<span id="cb7-402"><a href="#cb7-402" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-403"><a href="#cb7-403" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas1.matinfnorm],</span></span>
<span id="cb7-404"><a href="#cb7-404" aria-hidden="true" tabindex="-1"></a><span class="co">// Infinity norm of a matrix</span></span>
<span id="cb7-405"><a href="#cb7-405" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-406"><a href="#cb7-406" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb7-407"><a href="#cb7-407" aria-hidden="true" tabindex="-1"></a>Scalar matrix_inf_norm<span class="op">(</span></span>
<span id="cb7-408"><a href="#cb7-408" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-409"><a href="#cb7-409" aria-hidden="true" tabindex="-1"></a>  Scalar init<span class="op">)</span>;</span>
<span id="cb7-410"><a href="#cb7-410" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-411"><a href="#cb7-411" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-412"><a href="#cb7-412" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb7-413"><a href="#cb7-413" aria-hidden="true" tabindex="-1"></a>Scalar matrix_inf_norm<span class="op">(</span></span>
<span id="cb7-414"><a href="#cb7-414" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-415"><a href="#cb7-415" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-416"><a href="#cb7-416" aria-hidden="true" tabindex="-1"></a>  Scalar init<span class="op">)</span>;</span>
<span id="cb7-417"><a href="#cb7-417" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat<span class="op">&gt;</span></span>
<span id="cb7-418"><a href="#cb7-418" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> matrix_inf_norm<span class="op">(</span></span>
<span id="cb7-419"><a href="#cb7-419" aria-hidden="true" tabindex="-1"></a>  InMat A<span class="op">)</span>;</span>
<span id="cb7-420"><a href="#cb7-420" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-421"><a href="#cb7-421" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat<span class="op">&gt;</span></span>
<span id="cb7-422"><a href="#cb7-422" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> matrix_inf_norm<span class="op">(</span></span>
<span id="cb7-423"><a href="#cb7-423" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-424"><a href="#cb7-424" aria-hidden="true" tabindex="-1"></a>  InMat A<span class="op">)</span>;</span>
<span id="cb7-425"><a href="#cb7-425" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-426"><a href="#cb7-426" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas2], BLAS 2 algorithms</span></span>
<span id="cb7-427"><a href="#cb7-427" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-428"><a href="#cb7-428" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas2.gemv],</span></span>
<span id="cb7-429"><a href="#cb7-429" aria-hidden="true" tabindex="-1"></a><span class="co">// general matrix-vector product</span></span>
<span id="cb7-430"><a href="#cb7-430" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-431"><a href="#cb7-431" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-432"><a href="#cb7-432" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb7-433"><a href="#cb7-433" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_vector_product<span class="op">(</span>InMat A,</span>
<span id="cb7-434"><a href="#cb7-434" aria-hidden="true" tabindex="-1"></a>                           InVec x,</span>
<span id="cb7-435"><a href="#cb7-435" aria-hidden="true" tabindex="-1"></a>                           OutVec y<span class="op">)</span>;</span>
<span id="cb7-436"><a href="#cb7-436" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-437"><a href="#cb7-437" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-438"><a href="#cb7-438" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-439"><a href="#cb7-439" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb7-440"><a href="#cb7-440" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_vector_product<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-441"><a href="#cb7-441" aria-hidden="true" tabindex="-1"></a>                           InMat A,</span>
<span id="cb7-442"><a href="#cb7-442" aria-hidden="true" tabindex="-1"></a>                           InVec x,</span>
<span id="cb7-443"><a href="#cb7-443" aria-hidden="true" tabindex="-1"></a>                           OutVec y<span class="op">)</span>;</span>
<span id="cb7-444"><a href="#cb7-444" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-445"><a href="#cb7-445" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb7-446"><a href="#cb7-446" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-447"><a href="#cb7-447" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb7-448"><a href="#cb7-448" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_vector_product<span class="op">(</span>InMat A,</span>
<span id="cb7-449"><a href="#cb7-449" aria-hidden="true" tabindex="-1"></a>                           InVec1 x,</span>
<span id="cb7-450"><a href="#cb7-450" aria-hidden="true" tabindex="-1"></a>                           InVec2 y,</span>
<span id="cb7-451"><a href="#cb7-451" aria-hidden="true" tabindex="-1"></a>                           OutVec z<span class="op">)</span>;</span>
<span id="cb7-452"><a href="#cb7-452" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-453"><a href="#cb7-453" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-454"><a href="#cb7-454" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb7-455"><a href="#cb7-455" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-456"><a href="#cb7-456" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb7-457"><a href="#cb7-457" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_vector_product<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-458"><a href="#cb7-458" aria-hidden="true" tabindex="-1"></a>                           InMat A,</span>
<span id="cb7-459"><a href="#cb7-459" aria-hidden="true" tabindex="-1"></a>                           InVec1 x,</span>
<span id="cb7-460"><a href="#cb7-460" aria-hidden="true" tabindex="-1"></a>                           InVec2 y,</span>
<span id="cb7-461"><a href="#cb7-461" aria-hidden="true" tabindex="-1"></a>                           OutVec z<span class="op">)</span>;</span>
<span id="cb7-462"><a href="#cb7-462" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-463"><a href="#cb7-463" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas2.symv],</span></span>
<span id="cb7-464"><a href="#cb7-464" aria-hidden="true" tabindex="-1"></a><span class="co">// symmetric matrix-vector product</span></span>
<span id="cb7-465"><a href="#cb7-465" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-466"><a href="#cb7-466" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-467"><a href="#cb7-467" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-468"><a href="#cb7-468" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb7-469"><a href="#cb7-469" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_vector_product<span class="op">(</span>InMat A,</span>
<span id="cb7-470"><a href="#cb7-470" aria-hidden="true" tabindex="-1"></a>                                     Triangle t,</span>
<span id="cb7-471"><a href="#cb7-471" aria-hidden="true" tabindex="-1"></a>                                     InVec x,</span>
<span id="cb7-472"><a href="#cb7-472" aria-hidden="true" tabindex="-1"></a>                                     OutVec y<span class="op">)</span>;</span>
<span id="cb7-473"><a href="#cb7-473" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-474"><a href="#cb7-474" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-475"><a href="#cb7-475" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-476"><a href="#cb7-476" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-477"><a href="#cb7-477" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb7-478"><a href="#cb7-478" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_vector_product<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-479"><a href="#cb7-479" aria-hidden="true" tabindex="-1"></a>                                     InMat A,</span>
<span id="cb7-480"><a href="#cb7-480" aria-hidden="true" tabindex="-1"></a>                                     Triangle t,</span>
<span id="cb7-481"><a href="#cb7-481" aria-hidden="true" tabindex="-1"></a>                                     InVec x,</span>
<span id="cb7-482"><a href="#cb7-482" aria-hidden="true" tabindex="-1"></a>                                     OutVec y<span class="op">)</span>;</span>
<span id="cb7-483"><a href="#cb7-483" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-484"><a href="#cb7-484" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-485"><a href="#cb7-485" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb7-486"><a href="#cb7-486" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-487"><a href="#cb7-487" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb7-488"><a href="#cb7-488" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_vector_product<span class="op">(</span></span>
<span id="cb7-489"><a href="#cb7-489" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-490"><a href="#cb7-490" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-491"><a href="#cb7-491" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb7-492"><a href="#cb7-492" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb7-493"><a href="#cb7-493" aria-hidden="true" tabindex="-1"></a>  OutVec z<span class="op">)</span>;</span>
<span id="cb7-494"><a href="#cb7-494" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-495"><a href="#cb7-495" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-496"><a href="#cb7-496" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-497"><a href="#cb7-497" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-498"><a href="#cb7-498" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb7-499"><a href="#cb7-499" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-500"><a href="#cb7-500" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb7-501"><a href="#cb7-501" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_vector_product<span class="op">(</span></span>
<span id="cb7-502"><a href="#cb7-502" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-503"><a href="#cb7-503" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-504"><a href="#cb7-504" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-505"><a href="#cb7-505" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb7-506"><a href="#cb7-506" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb7-507"><a href="#cb7-507" aria-hidden="true" tabindex="-1"></a>  OutVec z<span class="op">)</span>;</span>
<span id="cb7-508"><a href="#cb7-508" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-509"><a href="#cb7-509" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas2.hemv],</span></span>
<span id="cb7-510"><a href="#cb7-510" aria-hidden="true" tabindex="-1"></a><span class="co">// Hermitian matrix-vector product</span></span>
<span id="cb7-511"><a href="#cb7-511" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-512"><a href="#cb7-512" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-513"><a href="#cb7-513" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-514"><a href="#cb7-514" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb7-515"><a href="#cb7-515" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_vector_product<span class="op">(</span>InMat A,</span>
<span id="cb7-516"><a href="#cb7-516" aria-hidden="true" tabindex="-1"></a>                                     Triangle t,</span>
<span id="cb7-517"><a href="#cb7-517" aria-hidden="true" tabindex="-1"></a>                                     InVec x,</span>
<span id="cb7-518"><a href="#cb7-518" aria-hidden="true" tabindex="-1"></a>                                     OutVec y<span class="op">)</span>;</span>
<span id="cb7-519"><a href="#cb7-519" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-520"><a href="#cb7-520" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-521"><a href="#cb7-521" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-522"><a href="#cb7-522" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-523"><a href="#cb7-523" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb7-524"><a href="#cb7-524" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_vector_product<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-525"><a href="#cb7-525" aria-hidden="true" tabindex="-1"></a>                                     InMat A,</span>
<span id="cb7-526"><a href="#cb7-526" aria-hidden="true" tabindex="-1"></a>                                     Triangle t,</span>
<span id="cb7-527"><a href="#cb7-527" aria-hidden="true" tabindex="-1"></a>                                     InVec x,</span>
<span id="cb7-528"><a href="#cb7-528" aria-hidden="true" tabindex="-1"></a>                                     OutVec y<span class="op">)</span>;</span>
<span id="cb7-529"><a href="#cb7-529" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-530"><a href="#cb7-530" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-531"><a href="#cb7-531" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb7-532"><a href="#cb7-532" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-533"><a href="#cb7-533" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb7-534"><a href="#cb7-534" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_vector_product<span class="op">(</span>InMat A,</span>
<span id="cb7-535"><a href="#cb7-535" aria-hidden="true" tabindex="-1"></a>                                     Triangle t,</span>
<span id="cb7-536"><a href="#cb7-536" aria-hidden="true" tabindex="-1"></a>                                     InVec1 x,</span>
<span id="cb7-537"><a href="#cb7-537" aria-hidden="true" tabindex="-1"></a>                                     InVec2 y,</span>
<span id="cb7-538"><a href="#cb7-538" aria-hidden="true" tabindex="-1"></a>                                     OutVec z<span class="op">)</span>;</span>
<span id="cb7-539"><a href="#cb7-539" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-540"><a href="#cb7-540" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-541"><a href="#cb7-541" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-542"><a href="#cb7-542" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-543"><a href="#cb7-543" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb7-544"><a href="#cb7-544" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-545"><a href="#cb7-545" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb7-546"><a href="#cb7-546" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_vector_product<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-547"><a href="#cb7-547" aria-hidden="true" tabindex="-1"></a>                                     InMat A,</span>
<span id="cb7-548"><a href="#cb7-548" aria-hidden="true" tabindex="-1"></a>                                     Triangle t,</span>
<span id="cb7-549"><a href="#cb7-549" aria-hidden="true" tabindex="-1"></a>                                     InVec1 x,</span>
<span id="cb7-550"><a href="#cb7-550" aria-hidden="true" tabindex="-1"></a>                                     InVec2 y,</span>
<span id="cb7-551"><a href="#cb7-551" aria-hidden="true" tabindex="-1"></a>                                     OutVec z<span class="op">)</span>;</span>
<span id="cb7-552"><a href="#cb7-552" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-553"><a href="#cb7-553" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas2.trmv],</span></span>
<span id="cb7-554"><a href="#cb7-554" aria-hidden="true" tabindex="-1"></a><span class="co">// Triangular matrix-vector product</span></span>
<span id="cb7-555"><a href="#cb7-555" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-556"><a href="#cb7-556" aria-hidden="true" tabindex="-1"></a><span class="co">// Overwriting triangular matrix-vector product</span></span>
<span id="cb7-557"><a href="#cb7-557" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-558"><a href="#cb7-558" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-559"><a href="#cb7-559" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-560"><a href="#cb7-560" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-561"><a href="#cb7-561" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb7-562"><a href="#cb7-562" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_product<span class="op">(</span></span>
<span id="cb7-563"><a href="#cb7-563" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-564"><a href="#cb7-564" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-565"><a href="#cb7-565" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-566"><a href="#cb7-566" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb7-567"><a href="#cb7-567" aria-hidden="true" tabindex="-1"></a>  OutVec y<span class="op">)</span>;</span>
<span id="cb7-568"><a href="#cb7-568" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-569"><a href="#cb7-569" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-570"><a href="#cb7-570" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-571"><a href="#cb7-571" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-572"><a href="#cb7-572" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-573"><a href="#cb7-573" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb7-574"><a href="#cb7-574" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_product<span class="op">(</span></span>
<span id="cb7-575"><a href="#cb7-575" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-576"><a href="#cb7-576" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-577"><a href="#cb7-577" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-578"><a href="#cb7-578" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-579"><a href="#cb7-579" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb7-580"><a href="#cb7-580" aria-hidden="true" tabindex="-1"></a>  OutVec y<span class="op">)</span>;</span>
<span id="cb7-581"><a href="#cb7-581" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-582"><a href="#cb7-582" aria-hidden="true" tabindex="-1"></a><span class="co">// In-place triangular matrix-vector product</span></span>
<span id="cb7-583"><a href="#cb7-583" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-584"><a href="#cb7-584" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-585"><a href="#cb7-585" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-586"><a href="#cb7-586" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec<span class="op">&gt;</span></span>
<span id="cb7-587"><a href="#cb7-587" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_product<span class="op">(</span></span>
<span id="cb7-588"><a href="#cb7-588" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-589"><a href="#cb7-589" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-590"><a href="#cb7-590" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-591"><a href="#cb7-591" aria-hidden="true" tabindex="-1"></a>  InOutVec y<span class="op">)</span>;</span>
<span id="cb7-592"><a href="#cb7-592" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-593"><a href="#cb7-593" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-594"><a href="#cb7-594" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-595"><a href="#cb7-595" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-596"><a href="#cb7-596" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec<span class="op">&gt;</span></span>
<span id="cb7-597"><a href="#cb7-597" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_product<span class="op">(</span></span>
<span id="cb7-598"><a href="#cb7-598" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-599"><a href="#cb7-599" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-600"><a href="#cb7-600" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-601"><a href="#cb7-601" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-602"><a href="#cb7-602" aria-hidden="true" tabindex="-1"></a>  InOutVec y<span class="op">)</span>;</span>
<span id="cb7-603"><a href="#cb7-603" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-604"><a href="#cb7-604" aria-hidden="true" tabindex="-1"></a><span class="co">// Updating triangular matrix-vector product</span></span>
<span id="cb7-605"><a href="#cb7-605" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-606"><a href="#cb7-606" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-607"><a href="#cb7-607" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-608"><a href="#cb7-608" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb7-609"><a href="#cb7-609" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-610"><a href="#cb7-610" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb7-611"><a href="#cb7-611" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_product<span class="op">(</span>InMat A,</span>
<span id="cb7-612"><a href="#cb7-612" aria-hidden="true" tabindex="-1"></a>                                      Triangle t,</span>
<span id="cb7-613"><a href="#cb7-613" aria-hidden="true" tabindex="-1"></a>                                      DiagonalStorage d,</span>
<span id="cb7-614"><a href="#cb7-614" aria-hidden="true" tabindex="-1"></a>                                      InVec1 x,</span>
<span id="cb7-615"><a href="#cb7-615" aria-hidden="true" tabindex="-1"></a>                                      InVec2 y,</span>
<span id="cb7-616"><a href="#cb7-616" aria-hidden="true" tabindex="-1"></a>                                      OutVec z<span class="op">)</span>;</span>
<span id="cb7-617"><a href="#cb7-617" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-618"><a href="#cb7-618" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-619"><a href="#cb7-619" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-620"><a href="#cb7-620" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-621"><a href="#cb7-621" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb7-622"><a href="#cb7-622" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-623"><a href="#cb7-623" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb7-624"><a href="#cb7-624" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_product<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-625"><a href="#cb7-625" aria-hidden="true" tabindex="-1"></a>                                      InMat A,</span>
<span id="cb7-626"><a href="#cb7-626" aria-hidden="true" tabindex="-1"></a>                                      Triangle t,</span>
<span id="cb7-627"><a href="#cb7-627" aria-hidden="true" tabindex="-1"></a>                                      DiagonalStorage d,</span>
<span id="cb7-628"><a href="#cb7-628" aria-hidden="true" tabindex="-1"></a>                                      InVec1 x,</span>
<span id="cb7-629"><a href="#cb7-629" aria-hidden="true" tabindex="-1"></a>                                      InVec2 y,</span>
<span id="cb7-630"><a href="#cb7-630" aria-hidden="true" tabindex="-1"></a>                                      OutVec z<span class="op">)</span>;</span>
<span id="cb7-631"><a href="#cb7-631" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-632"><a href="#cb7-632" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas2.trsv],</span></span>
<span id="cb7-633"><a href="#cb7-633" aria-hidden="true" tabindex="-1"></a><span class="co">// Solve a triangular linear system</span></span>
<span id="cb7-634"><a href="#cb7-634" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-635"><a href="#cb7-635" aria-hidden="true" tabindex="-1"></a><span class="co">// Solve a triangular linear system, not in place</span></span>
<span id="cb7-636"><a href="#cb7-636" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-637"><a href="#cb7-637" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-638"><a href="#cb7-638" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-639"><a href="#cb7-639" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-640"><a href="#cb7-640" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec,</span>
<span id="cb7-641"><a href="#cb7-641" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb7-642"><a href="#cb7-642" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_solve<span class="op">(</span></span>
<span id="cb7-643"><a href="#cb7-643" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-644"><a href="#cb7-644" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-645"><a href="#cb7-645" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-646"><a href="#cb7-646" aria-hidden="true" tabindex="-1"></a>  InVec b,</span>
<span id="cb7-647"><a href="#cb7-647" aria-hidden="true" tabindex="-1"></a>  OutVec x,</span>
<span id="cb7-648"><a href="#cb7-648" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span>
<span id="cb7-649"><a href="#cb7-649" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-650"><a href="#cb7-650" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-651"><a href="#cb7-651" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-652"><a href="#cb7-652" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-653"><a href="#cb7-653" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-654"><a href="#cb7-654" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec,</span>
<span id="cb7-655"><a href="#cb7-655" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb7-656"><a href="#cb7-656" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_solve<span class="op">(</span></span>
<span id="cb7-657"><a href="#cb7-657" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-658"><a href="#cb7-658" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-659"><a href="#cb7-659" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-660"><a href="#cb7-660" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-661"><a href="#cb7-661" aria-hidden="true" tabindex="-1"></a>  InVec b,</span>
<span id="cb7-662"><a href="#cb7-662" aria-hidden="true" tabindex="-1"></a>  OutVec x,</span>
<span id="cb7-663"><a href="#cb7-663" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span>
<span id="cb7-664"><a href="#cb7-664" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-665"><a href="#cb7-665" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-666"><a href="#cb7-666" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-667"><a href="#cb7-667" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-668"><a href="#cb7-668" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb7-669"><a href="#cb7-669" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_solve<span class="op">(</span></span>
<span id="cb7-670"><a href="#cb7-670" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-671"><a href="#cb7-671" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-672"><a href="#cb7-672" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-673"><a href="#cb7-673" aria-hidden="true" tabindex="-1"></a>  InVec b,</span>
<span id="cb7-674"><a href="#cb7-674" aria-hidden="true" tabindex="-1"></a>  OutVec x<span class="op">)</span>;</span>
<span id="cb7-675"><a href="#cb7-675" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-676"><a href="#cb7-676" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-677"><a href="#cb7-677" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-678"><a href="#cb7-678" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-679"><a href="#cb7-679" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-680"><a href="#cb7-680" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb7-681"><a href="#cb7-681" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_solve<span class="op">(</span></span>
<span id="cb7-682"><a href="#cb7-682" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-683"><a href="#cb7-683" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-684"><a href="#cb7-684" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-685"><a href="#cb7-685" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-686"><a href="#cb7-686" aria-hidden="true" tabindex="-1"></a>  InVec b,</span>
<span id="cb7-687"><a href="#cb7-687" aria-hidden="true" tabindex="-1"></a>  OutVec x<span class="op">)</span>;</span>
<span id="cb7-688"><a href="#cb7-688" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-689"><a href="#cb7-689" aria-hidden="true" tabindex="-1"></a><span class="co">// Solve a triangular linear system, in place</span></span>
<span id="cb7-690"><a href="#cb7-690" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-691"><a href="#cb7-691" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-692"><a href="#cb7-692" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-693"><a href="#cb7-693" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec,</span>
<span id="cb7-694"><a href="#cb7-694" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb7-695"><a href="#cb7-695" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_solve<span class="op">(</span></span>
<span id="cb7-696"><a href="#cb7-696" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-697"><a href="#cb7-697" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-698"><a href="#cb7-698" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-699"><a href="#cb7-699" aria-hidden="true" tabindex="-1"></a>  InOutVec b,</span>
<span id="cb7-700"><a href="#cb7-700" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span>
<span id="cb7-701"><a href="#cb7-701" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-702"><a href="#cb7-702" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-703"><a href="#cb7-703" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-704"><a href="#cb7-704" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-705"><a href="#cb7-705" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec,</span>
<span id="cb7-706"><a href="#cb7-706" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb7-707"><a href="#cb7-707" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_solve<span class="op">(</span></span>
<span id="cb7-708"><a href="#cb7-708" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-709"><a href="#cb7-709" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-710"><a href="#cb7-710" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-711"><a href="#cb7-711" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-712"><a href="#cb7-712" aria-hidden="true" tabindex="-1"></a>  InOutVec b,</span>
<span id="cb7-713"><a href="#cb7-713" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span>
<span id="cb7-714"><a href="#cb7-714" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-715"><a href="#cb7-715" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-716"><a href="#cb7-716" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-717"><a href="#cb7-717" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec<span class="op">&gt;</span></span>
<span id="cb7-718"><a href="#cb7-718" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_solve<span class="op">(</span></span>
<span id="cb7-719"><a href="#cb7-719" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-720"><a href="#cb7-720" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-721"><a href="#cb7-721" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-722"><a href="#cb7-722" aria-hidden="true" tabindex="-1"></a>  InOutVec b<span class="op">)</span>;</span>
<span id="cb7-723"><a href="#cb7-723" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-724"><a href="#cb7-724" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-725"><a href="#cb7-725" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-726"><a href="#cb7-726" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-727"><a href="#cb7-727" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec<span class="op">&gt;</span></span>
<span id="cb7-728"><a href="#cb7-728" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_solve<span class="op">(</span></span>
<span id="cb7-729"><a href="#cb7-729" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-730"><a href="#cb7-730" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-731"><a href="#cb7-731" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-732"><a href="#cb7-732" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-733"><a href="#cb7-733" aria-hidden="true" tabindex="-1"></a>  InOutVec b<span class="op">)</span>;</span>
<span id="cb7-734"><a href="#cb7-734" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-735"><a href="#cb7-735" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas2.rank1],</span></span>
<span id="cb7-736"><a href="#cb7-736" aria-hidden="true" tabindex="-1"></a><span class="co">// nonsymmetric rank-1 matrix update</span></span>
<span id="cb7-737"><a href="#cb7-737" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec1,</span>
<span id="cb7-738"><a href="#cb7-738" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-739"><a href="#cb7-739" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb7-740"><a href="#cb7-740" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_rank_1_update<span class="op">(</span></span>
<span id="cb7-741"><a href="#cb7-741" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb7-742"><a href="#cb7-742" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb7-743"><a href="#cb7-743" aria-hidden="true" tabindex="-1"></a>  InOutMat A<span class="op">)</span>;</span>
<span id="cb7-744"><a href="#cb7-744" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-745"><a href="#cb7-745" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb7-746"><a href="#cb7-746" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-747"><a href="#cb7-747" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb7-748"><a href="#cb7-748" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_rank_1_update<span class="op">(</span></span>
<span id="cb7-749"><a href="#cb7-749" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-750"><a href="#cb7-750" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb7-751"><a href="#cb7-751" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb7-752"><a href="#cb7-752" aria-hidden="true" tabindex="-1"></a>  InOutMat A<span class="op">)</span>;</span>
<span id="cb7-753"><a href="#cb7-753" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-754"><a href="#cb7-754" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec1,</span>
<span id="cb7-755"><a href="#cb7-755" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-756"><a href="#cb7-756" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb7-757"><a href="#cb7-757" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_rank_1_update_c<span class="op">(</span></span>
<span id="cb7-758"><a href="#cb7-758" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb7-759"><a href="#cb7-759" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb7-760"><a href="#cb7-760" aria-hidden="true" tabindex="-1"></a>  InOutMat A<span class="op">)</span>;</span>
<span id="cb7-761"><a href="#cb7-761" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-762"><a href="#cb7-762" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb7-763"><a href="#cb7-763" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-764"><a href="#cb7-764" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb7-765"><a href="#cb7-765" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_rank_1_update_c<span class="op">(</span></span>
<span id="cb7-766"><a href="#cb7-766" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-767"><a href="#cb7-767" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb7-768"><a href="#cb7-768" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb7-769"><a href="#cb7-769" aria-hidden="true" tabindex="-1"></a>  InOutMat A<span class="op">)</span>;</span>
<span id="cb7-770"><a href="#cb7-770" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-771"><a href="#cb7-771" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas2.symherrank1],</span></span>
<span id="cb7-772"><a href="#cb7-772" aria-hidden="true" tabindex="-1"></a><span class="co">// symmetric or Hermitian rank-1 matrix update</span></span>
<span id="cb7-773"><a href="#cb7-773" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec,</span>
<span id="cb7-774"><a href="#cb7-774" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-775"><a href="#cb7-775" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-776"><a href="#cb7-776" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_1_update<span class="op">(</span></span>
<span id="cb7-777"><a href="#cb7-777" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb7-778"><a href="#cb7-778" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb7-779"><a href="#cb7-779" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-780"><a href="#cb7-780" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-781"><a href="#cb7-781" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-782"><a href="#cb7-782" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-783"><a href="#cb7-783" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-784"><a href="#cb7-784" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_1_update<span class="op">(</span></span>
<span id="cb7-785"><a href="#cb7-785" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-786"><a href="#cb7-786" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb7-787"><a href="#cb7-787" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb7-788"><a href="#cb7-788" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-789"><a href="#cb7-789" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Scalar,</span>
<span id="cb7-790"><a href="#cb7-790" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-791"><a href="#cb7-791" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-792"><a href="#cb7-792" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-793"><a href="#cb7-793" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_1_update<span class="op">(</span></span>
<span id="cb7-794"><a href="#cb7-794" aria-hidden="true" tabindex="-1"></a>  Scalar alpha,</span>
<span id="cb7-795"><a href="#cb7-795" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb7-796"><a href="#cb7-796" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb7-797"><a href="#cb7-797" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-798"><a href="#cb7-798" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-799"><a href="#cb7-799" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar,</span>
<span id="cb7-800"><a href="#cb7-800" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-801"><a href="#cb7-801" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-802"><a href="#cb7-802" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-803"><a href="#cb7-803" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_1_update<span class="op">(</span></span>
<span id="cb7-804"><a href="#cb7-804" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-805"><a href="#cb7-805" aria-hidden="true" tabindex="-1"></a>  Scalar alpha,</span>
<span id="cb7-806"><a href="#cb7-806" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb7-807"><a href="#cb7-807" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb7-808"><a href="#cb7-808" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-809"><a href="#cb7-809" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-810"><a href="#cb7-810" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec,</span>
<span id="cb7-811"><a href="#cb7-811" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-812"><a href="#cb7-812" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-813"><a href="#cb7-813" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_1_update<span class="op">(</span></span>
<span id="cb7-814"><a href="#cb7-814" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb7-815"><a href="#cb7-815" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb7-816"><a href="#cb7-816" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-817"><a href="#cb7-817" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-818"><a href="#cb7-818" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-819"><a href="#cb7-819" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-820"><a href="#cb7-820" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-821"><a href="#cb7-821" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_1_update<span class="op">(</span></span>
<span id="cb7-822"><a href="#cb7-822" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-823"><a href="#cb7-823" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb7-824"><a href="#cb7-824" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb7-825"><a href="#cb7-825" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-826"><a href="#cb7-826" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Scalar,</span>
<span id="cb7-827"><a href="#cb7-827" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-828"><a href="#cb7-828" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-829"><a href="#cb7-829" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-830"><a href="#cb7-830" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_1_update<span class="op">(</span></span>
<span id="cb7-831"><a href="#cb7-831" aria-hidden="true" tabindex="-1"></a>  Scalar alpha,</span>
<span id="cb7-832"><a href="#cb7-832" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb7-833"><a href="#cb7-833" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb7-834"><a href="#cb7-834" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-835"><a href="#cb7-835" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-836"><a href="#cb7-836" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar,</span>
<span id="cb7-837"><a href="#cb7-837" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb7-838"><a href="#cb7-838" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-839"><a href="#cb7-839" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-840"><a href="#cb7-840" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_1_update<span class="op">(</span></span>
<span id="cb7-841"><a href="#cb7-841" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-842"><a href="#cb7-842" aria-hidden="true" tabindex="-1"></a>  Scalar alpha,</span>
<span id="cb7-843"><a href="#cb7-843" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb7-844"><a href="#cb7-844" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb7-845"><a href="#cb7-845" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-846"><a href="#cb7-846" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-847"><a href="#cb7-847" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas2.rank2],</span></span>
<span id="cb7-848"><a href="#cb7-848" aria-hidden="true" tabindex="-1"></a><span class="co">// Symmetric and Hermitian rank-2 matrix updates</span></span>
<span id="cb7-849"><a href="#cb7-849" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-850"><a href="#cb7-850" aria-hidden="true" tabindex="-1"></a><span class="co">// symmetric rank-2 matrix update</span></span>
<span id="cb7-851"><a href="#cb7-851" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec1,</span>
<span id="cb7-852"><a href="#cb7-852" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-853"><a href="#cb7-853" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-854"><a href="#cb7-854" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-855"><a href="#cb7-855" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_2_update<span class="op">(</span></span>
<span id="cb7-856"><a href="#cb7-856" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb7-857"><a href="#cb7-857" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb7-858"><a href="#cb7-858" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb7-859"><a href="#cb7-859" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-860"><a href="#cb7-860" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-861"><a href="#cb7-861" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb7-862"><a href="#cb7-862" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-863"><a href="#cb7-863" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-864"><a href="#cb7-864" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-865"><a href="#cb7-865" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_2_update<span class="op">(</span></span>
<span id="cb7-866"><a href="#cb7-866" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-867"><a href="#cb7-867" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb7-868"><a href="#cb7-868" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb7-869"><a href="#cb7-869" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb7-870"><a href="#cb7-870" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-871"><a href="#cb7-871" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-872"><a href="#cb7-872" aria-hidden="true" tabindex="-1"></a><span class="co">// Hermitian rank-2 matrix update</span></span>
<span id="cb7-873"><a href="#cb7-873" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec1,</span>
<span id="cb7-874"><a href="#cb7-874" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-875"><a href="#cb7-875" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-876"><a href="#cb7-876" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-877"><a href="#cb7-877" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_2_update<span class="op">(</span></span>
<span id="cb7-878"><a href="#cb7-878" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb7-879"><a href="#cb7-879" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb7-880"><a href="#cb7-880" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb7-881"><a href="#cb7-881" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-882"><a href="#cb7-882" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-883"><a href="#cb7-883" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb7-884"><a href="#cb7-884" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb7-885"><a href="#cb7-885" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-886"><a href="#cb7-886" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-887"><a href="#cb7-887" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_2_update<span class="op">(</span></span>
<span id="cb7-888"><a href="#cb7-888" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-889"><a href="#cb7-889" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb7-890"><a href="#cb7-890" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb7-891"><a href="#cb7-891" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb7-892"><a href="#cb7-892" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-893"><a href="#cb7-893" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-894"><a href="#cb7-894" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas3], BLAS 3 algorithms</span></span>
<span id="cb7-895"><a href="#cb7-895" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-896"><a href="#cb7-896" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas3.gemm],</span></span>
<span id="cb7-897"><a href="#cb7-897" aria-hidden="true" tabindex="-1"></a><span class="co">// general matrix-matrix product</span></span>
<span id="cb7-898"><a href="#cb7-898" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-899"><a href="#cb7-899" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-900"><a href="#cb7-900" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-901"><a href="#cb7-901" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_product<span class="op">(</span>InMat1 A,</span>
<span id="cb7-902"><a href="#cb7-902" aria-hidden="true" tabindex="-1"></a>                    InMat2 B,</span>
<span id="cb7-903"><a href="#cb7-903" aria-hidden="true" tabindex="-1"></a>                    OutMat C<span class="op">)</span>;</span>
<span id="cb7-904"><a href="#cb7-904" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-905"><a href="#cb7-905" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-906"><a href="#cb7-906" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-907"><a href="#cb7-907" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-908"><a href="#cb7-908" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_product<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-909"><a href="#cb7-909" aria-hidden="true" tabindex="-1"></a>                    InMat1 A,</span>
<span id="cb7-910"><a href="#cb7-910" aria-hidden="true" tabindex="-1"></a>                    InMat2 B,</span>
<span id="cb7-911"><a href="#cb7-911" aria-hidden="true" tabindex="-1"></a>                    OutMat C<span class="op">)</span>;</span>
<span id="cb7-912"><a href="#cb7-912" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-913"><a href="#cb7-913" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-914"><a href="#cb7-914" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb7-915"><a href="#cb7-915" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-916"><a href="#cb7-916" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_product<span class="op">(</span>InMat1 A,</span>
<span id="cb7-917"><a href="#cb7-917" aria-hidden="true" tabindex="-1"></a>                    InMat2 B,</span>
<span id="cb7-918"><a href="#cb7-918" aria-hidden="true" tabindex="-1"></a>                    InMat3 E,</span>
<span id="cb7-919"><a href="#cb7-919" aria-hidden="true" tabindex="-1"></a>                    OutMat C<span class="op">)</span>;</span>
<span id="cb7-920"><a href="#cb7-920" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-921"><a href="#cb7-921" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-922"><a href="#cb7-922" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-923"><a href="#cb7-923" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb7-924"><a href="#cb7-924" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-925"><a href="#cb7-925" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_product<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-926"><a href="#cb7-926" aria-hidden="true" tabindex="-1"></a>                    InMat1 A,</span>
<span id="cb7-927"><a href="#cb7-927" aria-hidden="true" tabindex="-1"></a>                    InMat2 B,</span>
<span id="cb7-928"><a href="#cb7-928" aria-hidden="true" tabindex="-1"></a>                    InMat3 E,</span>
<span id="cb7-929"><a href="#cb7-929" aria-hidden="true" tabindex="-1"></a>                    OutMat C<span class="op">)</span>;</span>
<span id="cb7-930"><a href="#cb7-930" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-931"><a href="#cb7-931" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas3.xxmm],</span></span>
<span id="cb7-932"><a href="#cb7-932" aria-hidden="true" tabindex="-1"></a><span class="co">// symmetric, Hermitian, and triangular matrix-matrix product</span></span>
<span id="cb7-933"><a href="#cb7-933" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-934"><a href="#cb7-934" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-935"><a href="#cb7-935" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-936"><a href="#cb7-936" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-937"><a href="#cb7-937" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-938"><a href="#cb7-938" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_product<span class="op">(</span></span>
<span id="cb7-939"><a href="#cb7-939" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-940"><a href="#cb7-940" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-941"><a href="#cb7-941" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-942"><a href="#cb7-942" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-943"><a href="#cb7-943" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-944"><a href="#cb7-944" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-945"><a href="#cb7-945" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-946"><a href="#cb7-946" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-947"><a href="#cb7-947" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-948"><a href="#cb7-948" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_product<span class="op">(</span></span>
<span id="cb7-949"><a href="#cb7-949" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-950"><a href="#cb7-950" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-951"><a href="#cb7-951" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-952"><a href="#cb7-952" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-953"><a href="#cb7-953" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-954"><a href="#cb7-954" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-955"><a href="#cb7-955" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-956"><a href="#cb7-956" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-957"><a href="#cb7-957" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-958"><a href="#cb7-958" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-959"><a href="#cb7-959" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_product<span class="op">(</span></span>
<span id="cb7-960"><a href="#cb7-960" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-961"><a href="#cb7-961" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-962"><a href="#cb7-962" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-963"><a href="#cb7-963" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-964"><a href="#cb7-964" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-965"><a href="#cb7-965" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-966"><a href="#cb7-966" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-967"><a href="#cb7-967" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-968"><a href="#cb7-968" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-969"><a href="#cb7-969" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_product<span class="op">(</span></span>
<span id="cb7-970"><a href="#cb7-970" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-971"><a href="#cb7-971" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-972"><a href="#cb7-972" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-973"><a href="#cb7-973" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-974"><a href="#cb7-974" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-975"><a href="#cb7-975" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-976"><a href="#cb7-976" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-977"><a href="#cb7-977" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-978"><a href="#cb7-978" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-979"><a href="#cb7-979" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-980"><a href="#cb7-980" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-981"><a href="#cb7-981" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_product<span class="op">(</span></span>
<span id="cb7-982"><a href="#cb7-982" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-983"><a href="#cb7-983" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-984"><a href="#cb7-984" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-985"><a href="#cb7-985" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-986"><a href="#cb7-986" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-987"><a href="#cb7-987" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-988"><a href="#cb7-988" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-989"><a href="#cb7-989" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-990"><a href="#cb7-990" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-991"><a href="#cb7-991" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-992"><a href="#cb7-992" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-993"><a href="#cb7-993" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_product<span class="op">(</span></span>
<span id="cb7-994"><a href="#cb7-994" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-995"><a href="#cb7-995" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-996"><a href="#cb7-996" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-997"><a href="#cb7-997" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-998"><a href="#cb7-998" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-999"><a href="#cb7-999" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1000"><a href="#cb7-1000" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1001"><a href="#cb7-1001" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-1002"><a href="#cb7-1002" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1003"><a href="#cb7-1003" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1004"><a href="#cb7-1004" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1005"><a href="#cb7-1005" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_product<span class="op">(</span></span>
<span id="cb7-1006"><a href="#cb7-1006" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1007"><a href="#cb7-1007" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1008"><a href="#cb7-1008" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1009"><a href="#cb7-1009" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1010"><a href="#cb7-1010" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1011"><a href="#cb7-1011" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-1012"><a href="#cb7-1012" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1013"><a href="#cb7-1013" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1014"><a href="#cb7-1014" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1015"><a href="#cb7-1015" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_product<span class="op">(</span></span>
<span id="cb7-1016"><a href="#cb7-1016" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1017"><a href="#cb7-1017" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1018"><a href="#cb7-1018" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1019"><a href="#cb7-1019" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1020"><a href="#cb7-1020" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1021"><a href="#cb7-1021" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1022"><a href="#cb7-1022" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-1023"><a href="#cb7-1023" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1024"><a href="#cb7-1024" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1025"><a href="#cb7-1025" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1026"><a href="#cb7-1026" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_product<span class="op">(</span></span>
<span id="cb7-1027"><a href="#cb7-1027" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1028"><a href="#cb7-1028" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1029"><a href="#cb7-1029" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1030"><a href="#cb7-1030" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1031"><a href="#cb7-1031" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1032"><a href="#cb7-1032" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-1033"><a href="#cb7-1033" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1034"><a href="#cb7-1034" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1035"><a href="#cb7-1035" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1036"><a href="#cb7-1036" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_product<span class="op">(</span></span>
<span id="cb7-1037"><a href="#cb7-1037" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1038"><a href="#cb7-1038" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1039"><a href="#cb7-1039" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1040"><a href="#cb7-1040" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1041"><a href="#cb7-1041" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1042"><a href="#cb7-1042" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1043"><a href="#cb7-1043" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-1044"><a href="#cb7-1044" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1045"><a href="#cb7-1045" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1046"><a href="#cb7-1046" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1047"><a href="#cb7-1047" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1048"><a href="#cb7-1048" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_product<span class="op">(</span></span>
<span id="cb7-1049"><a href="#cb7-1049" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1050"><a href="#cb7-1050" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1051"><a href="#cb7-1051" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1052"><a href="#cb7-1052" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1053"><a href="#cb7-1053" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1054"><a href="#cb7-1054" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1055"><a href="#cb7-1055" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-1056"><a href="#cb7-1056" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1057"><a href="#cb7-1057" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1058"><a href="#cb7-1058" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1059"><a href="#cb7-1059" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1060"><a href="#cb7-1060" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_product<span class="op">(</span></span>
<span id="cb7-1061"><a href="#cb7-1061" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1062"><a href="#cb7-1062" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1063"><a href="#cb7-1063" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1064"><a href="#cb7-1064" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1065"><a href="#cb7-1065" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1066"><a href="#cb7-1066" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1067"><a href="#cb7-1067" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1068"><a href="#cb7-1068" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-1069"><a href="#cb7-1069" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1070"><a href="#cb7-1070" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1071"><a href="#cb7-1071" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb7-1072"><a href="#cb7-1072" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1073"><a href="#cb7-1073" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_product<span class="op">(</span></span>
<span id="cb7-1074"><a href="#cb7-1074" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1075"><a href="#cb7-1075" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1076"><a href="#cb7-1076" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1077"><a href="#cb7-1077" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb7-1078"><a href="#cb7-1078" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1079"><a href="#cb7-1079" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1080"><a href="#cb7-1080" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-1081"><a href="#cb7-1081" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1082"><a href="#cb7-1082" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1083"><a href="#cb7-1083" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb7-1084"><a href="#cb7-1084" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1085"><a href="#cb7-1085" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_product<span class="op">(</span></span>
<span id="cb7-1086"><a href="#cb7-1086" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1087"><a href="#cb7-1087" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1088"><a href="#cb7-1088" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1089"><a href="#cb7-1089" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1090"><a href="#cb7-1090" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb7-1091"><a href="#cb7-1091" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1092"><a href="#cb7-1092" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1093"><a href="#cb7-1093" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-1094"><a href="#cb7-1094" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1095"><a href="#cb7-1095" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1096"><a href="#cb7-1096" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb7-1097"><a href="#cb7-1097" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1098"><a href="#cb7-1098" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_product<span class="op">(</span></span>
<span id="cb7-1099"><a href="#cb7-1099" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1100"><a href="#cb7-1100" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1101"><a href="#cb7-1101" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1102"><a href="#cb7-1102" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb7-1103"><a href="#cb7-1103" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1104"><a href="#cb7-1104" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1105"><a href="#cb7-1105" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-1106"><a href="#cb7-1106" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1107"><a href="#cb7-1107" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1108"><a href="#cb7-1108" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb7-1109"><a href="#cb7-1109" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1110"><a href="#cb7-1110" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_product<span class="op">(</span></span>
<span id="cb7-1111"><a href="#cb7-1111" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1112"><a href="#cb7-1112" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1113"><a href="#cb7-1113" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1114"><a href="#cb7-1114" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1115"><a href="#cb7-1115" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb7-1116"><a href="#cb7-1116" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1117"><a href="#cb7-1117" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1118"><a href="#cb7-1118" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-1119"><a href="#cb7-1119" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1120"><a href="#cb7-1120" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1121"><a href="#cb7-1121" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1122"><a href="#cb7-1122" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb7-1123"><a href="#cb7-1123" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1124"><a href="#cb7-1124" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_product<span class="op">(</span></span>
<span id="cb7-1125"><a href="#cb7-1125" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1126"><a href="#cb7-1126" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1127"><a href="#cb7-1127" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1128"><a href="#cb7-1128" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1129"><a href="#cb7-1129" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb7-1130"><a href="#cb7-1130" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1131"><a href="#cb7-1131" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1132"><a href="#cb7-1132" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-1133"><a href="#cb7-1133" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1134"><a href="#cb7-1134" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1135"><a href="#cb7-1135" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1136"><a href="#cb7-1136" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb7-1137"><a href="#cb7-1137" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1138"><a href="#cb7-1138" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_product<span class="op">(</span></span>
<span id="cb7-1139"><a href="#cb7-1139" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1140"><a href="#cb7-1140" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1141"><a href="#cb7-1141" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1142"><a href="#cb7-1142" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1143"><a href="#cb7-1143" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1144"><a href="#cb7-1144" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb7-1145"><a href="#cb7-1145" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1146"><a href="#cb7-1146" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1147"><a href="#cb7-1147" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-1148"><a href="#cb7-1148" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1149"><a href="#cb7-1149" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1150"><a href="#cb7-1150" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb7-1151"><a href="#cb7-1151" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1152"><a href="#cb7-1152" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_product<span class="op">(</span></span>
<span id="cb7-1153"><a href="#cb7-1153" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1154"><a href="#cb7-1154" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1155"><a href="#cb7-1155" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1156"><a href="#cb7-1156" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb7-1157"><a href="#cb7-1157" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1158"><a href="#cb7-1158" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1159"><a href="#cb7-1159" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-1160"><a href="#cb7-1160" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1161"><a href="#cb7-1161" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1162"><a href="#cb7-1162" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb7-1163"><a href="#cb7-1163" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1164"><a href="#cb7-1164" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_product<span class="op">(</span></span>
<span id="cb7-1165"><a href="#cb7-1165" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1166"><a href="#cb7-1166" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1167"><a href="#cb7-1167" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1168"><a href="#cb7-1168" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1169"><a href="#cb7-1169" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb7-1170"><a href="#cb7-1170" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1171"><a href="#cb7-1171" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1172"><a href="#cb7-1172" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-1173"><a href="#cb7-1173" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1174"><a href="#cb7-1174" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1175"><a href="#cb7-1175" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb7-1176"><a href="#cb7-1176" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1177"><a href="#cb7-1177" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_product<span class="op">(</span></span>
<span id="cb7-1178"><a href="#cb7-1178" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1179"><a href="#cb7-1179" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1180"><a href="#cb7-1180" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1181"><a href="#cb7-1181" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb7-1182"><a href="#cb7-1182" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1183"><a href="#cb7-1183" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1184"><a href="#cb7-1184" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-1185"><a href="#cb7-1185" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1186"><a href="#cb7-1186" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1187"><a href="#cb7-1187" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb7-1188"><a href="#cb7-1188" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1189"><a href="#cb7-1189" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_product<span class="op">(</span></span>
<span id="cb7-1190"><a href="#cb7-1190" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1191"><a href="#cb7-1191" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1192"><a href="#cb7-1192" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1193"><a href="#cb7-1193" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1194"><a href="#cb7-1194" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb7-1195"><a href="#cb7-1195" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1196"><a href="#cb7-1196" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1197"><a href="#cb7-1197" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-1198"><a href="#cb7-1198" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1199"><a href="#cb7-1199" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1200"><a href="#cb7-1200" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1201"><a href="#cb7-1201" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb7-1202"><a href="#cb7-1202" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1203"><a href="#cb7-1203" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_product<span class="op">(</span></span>
<span id="cb7-1204"><a href="#cb7-1204" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1205"><a href="#cb7-1205" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1206"><a href="#cb7-1206" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1207"><a href="#cb7-1207" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1208"><a href="#cb7-1208" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb7-1209"><a href="#cb7-1209" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1210"><a href="#cb7-1210" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1211"><a href="#cb7-1211" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-1212"><a href="#cb7-1212" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1213"><a href="#cb7-1213" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1214"><a href="#cb7-1214" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1215"><a href="#cb7-1215" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb7-1216"><a href="#cb7-1216" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1217"><a href="#cb7-1217" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_product<span class="op">(</span></span>
<span id="cb7-1218"><a href="#cb7-1218" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1219"><a href="#cb7-1219" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1220"><a href="#cb7-1220" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1221"><a href="#cb7-1221" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1222"><a href="#cb7-1222" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1223"><a href="#cb7-1223" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb7-1224"><a href="#cb7-1224" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb7-1225"><a href="#cb7-1225" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1226"><a href="#cb7-1226" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas3.trmm],</span></span>
<span id="cb7-1227"><a href="#cb7-1227" aria-hidden="true" tabindex="-1"></a><span class="co">// in-place triangular matrix-matrix product</span></span>
<span id="cb7-1228"><a href="#cb7-1228" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1229"><a href="#cb7-1229" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-1230"><a href="#cb7-1230" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1231"><a href="#cb7-1231" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1232"><a href="#cb7-1232" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb7-1233"><a href="#cb7-1233" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_left_product<span class="op">(</span></span>
<span id="cb7-1234"><a href="#cb7-1234" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1235"><a href="#cb7-1235" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1236"><a href="#cb7-1236" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1237"><a href="#cb7-1237" aria-hidden="true" tabindex="-1"></a>  InOutMat C<span class="op">)</span>;</span>
<span id="cb7-1238"><a href="#cb7-1238" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1239"><a href="#cb7-1239" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-1240"><a href="#cb7-1240" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1241"><a href="#cb7-1241" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1242"><a href="#cb7-1242" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb7-1243"><a href="#cb7-1243" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_left_product<span class="op">(</span></span>
<span id="cb7-1244"><a href="#cb7-1244" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1245"><a href="#cb7-1245" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1246"><a href="#cb7-1246" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1247"><a href="#cb7-1247" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1248"><a href="#cb7-1248" aria-hidden="true" tabindex="-1"></a>  InOutMat C<span class="op">)</span>;</span>
<span id="cb7-1249"><a href="#cb7-1249" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1250"><a href="#cb7-1250" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-1251"><a href="#cb7-1251" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1252"><a href="#cb7-1252" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1253"><a href="#cb7-1253" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb7-1254"><a href="#cb7-1254" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_right_product<span class="op">(</span></span>
<span id="cb7-1255"><a href="#cb7-1255" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1256"><a href="#cb7-1256" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1257"><a href="#cb7-1257" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1258"><a href="#cb7-1258" aria-hidden="true" tabindex="-1"></a>  InOutMat C<span class="op">)</span>;</span>
<span id="cb7-1259"><a href="#cb7-1259" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1260"><a href="#cb7-1260" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-1261"><a href="#cb7-1261" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1262"><a href="#cb7-1262" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1263"><a href="#cb7-1263" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb7-1264"><a href="#cb7-1264" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_right_product<span class="op">(</span></span>
<span id="cb7-1265"><a href="#cb7-1265" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1266"><a href="#cb7-1266" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1267"><a href="#cb7-1267" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1268"><a href="#cb7-1268" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1269"><a href="#cb7-1269" aria-hidden="true" tabindex="-1"></a>  InOutMat C<span class="op">)</span>;</span>
<span id="cb7-1270"><a href="#cb7-1270" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1271"><a href="#cb7-1271" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas3.rankk],</span></span>
<span id="cb7-1272"><a href="#cb7-1272" aria-hidden="true" tabindex="-1"></a><span class="co">// rank-k update of a symmetric or Hermitian matrix</span></span>
<span id="cb7-1273"><a href="#cb7-1273" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1274"><a href="#cb7-1274" aria-hidden="true" tabindex="-1"></a><span class="co">// rank-k symmetric matrix update</span></span>
<span id="cb7-1275"><a href="#cb7-1275" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Scalar,</span>
<span id="cb7-1276"><a href="#cb7-1276" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-1277"><a href="#cb7-1277" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-1278"><a href="#cb7-1278" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-1279"><a href="#cb7-1279" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_k_update<span class="op">(</span></span>
<span id="cb7-1280"><a href="#cb7-1280" aria-hidden="true" tabindex="-1"></a>  Scalar alpha,</span>
<span id="cb7-1281"><a href="#cb7-1281" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1282"><a href="#cb7-1282" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb7-1283"><a href="#cb7-1283" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-1284"><a href="#cb7-1284" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Scalar,</span>
<span id="cb7-1285"><a href="#cb7-1285" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1286"><a href="#cb7-1286" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-1287"><a href="#cb7-1287" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-1288"><a href="#cb7-1288" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-1289"><a href="#cb7-1289" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_k_update<span class="op">(</span></span>
<span id="cb7-1290"><a href="#cb7-1290" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1291"><a href="#cb7-1291" aria-hidden="true" tabindex="-1"></a>  Scalar alpha,</span>
<span id="cb7-1292"><a href="#cb7-1292" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1293"><a href="#cb7-1293" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb7-1294"><a href="#cb7-1294" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-1295"><a href="#cb7-1295" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1296"><a href="#cb7-1296" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-1297"><a href="#cb7-1297" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-1298"><a href="#cb7-1298" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-1299"><a href="#cb7-1299" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_k_update<span class="op">(</span></span>
<span id="cb7-1300"><a href="#cb7-1300" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1301"><a href="#cb7-1301" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb7-1302"><a href="#cb7-1302" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-1303"><a href="#cb7-1303" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1304"><a href="#cb7-1304" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-1305"><a href="#cb7-1305" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-1306"><a href="#cb7-1306" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-1307"><a href="#cb7-1307" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_k_update<span class="op">(</span></span>
<span id="cb7-1308"><a href="#cb7-1308" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1309"><a href="#cb7-1309" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1310"><a href="#cb7-1310" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb7-1311"><a href="#cb7-1311" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-1312"><a href="#cb7-1312" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1313"><a href="#cb7-1313" aria-hidden="true" tabindex="-1"></a><span class="co">// rank-k Hermitian matrix update</span></span>
<span id="cb7-1314"><a href="#cb7-1314" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Scalar,</span>
<span id="cb7-1315"><a href="#cb7-1315" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-1316"><a href="#cb7-1316" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-1317"><a href="#cb7-1317" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-1318"><a href="#cb7-1318" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_k_update<span class="op">(</span></span>
<span id="cb7-1319"><a href="#cb7-1319" aria-hidden="true" tabindex="-1"></a>  Scalar alpha,</span>
<span id="cb7-1320"><a href="#cb7-1320" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1321"><a href="#cb7-1321" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb7-1322"><a href="#cb7-1322" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-1323"><a href="#cb7-1323" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1324"><a href="#cb7-1324" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar,</span>
<span id="cb7-1325"><a href="#cb7-1325" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-1326"><a href="#cb7-1326" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-1327"><a href="#cb7-1327" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-1328"><a href="#cb7-1328" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_k_update<span class="op">(</span></span>
<span id="cb7-1329"><a href="#cb7-1329" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1330"><a href="#cb7-1330" aria-hidden="true" tabindex="-1"></a>  Scalar alpha,</span>
<span id="cb7-1331"><a href="#cb7-1331" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1332"><a href="#cb7-1332" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb7-1333"><a href="#cb7-1333" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-1334"><a href="#cb7-1334" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1335"><a href="#cb7-1335" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-1336"><a href="#cb7-1336" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-1337"><a href="#cb7-1337" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-1338"><a href="#cb7-1338" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_k_update<span class="op">(</span></span>
<span id="cb7-1339"><a href="#cb7-1339" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1340"><a href="#cb7-1340" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb7-1341"><a href="#cb7-1341" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-1342"><a href="#cb7-1342" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1343"><a href="#cb7-1343" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-1344"><a href="#cb7-1344" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-1345"><a href="#cb7-1345" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-1346"><a href="#cb7-1346" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_k_update<span class="op">(</span></span>
<span id="cb7-1347"><a href="#cb7-1347" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1348"><a href="#cb7-1348" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1349"><a href="#cb7-1349" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb7-1350"><a href="#cb7-1350" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-1351"><a href="#cb7-1351" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1352"><a href="#cb7-1352" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas3.rank2k],</span></span>
<span id="cb7-1353"><a href="#cb7-1353" aria-hidden="true" tabindex="-1"></a><span class="co">// rank-2k update of a symmetric or Hermitian matrix</span></span>
<span id="cb7-1354"><a href="#cb7-1354" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1355"><a href="#cb7-1355" aria-hidden="true" tabindex="-1"></a><span class="co">// rank-2k symmetric matrix update</span></span>
<span id="cb7-1356"><a href="#cb7-1356" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-1357"><a href="#cb7-1357" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1358"><a href="#cb7-1358" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-1359"><a href="#cb7-1359" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-1360"><a href="#cb7-1360" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_2k_update<span class="op">(</span></span>
<span id="cb7-1361"><a href="#cb7-1361" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1362"><a href="#cb7-1362" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1363"><a href="#cb7-1363" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb7-1364"><a href="#cb7-1364" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-1365"><a href="#cb7-1365" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1366"><a href="#cb7-1366" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-1367"><a href="#cb7-1367" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1368"><a href="#cb7-1368" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-1369"><a href="#cb7-1369" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-1370"><a href="#cb7-1370" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_2k_update<span class="op">(</span></span>
<span id="cb7-1371"><a href="#cb7-1371" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1372"><a href="#cb7-1372" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1373"><a href="#cb7-1373" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1374"><a href="#cb7-1374" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb7-1375"><a href="#cb7-1375" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-1376"><a href="#cb7-1376" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1377"><a href="#cb7-1377" aria-hidden="true" tabindex="-1"></a><span class="co">// rank-2k Hermitian matrix update</span></span>
<span id="cb7-1378"><a href="#cb7-1378" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-1379"><a href="#cb7-1379" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1380"><a href="#cb7-1380" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-1381"><a href="#cb7-1381" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-1382"><a href="#cb7-1382" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_2k_update<span class="op">(</span></span>
<span id="cb7-1383"><a href="#cb7-1383" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1384"><a href="#cb7-1384" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1385"><a href="#cb7-1385" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb7-1386"><a href="#cb7-1386" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-1387"><a href="#cb7-1387" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1388"><a href="#cb7-1388" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-1389"><a href="#cb7-1389" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1390"><a href="#cb7-1390" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb7-1391"><a href="#cb7-1391" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb7-1392"><a href="#cb7-1392" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_2k_update<span class="op">(</span></span>
<span id="cb7-1393"><a href="#cb7-1393" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1394"><a href="#cb7-1394" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1395"><a href="#cb7-1395" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1396"><a href="#cb7-1396" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb7-1397"><a href="#cb7-1397" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb7-1398"><a href="#cb7-1398" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1399"><a href="#cb7-1399" aria-hidden="true" tabindex="-1"></a><span class="co">// [linalg.algs.blas3.trsm],</span></span>
<span id="cb7-1400"><a href="#cb7-1400" aria-hidden="true" tabindex="-1"></a><span class="co">// solve multiple triangular linear systems</span></span>
<span id="cb7-1401"><a href="#cb7-1401" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1402"><a href="#cb7-1402" aria-hidden="true" tabindex="-1"></a><span class="co">// solve multiple triangular systems on the left, not-in-place</span></span>
<span id="cb7-1403"><a href="#cb7-1403" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-1404"><a href="#cb7-1404" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1405"><a href="#cb7-1405" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1406"><a href="#cb7-1406" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1407"><a href="#cb7-1407" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat,</span>
<span id="cb7-1408"><a href="#cb7-1408" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb7-1409"><a href="#cb7-1409" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_left_solve<span class="op">(</span></span>
<span id="cb7-1410"><a href="#cb7-1410" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1411"><a href="#cb7-1411" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1412"><a href="#cb7-1412" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1413"><a href="#cb7-1413" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1414"><a href="#cb7-1414" aria-hidden="true" tabindex="-1"></a>  OutMat X,</span>
<span id="cb7-1415"><a href="#cb7-1415" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span>
<span id="cb7-1416"><a href="#cb7-1416" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1417"><a href="#cb7-1417" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-1418"><a href="#cb7-1418" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1419"><a href="#cb7-1419" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1420"><a href="#cb7-1420" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1421"><a href="#cb7-1421" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat,</span>
<span id="cb7-1422"><a href="#cb7-1422" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb7-1423"><a href="#cb7-1423" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_left_solve<span class="op">(</span></span>
<span id="cb7-1424"><a href="#cb7-1424" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1425"><a href="#cb7-1425" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1426"><a href="#cb7-1426" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1427"><a href="#cb7-1427" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1428"><a href="#cb7-1428" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1429"><a href="#cb7-1429" aria-hidden="true" tabindex="-1"></a>  OutMat X,</span>
<span id="cb7-1430"><a href="#cb7-1430" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span>
<span id="cb7-1431"><a href="#cb7-1431" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-1432"><a href="#cb7-1432" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1433"><a href="#cb7-1433" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1434"><a href="#cb7-1434" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1435"><a href="#cb7-1435" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1436"><a href="#cb7-1436" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_left_solve<span class="op">(</span></span>
<span id="cb7-1437"><a href="#cb7-1437" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1438"><a href="#cb7-1438" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1439"><a href="#cb7-1439" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1440"><a href="#cb7-1440" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1441"><a href="#cb7-1441" aria-hidden="true" tabindex="-1"></a>  OutMat X<span class="op">)</span>;</span>
<span id="cb7-1442"><a href="#cb7-1442" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1443"><a href="#cb7-1443" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-1444"><a href="#cb7-1444" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1445"><a href="#cb7-1445" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1446"><a href="#cb7-1446" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1447"><a href="#cb7-1447" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1448"><a href="#cb7-1448" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_left_solve<span class="op">(</span></span>
<span id="cb7-1449"><a href="#cb7-1449" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1450"><a href="#cb7-1450" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1451"><a href="#cb7-1451" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1452"><a href="#cb7-1452" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1453"><a href="#cb7-1453" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1454"><a href="#cb7-1454" aria-hidden="true" tabindex="-1"></a>  OutMat X<span class="op">)</span>;</span>
<span id="cb7-1455"><a href="#cb7-1455" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1456"><a href="#cb7-1456" aria-hidden="true" tabindex="-1"></a><span class="co">// solve multiple triangular systems on the right, not-in-place</span></span>
<span id="cb7-1457"><a href="#cb7-1457" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-1458"><a href="#cb7-1458" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1459"><a href="#cb7-1459" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1460"><a href="#cb7-1460" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1461"><a href="#cb7-1461" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat,</span>
<span id="cb7-1462"><a href="#cb7-1462" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb7-1463"><a href="#cb7-1463" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_right_solve<span class="op">(</span></span>
<span id="cb7-1464"><a href="#cb7-1464" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1465"><a href="#cb7-1465" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1466"><a href="#cb7-1466" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1467"><a href="#cb7-1467" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1468"><a href="#cb7-1468" aria-hidden="true" tabindex="-1"></a>  OutMat X,</span>
<span id="cb7-1469"><a href="#cb7-1469" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span>
<span id="cb7-1470"><a href="#cb7-1470" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1471"><a href="#cb7-1471" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-1472"><a href="#cb7-1472" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1473"><a href="#cb7-1473" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1474"><a href="#cb7-1474" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1475"><a href="#cb7-1475" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat,</span>
<span id="cb7-1476"><a href="#cb7-1476" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb7-1477"><a href="#cb7-1477" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_right_solve<span class="op">(</span></span>
<span id="cb7-1478"><a href="#cb7-1478" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1479"><a href="#cb7-1479" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1480"><a href="#cb7-1480" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1481"><a href="#cb7-1481" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1482"><a href="#cb7-1482" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1483"><a href="#cb7-1483" aria-hidden="true" tabindex="-1"></a>  OutMat X,</span>
<span id="cb7-1484"><a href="#cb7-1484" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span>
<span id="cb7-1485"><a href="#cb7-1485" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb7-1486"><a href="#cb7-1486" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1487"><a href="#cb7-1487" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1488"><a href="#cb7-1488" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1489"><a href="#cb7-1489" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1490"><a href="#cb7-1490" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_right_solve<span class="op">(</span></span>
<span id="cb7-1491"><a href="#cb7-1491" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1492"><a href="#cb7-1492" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1493"><a href="#cb7-1493" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1494"><a href="#cb7-1494" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1495"><a href="#cb7-1495" aria-hidden="true" tabindex="-1"></a>  OutMat X<span class="op">)</span>;</span>
<span id="cb7-1496"><a href="#cb7-1496" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1497"><a href="#cb7-1497" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb7-1498"><a href="#cb7-1498" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1499"><a href="#cb7-1499" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1500"><a href="#cb7-1500" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb7-1501"><a href="#cb7-1501" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb7-1502"><a href="#cb7-1502" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_right_solve<span class="op">(</span></span>
<span id="cb7-1503"><a href="#cb7-1503" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1504"><a href="#cb7-1504" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb7-1505"><a href="#cb7-1505" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1506"><a href="#cb7-1506" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1507"><a href="#cb7-1507" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb7-1508"><a href="#cb7-1508" aria-hidden="true" tabindex="-1"></a>  OutMat X<span class="op">)</span>;</span>
<span id="cb7-1509"><a href="#cb7-1509" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1510"><a href="#cb7-1510" aria-hidden="true" tabindex="-1"></a><span class="co">// solve multiple triangular systems on the left, in-place</span></span>
<span id="cb7-1511"><a href="#cb7-1511" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-1512"><a href="#cb7-1512" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1513"><a href="#cb7-1513" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1514"><a href="#cb7-1514" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat,</span>
<span id="cb7-1515"><a href="#cb7-1515" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb7-1516"><a href="#cb7-1516" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_left_solve<span class="op">(</span></span>
<span id="cb7-1517"><a href="#cb7-1517" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1518"><a href="#cb7-1518" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1519"><a href="#cb7-1519" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1520"><a href="#cb7-1520" aria-hidden="true" tabindex="-1"></a>  InOutMat B,</span>
<span id="cb7-1521"><a href="#cb7-1521" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span>
<span id="cb7-1522"><a href="#cb7-1522" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1523"><a href="#cb7-1523" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-1524"><a href="#cb7-1524" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1525"><a href="#cb7-1525" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1526"><a href="#cb7-1526" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat,</span>
<span id="cb7-1527"><a href="#cb7-1527" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb7-1528"><a href="#cb7-1528" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_left_solve<span class="op">(</span></span>
<span id="cb7-1529"><a href="#cb7-1529" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1530"><a href="#cb7-1530" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1531"><a href="#cb7-1531" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1532"><a href="#cb7-1532" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1533"><a href="#cb7-1533" aria-hidden="true" tabindex="-1"></a>  InOutMat B,</span>
<span id="cb7-1534"><a href="#cb7-1534" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span>
<span id="cb7-1535"><a href="#cb7-1535" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-1536"><a href="#cb7-1536" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1537"><a href="#cb7-1537" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1538"><a href="#cb7-1538" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb7-1539"><a href="#cb7-1539" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_left_solve<span class="op">(</span></span>
<span id="cb7-1540"><a href="#cb7-1540" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1541"><a href="#cb7-1541" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1542"><a href="#cb7-1542" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1543"><a href="#cb7-1543" aria-hidden="true" tabindex="-1"></a>  InOutMat B<span class="op">)</span>;</span>
<span id="cb7-1544"><a href="#cb7-1544" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1545"><a href="#cb7-1545" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-1546"><a href="#cb7-1546" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1547"><a href="#cb7-1547" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1548"><a href="#cb7-1548" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb7-1549"><a href="#cb7-1549" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_left_solve<span class="op">(</span></span>
<span id="cb7-1550"><a href="#cb7-1550" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1551"><a href="#cb7-1551" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1552"><a href="#cb7-1552" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1553"><a href="#cb7-1553" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1554"><a href="#cb7-1554" aria-hidden="true" tabindex="-1"></a>  InOutMat B<span class="op">)</span>;</span>
<span id="cb7-1555"><a href="#cb7-1555" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-1556"><a href="#cb7-1556" aria-hidden="true" tabindex="-1"></a><span class="co">// solve multiple triangular systems on the right, in-place</span></span>
<span id="cb7-1557"><a href="#cb7-1557" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-1558"><a href="#cb7-1558" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1559"><a href="#cb7-1559" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1560"><a href="#cb7-1560" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat,</span>
<span id="cb7-1561"><a href="#cb7-1561" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb7-1562"><a href="#cb7-1562" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_right_solve<span class="op">(</span></span>
<span id="cb7-1563"><a href="#cb7-1563" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1564"><a href="#cb7-1564" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1565"><a href="#cb7-1565" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1566"><a href="#cb7-1566" aria-hidden="true" tabindex="-1"></a>  InOutMat B,</span>
<span id="cb7-1567"><a href="#cb7-1567" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span>
<span id="cb7-1568"><a href="#cb7-1568" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1569"><a href="#cb7-1569" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-1570"><a href="#cb7-1570" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1571"><a href="#cb7-1571" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1572"><a href="#cb7-1572" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat,</span>
<span id="cb7-1573"><a href="#cb7-1573" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb7-1574"><a href="#cb7-1574" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_right_solve<span class="op">(</span></span>
<span id="cb7-1575"><a href="#cb7-1575" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1576"><a href="#cb7-1576" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1577"><a href="#cb7-1577" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1578"><a href="#cb7-1578" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1579"><a href="#cb7-1579" aria-hidden="true" tabindex="-1"></a>  InOutMat B,</span>
<span id="cb7-1580"><a href="#cb7-1580" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;  </span>
<span id="cb7-1581"><a href="#cb7-1581" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb7-1582"><a href="#cb7-1582" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1583"><a href="#cb7-1583" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1584"><a href="#cb7-1584" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb7-1585"><a href="#cb7-1585" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_right_solve<span class="op">(</span></span>
<span id="cb7-1586"><a href="#cb7-1586" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1587"><a href="#cb7-1587" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1588"><a href="#cb7-1588" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1589"><a href="#cb7-1589" aria-hidden="true" tabindex="-1"></a>  InOutMat B<span class="op">)</span>;</span>
<span id="cb7-1590"><a href="#cb7-1590" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb7-1591"><a href="#cb7-1591" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb7-1592"><a href="#cb7-1592" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb7-1593"><a href="#cb7-1593" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb7-1594"><a href="#cb7-1594" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb7-1595"><a href="#cb7-1595" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_right_solve<span class="op">(</span></span>
<span id="cb7-1596"><a href="#cb7-1596" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb7-1597"><a href="#cb7-1597" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb7-1598"><a href="#cb7-1598" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb7-1599"><a href="#cb7-1599" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb7-1600"><a href="#cb7-1600" aria-hidden="true" tabindex="-1"></a>  InOutMat B<span class="op">)</span>;</span></code></pre></div>
<h3 data-number="28.9.3" id="general-linalg.general"><span class="header-section-number">28.9.3</span> General [linalg.general]<a href="#general-linalg.general" class="self-link"></a></h3>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
For the effects of all functions in [linalg], when the effects are
described as “computes <span class="math inline"><em>R</em> = <em>E</em><em>X</em><em>P</em><em>R</em></span>”
or “compute <span class="math inline"><em>R</em> = <em>E</em><em>X</em><em>P</em><em>R</em></span>”
(for some <span class="math inline"><em>R</em></span> and mathematical
expression <span class="math inline"><em>E</em><em>X</em><em>P</em><em>R</em></span>),
the following apply:</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.1)</a></span>
<span class="math inline"><em>E</em><em>X</em><em>P</em><em>R</em></span> has
the conventional mathematical meaning as written.</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.2)</a></span> The
pattern <span class="math inline"><em>x</em><sup><em>T</em></sup></span>
should be read as “the transpose of <span class="math inline"><em>x</em></span>.”</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.3)</a></span> The
pattern <span class="math inline"><em>x</em><sup><em>H</em></sup></span>
should be read as “the conjugate transpose of <span class="math inline"><em>x</em></span>.”</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.4)</a></span> When
<span class="math inline"><em>R</em></span> is the same name as a
function parameter whose type is a template parameter with
<code>Out</code> in its name, the intent is that the result of the
computation is written to the elements of the function parameter
<code>R</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
Some of the functions and types in [linalg] distinguish between the
“rows” and the “columns” of a matrix. For a matrix <code>A</code> and a
multidimensional index <code>i, j</code> in
<code>A.extents()</code>,</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span>
<em>row</em> <code>i</code> of <code>A</code> is the set of elements
<code>A[i, k1]</code> for all <code>k1</code> such that
<code>i, k1</code> is in <code>A.extents()</code>; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
<em>column</em> <code>j</code> of <code>A</code> is the set of elements
<code>A[k0, j]</code> for all <code>k0</code> such that
<code>k0, j</code> is in <code>A.extents()</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
Some of the functions in [linalg] distinguish between the “upper
triangle,” “lower triangle,” and “diagonal” of a matrix.</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.1)</a></span> The
<em>diagonal</em> is the set of all elements of <code>A</code> accessed
by <code>A[i,i]</code> for 0 ≤ <code>i</code> &lt;
min(<code>A.extent(0)</code>, <code>A.extent(1)</code>).</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.2)</a></span> The
<em>upper triangle</em> of a matrix <code>A</code> is the set of all
elements of <code>A</code> accessed by <code>A[i,j]</code> with
<code>i</code> ≤ <code>j</code>. It includes the diagonal.</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.3)</a></span> The
<em>lower triangle</em> of <code>A</code> is the set of all elements of
<code>A</code> accessed by <code>A[i,j]</code> with <code>i</code> ≥
<code>j</code>. It includes the diagonal.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
For any function <code>F</code> that takes a parameter named
<code>t</code>, <code>t</code> applies to accesses done through the
parameter preceding <code>t</code> in the parameter list of
<code>F</code>. Let <code>m</code> be such an access-modified function
parameter. <code>F</code> will only access the triangle of
<code>m</code> specified by <code>t</code>. For accesses
<code>m[i, j]</code> outside the triangle specified by <code>t</code>,
<code>F</code> will use the value`</p>
<ul>
<li><p><em><code>conj-if-needed</code></em><code>(m[j, i])</code> if the
name of <code>F</code> starts with <code>hermitian</code>,</p></li>
<li><p><code>m[j, i]</code> if the name of <code>F</code> starts with
<code>symmetric</code>, or</p></li>
<li><p>the additive identity if the name of <code>F</code> starts with
<code>triangular</code>.</p></li>
</ul>
<p>[<em>Example:</em> Small vector product accessing only specified
triangle. It would not be a precondition violation for the non-accessed
matrix element to be non-zero.</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_2x2_product<span class="op">(</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a>       mdspan<span class="op">&lt;</span><span class="kw">const</span> <span class="dt">float</span>, extents<span class="op">&lt;</span><span class="dt">int</span>, <span class="dv">2</span>, <span class="dv">2</span><span class="op">&gt;&gt;</span> m,</span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a>       Triangle t,</span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a>       mdspan<span class="op">&lt;</span><span class="kw">const</span> <span class="dt">float</span>, extents<span class="op">&lt;</span><span class="dt">int</span>, <span class="dv">2</span><span class="op">&gt;&gt;</span> x,</span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a>       mdspan<span class="op">&lt;</span><span class="dt">float</span>, extents<span class="op">&lt;</span><span class="dt">int</span>, <span class="dv">2</span><span class="op">&gt;&gt;</span> y<span class="op">)</span> <span class="op">{</span></span>
<span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-8"><a href="#cb8-8" aria-hidden="true" tabindex="-1"></a>  <span class="kw">static_assert</span><span class="op">(</span>is_same_v<span class="op">&lt;</span>Triangle, lower_triangle_t<span class="op">&gt;</span> <span class="op">||</span></span>
<span id="cb8-9"><a href="#cb8-9" aria-hidden="true" tabindex="-1"></a>                is_same_v<span class="op">&lt;</span>Triangle, upper_triangle_t<span class="op">&gt;)</span>;</span>
<span id="cb8-10"><a href="#cb8-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-11"><a href="#cb8-11" aria-hidden="true" tabindex="-1"></a>  <span class="cf">if</span> <span class="kw">constexpr</span> <span class="op">(</span>is_same_v<span class="op">&lt;</span>Triangle, lower_triangle_t<span class="op">&gt;)</span> <span class="op">{</span></span>
<span id="cb8-12"><a href="#cb8-12" aria-hidden="true" tabindex="-1"></a>    y<span class="op">[</span><span class="dv">0</span><span class="op">]</span> <span class="op">=</span> m<span class="op">[</span><span class="dv">0</span>,<span class="dv">0</span><span class="op">]</span> <span class="op">*</span> x<span class="op">[</span><span class="dv">0</span><span class="op">]</span>; <span class="co">// + 0 * x[1]</span></span>
<span id="cb8-13"><a href="#cb8-13" aria-hidden="true" tabindex="-1"></a>    y<span class="op">[</span><span class="dv">1</span><span class="op">]</span> <span class="op">=</span> m<span class="op">[</span><span class="dv">1</span>,<span class="dv">0</span><span class="op">]</span> <span class="op">*</span> x<span class="op">[</span><span class="dv">0</span><span class="op">]</span> <span class="op">+</span> m<span class="op">[</span><span class="dv">1</span>,<span class="dv">1</span><span class="op">]</span> <span class="op">*</span> x<span class="op">[</span><span class="dv">1</span><span class="op">]</span>;</span>
<span id="cb8-14"><a href="#cb8-14" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span> <span class="cf">else</span> <span class="op">{</span> <span class="co">// upper_triangle_t</span></span>
<span id="cb8-15"><a href="#cb8-15" aria-hidden="true" tabindex="-1"></a>    y<span class="op">[</span><span class="dv">0</span><span class="op">]</span> <span class="op">=</span> m<span class="op">[</span><span class="dv">0</span>,<span class="dv">0</span><span class="op">]</span> <span class="op">*</span> x<span class="op">[</span><span class="dv">0</span><span class="op">]</span> <span class="op">+</span> m<span class="op">[</span><span class="dv">0</span>,<span class="dv">1</span><span class="op">]</span> <span class="op">*</span> x<span class="op">[</span><span class="dv">1</span><span class="op">]</span>;</span>
<span id="cb8-16"><a href="#cb8-16" aria-hidden="true" tabindex="-1"></a>    y<span class="op">[</span><span class="dv">1</span><span class="op">]</span> <span class="op">=</span> <span class="co">/* 0 * x[0] + */</span> m<span class="op">[</span><span class="dv">1</span>,<span class="dv">1</span><span class="op">]</span> <span class="op">*</span> x<span class="op">[</span><span class="dv">1</span><span class="op">]</span>;</span>
<span id="cb8-17"><a href="#cb8-17" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb8-18"><a href="#cb8-18" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<p>–<em>end example</em>]</p>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
For any function <code>F</code> that takes a parameter named
<code>d</code>, <code>d</code> applies to accesses done through the
previous-of-the-previous parameter of <code>d</code> in the parameter
list of <code>F</code>. Let <code>m</code> be such an access-modified
function parameter. If <code>d</code> specifies that an implicit unit
diagonal is to be assumed, then</p>
<ul>
<li><p><code>F</code> will not access the diagonal of <code>m</code>;
and</p></li>
<li><p>the algorithm will interpret <code>m</code> as if it has a unit
diagonal, that is, a diagonal each of whose elements behaves as a
two-sided multiplicative identity (even if <code>m</code>’s value type
does not have a two-sided multiplicative identity).</p></li>
</ul>
<p>Otherwise, if <code>d</code> specifies that an explicit diagonal is
to be assumed, then <code>F</code> will access the diagonal of
<code>m</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
Within all the functions in [linalg], any calls to <code>abs</code>,
<code>conj</code>, <code>imag</code>, and <code>real</code> are
unqualified.</p>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
Two <code>mdspan</code> objects <code>x</code> and <code>y</code>
<em>alias</em> each other, if they have the same extents <code>e</code>,
and for every pack of integers <code>i</code> which is a
multidimensional index in <code>e</code>, <code>x[i...]</code> and
<code>y[i...]</code> refer to the same element. <i>[Note:</i> This means
that <code>x</code> and <code>y</code> view the same elements in the
same order. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">8</a></span>
Two <code>mdspan</code> objects <code>x</code> and <code>y</code>
<em>overlap</em> each other, if for some pack of integers <code>i</code>
that is a multidimensional index in <code>x.extents()</code>, there
exists a pack of integers <code>j</code> that is a multidimensional
index in <code>y.extents()</code>, such that <code>x[i...]</code> and
<code>y[j...]</code> refer to the same element. <i>[Note:</i> Aliasing
is a special case of overlapping. If <code>x</code> and <code>y</code>
do not overlap, then they also do not alias each other. <i>– end
note]</i></p>
<h3 data-number="28.9.4" id="requirements-linalg.reqs"><span class="header-section-number">28.9.4</span> Requirements [linalg.reqs]<a href="#requirements-linalg.reqs" class="self-link"></a></h3>
<h4 data-number="28.9.4.1" id="linear-algebra-value-types-linalg.reqs.val"><span class="header-section-number">28.9.4.1</span> Linear algebra value types
[linalg.reqs.val]<a href="#linear-algebra-value-types-linalg.reqs.val" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
Throughout [linalg], the following types are <em>linear algebra value
types</em>:</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.1)</a></span> the
<code>value_type</code> type alias of any input or output
<code>mdspan</code> parameter(s) of any function in [linalg];
and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.2)</a></span> the
<code>Scalar</code> template parameter (if any) of any function or class
in [linalg].</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
Linear algebra value types shall model <code>semiregular</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
A value-initialized object of linear algebra value type shall act as the
additive identity.</p>
<h4 data-number="28.9.4.2" id="algorithm-and-class-requirements-linalg.reqs.alg"><span class="header-section-number">28.9.4.2</span> Algorithm and class
requirements [linalg.reqs.alg]<a href="#algorithm-and-class-requirements-linalg.reqs.alg" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
[linalg.reqs.alg] lists common requirements for all algorithms and
classes in [linalg].</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
All of the following statements presume that the algorithm’s asymptotic
complexity requirements, if any, are satisfied.</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span> The
function may make arbitrarily many objects of any linear algebra value
type, value-initializing or direct-initializing them with any existing
object of that type.</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span> The
<em>triangular solve algorithms</em> in <strong>[linalg.algs]</strong>
either have a <code>BinaryDivideOp</code> template parameter (see
<strong>[linalg.algs.reqs]</strong>) and a binary function object
parameter <code>divide</code> of that type, or they have effects
equivalent to invoking such an algorithm. Triangular solve algorithms
interpret <code>divide(a, b)</code> as <code>a</code> times the
multiplicative inverse of <code>b</code>. Each triangular solve
algorithm uses a sequence of evaluations of <code>*</code>,
<code>*=</code>, <code>divide</code>, unary <code>+</code>, binary
<code>+</code>, <code>+=</code>, unary <code>-</code>, binary
<code>-</code>, <code>-=</code>, and <code>=</code> operators that would
produce the result specified by the algorithm’s Effects and Remarks when
operating on elements of a field with noncommutative multiplication. It
is a precondition of the algorithm that any addend, any subtrahend, any
partial sum of addends in any order (treating any difference as a sum
with the second term negated), any factor, any partial product of
factors respecting their order, any numerator (first argument of
<code>divide</code>), any denominator (second argument of
<code>divide</code>), and any assignment is a well-formed expression.
<!--
    EDITORIAL:
    We're not sure if we need the previous sentence.
    We're trying to express that all intermediate terms
    in the algorithm are again linear algebra value types
    with the operators that the algorithm needs.
    --></p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.3)</a></span>
Otherwise, the function will use a sequence of evaluations of
<code>*</code>, <code>*=</code>, <code>+</code>, <code>+=</code>, and
<code>=</code> operators that would produce the result specified by the
algorithm’s Effects and Remarks when operating on elements of a semiring
with noncommutative multiplication. It is a precondition of the
algorithm that any addend, any partial sum of addends in any order, any
factor, any partial product of factors respecting their order, and any
assignment is a well-formed expression. <!--
    EDITORIAL:
    We're not sure if we need the previous sentence.
    We're trying to express that all intermediate terms
    in the algorithm are again linear algebra value types
    with the operators that the algorithm needs.
    --></p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.4)</a></span> If
the function has an output <code>mdspan</code>, then all addends,
subtrahends (for the triangular solve algorithms), or results of the
<code>divide</code> parameter on intermediate terms (if the function
takes a <code>divide</code> parameter) are assignable and convertible to
the output <code>mdspan</code>’s <code>value_type</code>.</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.5)</a></span> The
function may reorder addends and partial sums arbitrarily. <i>[Note:</i>
Factors in each product are not reordered; multiplication is not
necessarily commutative. <i>– end note]</i></p></li>
</ul>
<p><i>[Note:</i> The above requirements do not prohibit implementation
approaches and optimization techniques which are not user-observable. In
particular, if for all input and output arguments the
<code>value_type</code> is a floating-point type, implementers are free
to leverage approximations, use arithmetic operations not explicitly
listed above, and compute floating point sums in any way that improves
their accuracy. <i>– end note]</i></p>
<p><i>[Note:</i> For all functions in [linalg], suppose that all input
and output <code>mdspan</code> have as <code>value_type</code> a
floating-point type, and any <code>Scalar</code> template argument has a
floating-point type.</p>
<p>Then, functions may do all of the following:</p>
<ul>
<li><p>compute floating-point sums in any way that improves their
accuracy for arbitrary input;</p></li>
<li><p>perform additional arithmetic operations (other than those
specified by the function’s wording and
<strong>[linalg.reqs.alg]</strong>) in order to improve performance or
accuracy; and</p></li>
<li><p>use approximations (that might not be exact even if computing
with real numbers), instead of computations that would be exact if it
were possible to compute without rounding error;</p></li>
</ul>
<p>as long as</p>
<ul>
<li><p>the function satisfies the complexity requirements; and</p></li>
<li><p>the function is logarithmically stable, as defined in Demmel
2007. Strassen’s algorithm for matrix-matrix multiply is an example of a
logarithmically stable algorithm. <i>– end note]</i></p></li>
</ul>
<h3 data-number="28.9.5" id="tag-classes-linalg.tags"><span class="header-section-number">28.9.5</span> Tag classes [linalg.tags]<a href="#tag-classes-linalg.tags" class="self-link"></a></h3>
<h4 data-number="28.9.5.1" id="storage-order-tags-linalg.tags.order"><span class="header-section-number">28.9.5.1</span> Storage order tags
[linalg.tags.order]<a href="#storage-order-tags-linalg.tags.order" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The storage order tags describe the order of elements in an
<code>mdspan</code> with <code>layout_blas_packed</code>
([linalg.layout.packed]) layout.</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> column_major_t <span class="op">{</span></span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">explicit</span> column_major_t<span class="op">()</span> <span class="op">=</span> <span class="cf">default</span>;</span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a><span class="op">}</span>;</span>
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a><span class="kw">inline</span> <span class="kw">constexpr</span> column_major_t column_major<span class="op">{}</span>;</span>
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> row_major_t <span class="op">{</span></span>
<span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a>  <span class="kw">explicit</span> row_major_t<span class="op">()</span> <span class="op">=</span> <span class="cf">default</span>;</span>
<span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a><span class="op">}</span>;</span>
<span id="cb9-9"><a href="#cb9-9" aria-hidden="true" tabindex="-1"></a><span class="kw">inline</span> <span class="kw">constexpr</span> row_major_t row_major<span class="op">{}</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<code>column_major_t</code> indicates a column-major order, and
<code>row_major_t</code> indicates a row-major order.</p>
<h4 data-number="28.9.5.2" id="triangle-tags-linalg.tags.triangle"><span class="header-section-number">28.9.5.2</span> Triangle tags
[linalg.tags.triangle]<a href="#triangle-tags-linalg.tags.triangle" class="self-link"></a></h4>
<div class="sourceCode" id="cb10"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> upper_triangle_t <span class="op">{</span></span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">explicit</span> upper_triangle_t<span class="op">()</span> <span class="op">=</span> <span class="cf">default</span>;</span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a><span class="op">}</span>;</span>
<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a><span class="kw">inline</span> <span class="kw">constexpr</span> upper_triangle_t upper_triangle<span class="op">{}</span>;</span>
<span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-6"><a href="#cb10-6" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> lower_triangle_t <span class="op">{</span></span>
<span id="cb10-7"><a href="#cb10-7" aria-hidden="true" tabindex="-1"></a>  <span class="kw">explicit</span> lower_triangle_t<span class="op">()</span> <span class="op">=</span> <span class="cf">default</span>;</span>
<span id="cb10-8"><a href="#cb10-8" aria-hidden="true" tabindex="-1"></a><span class="op">}</span>;</span>
<span id="cb10-9"><a href="#cb10-9" aria-hidden="true" tabindex="-1"></a><span class="kw">inline</span> <span class="kw">constexpr</span> lower_triangle_t lower_triangle<span class="op">{}</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
These tag classes specify whether algorithms and other users of a matrix
(represented as an <code>mdspan</code>) access the upper triangle
(<code>upper_triangle_t</code>) or lower triangle
(<code>lower_triangle_t</code>) of the matrix (see also
[linalg.general]). This is also subject to the restrictions of
<code>implicit_unit_diagonal_t</code> if that tag is also used as a
function argument; see below.</p>
<h4 data-number="28.9.5.3" id="diagonal-tags-linalg.tags.diagonal"><span class="header-section-number">28.9.5.3</span> Diagonal tags
[linalg.tags.diagonal]<a href="#diagonal-tags-linalg.tags.diagonal" class="self-link"></a></h4>
<div class="sourceCode" id="cb11"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> implicit_unit_diagonal_t <span class="op">{</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">explicit</span> implicit_unit_diagonal_t<span class="op">()</span> <span class="op">=</span> <span class="cf">default</span>;</span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a><span class="op">}</span>;</span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a><span class="kw">inline</span> <span class="kw">constexpr</span> implicit_unit_diagonal_t</span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a>  implicit_unit_diagonal<span class="op">{}</span>;</span>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> explicit_diagonal_t <span class="op">{</span></span>
<span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a>  <span class="kw">explicit</span> explicit_diagonal_t<span class="op">()</span> <span class="op">=</span> <span class="cf">default</span>;</span>
<span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a><span class="op">}</span>;</span>
<span id="cb11-10"><a href="#cb11-10" aria-hidden="true" tabindex="-1"></a><span class="kw">inline</span> <span class="kw">constexpr</span> explicit_diagonal_t explicit_diagonal<span class="op">{}</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
These tag classes specify whether algorithms access the matrix’s
diagonal entries, and if not, then how algorithms interpret the matrix’s
implicitly represented diagonal values.</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
The <code>implicit_unit_diagonal_t</code> tag indicates that an implicit
unit diagonal is to be assumed ([linalg.general]).</p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
The <code>explicit_diagonal_t</code> tag indicates that an explicit
diagonal is used ([linalg.general]).</p>
<h3 data-number="28.9.6" id="layouts-for-packed-matrix-types-linalg.layout.packed"><span class="header-section-number">28.9.6</span> Layouts for packed matrix
types [linalg.layout.packed]<a href="#layouts-for-packed-matrix-types-linalg.layout.packed" class="self-link"></a></h3>
<h4 data-number="28.9.6.1" id="overview-linalg.layout.packed.overview"><span class="header-section-number">28.9.6.1</span> Overview
[linalg.layout.packed.overview]<a href="#overview-linalg.layout.packed.overview" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
<code>layout_blas_packed</code> is an <code>mdspan</code> layout mapping
policy that represents a square matrix that stores only the entries in
one triangle, in a packed contiguous format. Its <code>Triangle</code>
template parameter determines whether an <code>mdspan</code> with this
layout stores the upper or lower triangle of the matrix. Its
<code>StorageOrder</code> template parameter determines whether the
layout packs the matrix’s elements in column-major or row-major
order.</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
A <code>StorageOrder</code> of <code>column_major_t</code> indicates
column-major ordering. This packs matrix elements starting with the
leftmost (least column index) column, and proceeding column by column,
from the top entry (least row index).</p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
A <code>StorageOrder</code> of <code>row_major_t</code> indicates
row-major ordering. This packs matrix elements starting with the topmost
(least row index) row, and proceeding row by row, from the leftmost
(least column index) entry.</p>
<p><i>[Note:</i> <code>layout_blas_packed</code> describes the data
layout used by the BLAS’ Symmetric Packed (SP), Hermitian Packed (HP),
and Triangular Packed (TP) matrix types. <i>– end note]</i></p>
<div class="sourceCode" id="cb12"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Triangle,</span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> StorageOrder<span class="op">&gt;</span></span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a><span class="kw">class</span> layout_blas_packed <span class="op">{</span></span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a><span class="kw">public</span><span class="op">:</span></span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> triangle_type <span class="op">=</span> Triangle;</span>
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> storage_order_type <span class="op">=</span> StorageOrder;</span>
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a>  <span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Extents<span class="op">&gt;</span></span>
<span id="cb12-9"><a href="#cb12-9" aria-hidden="true" tabindex="-1"></a>  <span class="kw">struct</span> mapping <span class="op">{</span></span>
<span id="cb12-10"><a href="#cb12-10" aria-hidden="true" tabindex="-1"></a>  <span class="kw">public</span><span class="op">:</span></span>
<span id="cb12-11"><a href="#cb12-11" aria-hidden="true" tabindex="-1"></a>    <span class="kw">using</span> extents_type <span class="op">=</span> Extents;</span>
<span id="cb12-12"><a href="#cb12-12" aria-hidden="true" tabindex="-1"></a>    <span class="kw">using</span> index_type <span class="op">=</span> <span class="kw">typename</span> extents_type<span class="op">::</span>index_type;</span>
<span id="cb12-13"><a href="#cb12-13" aria-hidden="true" tabindex="-1"></a>    <span class="kw">using</span> size_type <span class="op">=</span> <span class="kw">typename</span> extents_type<span class="op">::</span>size_type;</span>
<span id="cb12-14"><a href="#cb12-14" aria-hidden="true" tabindex="-1"></a>    <span class="kw">using</span> rank_type <span class="op">=</span> <span class="kw">typename</span> extents_type<span class="op">::</span>rank_type;</span>
<span id="cb12-15"><a href="#cb12-15" aria-hidden="true" tabindex="-1"></a>    <span class="kw">using</span> layout_type <span class="op">=</span> layout_blas_packed;</span>
<span id="cb12-16"><a href="#cb12-16" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-17"><a href="#cb12-17" aria-hidden="true" tabindex="-1"></a>    <span class="co">// [linalg.layout.packed.cons], constructors</span></span>
<span id="cb12-18"><a href="#cb12-18" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> mapping<span class="op">()</span> <span class="kw">noexcept</span> <span class="op">=</span> <span class="cf">default</span>;</span>
<span id="cb12-19"><a href="#cb12-19" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> mapping<span class="op">(</span><span class="kw">const</span> mapping<span class="op">&amp;)</span> <span class="kw">noexcept</span> <span class="op">=</span> <span class="cf">default</span>;</span>
<span id="cb12-20"><a href="#cb12-20" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> mapping<span class="op">(</span><span class="kw">const</span> extents_type<span class="op">&amp;)</span> <span class="kw">noexcept</span>;</span>
<span id="cb12-21"><a href="#cb12-21" aria-hidden="true" tabindex="-1"></a>    <span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> OtherExtents<span class="op">&gt;</span></span>
<span id="cb12-22"><a href="#cb12-22" aria-hidden="true" tabindex="-1"></a>      <span class="kw">constexpr</span> <span class="kw">explicit</span><span class="op">(!</span> is_convertible_v<span class="op">&lt;</span>OtherExtents, extents_type<span class="op">&gt;)</span></span>
<span id="cb12-23"><a href="#cb12-23" aria-hidden="true" tabindex="-1"></a>        mapping<span class="op">(</span><span class="kw">const</span> mapping<span class="op">&lt;</span>OtherExtents<span class="op">&gt;&amp;</span> other<span class="op">)</span> <span class="kw">noexcept</span>;</span>
<span id="cb12-24"><a href="#cb12-24" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-25"><a href="#cb12-25" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> mapping<span class="op">&amp;</span> <span class="kw">operator</span><span class="op">=(</span><span class="kw">const</span> mapping<span class="op">&amp;)</span> <span class="kw">noexcept</span> <span class="op">=</span> <span class="cf">default</span>;</span>
<span id="cb12-26"><a href="#cb12-26" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-27"><a href="#cb12-27" aria-hidden="true" tabindex="-1"></a>    <span class="co">// [linalg.layout.packed.obs], observers</span></span>
<span id="cb12-28"><a href="#cb12-28" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> <span class="kw">const</span> extents_type<span class="op">&amp;</span> extents<span class="op">()</span> <span class="kw">const</span> <span class="kw">noexcept</span> <span class="op">{</span> <span class="cf">return</span> <em>extents_</em>; <span class="op">}</span></span>
<span id="cb12-29"><a href="#cb12-29" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-30"><a href="#cb12-30" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> index_type required_span_size<span class="op">()</span> <span class="kw">const</span> <span class="kw">noexcept</span>;</span>
<span id="cb12-31"><a href="#cb12-31" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-32"><a href="#cb12-32" aria-hidden="true" tabindex="-1"></a>    <span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Index0, <span class="kw">class</span> Index1<span class="op">&gt;</span></span>
<span id="cb12-33"><a href="#cb12-33" aria-hidden="true" tabindex="-1"></a>      <span class="kw">constexpr</span> index_type <span class="kw">operator</span><span class="op">()</span> <span class="op">(</span>Index0 ind0, Index1 ind1<span class="op">)</span> <span class="kw">const</span> <span class="kw">noexcept</span>;</span>
<span id="cb12-34"><a href="#cb12-34" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-35"><a href="#cb12-35" aria-hidden="true" tabindex="-1"></a>    <span class="kw">static</span> <span class="kw">constexpr</span> <span class="dt">bool</span> is_always_unique<span class="op">()</span> <span class="kw">noexcept</span> <span class="op">{</span></span>
<span id="cb12-36"><a href="#cb12-36" aria-hidden="true" tabindex="-1"></a>      <span class="cf">return</span> <span class="op">(</span>extents_type<span class="op">::</span>static_extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">!=</span> dynamic_extent <span class="op">&amp;&amp;</span></span>
<span id="cb12-37"><a href="#cb12-37" aria-hidden="true" tabindex="-1"></a>              extents_type<span class="op">::</span>static_extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">&lt;</span> <span class="dv">2</span><span class="op">)</span> <span class="op">||</span></span>
<span id="cb12-38"><a href="#cb12-38" aria-hidden="true" tabindex="-1"></a>             <span class="op">(</span>extents_type<span class="op">::</span>static_extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span> <span class="op">!=</span> dynamic_extent <span class="op">&amp;&amp;</span></span>
<span id="cb12-39"><a href="#cb12-39" aria-hidden="true" tabindex="-1"></a>              extents_type<span class="op">::</span>static_extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span> <span class="op">&lt;</span> <span class="dv">2</span><span class="op">)</span>;</span>
<span id="cb12-40"><a href="#cb12-40" aria-hidden="true" tabindex="-1"></a>    <span class="op">}</span></span>
<span id="cb12-41"><a href="#cb12-41" aria-hidden="true" tabindex="-1"></a>    <span class="kw">static</span> <span class="kw">constexpr</span> <span class="dt">bool</span> is_always_exhaustive<span class="op">()</span> <span class="kw">noexcept</span> <span class="op">{</span> <span class="cf">return</span> <span class="kw">true</span>; <span class="op">}</span></span>
<span id="cb12-42"><a href="#cb12-42" aria-hidden="true" tabindex="-1"></a>    <span class="kw">static</span> <span class="kw">constexpr</span> <span class="dt">bool</span> is_always_strided<span class="op">()</span> <span class="kw">noexcept</span></span>
<span id="cb12-43"><a href="#cb12-43" aria-hidden="true" tabindex="-1"></a>      <span class="op">{</span> <span class="cf">return</span> is_always_unique<span class="op">()</span>; <span class="op">}</span></span>
<span id="cb12-44"><a href="#cb12-44" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-45"><a href="#cb12-45" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> <span class="dt">bool</span> is_unique<span class="op">()</span> <span class="kw">const</span> <span class="kw">noexcept</span> <span class="op">{</span></span>
<span id="cb12-46"><a href="#cb12-46" aria-hidden="true" tabindex="-1"></a>      <span class="cf">return</span> <em>extents_</em><span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">&lt;</span> <span class="dv">2</span>;</span>
<span id="cb12-47"><a href="#cb12-47" aria-hidden="true" tabindex="-1"></a>    <span class="op">}</span></span>
<span id="cb12-48"><a href="#cb12-48" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> <span class="dt">bool</span> is_exhaustive<span class="op">()</span> <span class="kw">const</span> <span class="kw">noexcept</span> <span class="op">{</span> <span class="cf">return</span> <span class="kw">true</span>; <span class="op">}</span></span>
<span id="cb12-49"><a href="#cb12-49" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> <span class="dt">bool</span> is_strided<span class="op">()</span> <span class="kw">const</span> <span class="kw">noexcept</span> <span class="op">{</span></span>
<span id="cb12-50"><a href="#cb12-50" aria-hidden="true" tabindex="-1"></a>      <span class="cf">return</span> <em>extents_</em><span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">&lt;</span> <span class="dv">2</span>;</span>
<span id="cb12-51"><a href="#cb12-51" aria-hidden="true" tabindex="-1"></a>    <span class="op">}</span></span>
<span id="cb12-52"><a href="#cb12-52" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-53"><a href="#cb12-53" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> index_type stride<span class="op">(</span>rank_type<span class="op">)</span> <span class="kw">const</span> <span class="kw">noexcept</span>;</span>
<span id="cb12-54"><a href="#cb12-54" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-55"><a href="#cb12-55" aria-hidden="true" tabindex="-1"></a>    <span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> OtherExtents<span class="op">&gt;</span></span>
<span id="cb12-56"><a href="#cb12-56" aria-hidden="true" tabindex="-1"></a>      <span class="kw">friend</span> <span class="kw">constexpr</span> <span class="dt">bool</span></span>
<span id="cb12-57"><a href="#cb12-57" aria-hidden="true" tabindex="-1"></a>        <span class="kw">operator</span><span class="op">==(</span><span class="kw">const</span> mapping<span class="op">&amp;</span>, <span class="kw">const</span> mapping<span class="op">&lt;</span>OtherExtents<span class="op">&gt;&amp;)</span> <span class="kw">noexcept</span>;</span>
<span id="cb12-58"><a href="#cb12-58" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-59"><a href="#cb12-59" aria-hidden="true" tabindex="-1"></a>  <span class="kw">private</span><span class="op">:</span></span>
<span id="cb12-60"><a href="#cb12-60" aria-hidden="true" tabindex="-1"></a>    extents_type <em>extents_</em><span class="op">{}</span>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb12-61"><a href="#cb12-61" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span>;</span>
<span id="cb12-62"><a href="#cb12-62" aria-hidden="true" tabindex="-1"></a><span class="op">}</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.1)</a></span>
<code>Triangle</code> is either <code>upper_triangle_t</code> or
<code>lower_triangle_t</code>,</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.2)</a></span>
<code>StorageOrder</code> is either <code>column_major_t</code> or
<code>row_major_t</code>,</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.3)</a></span>
<code>Extents</code> is a specialization of
<code>std::extents</code>,</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.4)</a></span>
<code>Extents::rank()</code> equals 2,</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.5)</a></span> one
of <code>extents_type::static_extent(0) == dynamic_extent</code>,
<code>extents_type::static_extent(1) == dynamic_extent</code>, or
<code>extents_type::static_extent(0) == extents_type::static_extent(1)</code>
is <code>true</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.6)</a></span> if
<code>Extents::rank_dynamic() == 0</code> is <code>true</code>, let
<span class="math inline"><em>N</em><sub><em>s</em></sub></span> be
equal to <code>Extents::static_extent(0)</code>; then, <span class="math inline"><em>N</em><sub><em>s</em></sub> × (<em>N</em><sub><em>s</em></sub>+1)</span>
is representable as a value of type <code>index_type</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
<code>layout_blas_packed&lt;T, SO&gt;::mapping&lt;E&gt;</code> is a
trivially copyable type that models <code>regular</code> for each
<code>T</code>, <code>SO</code>, and <code>E</code>.</p>
<h4 data-number="28.9.6.2" id="constructors-linalg.layout.packed.cons"><span class="header-section-number">28.9.6.2</span> Constructors
[linalg.layout.packed.cons]<a href="#constructors-linalg.layout.packed.cons" class="self-link"></a></h4>
<div class="sourceCode" id="cb13"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> mapping<span class="op">(</span><span class="kw">const</span> extents_type<span class="op">&amp;</span> e<span class="op">)</span> <span class="kw">noexcept</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(6.1)</a></span> Let
<span class="math inline"><em>N</em></span> be equal to
<code>e.extent(0)</code>. Then, <span class="math inline"><em>N</em> × (<em>N</em>+1)</span> is representable
as a value of type <code>index_type</code>
([basic.fundamental]).</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(6.2)</a></span>
<code>e.extent(0)</code> equals <code>e.extent(1)</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
<em>Effects:</em> Direct-non-list-initializes
<em><code>extents_</code></em> with <code>e</code>.</p>
<div class="sourceCode" id="cb14"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> OtherExtents<span class="op">&gt;</span></span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">explicit</span><span class="op">(!</span> is_convertible_v<span class="op">&lt;</span>OtherExtents, extents_type<span class="op">&gt;)</span></span>
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> mapping<span class="op">(</span><span class="kw">const</span> mapping<span class="op">&lt;</span>OtherExtents<span class="op">&gt;&amp;</span> other<span class="op">)</span> <span class="kw">noexcept</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">8</a></span>
<em>Constraints:</em>
<code>is_constructible_v&lt;extents_type, OtherExtents&gt;</code> is
<code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">9</a></span>
<em>Preconditions:</em> Let <span class="math inline"><em>N</em></span>
be <code>other.extents().extent(0)</code>. Then, <span class="math inline"><em>N</em> × (<em>N</em>+1)</span> is representable
as a value of type <code>index_type</code> ([basic.fundamental]).</p>
<p><span class="marginalizedparent"><a class="marginalized">10</a></span>
<em>Effects:</em> Direct-non-list-initializes
<em><code>extents_</code></em> with <code>other.extents()</code>.</p>
<h4 data-number="28.9.6.3" id="observers-linalg.layout.packed.obs"><span class="header-section-number">28.9.6.3</span> Observers
[linalg.layout.packed.obs]<a href="#observers-linalg.layout.packed.obs" class="self-link"></a></h4>
<div class="sourceCode" id="cb15"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> index_type required_span_size<span class="op">()</span> <span class="kw">const</span> <span class="kw">noexcept</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">11</a></span>
<em>Returns:</em>
<em><code>extents_</code></em><code>.extent(0) * (</code><em><code>extents_</code></em><code>.extent(0) + 1)/2</code>.
<i>[Note:</i> For example, a 5 x 5 packed matrix only stores 15 matrix
elements. <i>– end note]</i></p>
<div class="sourceCode" id="cb16"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Index0, <span class="kw">class</span> Index1<span class="op">&gt;</span></span>
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">constexpr</span> index_type <span class="kw">operator</span><span class="op">()</span> <span class="op">(</span>Index0 ind0, Index1 ind1<span class="op">)</span> <span class="kw">const</span> <span class="kw">noexcept</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">12</a></span>
<em>Constraints</em>:</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(12.1)</a></span>
<code>is_convertible_v&lt;Index0, index_type&gt;</code> is
<code>true</code>,</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(12.2)</a></span>
<code>is_convertible_v&lt;Index1, index_type&gt;</code> is
<code>true</code>,</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(12.3)</a></span>
<code>is_nothrow_constructible_v&lt;index_type, Index0&gt;</code> is
<code>true</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(12.4)</a></span>
<code>is_nothrow_constructible_v&lt;index_type, Index1&gt;</code> is
<code>true</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">13</a></span>
<em>Preconditions:</em>
<code>extents_type::</code><em><code>index-cast</code></em><code>(ind0), extents_type::</code><em><code>index-cast</code></em><code>(ind1)</code>
is a multidimensional index in <em><code>extents_</code></em>
([mdspan.overview]).</p>
<p><span class="marginalizedparent"><a class="marginalized">14</a></span>
<em>Returns:</em> Let <code>N</code> be
<em><code>extents_</code></em><code>.extent(0)</code>, let
<code>i</code> be
<code>extents_type::</code><em><code>index-cast</code></em><code>(ind0)</code>,
and let <code>j</code> be
<code>extents_type::</code><em><code>index-cast</code></em><code>(ind1)</code>.
Then</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(14.1)</a></span>
<code>(*this)(j, i)</code> if <code>i &gt; j</code> is
<code>true</code>; otherwise</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(14.2)</a></span>
<code>i + j * (j + 1)/2</code> if
<code>is_same_v&lt;StorageOrder, column_major_t&gt; &amp;&amp; is_same_v&lt;Triangle, upper_triangle_t&gt;</code>
is <code>true</code> or
<code>is_same_v&lt;StorageOrder, row_major_t&gt; &amp;&amp; is_same_v&lt;Triangle, lower_triangle_t&gt;</code>
is <code>true</code>; otherwise</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(14.3)</a></span>
<code>j + N * i - i * (i + 1)/2</code>.</p></li>
</ul>
<div class="sourceCode" id="cb17"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> index_type stride<span class="op">(</span>rank_type r<span class="op">)</span> <span class="kw">const</span> <span class="kw">noexcept</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">15</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(15.1)</a></span>
<code>is_strided()</code> is <code>true</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(15.1)</a></span>
<code>r &lt; extents_type::rank()</code> is <code>true</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">16</a></span>
<em>Returns:</em> 1.</p>
<div class="sourceCode" id="cb18"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> OtherExtents<span class="op">&gt;</span></span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">friend</span> <span class="kw">constexpr</span> <span class="dt">bool</span></span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a>    <span class="kw">operator</span><span class="op">==(</span><span class="kw">const</span> mapping<span class="op">&amp;</span> x, <span class="kw">const</span> mapping<span class="op">&lt;</span>OtherExtents<span class="op">&gt;&amp;</span> y<span class="op">)</span> <span class="kw">noexcept</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">17</a></span>
<em>Effects:</em> Equivalent to:
<code>return x.extents() == y.extents();</code></p>
<h3 data-number="28.9.7" id="exposition-only-helpers-linalg.helpers"><span class="header-section-number">28.9.7</span> Exposition-only helpers
[linalg.helpers]<a href="#exposition-only-helpers-linalg.helpers" class="self-link"></a></h3>
<h4 data-number="28.9.7.1" id="abs-if-needed-linalg.helpers.abs"><span class="header-section-number">28.9.7.1</span>
<em><code>abs-if-needed</code></em> [linalg.helpers.abs]<a href="#abs-if-needed-linalg.helpers.abs" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The name <em><code>abs-if-needed</code></em> denotes an exposition-only
function object. The expression
<em><code>abs-if-needed</code></em><code>(E)</code> for subexpression
<code>E</code> whose type is <code>T</code> is expression-equivalent
to:</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.1)</a></span>
<code>E</code> if <code>T</code> is an unsigned integer;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.2)</a></span>
otherwise, <code>std::abs(E)</code> if <code>T</code> is an arithmetic
type,</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.3)</a></span>
otherwise, <code>abs(E)</code>, if that expression is valid, with
overload resolution performed in a context that includes the declaration
<code>template&lt;class T&gt; T abs(T) = delete;</code>. If the function
selected by overload resolution does not return the absolute value of
its input, the program is ill-formed, no diagnostic required.</p></li>
</ul>
<h4 data-number="28.9.7.2" id="conj-if-needed-linalg.helpers.conj"><span class="header-section-number">28.9.7.2</span>
<em><code>conj-if-needed</code></em> [linalg.helpers.conj]<a href="#conj-if-needed-linalg.helpers.conj" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The name <em><code>conj-if-needed</code></em> denotes an exposition-only
function object. The expression
<em><code>conj-if-needed</code></em><code>(E)</code> for subexpression
<code>E</code> whose type is <code>T</code> is expression-equivalent
to:</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.1)</a></span>
<code>conj(E)</code>, if <code>T</code> is not an arithmetic type and
the expression <code>conj(E)</code> is valid, with overload resolution
performed in a context that includes the declaration
<code>template&lt;class T&gt; T conj(const T&amp;) = delete;</code>. If
the function selected by overload resolution does not return the complex
conjugate of its input, the program is ill-formed, no diagnostic
required;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.2)</a></span>
otherwise, <code>E</code>.</p></li>
</ul>
<h4 data-number="28.9.7.3" id="real-if-needed-linalg.helpers.real"><span class="header-section-number">28.9.7.3</span>
<em><code>real-if-needed</code></em> [linalg.helpers.real]<a href="#real-if-needed-linalg.helpers.real" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The name <em><code>real-if-needed</code></em> denotes an exposition-only
function object. The expression
<em><code>real-if-needed</code></em><code>(E)</code> for subexpression
<code>E</code> whose type is <code>T</code> is expression-equivalent
to:</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.1)</a></span>
<code>real(E)</code>, if <code>T</code> is not an arithmetic type and
the expression <code>real(E)</code> is valid, with overload resolution
performed in a context that includes the declaration
<code>template&lt;class T&gt; T real(const T&amp;) = delete;</code>. If
the function selected by overload resolution does not return the real
part of its input, the program is ill-formed, no diagnostic
required;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.2)</a></span>
otherwise, <code>E</code>.</p></li>
</ul>
<!--
The special case for arithmetic types
preserves the type of its argument, unlike `std::real`.
The `real(E)` case invokes `real` via unqualified lookup.
The `E` case presumes that a type without a `real` function is noncomplex,
so that taking the real part is the identity.
-->
<!--
_`real-if-needed`_ and _`imag-if-needed`_
exist so that `vector_abs_sum` will behave the same
for custom complex types as for std::complex.
-->
<h4 data-number="28.9.7.4" id="imag-if-needed-linalg.helpers.imag"><span class="header-section-number">28.9.7.4</span>
<em><code>imag-if-needed</code></em> [linalg.helpers.imag]<a href="#imag-if-needed-linalg.helpers.imag" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The name <em><code>imag-if-needed</code></em> denotes an exposition-only
function object. The expression
<em><code>imag-if-needed</code></em><code>(E)</code> for subexpression
<code>E</code> whose type is <code>T</code> is expression-equivalent
to:</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.1)</a></span>
<code>imag(E)</code>, if <code>T</code> is not an arithmetic type and
the expression <code>imag(E)</code> is valid, with overload resolution
performed in a context that includes the declaration
<code>template&lt;class T&gt; T imag(const T&amp;) = delete;</code>. If
the function selected by overload resolution does not return the
imaginary part of its input, the program is ill-formed, no diagnostic
required;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.2)</a></span>
otherwise, <code>((void)E, T{})</code>.</p></li>
</ul>
<!--
The `E` case presumes that a type without an `imag` function is noncomplex,
so that taking the real part is zero,
which we represent as a value-initialized T.
-->
<h4 data-number="28.9.7.5" id="linear-algebra-argument-concepts-linalg.helpers.concepts"><span class="header-section-number">28.9.7.5</span> Linear algebra argument
concepts [linalg.helpers.concepts]<a href="#linear-algebra-argument-concepts-linalg.helpers.concepts" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The exposition-only concepts defined in this section constrain the
algorithms in <em>[linalg.algs]</em>.</p>
<div class="sourceCode" id="cb19"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">bool</span> <em>is-mdspan</em> <span class="op">=</span> <span class="kw">false</span>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-4"><a href="#cb19-4" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ElementType, <span class="kw">class</span> Extents, <span class="kw">class</span> Layout, <span class="kw">class</span> Accessor<span class="op">&gt;</span></span>
<span id="cb19-5"><a href="#cb19-5" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">bool</span> <em>is-mdspan</em><span class="op">&lt;</span>mdspan<span class="op">&lt;</span>ElementType, Extents, Layout, Accessor<span class="op">&gt;&gt;</span> <span class="op">=</span> <span class="kw">true</span>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb19-6"><a href="#cb19-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-7"><a href="#cb19-7" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb19-8"><a href="#cb19-8" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>in-vector</em> <span class="op">=</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb19-9"><a href="#cb19-9" aria-hidden="true" tabindex="-1"></a>  <em>is-mdspan</em><span class="op">&lt;</span>T<span class="op">&gt;</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-10"><a href="#cb19-10" aria-hidden="true" tabindex="-1"></a>  T<span class="op">::</span>rank<span class="op">()</span> <span class="op">==</span> <span class="dv">1</span>;</span>
<span id="cb19-11"><a href="#cb19-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-12"><a href="#cb19-12" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb19-13"><a href="#cb19-13" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>out-vector</em> <span class="op">=</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb19-14"><a href="#cb19-14" aria-hidden="true" tabindex="-1"></a>  <em>is-mdspan</em><span class="op">&lt;</span>T<span class="op">&gt;</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-15"><a href="#cb19-15" aria-hidden="true" tabindex="-1"></a>  T<span class="op">::</span>rank<span class="op">()</span> <span class="op">==</span> <span class="dv">1</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-16"><a href="#cb19-16" aria-hidden="true" tabindex="-1"></a>  is_assignable_v<span class="op">&lt;</span><span class="kw">typename</span> T<span class="op">::</span>reference, <span class="kw">typename</span> T<span class="op">::</span>element_type<span class="op">&gt;</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-17"><a href="#cb19-17" aria-hidden="true" tabindex="-1"></a>  T<span class="op">::</span>is_always_unique<span class="op">()</span>;</span>
<span id="cb19-18"><a href="#cb19-18" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-19"><a href="#cb19-19" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb19-20"><a href="#cb19-20" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>inout-vector</em> <span class="op">=</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb19-21"><a href="#cb19-21" aria-hidden="true" tabindex="-1"></a>  <em>is-mdspan</em><span class="op">&lt;</span>T<span class="op">&gt;</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-22"><a href="#cb19-22" aria-hidden="true" tabindex="-1"></a>  T<span class="op">::</span>rank<span class="op">()</span> <span class="op">==</span> <span class="dv">1</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-23"><a href="#cb19-23" aria-hidden="true" tabindex="-1"></a>  is_assignable_v<span class="op">&lt;</span><span class="kw">typename</span> T<span class="op">::</span>reference, <span class="kw">typename</span> T<span class="op">::</span>element_type<span class="op">&gt;</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-24"><a href="#cb19-24" aria-hidden="true" tabindex="-1"></a>  T<span class="op">::</span>is_always_unique<span class="op">()</span>;</span>
<span id="cb19-25"><a href="#cb19-25" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-26"><a href="#cb19-26" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb19-27"><a href="#cb19-27" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>in-matrix</em> <span class="op">=</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb19-28"><a href="#cb19-28" aria-hidden="true" tabindex="-1"></a>  <em>is-mdspan</em><span class="op">&lt;</span>T<span class="op">&gt;</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-29"><a href="#cb19-29" aria-hidden="true" tabindex="-1"></a>  T<span class="op">::</span>rank<span class="op">()</span> <span class="op">==</span> <span class="dv">2</span>;</span>
<span id="cb19-30"><a href="#cb19-30" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-31"><a href="#cb19-31" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb19-32"><a href="#cb19-32" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>out-matrix</em> <span class="op">=</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb19-33"><a href="#cb19-33" aria-hidden="true" tabindex="-1"></a>  <em>is-mdspan</em><span class="op">&lt;</span>T<span class="op">&gt;</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-34"><a href="#cb19-34" aria-hidden="true" tabindex="-1"></a>  T<span class="op">::</span>rank<span class="op">()</span> <span class="op">==</span> <span class="dv">2</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-35"><a href="#cb19-35" aria-hidden="true" tabindex="-1"></a>  is_assignable_v<span class="op">&lt;</span><span class="kw">typename</span> T<span class="op">::</span>reference, <span class="kw">typename</span> T<span class="op">::</span>element_type<span class="op">&gt;</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-36"><a href="#cb19-36" aria-hidden="true" tabindex="-1"></a>  T<span class="op">::</span>is_always_unique<span class="op">()</span>;</span>
<span id="cb19-37"><a href="#cb19-37" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-38"><a href="#cb19-38" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb19-39"><a href="#cb19-39" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>inout-matrix</em> <span class="op">=</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb19-40"><a href="#cb19-40" aria-hidden="true" tabindex="-1"></a>  <em>is-mdspan</em><span class="op">&lt;</span>T<span class="op">&gt;</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-41"><a href="#cb19-41" aria-hidden="true" tabindex="-1"></a>  T<span class="op">::</span>rank<span class="op">()</span> <span class="op">==</span> <span class="dv">2</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-42"><a href="#cb19-42" aria-hidden="true" tabindex="-1"></a>  is_assignable_v<span class="op">&lt;</span><span class="kw">typename</span> T<span class="op">::</span>reference, <span class="kw">typename</span> T<span class="op">::</span>element_type<span class="op">&gt;</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-43"><a href="#cb19-43" aria-hidden="true" tabindex="-1"></a>  T<span class="op">::</span>is_always_unique<span class="op">()</span>;</span>
<span id="cb19-44"><a href="#cb19-44" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-45"><a href="#cb19-45" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb19-46"><a href="#cb19-46" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">bool</span> <em>is-layout-blas-packed</em> <span class="op">=</span> <span class="kw">false</span>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb19-47"><a href="#cb19-47" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-48"><a href="#cb19-48" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Triangle, <span class="kw">class</span> StorageOrder<span class="op">&gt;</span></span>
<span id="cb19-49"><a href="#cb19-49" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">bool</span> <em>is-layout-blas-packed</em><span class="op">&lt;</span><em>layout-blas-packed</em><span class="op">&lt;</span>Triangle, StorageOrder<span class="op">&gt;&gt;</span> <span class="op">=</span> <span class="kw">true</span>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb19-50"><a href="#cb19-50" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-51"><a href="#cb19-51" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb19-52"><a href="#cb19-52" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>possibly-packed-inout-matrix</em> <span class="op">=</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb19-53"><a href="#cb19-53" aria-hidden="true" tabindex="-1"></a>  <em>is-mdspan</em><span class="op">&lt;</span>T<span class="op">&gt;</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-54"><a href="#cb19-54" aria-hidden="true" tabindex="-1"></a>  T<span class="op">::</span>rank<span class="op">()</span> <span class="op">==</span> <span class="dv">2</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-55"><a href="#cb19-55" aria-hidden="true" tabindex="-1"></a>  is_assignable_v<span class="op">&lt;</span><span class="kw">typename</span> T<span class="op">::</span>reference, <span class="kw">typename</span> T<span class="op">::</span>element_type<span class="op">&gt;</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-56"><a href="#cb19-56" aria-hidden="true" tabindex="-1"></a>  <span class="op">(</span>T<span class="op">::</span>is_always_unique<span class="op">()</span> <span class="op">||</span> <em>is-layout-blas-packed</em><span class="op">&lt;</span><span class="kw">typename</span> T<span class="op">::</span>layout_type<span class="op">&gt;)</span>;</span>
<span id="cb19-57"><a href="#cb19-57" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-58"><a href="#cb19-58" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb19-59"><a href="#cb19-59" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>in-object</em> <span class="op">=</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb19-60"><a href="#cb19-60" aria-hidden="true" tabindex="-1"></a>  <em>is-mdspan</em><span class="op">&lt;</span>T<span class="op">&gt;</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-61"><a href="#cb19-61" aria-hidden="true" tabindex="-1"></a>  <span class="op">(</span>T<span class="op">::</span>rank<span class="op">()</span> <span class="op">==</span> <span class="dv">1</span> <span class="op">||</span> T<span class="op">::</span>rank<span class="op">()</span> <span class="op">==</span> <span class="dv">2</span><span class="op">)</span>;</span>
<span id="cb19-62"><a href="#cb19-62" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-63"><a href="#cb19-63" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb19-64"><a href="#cb19-64" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>out-object</em> <span class="op">=</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb19-65"><a href="#cb19-65" aria-hidden="true" tabindex="-1"></a>  <em>is-mdspan</em><span class="op">&lt;</span>T<span class="op">&gt;</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-66"><a href="#cb19-66" aria-hidden="true" tabindex="-1"></a>  <span class="op">(</span>T<span class="op">::</span>rank<span class="op">()</span> <span class="op">==</span> <span class="dv">1</span> <span class="op">||</span> T<span class="op">::</span>rank<span class="op">()</span> <span class="op">==</span> <span class="dv">2</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-67"><a href="#cb19-67" aria-hidden="true" tabindex="-1"></a>  is_assignable_v<span class="op">&lt;</span><span class="kw">typename</span> T<span class="op">::</span>reference, <span class="kw">typename</span> T<span class="op">::</span>element_type<span class="op">&gt;</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-68"><a href="#cb19-68" aria-hidden="true" tabindex="-1"></a>  T<span class="op">::</span>is_always_unique<span class="op">()</span>;</span>
<span id="cb19-69"><a href="#cb19-69" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-70"><a href="#cb19-70" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> T<span class="op">&gt;</span></span>
<span id="cb19-71"><a href="#cb19-71" aria-hidden="true" tabindex="-1"></a><span class="kw">concept</span> <em>inout-object</em> <span class="op">=</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb19-72"><a href="#cb19-72" aria-hidden="true" tabindex="-1"></a>  <em>is-mdspan</em><span class="op">&lt;</span>T<span class="op">&gt;</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-73"><a href="#cb19-73" aria-hidden="true" tabindex="-1"></a>  <span class="op">(</span>T<span class="op">::</span>rank<span class="op">()</span> <span class="op">==</span> <span class="dv">1</span> <span class="op">||</span> T<span class="op">::</span>rank<span class="op">()</span> <span class="op">==</span> <span class="dv">2</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-74"><a href="#cb19-74" aria-hidden="true" tabindex="-1"></a>  is_assignable_v<span class="op">&lt;</span><span class="kw">typename</span> T<span class="op">::</span>reference, <span class="kw">typename</span> T<span class="op">::</span>element_type<span class="op">&gt;</span> <span class="op">&amp;&amp;</span></span>
<span id="cb19-75"><a href="#cb19-75" aria-hidden="true" tabindex="-1"></a>  T<span class="op">::</span>is_always_unique<span class="op">()</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
If a function in <em>[linalg.algs]</em> accesses the elements of a
parameter constrained by <em><code>in-vector</code></em>,
<em><code>in-matrix</code></em>, or <em><code>in-object</code></em>,
those accesses will not modify the elements.</p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
Unless explicitly permitted, any <em><code>inout-vector</code></em>,
<em><code>inout-matrix</code></em>, <em><code>inout-object</code></em>,
<em><code>possibly-packed-inout-matrix</code></em>,
<em><code>out-vector</code></em>, <em><code>out-matrix</code></em>, or
<em><code>out-object</code></em> parameter of a function in
<em>[linalg.algs]</em> shall not overlap any other <code>mdspan</code>
parameter of the function.</p>
<h4 data-number="28.9.7.6" id="exposition-only-helpers-for-algorithm-mandates-linalg.helpers.mandates"><span class="header-section-number">28.9.7.6</span> Exposition-only helpers
for algorithm mandates [linalg.helpers.mandates]<a href="#exposition-only-helpers-for-algorithm-mandates-linalg.helpers.mandates" class="self-link"></a></h4>
<p><i>[Note:</i> These exposition-only helper functions use the less
constraining input concepts even for the output arguments, because the
additional constraint for assignability of elements is not necessary,
and they are sometimes used in a context where the third argument is an
input type too. <i>- end Note.]</i></p>
<div class="sourceCode" id="cb20"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> MDS1, <span class="kw">class</span> MDS2<span class="op">&gt;</span></span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="kw">requires</span><span class="op">(</span><em>is-mdspan</em><span class="op">&lt;</span>MDS1<span class="op">&gt;</span> <span class="op">&amp;&amp;</span> <em>is-mdspan</em><span class="op">&lt;</span>MDS2<span class="op">&gt;)</span> </span>
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">bool</span> <em>compatible-static-extents</em><span class="op">(</span><span class="dt">size_t</span> r1, <span class="dt">size_t</span> r2<span class="op">)</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb20-4"><a href="#cb20-4" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> MDS1<span class="op">::</span>static_extent<span class="op">(</span>r1<span class="op">)</span> <span class="op">==</span> dynamic_extent <span class="op">||</span></span>
<span id="cb20-6"><a href="#cb20-6" aria-hidden="true" tabindex="-1"></a>         MDS2<span class="op">::</span>static_extent<span class="op">(</span>r2<span class="op">)</span> <span class="op">==</span> dynamic_extent <span class="op">||</span> </span>
<span id="cb20-7"><a href="#cb20-7" aria-hidden="true" tabindex="-1"></a>         MDS1<span class="op">::</span>static_extent<span class="op">(</span>r1<span class="op">)</span> <span class="op">==</span> MDS2<span class="op">::</span>static_extent<span class="op">(</span>r2<span class="op">))</span>;</span>
<span id="cb20-8"><a href="#cb20-8" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<div class="sourceCode" id="cb21"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> In1, <em>in-vector</em> In2, <em>in-vector</em> Out<span class="op">&gt;</span></span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">bool</span> <em>possibly-addable</em><span class="op">()</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb21-3"><a href="#cb21-3" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb21-4"><a href="#cb21-4" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> <em>compatible-static-extents</em><span class="op">&lt;</span>Out, In1<span class="op">&gt;(</span><span class="dv">0</span>, <span class="dv">0</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb21-5"><a href="#cb21-5" aria-hidden="true" tabindex="-1"></a>         <em>compatible-static-extents</em><span class="op">&lt;</span>Out, In2<span class="op">&gt;(</span><span class="dv">0</span>, <span class="dv">0</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb21-6"><a href="#cb21-6" aria-hidden="true" tabindex="-1"></a>         <em>compatible-static-extents</em><span class="op">&lt;</span>In1, In2<span class="op">&gt;(</span><span class="dv">0</span>, <span class="dv">0</span><span class="op">)</span>;</span>
<span id="cb21-7"><a href="#cb21-7" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<div class="sourceCode" id="cb22"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> In1, <em>in-matrix</em> In2, <em>in-matrix</em> Out<span class="op">&gt;</span></span>
<span id="cb22-2"><a href="#cb22-2" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">bool</span> <em>possibly-addable</em><span class="op">()</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb22-3"><a href="#cb22-3" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb22-4"><a href="#cb22-4" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> <em>compatible-static-extents</em><span class="op">&lt;</span>Out, In1<span class="op">&gt;(</span><span class="dv">0</span>, <span class="dv">0</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb22-5"><a href="#cb22-5" aria-hidden="true" tabindex="-1"></a>         <em>compatible-static-extents</em><span class="op">&lt;</span>Out, In1<span class="op">&gt;(</span><span class="dv">1</span>, <span class="dv">1</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb22-6"><a href="#cb22-6" aria-hidden="true" tabindex="-1"></a>         <em>compatible-static-extents</em><span class="op">&lt;</span>Out, In2<span class="op">&gt;(</span><span class="dv">0</span>, <span class="dv">0</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb22-7"><a href="#cb22-7" aria-hidden="true" tabindex="-1"></a>         <em>compatible-static-extents</em><span class="op">&lt;</span>Out, In2<span class="op">&gt;(</span><span class="dv">1</span>, <span class="dv">1</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb22-8"><a href="#cb22-8" aria-hidden="true" tabindex="-1"></a>         <em>compatible-static-extents</em><span class="op">&lt;</span>In1, In2<span class="op">&gt;(</span><span class="dv">0</span>, <span class="dv">0</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb22-9"><a href="#cb22-9" aria-hidden="true" tabindex="-1"></a>         <em>compatible-static-extents</em><span class="op">&lt;</span>In1, In2<span class="op">&gt;(</span><span class="dv">1</span>, <span class="dv">1</span><span class="op">)</span>;</span>
<span id="cb22-10"><a href="#cb22-10" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<div class="sourceCode" id="cb23"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat, <em>in-vector</em> InVec, <em>in-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">bool</span> <em>possibly-multipliable</em><span class="op">()</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb23-3"><a href="#cb23-3" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb23-4"><a href="#cb23-4" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> <em>compatible-static-extents</em><span class="op">&lt;</span>OutVec, InMat<span class="op">&gt;(</span><span class="dv">0</span>, <span class="dv">0</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb23-5"><a href="#cb23-5" aria-hidden="true" tabindex="-1"></a>         <em>compatible-static-extents</em><span class="op">&lt;</span>InMat, InVec<span class="op">&gt;(</span><span class="dv">1</span>, <span class="dv">0</span><span class="op">)</span>;</span>
<span id="cb23-6"><a href="#cb23-6" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<div class="sourceCode" id="cb24"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec, <em>in-matrix</em> InMat, <em>in-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb24-2"><a href="#cb24-2" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">bool</span> <em>possibly-multipliable</em><span class="op">()</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb24-3"><a href="#cb24-3" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb24-4"><a href="#cb24-4" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> <em>compatible-static-extents</em><span class="op">&lt;</span>OutVec, InMat<span class="op">&gt;(</span><span class="dv">0</span>, <span class="dv">1</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb24-5"><a href="#cb24-5" aria-hidden="true" tabindex="-1"></a>         <em>compatible-static-extents</em><span class="op">&lt;</span>InMat, InVec<span class="op">&gt;(</span><span class="dv">0</span>, <span class="dv">0</span><span class="op">)</span>;</span>
<span id="cb24-6"><a href="#cb24-6" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<div class="sourceCode" id="cb25"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1, <em>in-matrix</em> InMat2, <em>in-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb25-2"><a href="#cb25-2" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">bool</span> <em>possibly-multipliable</em><span class="op">()</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb25-3"><a href="#cb25-3" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb25-4"><a href="#cb25-4" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> <em>compatible-static-extents</em><span class="op">&lt;</span>OutMat, InMat1<span class="op">&gt;(</span><span class="dv">0</span>, <span class="dv">0</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb25-5"><a href="#cb25-5" aria-hidden="true" tabindex="-1"></a>         <em>compatible-static-extents</em><span class="op">&lt;</span>OutMat, InMat2<span class="op">&gt;(</span><span class="dv">1</span>, <span class="dv">1</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb25-6"><a href="#cb25-6" aria-hidden="true" tabindex="-1"></a>         <em>compatible-static-extents</em><span class="op">&lt;</span>InMat1, InMat2<span class="op">&gt;(</span><span class="dv">1</span>, <span class="dv">0</span><span class="op">)</span>;</span>
<span id="cb25-7"><a href="#cb25-7" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<h4 data-number="28.9.7.7" id="exposition-only-checks-for-algorithm-preconditions-linalg.helpers.precond"><span class="header-section-number">28.9.7.7</span> Exposition-only checks for
algorithm preconditions [linalg.helpers.precond]<a href="#exposition-only-checks-for-algorithm-preconditions-linalg.helpers.precond" class="self-link"></a></h4>
<p><i>[Note:</i> These helpers use the less constraining input concepts
even for the output arguments, because the additional constraint for
assignability of elements is not necessary, and they are sometimes used
in a context where the third argument is an input type too. <i>- end
Note.]</i></p>
<div class="sourceCode" id="cb26"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">bool</span> <em>addable</em><span class="op">(</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb26-2"><a href="#cb26-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <em>in-vector</em> <span class="kw">auto</span><span class="op">&amp;</span> in1,</span>
<span id="cb26-3"><a href="#cb26-3" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <em>in-vector</em> <span class="kw">auto</span><span class="op">&amp;</span> in2,</span>
<span id="cb26-4"><a href="#cb26-4" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <em>in-vector</em> <span class="kw">auto</span><span class="op">&amp;</span> out<span class="op">)</span></span>
<span id="cb26-5"><a href="#cb26-5" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb26-6"><a href="#cb26-6" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> out<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">==</span> in1<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb26-7"><a href="#cb26-7" aria-hidden="true" tabindex="-1"></a>         out<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">==</span> in2<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>;</span>
<span id="cb26-8"><a href="#cb26-8" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<div class="sourceCode" id="cb27"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">bool</span> <em>addable</em><span class="op">(</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb27-2"><a href="#cb27-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <em>in-matrix</em> <span class="kw">auto</span><span class="op">&amp;</span> in1,</span>
<span id="cb27-3"><a href="#cb27-3" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <em>in-matrix</em> <span class="kw">auto</span><span class="op">&amp;</span> in2,</span>
<span id="cb27-4"><a href="#cb27-4" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <em>in-matrix</em> <span class="kw">auto</span><span class="op">&amp;</span> out<span class="op">)</span></span>
<span id="cb27-5"><a href="#cb27-5" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb27-6"><a href="#cb27-6" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> out<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">==</span> in1<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb27-7"><a href="#cb27-7" aria-hidden="true" tabindex="-1"></a>         out<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span> <span class="op">==</span> in1<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb27-8"><a href="#cb27-8" aria-hidden="true" tabindex="-1"></a>         out<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">==</span> in2<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb27-9"><a href="#cb27-9" aria-hidden="true" tabindex="-1"></a>         out<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span> <span class="op">==</span> in2<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span>;</span>
<span id="cb27-10"><a href="#cb27-10" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<div class="sourceCode" id="cb28"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb28-1"><a href="#cb28-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">bool</span> <em>multipliable</em><span class="op">(</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb28-2"><a href="#cb28-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <em>in-matrix</em> <span class="kw">auto</span><span class="op">&amp;</span> in_mat,</span>
<span id="cb28-3"><a href="#cb28-3" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <em>in-vector</em> <span class="kw">auto</span><span class="op">&amp;</span> in_vec,</span>
<span id="cb28-4"><a href="#cb28-4" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <em>in-vector</em> <span class="kw">auto</span><span class="op">&amp;</span> out_vec<span class="op">)</span></span>
<span id="cb28-5"><a href="#cb28-5" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb28-6"><a href="#cb28-6" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> out_vec<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">==</span> in_mat<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb28-7"><a href="#cb28-7" aria-hidden="true" tabindex="-1"></a>         in_mat<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span> <span class="op">==</span> in_vec<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>;</span>
<span id="cb28-8"><a href="#cb28-8" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<div class="sourceCode" id="cb29"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">bool</span> <em>multipliable</em><span class="op">(</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb29-2"><a href="#cb29-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <em>in-vector</em> <span class="kw">auto</span><span class="op">&amp;</span> in_vec,</span>
<span id="cb29-3"><a href="#cb29-3" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <em>in-matrix</em> <span class="kw">auto</span><span class="op">&amp;</span> in_mat,</span>
<span id="cb29-4"><a href="#cb29-4" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <em>in-vector</em> <span class="kw">auto</span><span class="op">&amp;</span> out_vec<span class="op">)</span></span>
<span id="cb29-5"><a href="#cb29-5" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb29-6"><a href="#cb29-6" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> out_vec<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">==</span> in_mat<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb29-7"><a href="#cb29-7" aria-hidden="true" tabindex="-1"></a>         in_mat<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">==</span> in_vec<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>;</span>
<span id="cb29-8"><a href="#cb29-8" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<div class="sourceCode" id="cb30"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb30-1"><a href="#cb30-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">bool</span> <em>multipliable</em><span class="op">(</span> <span class="co">// <em>exposition only</em></span></span>
<span id="cb30-2"><a href="#cb30-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <em>in-matrix</em> <span class="kw">auto</span><span class="op">&amp;</span> in_mat1,</span>
<span id="cb30-3"><a href="#cb30-3" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <em>in-matrix</em> <span class="kw">auto</span><span class="op">&amp;</span> in_mat2,</span>
<span id="cb30-4"><a href="#cb30-4" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <em>in-matrix</em> <span class="kw">auto</span><span class="op">&amp;</span> out_mat<span class="op">)</span></span>
<span id="cb30-5"><a href="#cb30-5" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb30-6"><a href="#cb30-6" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> out_mat<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">==</span> in_mat1<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb30-7"><a href="#cb30-7" aria-hidden="true" tabindex="-1"></a>         out_mat<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span> <span class="op">==</span> in_mat2<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span> <span class="op">&amp;&amp;</span></span>
<span id="cb30-8"><a href="#cb30-8" aria-hidden="true" tabindex="-1"></a>         in1_mat<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span> <span class="op">==</span> in_mat2<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>;</span>
<span id="cb30-9"><a href="#cb30-9" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<h3 data-number="28.9.8" id="scaled-in-place-transformation-linalg.scaled"><span class="header-section-number">28.9.8</span> Scaled in-place
transformation [linalg.scaled]<a href="#scaled-in-place-transformation-linalg.scaled" class="self-link"></a></h3>
<h4 data-number="28.9.8.1" id="introduction-linalg.scaled.intro"><span class="header-section-number">28.9.8.1</span> Introduction
[linalg.scaled.intro]<a href="#introduction-linalg.scaled.intro" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The <code>scaled</code> function takes a value <code>alpha</code> and an
<code>mdspan</code> <code>x</code>, and returns a new read-only
<code>mdspan</code> that represents the elementwise product of
<code>alpha</code> with each element of <code>x</code>.</p>
<p>[<em>Example:</em></p>
<div class="sourceCode" id="cb31"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb31-1"><a href="#cb31-1" aria-hidden="true" tabindex="-1"></a><span class="kw">using</span> Vec <span class="op">=</span> mdspan<span class="op">&lt;</span><span class="dt">double</span>, dextents<span class="op">&lt;</span><span class="dt">size_t</span>, <span class="dv">1</span><span class="op">&gt;&gt;</span>;</span>
<span id="cb31-2"><a href="#cb31-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb31-3"><a href="#cb31-3" aria-hidden="true" tabindex="-1"></a><span class="co">// z = alpha * x + y</span></span>
<span id="cb31-4"><a href="#cb31-4" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> z_equals_alpha_times_x_plus_y<span class="op">(</span></span>
<span id="cb31-5"><a href="#cb31-5" aria-hidden="true" tabindex="-1"></a>  <span class="dt">double</span> alpha, Vec x,</span>
<span id="cb31-6"><a href="#cb31-6" aria-hidden="true" tabindex="-1"></a>  Vec y,</span>
<span id="cb31-7"><a href="#cb31-7" aria-hidden="true" tabindex="-1"></a>  Vec z<span class="op">)</span></span>
<span id="cb31-8"><a href="#cb31-8" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb31-9"><a href="#cb31-9" aria-hidden="true" tabindex="-1"></a>  add<span class="op">(</span>scaled<span class="op">(</span>alpha, x<span class="op">)</span>, y, z<span class="op">)</span>;</span>
<span id="cb31-10"><a href="#cb31-10" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span>
<span id="cb31-11"><a href="#cb31-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb31-12"><a href="#cb31-12" aria-hidden="true" tabindex="-1"></a><span class="co">// z = alpha * x + beta * y</span></span>
<span id="cb31-13"><a href="#cb31-13" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> z_equals_alpha_times_x_plus_beta_times_y<span class="op">(</span></span>
<span id="cb31-14"><a href="#cb31-14" aria-hidden="true" tabindex="-1"></a>  <span class="dt">double</span> alpha, Vec x,</span>
<span id="cb31-15"><a href="#cb31-15" aria-hidden="true" tabindex="-1"></a>  <span class="dt">double</span> beta, Vec y,</span>
<span id="cb31-16"><a href="#cb31-16" aria-hidden="true" tabindex="-1"></a>  Vec z<span class="op">)</span></span>
<span id="cb31-17"><a href="#cb31-17" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb31-18"><a href="#cb31-18" aria-hidden="true" tabindex="-1"></a>  add<span class="op">(</span>scaled<span class="op">(</span>alpha, x<span class="op">)</span>, scaled<span class="op">(</span>beta, y<span class="op">)</span>, z<span class="op">)</span>;</span>
<span id="cb31-19"><a href="#cb31-19" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<p>–<em>end example</em>]</p>
<!--
An implementation could dispatch to a function
in the BLAS library, by noticing that the first argument
has an `scaled_accessor` `Accessor` type.
It could use this information to extract the appropriate
run-time value(s) of the relevant BLAS function arguments
(e.g., `ALPHA` and/or `BETA`),
by calling `scaled_accessor::scaling_factor`.
-->
<h4 data-number="28.9.8.2" id="class-template-scaled_accessor-linalg.scaled.scaledaccessor"><span class="header-section-number">28.9.8.2</span> Class template
<code>scaled_accessor</code> [linalg.scaled.scaledaccessor]<a href="#class-template-scaled_accessor-linalg.scaled.scaledaccessor" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The class template <code>scaled_accessor</code> is an
<code>mdspan</code> accessor policy which upon access produces scaled
elements. reference. It is part of the implementation of
<code>scaled</code> <strong>[linalg.scaled.scaled]</strong>.</p>
<div class="sourceCode" id="cb32"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb32-1"><a href="#cb32-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ScalingFactor,</span>
<span id="cb32-2"><a href="#cb32-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> NestedAccessor<span class="op">&gt;</span></span>
<span id="cb32-3"><a href="#cb32-3" aria-hidden="true" tabindex="-1"></a><span class="kw">class</span> scaled_accessor <span class="op">{</span></span>
<span id="cb32-4"><a href="#cb32-4" aria-hidden="true" tabindex="-1"></a><span class="kw">public</span><span class="op">:</span></span>
<span id="cb32-5"><a href="#cb32-5" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> element_type <span class="op">=</span> add_const_t<span class="op">&lt;</span><span class="kw">decltype</span><span class="op">(</span>declval<span class="op">&lt;</span>ScalingFactor<span class="op">&gt;()</span> <span class="op">*</span> declval<span class="op">&lt;</span>NestedAccessor<span class="op">::</span>element_type<span class="op">&gt;())&gt;</span>;</span>
<span id="cb32-6"><a href="#cb32-6" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> reference <span class="op">=</span> remove_const_t<span class="op">&lt;</span>element_type<span class="op">&gt;</span>;</span>
<span id="cb32-7"><a href="#cb32-7" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> data_handle_type <span class="op">=</span> NestedAccessor<span class="op">::</span>data_handle_type;</span>
<span id="cb32-8"><a href="#cb32-8" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> offset_policy <span class="op">=</span> scaled_accessor<span class="op">&lt;</span>ScalingFactor, NestedAccessor<span class="op">::</span>offset_policy<span class="op">&gt;</span>;</span>
<span id="cb32-9"><a href="#cb32-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb32-10"><a href="#cb32-10" aria-hidden="true" tabindex="-1"></a>  <span class="kw">constexpr</span> scaled_accessor<span class="op">()</span> <span class="op">=</span> <span class="cf">default</span>;</span>
<span id="cb32-11"><a href="#cb32-11" aria-hidden="true" tabindex="-1"></a>  <span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> OtherNestedAccessor<span class="op">&gt;</span></span>
<span id="cb32-12"><a href="#cb32-12" aria-hidden="true" tabindex="-1"></a>    <span class="kw">explicit</span><span class="op">(!</span>is_convertible_v<span class="op">&lt;</span>OtherNestedAccessor, NestedAccessor<span class="op">&gt;)</span></span>
<span id="cb32-13"><a href="#cb32-13" aria-hidden="true" tabindex="-1"></a>      <span class="kw">constexpr</span> scaled_accessor<span class="op">(</span><span class="kw">const</span> scaled_accessor<span class="op">&lt;</span>ScalingFactor, OtherNestedAccessor<span class="op">&gt;&amp;</span> other<span class="op">)</span>;</span>
<span id="cb32-14"><a href="#cb32-14" aria-hidden="true" tabindex="-1"></a>  <span class="kw">constexpr</span> scaled_accessor<span class="op">(</span><span class="kw">const</span> ScalingFactor<span class="op">&amp;</span> s, <span class="kw">const</span> NestedAccessor<span class="op">&amp;</span> a<span class="op">)</span>;</span>
<span id="cb32-15"><a href="#cb32-15" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb32-16"><a href="#cb32-16" aria-hidden="true" tabindex="-1"></a>  <span class="kw">constexpr</span> reference access<span class="op">(</span>data_handle_type p, <span class="dt">size_t</span> i<span class="op">)</span> <span class="kw">const</span>;</span>
<span id="cb32-17"><a href="#cb32-17" aria-hidden="true" tabindex="-1"></a>  <span class="kw">constexpr</span> offset_policy<span class="op">::</span>data_handle_type</span>
<span id="cb32-18"><a href="#cb32-18" aria-hidden="true" tabindex="-1"></a>    offset<span class="op">(</span>data_handle_type p, <span class="dt">size_t</span> i<span class="op">)</span> <span class="kw">const</span>;</span>
<span id="cb32-19"><a href="#cb32-19" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb32-20"><a href="#cb32-20" aria-hidden="true" tabindex="-1"></a>  <span class="kw">constexpr</span> <span class="kw">const</span> ScalingFactor<span class="op">&amp;</span> scaling_factor<span class="op">()</span> <span class="kw">const</span> <span class="kw">noexcept</span> <span class="op">{</span> <span class="cf">return</span> <em>scaling-factor</em>; <span class="op">}</span></span>
<span id="cb32-21"><a href="#cb32-21" aria-hidden="true" tabindex="-1"></a>  <span class="kw">constexpr</span> <span class="kw">const</span> NestedAccessor<span class="op">&amp;</span> nested_accessor<span class="op">()</span> <span class="kw">const</span> <span class="kw">noexcept</span> <span class="op">{</span> <span class="cf">return</span> <em>nested-accessor</em>; <span class="op">}</span></span>
<span id="cb32-22"><a href="#cb32-22" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb32-23"><a href="#cb32-23" aria-hidden="true" tabindex="-1"></a><span class="kw">private</span><span class="op">:</span></span>
<span id="cb32-24"><a href="#cb32-24" aria-hidden="true" tabindex="-1"></a>  ScalingFactor <em>scaling-factor</em><span class="op">{}</span>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb32-25"><a href="#cb32-25" aria-hidden="true" tabindex="-1"></a>  NestedAccessor <em>nested-accessor</em><span class="op">{}</span>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb32-26"><a href="#cb32-26" aria-hidden="true" tabindex="-1"></a><span class="op">}</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span>
<code>element_type</code> is valid and denotes a type,</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
<code>is_copy_constructible_v&lt;reference&gt;</code> is
<code>true</code>,</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.3)</a></span>
<code>is_reference_v&lt;element_type&gt;</code> is
<code>false</code>,</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.4)</a></span>
<code>ScalingFactor</code> models <code>semiregular</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.5)</a></span>
<code>NestedAccessor</code> meets the accessor policy requirements
[mdspan.accessor.reqmts].</p></li>
</ul>
<div class="sourceCode" id="cb33"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb33-1"><a href="#cb33-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> OtherNestedAccessor<span class="op">&gt;</span></span>
<span id="cb33-2"><a href="#cb33-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">explicit</span><span class="op">(!</span>is_convertible_v<span class="op">&lt;</span>OtherNestedAccessor, NestedAccessor<span class="op">&gt;)</span></span>
<span id="cb33-3"><a href="#cb33-3" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> scaled_accessor<span class="op">(</span><span class="kw">const</span> scaled_accessor<span class="op">&lt;</span>ScalingFactor, OtherNestedAccessor<span class="op">&gt;&amp;</span> other<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Constraints:</em>
<code>is_constructible_v&lt;NestedAccessor, const OtherNestedAccessor&amp;&gt;</code>
is <code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Effects:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.1)</a></span>
Direct-non-list-initializes <em><code>scaling-factor</code></em> with
<code>other.scaling_factor()</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.2)</a></span>
direct-non-list-initializes <em><code>nested-accessor</code></em> with
<code>other.nested_accessor()</code>.</p></li>
</ul>
<div class="sourceCode" id="cb34"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb34-1"><a href="#cb34-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> scaled_accessor<span class="op">(</span><span class="kw">const</span> ScalingFactor<span class="op">&amp;</span> s, <span class="kw">const</span> NestedAccessor<span class="op">&amp;</span> a<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
<em>Effects:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(5.1)</a></span>
Direct-non-list-initializes <em><code>scaling-factor</code></em> with
<code>s</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(5.2)</a></span>
direct-non-list-initializes <em><code>nested-accessor</code></em> with
<code>a</code>.</p></li>
</ul>
<div class="sourceCode" id="cb35"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb35-1"><a href="#cb35-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> reference access<span class="op">(</span>data_handle_type p, <span class="dt">size_t</span> i<span class="op">)</span> <span class="kw">const</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Returns:</em>
<code>scaling_factor() * NestedAccessor::element_type(</code>
<em><code>nested-accessor</code></em><code>.access(p, i))</code></p>
<div class="sourceCode" id="cb36"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb36-1"><a href="#cb36-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> offset_policy<span class="op">::</span>data_handle_type</span>
<span id="cb36-2"><a href="#cb36-2" aria-hidden="true" tabindex="-1"></a>offset<span class="op">(</span>data_handle_type p, <span class="dt">size_t</span> i<span class="op">)</span> <span class="kw">const</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
<em>Returns:</em>
<em><code>nested-accessor</code></em><code>.offset(p, i)</code></p>
<h4 data-number="28.9.8.3" id="function-template-scaled-linalg.scaled.scaled"><span class="header-section-number">28.9.8.3</span> Function template
<code>scaled</code> [linalg.scaled.scaled]<a href="#function-template-scaled-linalg.scaled.scaled" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The <code>scaled</code> function template takes a scaling factor
<code>alpha</code> and an <code>mdspan</code> <code>x</code>, and
returns a new read-only <code>mdspan</code> with the same domain as
<code>x</code>, that represents the elementwise product of
<code>alpha</code> with each element of <code>x</code>.</p>
<div class="sourceCode" id="cb37"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb37-1"><a href="#cb37-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ScalingFactor,</span>
<span id="cb37-2"><a href="#cb37-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> ElementType,</span>
<span id="cb37-3"><a href="#cb37-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Extents,</span>
<span id="cb37-4"><a href="#cb37-4" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Layout,</span>
<span id="cb37-5"><a href="#cb37-5" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Accessor<span class="op">&gt;</span></span>
<span id="cb37-6"><a href="#cb37-6" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="kw">auto</span> scaled<span class="op">(</span></span>
<span id="cb37-7"><a href="#cb37-7" aria-hidden="true" tabindex="-1"></a>  ScalingFactor alpha,</span>
<span id="cb37-8"><a href="#cb37-8" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span>ElementType, Extents, Layout, Accessor<span class="op">&gt;</span> x<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
Let <code>SA</code> be
<code>scaled_accessor&lt;ScalingFactor, Accessor&gt;</code></p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Returns:</em>
<code>mdspan&lt;typename SA::element_type, Extents, Layout, SA&gt;(x.data_handle(), x.mapping(), SA(alpha, x.accessor()))</code></p>
<!--
Nested `scaled` expressions remain nested.
An expression such as `scaled(alpha, scaled(beta, x))`
would not be transformed into `scaled(alpha * beta, x)`.
This is because such transformations would change at least
the order of operations, and possibly also the result type.
For example, if `x` is a rank-1 `mdspan` whose `value_type` is `double`,
and if `sizeof(int)` is 4 and `double` is IEEE 754 binary64,
then `scaled(1 << 20, scaled(1 << 20, x))` does not overflow `int`,
but `scaled((1 << 20) * (1 << 20), x)`
would overflow `int`.
-->
<p>[<em>Example:</em></p>
<div class="sourceCode" id="cb38"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb38-1"><a href="#cb38-1" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> test_scaled<span class="op">(</span>mdspan<span class="op">&lt;</span><span class="dt">double</span>, extents<span class="op">&lt;</span><span class="dt">int</span>, <span class="dv">10</span><span class="op">&gt;&gt;</span> x<span class="op">)</span></span>
<span id="cb38-2"><a href="#cb38-2" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb38-3"><a href="#cb38-3" aria-hidden="true" tabindex="-1"></a>  <span class="kw">auto</span> x_scaled <span class="op">=</span> scaled<span class="op">(</span><span class="fl">5.0</span>, x<span class="op">)</span>;</span>
<span id="cb38-4"><a href="#cb38-4" aria-hidden="true" tabindex="-1"></a>  <span class="cf">for</span><span class="op">(</span><span class="dt">int</span> i <span class="op">=</span> <span class="dv">0</span>; i <span class="op">&lt;</span> x<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>; <span class="op">++</span>i<span class="op">)</span> <span class="op">{</span></span>
<span id="cb38-5"><a href="#cb38-5" aria-hidden="true" tabindex="-1"></a>    <span class="ot">assert</span><span class="op">(</span>x_scaled<span class="op">[</span>i<span class="op">]</span> <span class="op">==</span> <span class="fl">5.0</span> <span class="op">*</span> x<span class="op">[</span>i<span class="op">])</span>;</span>
<span id="cb38-6"><a href="#cb38-6" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb38-7"><a href="#cb38-7" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<p>–<em>end example</em>]</p>
<h3 data-number="28.9.9" id="conjugated-in-place-transformation-linalg.conj"><span class="header-section-number">28.9.9</span> Conjugated in-place
transformation [linalg.conj]<a href="#conjugated-in-place-transformation-linalg.conj" class="self-link"></a></h3>
<h4 data-number="28.9.9.1" id="introduction-linalg.conj.intro"><span class="header-section-number">28.9.9.1</span> Introduction
[linalg.conj.intro]<a href="#introduction-linalg.conj.intro" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The <code>conjugated</code> function takes an <code>mdspan</code>
<code>x</code>, and returns a new read-only <code>mdspan</code>
<code>y</code> with the same domain as <code>x</code>, whose elements
are the complex conjugates of the corresponding elements of
<code>x</code>.</p>
<!--
An implementation could dispatch to a function in the BLAS library,
by noticing that the `Accessor` type of an `mdspan` input
has type `conjugated_accessor`,
and that its nested `Accessor` type is compatible with the BLAS library.
If so, it could set the corresponding `TRANS*` BLAS function argument accordingly
and call the BLAS function.
-->
<h4 data-number="28.9.9.2" id="class-template-conjugated_accessor-linalg.conj.conjugatedaccessor"><span class="header-section-number">28.9.9.2</span> Class template
<code>conjugated_accessor</code> [linalg.conj.conjugatedaccessor]<a href="#class-template-conjugated_accessor-linalg.conj.conjugatedaccessor" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The class template <code>conjugated_accessor</code> is an
<code>mdspan</code> accessor policy which upon access produces conjugate
elements. It is part of the implementation of <code>conjugated</code>
<strong>[linalg.conj.conjugated]</strong>.</p>
<div class="sourceCode" id="cb39"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb39-1"><a href="#cb39-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> NestedAccessor<span class="op">&gt;</span></span>
<span id="cb39-2"><a href="#cb39-2" aria-hidden="true" tabindex="-1"></a><span class="kw">class</span> conjugated_accessor <span class="op">{</span></span>
<span id="cb39-3"><a href="#cb39-3" aria-hidden="true" tabindex="-1"></a><span class="kw">public</span><span class="op">:</span></span>
<span id="cb39-4"><a href="#cb39-4" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> element_type <span class="op">=</span> add_const_t<span class="op">&lt;</span><span class="kw">decltype</span><span class="op">(</span><em>conj-if-needed</em><span class="op">(</span>declval<span class="op">&lt;</span>NestedAccessor<span class="op">::</span>element_type<span class="op">&gt;()))&gt;</span>;</span>
<span id="cb39-5"><a href="#cb39-5" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> reference <span class="op">=</span> remove_const_t<span class="op">&lt;</span>element_type<span class="op">&gt;</span>;</span>
<span id="cb39-6"><a href="#cb39-6" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> data_handle_type <span class="op">=</span> <span class="kw">typename</span> NestedAccessor<span class="op">::</span>data_handle_type;</span>
<span id="cb39-7"><a href="#cb39-7" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> offset_policy <span class="op">=</span> conjugated_accessor<span class="op">&lt;</span>NestedAccessor<span class="op">::</span>offset_policy<span class="op">&gt;</span>;</span>
<span id="cb39-8"><a href="#cb39-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb39-9"><a href="#cb39-9" aria-hidden="true" tabindex="-1"></a>  <span class="kw">constexpr</span> conjugated_accessor<span class="op">()</span> <span class="op">=</span> <span class="cf">default</span>;</span>
<span id="cb39-10"><a href="#cb39-10" aria-hidden="true" tabindex="-1"></a>  <span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> OtherNestedAccessor<span class="op">&gt;</span></span>
<span id="cb39-11"><a href="#cb39-11" aria-hidden="true" tabindex="-1"></a>    <span class="kw">explicit</span><span class="op">(!</span>is_convertible_v<span class="op">&lt;</span>OtherNestedAccessor, NestedAccessor<span class="op">&gt;&gt;)</span></span>
<span id="cb39-12"><a href="#cb39-12" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> conjugated_accessor<span class="op">(</span><span class="kw">const</span> conjugated_accessor<span class="op">&lt;</span>OtherNestedAccessor<span class="op">&gt;&amp;</span> other<span class="op">)</span>;</span>
<span id="cb39-13"><a href="#cb39-13" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb39-14"><a href="#cb39-14" aria-hidden="true" tabindex="-1"></a>  <span class="kw">constexpr</span> reference access<span class="op">(</span>data_handle_type p, <span class="dt">size_t</span> i<span class="op">)</span> <span class="kw">const</span>;</span>
<span id="cb39-15"><a href="#cb39-15" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb39-16"><a href="#cb39-16" aria-hidden="true" tabindex="-1"></a>  <span class="kw">constexpr</span> <span class="kw">typename</span> offset_policy<span class="op">::</span>data_handle_type</span>
<span id="cb39-17"><a href="#cb39-17" aria-hidden="true" tabindex="-1"></a>    offset<span class="op">(</span>data_handle_type p, <span class="dt">size_t</span> i<span class="op">)</span> <span class="kw">const</span>;</span>
<span id="cb39-18"><a href="#cb39-18" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb39-19"><a href="#cb39-19" aria-hidden="true" tabindex="-1"></a>  <span class="kw">constexpr</span> <span class="kw">const</span> Accessor<span class="op">&amp;</span> nested_accessor<span class="op">()</span> <span class="kw">const</span> <span class="kw">noexcept</span> <span class="op">{</span> <span class="cf">return</span> <em>nested-accessor_</em>; <span class="op">}</span></span>
<span id="cb39-20"><a href="#cb39-20" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb39-21"><a href="#cb39-21" aria-hidden="true" tabindex="-1"></a><span class="kw">private</span><span class="op">:</span></span>
<span id="cb39-22"><a href="#cb39-22" aria-hidden="true" tabindex="-1"></a>  NestedAccessor <em>nested-accessor_</em><span class="op">{}</span>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb39-23"><a href="#cb39-23" aria-hidden="true" tabindex="-1"></a><span class="op">}</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span>
<code>element_type</code> is valid and denotes a type,</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
<code>is_copy_constructible_v&lt;reference&gt;</code> is
<code>true</code>,</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.3)</a></span>
<code>is_reference_v&lt;element_type&gt;</code> is <code>false</code>,
and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.4)</a></span>
<code>NestedAccessor</code> meets the accessor policy requirements
[mdspan.accessor.reqmts].</p></li>
</ul>
<div class="sourceCode" id="cb40"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb40-1"><a href="#cb40-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> conjugated_accessor<span class="op">(</span><span class="kw">const</span> NestedAccessor<span class="op">&amp;</span> acc<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Effects:</em> Direct-non-list-initializes
<em><code>nested-accessor_</code></em> with <code>acc</code>.</p>
<div class="sourceCode" id="cb41"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb41-1"><a href="#cb41-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> OtherNestedAccessor<span class="op">&gt;</span></span>
<span id="cb41-2"><a href="#cb41-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">explicit</span><span class="op">(!</span>is_convertible_v<span class="op">&lt;</span>OtherNestedAccessor, NestedAccessor<span class="op">&gt;&gt;)</span></span>
<span id="cb41-3"><a href="#cb41-3" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> conjugated_accessor<span class="op">(</span><span class="kw">const</span> conjugated_accessor<span class="op">&lt;</span>OtherNestedAccessor<span class="op">&gt;&amp;</span> other<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Constraints:</em>
<code>is_constructible_v&lt;NestedAccessor, const OtherNestedAccessor&amp;&gt;</code>
is <code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
<em>Effects:</em> Direct-non-list-initializes
<em><code>nested-accessor_</code></em> with
<code>other.nested_accessor()</code>.</p>
<div class="sourceCode" id="cb42"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb42-1"><a href="#cb42-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> reference access<span class="op">(</span>data_handle_type p, <span class="dt">size_t</span> i<span class="op">)</span> <span class="kw">const</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Returns:</em>
<em><code>conj-if-needed</code></em><code>(NestedAccessor::element_type(</code><em><code>nested-accessor_</code></em><code>.access(p, i)))</code></p>
<div class="sourceCode" id="cb43"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb43-1"><a href="#cb43-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="kw">typename</span> offset_policy<span class="op">::</span>data_handle_type</span>
<span id="cb43-2"><a href="#cb43-2" aria-hidden="true" tabindex="-1"></a>  offset<span class="op">(</span>data_handle_type p, <span class="dt">size_t</span> i<span class="op">)</span> <span class="kw">const</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
<em>Returns:</em>
<em><code>nested-accessor_</code></em><code>.offset(p, i)</code></p>
<h4 data-number="28.9.9.3" id="function-template-conjugated-linalg.conj.conjugated"><span class="header-section-number">28.9.9.3</span> Function template
<code>conjugated</code> [linalg.conj.conjugated]<a href="#function-template-conjugated-linalg.conj.conjugated" class="self-link"></a></h4>
<div class="sourceCode" id="cb44"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb44-1"><a href="#cb44-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ElementType,</span>
<span id="cb44-2"><a href="#cb44-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Extents,</span>
<span id="cb44-3"><a href="#cb44-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Layout,</span>
<span id="cb44-4"><a href="#cb44-4" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Accessor<span class="op">&gt;</span></span>
<span id="cb44-5"><a href="#cb44-5" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="kw">auto</span> conjugated<span class="op">(</span></span>
<span id="cb44-6"><a href="#cb44-6" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span>ElementType, Extents, Layout, Accessor<span class="op">&gt;</span> a<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
Let <code>A</code> be
<code>remove_cvref_t&lt;decltype(a.accessor().nested_accessor())&gt;</code>
if <code>Accessor</code> is a specialization of
<code>conjugated_accessor</code>, and otherwise
<code>conjugated_accessor&lt;Accessor&gt;</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Returns:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span>
<code>mdspan&lt;typename A::element_type, Extents, Layout, A&gt;(a.data_handle(), a.mapping(), a.accessor().nested_accessor())</code>
if <code>Accessor</code> is a specialization of
<code>conjugated_accessor</code>; otherwise</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
<code>mdspan&lt;typename A::element_type, Extents, Layout, A&gt;(a.data_handle(), a.mapping(), conjugated_accessor(a.accessor()))</code>.</p></li>
</ul>
<p>[<em>Example:</em></p>
<div class="sourceCode" id="cb45"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb45-1"><a href="#cb45-1" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> test_conjugated_complex<span class="op">(</span></span>
<span id="cb45-2"><a href="#cb45-2" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span>complex<span class="op">&lt;</span><span class="dt">double</span><span class="op">&gt;</span>, extents<span class="op">&lt;</span><span class="dt">int</span>, <span class="dv">10</span><span class="op">&gt;&gt;</span> a<span class="op">)</span></span>
<span id="cb45-3"><a href="#cb45-3" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb45-4"><a href="#cb45-4" aria-hidden="true" tabindex="-1"></a>  <span class="kw">auto</span> a_conj <span class="op">=</span> conjugated<span class="op">(</span>a<span class="op">)</span>;</span>
<span id="cb45-5"><a href="#cb45-5" aria-hidden="true" tabindex="-1"></a>  <span class="cf">for</span><span class="op">(</span><span class="dt">int</span> i <span class="op">=</span> <span class="dv">0</span>; i <span class="op">&lt;</span> a<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>; <span class="op">++</span>i<span class="op">)</span> <span class="op">{</span></span>
<span id="cb45-6"><a href="#cb45-6" aria-hidden="true" tabindex="-1"></a>    <span class="ot">assert</span><span class="op">(</span>a_conj<span class="op">[</span>i<span class="op">]</span> <span class="op">==</span> conj<span class="op">(</span>a<span class="op">[</span>i<span class="op">])</span>;</span>
<span id="cb45-7"><a href="#cb45-7" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb45-8"><a href="#cb45-8" aria-hidden="true" tabindex="-1"></a>  <span class="kw">auto</span> a_conj_conj <span class="op">=</span> conjugated<span class="op">(</span>a_conj<span class="op">)</span>;</span>
<span id="cb45-9"><a href="#cb45-9" aria-hidden="true" tabindex="-1"></a>  <span class="cf">for</span><span class="op">(</span><span class="dt">int</span> i <span class="op">=</span> <span class="dv">0</span>; i <span class="op">&lt;</span> a<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>; <span class="op">++</span>i<span class="op">)</span> <span class="op">{</span></span>
<span id="cb45-10"><a href="#cb45-10" aria-hidden="true" tabindex="-1"></a>    <span class="ot">assert</span><span class="op">(</span>a_conj_conj<span class="op">[</span>i<span class="op">]</span> <span class="op">==</span> a<span class="op">[</span>i<span class="op">])</span>;</span>
<span id="cb45-11"><a href="#cb45-11" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb45-12"><a href="#cb45-12" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span>
<span id="cb45-13"><a href="#cb45-13" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb45-14"><a href="#cb45-14" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> test_conjugated_real<span class="op">(</span></span>
<span id="cb45-15"><a href="#cb45-15" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span><span class="dt">double</span>, extents<span class="op">&lt;</span><span class="dt">int</span>, <span class="dv">10</span><span class="op">&gt;&gt;</span> a<span class="op">)</span></span>
<span id="cb45-16"><a href="#cb45-16" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb45-17"><a href="#cb45-17" aria-hidden="true" tabindex="-1"></a>  <span class="kw">auto</span> a_conj <span class="op">=</span> conjugated<span class="op">(</span>a<span class="op">)</span>;</span>
<span id="cb45-18"><a href="#cb45-18" aria-hidden="true" tabindex="-1"></a>  <span class="cf">for</span><span class="op">(</span><span class="dt">int</span> i <span class="op">=</span> <span class="dv">0</span>; i <span class="op">&lt;</span> a<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>; <span class="op">++</span>i<span class="op">)</span> <span class="op">{</span></span>
<span id="cb45-19"><a href="#cb45-19" aria-hidden="true" tabindex="-1"></a>    <span class="ot">assert</span><span class="op">(</span>a_conj<span class="op">[</span>i<span class="op">]</span> <span class="op">==</span> a<span class="op">[</span>i<span class="op">])</span>;</span>
<span id="cb45-20"><a href="#cb45-20" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb45-21"><a href="#cb45-21" aria-hidden="true" tabindex="-1"></a>  <span class="kw">auto</span> a_conj_conj <span class="op">=</span> conjugated<span class="op">(</span>a_conj<span class="op">)</span>;</span>
<span id="cb45-22"><a href="#cb45-22" aria-hidden="true" tabindex="-1"></a>  <span class="cf">for</span><span class="op">(</span><span class="dt">int</span> i <span class="op">=</span> <span class="dv">0</span>; i <span class="op">&lt;</span> a<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>; <span class="op">++</span>i<span class="op">)</span> <span class="op">{</span></span>
<span id="cb45-23"><a href="#cb45-23" aria-hidden="true" tabindex="-1"></a>    <span class="ot">assert</span><span class="op">(</span>a_conj_conj<span class="op">[</span>i<span class="op">]</span> <span class="op">==</span> a<span class="op">[</span>i<span class="op">])</span>;</span>
<span id="cb45-24"><a href="#cb45-24" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb45-25"><a href="#cb45-25" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<p>–<em>end example</em>]</p>
<h3 data-number="28.9.10" id="transpose-in-place-transformation-linalg.transp"><span class="header-section-number">28.9.10</span> Transpose in-place
transformation [linalg.transp]<a href="#transpose-in-place-transformation-linalg.transp" class="self-link"></a></h3>
<h4 data-number="28.9.10.1" id="introduction-linalg.transp.intro"><span class="header-section-number">28.9.10.1</span> Introduction
[linalg.transp.intro]<a href="#introduction-linalg.transp.intro" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
<code>layout_transpose</code> is an <code>mdspan</code> layout mapping
policy that swaps the two indices, extents, and strides of any unique
<code>mdspan</code> layout mapping policy.</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
The <code>transposed</code> function takes an <code>mdspan</code>
representing a matrix, and returns a new <code>mdspan</code>
representing the transpose of the input matrix.</p>
<h4 data-number="28.9.10.2" id="exposition-only-helpers-for-layout_transpose-and-transposed-linalg.transp.helpers"><span class="header-section-number">28.9.10.2</span> Exposition-only helpers
for <code>layout_transpose</code> and <code>transposed</code>
[linalg.transp.helpers]<a href="#exposition-only-helpers-for-layout_transpose-and-transposed-linalg.transp.helpers" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The exposition-only <em><code>transpose-extents</code></em> function
takes an <code>extents</code> object representing the extents of a
matrix, and returns a new <code>extents</code> object representing the
extents of the transpose of the matrix.</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
The exposition-only alias template
<em><code>transpose-extents-t&lt;InputExtents&gt;</code></em> gives the
type of <em><code>transpose-extents</code></em><code>(e)</code> for a
given <code>extents</code> object <code>e</code> of type
<code>InputExtents</code>.</p>
<div class="sourceCode" id="cb46"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb46-1"><a href="#cb46-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> IndexType, <span class="dt">size_t</span> InputExtent0, <span class="dt">size_t</span> InputExtent1<span class="op">&gt;</span></span>
<span id="cb46-2"><a href="#cb46-2" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> extents<span class="op">&lt;</span>IndexType, InputExtent1, InputExtent0<span class="op">&gt;</span></span>
<span id="cb46-3"><a href="#cb46-3" aria-hidden="true" tabindex="-1"></a><em>transpose-extents</em><span class="op">(</span><span class="kw">const</span> extents<span class="op">&lt;</span>IndexType, InputExtent0, InputExtent1<span class="op">&gt;&amp;</span> in<span class="op">)</span>; <span class="co">// <em>exposition only</em></span></span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Returns:</em>
<code>extents&lt;IndexType, InputExtent1, InputExtent0&gt;(in.extent(1), in.extent(0))</code></p>
<div class="sourceCode" id="cb47"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb47-1"><a href="#cb47-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> InputExtents<span class="op">&gt;</span></span>
<span id="cb47-2"><a href="#cb47-2" aria-hidden="true" tabindex="-1"></a><span class="kw">using</span> <em>transpose-extents-t</em> <span class="op">=</span></span>
<span id="cb47-3"><a href="#cb47-3" aria-hidden="true" tabindex="-1"></a>  <span class="kw">decltype</span><span class="op">(</span><em>transpose-extents</em><span class="op">(</span>declval<span class="op">&lt;</span>InputExtents<span class="op">&gt;()))</span>; <span class="co">// <em>exposition only</em></span></span></code></pre></div>
<h4 data-number="28.9.10.3" id="class-template-layout_transpose-linalg.transp.layout.transpose"><span class="header-section-number">28.9.10.3</span> Class template
<code>layout_transpose</code> [linalg.transp.layout.transpose]<a href="#class-template-layout_transpose-linalg.transp.layout.transpose" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
<code>layout_transpose</code> is an <code>mdspan</code> layout mapping
policy that swaps the two indices, extents, and strides of any
<code>mdspan</code> layout mapping policy.</p>
<div class="sourceCode" id="cb48"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb48-1"><a href="#cb48-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Layout<span class="op">&gt;</span></span>
<span id="cb48-2"><a href="#cb48-2" aria-hidden="true" tabindex="-1"></a><span class="kw">class</span> layout_transpose <span class="op">{</span></span>
<span id="cb48-3"><a href="#cb48-3" aria-hidden="true" tabindex="-1"></a><span class="kw">public</span><span class="op">:</span></span>
<span id="cb48-4"><a href="#cb48-4" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> nested_layout_type <span class="op">=</span> Layout;</span>
<span id="cb48-5"><a href="#cb48-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-6"><a href="#cb48-6" aria-hidden="true" tabindex="-1"></a>  <span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Extents<span class="op">&gt;</span></span>
<span id="cb48-7"><a href="#cb48-7" aria-hidden="true" tabindex="-1"></a>  <span class="kw">struct</span> mapping <span class="op">{</span></span>
<span id="cb48-8"><a href="#cb48-8" aria-hidden="true" tabindex="-1"></a>  <span class="kw">private</span><span class="op">:</span></span>
<span id="cb48-9"><a href="#cb48-9" aria-hidden="true" tabindex="-1"></a>    <span class="kw">using</span> <em>nested-mapping-type</em> <span class="op">=</span></span>
<span id="cb48-10"><a href="#cb48-10" aria-hidden="true" tabindex="-1"></a>      <span class="kw">typename</span> Layout<span class="op">::</span><span class="kw">template</span> mapping<span class="op">&lt;</span></span>
<span id="cb48-11"><a href="#cb48-11" aria-hidden="true" tabindex="-1"></a>        <em>transpose-extents-t</em><span class="op">&lt;</span>Extents<span class="op">&gt;&gt;</span>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb48-12"><a href="#cb48-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-13"><a href="#cb48-13" aria-hidden="true" tabindex="-1"></a>  <span class="kw">public</span><span class="op">:</span></span>
<span id="cb48-14"><a href="#cb48-14" aria-hidden="true" tabindex="-1"></a>    <span class="kw">using</span> extents_type <span class="op">=</span> Extents;</span>
<span id="cb48-15"><a href="#cb48-15" aria-hidden="true" tabindex="-1"></a>    <span class="kw">using</span> index_type <span class="op">=</span> <span class="kw">typename</span> extents_type<span class="op">::</span>index_type;</span>
<span id="cb48-16"><a href="#cb48-16" aria-hidden="true" tabindex="-1"></a>    <span class="kw">using</span> size_type <span class="op">=</span> <span class="kw">typename</span> extents_type<span class="op">::</span>size_type;</span>
<span id="cb48-17"><a href="#cb48-17" aria-hidden="true" tabindex="-1"></a>    <span class="kw">using</span> rank_type <span class="op">=</span> <span class="kw">typename</span> extents_type<span class="op">::</span>rank_type;</span>
<span id="cb48-18"><a href="#cb48-18" aria-hidden="true" tabindex="-1"></a>    <span class="kw">using</span> layout_type <span class="op">=</span> layout_transpose;</span>
<span id="cb48-19"><a href="#cb48-19" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-20"><a href="#cb48-20" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> <span class="kw">explicit</span> mapping<span class="op">(</span><span class="kw">const</span> <em>nested-mapping-type</em><span class="op">&amp;)</span>;</span>
<span id="cb48-21"><a href="#cb48-21" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-22"><a href="#cb48-22" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> <span class="kw">const</span> extents_type<span class="op">&amp;</span> extents<span class="op">()</span> <span class="kw">const</span> <span class="kw">noexcept</span></span>
<span id="cb48-23"><a href="#cb48-23" aria-hidden="true" tabindex="-1"></a>      <span class="op">{</span> <span class="cf">return</span> <em>extents_</em>; <span class="op">}</span></span>
<span id="cb48-24"><a href="#cb48-24" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-25"><a href="#cb48-25" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> index_type required_span_size<span class="op">()</span> <span class="kw">const</span></span>
<span id="cb48-26"><a href="#cb48-26" aria-hidden="true" tabindex="-1"></a>      <span class="op">{</span> <span class="cf">return</span> <em>nested-mapping_</em><span class="op">.</span>required_span_size<span class="op">()</span>; <span class="op">}</span></span>
<span id="cb48-27"><a href="#cb48-27" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-28"><a href="#cb48-28" aria-hidden="true" tabindex="-1"></a>    <span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Index0, <span class="kw">class</span> Index1<span class="op">&gt;</span></span>
<span id="cb48-29"><a href="#cb48-29" aria-hidden="true" tabindex="-1"></a>      <span class="kw">constexpr</span> index_type <span class="kw">operator</span><span class="op">()(</span>Index0 ind0, Index1 ind1<span class="op">)</span> <span class="kw">const</span></span>
<span id="cb48-30"><a href="#cb48-30" aria-hidden="true" tabindex="-1"></a>      <span class="op">{</span> <span class="cf">return</span> <em>nested-mapping_</em><span class="op">(</span>ind1, ind0<span class="op">)</span>; <span class="op">}</span></span>
<span id="cb48-31"><a href="#cb48-31" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-32"><a href="#cb48-32" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> <span class="kw">const</span> <em>nested-mapping-type</em><span class="op">&amp;</span> nested_mapping<span class="op">()</span> <span class="kw">const</span> <span class="kw">noexcept</span></span>
<span id="cb48-33"><a href="#cb48-33" aria-hidden="true" tabindex="-1"></a>      <span class="op">{</span> <span class="cf">return</span> <em>nested-mapping_</em>; <span class="op">}</span></span>
<span id="cb48-34"><a href="#cb48-34" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-35"><a href="#cb48-35" aria-hidden="true" tabindex="-1"></a>    <span class="kw">static</span> <span class="kw">constexpr</span> <span class="dt">bool</span> is_always_unique<span class="op">()</span> <span class="kw">noexcept</span></span>
<span id="cb48-36"><a href="#cb48-36" aria-hidden="true" tabindex="-1"></a>      <span class="op">{</span> <span class="cf">return</span> <em>nested-mapping-type</em><span class="op">::</span>is_always_unique<span class="op">()</span>; <span class="op">}</span></span>
<span id="cb48-37"><a href="#cb48-37" aria-hidden="true" tabindex="-1"></a>    <span class="kw">static</span> <span class="kw">constexpr</span> <span class="dt">bool</span> is_always_exhaustive<span class="op">()</span> <span class="kw">noexcept</span></span>
<span id="cb48-38"><a href="#cb48-38" aria-hidden="true" tabindex="-1"></a>      <span class="op">{</span> <span class="cf">return</span> <em>nested-mapping_type</em><span class="op">::</span>is_always_exhaustive<span class="op">()</span>; <span class="op">}</span></span>
<span id="cb48-39"><a href="#cb48-39" aria-hidden="true" tabindex="-1"></a>    <span class="kw">static</span> <span class="kw">constexpr</span> <span class="dt">bool</span> is_always_strided<span class="op">()</span> <span class="kw">noexcept</span></span>
<span id="cb48-40"><a href="#cb48-40" aria-hidden="true" tabindex="-1"></a>      <span class="op">{</span> <span class="cf">return</span> <em>nested-mapping_type</em><span class="op">::</span>is_always_strided<span class="op">()</span>; <span class="op">}</span></span>
<span id="cb48-41"><a href="#cb48-41" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-42"><a href="#cb48-42" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> <span class="dt">bool</span> is_unique<span class="op">()</span> <span class="kw">const</span></span>
<span id="cb48-43"><a href="#cb48-43" aria-hidden="true" tabindex="-1"></a>      <span class="op">{</span> <span class="cf">return</span> <em>nested-mapping_</em><span class="op">.</span>is_unique<span class="op">()</span>; <span class="op">}</span></span>
<span id="cb48-44"><a href="#cb48-44" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> <span class="dt">bool</span> is_exhaustive<span class="op">()</span> <span class="kw">const</span></span>
<span id="cb48-45"><a href="#cb48-45" aria-hidden="true" tabindex="-1"></a>      <span class="op">{</span> <span class="cf">return</span> <em>nested-mapping_</em><span class="op">.</span>is_exhaustive<span class="op">()</span>; <span class="op">}</span></span>
<span id="cb48-46"><a href="#cb48-46" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> <span class="dt">bool</span> is_strided<span class="op">()</span> <span class="kw">const</span></span>
<span id="cb48-47"><a href="#cb48-47" aria-hidden="true" tabindex="-1"></a>      <span class="op">{</span> <span class="cf">return</span> <em>nested-mapping_</em><span class="op">.</span>is_strided<span class="op">()</span>; <span class="op">}</span></span>
<span id="cb48-48"><a href="#cb48-48" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-49"><a href="#cb48-49" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> index_type stride<span class="op">(</span><span class="dt">size_t</span> r<span class="op">)</span> <span class="kw">const</span>;</span>
<span id="cb48-50"><a href="#cb48-50" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-51"><a href="#cb48-51" aria-hidden="true" tabindex="-1"></a>    <span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> OtherExtents<span class="op">&gt;</span></span>
<span id="cb48-52"><a href="#cb48-52" aria-hidden="true" tabindex="-1"></a>      <span class="kw">friend</span> <span class="kw">constexpr</span> <span class="dt">bool</span></span>
<span id="cb48-53"><a href="#cb48-53" aria-hidden="true" tabindex="-1"></a>        <span class="kw">operator</span><span class="op">==(</span><span class="kw">const</span> mapping<span class="op">&amp;</span> x, <span class="kw">const</span> mapping<span class="op">&lt;</span>OtherExtents<span class="op">&gt;&amp;</span> y<span class="op">)</span>;</span>
<span id="cb48-54"><a href="#cb48-54" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span>;</span>
<span id="cb48-55"><a href="#cb48-55" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-56"><a href="#cb48-56" aria-hidden="true" tabindex="-1"></a>  <span class="kw">private</span><span class="op">:</span></span>
<span id="cb48-57"><a href="#cb48-57" aria-hidden="true" tabindex="-1"></a>    <em>nested-mapping-type</em> <em>nested-mapping_</em>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb48-58"><a href="#cb48-58" aria-hidden="true" tabindex="-1"></a>    extents_type <em>extents_</em>; <span class="co">// <em>exposition only</em></span></span>
<span id="cb48-59"><a href="#cb48-59" aria-hidden="true" tabindex="-1"></a><span class="op">}</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<code>Layout</code> shall meet the layout mapping policy requirements
([mdspan.layout.policy.reqmts]).</p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.1)</a></span>
<code>Extents</code> is a specialization of <code>std::extents</code>,
and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.2)</a></span>
<code>Extents::rank()</code> equals 2.</p></li>
</ul>
<div class="sourceCode" id="cb49"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb49-1"><a href="#cb49-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="kw">explicit</span> mapping<span class="op">(</span><span class="kw">const</span> <em>nested-mapping-type</em><span class="op">&amp;</span> map<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Effects:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.1)</a></span>
Initializes <em><code>nested-mapping_</code></em> with <code>map</code>,
and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.1)</a></span>
initializes <em><code>extents_</code></em> with
<em><code>transpose-extents</code></em><code>(map.extents())</code>.</p></li>
</ul>
<div class="sourceCode" id="cb50"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb50-1"><a href="#cb50-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> index_type stride<span class="op">(</span><span class="dt">size_t</span> r<span class="op">)</span> <span class="kw">const</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(5.1)</a></span>
<code>is_strided()</code> is <code>true</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(5.2)</a></span>
<code>r &lt; 2</code> is <code>true</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Returns:</em> <em><code>nested-mapping_</code></em>
<code>.stride(r == 0 ? 1 : 0)</code></p>
<div class="sourceCode" id="cb51"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb51-1"><a href="#cb51-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> OtherExtents<span class="op">&gt;</span></span>
<span id="cb51-2"><a href="#cb51-2" aria-hidden="true" tabindex="-1"></a>  <span class="kw">friend</span> <span class="kw">constexpr</span> <span class="dt">bool</span></span>
<span id="cb51-3"><a href="#cb51-3" aria-hidden="true" tabindex="-1"></a>    <span class="kw">operator</span><span class="op">==(</span><span class="kw">const</span> mapping<span class="op">&amp;</span> x, <span class="kw">const</span> mapping<span class="op">&lt;</span>OtherExtents<span class="op">&gt;&amp;</span> y<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
<em>Constraints:</em> The expression
<code>x.</code><em><code>nested-mapping_</code></em>
<code>== y.</code><em><code>nested-mapping_</code></em> is well-formed
and its result is convertible to <code>bool</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">8</a></span>
<em>Returns:</em> <code>x.</code><em><code>nested-mapping_</code></em>
<code>== y.</code><em><code>nested-mapping_</code></em>.</p>
<h4 data-number="28.9.10.4" id="function-template-transposed-linalg.transp.transposed"><span class="header-section-number">28.9.10.4</span> Function template
<code>transposed</code> [linalg.transp.transposed]<a href="#function-template-transposed-linalg.transp.transposed" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The <code>transposed</code> function takes a rank-2 <code>mdspan</code>
representing a matrix, and returns a new <code>mdspan</code>
representing the input matrix’s transpose. The input matrix’s data are
not modified, and the returned <code>mdspan</code> accesses the input
matrix’s data in place.</p>
<div class="sourceCode" id="cb52"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb52-1"><a href="#cb52-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ElementType,</span>
<span id="cb52-2"><a href="#cb52-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Extents,</span>
<span id="cb52-3"><a href="#cb52-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Layout,</span>
<span id="cb52-4"><a href="#cb52-4" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Accessor<span class="op">&gt;</span></span>
<span id="cb52-5"><a href="#cb52-5" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="kw">auto</span> transposed<span class="op">(</span></span>
<span id="cb52-6"><a href="#cb52-6" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span>ElementType, Extents, Layout, Accessor<span class="op">&gt;</span> a<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em> <code>Extents::rank() == 2</code> is
<code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
Let <code>ReturnExtents</code> be
<em><code>transpose-extents-t</code></em><code>&lt;Extents&gt;</code>.
Let <code>R</code> be
<code>mdspan&lt;ElementType, ReturnExtents, ReturnLayout, Accessor&gt;</code>,
where <code>ReturnLayout</code> is:</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.1)</a></span>
<code>layout_right</code> if <code>Layout</code> is
<code>layout_left</code>;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.2)</a></span>
otherwise, <code>layout_left</code> if <code>Layout</code> is
<code>layout_right</code>;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.3)</a></span>
otherwise, <code>layout_stride</code> if <code>Layout</code> is
<code>layout_stride</code>;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.4)</a></span>
otherwise,
<code>layout_blas_packed&lt;OppositeTriangle, OppositeStorageOrder&gt;</code>,
if <code>Layout</code> is
<code>layout_blas_packed&lt;Triangle, StorageOrder&gt;</code> for some
<code>Triangle</code> and <code>StorageOrder</code>, where</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.4.1)</a></span>
<code>OppositeTriangle</code> is
<code>conditional_t&lt;is_same_v&lt;Triangle, upper_triangle_t&gt;, lower_triangle_t, upper_triangle_t&gt;</code>,
and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.4.2)</a></span>
<code>OppositeStorageOrder</code> is
<code>conditional_t&lt;is_same_v&lt;StorageOrder, column_major_t&gt;, row_major_t, column_major_t&gt;</code>;</p></li>
</ul></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.5)</a></span>
otherwise, <code>NestedLayout</code> if <code>Layout</code> is
<code>layout_transpose&lt;NestedLayout&gt;</code> for some
<code>NestedLayout</code>;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.6)</a></span>
otherwise, <code>layout_transpose&lt;Layout&gt;</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Returns:</em> With <code>ReturnMapping</code> being the type
<code>typename ReturnLayout::template mapping&lt;ReturnExtents&gt;</code>:</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.1)</a></span>
<code>R(a.data_handle(), ReturnMapping(</code><em><code>transpose-extents</code></em><code>(a.mapping().extents())), a.accessor())</code>
if <code>Layout</code> is <code>layout_left</code>,
<code>layout_right</code>, or a specialization of
<code>layout_blas_packed</code>;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.2)</a></span>
otherwise,
<code>R(a.data_handle(), ReturnMapping(</code><em><code>transpose-extents</code></em><code>(a.mapping().extents()), array{a.mapping().stride(1), a.mapping().stride(0)}), a.accessor())</code>
if <code>Layout</code> is <code>layout_stride</code>;
<!-- this reverses the strides as well as the extents --></p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.3)</a></span>
otherwise,
<code>R(a.data_handle(), a.mapping().nested_mapping(), a.accessor())</code>
if <code>Layout</code> is a specialization of
<code>layout_transpose</code>;
<!-- getting the nested mapping untransposes the extents --></p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.4)</a></span>
otherwise,
<code>R(a.data_handle(), ReturnMapping(a.mapping()), a.accessor())</code>.</p></li>
</ul>
<p>[<em>Example:</em></p>
<div class="sourceCode" id="cb53"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb53-1"><a href="#cb53-1" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> test_transposed<span class="op">(</span>mdspan<span class="op">&lt;</span><span class="dt">double</span>, extents<span class="op">&lt;</span><span class="dt">size_t</span>, <span class="dv">3</span>, <span class="dv">4</span><span class="op">&gt;&gt;</span> a<span class="op">)</span></span>
<span id="cb53-2"><a href="#cb53-2" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb53-3"><a href="#cb53-3" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <span class="kw">auto</span> num_rows <span class="op">=</span> a<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>;</span>
<span id="cb53-4"><a href="#cb53-4" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <span class="kw">auto</span> num_cols <span class="op">=</span> a<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span>;</span>
<span id="cb53-5"><a href="#cb53-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb53-6"><a href="#cb53-6" aria-hidden="true" tabindex="-1"></a>  <span class="kw">auto</span> a_t <span class="op">=</span> transposed<span class="op">(</span>a<span class="op">)</span>;</span>
<span id="cb53-7"><a href="#cb53-7" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>num_rows <span class="op">==</span> a_t<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">))</span>;</span>
<span id="cb53-8"><a href="#cb53-8" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>num_cols <span class="op">==</span> a_t<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">))</span>;</span>
<span id="cb53-9"><a href="#cb53-9" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>a<span class="op">.</span>stride<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">==</span> a_t<span class="op">.</span>stride<span class="op">(</span><span class="dv">1</span><span class="op">))</span>;</span>
<span id="cb53-10"><a href="#cb53-10" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>a<span class="op">.</span>stride<span class="op">(</span><span class="dv">1</span><span class="op">)</span> <span class="op">==</span> a_t<span class="op">.</span>stride<span class="op">(</span><span class="dv">0</span><span class="op">))</span>;</span>
<span id="cb53-11"><a href="#cb53-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb53-12"><a href="#cb53-12" aria-hidden="true" tabindex="-1"></a>  <span class="cf">for</span><span class="op">(</span><span class="dt">size_t</span> row <span class="op">=</span> <span class="dv">0</span>; row <span class="op">&lt;</span> num_rows; <span class="op">++</span>row<span class="op">)</span> <span class="op">{</span></span>
<span id="cb53-13"><a href="#cb53-13" aria-hidden="true" tabindex="-1"></a>    <span class="cf">for</span><span class="op">(</span><span class="dt">size_t</span> col <span class="op">=</span> <span class="dv">0</span>; col <span class="op">&lt;</span> num_rows; <span class="op">++</span>col<span class="op">)</span> <span class="op">{</span></span>
<span id="cb53-14"><a href="#cb53-14" aria-hidden="true" tabindex="-1"></a>      <span class="ot">assert</span><span class="op">(</span>a<span class="op">[</span>row, col<span class="op">]</span> <span class="op">==</span> a_t<span class="op">[</span>col, row<span class="op">])</span>;</span>
<span id="cb53-15"><a href="#cb53-15" aria-hidden="true" tabindex="-1"></a>    <span class="op">}</span></span>
<span id="cb53-16"><a href="#cb53-16" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb53-17"><a href="#cb53-17" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb53-18"><a href="#cb53-18" aria-hidden="true" tabindex="-1"></a>  <span class="kw">auto</span> a_t_t <span class="op">=</span> transposed<span class="op">(</span>a_t<span class="op">)</span>;</span>
<span id="cb53-19"><a href="#cb53-19" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>num_rows <span class="op">==</span> a_t_t<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">))</span>;</span>
<span id="cb53-20"><a href="#cb53-20" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>num_cols <span class="op">==</span> a_t_t<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">))</span>;</span>
<span id="cb53-21"><a href="#cb53-21" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>a<span class="op">.</span>stride<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">==</span> a_t_t<span class="op">.</span>stride<span class="op">(</span><span class="dv">0</span><span class="op">))</span>;</span>
<span id="cb53-22"><a href="#cb53-22" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>a<span class="op">.</span>stride<span class="op">(</span><span class="dv">1</span><span class="op">)</span> <span class="op">==</span> a_t_t<span class="op">.</span>stride<span class="op">(</span><span class="dv">1</span><span class="op">))</span>;</span>
<span id="cb53-23"><a href="#cb53-23" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb53-24"><a href="#cb53-24" aria-hidden="true" tabindex="-1"></a>  <span class="cf">for</span><span class="op">(</span><span class="dt">size_t</span> row <span class="op">=</span> <span class="dv">0</span>; row <span class="op">&lt;</span> num_rows; <span class="op">++</span>row<span class="op">)</span> <span class="op">{</span></span>
<span id="cb53-25"><a href="#cb53-25" aria-hidden="true" tabindex="-1"></a>    <span class="cf">for</span><span class="op">(</span><span class="dt">size_t</span> col <span class="op">=</span> <span class="dv">0</span>; col <span class="op">&lt;</span> num_rows; <span class="op">++</span>col<span class="op">)</span> <span class="op">{</span></span>
<span id="cb53-26"><a href="#cb53-26" aria-hidden="true" tabindex="-1"></a>      <span class="ot">assert</span><span class="op">(</span>a<span class="op">[</span>row, col<span class="op">]</span> <span class="op">==</span> a_t_t<span class="op">[</span>row, col<span class="op">])</span>;</span>
<span id="cb53-27"><a href="#cb53-27" aria-hidden="true" tabindex="-1"></a>    <span class="op">}</span></span>
<span id="cb53-28"><a href="#cb53-28" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb53-29"><a href="#cb53-29" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<p>–<em>end example</em>]</p>
<h3 data-number="28.9.11" id="conjugate-transpose-in-place-transform-linalg.conjtransposed"><span class="header-section-number">28.9.11</span> Conjugate transpose
in-place transform [linalg.conjtransposed]<a href="#conjugate-transpose-in-place-transform-linalg.conjtransposed" class="self-link"></a></h3>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The <code>conjugate_transposed</code> function returns a conjugate
transpose view of an object. This combines the effects of
<code>transposed</code> and <code>conjugated</code>.</p>
<div class="sourceCode" id="cb54"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb54-1"><a href="#cb54-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ElementType,</span>
<span id="cb54-2"><a href="#cb54-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Extents,</span>
<span id="cb54-3"><a href="#cb54-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Layout,</span>
<span id="cb54-4"><a href="#cb54-4" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Accessor<span class="op">&gt;</span></span>
<span id="cb54-5"><a href="#cb54-5" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="kw">auto</span> conjugate_transposed<span class="op">(</span></span>
<span id="cb54-6"><a href="#cb54-6" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span>ElementType, Extents, Layout, Accessor<span class="op">&gt;</span> a<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Effects:</em> Equivalent to:
<code>return conjugated(transposed(a));</code></p>
<p>[<em>Example:</em></p>
<div class="sourceCode" id="cb55"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb55-1"><a href="#cb55-1" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> test_conjugate_transposed<span class="op">(</span></span>
<span id="cb55-2"><a href="#cb55-2" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span>complex<span class="op">&lt;</span><span class="dt">double</span><span class="op">&gt;</span>, extents<span class="op">&lt;</span><span class="dt">size_t</span>, <span class="dv">3</span>, <span class="dv">4</span><span class="op">&gt;&gt;</span> a<span class="op">)</span></span>
<span id="cb55-3"><a href="#cb55-3" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb55-4"><a href="#cb55-4" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <span class="kw">auto</span> num_rows <span class="op">=</span> a<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>;</span>
<span id="cb55-5"><a href="#cb55-5" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <span class="kw">auto</span> num_cols <span class="op">=</span> a<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span>;</span>
<span id="cb55-6"><a href="#cb55-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb55-7"><a href="#cb55-7" aria-hidden="true" tabindex="-1"></a>  <span class="kw">auto</span> a_ct <span class="op">=</span> conjugate_transposed<span class="op">(</span>a<span class="op">)</span>;</span>
<span id="cb55-8"><a href="#cb55-8" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>num_rows <span class="op">==</span> a_ct<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">))</span>;</span>
<span id="cb55-9"><a href="#cb55-9" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>num_cols <span class="op">==</span> a_ct<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">))</span>;</span>
<span id="cb55-10"><a href="#cb55-10" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>a<span class="op">.</span>stride<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">==</span> a_ct<span class="op">.</span>stride<span class="op">(</span><span class="dv">1</span><span class="op">))</span>;</span>
<span id="cb55-11"><a href="#cb55-11" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>a<span class="op">.</span>stride<span class="op">(</span><span class="dv">1</span><span class="op">)</span> <span class="op">==</span> a_ct<span class="op">.</span>stride<span class="op">(</span><span class="dv">0</span><span class="op">))</span>;</span>
<span id="cb55-12"><a href="#cb55-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb55-13"><a href="#cb55-13" aria-hidden="true" tabindex="-1"></a>  <span class="cf">for</span><span class="op">(</span><span class="dt">size_t</span> row <span class="op">=</span> <span class="dv">0</span>; row <span class="op">&lt;</span> num_rows; <span class="op">++</span>row<span class="op">)</span> <span class="op">{</span></span>
<span id="cb55-14"><a href="#cb55-14" aria-hidden="true" tabindex="-1"></a>    <span class="cf">for</span><span class="op">(</span><span class="dt">size_t</span> col <span class="op">=</span> <span class="dv">0</span>; col <span class="op">&lt;</span> num_rows; <span class="op">++</span>col<span class="op">)</span> <span class="op">{</span></span>
<span id="cb55-15"><a href="#cb55-15" aria-hidden="true" tabindex="-1"></a>      <span class="ot">assert</span><span class="op">(</span>a<span class="op">[</span>row, col<span class="op">]</span> <span class="op">==</span> conj<span class="op">(</span>a_ct<span class="op">[</span>col, row<span class="op">]))</span>;</span>
<span id="cb55-16"><a href="#cb55-16" aria-hidden="true" tabindex="-1"></a>    <span class="op">}</span></span>
<span id="cb55-17"><a href="#cb55-17" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb55-18"><a href="#cb55-18" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb55-19"><a href="#cb55-19" aria-hidden="true" tabindex="-1"></a>  <span class="kw">auto</span> a_ct_ct <span class="op">=</span> conjugate_transposed<span class="op">(</span>a_ct<span class="op">)</span>;</span>
<span id="cb55-20"><a href="#cb55-20" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>num_rows <span class="op">==</span> a_ct_ct<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">))</span>;</span>
<span id="cb55-21"><a href="#cb55-21" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>num_cols <span class="op">==</span> a_ct_ct<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">))</span>;</span>
<span id="cb55-22"><a href="#cb55-22" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>a<span class="op">.</span>stride<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">==</span> a_ct_ct<span class="op">.</span>stride<span class="op">(</span><span class="dv">0</span><span class="op">))</span>;</span>
<span id="cb55-23"><a href="#cb55-23" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>a<span class="op">.</span>stride<span class="op">(</span><span class="dv">1</span><span class="op">)</span> <span class="op">==</span> a_ct_ct<span class="op">.</span>stride<span class="op">(</span><span class="dv">1</span><span class="op">))</span>;</span>
<span id="cb55-24"><a href="#cb55-24" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb55-25"><a href="#cb55-25" aria-hidden="true" tabindex="-1"></a>  <span class="cf">for</span><span class="op">(</span><span class="dt">size_t</span> row <span class="op">=</span> <span class="dv">0</span>; row <span class="op">&lt;</span> num_rows; <span class="op">++</span>row<span class="op">)</span> <span class="op">{</span></span>
<span id="cb55-26"><a href="#cb55-26" aria-hidden="true" tabindex="-1"></a>    <span class="cf">for</span><span class="op">(</span><span class="dt">size_t</span> col <span class="op">=</span> <span class="dv">0</span>; col <span class="op">&lt;</span> num_rows; <span class="op">++</span>col<span class="op">)</span> <span class="op">{</span></span>
<span id="cb55-27"><a href="#cb55-27" aria-hidden="true" tabindex="-1"></a>      <span class="ot">assert</span><span class="op">(</span>a<span class="op">[</span>row, col<span class="op">]</span> <span class="op">==</span> a_ct_ct<span class="op">[</span>row, col<span class="op">])</span>;</span>
<span id="cb55-28"><a href="#cb55-28" aria-hidden="true" tabindex="-1"></a>      <span class="ot">assert</span><span class="op">(</span>conj<span class="op">(</span>a_ct<span class="op">[</span>col, row<span class="op">])</span> <span class="op">==</span> a_ct_ct<span class="op">[</span>row, col<span class="op">])</span>;</span>
<span id="cb55-29"><a href="#cb55-29" aria-hidden="true" tabindex="-1"></a>    <span class="op">}</span></span>
<span id="cb55-30"><a href="#cb55-30" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb55-31"><a href="#cb55-31" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<p>–<em>end example</em>]</p>
<h3 data-number="28.9.12" id="algorithm-requirements-based-on-template-parameter-name-linalg.algs.reqs"><span class="header-section-number">28.9.12</span> Algorithm Requirements
based on template parameter name [linalg.algs.reqs]<a href="#algorithm-requirements-based-on-template-parameter-name-linalg.algs.reqs" class="self-link"></a></h3>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
Throughout [linalg.algs.blas1], [linalg.algs.blas2], and
[linalg.algs.blas3], where the template parameters are not constrained,
the names of template parameters are used to express the following
Constraints. <!--
See **[algorithms.requirements]** 4 for this phrasing.
--></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.1)</a></span>
<code>is_execution_policy&lt;ExecutionPolicy&gt;::value</code> is
<code>true</code> (<strong>[execpol.type]</strong>).</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.2)</a></span>
<code>Real</code> is any type such that <code>complex&lt;Real&gt;</code>
is specified (<strong>[complex.numbers.general]</strong>).</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.3)</a></span>
<code>Triangle</code> is either <code>upper_triangle_t</code> or
<code>lower_triangle_t</code>.</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(1.4)</a></span>
<code>DiagonalStorage</code> is either
<code>implicit_unit_diagonal_t</code> or
<code>explicit_diagonal_t</code>.</p></li>
</ul>
<p><i>[Note:</i> Function templates that have a template parameter named
<code>ExecutionPolicy</code> are parallel algorithms
(<strong>[algorithms.parallel.defns]</strong>). <i>– end note]</i></p>
<h3 data-number="28.9.13" id="blas-1-algorithms-linalg.algs.blas1"><span class="header-section-number">28.9.13</span> BLAS 1 algorithms
[linalg.algs.blas1]<a href="#blas-1-algorithms-linalg.algs.blas1" class="self-link"></a></h3>
<h4 data-number="28.9.13.1" id="complexity-linalg.algs.blas1.complexity"><span class="header-section-number">28.9.13.1</span> Complexity
[linalg.algs.blas1.complexity]<a href="#complexity-linalg.algs.blas1.complexity" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
<em>Complexity:</em> All algorithms in [linalg.algs.blas1] with
<code>mdspan</code> parameters perform a count of <code>mdspan</code>
array accesses and arithmetic operations that is linear in the maximum
product of extents of any <code>mdspan</code> parameter.</p>
<h4 data-number="28.9.13.2" id="givens-rotations-linalg.algs.blas1.givens"><span class="header-section-number">28.9.13.2</span> Givens rotations
[linalg.algs.blas1.givens]<a href="#givens-rotations-linalg.algs.blas1.givens" class="self-link"></a></h4>
<h5 data-number="28.9.13.2.1" id="compute-givens-rotation-linalg.algs.blas1.givens.lartg"><span class="header-section-number">28.9.13.2.1</span> Compute Givens rotation
[linalg.algs.blas1.givens.lartg]<a href="#compute-givens-rotation-linalg.algs.blas1.givens.lartg" class="self-link"></a></h5>
<div class="sourceCode" id="cb56"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb56-1"><a href="#cb56-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Real<span class="op">&gt;</span></span>
<span id="cb56-2"><a href="#cb56-2" aria-hidden="true" tabindex="-1"></a>setup_givens_rotation_result<span class="op">&lt;</span>Real<span class="op">&gt;</span></span>
<span id="cb56-3"><a href="#cb56-3" aria-hidden="true" tabindex="-1"></a>setup_givens_rotation<span class="op">(</span>Real a, Real b<span class="op">)</span> <span class="kw">noexcept</span>;</span>
<span id="cb56-4"><a href="#cb56-4" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Real<span class="op">&gt;</span></span>
<span id="cb56-5"><a href="#cb56-5" aria-hidden="true" tabindex="-1"></a>setup_givens_rotation_result<span class="op">&lt;</span>complex<span class="op">&lt;</span>Real<span class="op">&gt;&gt;</span></span>
<span id="cb56-6"><a href="#cb56-6" aria-hidden="true" tabindex="-1"></a>setup_givens_rotation<span class="op">(</span>complex<span class="op">&lt;</span>Real<span class="op">&gt;</span> a, complex<span class="op">&lt;</span>Real<span class="op">&gt;</span> b<span class="op">)</span> <span class="kw">noexcept</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
These functions compute the Givens plane rotation represented by the two
values <span class="math inline"><em>c</em></span> and <span class="math inline"><em>s</em></span> such that the 2 x 2 system of
equations</p>
<table>
<tbody><tr>
<td>
<span class="math inline"><em>c</em></span>
</td>
<td>
<span class="math inline"><em>s</em></span>
</td>
</tr>
<tr>
<td>
<span class="math inline"> − <em>s̄</em></span>
</td>
<td>
<span class="math inline"><em>c</em></span>
</td>
</tr>
</tbody></table>
<span class="math inline">⋅</span>
<table>
<tbody><tr>
<td>
<span class="math inline"><em>a</em></span>
</td>
</tr>
<tr>
<td>
<span class="math inline"><em>b</em></span>
</td>
</tr>
</tbody></table>
<span class="math inline">=</span>
<table>
<tbody><tr>
<td>
<span class="math inline"><em>r</em></span>
</td>
</tr>
<tr>
<td>
<span class="math inline">0</span>
</td>
</tr>
</tbody></table>
<p><i>[Note:</i> EDITORIAL NOTE: Preferred rendering would use the LaTeX
code like the following.</p>
<div class="sourceCode" id="cb57"><pre class="sourceCode default"><code class="sourceCode default"><span id="cb57-1"><a href="#cb57-1" aria-hidden="true" tabindex="-1"></a>\left[ \begin{matrix}</span>
<span id="cb57-2"><a href="#cb57-2" aria-hidden="true" tabindex="-1"></a>c             &amp; s \\</span>
<span id="cb57-3"><a href="#cb57-3" aria-hidden="true" tabindex="-1"></a>-\overline{s} &amp; c \\</span>
<span id="cb57-4"><a href="#cb57-4" aria-hidden="true" tabindex="-1"></a>\end{matrix} \right]</span>
<span id="cb57-5"><a href="#cb57-5" aria-hidden="true" tabindex="-1"></a>\cdot</span>
<span id="cb57-6"><a href="#cb57-6" aria-hidden="true" tabindex="-1"></a>\left[ \begin{matrix}</span>
<span id="cb57-7"><a href="#cb57-7" aria-hidden="true" tabindex="-1"></a>a \\</span>
<span id="cb57-8"><a href="#cb57-8" aria-hidden="true" tabindex="-1"></a>b \\</span>
<span id="cb57-9"><a href="#cb57-9" aria-hidden="true" tabindex="-1"></a>\end{matrix} \right]</span>
<span id="cb57-10"><a href="#cb57-10" aria-hidden="true" tabindex="-1"></a>=</span>
<span id="cb57-11"><a href="#cb57-11" aria-hidden="true" tabindex="-1"></a>\left[ \begin{matrix}</span>
<span id="cb57-12"><a href="#cb57-12" aria-hidden="true" tabindex="-1"></a>r \\</span>
<span id="cb57-13"><a href="#cb57-13" aria-hidden="true" tabindex="-1"></a>0 \\</span>
<span id="cb57-14"><a href="#cb57-14" aria-hidden="true" tabindex="-1"></a>\end{matrix} \right]</span></code></pre></div>
<p><i>– end note]</i></p>
<!--
<i>[Note:</i> use of monospaced text in this equation does not indicate C++ code <i>-- end note]</i>

-->
<p>holds, where <span class="math inline"><em>c</em></span> is always a
real scalar, and <span class="math inline"><em>c</em><sup>2</sup> + |<em>s</em>|<sup>2</sup> = 1</span>.</p>
<p>That is, <span class="math inline"><em>c</em></span> and <span class="math inline"><em>s</em></span> represent a 2 x 2 matrix, that
when multiplied by the right by the input vector whose components are
<span class="math inline"><em>a</em></span> and <span class="math inline"><em>b</em></span>, produces a result vector whose
first component <span class="math inline"><em>r</em></span> is the
Euclidean norm of the input vector, and whose second component as
zero.</p>
<p><i>[Note:</i> These functions correspond to the LAPACK function
<code>xLARTG</code>. <i>– end note]</i></p>
<!--
The BLAS variant `xROTG` takes four arguments -- `a`, `b`, `c`, and
`s`-- and overwrites the input `a` with `r`.  We have chosen
`xLARTG`'s interface because it separates input and output, and to
encourage following `xLARTG`'s more careful implementation.

`setup_givens_rotation` has an overload for complex numbers,
because the output argument `c` (cosine) is a signed magnitude.
-->
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Returns:</em> <code>{c, s, r}</code>, where <code>c</code> and
<code>s</code> form the Givens plane rotation corresponding to the input
<code>a</code> and <code>b</code>, and <code>r</code> is the Euclidean
norm of the two-component vector formed by <code>a</code> and
<code>b</code>.</p>
<h5 data-number="28.9.13.2.2" id="apply-a-computed-givens-rotation-to-vectors-linalg.algs.blas1.givens.rot"><span class="header-section-number">28.9.13.2.2</span> Apply a computed Givens
rotation to vectors [linalg.algs.blas1.givens.rot]<a href="#apply-a-computed-givens-rotation-to-vectors-linalg.algs.blas1.givens.rot" class="self-link"></a></h5>
<div class="sourceCode" id="cb58"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb58-1"><a href="#cb58-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>inout-vector</em> InOutVec1,</span>
<span id="cb58-2"><a href="#cb58-2" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec2,</span>
<span id="cb58-3"><a href="#cb58-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Real<span class="op">&gt;</span></span>
<span id="cb58-4"><a href="#cb58-4" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> apply_givens_rotation<span class="op">(</span></span>
<span id="cb58-5"><a href="#cb58-5" aria-hidden="true" tabindex="-1"></a>  InOutVec1 x,</span>
<span id="cb58-6"><a href="#cb58-6" aria-hidden="true" tabindex="-1"></a>  InOutVec2 y,</span>
<span id="cb58-7"><a href="#cb58-7" aria-hidden="true" tabindex="-1"></a>  Real c,</span>
<span id="cb58-8"><a href="#cb58-8" aria-hidden="true" tabindex="-1"></a>  Real s<span class="op">)</span>;</span>
<span id="cb58-9"><a href="#cb58-9" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb58-10"><a href="#cb58-10" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec1,</span>
<span id="cb58-11"><a href="#cb58-11" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec2,</span>
<span id="cb58-12"><a href="#cb58-12" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Real<span class="op">&gt;</span></span>
<span id="cb58-13"><a href="#cb58-13" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> apply_givens_rotation<span class="op">(</span></span>
<span id="cb58-14"><a href="#cb58-14" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb58-15"><a href="#cb58-15" aria-hidden="true" tabindex="-1"></a>  InOutVec1 x,</span>
<span id="cb58-16"><a href="#cb58-16" aria-hidden="true" tabindex="-1"></a>  InOutVec2 y,</span>
<span id="cb58-17"><a href="#cb58-17" aria-hidden="true" tabindex="-1"></a>  Real c,</span>
<span id="cb58-18"><a href="#cb58-18" aria-hidden="true" tabindex="-1"></a>  Real s<span class="op">)</span>;</span>
<span id="cb58-19"><a href="#cb58-19" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb58-20"><a href="#cb58-20" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>inout-vector</em> InOutVec1,</span>
<span id="cb58-21"><a href="#cb58-21" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec2,</span>
<span id="cb58-22"><a href="#cb58-22" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Real<span class="op">&gt;</span></span>
<span id="cb58-23"><a href="#cb58-23" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> apply_givens_rotation<span class="op">(</span></span>
<span id="cb58-24"><a href="#cb58-24" aria-hidden="true" tabindex="-1"></a>  InOutVec1 x,</span>
<span id="cb58-25"><a href="#cb58-25" aria-hidden="true" tabindex="-1"></a>  InOutVec2 y,</span>
<span id="cb58-26"><a href="#cb58-26" aria-hidden="true" tabindex="-1"></a>  Real c,</span>
<span id="cb58-27"><a href="#cb58-27" aria-hidden="true" tabindex="-1"></a>  complex<span class="op">&lt;</span>Real<span class="op">&gt;</span> s<span class="op">)</span>;</span>
<span id="cb58-28"><a href="#cb58-28" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb58-29"><a href="#cb58-29" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec1,</span>
<span id="cb58-30"><a href="#cb58-30" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec2,</span>
<span id="cb58-31"><a href="#cb58-31" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Real<span class="op">&gt;</span></span>
<span id="cb58-32"><a href="#cb58-32" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> apply_givens_rotation<span class="op">(</span></span>
<span id="cb58-33"><a href="#cb58-33" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb58-34"><a href="#cb58-34" aria-hidden="true" tabindex="-1"></a>  InOutVec1 x,</span>
<span id="cb58-35"><a href="#cb58-35" aria-hidden="true" tabindex="-1"></a>  InOutVec2 y,</span>
<span id="cb58-36"><a href="#cb58-36" aria-hidden="true" tabindex="-1"></a>  Real c,</span>
<span id="cb58-37"><a href="#cb58-37" aria-hidden="true" tabindex="-1"></a>  complex<span class="op">&lt;</span>Real<span class="op">&gt;</span> s<span class="op">)</span>;</span></code></pre></div>
<p><i>[Note:</i> These functions correspond to the BLAS function
<code>xROT</code>. <i>– end note]</i></p>
<!--
`c` and `s` form a plane (Givens) rotation.
Users normally would compute `c` and `s`
using `setup_givens_rotation`,
but they are not required to do this.

For `i` in the domains of both `x` and `y`,
if $x_i$ is the value of `x[i]` on input
and $y_i$ is the value of `y[i]` on input,
then this algorithm computes
$x_i'$ such that $x_i' = c x_i + s y_i$ and
$y_i'$ such that $y_i' = c y_i - \bar{s} x_i$
(where $\bar{s}$ denotes the complex conjugate of $s$),
and assigns $x_i'$ to `x[i]` and $y_i'$ to `y[i]`.
-->
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
<em>Mandates:</em>
<em><code>compatible-static-extents</code></em><code>&lt;InOutVec1, InOutVec2&gt;(0,0)</code>
is <code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Preconditions:</em> <code>x.extent(0)</code> equals
<code>y.extent(0)</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Effects:</em> Applies the plane rotation specified by <code>c</code>
and <code>s</code> to the input vectors <code>x</code> and
<code>y</code>, as if the rotation were a 2 x 2 matrix and the input
vectors were successive rows of a matrix with two rows.</p>
<h4 data-number="28.9.13.3" id="swap-matrix-or-vector-elements-linalg.algs.blas1.swap"><span class="header-section-number">28.9.13.3</span> Swap matrix or vector
elements [linalg.algs.blas1.swap]<a href="#swap-matrix-or-vector-elements-linalg.algs.blas1.swap" class="self-link"></a></h4>
<div class="sourceCode" id="cb59"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb59-1"><a href="#cb59-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>inout-object</em> InOutObj1,</span>
<span id="cb59-2"><a href="#cb59-2" aria-hidden="true" tabindex="-1"></a>         <em>inout-object</em> InOutObj2<span class="op">&gt;</span></span>
<span id="cb59-3"><a href="#cb59-3" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> swap_elements<span class="op">(</span>InOutObj1 x,</span>
<span id="cb59-4"><a href="#cb59-4" aria-hidden="true" tabindex="-1"></a>                   InOutObj2 y<span class="op">)</span>;</span>
<span id="cb59-5"><a href="#cb59-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb59-6"><a href="#cb59-6" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb59-7"><a href="#cb59-7" aria-hidden="true" tabindex="-1"></a>         <em>inout-object</em> InOutObj1,</span>
<span id="cb59-8"><a href="#cb59-8" aria-hidden="true" tabindex="-1"></a>         <em>inout-object</em> InOutObj2<span class="op">&gt;</span></span>
<span id="cb59-9"><a href="#cb59-9" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> swap_elements<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb59-10"><a href="#cb59-10" aria-hidden="true" tabindex="-1"></a>                   InOutObj1 x,</span>
<span id="cb59-11"><a href="#cb59-11" aria-hidden="true" tabindex="-1"></a>                   InOutObj2 y<span class="op">)</span>;</span></code></pre></div>
<p><i>[Note:</i> These functions correspond to the BLAS function
<code>xSWAP</code>. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
<em>Constraints:</em> <code>x.rank()</code> equals
<code>y.rank()</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em> For all <code>r</code> in the range <span class="math inline">[</span> 0, <code>x.rank()</code><span class="math inline">)</span>,
<em><code>compatible-static-extents</code></em><code>&lt;InOutObj1, InOutObj2&gt;(r, r)</code>
is <code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em> <code>x.extents()</code> equals
<code>y.extents()</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Effects:</em> Swaps all corresponding elements of <code>x</code> and
<code>y</code>.</p>
<h4 data-number="28.9.13.4" id="multiply-the-elements-of-an-object-in-place-by-a-scalar-linalg.algs.blas1.scal"><span class="header-section-number">28.9.13.4</span> Multiply the elements of
an object in place by a scalar [linalg.algs.blas1.scal]<a href="#multiply-the-elements-of-an-object-in-place-by-a-scalar-linalg.algs.blas1.scal" class="self-link"></a></h4>
<div class="sourceCode" id="cb60"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb60-1"><a href="#cb60-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Scalar,</span>
<span id="cb60-2"><a href="#cb60-2" aria-hidden="true" tabindex="-1"></a>         <em>inout-object</em> InOutObj<span class="op">&gt;</span></span>
<span id="cb60-3"><a href="#cb60-3" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> scale<span class="op">(</span>Scalar alpha,</span>
<span id="cb60-4"><a href="#cb60-4" aria-hidden="true" tabindex="-1"></a>           InOutObj x<span class="op">)</span>;</span>
<span id="cb60-5"><a href="#cb60-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb60-6"><a href="#cb60-6" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb60-7"><a href="#cb60-7" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar,</span>
<span id="cb60-8"><a href="#cb60-8" aria-hidden="true" tabindex="-1"></a>         <em>inout-object</em> InOutObj<span class="op">&gt;</span></span>
<span id="cb60-9"><a href="#cb60-9" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> scale<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb60-10"><a href="#cb60-10" aria-hidden="true" tabindex="-1"></a>           Scalar alpha,</span>
<span id="cb60-11"><a href="#cb60-11" aria-hidden="true" tabindex="-1"></a>           InOutObj x<span class="op">)</span>;</span></code></pre></div>
<p><i>[Note:</i> These functions correspond to the BLAS function
<code>xSCAL</code>. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
<em>Effects:</em> Overwrites <span class="math inline"><em>x</em></span>
with the result of computing the elementwise multiplication <span class="math inline"><em>α</em><em>x</em></span>, where the scalar <span class="math inline"><em>α</em></span> is <code>alpha</code>.</p>
<h4 data-number="28.9.13.5" id="copy-elements-of-one-matrix-or-vector-into-another-linalg.algs.blas1.copy"><span class="header-section-number">28.9.13.5</span> Copy elements of one
matrix or vector into another [linalg.algs.blas1.copy]<a href="#copy-elements-of-one-matrix-or-vector-into-another-linalg.algs.blas1.copy" class="self-link"></a></h4>
<div class="sourceCode" id="cb61"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb61-1"><a href="#cb61-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-object</em> InObj,</span>
<span id="cb61-2"><a href="#cb61-2" aria-hidden="true" tabindex="-1"></a>         <em>out-object</em> OutObj<span class="op">&gt;</span></span>
<span id="cb61-3"><a href="#cb61-3" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> copy<span class="op">(</span>InObj x,</span>
<span id="cb61-4"><a href="#cb61-4" aria-hidden="true" tabindex="-1"></a>          OutObj y<span class="op">)</span>;</span>
<span id="cb61-5"><a href="#cb61-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb61-6"><a href="#cb61-6" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb61-7"><a href="#cb61-7" aria-hidden="true" tabindex="-1"></a>         <em>in-object</em> InObj,</span>
<span id="cb61-8"><a href="#cb61-8" aria-hidden="true" tabindex="-1"></a>         <em>out-object</em> OutObj<span class="op">&gt;</span></span>
<span id="cb61-9"><a href="#cb61-9" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> copy<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb61-10"><a href="#cb61-10" aria-hidden="true" tabindex="-1"></a>          InObj x,</span>
<span id="cb61-11"><a href="#cb61-11" aria-hidden="true" tabindex="-1"></a>          OutObj y<span class="op">)</span>;</span></code></pre></div>
<p><i>[Note:</i> These functions correspond to the BLAS function
<code>xCOPY</code>. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
<em>Constraints:</em> <code>x.rank()</code> equals
<code>y.rank()</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em> For all <code>r</code> in the range <span class="math inline">[</span> 0, <code>x.rank()</code><span class="math inline">)</span>,
<em><code>compatible-static-extents</code></em><code>&lt;InObj, OutObj&gt;(r, r)</code>
is <code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em> <code>x.extents()</code> equals
<code>y.extents()</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Effects:</em> Assigns each element of <span class="math inline"><em>x</em></span> to the corresponding element of
<span class="math inline"><em>y</em></span>.</p>
<h4 data-number="28.9.13.6" id="add-vectors-or-matrices-elementwise-linalg.algs.blas1.add"><span class="header-section-number">28.9.13.6</span> Add vectors or matrices
elementwise [linalg.algs.blas1.add]<a href="#add-vectors-or-matrices-elementwise-linalg.algs.blas1.add" class="self-link"></a></h4>
<div class="sourceCode" id="cb62"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb62-1"><a href="#cb62-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-object</em> InObj1,</span>
<span id="cb62-2"><a href="#cb62-2" aria-hidden="true" tabindex="-1"></a>         <em>in-object</em> InObj2,</span>
<span id="cb62-3"><a href="#cb62-3" aria-hidden="true" tabindex="-1"></a>         <em>out-object</em> OutObj<span class="op">&gt;</span></span>
<span id="cb62-4"><a href="#cb62-4" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> add<span class="op">(</span>InObj1 x,</span>
<span id="cb62-5"><a href="#cb62-5" aria-hidden="true" tabindex="-1"></a>         InObj2 y,</span>
<span id="cb62-6"><a href="#cb62-6" aria-hidden="true" tabindex="-1"></a>         OutObj z<span class="op">)</span>;</span>
<span id="cb62-7"><a href="#cb62-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb62-8"><a href="#cb62-8" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb62-9"><a href="#cb62-9" aria-hidden="true" tabindex="-1"></a>         <em>in-object</em> InObj1,</span>
<span id="cb62-10"><a href="#cb62-10" aria-hidden="true" tabindex="-1"></a>         <em>in-object</em> InObj2,</span>
<span id="cb62-11"><a href="#cb62-11" aria-hidden="true" tabindex="-1"></a>         <em>out-object</em> OutObj<span class="op">&gt;</span></span>
<span id="cb62-12"><a href="#cb62-12" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> add<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb62-13"><a href="#cb62-13" aria-hidden="true" tabindex="-1"></a>         InObj1 x,</span>
<span id="cb62-14"><a href="#cb62-14" aria-hidden="true" tabindex="-1"></a>         InObj2 y,</span>
<span id="cb62-15"><a href="#cb62-15" aria-hidden="true" tabindex="-1"></a>         OutObj z<span class="op">)</span>;</span></code></pre></div>
<p><i>[Note:</i> These functions correspond to the BLAS function
<code>xAXPY</code>. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
<em>Constraints:</em> <code>x.rank()</code>, <code>y.rank()</code>, and
<code>z.rank()</code> are all equal.</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em>
<em><code>possibly-addable</code></em><code>&lt;InObj1, InObj2, OutObj&gt;()</code>
is <code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em>
<em><code>addable</code></em><code>(x,y,z)</code> is
<code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>z</em> = <em>x</em> + <em>y</em></span>.</p>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
<em>Remarks:</em> <code>z</code> may alias <code>x</code> or
<code>y</code>.</p>
<h4 data-number="28.9.13.7" id="dot-product-of-two-vectors-linalg.algs.blas1.dot"><span class="header-section-number">28.9.13.7</span> Dot product of two
vectors [linalg.algs.blas1.dot]<a href="#dot-product-of-two-vectors-linalg.algs.blas1.dot" class="self-link"></a></h4>
<p><i>[Note:</i> The functions in this section correspond to the BLAS
functions <code>xDOT</code>, <code>xDOTU</code>, and <code>xDOTC</code>.
<i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The following elements apply to all functions in
[linalg.algs.blas1.dot].</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em>
<em><code>compatible-static-extents</code></em><code>&lt;InVec1, InVec2&gt;(0, 0)</code>
is <code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em> <code>v1.extent(0)</code> equals
<code>v2.extent(0)</code>.</p>
<div class="sourceCode" id="cb63"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb63-1"><a href="#cb63-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec1,</span>
<span id="cb63-2"><a href="#cb63-2" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb63-3"><a href="#cb63-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb63-4"><a href="#cb63-4" aria-hidden="true" tabindex="-1"></a>Scalar dot<span class="op">(</span>InVec1 v1,</span>
<span id="cb63-5"><a href="#cb63-5" aria-hidden="true" tabindex="-1"></a>           InVec2 v2,</span>
<span id="cb63-6"><a href="#cb63-6" aria-hidden="true" tabindex="-1"></a>           Scalar init<span class="op">)</span>;</span>
<span id="cb63-7"><a href="#cb63-7" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb63-8"><a href="#cb63-8" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb63-9"><a href="#cb63-9" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb63-10"><a href="#cb63-10" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb63-11"><a href="#cb63-11" aria-hidden="true" tabindex="-1"></a>Scalar dot<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb63-12"><a href="#cb63-12" aria-hidden="true" tabindex="-1"></a>           InVec1 v1,</span>
<span id="cb63-13"><a href="#cb63-13" aria-hidden="true" tabindex="-1"></a>           InVec2 v2,</span>
<span id="cb63-14"><a href="#cb63-14" aria-hidden="true" tabindex="-1"></a>           Scalar init<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
These functions compute a non-conjugated dot product with an explicitly
specified result type.</p>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
<em>Returns:</em> Let <code>N</code> be <code>v1.extent(0)</code>.</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(5.1)</a></span>
<code>init</code> if <code>N</code> is zero;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(5.2)</a></span>
otherwise, <em>GENERALIZED_SUM</em>(<code>plus&lt;&gt;()</code>,
<code>init</code>, <code>v1[0]*v2[0]</code>, …,
<code>v1[N-1]*v2[N-1]</code>).</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Remarks:</em> If <code>InVec1::value_type</code>,
<code>InVec2::value_type</code>, and <code>Scalar</code> are all
floating-point types or specializations of <code>complex</code>, and if
<code>Scalar</code> has higher precision than
<code>InVec1::value_type</code> or <code>InVec2::value_type</code>, then
intermediate terms in the sum use <code>Scalar</code>’s precision or
greater.</p>
<div class="sourceCode" id="cb64"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb64-1"><a href="#cb64-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec1,</span>
<span id="cb64-2"><a href="#cb64-2" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2<span class="op">&gt;</span></span>
<span id="cb64-3"><a href="#cb64-3" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> dot<span class="op">(</span>InVec1 v1,</span>
<span id="cb64-4"><a href="#cb64-4" aria-hidden="true" tabindex="-1"></a>         InVec2 v2<span class="op">)</span>;</span>
<span id="cb64-5"><a href="#cb64-5" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb64-6"><a href="#cb64-6" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb64-7"><a href="#cb64-7" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2<span class="op">&gt;</span></span>
<span id="cb64-8"><a href="#cb64-8" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> dot<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb64-9"><a href="#cb64-9" aria-hidden="true" tabindex="-1"></a>         InVec1 v1,</span>
<span id="cb64-10"><a href="#cb64-10" aria-hidden="true" tabindex="-1"></a>         InVec2 v2<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
These functions compute a non-conjugated dot product with a default
result type.</p>
<p><span class="marginalizedparent"><a class="marginalized">8</a></span>
<em>Effects:</em> Let <code>T</code> be
<code>decltype(declval&lt;typename InVec1::value_type&gt;() * declval&lt;typename InVec2::value_type&gt;())</code>.
Then,</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(8.1)</a></span> the
two-parameter overload is equivalent to
<code>return dot(v1, v2, T{});</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(8.2)</a></span> the
three-parameter overload is equivalent to
<code>return dot(std::forward&lt;ExecutionPolicy&gt;(exec), v1, v2, T{});</code>.</p></li>
</ul>
<div class="sourceCode" id="cb65"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb65-1"><a href="#cb65-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec1,</span>
<span id="cb65-2"><a href="#cb65-2" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb65-3"><a href="#cb65-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb65-4"><a href="#cb65-4" aria-hidden="true" tabindex="-1"></a>Scalar dotc<span class="op">(</span>InVec1 v1,</span>
<span id="cb65-5"><a href="#cb65-5" aria-hidden="true" tabindex="-1"></a>            InVec2 v2,</span>
<span id="cb65-6"><a href="#cb65-6" aria-hidden="true" tabindex="-1"></a>            Scalar init<span class="op">)</span>;</span>
<span id="cb65-7"><a href="#cb65-7" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb65-8"><a href="#cb65-8" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb65-9"><a href="#cb65-9" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb65-10"><a href="#cb65-10" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb65-11"><a href="#cb65-11" aria-hidden="true" tabindex="-1"></a>Scalar dotc<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb65-12"><a href="#cb65-12" aria-hidden="true" tabindex="-1"></a>            InVec1 v1,</span>
<span id="cb65-13"><a href="#cb65-13" aria-hidden="true" tabindex="-1"></a>            InVec2 v2,</span>
<span id="cb65-14"><a href="#cb65-14" aria-hidden="true" tabindex="-1"></a>            Scalar init<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">9</a></span>
These functions compute a conjugated dot product with an explicit
specified result type.</p>
<p><span class="marginalizedparent"><a class="marginalized">10</a></span>
<em>Effects:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(10.1)</a></span> The
three-parameter overload is equivalent to
<code>return dot(conjugated(v1), v2, init);</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(10.2)</a></span> the
four-parameter overload is equivalent to
<code>return dot(std::forward&lt;ExecutionPolicy&gt;(exec), conjugated(v1), v2, init);</code>.</p></li>
</ul>
<div class="sourceCode" id="cb66"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb66-1"><a href="#cb66-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec1,</span>
<span id="cb66-2"><a href="#cb66-2" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2<span class="op">&gt;</span></span>
<span id="cb66-3"><a href="#cb66-3" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> dotc<span class="op">(</span>InVec1 v1,</span>
<span id="cb66-4"><a href="#cb66-4" aria-hidden="true" tabindex="-1"></a>          InVec2 v2<span class="op">)</span>;</span>
<span id="cb66-5"><a href="#cb66-5" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb66-6"><a href="#cb66-6" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb66-7"><a href="#cb66-7" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2<span class="op">&gt;</span></span>
<span id="cb66-8"><a href="#cb66-8" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> dotc<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb66-9"><a href="#cb66-9" aria-hidden="true" tabindex="-1"></a>          InVec1 v1,</span>
<span id="cb66-10"><a href="#cb66-10" aria-hidden="true" tabindex="-1"></a>          InVec2 v2<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">11</a></span> These
functions compute a conjugated dot product with a default result
type.</p>
<p><span class="marginalizedparent"><a class="marginalized">12</a></span>
<em>Effects:</em> Let <code>T</code> be
<code>decltype(</code><em><code>conj-if-needed</code></em><code>(declval&lt;typename InVec1::value_type&gt;()) * declval&lt;typename InVec2::value_type&gt;())</code>.
Then,</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(12.1)</a></span> the
two-parameter overload is equivalent to
<code>return dotc(v1, v2, T{});</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(12.2)</a></span> the
three-parameter overload is equivalent to
<code>return dotc(std::forward&lt;ExecutionPolicy&gt;(exec), v1, v2, T{});</code>.</p></li>
</ul>
<h4 data-number="28.9.13.8" id="scaled-sum-of-squares-of-a-vectors-elements-linalg.algs.blas1.ssq"><span class="header-section-number">28.9.13.8</span> Scaled sum of squares of
a vector’s elements [linalg.algs.blas1.ssq]<a href="#scaled-sum-of-squares-of-a-vectors-elements-linalg.algs.blas1.ssq" class="self-link"></a></h4>
<div class="sourceCode" id="cb67"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb67-1"><a href="#cb67-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb67-2"><a href="#cb67-2" aria-hidden="true" tabindex="-1"></a><span class="kw">struct</span> sum_of_squares_result <span class="op">{</span></span>
<span id="cb67-3"><a href="#cb67-3" aria-hidden="true" tabindex="-1"></a>  Scalar scaling_factor;</span>
<span id="cb67-4"><a href="#cb67-4" aria-hidden="true" tabindex="-1"></a>  Scalar scaled_sum_of_squares;</span>
<span id="cb67-5"><a href="#cb67-5" aria-hidden="true" tabindex="-1"></a><span class="op">}</span>;</span>
<span id="cb67-6"><a href="#cb67-6" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec,</span>
<span id="cb67-7"><a href="#cb67-7" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb67-8"><a href="#cb67-8" aria-hidden="true" tabindex="-1"></a>sum_of_squares_result<span class="op">&lt;</span>Scalar<span class="op">&gt;</span> vector_sum_of_squares<span class="op">(</span></span>
<span id="cb67-9"><a href="#cb67-9" aria-hidden="true" tabindex="-1"></a>  InVec v,</span>
<span id="cb67-10"><a href="#cb67-10" aria-hidden="true" tabindex="-1"></a>  sum_of_squares_result<span class="op">&lt;</span>Scalar<span class="op">&gt;</span> init<span class="op">)</span>;</span>
<span id="cb67-11"><a href="#cb67-11" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb67-12"><a href="#cb67-12" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb67-13"><a href="#cb67-13" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb67-14"><a href="#cb67-14" aria-hidden="true" tabindex="-1"></a>sum_of_squares_result<span class="op">&lt;</span>Scalar<span class="op">&gt;</span> vector_sum_of_squares<span class="op">(</span></span>
<span id="cb67-15"><a href="#cb67-15" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb67-16"><a href="#cb67-16" aria-hidden="true" tabindex="-1"></a>  InVec v,</span>
<span id="cb67-17"><a href="#cb67-17" aria-hidden="true" tabindex="-1"></a>  sum_of_squares_result<span class="op">&lt;</span>Scalar<span class="op">&gt;</span> init<span class="op">)</span>;</span></code></pre></div>
<p><i>[Note:</i> These functions correspond to the LAPACK function
<code>xLASSQ</code>. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
<em>Mandates:</em>
<code>decltype(</code><em><code>abs-if-needed</code></em><code>(declval&lt;typename InVec::value_type&gt;()))</code>
is convertible to <code>Scalar</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Effects:</em> Returns a value <code>result</code> such that</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span>
<code>result.scaling_factor</code> is the maximum of
<code>init.scaling_factor</code> and
<em><code>abs-if-needed</code></em><code>(x[i])</code> for all
<code>i</code> in the domain of <code>v</code>; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span> let
<code>s2init</code> be
<code>init.scaling_factor * init.scaling_factor * init.scaled_sum_of_squares</code>,
then
<code>result.scaling_factor * result.scaling_factor * result.scaled_sum_of_squares</code>
equals the sum of <code>s2init</code> and the squares of
<em><code>abs-if-needed</code></em><code>(x[i])</code> for all
<code>i</code> in the domain of <code>v</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Remarks:</em> If <code>InVec::value_type</code>, and
<code>Scalar</code> are all floating-point types or specializations of
<code>complex</code>, and if <code>Scalar</code> has higher precision
than <code>InVec::value_type</code>, then intermediate terms in the sum
use <code>Scalar</code>’s precision or greater.</p>
<h4 data-number="28.9.13.9" id="euclidean-norm-of-a-vector-linalg.algs.blas1.nrm2"><span class="header-section-number">28.9.13.9</span> Euclidean norm of a
vector [linalg.algs.blas1.nrm2]<a href="#euclidean-norm-of-a-vector-linalg.algs.blas1.nrm2" class="self-link"></a></h4>
<div class="sourceCode" id="cb68"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb68-1"><a href="#cb68-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec,</span>
<span id="cb68-2"><a href="#cb68-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb68-3"><a href="#cb68-3" aria-hidden="true" tabindex="-1"></a>Scalar vector_two_norm<span class="op">(</span>InVec v,</span>
<span id="cb68-4"><a href="#cb68-4" aria-hidden="true" tabindex="-1"></a>                       Scalar init<span class="op">)</span>;</span>
<span id="cb68-5"><a href="#cb68-5" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb68-6"><a href="#cb68-6" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb68-7"><a href="#cb68-7" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb68-8"><a href="#cb68-8" aria-hidden="true" tabindex="-1"></a>Scalar vector_two_norm<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb68-9"><a href="#cb68-9" aria-hidden="true" tabindex="-1"></a>                       InVec v,</span>
<span id="cb68-10"><a href="#cb68-10" aria-hidden="true" tabindex="-1"></a>                       Scalar init<span class="op">)</span>;</span></code></pre></div>
<p><i>[Note:</i> These functions correspond to the BLAS function
<code>xNRM2</code>. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
<em>Mandates:</em> <code>decltype(init +</code>
<em><code>abs-if-needed</code></em><code>(declval&lt;typename InVec::value_type&gt;()) *</code>
<em><code>abs-if-needed</code></em><code>(declval&lt;typename InVec::value_type&gt;()))</code>
is convertible to <code>Scalar</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Returns:</em> The square root of the sum of the square of
<code>init</code> and the squares of the absolute values of the elements
of <code>v</code>. <i>[Note:</i> For <code>init</code> equal to zero,
this is the Euclidean norm (also called 2-norm) of the vector
<code>v</code>.<i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Remarks:</em> If <code>InVec::value_type</code>, and
<code>Scalar</code> are all floating-point types or specializations of
<code>complex</code>, and if <code>Scalar</code> has higher precision
than <code>InVec::value_type</code>, then intermediate terms in the sum
use <code>Scalar</code>’s precision or greater.</p>
<p><i>[Note:</i> A possible implementation of this function for
floating-point types <code>T</code> would use the
<code>scaled_sum_of_squares</code> result from
<code>vector_sum_of_squares(x, {.scaling_factor=1.0, .scaled_sum_of_squares=init})</code>.
<i>– end note]</i></p>
<div class="sourceCode" id="cb69"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb69-1"><a href="#cb69-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec<span class="op">&gt;</span></span>
<span id="cb69-2"><a href="#cb69-2" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> vector_two_norm<span class="op">(</span>InVec v<span class="op">)</span>;</span>
<span id="cb69-3"><a href="#cb69-3" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb69-4"><a href="#cb69-4" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec<span class="op">&gt;</span></span>
<span id="cb69-5"><a href="#cb69-5" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> vector_two_norm<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec, InVec v<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Effects:</em> Let <code>T</code> be <code>decltype(</code>
<em><code>abs-if-needed</code></em><code>(declval&lt;typename InVec::value_type&gt;()) *</code>
<em><code>abs-if-needed</code></em><code>(declval&lt;typename InVec::value_type&gt;()))</code>.
Then,</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.1)</a></span> the
one-parameter overload is equivalent to
<code>return vector_two_norm(v, T{});</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.2)</a></span> the
two-parameter overload is equivalent to
<code>return vector_two_norm(std::forward&lt;ExecutionPolicy&gt;(exec), v, T{});</code>.</p></li>
</ul>
<h4 data-number="28.9.13.10" id="sum-of-absolute-values-of-vector-elements-linalg.algs.blas1.asum"><span class="header-section-number">28.9.13.10</span> Sum of absolute values
of vector elements [linalg.algs.blas1.asum]<a href="#sum-of-absolute-values-of-vector-elements-linalg.algs.blas1.asum" class="self-link"></a></h4>
<div class="sourceCode" id="cb70"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb70-1"><a href="#cb70-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec,</span>
<span id="cb70-2"><a href="#cb70-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb70-3"><a href="#cb70-3" aria-hidden="true" tabindex="-1"></a>Scalar vector_abs_sum<span class="op">(</span>InVec v,</span>
<span id="cb70-4"><a href="#cb70-4" aria-hidden="true" tabindex="-1"></a>                      Scalar init<span class="op">)</span>;</span>
<span id="cb70-5"><a href="#cb70-5" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb70-6"><a href="#cb70-6" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb70-7"><a href="#cb70-7" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb70-8"><a href="#cb70-8" aria-hidden="true" tabindex="-1"></a>Scalar vector_abs_sum<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb70-9"><a href="#cb70-9" aria-hidden="true" tabindex="-1"></a>                      InVec v,</span>
<span id="cb70-10"><a href="#cb70-10" aria-hidden="true" tabindex="-1"></a>                      Scalar init<span class="op">)</span>;</span></code></pre></div>
<p><i>[Note:</i> These functions correspond to the BLAS functions
<code>SASUM</code>, <code>DASUM</code>, <code>SCASUM</code>, and
<code>DZASUM</code>.<i>– end note]</i></p>
<!--
The different behavior for complex
element types is based on the observation that this lower-cost
approximation of the one-norm serves just as well as the actual
one-norm for many linear algebra algorithms in practice.
-->
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
<em>Mandates:</em> <code>decltype(init +</code>
<em><code>abs-if-needed</code></em><code>(</code>
<em><code>real-if-needed</code></em>
<code>(declval&lt;typename InVec::value_type&gt;())) +</code>
<em><code>abs-if-needed</code></em><code>(</code>
<em><code>imag-if-needed</code></em>
<code>(declval&lt;typename InVec::value_type&gt;())))</code> is
convertible to <code>Scalar</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Returns:</em> Let <code>N</code> be <code>v.extent(0)</code>.</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span>
<code>init</code> if <code>N</code> is zero;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
otherwise, <em>GENERALIZED_SUM</em>(<code>plus&lt;&gt;()</code>,
<code>init</code>,
<em><code>abs-if-needed</code></em><code>(v[0])</code>, …,
<em><code>abs-if-needed</code></em><code>(v[N-1])</code>), if
<code>InVec::value_type</code> is an arithmetic type;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.3)</a></span>
otherwise, <em>GENERALIZED_SUM</em>(<code>plus&lt;&gt;()</code>,
<code>init</code>, <em><code>abs-if-needed</code></em><code>(</code>
<em><code>real-if-needed</code></em> <code>(v[0])) +</code>
<em><code>abs-if-needed</code></em><code>(</code>
<em><code>imag-if-needed</code></em> <code>(v[0]))</code>, …,
<em><code>abs-if-needed</code></em><code>(</code>
<em><code>real-if-needed</code></em> <code>(v[N-1])) +</code>
<em><code>abs-if-needed</code></em><code>(</code>
<em><code>imag-if-needed</code></em> <code>(v[N-1]))</code>).</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Remarks:</em> If <code>InVec::value_type</code> and
<code>Scalar</code> are all floating-point types or specializations of
<code>complex</code>, and if <code>Scalar</code> has higher precision
than <code>InVec::value_type</code>, then intermediate terms in the sum
use <code>Scalar</code>’s precision or greater.</p>
<div class="sourceCode" id="cb71"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb71-1"><a href="#cb71-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec<span class="op">&gt;</span></span>
<span id="cb71-2"><a href="#cb71-2" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> vector_abs_sum<span class="op">(</span>InVec v<span class="op">)</span>;</span>
<span id="cb71-3"><a href="#cb71-3" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb71-4"><a href="#cb71-4" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec<span class="op">&gt;</span></span>
<span id="cb71-5"><a href="#cb71-5" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> vector_abs_sum<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec, InVec v<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Effects:</em> Let <code>T</code> be
<code>typename InVec::value_type</code>. Then,</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.1)</a></span> the
one-parameter overload is equivalent to
<code>return vector_abs_sum(v, T{});</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.2)</a></span> the
two-parameter overload is equivalent to
<code>return vector_abs_sum(std::forward&lt;ExecutionPolicy&gt;(exec), v, T{});</code>.</p></li>
</ul>
<h4 data-number="28.9.13.11" id="index-of-maximum-absolute-value-of-vector-elements-linalg.algs.blas1.iamax"><span class="header-section-number">28.9.13.11</span> Index of maximum
absolute value of vector elements [linalg.algs.blas1.iamax]<a href="#index-of-maximum-absolute-value-of-vector-elements-linalg.algs.blas1.iamax" class="self-link"></a></h4>
<div class="sourceCode" id="cb72"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb72-1"><a href="#cb72-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec<span class="op">&gt;</span></span>
<span id="cb72-2"><a href="#cb72-2" aria-hidden="true" tabindex="-1"></a><span class="kw">typename</span> InVec<span class="op">::</span>size_type vector_idx_abs_max<span class="op">(</span>InVec v<span class="op">)</span>;</span>
<span id="cb72-3"><a href="#cb72-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb72-4"><a href="#cb72-4" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb72-5"><a href="#cb72-5" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec<span class="op">&gt;</span></span>
<span id="cb72-6"><a href="#cb72-6" aria-hidden="true" tabindex="-1"></a><span class="kw">typename</span> InVec<span class="op">::</span>size_type vector_idx_abs_max<span class="op">(</span></span>
<span id="cb72-7"><a href="#cb72-7" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb72-8"><a href="#cb72-8" aria-hidden="true" tabindex="-1"></a>  InVec v<span class="op">)</span>;</span></code></pre></div>
<p><i>[Note:</i> These functions correspond to the BLAS function
<code>IxAMAX</code>. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
Let <code>T</code> be <code>decltype(</code>
<em><code>abs-if-needed</code></em><code>(</code>
<em><code>real-if-needed</code></em>
<code>(declval&lt;typename InVec::value_type&gt;())) +</code>
<em><code>abs-if-needed</code></em><code>(</code>
<em><code>imag-if-needed</code></em>
<code>(declval&lt;typename InVec::value_type&gt;())))</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em>
<code>declval&lt;T&gt;() &lt; declval&lt;T&gt;()</code> is a valid
expression.</p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Returns:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.1)</a></span>
<code>numeric_limits&lt;typename InVec::size_type&gt;::max()</code> if
<code>v</code> has zero elements;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.2)</a></span>
otherwise, the index of the first element of <code>v</code> having
largest absolute value, if <code>InVec::value_type</code> is an
arithmetic type;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.3)</a></span>
otherwise, the index of the first element <code>v_e</code> of
<code>v</code> for which
<em><code>abs-if-needed</code></em><code>(</code>
<em><code>real-if-needed</code></em> <code>(v_e)) +</code>
<em><code>abs-if-needed</code></em><code>(</code>
<em><code>imag-if-needed</code></em> <code>(v_e))</code> has the largest
value.</p></li>
</ul>
<h4 data-number="28.9.13.12" id="frobenius-norm-of-a-matrix-linalg.algs.blas1.matfrobnorm"><span class="header-section-number">28.9.13.12</span> Frobenius norm of a
matrix [linalg.algs.blas1.matfrobnorm]<a href="#frobenius-norm-of-a-matrix-linalg.algs.blas1.matfrobnorm" class="self-link"></a></h4>
<p><i>[Note:</i> These functions exist in the BLAS standard but are not
part of the reference implementation. <i>– end note]</i></p>
<div class="sourceCode" id="cb73"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb73-1"><a href="#cb73-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb73-2"><a href="#cb73-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb73-3"><a href="#cb73-3" aria-hidden="true" tabindex="-1"></a>Scalar matrix_frob_norm<span class="op">(</span></span>
<span id="cb73-4"><a href="#cb73-4" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb73-5"><a href="#cb73-5" aria-hidden="true" tabindex="-1"></a>  Scalar init<span class="op">)</span>;</span>
<span id="cb73-6"><a href="#cb73-6" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb73-7"><a href="#cb73-7" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb73-8"><a href="#cb73-8" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb73-9"><a href="#cb73-9" aria-hidden="true" tabindex="-1"></a>Scalar matrix_frob_norm<span class="op">(</span></span>
<span id="cb73-10"><a href="#cb73-10" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb73-11"><a href="#cb73-11" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb73-12"><a href="#cb73-12" aria-hidden="true" tabindex="-1"></a>  Scalar init<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
<em>Mandates:</em> <code>decltype(init +</code>
<em><code>abs-if-needed</code></em><code>(declval&lt;typename InMat::value_type&gt;()) *</code>
<em><code>abs-if-needed</code></em><code>(declval&lt;typename InMat::value_type&gt;()))</code>
is convertible to <code>Scalar</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Returns:</em> The square root of the sum of squares of
<code>init</code> and the absolute values of the elements of
<code>A</code>.</p>
<p><i>[Note:</i> For <code>init</code> equal to zero, this is the
Frobenius norm of the matrix <code>A</code>. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Remarks:</em> If <code>InMat::value_type</code> and
<code>Scalar</code> are all floating-point types or specializations of
<code>complex</code>, and if <code>Scalar</code> has higher precision
than <code>InMat::value_type</code>, then intermediate terms in the sum
use <code>Scalar</code>’s precision or greater.</p>
<div class="sourceCode" id="cb74"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb74-1"><a href="#cb74-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat<span class="op">&gt;</span></span>
<span id="cb74-2"><a href="#cb74-2" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> matrix_frob_norm<span class="op">(</span>InMat A<span class="op">)</span>;</span>
<span id="cb74-3"><a href="#cb74-3" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb74-4"><a href="#cb74-4" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat<span class="op">&gt;</span></span>
<span id="cb74-5"><a href="#cb74-5" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> matrix_frob_norm<span class="op">(</span></span>
<span id="cb74-6"><a href="#cb74-6" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec, InMat A<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Effects:</em> Let <code>T</code> be <code>decltype(</code>
<em><code>abs-if-needed</code></em><code>(declval&lt;typename InMat::value_type&gt;()) *</code>
<em><code>abs-if-needed</code></em><code>(declval&lt;typename InMat::value_type&gt;()))</code>.
Then,</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.1)</a></span> the
one-parameter overload is equivalent to
<code>return matrix_frob_norm(A, T{});</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.2)</a></span> the
two-parameter overload is equivalent to
<code>return matrix_frob_norm(std::forward&lt;ExecutionPolicy&gt;(exec), A, T{});</code>.</p></li>
</ul>
<h4 data-number="28.9.13.13" id="one-norm-of-a-matrix-linalg.algs.blas1.matonenorm"><span class="header-section-number">28.9.13.13</span> One norm of a matrix
[linalg.algs.blas1.matonenorm]<a href="#one-norm-of-a-matrix-linalg.algs.blas1.matonenorm" class="self-link"></a></h4>
<p><i>[Note:</i> These functions exist in the BLAS standard but are not
part of the reference implementation. <i>– end note]</i></p>
<div class="sourceCode" id="cb75"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb75-1"><a href="#cb75-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb75-2"><a href="#cb75-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb75-3"><a href="#cb75-3" aria-hidden="true" tabindex="-1"></a>Scalar matrix_one_norm<span class="op">(</span></span>
<span id="cb75-4"><a href="#cb75-4" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb75-5"><a href="#cb75-5" aria-hidden="true" tabindex="-1"></a>  Scalar init<span class="op">)</span>;</span>
<span id="cb75-6"><a href="#cb75-6" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb75-7"><a href="#cb75-7" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb75-8"><a href="#cb75-8" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb75-9"><a href="#cb75-9" aria-hidden="true" tabindex="-1"></a>Scalar matrix_one_norm<span class="op">(</span></span>
<span id="cb75-10"><a href="#cb75-10" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb75-11"><a href="#cb75-11" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb75-12"><a href="#cb75-12" aria-hidden="true" tabindex="-1"></a>  Scalar init<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
<em>Mandates:</em>
<code>decltype(</code><em><code>abs-if-needed</code></em><code>(declval&lt;typename InMat::value_type&gt;()))</code>
is convertible to <code>Scalar</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Returns:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span>
<code>init</code> if <code>A.extent(1)</code> is zero;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
otherwise, the sum of <code>init</code> and the one norm of the matrix
<span class="math inline"><em>A</em></span>.</p></li>
</ul>
<p><i>[Note:</i> The one norm of the matrix <code>A</code> is the
maximum over all columns of <code>A</code>, of the sum of the absolute
values of the elements of the column. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Remarks:</em> If <code>InMat::value_type</code> and
<code>Scalar</code> are all floating-point types or specializations of
<code>complex</code>, and if <code>Scalar</code> has higher precision
than <code>InMat::value_type</code>, then intermediate terms in the sum
use <code>Scalar</code>’s precision or greater.</p>
<div class="sourceCode" id="cb76"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb76-1"><a href="#cb76-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat<span class="op">&gt;</span></span>
<span id="cb76-2"><a href="#cb76-2" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> matrix_one_norm<span class="op">(</span>InMat A<span class="op">)</span>;</span>
<span id="cb76-3"><a href="#cb76-3" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb76-4"><a href="#cb76-4" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat<span class="op">&gt;</span></span>
<span id="cb76-5"><a href="#cb76-5" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> matrix_one_norm<span class="op">(</span></span>
<span id="cb76-6"><a href="#cb76-6" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec, InMat A<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Effects:</em> Let <code>T</code> be <code>decltype(</code>
<em><code>abs-if-needed</code></em><code>(declval&lt;typename InMat::value_type&gt;())</code>.
Then,</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.1)</a></span> the
one-parameter overload is equivalent to
<code>return matrix_one_norm(A, T{});</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.2)</a></span> the
two-parameter overload is equivalent to
<code>return matrix_one_norm(std::forward&lt;ExecutionPolicy&gt;(exec), A, T{});</code>.</p></li>
</ul>
<h4 data-number="28.9.13.14" id="infinity-norm-of-a-matrix-linalg.algs.blas1.matinfnorm"><span class="header-section-number">28.9.13.14</span> Infinity norm of a
matrix [linalg.algs.blas1.matinfnorm]<a href="#infinity-norm-of-a-matrix-linalg.algs.blas1.matinfnorm" class="self-link"></a></h4>
<p><i>[Note:</i> These functions exist in the BLAS standard but are not
part of the reference implementation. <i>– end note]</i></p>
<div class="sourceCode" id="cb77"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb77-1"><a href="#cb77-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb77-2"><a href="#cb77-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb77-3"><a href="#cb77-3" aria-hidden="true" tabindex="-1"></a>Scalar matrix_inf_norm<span class="op">(</span></span>
<span id="cb77-4"><a href="#cb77-4" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb77-5"><a href="#cb77-5" aria-hidden="true" tabindex="-1"></a>  Scalar init<span class="op">)</span>;</span>
<span id="cb77-6"><a href="#cb77-6" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb77-7"><a href="#cb77-7" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb77-8"><a href="#cb77-8" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar<span class="op">&gt;</span></span>
<span id="cb77-9"><a href="#cb77-9" aria-hidden="true" tabindex="-1"></a>Scalar matrix_inf_norm<span class="op">(</span></span>
<span id="cb77-10"><a href="#cb77-10" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb77-11"><a href="#cb77-11" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb77-12"><a href="#cb77-12" aria-hidden="true" tabindex="-1"></a>  Scalar init<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
<em>Mandates:</em>
<code>decltype(</code><em><code>abs-if-needed</code></em><code>(declval&lt;typename InMat::value_type&gt;()))</code>
is convertible to <code>Scalar</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Returns:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span>
<code>init</code> if <code>A.extent(0)</code> is zero;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
otherwise, the sum of <code>init</code> and the infinity norm of the
matrix <code>A</code>.</p></li>
</ul>
<p><i>[Note:</i> The infinity norm of the matrix <code>A</code> is the
maximum over all rows of <code>A</code>, of the sum of the absolute
values of the elements of the row. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Remarks:</em> If <code>InMat::value_type</code> and
<code>Scalar</code> are all floating-point types or specializations of
<code>complex</code>, and if <code>Scalar</code> has higher precision
than <code>InMat::value_type</code>, then intermediate terms in the sum
use <code>Scalar</code>’s precision or greater.</p>
<div class="sourceCode" id="cb78"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb78-1"><a href="#cb78-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat<span class="op">&gt;</span></span>
<span id="cb78-2"><a href="#cb78-2" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> matrix_inf_norm<span class="op">(</span>InMat A<span class="op">)</span>;</span>
<span id="cb78-3"><a href="#cb78-3" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb78-4"><a href="#cb78-4" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat<span class="op">&gt;</span></span>
<span id="cb78-5"><a href="#cb78-5" aria-hidden="true" tabindex="-1"></a><span class="kw">auto</span> matrix_inf_norm<span class="op">(</span></span>
<span id="cb78-6"><a href="#cb78-6" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec, InMat A<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Effects:</em> Let <code>T</code> be <code>decltype(</code>
<em><code>abs-if-needed</code></em><code>(declval&lt;typename InMat::value_type&gt;())</code>.
Then,</p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.1)</a></span> the
one-parameter overload is equivalent to
<code>return matrix_inf_norm(A, T{});</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(4.2)</a></span> the
two-parameter overload is equivalent to
<code>return matrix_inf_norm(std::forward&lt;ExecutionPolicy&gt;(exec), A, T{});</code>.</p></li>
</ul>
<h3 data-number="28.9.14" id="blas-2-algorithms-linalg.algs.blas2"><span class="header-section-number">28.9.14</span> BLAS 2 algorithms
[linalg.algs.blas2]<a href="#blas-2-algorithms-linalg.algs.blas2" class="self-link"></a></h3>
<h4 data-number="28.9.14.1" id="general-matrix-vector-product-linalg.algs.blas2.gemv"><span class="header-section-number">28.9.14.1</span> General matrix-vector
product [linalg.algs.blas2.gemv]<a href="#general-matrix-vector-product-linalg.algs.blas2.gemv" class="self-link"></a></h4>
<p><i>[Note:</i> These functions correspond to the BLAS function
<code>xGEMV</code>. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The following elements apply to all functions in
[linalg.algs.blas2.gemv].</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span>
<em><code>possibly-multipliable</code></em><code>&lt;decltype(A), decltype(x), decltype(y)&gt;()</code>
is <code>true</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
<em><code>possibly-addable</code></em><code>&lt;decltype(x),decltype(y),decltype(z)&gt;()</code>
is <code>true</code> for those overloads that take a <code>z</code>
parameter.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.1)</a></span>
<em><code>multipliable</code></em><code>(A,x,y)</code> is
<code>true</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.2)</a></span>
<em><code>addable</code></em><code>(x,y,z)</code> is <code>true</code>
for those overloads that take a <code>z</code> parameter.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>x.extent(0)</code> <span class="math inline">⋅</span>
<code>A.extent(1)</code> <span class="math inline">)</span></p>
<div class="sourceCode" id="cb79"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb79-1"><a href="#cb79-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb79-2"><a href="#cb79-2" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb79-3"><a href="#cb79-3" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb79-4"><a href="#cb79-4" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_vector_product<span class="op">(</span>InMat A,</span>
<span id="cb79-5"><a href="#cb79-5" aria-hidden="true" tabindex="-1"></a>                           InVec x,</span>
<span id="cb79-6"><a href="#cb79-6" aria-hidden="true" tabindex="-1"></a>                           OutVec y<span class="op">)</span>;</span>
<span id="cb79-7"><a href="#cb79-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb79-8"><a href="#cb79-8" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb79-9"><a href="#cb79-9" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb79-10"><a href="#cb79-10" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb79-11"><a href="#cb79-11" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb79-12"><a href="#cb79-12" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_vector_product<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb79-13"><a href="#cb79-13" aria-hidden="true" tabindex="-1"></a>                           InMat A,</span>
<span id="cb79-14"><a href="#cb79-14" aria-hidden="true" tabindex="-1"></a>                           InVec x,</span>
<span id="cb79-15"><a href="#cb79-15" aria-hidden="true" tabindex="-1"></a>                           OutVec y<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
These functions perform an overwriting matrix-vector product.</p>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>y</em> = <em>A</em><em>x</em></span>.</p>
<p>[<em>Example:</em></p>
<div class="sourceCode" id="cb80"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb80-1"><a href="#cb80-1" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">size_t</span> num_rows <span class="op">=</span> <span class="dv">5</span>;</span>
<span id="cb80-2"><a href="#cb80-2" aria-hidden="true" tabindex="-1"></a><span class="kw">constexpr</span> <span class="dt">size_t</span> num_cols <span class="op">=</span> <span class="dv">6</span>;</span>
<span id="cb80-3"><a href="#cb80-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb80-4"><a href="#cb80-4" aria-hidden="true" tabindex="-1"></a><span class="co">// y = 3.0 * A * x</span></span>
<span id="cb80-5"><a href="#cb80-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> scaled_matvec_1<span class="op">(</span></span>
<span id="cb80-6"><a href="#cb80-6" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span><span class="dt">double</span>, extents<span class="op">&lt;</span><span class="dt">size_t</span>, num_rows, num_cols<span class="op">&gt;&gt;</span> A,</span>
<span id="cb80-7"><a href="#cb80-7" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span><span class="dt">double</span>, extents<span class="op">&lt;</span><span class="dt">size_t</span>, num_cols<span class="op">&gt;&gt;</span> x,</span>
<span id="cb80-8"><a href="#cb80-8" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span><span class="dt">double</span>, extents<span class="op">&lt;</span><span class="dt">size_t</span>, num_rows<span class="op">&gt;&gt;</span> y<span class="op">)</span></span>
<span id="cb80-9"><a href="#cb80-9" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb80-10"><a href="#cb80-10" aria-hidden="true" tabindex="-1"></a>  matrix_vector_product<span class="op">(</span>scaled<span class="op">(</span><span class="fl">3.0</span>, A<span class="op">)</span>, x, y<span class="op">)</span>;</span>
<span id="cb80-11"><a href="#cb80-11" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span>
<span id="cb80-12"><a href="#cb80-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb80-13"><a href="#cb80-13" aria-hidden="true" tabindex="-1"></a><span class="co">// y = 3.0 * A * x + 2.0 * y</span></span>
<span id="cb80-14"><a href="#cb80-14" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> scaled_matvec_2<span class="op">(</span></span>
<span id="cb80-15"><a href="#cb80-15" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span><span class="dt">double</span>, extents<span class="op">&lt;</span><span class="dt">size_t</span>, num_rows, num_cols<span class="op">&gt;&gt;</span> A,</span>
<span id="cb80-16"><a href="#cb80-16" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span><span class="dt">double</span>, extents<span class="op">&lt;</span><span class="dt">size_t</span>, num_cols<span class="op">&gt;&gt;</span> x,</span>
<span id="cb80-17"><a href="#cb80-17" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span><span class="dt">double</span>, extents<span class="op">&lt;</span><span class="dt">size_t</span>, num_rows<span class="op">&gt;&gt;</span> y<span class="op">)</span></span>
<span id="cb80-18"><a href="#cb80-18" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb80-19"><a href="#cb80-19" aria-hidden="true" tabindex="-1"></a>  matrix_vector_product<span class="op">(</span>scaled<span class="op">(</span><span class="fl">3.0</span>, A<span class="op">)</span>, x,</span>
<span id="cb80-20"><a href="#cb80-20" aria-hidden="true" tabindex="-1"></a>                        scaled<span class="op">(</span><span class="fl">2.0</span>, y<span class="op">)</span>, y<span class="op">)</span>;</span>
<span id="cb80-21"><a href="#cb80-21" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span>
<span id="cb80-22"><a href="#cb80-22" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb80-23"><a href="#cb80-23" aria-hidden="true" tabindex="-1"></a><span class="co">// z = 7.0 times the transpose of A, times y</span></span>
<span id="cb80-24"><a href="#cb80-24" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> scaled_transposed_matvec<span class="op">(</span>mdspan<span class="op">&lt;</span><span class="dt">double</span>, extents<span class="op">&lt;</span><span class="dt">size_t</span>, num_rows, num_cols<span class="op">&gt;&gt;</span> A,</span>
<span id="cb80-25"><a href="#cb80-25" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span><span class="dt">double</span>, extents<span class="op">&lt;</span><span class="dt">size_t</span>, num_rows<span class="op">&gt;&gt;</span> y,</span>
<span id="cb80-26"><a href="#cb80-26" aria-hidden="true" tabindex="-1"></a>  mdspan<span class="op">&lt;</span><span class="dt">double</span>, extents<span class="op">&lt;</span><span class="dt">size_t</span>, num_cols<span class="op">&gt;&gt;</span> z<span class="op">)</span></span>
<span id="cb80-27"><a href="#cb80-27" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb80-28"><a href="#cb80-28" aria-hidden="true" tabindex="-1"></a>  matrix_vector_product<span class="op">(</span>scaled<span class="op">(</span><span class="fl">7.0</span>, transposed<span class="op">(</span>A<span class="op">))</span>, y, z<span class="op">)</span>;</span>
<span id="cb80-29"><a href="#cb80-29" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<p>–<em>end example</em>]</p>
<div class="sourceCode" id="cb81"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb81-1"><a href="#cb81-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb81-2"><a href="#cb81-2" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb81-3"><a href="#cb81-3" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb81-4"><a href="#cb81-4" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb81-5"><a href="#cb81-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_vector_product<span class="op">(</span>InMat A,</span>
<span id="cb81-6"><a href="#cb81-6" aria-hidden="true" tabindex="-1"></a>                           InVec1 x,</span>
<span id="cb81-7"><a href="#cb81-7" aria-hidden="true" tabindex="-1"></a>                           InVec2 y,</span>
<span id="cb81-8"><a href="#cb81-8" aria-hidden="true" tabindex="-1"></a>                           OutVec z<span class="op">)</span>;</span>
<span id="cb81-9"><a href="#cb81-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb81-10"><a href="#cb81-10" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb81-11"><a href="#cb81-11" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb81-12"><a href="#cb81-12" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb81-13"><a href="#cb81-13" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb81-14"><a href="#cb81-14" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb81-15"><a href="#cb81-15" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_vector_product<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb81-16"><a href="#cb81-16" aria-hidden="true" tabindex="-1"></a>                           InMat A,</span>
<span id="cb81-17"><a href="#cb81-17" aria-hidden="true" tabindex="-1"></a>                           InVec1 x,</span>
<span id="cb81-18"><a href="#cb81-18" aria-hidden="true" tabindex="-1"></a>                           InVec2 y,</span>
<span id="cb81-19"><a href="#cb81-19" aria-hidden="true" tabindex="-1"></a>                           OutVec z<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
These functions performs an updating matrix-vector product.</p>
<p><span class="marginalizedparent"><a class="marginalized">8</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>z</em> = <em>y</em> + <em>A</em><em>x</em></span>.</p>
<p><span class="marginalizedparent"><a class="marginalized">9</a></span>
<em>Remarks:</em> <code>z</code> may alias <code>y</code>.</p>
<h4 data-number="28.9.14.2" id="symmetric-matrix-vector-product-linalg.algs.blas2.symv"><span class="header-section-number">28.9.14.2</span> Symmetric matrix-vector
product [linalg.algs.blas2.symv]<a href="#symmetric-matrix-vector-product-linalg.algs.blas2.symv" class="self-link"></a></h4>
<p><i>[Note:</i> These functions correspond to the BLAS functions
<code>xSYMV</code> and <code>xSPMV</code>. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The following elements apply to all functions in
[linalg.algs.blas2.symv].</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span> If
<code>InMat</code> has <code>layout_blas_packed</code> layout, then the
layout’s <code>Triangle</code> template argument has the same type as
the function’s <code>Triangle</code> template argument;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;decltype(A), decltype(A)&gt;(0, 1)</code>
is <code>true</code>;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.3)</a></span>
<em><code>possibly-multipliable</code></em><code>&lt;decltype(A), decltype(x), decltype(y)&gt;()</code>
is <code>true</code>; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.4)</a></span>
<em><code>possibly-addable</code></em><code>&lt;decltype(x),decltype(y),decltype(z)&gt;()</code>
is <code>true</code> for those overloads that take a <code>z</code>
parameter.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.1)</a></span>
<code>A.extent(0)</code> equals <code>A.extent(1)</code>,</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.2)</a></span>
<em><code>multipliable</code></em><code>(A,x,y)</code> is
<code>true</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.3)</a></span>
<em><code>addable</code></em><code>(x,y,z)</code> is <code>true</code>
for those overloads that take a <code>z</code> parameter.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>x.extent(0)</code> <span class="math inline">⋅</span>
<code>A.extent(1)</code> <span class="math inline">)</span></p>
<div class="sourceCode" id="cb82"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb82-1"><a href="#cb82-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb82-2"><a href="#cb82-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb82-3"><a href="#cb82-3" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb82-4"><a href="#cb82-4" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb82-5"><a href="#cb82-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_vector_product<span class="op">(</span>InMat A,</span>
<span id="cb82-6"><a href="#cb82-6" aria-hidden="true" tabindex="-1"></a>                                     Triangle t,</span>
<span id="cb82-7"><a href="#cb82-7" aria-hidden="true" tabindex="-1"></a>                                     InVec x,</span>
<span id="cb82-8"><a href="#cb82-8" aria-hidden="true" tabindex="-1"></a>                                     OutVec y<span class="op">)</span>;</span>
<span id="cb82-9"><a href="#cb82-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb82-10"><a href="#cb82-10" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb82-11"><a href="#cb82-11" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb82-12"><a href="#cb82-12" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb82-13"><a href="#cb82-13" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb82-14"><a href="#cb82-14" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb82-15"><a href="#cb82-15" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_vector_product<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb82-16"><a href="#cb82-16" aria-hidden="true" tabindex="-1"></a>                                     InMat A,</span>
<span id="cb82-17"><a href="#cb82-17" aria-hidden="true" tabindex="-1"></a>                                     Triangle t,</span>
<span id="cb82-18"><a href="#cb82-18" aria-hidden="true" tabindex="-1"></a>                                     InVec x,</span>
<span id="cb82-19"><a href="#cb82-19" aria-hidden="true" tabindex="-1"></a>                                     OutVec y<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
These functions perform an overwriting symmetric matrix-vector product,
taking into account the <code>Triangle</code> parameter that applies to
the symmetric matrix <code>A</code> [linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>y</em> = <em>A</em><em>x</em></span>.</p>
<div class="sourceCode" id="cb83"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb83-1"><a href="#cb83-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb83-2"><a href="#cb83-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb83-3"><a href="#cb83-3" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb83-4"><a href="#cb83-4" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb83-5"><a href="#cb83-5" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb83-6"><a href="#cb83-6" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_vector_product<span class="op">(</span></span>
<span id="cb83-7"><a href="#cb83-7" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb83-8"><a href="#cb83-8" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb83-9"><a href="#cb83-9" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb83-10"><a href="#cb83-10" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb83-11"><a href="#cb83-11" aria-hidden="true" tabindex="-1"></a>  OutVec z<span class="op">)</span>;</span>
<span id="cb83-12"><a href="#cb83-12" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb83-13"><a href="#cb83-13" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb83-14"><a href="#cb83-14" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb83-15"><a href="#cb83-15" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb83-16"><a href="#cb83-16" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb83-17"><a href="#cb83-17" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb83-18"><a href="#cb83-18" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_vector_product<span class="op">(</span></span>
<span id="cb83-19"><a href="#cb83-19" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb83-20"><a href="#cb83-20" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb83-21"><a href="#cb83-21" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb83-22"><a href="#cb83-22" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb83-23"><a href="#cb83-23" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb83-24"><a href="#cb83-24" aria-hidden="true" tabindex="-1"></a>  OutVec z<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
These functions perform an updating symmetric matrix-vector product,
taking into account the <code>Triangle</code> parameter that applies to
the symmetric matrix <code>A</code> [linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">8</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>z</em> = <em>y</em> + <em>A</em><em>x</em></span>.</p>
<p><span class="marginalizedparent"><a class="marginalized">9</a></span>
<em>Remarks:</em> <code>z</code> may alias <code>y</code>.</p>
<h4 data-number="28.9.14.3" id="hermitian-matrix-vector-product-linalg.algs.blas2.hemv"><span class="header-section-number">28.9.14.3</span> Hermitian matrix-vector
product [linalg.algs.blas2.hemv]<a href="#hermitian-matrix-vector-product-linalg.algs.blas2.hemv" class="self-link"></a></h4>
<p><i>[Note:</i> These functions correspond to the BLAS functions
<code>xHEMV</code> and <code>xHPMV</code>. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The following elements apply to all functions in
[linalg.algs.blas2.hemv].</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span> If
<code>InMat</code> has <code>layout_blas_packed</code> layout, then the
layout’s <code>Triangle</code> template argument has the same type as
the function’s <code>Triangle</code> template argument;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;decltype(A), decltype(A)&gt;(0, 1)</code>
is <code>true</code>;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.3)</a></span>
<em><code>possibly-multipliable</code></em><code>&lt;decltype(A), decltype(x), decltype(y)&gt;()</code>
is <code>true</code>; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.4)</a></span>
<em><code>possibly-addable</code></em><code>&lt;decltype(x),decltype(y),decltype(z)&gt;()</code>
is <code>true</code> for those overloads that take a <code>z</code>
parameter.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.1)</a></span>
<code>A.extent(0)</code> equals <code>A.extent(1)</code>,</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.2)</a></span>
<em><code>multipliable</code></em><code>(A,x,y)</code> is
<code>true</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.3)</a></span>
<em><code>addable</code></em><code>(x,y,z)</code> is <code>true</code>
for those overloads that take a <code>z</code> parameter.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>x.extent(0)</code> <span class="math inline">⋅</span>
<code>A.extent(1)</code> <span class="math inline">)</span></p>
<div class="sourceCode" id="cb84"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb84-1"><a href="#cb84-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb84-2"><a href="#cb84-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb84-3"><a href="#cb84-3" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb84-4"><a href="#cb84-4" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb84-5"><a href="#cb84-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_vector_product<span class="op">(</span>InMat A,</span>
<span id="cb84-6"><a href="#cb84-6" aria-hidden="true" tabindex="-1"></a>                                     Triangle t,</span>
<span id="cb84-7"><a href="#cb84-7" aria-hidden="true" tabindex="-1"></a>                                     InVec x,</span>
<span id="cb84-8"><a href="#cb84-8" aria-hidden="true" tabindex="-1"></a>                                     OutVec y<span class="op">)</span>;</span>
<span id="cb84-9"><a href="#cb84-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb84-10"><a href="#cb84-10" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb84-11"><a href="#cb84-11" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb84-12"><a href="#cb84-12" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb84-13"><a href="#cb84-13" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb84-14"><a href="#cb84-14" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb84-15"><a href="#cb84-15" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_vector_product<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb84-16"><a href="#cb84-16" aria-hidden="true" tabindex="-1"></a>                                     InMat A,</span>
<span id="cb84-17"><a href="#cb84-17" aria-hidden="true" tabindex="-1"></a>                                     Triangle t,</span>
<span id="cb84-18"><a href="#cb84-18" aria-hidden="true" tabindex="-1"></a>                                     InVec x,</span>
<span id="cb84-19"><a href="#cb84-19" aria-hidden="true" tabindex="-1"></a>                                     OutVec y<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
These functions perform an overwriting Hermitian matrix-vector product,
taking into account the <code>Triangle</code> parameter that applies to
the Hermitian matrix <code>A</code> [linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>y</em> = <em>A</em><em>x</em></span>.</p>
<div class="sourceCode" id="cb85"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb85-1"><a href="#cb85-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb85-2"><a href="#cb85-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb85-3"><a href="#cb85-3" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb85-4"><a href="#cb85-4" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb85-5"><a href="#cb85-5" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb85-6"><a href="#cb85-6" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_vector_product<span class="op">(</span>InMat A,</span>
<span id="cb85-7"><a href="#cb85-7" aria-hidden="true" tabindex="-1"></a>                                     Triangle t,</span>
<span id="cb85-8"><a href="#cb85-8" aria-hidden="true" tabindex="-1"></a>                                     InVec1 x,</span>
<span id="cb85-9"><a href="#cb85-9" aria-hidden="true" tabindex="-1"></a>                                     InVec2 y,</span>
<span id="cb85-10"><a href="#cb85-10" aria-hidden="true" tabindex="-1"></a>                                     OutVec z<span class="op">)</span>;</span>
<span id="cb85-11"><a href="#cb85-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb85-12"><a href="#cb85-12" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb85-13"><a href="#cb85-13" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb85-14"><a href="#cb85-14" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb85-15"><a href="#cb85-15" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb85-16"><a href="#cb85-16" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb85-17"><a href="#cb85-17" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb85-18"><a href="#cb85-18" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_vector_product<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb85-19"><a href="#cb85-19" aria-hidden="true" tabindex="-1"></a>                                     InMat A,</span>
<span id="cb85-20"><a href="#cb85-20" aria-hidden="true" tabindex="-1"></a>                                     Triangle t,</span>
<span id="cb85-21"><a href="#cb85-21" aria-hidden="true" tabindex="-1"></a>                                     InVec1 x,</span>
<span id="cb85-22"><a href="#cb85-22" aria-hidden="true" tabindex="-1"></a>                                     InVec2 y,</span>
<span id="cb85-23"><a href="#cb85-23" aria-hidden="true" tabindex="-1"></a>                                     OutVec z<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
These functions perform an updating Hermitian matrix-vector product,
taking into account the <code>Triangle</code> parameter that applies to
the Hermitian matrix <code>A</code> [linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">8</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>z</em> = <em>y</em> + <em>A</em><em>x</em></span>.</p>
<p><span class="marginalizedparent"><a class="marginalized">9</a></span>
<em>Remarks:</em> <code>z</code> may alias <code>y</code>.</p>
<h4 data-number="28.9.14.4" id="triangular-matrix-vector-product-linalg.algs.blas2.trmv"><span class="header-section-number">28.9.14.4</span> Triangular matrix-vector
product [linalg.algs.blas2.trmv]<a href="#triangular-matrix-vector-product-linalg.algs.blas2.trmv" class="self-link"></a></h4>
<p><i>[Note:</i> These functions correspond to the BLAS functions
<code>xTRMV</code> and <code>xTPMV</code>. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The following elements apply to all functions in
[linalg.algs.blas2.trmv].</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span> If
<code>InMat</code> has <code>layout_blas_packed</code> layout, then the
layout’s <code>Triangle</code> template argument has the same type as
the function’s <code>Triangle</code> template argument;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;decltype(A), decltype(A)&gt;(0, 1)</code>
is <code>true</code>;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.3)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;decltype(A), decltype(y)&gt;(0, 0)</code>
is <code>true</code>;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.4)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;decltype(A), decltype(x)&gt;(0, 0)</code>
is <code>true</code> for those overloads that take an <code>x</code>
parameter; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.5)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;decltype(A), decltype(z)&gt;(0, 0)</code>
is <code>true</code> for those overloads that take a <code>z</code>
parameter.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.1)</a></span>
<code>A.extent(0)</code> equals <code>A.extent(1)</code>,</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.2)</a></span>
<code>A.extent(0)</code> equals <code>y.extent(0)</code>,</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.3)</a></span>
<code>A.extent(0)</code> equals <code>x.extent(0)</code> for those
overloads that take an <code>x</code> parameter, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.4)</a></span>
<code>A.extent(0)</code> equals <code>z.extent(0)</code> for those
overloads that take a <code>z</code> parameter.</p></li>
</ul>
<div class="sourceCode" id="cb86"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb86-1"><a href="#cb86-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb86-2"><a href="#cb86-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb86-3"><a href="#cb86-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb86-4"><a href="#cb86-4" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb86-5"><a href="#cb86-5" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb86-6"><a href="#cb86-6" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_product<span class="op">(</span></span>
<span id="cb86-7"><a href="#cb86-7" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb86-8"><a href="#cb86-8" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb86-9"><a href="#cb86-9" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb86-10"><a href="#cb86-10" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb86-11"><a href="#cb86-11" aria-hidden="true" tabindex="-1"></a>  OutVec y<span class="op">)</span>;</span>
<span id="cb86-12"><a href="#cb86-12" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb86-13"><a href="#cb86-13" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb86-14"><a href="#cb86-14" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb86-15"><a href="#cb86-15" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb86-16"><a href="#cb86-16" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb86-17"><a href="#cb86-17" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb86-18"><a href="#cb86-18" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_product<span class="op">(</span></span>
<span id="cb86-19"><a href="#cb86-19" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb86-20"><a href="#cb86-20" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb86-21"><a href="#cb86-21" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb86-22"><a href="#cb86-22" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb86-23"><a href="#cb86-23" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb86-24"><a href="#cb86-24" aria-hidden="true" tabindex="-1"></a>  OutVec y<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
These functions perform an overwriting triangular matrix-vector product,
taking into account the <code>Triangle</code> and
<code>DiagonalStorage</code> parameters that apply to the triangular
matrix <code>A</code> [linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>y</em> = <em>A</em><em>x</em></span>.</p>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>x.extent(0)</code> <span class="math inline">⋅</span>
<code>A.extent(1)</code> <span class="math inline">)</span></p>
<div class="sourceCode" id="cb87"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb87-1"><a href="#cb87-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb87-2"><a href="#cb87-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb87-3"><a href="#cb87-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb87-4"><a href="#cb87-4" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec<span class="op">&gt;</span></span>
<span id="cb87-5"><a href="#cb87-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_product<span class="op">(</span></span>
<span id="cb87-6"><a href="#cb87-6" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb87-7"><a href="#cb87-7" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb87-8"><a href="#cb87-8" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb87-9"><a href="#cb87-9" aria-hidden="true" tabindex="-1"></a>  InOutVec y<span class="op">)</span>;</span>
<span id="cb87-10"><a href="#cb87-10" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb87-11"><a href="#cb87-11" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb87-12"><a href="#cb87-12" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb87-13"><a href="#cb87-13" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb87-14"><a href="#cb87-14" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec<span class="op">&gt;</span></span>
<span id="cb87-15"><a href="#cb87-15" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_product<span class="op">(</span></span>
<span id="cb87-16"><a href="#cb87-16" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb87-17"><a href="#cb87-17" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb87-18"><a href="#cb87-18" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb87-19"><a href="#cb87-19" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb87-20"><a href="#cb87-20" aria-hidden="true" tabindex="-1"></a>  InOutVec y<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
These functions perform an in-place triangular matrix-vector product,
taking into account the <code>Triangle</code> and
<code>DiagonalStorage</code> parameters that apply to the triangular
matrix <code>A</code> [linalg.general].</p>
<p><i>[Note:</i> Performing this operation in place hinders
parallelization. However, other <code>ExecutionPolicy</code> specific
optimizations, such as vectorization, are still possible. <i>– end
note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">8</a></span>
<em>Effects:</em> Computes a vector <span class="math inline"><em>y</em>′</span> such that <span class="math inline"><em>y</em>′ = <em>A</em><em>y</em></span>, and
assigns each element of <span class="math inline"><em>y</em>′</span> to
the corresponding element of <span class="math inline"><em>y</em></span>.</p>
<p><span class="marginalizedparent"><a class="marginalized">9</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>y.extent(0)</code> <span class="math inline">⋅</span>
<code>A.extent(1)</code> <span class="math inline">)</span></p>
<div class="sourceCode" id="cb88"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb88-1"><a href="#cb88-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb88-2"><a href="#cb88-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb88-3"><a href="#cb88-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb88-4"><a href="#cb88-4" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb88-5"><a href="#cb88-5" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb88-6"><a href="#cb88-6" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb88-7"><a href="#cb88-7" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_product<span class="op">(</span>InMat A,</span>
<span id="cb88-8"><a href="#cb88-8" aria-hidden="true" tabindex="-1"></a>                                      Triangle t,</span>
<span id="cb88-9"><a href="#cb88-9" aria-hidden="true" tabindex="-1"></a>                                      DiagonalStorage d,</span>
<span id="cb88-10"><a href="#cb88-10" aria-hidden="true" tabindex="-1"></a>                                      InVec1 x,</span>
<span id="cb88-11"><a href="#cb88-11" aria-hidden="true" tabindex="-1"></a>                                      InVec2 y,</span>
<span id="cb88-12"><a href="#cb88-12" aria-hidden="true" tabindex="-1"></a>                                      OutVec z<span class="op">)</span>;</span>
<span id="cb88-13"><a href="#cb88-13" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb88-14"><a href="#cb88-14" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb88-15"><a href="#cb88-15" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb88-16"><a href="#cb88-16" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb88-17"><a href="#cb88-17" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb88-18"><a href="#cb88-18" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb88-19"><a href="#cb88-19" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb88-20"><a href="#cb88-20" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb88-21"><a href="#cb88-21" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_product<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb88-22"><a href="#cb88-22" aria-hidden="true" tabindex="-1"></a>                                      InMat A,</span>
<span id="cb88-23"><a href="#cb88-23" aria-hidden="true" tabindex="-1"></a>                                      Triangle t,</span>
<span id="cb88-24"><a href="#cb88-24" aria-hidden="true" tabindex="-1"></a>                                      DiagonalStorage d,</span>
<span id="cb88-25"><a href="#cb88-25" aria-hidden="true" tabindex="-1"></a>                                      InVec1 x,</span>
<span id="cb88-26"><a href="#cb88-26" aria-hidden="true" tabindex="-1"></a>                                      InVec2 y,</span>
<span id="cb88-27"><a href="#cb88-27" aria-hidden="true" tabindex="-1"></a>                                      OutVec z<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">10</a></span> These
functions perform an updating triangular matrix-vector product, taking
into account the <code>Triangle</code> and <code>DiagonalStorage</code>
parameters that apply to the triangular matrix <code>A</code>
[linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">11</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>z</em> = <em>y</em> + <em>A</em><em>x</em></span>.</p>
<p><span class="marginalizedparent"><a class="marginalized">12</a></span>
<em>Remarks:</em> <code>z</code> may alias <code>y</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">13</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>x.extent(0)</code> <span class="math inline">⋅</span>
<code>A.extent(1)</code> <span class="math inline">)</span></p>
<h4 data-number="28.9.14.5" id="solve-a-triangular-linear-system-linalg.algs.blas2.trsv"><span class="header-section-number">28.9.14.5</span> Solve a triangular linear
system [linalg.algs.blas2.trsv]<a href="#solve-a-triangular-linear-system-linalg.algs.blas2.trsv" class="self-link"></a></h4>
<p><i>[Note:</i> These functions correspond to the BLAS functions
<code>xTRSV</code> and <code>xTPSV</code>. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The following elements apply to all functions in
[linalg.algs.blas2.trsv].</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span> If
<code>InMat</code> has <code>layout_blas_packed</code> layout, then the
layout’s <code>Triangle</code> template argument has the same type as
the function’s <code>Triangle</code> template argument;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;decltype(A), decltype(A)&gt;(0, 1)</code>
is <code>true</code>;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.3)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;decltype(A), decltype(b)&gt;(0, 0)</code>
is <code>true</code>; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.4)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;decltype(A), decltype(x)&gt;(0, 0)</code>
is <code>true</code> for those overloads that take an <code>x</code>
parameter.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.1)</a></span>
<code>A.extent(0)</code> equals <code>A.extent(1)</code>,</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.2)</a></span>
<code>A.extent(0)</code> equals <code>b.extent(0)</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.3)</a></span>
<code>A.extent(0)</code> equals <code>x.extent(0)</code> for those
overloads that take an <code>x</code> parameter.</p></li>
</ul>
<div class="sourceCode" id="cb89"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb89-1"><a href="#cb89-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb89-2"><a href="#cb89-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb89-3"><a href="#cb89-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb89-4"><a href="#cb89-4" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb89-5"><a href="#cb89-5" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec,</span>
<span id="cb89-6"><a href="#cb89-6" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb89-7"><a href="#cb89-7" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_solve<span class="op">(</span></span>
<span id="cb89-8"><a href="#cb89-8" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb89-9"><a href="#cb89-9" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb89-10"><a href="#cb89-10" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb89-11"><a href="#cb89-11" aria-hidden="true" tabindex="-1"></a>  InVec b,</span>
<span id="cb89-12"><a href="#cb89-12" aria-hidden="true" tabindex="-1"></a>  OutVec x,</span>
<span id="cb89-13"><a href="#cb89-13" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span>
<span id="cb89-14"><a href="#cb89-14" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb89-15"><a href="#cb89-15" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb89-16"><a href="#cb89-16" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb89-17"><a href="#cb89-17" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb89-18"><a href="#cb89-18" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb89-19"><a href="#cb89-19" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec,</span>
<span id="cb89-20"><a href="#cb89-20" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb89-21"><a href="#cb89-21" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_solve<span class="op">(</span></span>
<span id="cb89-22"><a href="#cb89-22" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb89-23"><a href="#cb89-23" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb89-24"><a href="#cb89-24" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb89-25"><a href="#cb89-25" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb89-26"><a href="#cb89-26" aria-hidden="true" tabindex="-1"></a>  InVec b,</span>
<span id="cb89-27"><a href="#cb89-27" aria-hidden="true" tabindex="-1"></a>  OutVec x,</span>
<span id="cb89-28"><a href="#cb89-28" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
These functions perform a triangular solve, taking into account the
<code>Triangle</code> and <code>DiagonalStorage</code> parameters that
apply to the triangular matrix <code>A</code> [linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
<em>Effects:</em> Computes a vector <span class="math inline"><em>x</em>′</span> such that <span class="math inline"><em>b</em> = <em>A</em><em>x</em>′</span>, and
assigns each element of <span class="math inline"><em>x</em>′</span> to
the corresponding element of <span class="math inline"><em>x</em></span>. If no such <span class="math inline"><em>x</em>′</span> exists, then the elements of
<code>x</code> are valid but unspecified.</p>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>A.extent(1)</code> <span class="math inline">⋅</span>
<code>b.extent(0)</code> <span class="math inline">)</span></p>
<div class="sourceCode" id="cb90"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb90-1"><a href="#cb90-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb90-2"><a href="#cb90-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb90-3"><a href="#cb90-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb90-4"><a href="#cb90-4" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb90-5"><a href="#cb90-5" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb90-6"><a href="#cb90-6" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_solve<span class="op">(</span></span>
<span id="cb90-7"><a href="#cb90-7" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb90-8"><a href="#cb90-8" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb90-9"><a href="#cb90-9" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb90-10"><a href="#cb90-10" aria-hidden="true" tabindex="-1"></a>  InVec b,</span>
<span id="cb90-11"><a href="#cb90-11" aria-hidden="true" tabindex="-1"></a>  OutVec x<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
<em>Effects:</em> Equivalent to</p>
<div class="sourceCode" id="cb91"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb91-1"><a href="#cb91-1" aria-hidden="true" tabindex="-1"></a>triangular_matrix_vector_solve<span class="op">(</span>A, t, d, b, x, divides<span class="op">&lt;</span><span class="dt">void</span><span class="op">&gt;{})</span>;</span></code></pre></div>
<div class="sourceCode" id="cb92"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb92-1"><a href="#cb92-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb92-2"><a href="#cb92-2" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb92-3"><a href="#cb92-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb92-4"><a href="#cb92-4" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb92-5"><a href="#cb92-5" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb92-6"><a href="#cb92-6" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb92-7"><a href="#cb92-7" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_solve<span class="op">(</span></span>
<span id="cb92-8"><a href="#cb92-8" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb92-9"><a href="#cb92-9" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb92-10"><a href="#cb92-10" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb92-11"><a href="#cb92-11" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb92-12"><a href="#cb92-12" aria-hidden="true" tabindex="-1"></a>  InVec b,</span>
<span id="cb92-13"><a href="#cb92-13" aria-hidden="true" tabindex="-1"></a>  OutVec x<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">8</a></span>
<em>Effects:</em> Equivalent to</p>
<div class="sourceCode" id="cb93"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb93-1"><a href="#cb93-1" aria-hidden="true" tabindex="-1"></a>triangular_matrix_vector_solve<span class="op">(</span>std<span class="op">::</span>forward<span class="op">&lt;</span>ExecutionPolicy<span class="op">&gt;(</span>exec<span class="op">)</span>,</span>
<span id="cb93-2"><a href="#cb93-2" aria-hidden="true" tabindex="-1"></a>  A, t, d, b, x, divides<span class="op">&lt;</span><span class="dt">void</span><span class="op">&gt;{})</span>;</span></code></pre></div>
<div class="sourceCode" id="cb94"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb94-1"><a href="#cb94-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb94-2"><a href="#cb94-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb94-3"><a href="#cb94-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb94-4"><a href="#cb94-4" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec,</span>
<span id="cb94-5"><a href="#cb94-5" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb94-6"><a href="#cb94-6" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_solve<span class="op">(</span></span>
<span id="cb94-7"><a href="#cb94-7" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb94-8"><a href="#cb94-8" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb94-9"><a href="#cb94-9" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb94-10"><a href="#cb94-10" aria-hidden="true" tabindex="-1"></a>  InOutVec b,</span>
<span id="cb94-11"><a href="#cb94-11" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span>
<span id="cb94-12"><a href="#cb94-12" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb94-13"><a href="#cb94-13" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb94-14"><a href="#cb94-14" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb94-15"><a href="#cb94-15" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb94-16"><a href="#cb94-16" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec,</span>
<span id="cb94-17"><a href="#cb94-17" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb94-18"><a href="#cb94-18" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_solve<span class="op">(</span></span>
<span id="cb94-19"><a href="#cb94-19" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb94-20"><a href="#cb94-20" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb94-21"><a href="#cb94-21" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb94-22"><a href="#cb94-22" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb94-23"><a href="#cb94-23" aria-hidden="true" tabindex="-1"></a>  InOutVec b,</span>
<span id="cb94-24"><a href="#cb94-24" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">9</a></span>
These functions perform an in-place triangular solve, taking into
account the <code>Triangle</code> and <code>DiagonalStorage</code>
parameters that apply to the triangular matrix <code>A</code>
[linalg.general].</p>
<p><i>[Note:</i> Performing triangular solve in place hinders
parallelization. However, other <code>ExecutionPolicy</code> specific
optimizations, such as vectorization, are still possible. <i>– end
note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">10</a></span>
<em>Effects:</em> Computes a vector <span class="math inline"><em>x</em>′</span> such that <span class="math inline"><em>b</em> = <em>A</em><em>x</em>′</span>, and
assigns each element of <span class="math inline"><em>x</em>′</span> to
the corresponding element of <span class="math inline"><em>b</em></span>. If no such <span class="math inline"><em>x</em>′</span> exists, then the elements of
<code>b</code> are valid but unspecified.</p>
<p><span class="marginalizedparent"><a class="marginalized">11</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>A.extent(1)</code> <span class="math inline">⋅</span>
<code>b.extent(0)</code> <span class="math inline">)</span></p>
<div class="sourceCode" id="cb95"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb95-1"><a href="#cb95-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb95-2"><a href="#cb95-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb95-3"><a href="#cb95-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb95-4"><a href="#cb95-4" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec<span class="op">&gt;</span></span>
<span id="cb95-5"><a href="#cb95-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_solve<span class="op">(</span></span>
<span id="cb95-6"><a href="#cb95-6" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb95-7"><a href="#cb95-7" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb95-8"><a href="#cb95-8" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb95-9"><a href="#cb95-9" aria-hidden="true" tabindex="-1"></a>  InOutVec b<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">12</a></span>
<em>Effects:</em> Equivalent to:</p>
<div class="sourceCode" id="cb96"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb96-1"><a href="#cb96-1" aria-hidden="true" tabindex="-1"></a>triangular_matrix_vector_solve<span class="op">(</span>A, t, d, b, divides<span class="op">&lt;</span><span class="dt">void</span><span class="op">&gt;{})</span>;</span></code></pre></div>
<div class="sourceCode" id="cb97"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb97-1"><a href="#cb97-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb97-2"><a href="#cb97-2" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb97-3"><a href="#cb97-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb97-4"><a href="#cb97-4" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb97-5"><a href="#cb97-5" aria-hidden="true" tabindex="-1"></a>         <em>inout-vector</em> InOutVec<span class="op">&gt;</span></span>
<span id="cb97-6"><a href="#cb97-6" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_vector_solve<span class="op">(</span></span>
<span id="cb97-7"><a href="#cb97-7" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb97-8"><a href="#cb97-8" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb97-9"><a href="#cb97-9" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb97-10"><a href="#cb97-10" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb97-11"><a href="#cb97-11" aria-hidden="true" tabindex="-1"></a>  InOutVec b<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">13</a></span>
<em>Effects:</em> Equivalent to:</p>
<div class="sourceCode" id="cb98"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb98-1"><a href="#cb98-1" aria-hidden="true" tabindex="-1"></a>triangular_matrix_vector_solve<span class="op">(</span>std<span class="op">::</span>forward<span class="op">&lt;</span>ExecutionPolicy<span class="op">&gt;(</span>exec<span class="op">)</span>,</span>
<span id="cb98-2"><a href="#cb98-2" aria-hidden="true" tabindex="-1"></a>  A, t, d, b, divides<span class="op">&lt;</span><span class="dt">void</span><span class="op">&gt;{})</span>;</span></code></pre></div>
<h4 data-number="28.9.14.6" id="rank-1-outer-product-update-of-a-matrix-linalg.algs.blas2.rank1"><span class="header-section-number">28.9.14.6</span> Rank-1 (outer product)
update of a matrix [linalg.algs.blas2.rank1]<a href="#rank-1-outer-product-update-of-a-matrix-linalg.algs.blas2.rank1" class="self-link"></a></h4>
<div class="sourceCode" id="cb99"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb99-1"><a href="#cb99-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec1,</span>
<span id="cb99-2"><a href="#cb99-2" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb99-3"><a href="#cb99-3" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb99-4"><a href="#cb99-4" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_rank_1_update<span class="op">(</span></span>
<span id="cb99-5"><a href="#cb99-5" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb99-6"><a href="#cb99-6" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb99-7"><a href="#cb99-7" aria-hidden="true" tabindex="-1"></a>  InOutMat A<span class="op">)</span>;</span>
<span id="cb99-8"><a href="#cb99-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb99-9"><a href="#cb99-9" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb99-10"><a href="#cb99-10" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb99-11"><a href="#cb99-11" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb99-12"><a href="#cb99-12" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb99-13"><a href="#cb99-13" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_rank_1_update<span class="op">(</span></span>
<span id="cb99-14"><a href="#cb99-14" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb99-15"><a href="#cb99-15" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb99-16"><a href="#cb99-16" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb99-17"><a href="#cb99-17" aria-hidden="true" tabindex="-1"></a>  InOutMat A<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
These functions perform a nonsymmetric nonconjugated rank-1 update.</p>
<p><i>[Note:</i> These functions correspond to the BLAS functions
<code>xGER</code> (for real element types) and <code>xGERU</code> (for
complex element types). <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em>
<em><code>possibly-multipliable</code></em><code>&lt;InOutMat, InVec2, InVec1&gt;()</code>
is <code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em>
<em><code>multipliable</code></em><code>(A,y,x)</code> is
<code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Effects:</em> Computes a matrix <span class="math inline"><em>A</em>′</span> such that <span class="math inline"><em>A</em>′ = <em>A</em> + <em>x</em><em>y</em><sup><em>T</em></sup></span>,
and assigns each element of <span class="math inline"><em>A</em>′</span>
to the corresponding element of <span class="math inline"><em>A</em></span>.</p>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>x.extent(0)</code> <span class="math inline">⋅</span>
<code>y.extent(0)</code> <span class="math inline">)</span></p>
<!--
Users can get `xGERC` behavior by giving the second argument
as the result of `conjugated`.  Alternately, they can use the shortcut
`matrix_rank_1_update_c` below.
-->
<div class="sourceCode" id="cb100"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb100-1"><a href="#cb100-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec1,</span>
<span id="cb100-2"><a href="#cb100-2" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb100-3"><a href="#cb100-3" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb100-4"><a href="#cb100-4" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_rank_1_update_c<span class="op">(</span></span>
<span id="cb100-5"><a href="#cb100-5" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb100-6"><a href="#cb100-6" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb100-7"><a href="#cb100-7" aria-hidden="true" tabindex="-1"></a>  InOutMat A<span class="op">)</span>;</span>
<span id="cb100-8"><a href="#cb100-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb100-9"><a href="#cb100-9" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb100-10"><a href="#cb100-10" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb100-11"><a href="#cb100-11" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb100-12"><a href="#cb100-12" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb100-13"><a href="#cb100-13" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_rank_1_update_c<span class="op">(</span></span>
<span id="cb100-14"><a href="#cb100-14" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb100-15"><a href="#cb100-15" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb100-16"><a href="#cb100-16" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb100-17"><a href="#cb100-17" aria-hidden="true" tabindex="-1"></a>  InOutMat A<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
These functions perform a nonsymmetric conjugated rank-1 update.</p>
<p><i>[Note:</i> These functions correspond to the BLAS functions
<code>xGER</code> (for real element types) and <code>xGERC</code> (for
complex element types). <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
<em>Effects:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(7.1)</a></span> For
the overloads without an <code>ExecutionPolicy</code> argument,
equivalent to
<code>matrix_rank_1_update(x, conjugated(y), A);</code>;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(7.2)</a></span>
otherwise, equivalent to
<code>matrix_rank_1_update(std::forward&lt;ExecutionPolicy&gt;(exec), x, conjugated(y), A);</code>.</p></li>
</ul>
<h4 data-number="28.9.14.7" id="symmetric-or-hermitian-rank-1-outer-product-update-of-a-matrix-linalg.algs.blas2.symherrank1"><span class="header-section-number">28.9.14.7</span> Symmetric or Hermitian
Rank-1 (outer product) update of a matrix
[linalg.algs.blas2.symherrank1]<a href="#symmetric-or-hermitian-rank-1-outer-product-update-of-a-matrix-linalg.algs.blas2.symherrank1" class="self-link"></a></h4>
<p><i>[Note:</i> These functions correspond to the BLAS functions
<code>xSYR</code>, <code>xSPR</code>, <code>xHER</code>, and
<code>xHPR</code>.</p>
<p>They have overloads taking a scaling factor <code>alpha</code>,
because it would be impossible to express the update <span class="math inline"><em>A</em> = <em>A</em> − <em>x</em><em>x</em><sup><em>T</em></sup></span>
otherwise. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The following elements apply to all functions in
[linalg.algs.blas2.symherrank1].</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span> If
<code>InOutMat</code> has <code>layout_blas_packed</code> layout, then
the layout’s <code>Triangle</code> template argument has the same type
as the function’s <code>Triangle</code> template argument;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;decltype(A), decltype(A)&gt;(0,1)</code>
is <code>true</code>; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.3)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;decltype(A), decltype(x)&gt;(0,0)</code>
is <code>true</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.1)</a></span>
<code>A.extent(0)</code> equals <code>A.extent(1)</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.2)</a></span>
<code>A.extent(0)</code> equals <code>x.extent(0)</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>x.extent(0)</code> <span class="math inline">⋅</span>
<code>x.extent(0)</code> <span class="math inline">)</span></p>
<div class="sourceCode" id="cb101"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb101-1"><a href="#cb101-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec,</span>
<span id="cb101-2"><a href="#cb101-2" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb101-3"><a href="#cb101-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb101-4"><a href="#cb101-4" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_1_update<span class="op">(</span></span>
<span id="cb101-5"><a href="#cb101-5" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb101-6"><a href="#cb101-6" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb101-7"><a href="#cb101-7" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb101-8"><a href="#cb101-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb101-9"><a href="#cb101-9" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb101-10"><a href="#cb101-10" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb101-11"><a href="#cb101-11" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb101-12"><a href="#cb101-12" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb101-13"><a href="#cb101-13" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_1_update<span class="op">(</span></span>
<span id="cb101-14"><a href="#cb101-14" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb101-15"><a href="#cb101-15" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb101-16"><a href="#cb101-16" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb101-17"><a href="#cb101-17" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
These functions perform a symmetric rank-1 update of the symmetric
matrix <code>A</code>, taking into account the <code>Triangle</code>
parameter that applies to <code>A</code> [linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Effects:</em> Computes a matrix <span class="math inline"><em>A</em>′</span> such that <span class="math inline"><em>A</em>′ = <em>A</em> + <em>x</em><em>x</em><sup><em>T</em></sup></span>
and assigns each element of <span class="math inline"><em>A</em>′</span>
to the corresponding element of <span class="math inline"><em>A</em></span>.</p>
<div class="sourceCode" id="cb102"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb102-1"><a href="#cb102-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Scalar,</span>
<span id="cb102-2"><a href="#cb102-2" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb102-3"><a href="#cb102-3" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb102-4"><a href="#cb102-4" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb102-5"><a href="#cb102-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_1_update<span class="op">(</span></span>
<span id="cb102-6"><a href="#cb102-6" aria-hidden="true" tabindex="-1"></a>  Scalar alpha,</span>
<span id="cb102-7"><a href="#cb102-7" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb102-8"><a href="#cb102-8" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb102-9"><a href="#cb102-9" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb102-10"><a href="#cb102-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb102-11"><a href="#cb102-11" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb102-12"><a href="#cb102-12" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar,</span>
<span id="cb102-13"><a href="#cb102-13" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb102-14"><a href="#cb102-14" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb102-15"><a href="#cb102-15" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb102-16"><a href="#cb102-16" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_1_update<span class="op">(</span></span>
<span id="cb102-17"><a href="#cb102-17" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb102-18"><a href="#cb102-18" aria-hidden="true" tabindex="-1"></a>  Scalar alpha,</span>
<span id="cb102-19"><a href="#cb102-19" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb102-20"><a href="#cb102-20" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb102-21"><a href="#cb102-21" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
These functions perform a symmetric rank-1 update of the symmetric
matrix <code>A</code>, taking into account the <code>Triangle</code>
parameter that applies to <code>A</code> [linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">8</a></span>
<em>Effects:</em> Computes a matrix <span class="math inline"><em>A</em>′</span> such that <span class="math inline"><em>A</em>′ = <em>A</em> + <em>α</em><em>x</em><em>x</em><sup><em>T</em></sup></span>,
where the scalar <span class="math inline"><em>α</em></span> is
<code>alpha</code>, and assigns each element of <span class="math inline"><em>A</em>′</span> to the corresponding element of
<span class="math inline"><em>A</em></span>.</p>
<div class="sourceCode" id="cb103"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb103-1"><a href="#cb103-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec,</span>
<span id="cb103-2"><a href="#cb103-2" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb103-3"><a href="#cb103-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb103-4"><a href="#cb103-4" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_1_update<span class="op">(</span></span>
<span id="cb103-5"><a href="#cb103-5" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb103-6"><a href="#cb103-6" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb103-7"><a href="#cb103-7" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb103-8"><a href="#cb103-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb103-9"><a href="#cb103-9" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb103-10"><a href="#cb103-10" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb103-11"><a href="#cb103-11" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb103-12"><a href="#cb103-12" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb103-13"><a href="#cb103-13" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_1_update<span class="op">(</span></span>
<span id="cb103-14"><a href="#cb103-14" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb103-15"><a href="#cb103-15" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb103-16"><a href="#cb103-16" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb103-17"><a href="#cb103-17" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">9</a></span>
These functions perform a Hermitian rank-1 update of the Hermitian
matrix <code>A</code>, taking into account the <code>Triangle</code>
parameter that applies to <code>A</code> [linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">10</a></span>
<em>Effects:</em> Computes a matrix <span class="math inline"><em>A</em>′</span> such that <span class="math inline"><em>A</em>′ = <em>A</em> + <em>x</em><em>x</em><sup><em>H</em></sup></span>
and assigns each element of <span class="math inline"><em>A</em>′</span>
to the corresponding element of <span class="math inline"><em>A</em></span>.</p>
<div class="sourceCode" id="cb104"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb104-1"><a href="#cb104-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Scalar,</span>
<span id="cb104-2"><a href="#cb104-2" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb104-3"><a href="#cb104-3" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb104-4"><a href="#cb104-4" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb104-5"><a href="#cb104-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_1_update<span class="op">(</span></span>
<span id="cb104-6"><a href="#cb104-6" aria-hidden="true" tabindex="-1"></a>  Scalar alpha,</span>
<span id="cb104-7"><a href="#cb104-7" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb104-8"><a href="#cb104-8" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb104-9"><a href="#cb104-9" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb104-10"><a href="#cb104-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb104-11"><a href="#cb104-11" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb104-12"><a href="#cb104-12" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar,</span>
<span id="cb104-13"><a href="#cb104-13" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb104-14"><a href="#cb104-14" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb104-15"><a href="#cb104-15" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb104-16"><a href="#cb104-16" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_1_update<span class="op">(</span></span>
<span id="cb104-17"><a href="#cb104-17" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb104-18"><a href="#cb104-18" aria-hidden="true" tabindex="-1"></a>  Scalar alpha,</span>
<span id="cb104-19"><a href="#cb104-19" aria-hidden="true" tabindex="-1"></a>  InVec x,</span>
<span id="cb104-20"><a href="#cb104-20" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb104-21"><a href="#cb104-21" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">11</a></span> These
functions perform a Hermitian rank-1 update of the Hermitian matrix
<code>A</code>, taking into account the <code>Triangle</code> parameter
that applies to <code>A</code> [linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">12</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>A</em>′</span>
such that <span class="math inline"><em>A</em>′ = <em>A</em> + <em>α</em><em>x</em><em>x</em><sup><em>H</em></sup></span>,
where the scalar <span class="math inline"><em>α</em></span> is
<code>alpha</code>, and assigns each element of <span class="math inline"><em>A</em>′</span> to the corresponding element of
<span class="math inline"><em>A</em></span>.</p>
<h4 data-number="28.9.14.8" id="symmetric-and-hermitian-rank-2-matrix-updates-linalg.algs.blas2.rank2"><span class="header-section-number">28.9.14.8</span> Symmetric and Hermitian
rank-2 matrix updates [linalg.algs.blas2.rank2]<a href="#symmetric-and-hermitian-rank-2-matrix-updates-linalg.algs.blas2.rank2" class="self-link"></a></h4>
<p><i>[Note:</i> These functions correspond to the BLAS functions
<code>xSYR2</code>,<code>xSPR2</code>, <code>xHER2</code> and
<code>xHPR2</code>. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The following elements apply to all functions in
[linalg.algs.blas2.rank2].</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span> If
<code>InOutMat</code> has <code>layout_blas_packed</code> layout, then
the layout’s <code>Triangle</code> template argument has the same type
as the function’s <code>Triangle</code> template argument;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;decltype(A), decltype(A)&gt;(0, 1)</code>
is <code>true</code>; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.3)</a></span>
<em><code>possibly-multipliable</code></em><code>&lt;decltype(A), decltype(x), decltype(y)&gt;()</code>
is <code>true</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.1)</a></span>
<code>A.extent(0)</code> equals <code>A.extent(1)</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.2)</a></span>
<em><code>multipliable</code></em><code>(A,x,y)</code> is
<code>true</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>x.extent(0)</code> <span class="math inline">⋅</span>
<code>y.extent(0)</code> <span class="math inline">)</span></p>
<div class="sourceCode" id="cb105"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb105-1"><a href="#cb105-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec1,</span>
<span id="cb105-2"><a href="#cb105-2" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb105-3"><a href="#cb105-3" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb105-4"><a href="#cb105-4" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb105-5"><a href="#cb105-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_2_update<span class="op">(</span></span>
<span id="cb105-6"><a href="#cb105-6" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb105-7"><a href="#cb105-7" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb105-8"><a href="#cb105-8" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb105-9"><a href="#cb105-9" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb105-10"><a href="#cb105-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb105-11"><a href="#cb105-11" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb105-12"><a href="#cb105-12" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb105-13"><a href="#cb105-13" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb105-14"><a href="#cb105-14" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb105-15"><a href="#cb105-15" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb105-16"><a href="#cb105-16" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_2_update<span class="op">(</span></span>
<span id="cb105-17"><a href="#cb105-17" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb105-18"><a href="#cb105-18" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb105-19"><a href="#cb105-19" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb105-20"><a href="#cb105-20" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb105-21"><a href="#cb105-21" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
These functions perform a symmetric rank-2 update of the symmetric
matrix <code>A</code>, taking into account the <code>Triangle</code>
parameter that applies to <code>A</code> [linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>A</em>′</span>
such that <span class="math inline"><em>A</em>′ = <em>A</em> + <em>x</em><em>y</em><sup><em>T</em></sup> + <em>y</em><em>x</em><sup><em>T</em></sup></span>
and assigns each element of <span class="math inline"><em>A</em>′</span>
to the corresponding element of <span class="math inline"><em>A</em></span>.</p>
<div class="sourceCode" id="cb106"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb106-1"><a href="#cb106-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-vector</em> InVec1,</span>
<span id="cb106-2"><a href="#cb106-2" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb106-3"><a href="#cb106-3" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb106-4"><a href="#cb106-4" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb106-5"><a href="#cb106-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_2_update<span class="op">(</span></span>
<span id="cb106-6"><a href="#cb106-6" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb106-7"><a href="#cb106-7" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb106-8"><a href="#cb106-8" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb106-9"><a href="#cb106-9" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb106-10"><a href="#cb106-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb106-11"><a href="#cb106-11" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb106-12"><a href="#cb106-12" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec1,</span>
<span id="cb106-13"><a href="#cb106-13" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec2,</span>
<span id="cb106-14"><a href="#cb106-14" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb106-15"><a href="#cb106-15" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb106-16"><a href="#cb106-16" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_2_update<span class="op">(</span></span>
<span id="cb106-17"><a href="#cb106-17" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb106-18"><a href="#cb106-18" aria-hidden="true" tabindex="-1"></a>  InVec1 x,</span>
<span id="cb106-19"><a href="#cb106-19" aria-hidden="true" tabindex="-1"></a>  InVec2 y,</span>
<span id="cb106-20"><a href="#cb106-20" aria-hidden="true" tabindex="-1"></a>  InOutMat A,</span>
<span id="cb106-21"><a href="#cb106-21" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
These functions perform a Hermitian rank-2 update of the Hermitian
matrix <code>A</code>, taking into account the <code>Triangle</code>
parameter that applies to <code>A</code> [linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">8</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>A</em>′</span>
such that <span class="math inline"><em>A</em>′ = <em>A</em> + <em>x</em><em>y</em><sup><em>H</em></sup> + <em>y</em><em>x</em><sup><em>H</em></sup></span>
and assigns each element of <span class="math inline"><em>A</em>′</span>
to the corresponding element of <span class="math inline"><em>A</em></span>.</p>
<h3 data-number="28.9.15" id="blas-3-algorithms-linalg.algs.blas3"><span class="header-section-number">28.9.15</span> BLAS 3 algorithms
[linalg.algs.blas3]<a href="#blas-3-algorithms-linalg.algs.blas3" class="self-link"></a></h3>
<h4 data-number="28.9.15.1" id="general-matrix-matrix-product-linalg.algs.blas3.gemm"><span class="header-section-number">28.9.15.1</span> General matrix-matrix
product [linalg.algs.blas3.gemm]<a href="#general-matrix-matrix-product-linalg.algs.blas3.gemm" class="self-link"></a></h4>
<p><i>[Note:</i> These functions correspond to the BLAS function
<code>xGEMM</code>. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The following elements apply to all functions in
[linalg.algs.blas3.gemm] in addition to function-specific elements.</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em>
<em><code>possibly-multipliable</code></em><code>&lt;decltype(A), decltype(B), decltype(C)&gt;()</code>
is <code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em>
<em><code>multipliable</code></em><code>(A, B, C)</code> is
<code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>A.extent(0)</code> <span class="math inline">⋅</span>
<code>A.extent(1)</code> <span class="math inline">⋅</span>
<code>B.extent(1)</code> <span class="math inline">)</span></p>
<div class="sourceCode" id="cb107"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb107-1"><a href="#cb107-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb107-2"><a href="#cb107-2" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb107-3"><a href="#cb107-3" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb107-4"><a href="#cb107-4" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_product<span class="op">(</span>InMat1 A,</span>
<span id="cb107-5"><a href="#cb107-5" aria-hidden="true" tabindex="-1"></a>                    InMat2 B,</span>
<span id="cb107-6"><a href="#cb107-6" aria-hidden="true" tabindex="-1"></a>                    OutMat C<span class="op">)</span>;</span>
<span id="cb107-7"><a href="#cb107-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb107-8"><a href="#cb107-8" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb107-9"><a href="#cb107-9" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb107-10"><a href="#cb107-10" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb107-11"><a href="#cb107-11" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb107-12"><a href="#cb107-12" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_product<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb107-13"><a href="#cb107-13" aria-hidden="true" tabindex="-1"></a>                    InMat1 A,</span>
<span id="cb107-14"><a href="#cb107-14" aria-hidden="true" tabindex="-1"></a>                    InMat2 B,</span>
<span id="cb107-15"><a href="#cb107-15" aria-hidden="true" tabindex="-1"></a>                    OutMat C<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>C</em> = <em>A</em><em>B</em></span>.</p>
<div class="sourceCode" id="cb108"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb108-1"><a href="#cb108-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb108-2"><a href="#cb108-2" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb108-3"><a href="#cb108-3" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb108-4"><a href="#cb108-4" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb108-5"><a href="#cb108-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_product<span class="op">(</span>InMat1 A,</span>
<span id="cb108-6"><a href="#cb108-6" aria-hidden="true" tabindex="-1"></a>                    InMat2 B,</span>
<span id="cb108-7"><a href="#cb108-7" aria-hidden="true" tabindex="-1"></a>                    InMat3 E,</span>
<span id="cb108-8"><a href="#cb108-8" aria-hidden="true" tabindex="-1"></a>                    OutMat C<span class="op">)</span>;</span>
<span id="cb108-9"><a href="#cb108-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb108-10"><a href="#cb108-10" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb108-11"><a href="#cb108-11" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb108-12"><a href="#cb108-12" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb108-13"><a href="#cb108-13" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb108-14"><a href="#cb108-14" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb108-15"><a href="#cb108-15" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> matrix_product<span class="op">(</span>ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb108-16"><a href="#cb108-16" aria-hidden="true" tabindex="-1"></a>                    InMat1 A,</span>
<span id="cb108-17"><a href="#cb108-17" aria-hidden="true" tabindex="-1"></a>                    InMat2 B,</span>
<span id="cb108-18"><a href="#cb108-18" aria-hidden="true" tabindex="-1"></a>                    InMat3 E,</span>
<span id="cb108-19"><a href="#cb108-19" aria-hidden="true" tabindex="-1"></a>                    OutMat C<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Mandates:</em>
<em><code>possibly-addable</code></em><code>&lt;InMat3, InMat3, OutMat&gt;()</code>
is <code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
<em>Preconditions:</em>
<em><code>addable</code></em><code>(E, E, C)</code> is
<code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">8</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>C</em> = <em>E</em> + <em>A</em><em>B</em></span>.</p>
<p><span class="marginalizedparent"><a class="marginalized">9</a></span>
<em>Remarks:</em> <code>C</code> may alias <code>E</code>.</p>
<h4 data-number="28.9.15.2" id="symmetric-hermitian-and-triangular-matrix-matrix-product-linalg.algs.blas3.xxmm"><span class="header-section-number">28.9.15.2</span> Symmetric, Hermitian, and
triangular matrix-matrix product [linalg.algs.blas3.xxmm]<a href="#symmetric-hermitian-and-triangular-matrix-matrix-product-linalg.algs.blas3.xxmm" class="self-link"></a></h4>
<p><i>[Note:</i> These functions correspond to the BLAS functions
<code>xSYMM</code>, <code>xHEMM</code>, and <code>xTRMM</code>. <i>– end
note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The following elements apply to all functions in
[linalg.algs.blas3.xxmm] in addition to function-specific elements.</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span>
<em><code>possibly-multipliable</code></em><code>&lt;decltype(A), decltype(B), decltype(C)&gt;()</code>
is <code>true</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
<em><code>possibly-addable</code></em><code>&lt;decltype(E), decltype(E), decltype(C)&gt;()</code>
is <code>true</code> for those overloads that take an <code>E</code>
parameter.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.1)</a></span>
<em><code>multipliable</code></em><code>(A, B, C)</code> is
<code>true</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.2)</a></span>
<em><code>addable</code></em><code>(E, E, C)</code> is <code>true</code>
for those overloads that take an <code>E</code> parameter.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>A.extent(0)</code> <span class="math inline">⋅</span>
<code>A.extent(1)</code> <span class="math inline">⋅</span>
<code>B.extent(1)</code> <span class="math inline">)</span></p>
<div class="sourceCode" id="cb109"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb109-1"><a href="#cb109-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb109-2"><a href="#cb109-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb109-3"><a href="#cb109-3" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb109-4"><a href="#cb109-4" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb109-5"><a href="#cb109-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_product<span class="op">(</span></span>
<span id="cb109-6"><a href="#cb109-6" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb109-7"><a href="#cb109-7" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb109-8"><a href="#cb109-8" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb109-9"><a href="#cb109-9" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb109-10"><a href="#cb109-10" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb109-11"><a href="#cb109-11" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb109-12"><a href="#cb109-12" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb109-13"><a href="#cb109-13" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb109-14"><a href="#cb109-14" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb109-15"><a href="#cb109-15" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_product<span class="op">(</span></span>
<span id="cb109-16"><a href="#cb109-16" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb109-17"><a href="#cb109-17" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb109-18"><a href="#cb109-18" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb109-19"><a href="#cb109-19" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb109-20"><a href="#cb109-20" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb109-21"><a href="#cb109-21" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb109-22"><a href="#cb109-22" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb109-23"><a href="#cb109-23" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb109-24"><a href="#cb109-24" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb109-25"><a href="#cb109-25" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb109-26"><a href="#cb109-26" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_product<span class="op">(</span></span>
<span id="cb109-27"><a href="#cb109-27" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb109-28"><a href="#cb109-28" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb109-29"><a href="#cb109-29" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb109-30"><a href="#cb109-30" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb109-31"><a href="#cb109-31" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb109-32"><a href="#cb109-32" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb109-33"><a href="#cb109-33" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb109-34"><a href="#cb109-34" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb109-35"><a href="#cb109-35" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb109-36"><a href="#cb109-36" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_product<span class="op">(</span></span>
<span id="cb109-37"><a href="#cb109-37" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb109-38"><a href="#cb109-38" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb109-39"><a href="#cb109-39" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb109-40"><a href="#cb109-40" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb109-41"><a href="#cb109-41" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb109-42"><a href="#cb109-42" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb109-43"><a href="#cb109-43" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb109-44"><a href="#cb109-44" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb109-45"><a href="#cb109-45" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb109-46"><a href="#cb109-46" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb109-47"><a href="#cb109-47" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb109-48"><a href="#cb109-48" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_product<span class="op">(</span></span>
<span id="cb109-49"><a href="#cb109-49" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb109-50"><a href="#cb109-50" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb109-51"><a href="#cb109-51" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb109-52"><a href="#cb109-52" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb109-53"><a href="#cb109-53" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb109-54"><a href="#cb109-54" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb109-55"><a href="#cb109-55" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb109-56"><a href="#cb109-56" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb109-57"><a href="#cb109-57" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb109-58"><a href="#cb109-58" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb109-59"><a href="#cb109-59" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb109-60"><a href="#cb109-60" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_product<span class="op">(</span></span>
<span id="cb109-61"><a href="#cb109-61" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb109-62"><a href="#cb109-62" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb109-63"><a href="#cb109-63" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb109-64"><a href="#cb109-64" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb109-65"><a href="#cb109-65" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb109-66"><a href="#cb109-66" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
These functions perform a matrix-matrix multiply, taking into account
the <code>Triangle</code> and <code>DiagonalStorage</code> (if
applicable) parameters that apply to the symmetric, Hermitian, or
triangular (respectively) matrix <code>A</code> [linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(6.1)</a></span> If
<code>InMat1</code> has <code>layout_blas_packed</code> layout, then the
layout’s <code>Triangle</code> template argument has the same type as
the function’s <code>Triangle</code> template argument; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(6.2)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;InMat1,InMat1&gt;(0,1)</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
<em>Preconditions:</em> <code>A.extent(0) == A.extent(1)</code> is
<code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">8</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>C</em> = <em>A</em><em>B</em></span>.</p>
<div class="sourceCode" id="cb110"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb110-1"><a href="#cb110-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb110-2"><a href="#cb110-2" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb110-3"><a href="#cb110-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb110-4"><a href="#cb110-4" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb110-5"><a href="#cb110-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_product<span class="op">(</span></span>
<span id="cb110-6"><a href="#cb110-6" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb110-7"><a href="#cb110-7" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb110-8"><a href="#cb110-8" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb110-9"><a href="#cb110-9" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb110-10"><a href="#cb110-10" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb110-11"><a href="#cb110-11" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb110-12"><a href="#cb110-12" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb110-13"><a href="#cb110-13" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb110-14"><a href="#cb110-14" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb110-15"><a href="#cb110-15" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_product<span class="op">(</span></span>
<span id="cb110-16"><a href="#cb110-16" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb110-17"><a href="#cb110-17" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb110-18"><a href="#cb110-18" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb110-19"><a href="#cb110-19" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb110-20"><a href="#cb110-20" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb110-21"><a href="#cb110-21" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb110-22"><a href="#cb110-22" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb110-23"><a href="#cb110-23" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb110-24"><a href="#cb110-24" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb110-25"><a href="#cb110-25" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb110-26"><a href="#cb110-26" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_product<span class="op">(</span></span>
<span id="cb110-27"><a href="#cb110-27" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb110-28"><a href="#cb110-28" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb110-29"><a href="#cb110-29" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb110-30"><a href="#cb110-30" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb110-31"><a href="#cb110-31" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb110-32"><a href="#cb110-32" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb110-33"><a href="#cb110-33" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb110-34"><a href="#cb110-34" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb110-35"><a href="#cb110-35" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb110-36"><a href="#cb110-36" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_product<span class="op">(</span></span>
<span id="cb110-37"><a href="#cb110-37" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb110-38"><a href="#cb110-38" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb110-39"><a href="#cb110-39" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb110-40"><a href="#cb110-40" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb110-41"><a href="#cb110-41" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb110-42"><a href="#cb110-42" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb110-43"><a href="#cb110-43" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb110-44"><a href="#cb110-44" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb110-45"><a href="#cb110-45" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb110-46"><a href="#cb110-46" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb110-47"><a href="#cb110-47" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb110-48"><a href="#cb110-48" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_product<span class="op">(</span></span>
<span id="cb110-49"><a href="#cb110-49" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb110-50"><a href="#cb110-50" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb110-51"><a href="#cb110-51" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb110-52"><a href="#cb110-52" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb110-53"><a href="#cb110-53" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb110-54"><a href="#cb110-54" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb110-55"><a href="#cb110-55" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb110-56"><a href="#cb110-56" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb110-57"><a href="#cb110-57" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb110-58"><a href="#cb110-58" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb110-59"><a href="#cb110-59" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb110-60"><a href="#cb110-60" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_product<span class="op">(</span></span>
<span id="cb110-61"><a href="#cb110-61" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb110-62"><a href="#cb110-62" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb110-63"><a href="#cb110-63" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb110-64"><a href="#cb110-64" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb110-65"><a href="#cb110-65" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb110-66"><a href="#cb110-66" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">9</a></span>
These functions perform a matrix-matrix multiply, taking into account
the <code>Triangle</code> and <code>DiagonalStorage</code> (if
applicable) parameters that apply to the symmetric, Hermitian, or
triangular (respectively) matrix <code>B</code> [linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">10</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(10.1)</a></span> If
<code>InMat2</code> has <code>layout_blas_packed</code> layout, then the
layout’s <code>Triangle</code> template argument has the same type as
the function’s <code>Triangle</code> template argument; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(10.2)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;InMat2,InMat2&gt;(0,1)</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">11</a></span>
<em>Preconditions:</em> <code>B.extent(0) == B.extent(1)</code> is
<code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">12</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>C</em> = <em>A</em><em>B</em></span>.</p>
<div class="sourceCode" id="cb111"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb111-1"><a href="#cb111-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb111-2"><a href="#cb111-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb111-3"><a href="#cb111-3" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb111-4"><a href="#cb111-4" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb111-5"><a href="#cb111-5" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb111-6"><a href="#cb111-6" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_product<span class="op">(</span></span>
<span id="cb111-7"><a href="#cb111-7" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb111-8"><a href="#cb111-8" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb111-9"><a href="#cb111-9" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb111-10"><a href="#cb111-10" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb111-11"><a href="#cb111-11" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb111-12"><a href="#cb111-12" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb111-13"><a href="#cb111-13" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb111-14"><a href="#cb111-14" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb111-15"><a href="#cb111-15" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb111-16"><a href="#cb111-16" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb111-17"><a href="#cb111-17" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb111-18"><a href="#cb111-18" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_product<span class="op">(</span></span>
<span id="cb111-19"><a href="#cb111-19" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb111-20"><a href="#cb111-20" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb111-21"><a href="#cb111-21" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb111-22"><a href="#cb111-22" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb111-23"><a href="#cb111-23" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb111-24"><a href="#cb111-24" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb111-25"><a href="#cb111-25" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb111-26"><a href="#cb111-26" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb111-27"><a href="#cb111-27" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb111-28"><a href="#cb111-28" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb111-29"><a href="#cb111-29" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb111-30"><a href="#cb111-30" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb111-31"><a href="#cb111-31" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_product<span class="op">(</span></span>
<span id="cb111-32"><a href="#cb111-32" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb111-33"><a href="#cb111-33" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb111-34"><a href="#cb111-34" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb111-35"><a href="#cb111-35" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb111-36"><a href="#cb111-36" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb111-37"><a href="#cb111-37" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb111-38"><a href="#cb111-38" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb111-39"><a href="#cb111-39" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb111-40"><a href="#cb111-40" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb111-41"><a href="#cb111-41" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb111-42"><a href="#cb111-42" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb111-43"><a href="#cb111-43" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_product<span class="op">(</span></span>
<span id="cb111-44"><a href="#cb111-44" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb111-45"><a href="#cb111-45" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb111-46"><a href="#cb111-46" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb111-47"><a href="#cb111-47" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb111-48"><a href="#cb111-48" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb111-49"><a href="#cb111-49" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb111-50"><a href="#cb111-50" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb111-51"><a href="#cb111-51" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb111-52"><a href="#cb111-52" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb111-53"><a href="#cb111-53" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb111-54"><a href="#cb111-54" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb111-55"><a href="#cb111-55" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb111-56"><a href="#cb111-56" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb111-57"><a href="#cb111-57" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_product<span class="op">(</span></span>
<span id="cb111-58"><a href="#cb111-58" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb111-59"><a href="#cb111-59" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb111-60"><a href="#cb111-60" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb111-61"><a href="#cb111-61" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb111-62"><a href="#cb111-62" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb111-63"><a href="#cb111-63" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb111-64"><a href="#cb111-64" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb111-65"><a href="#cb111-65" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb111-66"><a href="#cb111-66" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb111-67"><a href="#cb111-67" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb111-68"><a href="#cb111-68" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb111-69"><a href="#cb111-69" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb111-70"><a href="#cb111-70" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb111-71"><a href="#cb111-71" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_product<span class="op">(</span></span>
<span id="cb111-72"><a href="#cb111-72" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb111-73"><a href="#cb111-73" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb111-74"><a href="#cb111-74" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb111-75"><a href="#cb111-75" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb111-76"><a href="#cb111-76" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb111-77"><a href="#cb111-77" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb111-78"><a href="#cb111-78" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">13</a></span> These
functions perform a potentially overwriting matrix-matrix multiply-add,
taking into account the <code>Triangle</code> and
<code>DiagonalStorage</code> (if applicable) parameters that apply to
the symmetric, Hermitian, or triangular (respectively) matrix
<code>A</code> [linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">14</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(14.1)</a></span> If
<code>InMat1</code> has <code>layout_blas_packed</code> layout, then the
layout’s <code>Triangle</code> template argument has the same type as
the function’s <code>Triangle</code> template argument; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(14.2)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;InMat1,InMat1&gt;(0,1)</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">15</a></span>
<em>Preconditions:</em> <code>A.extent(0) == A.extent(1)</code> is
<code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">16</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>C</em> = <em>E</em> + <em>A</em><em>B</em></span>.</p>
<p><span class="marginalizedparent"><a class="marginalized">17</a></span>
<em>Remarks:</em> <code>C</code> may alias <code>E</code>.</p>
<div class="sourceCode" id="cb112"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb112-1"><a href="#cb112-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb112-2"><a href="#cb112-2" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb112-3"><a href="#cb112-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb112-4"><a href="#cb112-4" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb112-5"><a href="#cb112-5" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb112-6"><a href="#cb112-6" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_product<span class="op">(</span></span>
<span id="cb112-7"><a href="#cb112-7" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb112-8"><a href="#cb112-8" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb112-9"><a href="#cb112-9" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb112-10"><a href="#cb112-10" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb112-11"><a href="#cb112-11" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb112-12"><a href="#cb112-12" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb112-13"><a href="#cb112-13" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb112-14"><a href="#cb112-14" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb112-15"><a href="#cb112-15" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb112-16"><a href="#cb112-16" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb112-17"><a href="#cb112-17" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb112-18"><a href="#cb112-18" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_product<span class="op">(</span></span>
<span id="cb112-19"><a href="#cb112-19" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb112-20"><a href="#cb112-20" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb112-21"><a href="#cb112-21" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb112-22"><a href="#cb112-22" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb112-23"><a href="#cb112-23" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb112-24"><a href="#cb112-24" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb112-25"><a href="#cb112-25" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb112-26"><a href="#cb112-26" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb112-27"><a href="#cb112-27" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb112-28"><a href="#cb112-28" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb112-29"><a href="#cb112-29" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb112-30"><a href="#cb112-30" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb112-31"><a href="#cb112-31" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_product<span class="op">(</span></span>
<span id="cb112-32"><a href="#cb112-32" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb112-33"><a href="#cb112-33" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb112-34"><a href="#cb112-34" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb112-35"><a href="#cb112-35" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb112-36"><a href="#cb112-36" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb112-37"><a href="#cb112-37" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb112-38"><a href="#cb112-38" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb112-39"><a href="#cb112-39" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb112-40"><a href="#cb112-40" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb112-41"><a href="#cb112-41" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb112-42"><a href="#cb112-42" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb112-43"><a href="#cb112-43" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_product<span class="op">(</span></span>
<span id="cb112-44"><a href="#cb112-44" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb112-45"><a href="#cb112-45" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb112-46"><a href="#cb112-46" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb112-47"><a href="#cb112-47" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb112-48"><a href="#cb112-48" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb112-49"><a href="#cb112-49" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb112-50"><a href="#cb112-50" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb112-51"><a href="#cb112-51" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb112-52"><a href="#cb112-52" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb112-53"><a href="#cb112-53" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb112-54"><a href="#cb112-54" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb112-55"><a href="#cb112-55" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb112-56"><a href="#cb112-56" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb112-57"><a href="#cb112-57" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_product<span class="op">(</span></span>
<span id="cb112-58"><a href="#cb112-58" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb112-59"><a href="#cb112-59" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb112-60"><a href="#cb112-60" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb112-61"><a href="#cb112-61" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb112-62"><a href="#cb112-62" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb112-63"><a href="#cb112-63" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span>
<span id="cb112-64"><a href="#cb112-64" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb112-65"><a href="#cb112-65" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb112-66"><a href="#cb112-66" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb112-67"><a href="#cb112-67" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb112-68"><a href="#cb112-68" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb112-69"><a href="#cb112-69" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat3,</span>
<span id="cb112-70"><a href="#cb112-70" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb112-71"><a href="#cb112-71" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_product<span class="op">(</span></span>
<span id="cb112-72"><a href="#cb112-72" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb112-73"><a href="#cb112-73" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb112-74"><a href="#cb112-74" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb112-75"><a href="#cb112-75" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb112-76"><a href="#cb112-76" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb112-77"><a href="#cb112-77" aria-hidden="true" tabindex="-1"></a>  InMat3 E,</span>
<span id="cb112-78"><a href="#cb112-78" aria-hidden="true" tabindex="-1"></a>  OutMat C<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">18</a></span> These
functions perform a potentially overwriting matrix-matrix multiply-add,
taking into account the <code>Triangle</code> and
<code>DiagonalStorage</code> (if applicable) parameters that apply to
the symmetric, Hermitian, or triangular (respectively) matrix
<code>B</code> [linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">19</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(19.1)</a></span> If
<code>InMat2</code> has <code>layout_blas_packed</code> layout, then the
layout’s <code>Triangle</code> template argument has the same type as
the function’s <code>Triangle</code> template argument; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(19.2)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;InMat2,InMat2&gt;(0,1)</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">20</a></span>
<em>Preconditions:</em> <code>B.extent(0) == B.extent(1)</code> is
<code>true</code>.</p>
<p><span class="marginalizedparent"><a class="marginalized">21</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>C</em> = <em>E</em> + <em>A</em><em>B</em></span>.</p>
<p><span class="marginalizedparent"><a class="marginalized">22</a></span>
<em>Remarks:</em> <code>C</code> may alias <code>E</code>.</p>
<h4 data-number="28.9.15.3" id="in-place-triangular-matrix-matrix-product-linalg.algs.blas3.trmm"><span class="header-section-number">28.9.15.3</span> In-place triangular
matrix-matrix product [linalg.algs.blas3.trmm]<a href="#in-place-triangular-matrix-matrix-product-linalg.algs.blas3.trmm" class="self-link"></a></h4>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
These functions perform an in-place matrix-matrix multiply, taking into
account the <code>Triangle</code> and <code>DiagonalStorage</code>
parameters that apply to the triangular matrix <code>A</code>
[linalg.general].</p>
<p><i>[Note:</i> These functions correspond to the BLAS function
<code>xTRMM</code>. <i>– end note]</i></p>
<div class="sourceCode" id="cb113"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb113-1"><a href="#cb113-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb113-2"><a href="#cb113-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb113-3"><a href="#cb113-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb113-4"><a href="#cb113-4" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb113-5"><a href="#cb113-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_left_product<span class="op">(</span></span>
<span id="cb113-6"><a href="#cb113-6" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb113-7"><a href="#cb113-7" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb113-8"><a href="#cb113-8" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb113-9"><a href="#cb113-9" aria-hidden="true" tabindex="-1"></a>  InOutMat C<span class="op">)</span>;</span>
<span id="cb113-10"><a href="#cb113-10" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb113-11"><a href="#cb113-11" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb113-12"><a href="#cb113-12" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb113-13"><a href="#cb113-13" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb113-14"><a href="#cb113-14" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb113-15"><a href="#cb113-15" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_left_product<span class="op">(</span></span>
<span id="cb113-16"><a href="#cb113-16" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb113-17"><a href="#cb113-17" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb113-18"><a href="#cb113-18" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb113-19"><a href="#cb113-19" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb113-20"><a href="#cb113-20" aria-hidden="true" tabindex="-1"></a>  InOutMat C<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span> If
<code>InMat</code> has <code>layout_blas_packed</code> layout, then the
layout’s <code>Triangle</code> template argument has the same type as
the function’s <code>Triangle</code> template argument;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
<em><code>possibly-multipliable</code></em><code>&lt;InMat, InOutMat, InOutMat&gt;()</code>
is <code>true</code>; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.3)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;InMat,InMat&gt;(0,1)</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.1)</a></span>
<em><code>multipliable</code></em><code>(A, C, C)</code> is
<code>true</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.2)</a></span>
<code>A.extent(0) == A.extent(1)</code> is <code>true</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Effects:</em> Computes a matrix <span class="math inline"><em>C</em>′</span> such that <span class="math inline"><em>C</em>′ = <em>A</em><em>C</em></span> and
assigns each element of <span class="math inline"><em>C</em>′</span> to
the corresponding element of <span class="math inline"><em>C</em></span>.</p>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>A.extent(0)</code> <span class="math inline">⋅</span>
<code>A.extent(1)</code> <span class="math inline">⋅</span>
<code>C.extent(0)</code> <span class="math inline">)</span></p>
<div class="sourceCode" id="cb114"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb114-1"><a href="#cb114-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb114-2"><a href="#cb114-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb114-3"><a href="#cb114-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb114-4"><a href="#cb114-4" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb114-5"><a href="#cb114-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_right_product<span class="op">(</span></span>
<span id="cb114-6"><a href="#cb114-6" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb114-7"><a href="#cb114-7" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb114-8"><a href="#cb114-8" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb114-9"><a href="#cb114-9" aria-hidden="true" tabindex="-1"></a>  InOutMat C<span class="op">)</span>;</span>
<span id="cb114-10"><a href="#cb114-10" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb114-11"><a href="#cb114-11" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb114-12"><a href="#cb114-12" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb114-13"><a href="#cb114-13" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb114-14"><a href="#cb114-14" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb114-15"><a href="#cb114-15" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_right_product<span class="op">(</span></span>
<span id="cb114-16"><a href="#cb114-16" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb114-17"><a href="#cb114-17" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb114-18"><a href="#cb114-18" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb114-19"><a href="#cb114-19" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb114-20"><a href="#cb114-20" aria-hidden="true" tabindex="-1"></a>  InOutMat C<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(6.1)</a></span> If
<code>InMat</code> has <code>layout_blas_packed</code> layout, then the
layout’s <code>Triangle</code> template argument has the same type as
the function’s <code>Triangle</code> template argument;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(6.2)</a></span>
<em><code>possibly-multipliable</code></em><code>&lt;InOutMat, InMat, InOutMat&gt;()</code>
is <code>true</code>; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(6.3)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;InMat, InMat&gt;(0,1)</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(7.1)</a></span>
<em><code>multipliable</code></em><code>(C, A, C)</code> is
<code>true</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(7.2)</a></span>
<code>A.extent(0) == A.extent(1)</code> is <code>true</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">8</a></span>
<em>Effects:</em> Computes a matrix <span class="math inline"><em>C</em>′</span> such that <span class="math inline"><em>C</em>′ = <em>C</em><em>A</em></span> and
assigns each element of <span class="math inline"><em>C</em>′</span> to
the corresponding element of <span class="math inline"><em>C</em></span>.</p>
<p><span class="marginalizedparent"><a class="marginalized">9</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>A.extent(0)</code> <span class="math inline">⋅</span>
<code>A.extent(1)</code> <span class="math inline">⋅</span>
<code>C.extent(0)</code> <span class="math inline">)</span></p>
<h4 data-number="28.9.15.4" id="rank-k-update-of-a-symmetric-or-hermitian-matrix-linalg.algs.blas3.rankk"><span class="header-section-number">28.9.15.4</span> Rank-k update of a
symmetric or Hermitian matrix [linalg.algs.blas3.rankk]<a href="#rank-k-update-of-a-symmetric-or-hermitian-matrix-linalg.algs.blas3.rankk" class="self-link"></a></h4>
<p><i>[Note:</i> These functions correspond to the BLAS functions
<code>xSYRK</code> and <code>xHERK</code>. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The following elements apply to all functions in
[linalg.algs.blas3.rankk].</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span> If
<code>InOutMat</code> has <code>layout_blas_packed</code> layout, then
the layout’s <code>Triangle</code> template argument has the same type
as the function’s <code>Triangle</code> template argument;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;decltype(A), decltype(A)&gt;(0, 1)</code>
is <code>true</code>;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.3)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;decltype(C), decltype(C)&gt;(0, 1)</code>
is <code>true</code>; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.4)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;decltype(A), decltype(C)&gt;(0, 0)</code>
is <code>true</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.1)</a></span>
<code>A.extent(0)</code> equals <code>A.extent(1)</code>,</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.2)</a></span>
<code>C.extent(0)</code> equals <code>C.extent(1)</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.3)</a></span>
<code>A.extent(0)</code> equals <code>C.extent(0)</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>A.extent(0)</code> <span class="math inline">⋅</span>
<code>A.extent(1)</code> <span class="math inline">⋅</span>
<code>C.extent(0)</code> <span class="math inline">)</span></p>
<div class="sourceCode" id="cb115"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb115-1"><a href="#cb115-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Scalar,</span>
<span id="cb115-2"><a href="#cb115-2" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb115-3"><a href="#cb115-3" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb115-4"><a href="#cb115-4" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb115-5"><a href="#cb115-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_k_update<span class="op">(</span></span>
<span id="cb115-6"><a href="#cb115-6" aria-hidden="true" tabindex="-1"></a>  Scalar alpha,</span>
<span id="cb115-7"><a href="#cb115-7" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb115-8"><a href="#cb115-8" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb115-9"><a href="#cb115-9" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb115-10"><a href="#cb115-10" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb115-11"><a href="#cb115-11" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar,</span>
<span id="cb115-12"><a href="#cb115-12" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb115-13"><a href="#cb115-13" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb115-14"><a href="#cb115-14" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb115-15"><a href="#cb115-15" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_k_update<span class="op">(</span></span>
<span id="cb115-16"><a href="#cb115-16" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb115-17"><a href="#cb115-17" aria-hidden="true" tabindex="-1"></a>  Scalar alpha,</span>
<span id="cb115-18"><a href="#cb115-18" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb115-19"><a href="#cb115-19" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb115-20"><a href="#cb115-20" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
<em>Effects:</em> Computes a matrix <span class="math inline"><em>C</em>′</span> such that <span class="math inline"><em>C</em>′ = <em>C</em> + <em>α</em><em>A</em><em>A</em><sup><em>T</em></sup></span>,
where the scalar <span class="math inline"><em>α</em></span> is
<code>alpha</code>, and assigns each element of <span class="math inline"><em>C</em>′</span> to the corresponding element of
<span class="math inline"><em>C</em></span>.</p>
<div class="sourceCode" id="cb116"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb116-1"><a href="#cb116-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb116-2"><a href="#cb116-2" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb116-3"><a href="#cb116-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb116-4"><a href="#cb116-4" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_k_update<span class="op">(</span></span>
<span id="cb116-5"><a href="#cb116-5" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb116-6"><a href="#cb116-6" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb116-7"><a href="#cb116-7" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb116-8"><a href="#cb116-8" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb116-9"><a href="#cb116-9" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb116-10"><a href="#cb116-10" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb116-11"><a href="#cb116-11" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb116-12"><a href="#cb116-12" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_k_update<span class="op">(</span></span>
<span id="cb116-13"><a href="#cb116-13" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb116-14"><a href="#cb116-14" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb116-15"><a href="#cb116-15" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb116-16"><a href="#cb116-16" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Effects:</em> Computes a matrix <span class="math inline"><em>C</em>′</span> such that <span class="math inline"><em>C</em>′ = <em>C</em> + <em>A</em><em>A</em><sup><em>T</em></sup></span>,
and assigns each element of <span class="math inline"><em>C</em>′</span>
to the corresponding element of <span class="math inline"><em>C</em></span>.</p>
<div class="sourceCode" id="cb117"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb117-1"><a href="#cb117-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> Scalar,</span>
<span id="cb117-2"><a href="#cb117-2" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb117-3"><a href="#cb117-3" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb117-4"><a href="#cb117-4" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb117-5"><a href="#cb117-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_k_update<span class="op">(</span></span>
<span id="cb117-6"><a href="#cb117-6" aria-hidden="true" tabindex="-1"></a>  Scalar alpha,</span>
<span id="cb117-7"><a href="#cb117-7" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb117-8"><a href="#cb117-8" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb117-9"><a href="#cb117-9" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb117-10"><a href="#cb117-10" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb117-11"><a href="#cb117-11" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Scalar,</span>
<span id="cb117-12"><a href="#cb117-12" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb117-13"><a href="#cb117-13" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb117-14"><a href="#cb117-14" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb117-15"><a href="#cb117-15" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_k_update<span class="op">(</span></span>
<span id="cb117-16"><a href="#cb117-16" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb117-17"><a href="#cb117-17" aria-hidden="true" tabindex="-1"></a>  Scalar alpha,</span>
<span id="cb117-18"><a href="#cb117-18" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb117-19"><a href="#cb117-19" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb117-20"><a href="#cb117-20" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
<em>Effects:</em> Computes a matrix <span class="math inline"><em>C</em>′</span> such that <span class="math inline"><em>C</em>′ = <em>C</em> + <em>A</em><em>A</em><sup><em>H</em></sup></span>,
where the scalar <span class="math inline"><em>α</em></span> is
<code>alpha</code>, and assigns each element of <span class="math inline"><em>C</em>′</span> to the corresponding element of
<span class="math inline"><em>C</em></span>.</p>
<div class="sourceCode" id="cb118"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb118-1"><a href="#cb118-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb118-2"><a href="#cb118-2" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb118-3"><a href="#cb118-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb118-4"><a href="#cb118-4" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_k_update<span class="op">(</span></span>
<span id="cb118-5"><a href="#cb118-5" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb118-6"><a href="#cb118-6" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb118-7"><a href="#cb118-7" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb118-8"><a href="#cb118-8" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb118-9"><a href="#cb118-9" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb118-10"><a href="#cb118-10" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb118-11"><a href="#cb118-11" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb118-12"><a href="#cb118-12" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_k_update<span class="op">(</span></span>
<span id="cb118-13"><a href="#cb118-13" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb118-14"><a href="#cb118-14" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb118-15"><a href="#cb118-15" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb118-16"><a href="#cb118-16" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">8</a></span>
<em>Effects:</em> Computes a matrix <span class="math inline"><em>C</em>′</span> such that <span class="math inline"><em>C</em>′ = <em>C</em> + <em>A</em><em>A</em><sup><em>H</em></sup></span>,
and assigns each element of <span class="math inline"><em>C</em>′</span>
to the corresponding element of <span class="math inline"><em>C</em></span>.</p>
<h4 data-number="28.9.15.5" id="rank-2k-update-of-a-symmetric-or-hermitian-matrix-linalg.algs.blas3.rank2k"><span class="header-section-number">28.9.15.5</span> Rank-2k update of a
symmetric or Hermitian matrix [linalg.algs.blas3.rank2k]<a href="#rank-2k-update-of-a-symmetric-or-hermitian-matrix-linalg.algs.blas3.rank2k" class="self-link"></a></h4>
<p><i>[Note:</i> These functions correspond to the BLAS functions
<code>xSYR2K</code> and <code>xHER2K</code>. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
The following elements apply to all functions in
[linalg.algs.blas3.rank2k].</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span> If
<code>InOutMat</code> has <code>layout_blas_packed</code> layout, then
the layout’s <code>Triangle</code> template argument has the same type
as the function’s <code>Triangle</code> template argument;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
<em><code>possibly-addable</code></em><code>&lt;decltype(A), decltype(B), decltype(C)&gt;()</code>
is <code>true</code>; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.3)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;decltype(A), decltype(A)&gt;(0, 1)</code>
is <code>true</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.1)</a></span>
<em><code>addable</code></em><code>(A, B, C)</code> is
<code>true</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.2)</a></span>
<code>A.extent(0)</code> equals <code>A.extent(1)</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>A.extent(0)</code> <span class="math inline">⋅</span>
<code>A.extent(1)</code> <span class="math inline">⋅</span>
<code>C.extent(0)</code> <span class="math inline">)</span></p>
<div class="sourceCode" id="cb119"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb119-1"><a href="#cb119-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb119-2"><a href="#cb119-2" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb119-3"><a href="#cb119-3" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb119-4"><a href="#cb119-4" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb119-5"><a href="#cb119-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_2k_update<span class="op">(</span></span>
<span id="cb119-6"><a href="#cb119-6" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb119-7"><a href="#cb119-7" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb119-8"><a href="#cb119-8" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb119-9"><a href="#cb119-9" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb119-10"><a href="#cb119-10" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb119-11"><a href="#cb119-11" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb119-12"><a href="#cb119-12" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb119-13"><a href="#cb119-13" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb119-14"><a href="#cb119-14" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb119-15"><a href="#cb119-15" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> symmetric_matrix_rank_2k_update<span class="op">(</span></span>
<span id="cb119-16"><a href="#cb119-16" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb119-17"><a href="#cb119-17" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb119-18"><a href="#cb119-18" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb119-19"><a href="#cb119-19" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb119-20"><a href="#cb119-20" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
<em>Effects:</em> Computes a matrix <span class="math inline"><em>C</em>′</span> such that <span class="math inline"><em>C</em>′ = <em>C</em> + <em>A</em><em>B</em><sup><em>T</em></sup> + <em>B</em><em>A</em><sup><em>T</em></sup></span>,
and assigns each element of <span class="math inline"><em>C</em>′</span>
to the corresponding element of <span class="math inline"><em>C</em></span>.</p>
<div class="sourceCode" id="cb120"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb120-1"><a href="#cb120-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb120-2"><a href="#cb120-2" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb120-3"><a href="#cb120-3" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb120-4"><a href="#cb120-4" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb120-5"><a href="#cb120-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_2k_update<span class="op">(</span></span>
<span id="cb120-6"><a href="#cb120-6" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb120-7"><a href="#cb120-7" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb120-8"><a href="#cb120-8" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb120-9"><a href="#cb120-9" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span>
<span id="cb120-10"><a href="#cb120-10" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb120-11"><a href="#cb120-11" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb120-12"><a href="#cb120-12" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb120-13"><a href="#cb120-13" aria-hidden="true" tabindex="-1"></a>         <em>possibly-packed-inout-matrix</em> InOutMat,</span>
<span id="cb120-14"><a href="#cb120-14" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb120-15"><a href="#cb120-15" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> hermitian_matrix_rank_2k_update<span class="op">(</span></span>
<span id="cb120-16"><a href="#cb120-16" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb120-17"><a href="#cb120-17" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb120-18"><a href="#cb120-18" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb120-19"><a href="#cb120-19" aria-hidden="true" tabindex="-1"></a>  InOutMat C,</span>
<span id="cb120-20"><a href="#cb120-20" aria-hidden="true" tabindex="-1"></a>  Triangle t<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Effects:</em> Computes a matrix <span class="math inline"><em>C</em>′</span> such that <span class="math inline"><em>C</em>′ = <em>C</em> + <em>A</em><em>B</em><sup><em>T</em></sup> + <em>B</em><em>A</em><sup><em>T</em></sup></span>,
and assigns each element of <span class="math inline"><em>C</em>′</span>
to the corresponding element of <span class="math inline"><em>C</em></span>.</p>
<h4 data-number="28.9.15.6" id="solve-multiple-triangular-linear-systems-linalg.algs.blas3.trsm"><span class="header-section-number">28.9.15.6</span> Solve multiple triangular
linear systems [linalg.algs.blas3.trsm]<a href="#solve-multiple-triangular-linear-systems-linalg.algs.blas3.trsm" class="self-link"></a></h4>
<p><i>[Note:</i> These functions correspond to the BLAS function
<code>xTRSM</code>.
<!-- The Reference BLAS does not have a `xTPSM` function. --> <i>– end
note]</i></p>
<div class="sourceCode" id="cb121"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb121-1"><a href="#cb121-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb121-2"><a href="#cb121-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb121-3"><a href="#cb121-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb121-4"><a href="#cb121-4" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb121-5"><a href="#cb121-5" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat,</span>
<span id="cb121-6"><a href="#cb121-6" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb121-7"><a href="#cb121-7" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_left_solve<span class="op">(</span></span>
<span id="cb121-8"><a href="#cb121-8" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb121-9"><a href="#cb121-9" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb121-10"><a href="#cb121-10" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb121-11"><a href="#cb121-11" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb121-12"><a href="#cb121-12" aria-hidden="true" tabindex="-1"></a>  OutMat X,</span>
<span id="cb121-13"><a href="#cb121-13" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span>
<span id="cb121-14"><a href="#cb121-14" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb121-15"><a href="#cb121-15" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb121-16"><a href="#cb121-16" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb121-17"><a href="#cb121-17" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb121-18"><a href="#cb121-18" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb121-19"><a href="#cb121-19" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat,</span>
<span id="cb121-20"><a href="#cb121-20" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb121-21"><a href="#cb121-21" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_left_solve<span class="op">(</span></span>
<span id="cb121-22"><a href="#cb121-22" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb121-23"><a href="#cb121-23" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb121-24"><a href="#cb121-24" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb121-25"><a href="#cb121-25" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb121-26"><a href="#cb121-26" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb121-27"><a href="#cb121-27" aria-hidden="true" tabindex="-1"></a>  OutMat X,</span>
<span id="cb121-28"><a href="#cb121-28" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
These functions perform multiple matrix solves, taking into account the
<code>Triangle</code> and <code>DiagonalStorage</code> parameters that
apply to the triangular matrix <code>A</code> [linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span> If
<code>InMat1</code> has <code>layout_blas_packed</code> layout, then the
layout’s <code>Triangle</code> template argument has the same type as
the function’s <code>Triangle</code> template argument;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
<em><code>possibly-multipliable</code></em><code>&lt;InMat1, OutMat, InMat2&gt;()</code>
is <code>true</code>; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.3)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;InMat1, InMat1&gt;(0,1)</code>
is <code>true</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.1)</a></span>
<em><code>multipliable</code></em><code>(A,X,B)</code> is
<code>true</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.2)</a></span>
<code>A.extent(0) == A.extent(1)</code> is <code>true</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>X</em>′</span>
such that <span class="math inline"><em>A</em><em>X</em>′ = <em>B</em></span>, and
assigns each element of <span class="math inline"><em>X</em>′</span> to
the corresponding element of <span class="math inline"><em>X</em></span>. If no such <span class="math inline"><em>X</em>′</span> exists, then the elements of
<code>X</code> are valid but unspecified.</p>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>A.extent(0)</code> <span class="math inline">⋅</span>
<code>X.extent(1)</code> <span class="math inline">⋅</span>
<code>X.extent(1)</code> <span class="math inline">)</span></p>
<p><i>[Note:</i> Since the triangular matrix is on the left, the desired
<code>divide</code> implementation in the case of noncommutative
multiplication would be mathematically equivalent to <span class="math inline"><em>y</em><sup>−1</sup><em>x</em></span>, where
<span class="math inline"><em>x</em></span> is the first argument and
<span class="math inline"><em>y</em></span> is the second argument, and
<span class="math inline"><em>y</em><sup>−1</sup></span> denotes the
multiplicative inverse of <span class="math inline"><em>y</em></span>.
<i>– end note]</i></p>
<div class="sourceCode" id="cb122"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb122-1"><a href="#cb122-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb122-2"><a href="#cb122-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb122-3"><a href="#cb122-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb122-4"><a href="#cb122-4" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb122-5"><a href="#cb122-5" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb122-6"><a href="#cb122-6" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_left_solve<span class="op">(</span></span>
<span id="cb122-7"><a href="#cb122-7" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb122-8"><a href="#cb122-8" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb122-9"><a href="#cb122-9" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb122-10"><a href="#cb122-10" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb122-11"><a href="#cb122-11" aria-hidden="true" tabindex="-1"></a>  OutMat X<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Effects:</em> Equivalent to:</p>
<div class="sourceCode" id="cb123"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb123-1"><a href="#cb123-1" aria-hidden="true" tabindex="-1"></a>triangular_matrix_matrix_left_solve<span class="op">(</span>A, t, d, B, X, divides<span class="op">&lt;</span><span class="dt">void</span><span class="op">&gt;{})</span>;</span></code></pre></div>
<div class="sourceCode" id="cb124"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb124-1"><a href="#cb124-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb124-2"><a href="#cb124-2" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb124-3"><a href="#cb124-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb124-4"><a href="#cb124-4" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb124-5"><a href="#cb124-5" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb124-6"><a href="#cb124-6" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb124-7"><a href="#cb124-7" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_left_solve<span class="op">(</span></span>
<span id="cb124-8"><a href="#cb124-8" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb124-9"><a href="#cb124-9" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb124-10"><a href="#cb124-10" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb124-11"><a href="#cb124-11" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb124-12"><a href="#cb124-12" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb124-13"><a href="#cb124-13" aria-hidden="true" tabindex="-1"></a>  OutMat X<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
<em>Effects:</em> Equivalent to:</p>
<div class="sourceCode" id="cb125"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb125-1"><a href="#cb125-1" aria-hidden="true" tabindex="-1"></a>triangular_matrix_matrix_left_solve<span class="op">(</span>std<span class="op">::</span>forward<span class="op">&lt;</span>ExecutionPolicy<span class="op">&gt;(</span>exec<span class="op">)</span>,</span>
<span id="cb125-2"><a href="#cb125-2" aria-hidden="true" tabindex="-1"></a>  A, t, d, B, X, divides<span class="op">&lt;</span><span class="dt">void</span><span class="op">&gt;{})</span>;</span></code></pre></div>
<div class="sourceCode" id="cb126"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb126-1"><a href="#cb126-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb126-2"><a href="#cb126-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb126-3"><a href="#cb126-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb126-4"><a href="#cb126-4" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb126-5"><a href="#cb126-5" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat,</span>
<span id="cb126-6"><a href="#cb126-6" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb126-7"><a href="#cb126-7" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_right_solve<span class="op">(</span></span>
<span id="cb126-8"><a href="#cb126-8" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb126-9"><a href="#cb126-9" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb126-10"><a href="#cb126-10" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb126-11"><a href="#cb126-11" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb126-12"><a href="#cb126-12" aria-hidden="true" tabindex="-1"></a>  OutMat X,</span>
<span id="cb126-13"><a href="#cb126-13" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span>
<span id="cb126-14"><a href="#cb126-14" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb126-15"><a href="#cb126-15" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb126-16"><a href="#cb126-16" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb126-17"><a href="#cb126-17" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb126-18"><a href="#cb126-18" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb126-19"><a href="#cb126-19" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat,</span>
<span id="cb126-20"><a href="#cb126-20" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb126-21"><a href="#cb126-21" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_right_solve<span class="op">(</span></span>
<span id="cb126-22"><a href="#cb126-22" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb126-23"><a href="#cb126-23" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb126-24"><a href="#cb126-24" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb126-25"><a href="#cb126-25" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb126-26"><a href="#cb126-26" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb126-27"><a href="#cb126-27" aria-hidden="true" tabindex="-1"></a>  OutMat X,</span>
<span id="cb126-28"><a href="#cb126-28" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">8</a></span>
These functions perform multiple matrix solves, taking into account the
<code>Triangle</code> and <code>DiagonalStorage</code> parameters that
apply to the triangular matrix <code>A</code> [linalg.general].</p>
<p><span class="marginalizedparent"><a class="marginalized">9</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(9.1)</a></span> If
<code>InMat1</code> has <code>layout_blas_packed</code> layout, then the
layout’s <code>Triangle</code> template argument has the same type as
the function’s <code>Triangle</code> template argument;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(9.2)</a></span>
<em><code>possibly-multipliable</code></em><code>&lt;OutMat, InMat1, InMat2&gt;()</code>
is <code>true</code>; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(9.3)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;InMat1, InMat1&gt;(0,1)</code>
is <code>true</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">10</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(10.1)</a></span>
<em><code>multipliable</code></em><code>(X,A,B)</code> is
<code>true</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(10.2)</a></span>
<code>A.extent(0) == A.extent(1)</code> is <code>true</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">11</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>X</em>′</span>
such that <span class="math inline"><em>X</em>′<em>A</em> = <em>B</em></span>, and
assigns each element of <span class="math inline"><em>X</em>′</span> to
the corresponding element of <span class="math inline"><em>X</em></span>. If no such <span class="math inline"><em>X</em>′</span> exists, then the elements of
<code>X</code> are valid but unspecified.</p>
<p><span class="marginalizedparent"><a class="marginalized">12</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>B.extent(0)</code> <span class="math inline">⋅</span>
<code>B.extent(1)</code> <span class="math inline">⋅</span>
<code>A.extent(1)</code> <span class="math inline">)</span></p>
<p><i>[Note:</i> Since the triangular matrix is on the right, the
desired <code>divide</code> implementation in the case of noncommutative
multiplication would be mathematically equivalent to <span class="math inline"><em>x</em><em>y</em><sup>−1</sup></span>, where
<span class="math inline"><em>x</em></span> is the first argument and
<span class="math inline"><em>y</em></span> is the second argument, and
<span class="math inline"><em>y</em><sup>−1</sup></span> denotes the
multiplicative inverse of <span class="math inline"><em>y</em></span>.
<i>– end note]</i></p>
<div class="sourceCode" id="cb127"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb127-1"><a href="#cb127-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat1,</span>
<span id="cb127-2"><a href="#cb127-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb127-3"><a href="#cb127-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb127-4"><a href="#cb127-4" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb127-5"><a href="#cb127-5" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb127-6"><a href="#cb127-6" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_right_solve<span class="op">(</span></span>
<span id="cb127-7"><a href="#cb127-7" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb127-8"><a href="#cb127-8" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb127-9"><a href="#cb127-9" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb127-10"><a href="#cb127-10" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb127-11"><a href="#cb127-11" aria-hidden="true" tabindex="-1"></a>  OutMat X<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">13</a></span>
<em>Effects:</em> Equivalent to:</p>
<div class="sourceCode" id="cb128"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb128-1"><a href="#cb128-1" aria-hidden="true" tabindex="-1"></a>triangular_matrix_matrix_right_solve<span class="op">(</span>A, t, d, B, X, divides<span class="op">&lt;</span><span class="dt">void</span><span class="op">&gt;{})</span>;</span></code></pre></div>
<div class="sourceCode" id="cb129"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb129-1"><a href="#cb129-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb129-2"><a href="#cb129-2" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat1,</span>
<span id="cb129-3"><a href="#cb129-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb129-4"><a href="#cb129-4" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb129-5"><a href="#cb129-5" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat2,</span>
<span id="cb129-6"><a href="#cb129-6" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb129-7"><a href="#cb129-7" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_right_solve<span class="op">(</span></span>
<span id="cb129-8"><a href="#cb129-8" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb129-9"><a href="#cb129-9" aria-hidden="true" tabindex="-1"></a>  InMat1 A,</span>
<span id="cb129-10"><a href="#cb129-10" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb129-11"><a href="#cb129-11" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb129-12"><a href="#cb129-12" aria-hidden="true" tabindex="-1"></a>  InMat2 B,</span>
<span id="cb129-13"><a href="#cb129-13" aria-hidden="true" tabindex="-1"></a>  OutMat X<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">14</a></span>
<em>Effects:</em> Equivalent to:</p>
<div class="sourceCode" id="cb130"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb130-1"><a href="#cb130-1" aria-hidden="true" tabindex="-1"></a>triangular_matrix_matrix_right_solve<span class="op">(</span>std<span class="op">::</span>forward<span class="op">&lt;</span>ExecutionPolicy<span class="op">&gt;(</span>exec<span class="op">)</span>,</span>
<span id="cb130-2"><a href="#cb130-2" aria-hidden="true" tabindex="-1"></a>  A, t, d, B, X, divides<span class="op">&lt;</span><span class="dt">void</span><span class="op">&gt;{})</span>;</span></code></pre></div>
<h4 data-number="28.9.15.7" id="solve-multiple-triangular-linear-systems-in-place-linalg.algs.blas3.inplacetrsm"><span class="header-section-number">28.9.15.7</span> Solve multiple triangular
linear systems in-place [linalg.algs.blas3.inplacetrsm]<a href="#solve-multiple-triangular-linear-systems-in-place-linalg.algs.blas3.inplacetrsm" class="self-link"></a></h4>
<p><i>[Note:</i> These functions correspond to the BLAS function
<code>xTRSM</code>.
<!-- The Reference BLAS does not have a `xTPSM` function. --> <i>– end
note]</i></p>
<div class="sourceCode" id="cb131"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb131-1"><a href="#cb131-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb131-2"><a href="#cb131-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb131-3"><a href="#cb131-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb131-4"><a href="#cb131-4" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat,</span>
<span id="cb131-5"><a href="#cb131-5" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb131-6"><a href="#cb131-6" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_left_solve<span class="op">(</span></span>
<span id="cb131-7"><a href="#cb131-7" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb131-8"><a href="#cb131-8" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb131-9"><a href="#cb131-9" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb131-10"><a href="#cb131-10" aria-hidden="true" tabindex="-1"></a>  InOutMat B,</span>
<span id="cb131-11"><a href="#cb131-11" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span>
<span id="cb131-12"><a href="#cb131-12" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb131-13"><a href="#cb131-13" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb131-14"><a href="#cb131-14" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb131-15"><a href="#cb131-15" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb131-16"><a href="#cb131-16" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat,</span>
<span id="cb131-17"><a href="#cb131-17" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb131-18"><a href="#cb131-18" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_left_solve<span class="op">(</span></span>
<span id="cb131-19"><a href="#cb131-19" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb131-20"><a href="#cb131-20" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb131-21"><a href="#cb131-21" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb131-22"><a href="#cb131-22" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb131-23"><a href="#cb131-23" aria-hidden="true" tabindex="-1"></a>  InOutMat B,</span>
<span id="cb131-24"><a href="#cb131-24" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
These functions perform multiple in-place matrix solves, taking into
account the <code>Triangle</code> and <code>DiagonalStorage</code>
parameters that apply to the triangular matrix <code>A</code>
[linalg.general].</p>
<p><i>[Note:</i> This algorithm makes it possible to compute
factorizations like Cholesky and LU in place.</p>
<p>Performing triangular solve in place hinders parallelization.
However, other <code>ExecutionPolicy</code> specific optimizations, such
as vectorization, are still possible. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">2</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.1)</a></span> If
<code>InMat</code> has <code>layout_blas_packed</code> layout, then the
layout’s <code>Triangle</code> template argument has the same type as
the function’s <code>Triangle</code> template argument;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.2)</a></span>
<em><code>possibly-multipliable</code></em><code>&lt;InMat, InOutMat, InOutMat&gt;()</code>
is <code>true</code>; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(2.3)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;InMat, InMat&gt;(0,1)</code>
is <code>true</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">3</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.1)</a></span>
<em><code>multipliable</code></em><code>(A,B,B)</code> is
<code>true</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(3.2)</a></span>
<code>A.extent(0) == A.extent(1)</code> is <code>true</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">4</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>X</em>′</span>
such that <span class="math inline"><em>A</em><em>X</em>′ = <em>B</em></span>, and
assigns each element of <span class="math inline"><em>X</em>′</span> to
the corresponding element of <span class="math inline"><em>B</em></span>. If so such <span class="math inline"><em>X</em>′</span> exists, then the elements of
<code>B</code> are valid but unspecified.</p>
<p><span class="marginalizedparent"><a class="marginalized">5</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>A.extent(0)</code> <span class="math inline">⋅</span>
<code>A.extent(1)</code> <span class="math inline">⋅</span>
<code>B.extent(1)</code> <span class="math inline">)</span></p>
<div class="sourceCode" id="cb132"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb132-1"><a href="#cb132-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb132-2"><a href="#cb132-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb132-3"><a href="#cb132-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb132-4"><a href="#cb132-4" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb132-5"><a href="#cb132-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_left_solve<span class="op">(</span></span>
<span id="cb132-6"><a href="#cb132-6" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb132-7"><a href="#cb132-7" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb132-8"><a href="#cb132-8" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb132-9"><a href="#cb132-9" aria-hidden="true" tabindex="-1"></a>  InOutMat B<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">6</a></span>
<em>Effects:</em> Equivalent to:</p>
<div class="sourceCode" id="cb133"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb133-1"><a href="#cb133-1" aria-hidden="true" tabindex="-1"></a>triangular_matrix_matrix_left_solve<span class="op">(</span>A, t, d, B, divides<span class="op">&lt;</span><span class="dt">void</span><span class="op">&gt;{})</span>;</span></code></pre></div>
<div class="sourceCode" id="cb134"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb134-1"><a href="#cb134-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb134-2"><a href="#cb134-2" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb134-3"><a href="#cb134-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb134-4"><a href="#cb134-4" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb134-5"><a href="#cb134-5" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb134-6"><a href="#cb134-6" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_left_solve<span class="op">(</span></span>
<span id="cb134-7"><a href="#cb134-7" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb134-8"><a href="#cb134-8" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb134-9"><a href="#cb134-9" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb134-10"><a href="#cb134-10" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb134-11"><a href="#cb134-11" aria-hidden="true" tabindex="-1"></a>  InOutMat B<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">7</a></span>
<em>Effects:</em> Equivalent to:</p>
<div class="sourceCode" id="cb135"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb135-1"><a href="#cb135-1" aria-hidden="true" tabindex="-1"></a>triangular_matrix_matrix_left_solve<span class="op">(</span>std<span class="op">::</span>forward<span class="op">&lt;</span>ExecutionPolicy<span class="op">&gt;(</span>exec<span class="op">)</span>,</span>
<span id="cb135-2"><a href="#cb135-2" aria-hidden="true" tabindex="-1"></a>  A, t, d, B, divides<span class="op">&lt;</span><span class="dt">void</span><span class="op">&gt;{})</span>;</span></code></pre></div>
<div class="sourceCode" id="cb136"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb136-1"><a href="#cb136-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb136-2"><a href="#cb136-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb136-3"><a href="#cb136-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb136-4"><a href="#cb136-4" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat,</span>
<span id="cb136-5"><a href="#cb136-5" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb136-6"><a href="#cb136-6" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_right_solve<span class="op">(</span></span>
<span id="cb136-7"><a href="#cb136-7" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb136-8"><a href="#cb136-8" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb136-9"><a href="#cb136-9" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb136-10"><a href="#cb136-10" aria-hidden="true" tabindex="-1"></a>  InOutMat B,</span>
<span id="cb136-11"><a href="#cb136-11" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;</span>
<span id="cb136-12"><a href="#cb136-12" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb136-13"><a href="#cb136-13" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb136-14"><a href="#cb136-14" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb136-15"><a href="#cb136-15" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb136-16"><a href="#cb136-16" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat,</span>
<span id="cb136-17"><a href="#cb136-17" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> BinaryDivideOp<span class="op">&gt;</span></span>
<span id="cb136-18"><a href="#cb136-18" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_right_solve<span class="op">(</span></span>
<span id="cb136-19"><a href="#cb136-19" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb136-20"><a href="#cb136-20" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb136-21"><a href="#cb136-21" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb136-22"><a href="#cb136-22" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb136-23"><a href="#cb136-23" aria-hidden="true" tabindex="-1"></a>  InOutMat B,</span>
<span id="cb136-24"><a href="#cb136-24" aria-hidden="true" tabindex="-1"></a>  BinaryDivideOp divide<span class="op">)</span>;  </span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">8</a></span>
These functions perform multiple in-place matrix solves, taking into
account the <code>Triangle</code> and <code>DiagonalStorage</code>
parameters that apply to the triangular matrix <code>A</code>
[linalg.general].</p>
<p><i>[Note:</i> This algorithm makes it possible to compute
factorizations like Cholesky and LU in place.</p>
<p>Performing triangular solve in place hinders parallelization.
However, other <code>ExecutionPolicy</code> specific optimizations, such
as vectorization, are still possible. <i>– end note]</i></p>
<p><span class="marginalizedparent"><a class="marginalized">9</a></span>
<em>Mandates:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(9.1)</a></span> If
<code>InMat</code> has <code>layout_blas_packed</code> layout, then the
layout’s <code>Triangle</code> template argument has the same type as
the function’s <code>Triangle</code> template argument;</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(9.2)</a></span>
<em><code>possibly-multipliable</code></em><code>&lt;InOutMat, InMat, InOutMat&gt;()</code>
is <code>true</code>; and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(9.3)</a></span>
<em><code>compatible-static-extents</code></em><code>&lt;InMat, InMat&gt;(0,1)</code>
is <code>true</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">10</a></span>
<em>Preconditions:</em></p>
<ul>
<li><p><span class="marginalizedparent"><a class="marginalized">(10.1)</a></span>
<em><code>multipliable</code></em><code>(B,A,B)</code> is
<code>true</code>, and</p></li>
<li><p><span class="marginalizedparent"><a class="marginalized">(10.2)</a></span>
<code>A.extent(0) == A.extent(1)</code> is <code>true</code>.</p></li>
</ul>
<p><span class="marginalizedparent"><a class="marginalized">11</a></span>
<em>Effects:</em> Computes <span class="math inline"><em>X</em>′</span>
such that <span class="math inline"><em>X</em>′<em>A</em> = <em>B</em></span>, and
assigns each element of <span class="math inline"><em>X</em>′</span> to
the corresponding element of <span class="math inline"><em>B</em></span>. If so such <span class="math inline"><em>X</em>′</span> exists, then the elements of
<code>B</code> are valid but unspecified.</p>
<p><span class="marginalizedparent"><a class="marginalized">12</a></span>
<em>Complexity:</em> <span class="math inline"><em>O</em>(</span>
<code>A.extent(0)</code> <span class="math inline">⋅</span>
<code>A.extent(1)</code> <span class="math inline">⋅</span>
<code>B.extent(1)</code> <span class="math inline">)</span></p>
<div class="sourceCode" id="cb137"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb137-1"><a href="#cb137-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb137-2"><a href="#cb137-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb137-3"><a href="#cb137-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb137-4"><a href="#cb137-4" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb137-5"><a href="#cb137-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_right_solve<span class="op">(</span></span>
<span id="cb137-6"><a href="#cb137-6" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb137-7"><a href="#cb137-7" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb137-8"><a href="#cb137-8" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb137-9"><a href="#cb137-9" aria-hidden="true" tabindex="-1"></a>  InOutMat B<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">13</a></span>
<em>Effects:</em> Equivalent to:</p>
<div class="sourceCode" id="cb138"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb138-1"><a href="#cb138-1" aria-hidden="true" tabindex="-1"></a>triangular_matrix_matrix_right_solve<span class="op">(</span>A, t, d, B, divides<span class="op">&lt;</span><span class="dt">void</span><span class="op">&gt;{})</span>;</span></code></pre></div>
<div class="sourceCode" id="cb139"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb139-1"><a href="#cb139-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><span class="kw">class</span> ExecutionPolicy,</span>
<span id="cb139-2"><a href="#cb139-2" aria-hidden="true" tabindex="-1"></a>         <em>in-matrix</em> InMat,</span>
<span id="cb139-3"><a href="#cb139-3" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb139-4"><a href="#cb139-4" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> DiagonalStorage,</span>
<span id="cb139-5"><a href="#cb139-5" aria-hidden="true" tabindex="-1"></a>         <em>inout-matrix</em> InOutMat<span class="op">&gt;</span></span>
<span id="cb139-6"><a href="#cb139-6" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> triangular_matrix_matrix_right_solve<span class="op">(</span></span>
<span id="cb139-7"><a href="#cb139-7" aria-hidden="true" tabindex="-1"></a>  ExecutionPolicy<span class="op">&amp;&amp;</span> exec,</span>
<span id="cb139-8"><a href="#cb139-8" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb139-9"><a href="#cb139-9" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb139-10"><a href="#cb139-10" aria-hidden="true" tabindex="-1"></a>  DiagonalStorage d,</span>
<span id="cb139-11"><a href="#cb139-11" aria-hidden="true" tabindex="-1"></a>  InOutMat B<span class="op">)</span>;</span></code></pre></div>
<p><span class="marginalizedparent"><a class="marginalized">14</a></span>
<em>Effects:</em> Equivalent to:</p>
<div class="sourceCode" id="cb140"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb140-1"><a href="#cb140-1" aria-hidden="true" tabindex="-1"></a>triangular_matrix_matrix_right_solve<span class="op">(</span>std<span class="op">::</span>forward<span class="op">&lt;</span>ExecutionPolicy<span class="op">&gt;(</span>exec<span class="op">)</span>,</span>
<span id="cb140-2"><a href="#cb140-2" aria-hidden="true" tabindex="-1"></a>  A, t, d, B, divides<span class="op">&lt;</span><span class="dt">void</span><span class="op">&gt;{})</span>;</span></code></pre></div>
<h1 data-number="29" id="examples"><span class="header-section-number">29</span> Examples<a href="#examples" class="self-link"></a></h1>
<h2 data-number="29.1" id="cholesky-factorization"><span class="header-section-number">29.1</span> Cholesky factorization<a href="#cholesky-factorization" class="self-link"></a></h2>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
This example shows how to compute the Cholesky factorization of a real
symmetric positive definite matrix <span class="math inline"><em>A</em></span> stored as an <code>mdspan</code>
with a unique non-packed layout. The algorithm imitates
<code>DPOTRF2</code> in LAPACK 3.9.0. If <code>Triangle</code> is
<code>upper_triangle_t</code>, then it computes the factorization <span class="math inline"><em>A</em> = <em>U</em><sup><em>T</em></sup><em>U</em></span>
in place, with U stored in the upper triangle of A on output. Otherwise,
it computes the factorization <span class="math inline"><em>A</em> = <em>L</em><em>L</em><sup><em>T</em></sup></span>
in place, with L stored in the lower triangle of A on output. The
function returns 0 if success, else k+1 if row/column k has a zero or
NaN (not a number) diagonal entry.</p>
<div class="sourceCode" id="cb141"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb141-1"><a href="#cb141-1" aria-hidden="true" tabindex="-1"></a><span class="pp">#include </span><span class="im">&lt;linalg&gt;</span></span>
<span id="cb141-2"><a href="#cb141-2" aria-hidden="true" tabindex="-1"></a><span class="pp">#include </span><span class="im">&lt;cmath&gt;</span></span>
<span id="cb141-3"><a href="#cb141-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb141-4"><a href="#cb141-4" aria-hidden="true" tabindex="-1"></a><span class="co">// Flip upper to lower, and lower to upper</span></span>
<span id="cb141-5"><a href="#cb141-5" aria-hidden="true" tabindex="-1"></a>lower_triangular_t opposite_triangle<span class="op">(</span>upper_triangular_t<span class="op">)</span> <span class="op">{</span></span>
<span id="cb141-6"><a href="#cb141-6" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> <span class="op">{}</span>;</span>
<span id="cb141-7"><a href="#cb141-7" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span>
<span id="cb141-8"><a href="#cb141-8" aria-hidden="true" tabindex="-1"></a>upper_triangular_t opposite_triangle<span class="op">(</span>lower_triangular_t<span class="op">)</span> <span class="op">{</span></span>
<span id="cb141-9"><a href="#cb141-9" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> <span class="op">{}</span>;</span>
<span id="cb141-10"><a href="#cb141-10" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span>
<span id="cb141-11"><a href="#cb141-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb141-12"><a href="#cb141-12" aria-hidden="true" tabindex="-1"></a><span class="co">// Returns nullopt if no bad pivots,</span></span>
<span id="cb141-13"><a href="#cb141-13" aria-hidden="true" tabindex="-1"></a><span class="co">// else the index of the first bad pivot.</span></span>
<span id="cb141-14"><a href="#cb141-14" aria-hidden="true" tabindex="-1"></a><span class="co">// A "bad" pivot is zero or NaN.</span></span>
<span id="cb141-15"><a href="#cb141-15" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>inout-matrix</em> InOutMat,</span>
<span id="cb141-16"><a href="#cb141-16" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle<span class="op">&gt;</span></span>
<span id="cb141-17"><a href="#cb141-17" aria-hidden="true" tabindex="-1"></a>std<span class="op">::</span>optional<span class="op">&lt;</span><span class="kw">typename</span> InOutMat<span class="op">::</span>size_type<span class="op">&gt;</span></span>
<span id="cb141-18"><a href="#cb141-18" aria-hidden="true" tabindex="-1"></a>cholesky_factor<span class="op">(</span>InOutMat A, Triangle t<span class="op">)</span></span>
<span id="cb141-19"><a href="#cb141-19" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb141-20"><a href="#cb141-20" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> std<span class="op">::</span>submdspan;</span>
<span id="cb141-21"><a href="#cb141-21" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> std<span class="op">::</span>tuple;</span>
<span id="cb141-22"><a href="#cb141-22" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> value_type <span class="op">=</span> <span class="kw">typename</span> InOutMat<span class="op">::</span>value_type;</span>
<span id="cb141-23"><a href="#cb141-23" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> size_type <span class="op">=</span> <span class="kw">typename</span> InOutMat<span class="op">::</span>size_type;</span>
<span id="cb141-24"><a href="#cb141-24" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb141-25"><a href="#cb141-25" aria-hidden="true" tabindex="-1"></a>  <span class="kw">constexpr</span> value_type ZERO <span class="op">{}</span>;</span>
<span id="cb141-26"><a href="#cb141-26" aria-hidden="true" tabindex="-1"></a>  <span class="kw">constexpr</span> value_type ONE <span class="op">(</span><span class="fl">1.0</span><span class="op">)</span>;</span>
<span id="cb141-27"><a href="#cb141-27" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> size_type n <span class="op">=</span> A<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>;</span>
<span id="cb141-28"><a href="#cb141-28" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb141-29"><a href="#cb141-29" aria-hidden="true" tabindex="-1"></a>  <span class="cf">if</span> <span class="op">(</span>n <span class="op">==</span> <span class="dv">0</span><span class="op">)</span> <span class="op">{</span></span>
<span id="cb141-30"><a href="#cb141-30" aria-hidden="true" tabindex="-1"></a>    <span class="cf">return</span> std<span class="op">::</span>nullopt;</span>
<span id="cb141-31"><a href="#cb141-31" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb141-32"><a href="#cb141-32" aria-hidden="true" tabindex="-1"></a>  <span class="cf">else</span> <span class="cf">if</span> <span class="op">(</span>n <span class="op">==</span> <span class="dv">1</span><span class="op">)</span> <span class="op">{</span></span>
<span id="cb141-33"><a href="#cb141-33" aria-hidden="true" tabindex="-1"></a>    <span class="cf">if</span> <span class="op">(</span>A<span class="op">[</span><span class="dv">0</span>,<span class="dv">0</span><span class="op">]</span> <span class="op">&lt;=</span> ZERO <span class="op">||</span> std<span class="op">::</span>isnan<span class="op">(</span>A<span class="op">[</span><span class="dv">0</span>,<span class="dv">0</span><span class="op">]))</span> <span class="op">{</span></span>
<span id="cb141-34"><a href="#cb141-34" aria-hidden="true" tabindex="-1"></a>      <span class="cf">return</span> <span class="op">{</span>size_type<span class="op">(</span><span class="dv">1</span><span class="op">)}</span>;</span>
<span id="cb141-35"><a href="#cb141-35" aria-hidden="true" tabindex="-1"></a>    <span class="op">}</span></span>
<span id="cb141-36"><a href="#cb141-36" aria-hidden="true" tabindex="-1"></a>    A<span class="op">[</span><span class="dv">0</span>,<span class="dv">0</span><span class="op">]</span> <span class="op">=</span> std<span class="op">::</span>sqrt<span class="op">(</span>A<span class="op">[</span><span class="dv">0</span>,<span class="dv">0</span><span class="op">])</span>;</span>
<span id="cb141-37"><a href="#cb141-37" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb141-38"><a href="#cb141-38" aria-hidden="true" tabindex="-1"></a>  <span class="cf">else</span> <span class="op">{</span></span>
<span id="cb141-39"><a href="#cb141-39" aria-hidden="true" tabindex="-1"></a>    <span class="co">// Partition A into [A11, A12,</span></span>
<span id="cb141-40"><a href="#cb141-40" aria-hidden="true" tabindex="-1"></a>    <span class="co">//                   A21, A22],</span></span>
<span id="cb141-41"><a href="#cb141-41" aria-hidden="true" tabindex="-1"></a>    <span class="co">// where A21 is the transpose of A12.</span></span>
<span id="cb141-42"><a href="#cb141-42" aria-hidden="true" tabindex="-1"></a>    <span class="kw">const</span> size_type n1 <span class="op">=</span> n <span class="op">/</span> <span class="dv">2</span>;</span>
<span id="cb141-43"><a href="#cb141-43" aria-hidden="true" tabindex="-1"></a>    <span class="kw">const</span> size_type n2 <span class="op">=</span> n <span class="op">-</span> n1;</span>
<span id="cb141-44"><a href="#cb141-44" aria-hidden="true" tabindex="-1"></a>    <span class="kw">auto</span> A11 <span class="op">=</span> submdspan<span class="op">(</span>A, pair<span class="op">{</span><span class="dv">0</span>, n1<span class="op">}</span>, pair<span class="op">{</span><span class="dv">0</span>, n1<span class="op">})</span>;</span>
<span id="cb141-45"><a href="#cb141-45" aria-hidden="true" tabindex="-1"></a>    <span class="kw">auto</span> A22 <span class="op">=</span> submdspan<span class="op">(</span>A, pair<span class="op">{</span>n1, n<span class="op">}</span>, pair<span class="op">{</span>n1, n<span class="op">})</span>;</span>
<span id="cb141-46"><a href="#cb141-46" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb141-47"><a href="#cb141-47" aria-hidden="true" tabindex="-1"></a>    <span class="co">// Factor A11</span></span>
<span id="cb141-48"><a href="#cb141-48" aria-hidden="true" tabindex="-1"></a>    <span class="kw">const</span> <span class="kw">auto</span> info1 <span class="op">=</span> cholesky_factor<span class="op">(</span>A11, t<span class="op">)</span>;</span>
<span id="cb141-49"><a href="#cb141-49" aria-hidden="true" tabindex="-1"></a>    <span class="cf">if</span> <span class="op">(</span>info1<span class="op">.</span>has_value<span class="op">())</span> <span class="op">{</span></span>
<span id="cb141-50"><a href="#cb141-50" aria-hidden="true" tabindex="-1"></a>      <span class="cf">return</span> info1;</span>
<span id="cb141-51"><a href="#cb141-51" aria-hidden="true" tabindex="-1"></a>    <span class="op">}</span></span>
<span id="cb141-52"><a href="#cb141-52" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb141-53"><a href="#cb141-53" aria-hidden="true" tabindex="-1"></a>    <span class="kw">using</span> std<span class="op">::</span>linalg<span class="op">::</span>explicit_diagonal;</span>
<span id="cb141-54"><a href="#cb141-54" aria-hidden="true" tabindex="-1"></a>    <span class="kw">using</span> std<span class="op">::</span>linalg<span class="op">::</span>symmetric_matrix_rank_k_update;</span>
<span id="cb141-55"><a href="#cb141-55" aria-hidden="true" tabindex="-1"></a>    <span class="kw">using</span> std<span class="op">::</span>linalg<span class="op">::</span>transposed;</span>
<span id="cb141-56"><a href="#cb141-56" aria-hidden="true" tabindex="-1"></a>    <span class="cf">if</span> <span class="kw">constexpr</span> <span class="op">(</span>std<span class="op">::</span>is_same_v<span class="op">&lt;</span>Triangle, upper_triangle_t<span class="op">&gt;)</span> <span class="op">{</span></span>
<span id="cb141-57"><a href="#cb141-57" aria-hidden="true" tabindex="-1"></a>      <span class="co">// Update and scale A12</span></span>
<span id="cb141-58"><a href="#cb141-58" aria-hidden="true" tabindex="-1"></a>      <span class="kw">auto</span> A12 <span class="op">=</span> submdspan<span class="op">(</span>A, tuple<span class="op">{</span><span class="dv">0</span>, n1<span class="op">}</span>, tuple<span class="op">{</span>n1, n<span class="op">})</span>;</span>
<span id="cb141-59"><a href="#cb141-59" aria-hidden="true" tabindex="-1"></a>      <span class="kw">using</span> std<span class="op">::</span>linalg<span class="op">::</span>triangular_matrix_matrix_left_solve;</span>
<span id="cb141-60"><a href="#cb141-60" aria-hidden="true" tabindex="-1"></a>      <span class="co">// BLAS would use original triangle; we need to flip it</span></span>
<span id="cb141-61"><a href="#cb141-61" aria-hidden="true" tabindex="-1"></a>      triangular_matrix_matrix_left_solve<span class="op">(</span>transposed<span class="op">(</span>A11<span class="op">)</span>,</span>
<span id="cb141-62"><a href="#cb141-62" aria-hidden="true" tabindex="-1"></a>        opposite_triangle<span class="op">(</span>t<span class="op">)</span>, explicit_diagonal, A12<span class="op">)</span>;</span>
<span id="cb141-63"><a href="#cb141-63" aria-hidden="true" tabindex="-1"></a>      <span class="co">// A22 = A22 - A12^T * A12</span></span>
<span id="cb141-64"><a href="#cb141-64" aria-hidden="true" tabindex="-1"></a>      <span class="co">//</span></span>
<span id="cb141-65"><a href="#cb141-65" aria-hidden="true" tabindex="-1"></a>      <span class="co">// The Triangle argument applies to A22,</span></span>
<span id="cb141-66"><a href="#cb141-66" aria-hidden="true" tabindex="-1"></a>      <span class="co">// not transposed(A12), so we don't flip it.</span></span>
<span id="cb141-67"><a href="#cb141-67" aria-hidden="true" tabindex="-1"></a>      symmetric_matrix_rank_k_update<span class="op">(-</span>ONE, transposed<span class="op">(</span>A12<span class="op">)</span>,</span>
<span id="cb141-68"><a href="#cb141-68" aria-hidden="true" tabindex="-1"></a>                                     A22, t<span class="op">)</span>;</span>
<span id="cb141-69"><a href="#cb141-69" aria-hidden="true" tabindex="-1"></a>    <span class="op">}</span></span>
<span id="cb141-70"><a href="#cb141-70" aria-hidden="true" tabindex="-1"></a>    <span class="cf">else</span> <span class="op">{</span></span>
<span id="cb141-71"><a href="#cb141-71" aria-hidden="true" tabindex="-1"></a>      <span class="co">//</span></span>
<span id="cb141-72"><a href="#cb141-72" aria-hidden="true" tabindex="-1"></a>      <span class="co">// Compute the Cholesky factorization A = L * L^T</span></span>
<span id="cb141-73"><a href="#cb141-73" aria-hidden="true" tabindex="-1"></a>      <span class="co">//</span></span>
<span id="cb141-74"><a href="#cb141-74" aria-hidden="true" tabindex="-1"></a>      <span class="co">// Update and scale A21</span></span>
<span id="cb141-75"><a href="#cb141-75" aria-hidden="true" tabindex="-1"></a>      <span class="kw">auto</span> A21 <span class="op">=</span> submdspan<span class="op">(</span>A, tuple<span class="op">{</span>n1, n<span class="op">}</span>, tuple<span class="op">{</span><span class="dv">0</span>, n1<span class="op">})</span>;</span>
<span id="cb141-76"><a href="#cb141-76" aria-hidden="true" tabindex="-1"></a>      <span class="kw">using</span> std<span class="op">::</span>linalg<span class="op">::</span>triangular_matrix_matrix_right_solve;</span>
<span id="cb141-77"><a href="#cb141-77" aria-hidden="true" tabindex="-1"></a>      <span class="co">// BLAS would use original triangle; we need to flip it</span></span>
<span id="cb141-78"><a href="#cb141-78" aria-hidden="true" tabindex="-1"></a>      triangular_matrix_matrix_right_solve<span class="op">(</span>transposed<span class="op">(</span>A11<span class="op">)</span>,</span>
<span id="cb141-79"><a href="#cb141-79" aria-hidden="true" tabindex="-1"></a>        opposite_triangle<span class="op">(</span>t<span class="op">)</span>, explicit_diagonal, A21<span class="op">)</span>;</span>
<span id="cb141-80"><a href="#cb141-80" aria-hidden="true" tabindex="-1"></a>      <span class="co">// A22 = A22 - A21 * A21^T</span></span>
<span id="cb141-81"><a href="#cb141-81" aria-hidden="true" tabindex="-1"></a>      symmetric_matrix_rank_k_update<span class="op">(-</span>ONE, A21, A22, t<span class="op">)</span>;</span>
<span id="cb141-82"><a href="#cb141-82" aria-hidden="true" tabindex="-1"></a>    <span class="op">}</span></span>
<span id="cb141-83"><a href="#cb141-83" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb141-84"><a href="#cb141-84" aria-hidden="true" tabindex="-1"></a>    <span class="co">// Factor A22</span></span>
<span id="cb141-85"><a href="#cb141-85" aria-hidden="true" tabindex="-1"></a>    <span class="kw">const</span> <span class="kw">auto</span> info2 <span class="op">=</span> cholesky_factor<span class="op">(</span>A22, t<span class="op">)</span>;</span>
<span id="cb141-86"><a href="#cb141-86" aria-hidden="true" tabindex="-1"></a>    <span class="cf">if</span> <span class="op">(</span>info2<span class="op">.</span>has_value<span class="op">())</span> <span class="op">{</span></span>
<span id="cb141-87"><a href="#cb141-87" aria-hidden="true" tabindex="-1"></a>      <span class="cf">return</span> <span class="op">{</span>info2<span class="op">.</span>value<span class="op">()</span> <span class="op">+</span> n1<span class="op">}</span>;</span>
<span id="cb141-88"><a href="#cb141-88" aria-hidden="true" tabindex="-1"></a>    <span class="op">}</span></span>
<span id="cb141-89"><a href="#cb141-89" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb141-90"><a href="#cb141-90" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb141-91"><a href="#cb141-91" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> std<span class="op">::</span>nullopt;</span>
<span id="cb141-92"><a href="#cb141-92" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<h2 data-number="29.2" id="solve-linear-system-using-cholesky-factorization"><span class="header-section-number">29.2</span> Solve linear system using
Cholesky factorization<a href="#solve-linear-system-using-cholesky-factorization" class="self-link"></a></h2>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
This example shows how to solve a symmetric positive definite linear
system <span class="math inline"><em>A</em><em>x</em> = <em>b</em></span>, using the
Cholesky factorization computed in the previous example in-place in the
matrix <code>A</code>. The example assumes that
<code>cholesky_factor(A, t)</code> returned <code>nullopt</code>,
indicating no zero or NaN pivots.</p>
<div class="sourceCode" id="cb142"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb142-1"><a href="#cb142-1" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb142-2"><a href="#cb142-2" aria-hidden="true" tabindex="-1"></a>         <span class="kw">class</span> Triangle,</span>
<span id="cb142-3"><a href="#cb142-3" aria-hidden="true" tabindex="-1"></a>         <em>in-vector</em> InVec,</span>
<span id="cb142-4"><a href="#cb142-4" aria-hidden="true" tabindex="-1"></a>         <em>out-vector</em> OutVec<span class="op">&gt;</span></span>
<span id="cb142-5"><a href="#cb142-5" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> cholesky_solve<span class="op">(</span></span>
<span id="cb142-6"><a href="#cb142-6" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb142-7"><a href="#cb142-7" aria-hidden="true" tabindex="-1"></a>  Triangle t,</span>
<span id="cb142-8"><a href="#cb142-8" aria-hidden="true" tabindex="-1"></a>  InVec b,</span>
<span id="cb142-9"><a href="#cb142-9" aria-hidden="true" tabindex="-1"></a>  OutVec x<span class="op">)</span></span>
<span id="cb142-10"><a href="#cb142-10" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb142-11"><a href="#cb142-11" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> std<span class="op">::</span>linalg<span class="op">::</span>explicit_diagonal;</span>
<span id="cb142-12"><a href="#cb142-12" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> std<span class="op">::</span>linalg<span class="op">::</span>transposed;</span>
<span id="cb142-13"><a href="#cb142-13" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> std<span class="op">::</span>linalg<span class="op">::</span>triangular_matrix_vector_solve;</span>
<span id="cb142-14"><a href="#cb142-14" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb142-15"><a href="#cb142-15" aria-hidden="true" tabindex="-1"></a>  <span class="cf">if</span> <span class="kw">constexpr</span> <span class="op">(</span>std<span class="op">::</span>is_same_v<span class="op">&lt;</span>Triangle, upper_triangle_t<span class="op">&gt;)</span> <span class="op">{</span></span>
<span id="cb142-16"><a href="#cb142-16" aria-hidden="true" tabindex="-1"></a>    <span class="co">// Solve Ax=b where A = U^T U</span></span>
<span id="cb142-17"><a href="#cb142-17" aria-hidden="true" tabindex="-1"></a>    <span class="co">//</span></span>
<span id="cb142-18"><a href="#cb142-18" aria-hidden="true" tabindex="-1"></a>    <span class="co">// Solve U^T c = b, using x to store c.</span></span>
<span id="cb142-19"><a href="#cb142-19" aria-hidden="true" tabindex="-1"></a>    triangular_matrix_vector_solve<span class="op">(</span>transposed<span class="op">(</span>A<span class="op">)</span>,</span>
<span id="cb142-20"><a href="#cb142-20" aria-hidden="true" tabindex="-1"></a>      opposite_triangle<span class="op">(</span>t<span class="op">)</span>, explicit_diagonal, b, x<span class="op">)</span>;</span>
<span id="cb142-21"><a href="#cb142-21" aria-hidden="true" tabindex="-1"></a>    <span class="co">// Solve U x = c, overwriting x with result.</span></span>
<span id="cb142-22"><a href="#cb142-22" aria-hidden="true" tabindex="-1"></a>    triangular_matrix_vector_solve<span class="op">(</span>A, t, explicit_diagonal, x<span class="op">)</span>;</span>
<span id="cb142-23"><a href="#cb142-23" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb142-24"><a href="#cb142-24" aria-hidden="true" tabindex="-1"></a>  <span class="cf">else</span> <span class="op">{</span></span>
<span id="cb142-25"><a href="#cb142-25" aria-hidden="true" tabindex="-1"></a>    <span class="co">// Solve Ax=b where A = L L^T</span></span>
<span id="cb142-26"><a href="#cb142-26" aria-hidden="true" tabindex="-1"></a>    <span class="co">//</span></span>
<span id="cb142-27"><a href="#cb142-27" aria-hidden="true" tabindex="-1"></a>    <span class="co">// Solve L c = b, using x to store c.</span></span>
<span id="cb142-28"><a href="#cb142-28" aria-hidden="true" tabindex="-1"></a>    triangular_matrix_vector_solve<span class="op">(</span>A, t, explicit_diagonal, b, x<span class="op">)</span>;</span>
<span id="cb142-29"><a href="#cb142-29" aria-hidden="true" tabindex="-1"></a>    <span class="co">// Solve L^T x = c, overwriting x with result.</span></span>
<span id="cb142-30"><a href="#cb142-30" aria-hidden="true" tabindex="-1"></a>    triangular_matrix_vector_solve<span class="op">(</span>transposed<span class="op">(</span>A<span class="op">)</span>,</span>
<span id="cb142-31"><a href="#cb142-31" aria-hidden="true" tabindex="-1"></a>      opposite_triangle<span class="op">(</span>t<span class="op">)</span>, explicit_diagonal, x<span class="op">)</span>;</span>
<span id="cb142-32"><a href="#cb142-32" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb142-33"><a href="#cb142-33" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<h2 data-number="29.3" id="compute-qr-factorization-of-a-tall-skinny-matrix"><span class="header-section-number">29.3</span> Compute QR factorization of a
tall skinny matrix<a href="#compute-qr-factorization-of-a-tall-skinny-matrix" class="self-link"></a></h2>
<p><span class="marginalizedparent"><a class="marginalized">1</a></span>
This example shows how to compute the QR factorization of a “tall and
skinny” matrix <code>V</code>, using a cache-blocked algorithm based on
rank-k symmetric matrix update and Cholesky factorization. “Tall and
skinny” means that the matrix has many more rows than columns.</p>
<div class="sourceCode" id="cb143"><pre class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb143-1"><a href="#cb143-1" aria-hidden="true" tabindex="-1"></a><span class="co">// Compute QR factorization A = Q R, with A storing Q.</span></span>
<span id="cb143-2"><a href="#cb143-2" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>inout-matrix</em> InOutMat,</span>
<span id="cb143-3"><a href="#cb143-3" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat<span class="op">&gt;</span></span>
<span id="cb143-4"><a href="#cb143-4" aria-hidden="true" tabindex="-1"></a>std<span class="op">::</span>optional<span class="op">&lt;</span><span class="kw">typename</span> InOutMat<span class="op">::</span>size_type<span class="op">&gt;</span></span>
<span id="cb143-5"><a href="#cb143-5" aria-hidden="true" tabindex="-1"></a>cholesky_tsqr_one_step<span class="op">(</span></span>
<span id="cb143-6"><a href="#cb143-6" aria-hidden="true" tabindex="-1"></a>  InOutMat A, <span class="co">// A on input, Q on output</span></span>
<span id="cb143-7"><a href="#cb143-7" aria-hidden="true" tabindex="-1"></a>  OutMat R<span class="op">)</span></span>
<span id="cb143-8"><a href="#cb143-8" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb143-9"><a href="#cb143-9" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> std<span class="op">::</span>full_extent;</span>
<span id="cb143-10"><a href="#cb143-10" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> std<span class="op">::</span>submdspan;</span>
<span id="cb143-11"><a href="#cb143-11" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> std<span class="op">::</span>tuple;</span>
<span id="cb143-12"><a href="#cb143-12" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> size_type <span class="op">=</span> <span class="kw">typename</span> InOutMat<span class="op">::</span>size_type;</span>
<span id="cb143-13"><a href="#cb143-13" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb143-14"><a href="#cb143-14" aria-hidden="true" tabindex="-1"></a>  <span class="co">// One might use cache size, sizeof(element_type), and A.extent(1)</span></span>
<span id="cb143-15"><a href="#cb143-15" aria-hidden="true" tabindex="-1"></a>  <span class="co">// to pick the number of rows per block.  For now, we just pick</span></span>
<span id="cb143-16"><a href="#cb143-16" aria-hidden="true" tabindex="-1"></a>  <span class="co">// some constant.</span></span>
<span id="cb143-17"><a href="#cb143-17" aria-hidden="true" tabindex="-1"></a>  <span class="kw">constexpr</span> size_type max_num_rows_per_block <span class="op">=</span> <span class="dv">500</span>;</span>
<span id="cb143-18"><a href="#cb143-18" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb143-19"><a href="#cb143-19" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> R_value_type <span class="op">=</span> <span class="kw">typename</span> OutMat<span class="op">::</span>value_type;</span>
<span id="cb143-20"><a href="#cb143-20" aria-hidden="true" tabindex="-1"></a>  <span class="kw">constexpr</span> R_element_type ZERO <span class="op">{}</span>;</span>
<span id="cb143-21"><a href="#cb143-21" aria-hidden="true" tabindex="-1"></a>  <span class="cf">for</span><span class="op">(</span>size_type j <span class="op">=</span> <span class="dv">0</span>; j <span class="op">&lt;</span> R<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span>; <span class="op">++</span>j<span class="op">)</span> <span class="op">{</span></span>
<span id="cb143-22"><a href="#cb143-22" aria-hidden="true" tabindex="-1"></a>    <span class="cf">for</span><span class="op">(</span>size_type i <span class="op">=</span> <span class="dv">0</span>; i <span class="op">&lt;</span> R<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>; <span class="op">++</span>i<span class="op">)</span> <span class="op">{</span></span>
<span id="cb143-23"><a href="#cb143-23" aria-hidden="true" tabindex="-1"></a>      R<span class="op">[</span>i,j<span class="op">]</span> <span class="op">=</span> ZERO;</span>
<span id="cb143-24"><a href="#cb143-24" aria-hidden="true" tabindex="-1"></a>    <span class="op">}</span></span>
<span id="cb143-25"><a href="#cb143-25" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb143-26"><a href="#cb143-26" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb143-27"><a href="#cb143-27" aria-hidden="true" tabindex="-1"></a>  <span class="co">// Cache-blocked version of R = R + A^T * A.</span></span>
<span id="cb143-28"><a href="#cb143-28" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <span class="kw">auto</span> num_rows <span class="op">=</span> A<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>;</span>
<span id="cb143-29"><a href="#cb143-29" aria-hidden="true" tabindex="-1"></a>  <span class="kw">auto</span> rest_num_rows <span class="op">=</span> num_rows;</span>
<span id="cb143-30"><a href="#cb143-30" aria-hidden="true" tabindex="-1"></a>  <span class="kw">auto</span> A_rest <span class="op">=</span> A;</span>
<span id="cb143-31"><a href="#cb143-31" aria-hidden="true" tabindex="-1"></a>  <span class="cf">while</span><span class="op">(</span>A_rest<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">&gt;</span> <span class="dv">0</span><span class="op">)</span> <span class="op">{</span></span>
<span id="cb143-32"><a href="#cb143-32" aria-hidden="true" tabindex="-1"></a>    <span class="kw">const</span> size_type num_rows_per_block <span class="op">=</span></span>
<span id="cb143-33"><a href="#cb143-33" aria-hidden="true" tabindex="-1"></a>      std<span class="op">::</span>min<span class="op">(</span>A<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span>, max_num_rows_per_block<span class="op">)</span>;</span>
<span id="cb143-34"><a href="#cb143-34" aria-hidden="true" tabindex="-1"></a>    <span class="kw">auto</span> A_cur <span class="op">=</span> submdspan<span class="op">(</span>A_rest,</span>
<span id="cb143-35"><a href="#cb143-35" aria-hidden="true" tabindex="-1"></a>      tuple<span class="op">{</span><span class="dv">0</span>, num_rows_per_block<span class="op">}</span>,</span>
<span id="cb143-36"><a href="#cb143-36" aria-hidden="true" tabindex="-1"></a>      full_extent<span class="op">)</span>;</span>
<span id="cb143-37"><a href="#cb143-37" aria-hidden="true" tabindex="-1"></a>    A_rest <span class="op">=</span> submdspan<span class="op">(</span>A_rest,</span>
<span id="cb143-38"><a href="#cb143-38" aria-hidden="true" tabindex="-1"></a>      tuple<span class="op">{</span>num_rows_per_block, A_rest<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)}</span>,</span>
<span id="cb143-39"><a href="#cb143-39" aria-hidden="true" tabindex="-1"></a>      full_extent<span class="op">)</span>;</span>
<span id="cb143-40"><a href="#cb143-40" aria-hidden="true" tabindex="-1"></a>    <span class="co">// R = R + A_cur^T * A_cur</span></span>
<span id="cb143-41"><a href="#cb143-41" aria-hidden="true" tabindex="-1"></a>    <span class="kw">using</span> std<span class="op">::</span>linalg<span class="op">::</span>symmetric_matrix_rank_k_update;</span>
<span id="cb143-42"><a href="#cb143-42" aria-hidden="true" tabindex="-1"></a>    <span class="kw">constexpr</span> R_element_type ONE<span class="op">(</span><span class="fl">1.0</span><span class="op">)</span>;</span>
<span id="cb143-43"><a href="#cb143-43" aria-hidden="true" tabindex="-1"></a>    <span class="co">// The Triangle argument applies to R,</span></span>
<span id="cb143-44"><a href="#cb143-44" aria-hidden="true" tabindex="-1"></a>    <span class="co">// not transposed(A_cur), so we don't flip it.</span></span>
<span id="cb143-45"><a href="#cb143-45" aria-hidden="true" tabindex="-1"></a>    symmetric_matrix_rank_k_update<span class="op">(</span>ONE,</span>
<span id="cb143-46"><a href="#cb143-46" aria-hidden="true" tabindex="-1"></a>      std<span class="op">::</span>linalg<span class="op">::</span>transposed<span class="op">(</span>A_cur<span class="op">)</span>,</span>
<span id="cb143-47"><a href="#cb143-47" aria-hidden="true" tabindex="-1"></a>      R, upper_triangle<span class="op">)</span>;</span>
<span id="cb143-48"><a href="#cb143-48" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb143-49"><a href="#cb143-49" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb143-50"><a href="#cb143-50" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <span class="kw">auto</span> info <span class="op">=</span> cholesky_factor<span class="op">(</span>R, upper_triangle<span class="op">)</span>;</span>
<span id="cb143-51"><a href="#cb143-51" aria-hidden="true" tabindex="-1"></a>  <span class="cf">if</span><span class="op">(</span>info<span class="op">.</span>has_value<span class="op">())</span> <span class="op">{</span></span>
<span id="cb143-52"><a href="#cb143-52" aria-hidden="true" tabindex="-1"></a>    <span class="cf">return</span> info;</span>
<span id="cb143-53"><a href="#cb143-53" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb143-54"><a href="#cb143-54" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> std<span class="op">::</span>linalg<span class="op">::</span>triangular_matrix_matrix_left_solve;</span>
<span id="cb143-55"><a href="#cb143-55" aria-hidden="true" tabindex="-1"></a>  triangular_matrix_matrix_left_solve<span class="op">(</span>R, upper_triangle, A<span class="op">)</span>;</span>
<span id="cb143-56"><a href="#cb143-56" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> std<span class="op">::</span>nullopt;</span>
<span id="cb143-57"><a href="#cb143-57" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span>
<span id="cb143-58"><a href="#cb143-58" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb143-59"><a href="#cb143-59" aria-hidden="true" tabindex="-1"></a><span class="co">// Compute QR factorization A = Q R.</span></span>
<span id="cb143-60"><a href="#cb143-60" aria-hidden="true" tabindex="-1"></a><span class="co">// Use R_tmp as temporary R factor storage</span></span>
<span id="cb143-61"><a href="#cb143-61" aria-hidden="true" tabindex="-1"></a><span class="co">// for iterative refinement.</span></span>
<span id="cb143-62"><a href="#cb143-62" aria-hidden="true" tabindex="-1"></a><span class="kw">template</span><span class="op">&lt;</span><em>in-matrix</em> InMat,</span>
<span id="cb143-63"><a href="#cb143-63" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat1,</span>
<span id="cb143-64"><a href="#cb143-64" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat2,</span>
<span id="cb143-65"><a href="#cb143-65" aria-hidden="true" tabindex="-1"></a>         <em>out-matrix</em> OutMat3<span class="op">&gt;</span></span>
<span id="cb143-66"><a href="#cb143-66" aria-hidden="true" tabindex="-1"></a>std<span class="op">::</span>optional<span class="op">&lt;</span><span class="kw">typename</span> OutMat1<span class="op">::</span>size_type<span class="op">&gt;</span></span>
<span id="cb143-67"><a href="#cb143-67" aria-hidden="true" tabindex="-1"></a>cholesky_tsqr<span class="op">(</span></span>
<span id="cb143-68"><a href="#cb143-68" aria-hidden="true" tabindex="-1"></a>  InMat A,</span>
<span id="cb143-69"><a href="#cb143-69" aria-hidden="true" tabindex="-1"></a>  OutMat1 Q,</span>
<span id="cb143-70"><a href="#cb143-70" aria-hidden="true" tabindex="-1"></a>  OutMat2 R_tmp,</span>
<span id="cb143-71"><a href="#cb143-71" aria-hidden="true" tabindex="-1"></a>  OutMat3 R<span class="op">)</span></span>
<span id="cb143-72"><a href="#cb143-72" aria-hidden="true" tabindex="-1"></a><span class="op">{</span></span>
<span id="cb143-73"><a href="#cb143-73" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>R<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">==</span> R<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">))</span>;</span>
<span id="cb143-74"><a href="#cb143-74" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>A<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span> <span class="op">==</span> R<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">))</span>;</span>
<span id="cb143-75"><a href="#cb143-75" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>R_tmp<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">==</span> R_tmp<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">))</span>;</span>
<span id="cb143-76"><a href="#cb143-76" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>A<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">)</span> <span class="op">==</span> Q<span class="op">.</span>extent<span class="op">(</span><span class="dv">0</span><span class="op">))</span>;</span>
<span id="cb143-77"><a href="#cb143-77" aria-hidden="true" tabindex="-1"></a>  <span class="ot">assert</span><span class="op">(</span>A<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">)</span> <span class="op">==</span> Q<span class="op">.</span>extent<span class="op">(</span><span class="dv">1</span><span class="op">))</span>;</span>
<span id="cb143-78"><a href="#cb143-78" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb143-79"><a href="#cb143-79" aria-hidden="true" tabindex="-1"></a>  std<span class="op">::</span>linalg<span class="op">::</span>copy<span class="op">(</span>A, Q<span class="op">)</span>;</span>
<span id="cb143-80"><a href="#cb143-80" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <span class="kw">auto</span> info1 <span class="op">=</span> cholesky_tsqr_one_step<span class="op">(</span>Q, R<span class="op">)</span>;</span>
<span id="cb143-81"><a href="#cb143-81" aria-hidden="true" tabindex="-1"></a>  <span class="cf">if</span><span class="op">(</span>info1<span class="op">.</span>has_value<span class="op">())</span> <span class="op">{</span></span>
<span id="cb143-82"><a href="#cb143-82" aria-hidden="true" tabindex="-1"></a>    <span class="cf">return</span> info1;</span>
<span id="cb143-83"><a href="#cb143-83" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb143-84"><a href="#cb143-84" aria-hidden="true" tabindex="-1"></a>  <span class="co">// Use one step of iterative refinement to improve accuracy.</span></span>
<span id="cb143-85"><a href="#cb143-85" aria-hidden="true" tabindex="-1"></a>  <span class="kw">const</span> <span class="kw">auto</span> info2 <span class="op">=</span> cholesky_tsqr_one_step<span class="op">(</span>Q, R_tmp<span class="op">)</span>;</span>
<span id="cb143-86"><a href="#cb143-86" aria-hidden="true" tabindex="-1"></a>  <span class="cf">if</span><span class="op">(</span>info2<span class="op">.</span>has_value<span class="op">())</span> <span class="op">{</span></span>
<span id="cb143-87"><a href="#cb143-87" aria-hidden="true" tabindex="-1"></a>    <span class="cf">return</span> info2;</span>
<span id="cb143-88"><a href="#cb143-88" aria-hidden="true" tabindex="-1"></a>  <span class="op">}</span></span>
<span id="cb143-89"><a href="#cb143-89" aria-hidden="true" tabindex="-1"></a>  <span class="co">// R = R_tmp * R</span></span>
<span id="cb143-90"><a href="#cb143-90" aria-hidden="true" tabindex="-1"></a>  <span class="kw">using</span> std<span class="op">::</span>linalg<span class="op">::</span>triangular_matrix_product;</span>
<span id="cb143-91"><a href="#cb143-91" aria-hidden="true" tabindex="-1"></a>  triangular_matrix_product<span class="op">(</span>R_tmp, upper_triangle,</span>
<span id="cb143-92"><a href="#cb143-92" aria-hidden="true" tabindex="-1"></a>                            explicit_diagonal, R<span class="op">)</span>;</span>
<span id="cb143-93"><a href="#cb143-93" aria-hidden="true" tabindex="-1"></a>  <span class="cf">return</span> std<span class="op">::</span>nullopt;</span>
<span id="cb143-94"><a href="#cb143-94" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
</div>
</div>


</body></html>