From Jason Turner

[linalg.algs.blas2]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp_1pev5g3/{from.md → to.md} +620 -0
tmp/tmp_1pev5g3/{from.md → to.md} RENAMED
@@ -0,0 +1,620 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### BLAS 2 algorithms <a id="linalg.algs.blas2">[[linalg.algs.blas2]]</a>
2
+
3
+ #### General matrix-vector product <a id="linalg.algs.blas2.gemv">[[linalg.algs.blas2.gemv]]</a>
4
+
5
+ [*Note 1*: These functions correspond to the BLAS function
6
+ `xGEMV`. — *end note*]
7
+
8
+ The following elements apply to all functions in
9
+ [[linalg.algs.blas2.gemv]].
10
+
11
+ *Mandates:*
12
+
13
+ - `possibly-multipliable<decltype(A), decltype(x), decltype(y)>()` is
14
+ `true`, and
15
+ - `possibly-addable<decltype(x), decltype(y), decltype(z)>()` is `true`
16
+ for those overloads that take a `z` parameter.
17
+
18
+ *Preconditions:*
19
+
20
+ - `multipliable(A,x,y)` is `true`, and
21
+ - `addable(x,y,z)` is `true` for those overloads that take a `z`
22
+ parameter.
23
+
24
+ *Complexity:* 𝑂(`x.extent(0)` × `A.extent(1)`).
25
+
26
+ ``` cpp
27
+ template<in-matrix InMat, in-vector InVec, out-vector OutVec>
28
+ void matrix_vector_product(InMat A, InVec x, OutVec y);
29
+ template<class ExecutionPolicy, in-matrix InMat, in-vector InVec, out-vector OutVec>
30
+ void matrix_vector_product(ExecutionPolicy&& exec, InMat A, InVec x, OutVec y);
31
+ ```
32
+
33
+ These functions perform an overwriting matrix-vector product.
34
+
35
+ *Effects:* Computes y = A x.
36
+
37
+ [*Example 1*:
38
+
39
+ ``` cpp
40
+ constexpr size_t num_rows = 5;
41
+ constexpr size_t num_cols = 6;
42
+
43
+ // y = 3.0 * A * x
44
+ void scaled_matvec_1(mdspan<double, extents<size_t, num_rows, num_cols>> A,
45
+ mdspan<double, extents<size_t, num_cols>> x, mdspan<double, extents<size_t, num_rows>> y) {
46
+ matrix_vector_product(scaled(3.0, A), x, y);
47
+ }
48
+
49
+ // z = 7.0 times the transpose of A, times y
50
+ void scaled_transposed_matvec(mdspan<double, extents<size_t, num_rows, num_cols>> A,
51
+ mdspan<double, extents<size_t, num_rows>> y, mdspan<double, extents<size_t, num_cols>> z) {
52
+ matrix_vector_product(scaled(7.0, transposed(A)), y, z);
53
+ }
54
+ ```
55
+
56
+ — *end example*]
57
+
58
+ ``` cpp
59
+ template<in-matrix InMat, in-vector InVec1, in-vector InVec2, out-vector OutVec>
60
+ void matrix_vector_product(InMat A, InVec1 x, InVec2 y, OutVec z);
61
+ template<class ExecutionPolicy,
62
+ in-matrix InMat, in-vector InVec1, in-vector InVec2, out-vector OutVec>
63
+ void matrix_vector_product(ExecutionPolicy&& exec,
64
+ InMat A, InVec1 x, InVec2 y, OutVec z);
65
+ ```
66
+
67
+ These functions perform an updating matrix-vector product.
68
+
69
+ *Effects:* Computes z = y + A x.
70
+
71
+ *Remarks:* `z` may alias `y`.
72
+
73
+ [*Example 2*:
74
+
75
+ ``` cpp
76
+ // y = 3.0 * A * x + 2.0 * y
77
+ void scaled_matvec_2(mdspan<double, extents<size_t, num_rows, num_cols>> A,
78
+ mdspan<double, extents<size_t, num_cols>> x, mdspan<double, extents<size_t, num_rows>> y) {
79
+ matrix_vector_product(scaled(3.0, A), x, scaled(2.0, y), y);
80
+ }
81
+ ```
82
+
83
+ — *end example*]
84
+
85
+ #### Symmetric matrix-vector product <a id="linalg.algs.blas2.symv">[[linalg.algs.blas2.symv]]</a>
86
+
87
+ [*Note 1*: These functions correspond to the BLAS functions `xSYMV` and
88
+ `xSPMV`. — *end note*]
89
+
90
+ The following elements apply to all functions in
91
+ [[linalg.algs.blas2.symv]].
92
+
93
+ *Mandates:*
94
+
95
+ - If `InMat` has `layout_blas_packed` layout, then the layout’s
96
+ `Triangle` template argument has the same type as the function’s
97
+ `Triangle` template argument;
98
+ - `compatible-static-extents<decltype(A), decltype(A)>(0, 1)` is `true`;
99
+ - `possibly-multipliable<decltype(A), decltype(x), decltype(y)>()` is
100
+ `true`; and
101
+ - `possibly-addable<decltype(x), decltype(y), decltype(z)>()` is `true`
102
+ for those overloads that take a `z` parameter.
103
+
104
+ *Preconditions:*
105
+
106
+ - `A.extent(0)` equals `A.extent(1)`,
107
+ - `multipliable(A,x,y)` is `true`, and
108
+ - `addable(x,y,z)` is `true` for those overloads that take a `z`
109
+ parameter.
110
+
111
+ *Complexity:* 𝑂(`x.extent(0)` × `A.extent(1)`).
112
+
113
+ ``` cpp
114
+ template<in-matrix InMat, class Triangle, in-vector InVec, out-vector OutVec>
115
+ void symmetric_matrix_vector_product(InMat A, Triangle t, InVec x, OutVec y);
116
+ template<class ExecutionPolicy,
117
+ in-matrix InMat, class Triangle, in-vector InVec, out-vector OutVec>
118
+ void symmetric_matrix_vector_product(ExecutionPolicy&& exec,
119
+ InMat A, Triangle t, InVec x, OutVec y);
120
+ ```
121
+
122
+ These functions perform an overwriting symmetric matrix-vector product,
123
+ taking into account the `Triangle` parameter that applies to the
124
+ symmetric matrix `A` [[linalg.general]].
125
+
126
+ *Effects:* Computes y = A x.
127
+
128
+ ``` cpp
129
+ template<in-matrix InMat, class Triangle, in-vector InVec1, in-vector InVec2, out-vector OutVec>
130
+ void symmetric_matrix_vector_product(InMat A, Triangle t, InVec1 x, InVec2 y, OutVec z);
131
+ template<class ExecutionPolicy,
132
+ in-matrix InMat, class Triangle, in-vector InVec1, in-vector InVec2, out-vector OutVec>
133
+ void symmetric_matrix_vector_product(ExecutionPolicy&& exec,
134
+ InMat A, Triangle t, InVec1 x, InVec2 y, OutVec z);
135
+ ```
136
+
137
+ These functions perform an updating symmetric matrix-vector product,
138
+ taking into account the `Triangle` parameter that applies to the
139
+ symmetric matrix `A` [[linalg.general]].
140
+
141
+ *Effects:* Computes z = y + A x.
142
+
143
+ *Remarks:* `z` may alias `y`.
144
+
145
+ #### Hermitian matrix-vector product <a id="linalg.algs.blas2.hemv">[[linalg.algs.blas2.hemv]]</a>
146
+
147
+ [*Note 1*: These functions correspond to the BLAS functions `xHEMV` and
148
+ `xHPMV`. — *end note*]
149
+
150
+ The following elements apply to all functions in
151
+ [[linalg.algs.blas2.hemv]].
152
+
153
+ *Mandates:*
154
+
155
+ - If `InMat` has `layout_blas_packed` layout, then the layout’s
156
+ `Triangle` template argument has the same type as the function’s
157
+ `Triangle` template argument;
158
+ - `compatible-static-extents<decltype(A), decltype(A)>(0, 1)` is `true`;
159
+ - `possibly-multipliable<decltype(A), decltype(x), decltype(y)>()` is
160
+ `true`; and
161
+ - `possibly-addable<decltype(x), decltype(y), decltype(z)>()` is `true`
162
+ for those overloads that take a `z` parameter.
163
+
164
+ *Preconditions:*
165
+
166
+ - `A.extent(0)` equals `A.extent(1)`,
167
+ - `multipliable(A, x, y)` is `true`, and
168
+ - `addable(x, y, z)` is `true` for those overloads that take a `z`
169
+ parameter.
170
+
171
+ *Complexity:* 𝑂(`x.extent(0)` × `A.extent(1)`).
172
+
173
+ ``` cpp
174
+ template<in-matrix InMat, class Triangle, in-vector InVec, out-vector OutVec>
175
+ void hermitian_matrix_vector_product(InMat A, Triangle t, InVec x, OutVec y);
176
+ template<class ExecutionPolicy,
177
+ in-matrix InMat, class Triangle, in-vector InVec, out-vector OutVec>
178
+ void hermitian_matrix_vector_product(ExecutionPolicy&& exec,
179
+ InMat A, Triangle t, InVec x, OutVec y);
180
+ ```
181
+
182
+ These functions perform an overwriting Hermitian matrix-vector product,
183
+ taking into account the `Triangle` parameter that applies to the
184
+ Hermitian matrix `A` [[linalg.general]].
185
+
186
+ *Effects:* Computes y = A x.
187
+
188
+ ``` cpp
189
+ template<in-matrix InMat, class Triangle, in-vector InVec1, in-vector InVec2, out-vector OutVec>
190
+ void hermitian_matrix_vector_product(InMat A, Triangle t, InVec1 x, InVec2 y, OutVec z);
191
+ template<class ExecutionPolicy,
192
+ in-matrix InMat, class Triangle, in-vector InVec1, in-vector InVec2, out-vector OutVec>
193
+ void hermitian_matrix_vector_product(ExecutionPolicy&& exec,
194
+ InMat A, Triangle t, InVec1 x, InVec2 y, OutVec z);
195
+ ```
196
+
197
+ These functions perform an updating Hermitian matrix-vector product,
198
+ taking into account the `Triangle` parameter that applies to the
199
+ Hermitian matrix `A` [[linalg.general]].
200
+
201
+ *Effects:* Computes z = y + A x.
202
+
203
+ *Remarks:* `z` may alias `y`.
204
+
205
+ #### Triangular matrix-vector product <a id="linalg.algs.blas2.trmv">[[linalg.algs.blas2.trmv]]</a>
206
+
207
+ [*Note 1*: These functions correspond to the BLAS functions `xTRMV` and
208
+ `xTPMV`. — *end note*]
209
+
210
+ The following elements apply to all functions in
211
+ [[linalg.algs.blas2.trmv]].
212
+
213
+ *Mandates:*
214
+
215
+ - If `InMat` has `layout_blas_packed` layout, then the layout’s
216
+ `Triangle` template argument has the same type as the function’s
217
+ `Triangle` template argument;
218
+ - `compatible-static-extents<decltype(A), decltype(A)>(0, 1)` is `true`;
219
+ - `compatible-static-extents<decltype(A), decltype(y)>(0, 0)` is `true`;
220
+ - `compatible-static-extents<decltype(A), decltype(x)>(0, 0)` is `true`
221
+ for those overloads that take an `x` parameter; and
222
+ - `compatible-static-extents<decltype(A), decltype(z)>(0, 0)` is `true`
223
+ for those overloads that take a `z` parameter.
224
+
225
+ *Preconditions:*
226
+
227
+ - `A.extent(0)` equals `A.extent(1)`,
228
+ - `A.extent(0)` equals `y.extent(0)`,
229
+ - `A.extent(0)` equals `x.extent(0)` for those overloads that take an
230
+ `x` parameter, and
231
+ - `A.extent(0)` equals `z.extent(0)` for those overloads that take a `z`
232
+ parameter.
233
+
234
+ ``` cpp
235
+ template<in-matrix InMat, class Triangle, class DiagonalStorage, in-vector InVec,
236
+ out-vector OutVec>
237
+ void triangular_matrix_vector_product(InMat A, Triangle t, DiagonalStorage d, InVec x, OutVec y);
238
+ template<class ExecutionPolicy,
239
+ in-matrix InMat, class Triangle, class DiagonalStorage, in-vector InVec,
240
+ out-vector OutVec>
241
+ void triangular_matrix_vector_product(ExecutionPolicy&& exec,
242
+ InMat A, Triangle t, DiagonalStorage d, InVec x, OutVec y);
243
+ ```
244
+
245
+ These functions perform an overwriting triangular matrix-vector product,
246
+ taking into account the `Triangle` and `DiagonalStorage` parameters that
247
+ apply to the triangular matrix `A` [[linalg.general]].
248
+
249
+ *Effects:* Computes y = A x.
250
+
251
+ *Complexity:* 𝑂(`x.extent(0)` × `A.extent(1)`).
252
+
253
+ ``` cpp
254
+ template<in-matrix InMat, class Triangle, class DiagonalStorage, inout-vector InOutVec>
255
+ void triangular_matrix_vector_product(InMat A, Triangle t, DiagonalStorage d, InOutVec y);
256
+ template<class ExecutionPolicy,
257
+ in-matrix InMat, class Triangle, class DiagonalStorage, inout-vector InOutVec>
258
+ void triangular_matrix_vector_product(ExecutionPolicy&& exec,
259
+ InMat A, Triangle t, DiagonalStorage d, InOutVec y);
260
+ ```
261
+
262
+ These functions perform an in-place triangular matrix-vector product,
263
+ taking into account the `Triangle` and `DiagonalStorage` parameters that
264
+ apply to the triangular matrix `A` [[linalg.general]].
265
+
266
+ [*Note 1*: Performing this operation in place hinders parallelization.
267
+ However, other `ExecutionPolicy` specific optimizations, such as
268
+ vectorization, are still possible. — *end note*]
269
+
270
+ *Effects:* Computes a vector y' such that y' = A y, and assigns each
271
+ element of y' to the corresponding element of y.
272
+
273
+ *Complexity:* 𝑂(`y.extent(0)` × `A.extent(1)`).
274
+
275
+ ``` cpp
276
+ template<in-matrix InMat, class Triangle, class DiagonalStorage,
277
+ in-vector InVec1, in-vector InVec2, out-vector OutVec>
278
+ void triangular_matrix_vector_product(InMat A, Triangle t, DiagonalStorage d,
279
+ InVec1 x, InVec2 y, OutVec z);
280
+ template<class ExecutionPolicy, in-matrix InMat, class Triangle, class DiagonalStorage,
281
+ in-vector InVec1, in-vector InVec2, out-vector OutVec>
282
+ void triangular_matrix_vector_product(ExecutionPolicy&& exec,
283
+ InMat A, Triangle t, DiagonalStorage d,
284
+ InVec1 x, InVec2 y, OutVec z);
285
+ ```
286
+
287
+ These functions perform an updating triangular matrix-vector product,
288
+ taking into account the `Triangle` and `DiagonalStorage` parameters that
289
+ apply to the triangular matrix `A` [[linalg.general]].
290
+
291
+ *Effects:* Computes z = y + A x.
292
+
293
+ *Complexity:* 𝑂(`x.extent(0)` × `A.extent(1)`).
294
+
295
+ *Remarks:* `z` may alias `y`.
296
+
297
+ #### Solve a triangular linear system <a id="linalg.algs.blas2.trsv">[[linalg.algs.blas2.trsv]]</a>
298
+
299
+ [*Note 1*: These functions correspond to the BLAS functions `xTRSV` and
300
+ `xTPSV`. — *end note*]
301
+
302
+ The following elements apply to all functions in
303
+ [[linalg.algs.blas2.trsv]].
304
+
305
+ *Mandates:*
306
+
307
+ - If `InMat` has `layout_blas_packed` layout, then the layout’s
308
+ `Triangle` template argument has the same type as the function’s
309
+ `Triangle` template argument;
310
+ - `compatible-static-extents<decltype(A), decltype(A)>(0, 1)` is `true`;
311
+ - `compatible-static-extents<decltype(A), decltype(b)>(0, 0)` is `true`;
312
+ and
313
+ - `compatible-static-extents<decltype(A), decltype(x)>(0, 0)` is `true`
314
+ for those overloads that take an `x` parameter.
315
+
316
+ *Preconditions:*
317
+
318
+ - `A.extent(0)` equals `A.extent(1)`,
319
+ - `A.extent(0)` equals `b.extent(0)`, and
320
+ - `A.extent(0)` equals `x.extent(0)` for those overloads that take an
321
+ `x` parameter.
322
+
323
+ ``` cpp
324
+ template<in-matrix InMat, class Triangle, class DiagonalStorage,
325
+ in-vector InVec, out-vector OutVec, class BinaryDivideOp>
326
+ void triangular_matrix_vector_solve(InMat A, Triangle t, DiagonalStorage d,
327
+ InVec b, OutVec x, BinaryDivideOp divide);
328
+ template<class ExecutionPolicy, in-matrix InMat, class Triangle, class DiagonalStorage,
329
+ in-vector InVec, out-vector OutVec, class BinaryDivideOp>
330
+ void triangular_matrix_vector_solve(ExecutionPolicy&& exec,
331
+ InMat A, Triangle t, DiagonalStorage d,
332
+ InVec b, OutVec x, BinaryDivideOp divide);
333
+ ```
334
+
335
+ These functions perform a triangular solve, taking into account the
336
+ `Triangle` and `DiagonalStorage` parameters that apply to the triangular
337
+ matrix `A` [[linalg.general]].
338
+
339
+ *Effects:* Computes a vector x' such that b = A x', and assigns each
340
+ element of x' to the corresponding element of x. If no such x' exists,
341
+ then the elements of `x` are valid but unspecified.
342
+
343
+ *Complexity:* 𝑂(`A.extent(1)` × `b.extent(0)`).
344
+
345
+ ``` cpp
346
+ template<in-matrix InMat, class Triangle, class DiagonalStorage,
347
+ in-vector InVec, out-vector OutVec>
348
+ void triangular_matrix_vector_solve(InMat A, Triangle t, DiagonalStorage d, InVec b, OutVec x);
349
+ ```
350
+
351
+ *Effects:* Equivalent to:
352
+
353
+ ``` cpp
354
+ triangular_matrix_vector_solve(A, t, d, b, x, divides<void>{});
355
+ ```
356
+
357
+ ``` cpp
358
+ template<class ExecutionPolicy, in-matrix InMat, class Triangle, class DiagonalStorage,
359
+ in-vector InVec, out-vector OutVec>
360
+ void triangular_matrix_vector_solve(ExecutionPolicy&& exec,
361
+ InMat A, Triangle t, DiagonalStorage d, InVec b, OutVec x);
362
+ ```
363
+
364
+ *Effects:* Equivalent to:
365
+
366
+ ``` cpp
367
+ triangular_matrix_vector_solve(std::forward<ExecutionPolicy>(exec),
368
+ A, t, d, b, x, divides<void>{});
369
+ ```
370
+
371
+ ``` cpp
372
+ template<in-matrix InMat, class Triangle, class DiagonalStorage,
373
+ inout-vector InOutVec, class BinaryDivideOp>
374
+ void triangular_matrix_vector_solve(InMat A, Triangle t, DiagonalStorage d,
375
+ InOutVec b, BinaryDivideOp divide);
376
+ template<class ExecutionPolicy, in-matrix InMat, class Triangle, class DiagonalStorage,
377
+ inout-vector InOutVec, class BinaryDivideOp>
378
+ void triangular_matrix_vector_solve(ExecutionPolicy&& exec,
379
+ InMat A, Triangle t, DiagonalStorage d,
380
+ InOutVec b, BinaryDivideOp divide);
381
+ ```
382
+
383
+ These functions perform an in-place triangular solve, taking into
384
+ account the `Triangle` and `DiagonalStorage` parameters that apply to
385
+ the triangular matrix `A` [[linalg.general]].
386
+
387
+ [*Note 1*: Performing triangular solve in place hinders
388
+ parallelization. However, other `ExecutionPolicy` specific
389
+ optimizations, such as vectorization, are still possible. — *end note*]
390
+
391
+ *Effects:* Computes a vector x' such that b = A x', and assigns each
392
+ element of x' to the corresponding element of b. If no such x' exists,
393
+ then the elements of `b` are valid but unspecified.
394
+
395
+ *Complexity:* 𝑂(`A.extent(1)` × `b.extent(0)`).
396
+
397
+ ``` cpp
398
+ template<in-matrix InMat, class Triangle, class DiagonalStorage, inout-vector InOutVec>
399
+ void triangular_matrix_vector_solve(InMat A, Triangle t, DiagonalStorage d, InOutVec b);
400
+ ```
401
+
402
+ *Effects:* Equivalent to:
403
+
404
+ ``` cpp
405
+ triangular_matrix_vector_solve(A, t, d, b, divides<void>{});
406
+ ```
407
+
408
+ ``` cpp
409
+ template<class ExecutionPolicy,
410
+ in-matrix InMat, class Triangle, class DiagonalStorage, inout-vector InOutVec>
411
+ void triangular_matrix_vector_solve(ExecutionPolicy&& exec,
412
+ InMat A, Triangle t, DiagonalStorage d, InOutVec b);
413
+ ```
414
+
415
+ *Effects:* Equivalent to:
416
+
417
+ ``` cpp
418
+ triangular_matrix_vector_solve(std::forward<ExecutionPolicy>(exec),
419
+ A, t, d, b, divides<void>{});
420
+ ```
421
+
422
+ #### Rank-1 (outer product) update of a matrix <a id="linalg.algs.blas2.rank1">[[linalg.algs.blas2.rank1]]</a>
423
+
424
+ ``` cpp
425
+ template<in-vector InVec1, in-vector InVec2, inout-matrix InOutMat>
426
+ void matrix_rank_1_update(InVec1 x, InVec2 y, InOutMat A);
427
+ template<class ExecutionPolicy, in-vector InVec1, in-vector InVec2, inout-matrix InOutMat>
428
+ void matrix_rank_1_update(ExecutionPolicy&& exec, InVec1 x, InVec2 y, InOutMat A);
429
+ ```
430
+
431
+ These functions perform a nonsymmetric nonconjugated rank-1 update.
432
+
433
+ [*Note 1*: These functions correspond to the BLAS functions `xGER` (for
434
+ real element types) and `xGERU` (for complex element
435
+ types). — *end note*]
436
+
437
+ *Mandates:* *`possibly-multipliable`*`<InOutMat, InVec2, InVec1>()` is
438
+ `true`.
439
+
440
+ *Preconditions:* *`multipliable`*`(A, y, x)` is `true`.
441
+
442
+ *Effects:* Computes a matrix A' such that $A' = A + x y^T$, and assigns
443
+ each element of A' to the corresponding element of A.
444
+
445
+ *Complexity:* 𝑂(`x.extent(0)` × `y.extent(0)`).
446
+
447
+ ``` cpp
448
+ template<in-vector InVec1, in-vector InVec2, inout-matrix InOutMat>
449
+ void matrix_rank_1_update_c(InVec1 x, InVec2 y, InOutMat A);
450
+ template<class ExecutionPolicy, in-vector InVec1, in-vector InVec2, inout-matrix InOutMat>
451
+ void matrix_rank_1_update_c(ExecutionPolicy&& exec, InVec1 x, InVec2 y, InOutMat A);
452
+ ```
453
+
454
+ These functions perform a nonsymmetric conjugated rank-1 update.
455
+
456
+ [*Note 2*: These functions correspond to the BLAS functions `xGER` (for
457
+ real element types) and `xGERC` (for complex element
458
+ types). — *end note*]
459
+
460
+ *Effects:*
461
+
462
+ - For the overloads without an `ExecutionPolicy` argument, equivalent
463
+ to:
464
+ ``` cpp
465
+ matrix_rank_1_update(x, conjugated(y), A);
466
+ ```
467
+ - otherwise, equivalent to:
468
+ ``` cpp
469
+ matrix_rank_1_update(std::forward<ExecutionPolicy>(exec), x, conjugated(y), A);
470
+ ```
471
+
472
+ #### Symmetric or Hermitian Rank-1 (outer product) update of a matrix <a id="linalg.algs.blas2.symherrank1">[[linalg.algs.blas2.symherrank1]]</a>
473
+
474
+ [*Note 1*: These functions correspond to the BLAS functions `xSYR`,
475
+ `xSPR`, `xHER`, and `xHPR`. They have overloads taking a scaling factor
476
+ `alpha`, because it would be impossible to express the update
477
+ $A = A - x x^T$ otherwise. — *end note*]
478
+
479
+ The following elements apply to all functions in
480
+ [[linalg.algs.blas2.symherrank1]].
481
+
482
+ *Mandates:*
483
+
484
+ - If `InOutMat` has `layout_blas_packed` layout, then the layout’s
485
+ `Triangle` template argument has the same type as the function’s
486
+ `Triangle` template argument;
487
+ - `compatible-static-extents<decltype(A), decltype(A)>(0, 1)` is `true`;
488
+ and
489
+ - `compatible-static-extents<decltype(A), decltype(x)>(0, 0)` is `true`.
490
+
491
+ *Preconditions:*
492
+
493
+ - `A.extent(0)` equals `A.extent(1)`, and
494
+ - `A.extent(0)` equals `x.extent(0)`.
495
+
496
+ *Complexity:* 𝑂(`x.extent(0)` × `x.extent(0)`).
497
+
498
+ ``` cpp
499
+ template<class Scalar, in-vector InVec, possibly-packed-inout-matrix InOutMat, class Triangle>
500
+ void symmetric_matrix_rank_1_update(Scalar alpha, InVec x, InOutMat A, Triangle t);
501
+ template<class ExecutionPolicy,
502
+ class Scalar, in-vector InVec, possibly-packed-inout-matrix InOutMat, class Triangle>
503
+ void symmetric_matrix_rank_1_update(ExecutionPolicy&& exec,
504
+ Scalar alpha, InVec x, InOutMat A, Triangle t);
505
+ ```
506
+
507
+ These functions perform a symmetric rank-1 update of the symmetric
508
+ matrix `A`, taking into account the `Triangle` parameter that applies to
509
+ `A` [[linalg.general]].
510
+
511
+ *Effects:* Computes a matrix A' such that $A' = A + \alpha x x^T$, where
512
+ the scalar α is `alpha`, and assigns each element of A' to the
513
+ corresponding element of A.
514
+
515
+ ``` cpp
516
+ template<in-vector InVec, possibly-packed-inout-matrix InOutMat, class Triangle>
517
+ void symmetric_matrix_rank_1_update(InVec x, InOutMat A, Triangle t);
518
+ template<class ExecutionPolicy,
519
+ in-vector InVec, possibly-packed-inout-matrix InOutMat, class Triangle>
520
+ void symmetric_matrix_rank_1_update(ExecutionPolicy&& exec, InVec x, InOutMat A, Triangle t);
521
+ ```
522
+
523
+ These functions perform a symmetric rank-1 update of the symmetric
524
+ matrix `A`, taking into account the `Triangle` parameter that applies to
525
+ `A` [[linalg.general]].
526
+
527
+ *Effects:* Computes a matrix A' such that $A' = A + x x^T$ and assigns
528
+ each element of A' to the corresponding element of A.
529
+
530
+ ``` cpp
531
+ template<class Scalar, in-vector InVec, possibly-packed-inout-matrix InOutMat, class Triangle>
532
+ void hermitian_matrix_rank_1_update(Scalar alpha, InVec x, InOutMat A, Triangle t);
533
+ template<class ExecutionPolicy,
534
+ class Scalar, in-vector InVec, possibly-packed-inout-matrix InOutMat, class Triangle>
535
+ void hermitian_matrix_rank_1_update(ExecutionPolicy&& exec,
536
+ Scalar alpha, InVec x, InOutMat A, Triangle t);
537
+ ```
538
+
539
+ These functions perform a Hermitian rank-1 update of the Hermitian
540
+ matrix `A`, taking into account the `Triangle` parameter that applies to
541
+ `A` [[linalg.general]].
542
+
543
+ *Effects:* Computes A' such that $A' = A + \alpha x x^H$, where the
544
+ scalar α is `alpha`, and assigns each element of A' to the corresponding
545
+ element of A.
546
+
547
+ ``` cpp
548
+ template<in-vector InVec, possibly-packed-inout-matrix InOutMat, class Triangle>
549
+ void hermitian_matrix_rank_1_update(InVec x, InOutMat A, Triangle t);
550
+ template<class ExecutionPolicy,
551
+ in-vector InVec, possibly-packed-inout-matrix InOutMat, class Triangle>
552
+ void hermitian_matrix_rank_1_update(ExecutionPolicy&& exec, InVec x, InOutMat A, Triangle t);
553
+ ```
554
+
555
+ These functions perform a Hermitian rank-1 update of the Hermitian
556
+ matrix `A`, taking into account the `Triangle` parameter that applies to
557
+ `A` [[linalg.general]].
558
+
559
+ *Effects:* Computes a matrix A' such that $A' = A + x x^H$ and assigns
560
+ each element of A' to the corresponding element of A.
561
+
562
+ #### Symmetric and Hermitian rank-2 matrix updates <a id="linalg.algs.blas2.rank2">[[linalg.algs.blas2.rank2]]</a>
563
+
564
+ [*Note 1*: These functions correspond to the BLAS functions
565
+ `xSYR2`,`xSPR2`, `xHER2` and `xHPR2`. — *end note*]
566
+
567
+ The following elements apply to all functions in
568
+ [[linalg.algs.blas2.rank2]].
569
+
570
+ *Mandates:*
571
+
572
+ - If `InOutMat` has `layout_blas_packed` layout, then the layout’s
573
+ `Triangle` template argument has the same type as the function’s
574
+ `Triangle` template argument;
575
+ - `compatible-static-extents<decltype(A), decltype(A)>(0, 1)` is `true`;
576
+ and
577
+ - `possibly-multipliable<decltype(A), decltype(x), decltype(y)>()` is
578
+ `true`.
579
+
580
+ *Preconditions:*
581
+
582
+ - `A.extent(0)` equals `A.extent(1)`, and
583
+ - `multipliable(A, x, y)` is `true`.
584
+
585
+ *Complexity:* 𝑂(`x.extent(0)` × `y.extent(0)`).
586
+
587
+ ``` cpp
588
+ template<in-vector InVec1, in-vector InVec2,
589
+ possibly-packed-inout-matrix InOutMat, class Triangle>
590
+ void symmetric_matrix_rank_2_update(InVec1 x, InVec2 y, InOutMat A, Triangle t);
591
+ template<class ExecutionPolicy, in-vector InVec1, in-vector InVec2,
592
+ possibly-packed-inout-matrix InOutMat, class Triangle>
593
+ void symmetric_matrix_rank_2_update(ExecutionPolicy&& exec,
594
+ InVec1 x, InVec2 y, InOutMat A, Triangle t);
595
+ ```
596
+
597
+ These functions perform a symmetric rank-2 update of the symmetric
598
+ matrix `A`, taking into account the `Triangle` parameter that applies to
599
+ `A` [[linalg.general]].
600
+
601
+ *Effects:* Computes A' such that $A' = A + x y^T + y x^T$ and assigns
602
+ each element of A' to the corresponding element of A.
603
+
604
+ ``` cpp
605
+ template<in-vector InVec1, in-vector InVec2,
606
+ possibly-packed-inout-matrix InOutMat, class Triangle>
607
+ void hermitian_matrix_rank_2_update(InVec1 x, InVec2 y, InOutMat A, Triangle t);
608
+ template<class ExecutionPolicy, in-vector InVec1, in-vector InVec2,
609
+ possibly-packed-inout-matrix InOutMat, class Triangle>
610
+ void hermitian_matrix_rank_2_update(ExecutionPolicy&& exec,
611
+ InVec1 x, InVec2 y, InOutMat A, Triangle t);
612
+ ```
613
+
614
+ These functions perform a Hermitian rank-2 update of the Hermitian
615
+ matrix `A`, taking into account the `Triangle` parameter that applies to
616
+ `A` [[linalg.general]].
617
+
618
+ *Effects:* Computes A' such that $A' = A + x y^H + y x^H$ and assigns
619
+ each element of A' to the corresponding element of A.
620
+