forked from uxlfoundation/oneMath
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreference_blas_templates.hpp
More file actions
1660 lines (1429 loc) · 69.5 KB
/
Copy pathreference_blas_templates.hpp
File metadata and controls
1660 lines (1429 loc) · 69.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*******************************************************************************
* Copyright 2020-2021 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
*
*
* SPDX-License-Identifier: Apache-2.0
*******************************************************************************/
#ifndef _REFERENCE_BLAS_TEMPLATES_HPP__
#define _REFERENCE_BLAS_TEMPLATES_HPP__
#include <stdlib.h>
#include <complex>
#include "cblas.h"
#include "test_helper.hpp"
#ifdef __linux__
#include <dlfcn.h>
#define LIB_TYPE void *
#define GET_LIB_HANDLE(libname) dlopen((libname), RTLD_LAZY | RTLD_GLOBAL)
#define GET_FUNC(lib, fn) dlsym(lib, (fn))
#elif defined(_WIN64)
#include <windows.h>
#define LIB_TYPE HINSTANCE
#define GET_LIB_HANDLE(libname) LoadLibrary(libname)
#define GET_FUNC(lib, fn) GetProcAddress((lib), (fn))
#endif
extern "C" {
static LIB_TYPE h = NULL;
static void (*csrot_p)(const int *N, void *X, const int *incX, void *Y, const int *incY,
const float *c, const float *s);
static void (*zdrot_p)(const int *N, void *X, const int *incX, void *Y, const int *incY,
const double *c, const double *s);
static void (*crotg_p)(void *a, void *b, const float *c, void *s);
static void (*zrotg_p)(void *a, void *b, const double *c, void *s);
static LIB_TYPE cblas_library() {
if (h == NULL) {
#ifdef _WIN64
h = GET_LIB_HANDLE("libblas.dll");
if (h == NULL)
h = GET_LIB_HANDLE("blas.dll");
#else
h = GET_LIB_HANDLE("libblas.so");
#endif
}
return h;
}
static void csrot_wrapper(const int *N, void *X, const int *incX, void *Y, const int *incY,
const float *c, const float *s) {
if (cblas_library() != NULL) {
if (csrot_p == NULL)
csrot_p = (void (*)(const int *N, void *X, const int *incX, void *Y, const int *incY,
const float *c, const float *s))GET_FUNC(h, "csrot_");
if (csrot_p == NULL)
csrot_p = (void (*)(const int *N, void *X, const int *incX, void *Y, const int *incY,
const float *c, const float *s))GET_FUNC(h, "CSROT");
if (csrot_p != NULL)
csrot_p(N, X, incX, Y, incY, c, s);
}
}
static void zdrot_wrapper(const int *N, void *X, const int *incX, void *Y, const int *incY,
const double *c, const double *s) {
if (cblas_library() != NULL) {
if (zdrot_p == NULL)
zdrot_p = (void (*)(const int *N, void *X, const int *incX, void *Y, const int *incY,
const double *c, const double *s))GET_FUNC(h, "zdrot_");
if (zdrot_p == NULL)
zdrot_p = (void (*)(const int *N, void *X, const int *incX, void *Y, const int *incY,
const double *c, const double *s))GET_FUNC(h, "ZDROT");
if (zdrot_p != NULL)
zdrot_p(N, X, incX, Y, incY, c, s);
}
}
static void crotg_wrapper(void *a, void *b, const float *c, void *s) {
if (cblas_library() != NULL) {
if (crotg_p == NULL)
crotg_p = (void (*)(void *a, void *b, const float *c, void *s))GET_FUNC(h, "crotg_");
if (crotg_p == NULL)
crotg_p = (void (*)(void *a, void *b, const float *c, void *s))GET_FUNC(h, "CROTG");
if (crotg_p != NULL)
crotg_p(a, b, c, s);
}
}
static void zrotg_wrapper(void *a, void *b, const double *c, void *s) {
if (cblas_library() != NULL) {
if (zrotg_p == NULL)
zrotg_p = (void (*)(void *a, void *b, const double *c, void *s))GET_FUNC(h, "zrotg_");
if (zrotg_p == NULL)
zrotg_p = (void (*)(void *a, void *b, const double *c, void *s))GET_FUNC(h, "ZROTG");
if (zrotg_p != NULL)
zrotg_p(a, b, c, s);
}
}
}
inline bool isNonTranspose(CBLAS_TRANSPOSE trans) {
return trans == CblasNoTrans;
}
template <typename T_src, typename T_dest>
static inline void copy_mat(T_src &src, CBLAS_LAYOUT layout, CBLAS_TRANSPOSE trans, int row,
int col, int ld, T_dest *&dest) {
int i, j, Iend, Jend;
if (layout == CblasColMajor) {
Jend = isNonTranspose(trans) ? col : row;
Iend = isNonTranspose(trans) ? row : col;
}
else {
Jend = isNonTranspose(trans) ? row : col;
Iend = isNonTranspose(trans) ? col : row;
}
for (j = 0; j < Jend; j++) {
for (i = 0; i < Iend; i++) {
dest[i + ld * j] = (T_dest)src[i + ld * j];
}
}
}
template <typename T_src, typename T_dest>
static inline void copy_mat(T_src &src, CBLAS_LAYOUT layout, CBLAS_TRANSPOSE trans, int row,
int col, int ld, T_dest off, T_dest *&dest) {
int i, j, Iend, Jend;
if (layout == CblasColMajor) {
Jend = isNonTranspose(trans) ? col : row;
Iend = isNonTranspose(trans) ? row : col;
}
else {
Jend = isNonTranspose(trans) ? row : col;
Iend = isNonTranspose(trans) ? col : row;
}
for (j = 0; j < Jend; j++) {
for (i = 0; i < Iend; i++) {
dest[i + ld * j] = (T_dest)src[i + ld * j] - off;
}
}
}
template <typename T_src, typename T_dest, typename T_off>
static inline void copy_mat(T_src &src, CBLAS_LAYOUT layout, int row, int col, int ld,
CBLAS_OFFSET off_kind, T_off off, T_dest &dest) {
using T_data = typename std::remove_reference<decltype(dest[0])>::type;
int i, j;
T_data tmp;
int Jend = (layout == CblasColMajor) ? col : row;
int Iend = (layout == CblasColMajor) ? row : col;
if (off_kind == CblasFixOffset) {
tmp = off[0];
for (j = 0; j < Jend; j++) {
for (i = 0; i < Iend; i++) {
dest[i + ld * j] = tmp + (T_data)src[i + ld * j];
}
}
}
else if (((off_kind == CblasColOffset) && (layout == CblasColMajor)) ||
((off_kind == CblasRowOffset) && (layout == CblasRowMajor))) {
for (j = 0; j < Jend; j++) {
for (i = 0; i < Iend; i++) {
tmp = off[i];
dest[i + ld * j] = tmp + (T_data)src[i + ld * j];
}
}
}
else {
for (j = 0; j < Jend; j++) {
tmp = off[j];
for (i = 0; i < Iend; i++) {
dest[i + ld * j] = tmp + (T_data)src[i + ld * j];
}
}
}
}
template <typename T_src, typename T_desc>
static inline void update_c(T_src &src, CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, int row,
int col, int ld, T_desc *&dest) {
int i, j;
int Jend = (layout == CblasColMajor) ? col : row;
int Iend = (layout == CblasColMajor) ? row : col;
for (j = 0; j < Jend; j++) {
for (i = 0; i < Iend; i++) {
if (((upper_lower == CblasUpper) && (layout == CblasColMajor)) ||
((upper_lower == CblasLower) && (layout == CblasRowMajor))) {
if (j >= i)
dest[i + ld * j] = (T_desc)src[i + ld * j];
else
dest[i + ld * j] = (T_desc)0.0;
}
else {
if (j <= i)
dest[i + ld * j] = (T_desc)src[i + ld * j];
else
dest[i + ld * j] = (T_desc)0.0;
}
}
}
}
/* Level 3 */
template <typename fp>
static void gemm(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE transa, CBLAS_TRANSPOSE transb, const int *m,
const int *n, const int *k, const fp *alpha, const fp *a, const int *lda,
const fp *b, const int *ldb, const fp *beta, fp *c, const int *ldc);
#ifdef NOT_HIPSYCL
template <>
void gemm(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE transa, CBLAS_TRANSPOSE transb, const int *m,
const int *n, const int *k, const half *alpha, const half *a, const int *lda,
const half *b, const int *ldb, const half *beta, half *c, const int *ldc) {
// Not supported in NETLIB. SGEMM is used as reference.
int sizea, sizeb, sizec;
const float alphaf = *alpha;
const float betaf = *beta;
if (layout == CblasColMajor) {
sizea = (transa == CblasNoTrans) ? *lda * *k : *lda * *m;
sizeb = (transb == CblasNoTrans) ? *ldb * *n : *ldb * *k;
sizec = *ldc * *n;
}
else {
sizea = (transa == CblasNoTrans) ? *lda * *m : *lda * *k;
sizeb = (transb == CblasNoTrans) ? *ldb * *k : *ldb * *n;
sizec = *ldc * *m;
}
float *af = (float *)oneapi::mkl::aligned_alloc(64, sizeof(float) * sizea);
float *bf = (float *)oneapi::mkl::aligned_alloc(64, sizeof(float) * sizeb);
float *cf = (float *)oneapi::mkl::aligned_alloc(64, sizeof(float) * sizec);
copy_mat(a, layout, transa, *m, *k, *lda, af);
copy_mat(b, layout, transb, *k, *n, *ldb, bf);
copy_mat(c, layout, CblasNoTrans, *m, *n, *ldc, cf);
cblas_sgemm(layout, transa, transb, *m, *n, *k, alphaf, af, *lda, bf, *ldb, betaf, cf, *ldc);
copy_mat(cf, layout, CblasNoTrans, *m, *n, *ldc, c);
oneapi::mkl::aligned_free(af);
oneapi::mkl::aligned_free(bf);
oneapi::mkl::aligned_free(cf);
}
#endif
template <>
void gemm(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE transa, CBLAS_TRANSPOSE transb, const int *m,
const int *n, const int *k, const float *alpha, const float *a, const int *lda,
const float *b, const int *ldb, const float *beta, float *c, const int *ldc) {
cblas_sgemm(layout, transa, transb, *m, *n, *k, *alpha, a, *lda, b, *ldb, *beta, c, *ldc);
}
template <>
void gemm(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE transa, CBLAS_TRANSPOSE transb, const int *m,
const int *n, const int *k, const double *alpha, const double *a, const int *lda,
const double *b, const int *ldb, const double *beta, double *c, const int *ldc) {
cblas_dgemm(layout, transa, transb, *m, *n, *k, *alpha, a, *lda, b, *ldb, *beta, c, *ldc);
}
template <>
void gemm(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE transa, CBLAS_TRANSPOSE transb, const int *m,
const int *n, const int *k, const std::complex<float> *alpha,
const std::complex<float> *a, const int *lda, const std::complex<float> *b,
const int *ldb, const std::complex<float> *beta, std::complex<float> *c, const int *ldc) {
cblas_cgemm(layout, transa, transb, *m, *n, *k, alpha, a, *lda, b, *ldb, beta, c, *ldc);
}
template <>
void gemm(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE transa, CBLAS_TRANSPOSE transb, const int *m,
const int *n, const int *k, const std::complex<double> *alpha,
const std::complex<double> *a, const int *lda, const std::complex<double> *b,
const int *ldb, const std::complex<double> *beta, std::complex<double> *c,
const int *ldc) {
cblas_zgemm(layout, transa, transb, *m, *n, *k, alpha, a, *lda, b, *ldb, beta, c, *ldc);
}
template <typename fpa, typename fpc>
static void gemm(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE transa, CBLAS_TRANSPOSE transb, const int *m,
const int *n, const int *k, const fpc *alpha, const fpa *a, const int *lda,
const fpa *b, const int *ldb, const fpc *beta, fpc *c, const int *ldc);
#ifdef NOT_HIPSYCL
template <>
void gemm(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE transa, CBLAS_TRANSPOSE transb, const int *m,
const int *n, const int *k, const float *alpha, const half *a, const int *lda,
const half *b, const int *ldb, const float *beta, float *c, const int *ldc) {
// Not supported in NETLIB. SGEMM is used as reference.
int sizea, sizeb;
if (layout == CblasColMajor) {
sizea = (transa == CblasNoTrans) ? *lda * *k : *lda * *m;
sizeb = (transb == CblasNoTrans) ? *ldb * *n : *ldb * *k;
}
else {
sizea = (transa == CblasNoTrans) ? *lda * *m : *lda * *k;
sizeb = (transb == CblasNoTrans) ? *ldb * *k : *ldb * *n;
}
float *af = (float *)oneapi::mkl::aligned_alloc(64, sizeof(float) * sizea);
float *bf = (float *)oneapi::mkl::aligned_alloc(64, sizeof(float) * sizeb);
copy_mat(a, layout, transa, *m, *k, *lda, af);
copy_mat(b, layout, transb, *k, *n, *ldb, bf);
cblas_sgemm(layout, transa, transb, *m, *n, *k, *alpha, af, *lda, bf, *ldb, *beta, c, *ldc);
oneapi::mkl::aligned_free(af);
oneapi::mkl::aligned_free(bf);
}
#endif
template <typename fp>
static void symm(CBLAS_LAYOUT layout, CBLAS_SIDE left_right, CBLAS_UPLO uplo, const int *m,
const int *n, const fp *alpha, const fp *a, const int *lda, const fp *b,
const int *ldb, const fp *beta, fp *c, const int *ldc);
template <>
void symm(CBLAS_LAYOUT layout, CBLAS_SIDE left_right, CBLAS_UPLO uplo, const int *m, const int *n,
const float *alpha, const float *a, const int *lda, const float *b, const int *ldb,
const float *beta, float *c, const int *ldc) {
cblas_ssymm(layout, left_right, uplo, *m, *n, *alpha, a, *lda, b, *ldb, *beta, c, *ldc);
}
template <>
void symm(CBLAS_LAYOUT layout, CBLAS_SIDE left_right, CBLAS_UPLO uplo, const int *m, const int *n,
const double *alpha, const double *a, const int *lda, const double *b, const int *ldb,
const double *beta, double *c, const int *ldc) {
cblas_dsymm(layout, left_right, uplo, *m, *n, *alpha, a, *lda, b, *ldb, *beta, c, *ldc);
}
template <>
void symm(CBLAS_LAYOUT layout, CBLAS_SIDE left_right, CBLAS_UPLO uplo, const int *m, const int *n,
const std::complex<float> *alpha, const std::complex<float> *a, const int *lda,
const std::complex<float> *b, const int *ldb, const std::complex<float> *beta,
std::complex<float> *c, const int *ldc) {
cblas_csymm(layout, left_right, uplo, *m, *n, alpha, a, *lda, b, *ldb, beta, c, *ldc);
}
template <>
void symm(CBLAS_LAYOUT layout, CBLAS_SIDE left_right, CBLAS_UPLO uplo, const int *m, const int *n,
const std::complex<double> *alpha, const std::complex<double> *a, const int *lda,
const std::complex<double> *b, const int *ldb, const std::complex<double> *beta,
std::complex<double> *c, const int *ldc) {
cblas_zsymm(layout, left_right, uplo, *m, *n, alpha, a, *lda, b, *ldb, beta, c, *ldc);
}
template <typename fp>
static void syrk(CBLAS_LAYOUT layout, CBLAS_UPLO uplo, CBLAS_TRANSPOSE trans, const int *n,
const int *k, const fp *alpha, const fp *a, const int *lda, const fp *beta, fp *c,
const int *ldc);
template <>
void syrk(CBLAS_LAYOUT layout, CBLAS_UPLO uplo, CBLAS_TRANSPOSE trans, const int *n, const int *k,
const float *alpha, const float *a, const int *lda, const float *beta, float *c,
const int *ldc) {
cblas_ssyrk(layout, uplo, trans, *n, *k, *alpha, a, *lda, *beta, c, *ldc);
}
template <>
void syrk(CBLAS_LAYOUT layout, CBLAS_UPLO uplo, CBLAS_TRANSPOSE trans, const int *n, const int *k,
const double *alpha, const double *a, const int *lda, const double *beta, double *c,
const int *ldc) {
cblas_dsyrk(layout, uplo, trans, *n, *k, *alpha, a, *lda, *beta, c, *ldc);
}
template <>
void syrk(CBLAS_LAYOUT layout, CBLAS_UPLO uplo, CBLAS_TRANSPOSE trans, const int *n, const int *k,
const std::complex<float> *alpha, const std::complex<float> *a, const int *lda,
const std::complex<float> *beta, std::complex<float> *c, const int *ldc) {
cblas_csyrk(layout, uplo, trans, *n, *k, alpha, a, *lda, beta, c, *ldc);
}
template <>
void syrk(CBLAS_LAYOUT layout, CBLAS_UPLO uplo, CBLAS_TRANSPOSE trans, const int *n, const int *k,
const std::complex<double> *alpha, const std::complex<double> *a, const int *lda,
const std::complex<double> *beta, std::complex<double> *c, const int *ldc) {
cblas_zsyrk(layout, uplo, trans, *n, *k, alpha, a, *lda, beta, c, *ldc);
}
template <typename fp>
static void hemm(CBLAS_LAYOUT layout, CBLAS_SIDE left_right, CBLAS_UPLO uplo, const int *m,
const int *n, const fp *alpha, const fp *a, const int *lda, const fp *b,
const int *ldb, const fp *beta, fp *c, const int *ldc);
template <>
void hemm(CBLAS_LAYOUT layout, CBLAS_SIDE left_right, CBLAS_UPLO uplo, const int *m, const int *n,
const std::complex<float> *alpha, const std::complex<float> *a, const int *lda,
const std::complex<float> *b, const int *ldb, const std::complex<float> *beta,
std::complex<float> *c, const int *ldc) {
cblas_chemm(layout, left_right, uplo, *m, *n, alpha, a, *lda, b, *ldb, beta, c, *ldc);
}
template <>
void hemm(CBLAS_LAYOUT layout, CBLAS_SIDE left_right, CBLAS_UPLO uplo, const int *m, const int *n,
const std::complex<double> *alpha, const std::complex<double> *a, const int *lda,
const std::complex<double> *b, const int *ldb, const std::complex<double> *beta,
std::complex<double> *c, const int *ldc) {
cblas_zhemm(layout, left_right, uplo, *m, *n, alpha, a, *lda, b, *ldb, beta, c, *ldc);
}
template <typename fp_scalar, typename fp_data>
static void herk(CBLAS_LAYOUT layout, CBLAS_UPLO uplo, CBLAS_TRANSPOSE trans, const int *n,
const int *k, const fp_scalar *alpha, const fp_data *a, const int *lda,
const fp_scalar *beta, fp_data *c, const int *ldc);
template <>
void herk(CBLAS_LAYOUT layout, CBLAS_UPLO uplo, CBLAS_TRANSPOSE trans, const int *n, const int *k,
const float *alpha, const std::complex<float> *a, const int *lda, const float *beta,
std::complex<float> *c, const int *ldc) {
cblas_cherk(layout, uplo, trans, *n, *k, *alpha, a, *lda, *beta, c, *ldc);
}
template <>
void herk(CBLAS_LAYOUT layout, CBLAS_UPLO uplo, CBLAS_TRANSPOSE trans, const int *n, const int *k,
const double *alpha, const std::complex<double> *a, const int *lda, const double *beta,
std::complex<double> *c, const int *ldc) {
cblas_zherk(layout, uplo, trans, *n, *k, *alpha, a, *lda, *beta, c, *ldc);
}
template <typename fp>
static void syr2k(CBLAS_LAYOUT layout, CBLAS_UPLO uplo, CBLAS_TRANSPOSE trans, const int *n,
const int *k, const fp *alpha, const fp *a, const int *lda, const fp *b,
const int *ldb, const fp *beta, fp *c, const int *ldc);
template <>
void syr2k(CBLAS_LAYOUT layout, CBLAS_UPLO uplo, CBLAS_TRANSPOSE trans, const int *n, const int *k,
const float *alpha, const float *a, const int *lda, const float *b, const int *ldb,
const float *beta, float *c, const int *ldc) {
cblas_ssyr2k(layout, uplo, trans, *n, *k, *alpha, a, *lda, b, *ldb, *beta, c, *ldc);
}
template <>
void syr2k(CBLAS_LAYOUT layout, CBLAS_UPLO uplo, CBLAS_TRANSPOSE trans, const int *n, const int *k,
const double *alpha, const double *a, const int *lda, const double *b, const int *ldb,
const double *beta, double *c, const int *ldc) {
cblas_dsyr2k(layout, uplo, trans, *n, *k, *alpha, a, *lda, b, *ldb, *beta, c, *ldc);
}
template <>
void syr2k(CBLAS_LAYOUT layout, CBLAS_UPLO uplo, CBLAS_TRANSPOSE trans, const int *n, const int *k,
const std::complex<float> *alpha, const std::complex<float> *a, const int *lda,
const std::complex<float> *b, const int *ldb, const std::complex<float> *beta,
std::complex<float> *c, const int *ldc) {
cblas_csyr2k(layout, uplo, trans, *n, *k, alpha, a, *lda, b, *ldb, beta, c, *ldc);
}
template <>
void syr2k(CBLAS_LAYOUT layout, CBLAS_UPLO uplo, CBLAS_TRANSPOSE trans, const int *n, const int *k,
const std::complex<double> *alpha, const std::complex<double> *a, const int *lda,
const std::complex<double> *b, const int *ldb, const std::complex<double> *beta,
std::complex<double> *c, const int *ldc) {
cblas_zsyr2k(layout, uplo, trans, *n, *k, alpha, a, *lda, b, *ldb, beta, c, *ldc);
}
template <typename fp_scalar, typename fp_data>
static void her2k(CBLAS_LAYOUT layout, CBLAS_UPLO uplo, CBLAS_TRANSPOSE trans, const int *n,
const int *k, const fp_data *alpha, const fp_data *a, const int *lda,
const fp_data *b, const int *ldb, const fp_scalar *beta, fp_data *c,
const int *ldc);
template <>
void her2k(CBLAS_LAYOUT layout, CBLAS_UPLO uplo, CBLAS_TRANSPOSE trans, const int *n, const int *k,
const std::complex<float> *alpha, const std::complex<float> *a, const int *lda,
const std::complex<float> *b, const int *ldb, const float *beta, std::complex<float> *c,
const int *ldc) {
cblas_cher2k(layout, uplo, trans, *n, *k, alpha, a, *lda, b, *ldb, *beta, c, *ldc);
}
template <>
void her2k(CBLAS_LAYOUT layout, CBLAS_UPLO uplo, CBLAS_TRANSPOSE trans, const int *n, const int *k,
const std::complex<double> *alpha, const std::complex<double> *a, const int *lda,
const std::complex<double> *b, const int *ldb, const double *beta,
std::complex<double> *c, const int *ldc) {
cblas_zher2k(layout, uplo, trans, *n, *k, alpha, a, *lda, b, *ldb, *beta, c, *ldc);
}
template <typename fp>
static void trmm(CBLAS_LAYOUT layout, CBLAS_SIDE side, CBLAS_UPLO uplo, CBLAS_TRANSPOSE transa,
CBLAS_DIAG diag, const int *m, const int *n, const fp *alpha, const fp *a,
const int *lda, fp *b, const int *ldb);
template <>
void trmm(CBLAS_LAYOUT layout, CBLAS_SIDE side, CBLAS_UPLO uplo, CBLAS_TRANSPOSE transa,
CBLAS_DIAG diag, const int *m, const int *n, const float *alpha, const float *a,
const int *lda, float *b, const int *ldb) {
cblas_strmm(layout, side, uplo, transa, diag, *m, *n, *alpha, a, *lda, b, *ldb);
}
template <>
void trmm(CBLAS_LAYOUT layout, CBLAS_SIDE side, CBLAS_UPLO uplo, CBLAS_TRANSPOSE transa,
CBLAS_DIAG diag, const int *m, const int *n, const double *alpha, const double *a,
const int *lda, double *b, const int *ldb) {
cblas_dtrmm(layout, side, uplo, transa, diag, *m, *n, *alpha, a, *lda, b, *ldb);
}
template <>
void trmm(CBLAS_LAYOUT layout, CBLAS_SIDE side, CBLAS_UPLO uplo, CBLAS_TRANSPOSE transa,
CBLAS_DIAG diag, const int *m, const int *n, const std::complex<float> *alpha,
const std::complex<float> *a, const int *lda, std::complex<float> *b, const int *ldb) {
cblas_ctrmm(layout, side, uplo, transa, diag, *m, *n, alpha, a, *lda, b, *ldb);
}
template <>
void trmm(CBLAS_LAYOUT layout, CBLAS_SIDE side, CBLAS_UPLO uplo, CBLAS_TRANSPOSE transa,
CBLAS_DIAG diag, const int *m, const int *n, const std::complex<double> *alpha,
const std::complex<double> *a, const int *lda, std::complex<double> *b, const int *ldb) {
cblas_ztrmm(layout, side, uplo, transa, diag, *m, *n, alpha, a, *lda, b, *ldb);
}
template <typename fp>
static void trsm(CBLAS_LAYOUT layout, CBLAS_SIDE side, CBLAS_UPLO uplo, CBLAS_TRANSPOSE transa,
CBLAS_DIAG diag, const int *m, const int *n, const fp *alpha, const fp *a,
const int *lda, fp *b, const int *ldb);
template <>
void trsm(CBLAS_LAYOUT layout, CBLAS_SIDE side, CBLAS_UPLO uplo, CBLAS_TRANSPOSE transa,
CBLAS_DIAG diag, const int *m, const int *n, const float *alpha, const float *a,
const int *lda, float *b, const int *ldb) {
cblas_strsm(layout, side, uplo, transa, diag, *m, *n, *alpha, a, *lda, b, *ldb);
}
template <>
void trsm(CBLAS_LAYOUT layout, CBLAS_SIDE side, CBLAS_UPLO uplo, CBLAS_TRANSPOSE transa,
CBLAS_DIAG diag, const int *m, const int *n, const double *alpha, const double *a,
const int *lda, double *b, const int *ldb) {
cblas_dtrsm(layout, side, uplo, transa, diag, *m, *n, *alpha, a, *lda, b, *ldb);
}
template <>
void trsm(CBLAS_LAYOUT layout, CBLAS_SIDE side, CBLAS_UPLO uplo, CBLAS_TRANSPOSE transa,
CBLAS_DIAG diag, const int *m, const int *n, const std::complex<float> *alpha,
const std::complex<float> *a, const int *lda, std::complex<float> *b, const int *ldb) {
cblas_ctrsm(layout, side, uplo, transa, diag, *m, *n, alpha, a, *lda, b, *ldb);
}
template <>
void trsm(CBLAS_LAYOUT layout, CBLAS_SIDE side, CBLAS_UPLO uplo, CBLAS_TRANSPOSE transa,
CBLAS_DIAG diag, const int *m, const int *n, const std::complex<double> *alpha,
const std::complex<double> *a, const int *lda, std::complex<double> *b, const int *ldb) {
cblas_ztrsm(layout, side, uplo, transa, diag, *m, *n, alpha, a, *lda, b, *ldb);
}
/* Level 2 */
template <typename fp>
static void gemv(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE trans, const int *m, const int *n,
const fp *alpha, const fp *a, const int *lda, const fp *x, const int *incx,
const fp *beta, fp *y, const int *incy);
template <>
void gemv(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE trans, const int *m, const int *n,
const float *alpha, const float *a, const int *lda, const float *x, const int *incx,
const float *beta, float *y, const int *incy) {
cblas_sgemv(layout, trans, *m, *n, *alpha, a, *lda, x, *incx, *beta, y, *incy);
}
template <>
void gemv(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE trans, const int *m, const int *n,
const double *alpha, const double *a, const int *lda, const double *x, const int *incx,
const double *beta, double *y, const int *incy) {
cblas_dgemv(layout, trans, *m, *n, *alpha, a, *lda, x, *incx, *beta, y, *incy);
}
template <>
void gemv(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE trans, const int *m, const int *n,
const std::complex<float> *alpha, const std::complex<float> *a, const int *lda,
const std::complex<float> *x, const int *incx, const std::complex<float> *beta,
std::complex<float> *y, const int *incy) {
cblas_cgemv(layout, trans, *m, *n, alpha, a, *lda, x, *incx, beta, y, *incy);
}
template <>
void gemv(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE trans, const int *m, const int *n,
const std::complex<double> *alpha, const std::complex<double> *a, const int *lda,
const std::complex<double> *x, const int *incx, const std::complex<double> *beta,
std::complex<double> *y, const int *incy) {
cblas_zgemv(layout, trans, *m, *n, alpha, a, *lda, x, *incx, beta, y, *incy);
}
template <typename fp>
static void gbmv(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE trans, const int *m, const int *n, int *kl,
int *ku, const fp *alpha, const fp *a, const int *lda, const fp *x,
const int *incx, const fp *beta, fp *y, const int *incy);
template <>
void gbmv(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE trans, const int *m, const int *n, int *kl, int *ku,
const float *alpha, const float *a, const int *lda, const float *x, const int *incx,
const float *beta, float *y, const int *incy) {
cblas_sgbmv(layout, trans, *m, *n, *kl, *ku, *alpha, a, *lda, x, *incx, *beta, y, *incy);
}
template <>
void gbmv(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE trans, const int *m, const int *n, int *kl, int *ku,
const double *alpha, const double *a, const int *lda, const double *x, const int *incx,
const double *beta, double *y, const int *incy) {
cblas_dgbmv(layout, trans, *m, *n, *kl, *ku, *alpha, a, *lda, x, *incx, *beta, y, *incy);
}
template <>
void gbmv(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE trans, const int *m, const int *n, int *kl, int *ku,
const std::complex<float> *alpha, const std::complex<float> *a, const int *lda,
const std::complex<float> *x, const int *incx, const std::complex<float> *beta,
std::complex<float> *y, const int *incy) {
cblas_cgbmv(layout, trans, *m, *n, *kl, *ku, alpha, a, *lda, x, *incx, beta, y, *incy);
}
template <>
void gbmv(CBLAS_LAYOUT layout, CBLAS_TRANSPOSE trans, const int *m, const int *n, int *kl, int *ku,
const std::complex<double> *alpha, const std::complex<double> *a, const int *lda,
const std::complex<double> *x, const int *incx, const std::complex<double> *beta,
std::complex<double> *y, const int *incy) {
cblas_zgbmv(layout, trans, *m, *n, *kl, *ku, alpha, a, *lda, x, *incx, beta, y, *incy);
}
template <typename fp>
static void ger(CBLAS_LAYOUT layout, const int *m, const int *n, const fp *alpha, const fp *x,
const int *incx, const fp *y, const int *incy, fp *a, const int *lda);
template <>
void ger(CBLAS_LAYOUT layout, const int *m, const int *n, const float *alpha, const float *x,
const int *incx, const float *y, const int *incy, float *a, const int *lda) {
cblas_sger(layout, *m, *n, *alpha, x, *incx, y, *incy, a, *lda);
}
template <>
void ger(CBLAS_LAYOUT layout, const int *m, const int *n, const double *alpha, const double *x,
const int *incx, const double *y, const int *incy, double *a, const int *lda) {
cblas_dger(layout, *m, *n, *alpha, x, *incx, y, *incy, a, *lda);
}
template <typename fp>
static void gerc(CBLAS_LAYOUT layout, const int *m, const int *n, const fp *alpha, const fp *x,
const int *incx, const fp *y, const int *incy, fp *a, const int *lda);
template <>
void gerc(CBLAS_LAYOUT layout, const int *m, const int *n, const std::complex<float> *alpha,
const std::complex<float> *x, const int *incx, const std::complex<float> *y,
const int *incy, std::complex<float> *a, const int *lda) {
cblas_cgerc(layout, *m, *n, alpha, x, *incx, y, *incy, a, *lda);
}
template <>
void gerc(CBLAS_LAYOUT layout, const int *m, const int *n, const std::complex<double> *alpha,
const std::complex<double> *x, const int *incx, const std::complex<double> *y,
const int *incy, std::complex<double> *a, const int *lda) {
cblas_zgerc(layout, *m, *n, alpha, x, *incx, y, *incy, a, *lda);
}
template <typename fp>
static void geru(CBLAS_LAYOUT layout, const int *m, const int *n, const fp *alpha, const fp *x,
const int *incx, const fp *y, const int *incy, fp *a, const int *lda);
template <>
void geru(CBLAS_LAYOUT layout, const int *m, const int *n, const std::complex<float> *alpha,
const std::complex<float> *x, const int *incx, const std::complex<float> *y,
const int *incy, std::complex<float> *a, const int *lda) {
cblas_cgeru(layout, *m, *n, alpha, x, *incx, y, *incy, a, *lda);
}
template <>
void geru(CBLAS_LAYOUT layout, const int *m, const int *n, const std::complex<double> *alpha,
const std::complex<double> *x, const int *incx, const std::complex<double> *y,
const int *incy, std::complex<double> *a, const int *lda) {
cblas_zgeru(layout, *m, *n, alpha, x, *incx, y, *incy, a, *lda);
}
template <typename fp>
static void hbmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const int *k,
const fp *alpha, const fp *a, const int *lda, const fp *x, const int *incx,
const fp *beta, fp *y, const int *incy);
template <>
void hbmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const int *k,
const std::complex<float> *alpha, const std::complex<float> *a, const int *lda,
const std::complex<float> *x, const int *incx, const std::complex<float> *beta,
std::complex<float> *y, const int *incy) {
cblas_chbmv(layout, upper_lower, *n, *k, alpha, a, *lda, x, *incx, beta, y, *incy);
}
template <>
void hbmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const int *k,
const std::complex<double> *alpha, const std::complex<double> *a, const int *lda,
const std::complex<double> *x, const int *incx, const std::complex<double> *beta,
std::complex<double> *y, const int *incy) {
cblas_zhbmv(layout, upper_lower, *n, *k, alpha, a, *lda, x, *incx, beta, y, *incy);
}
template <typename fp>
static void hemv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const fp *alpha,
const fp *a, const int *lda, const fp *x, const int *incx, const fp *beta, fp *y,
const int *incy);
template <>
void hemv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n,
const std::complex<float> *alpha, const std::complex<float> *a, const int *lda,
const std::complex<float> *x, const int *incx, const std::complex<float> *beta,
std::complex<float> *y, const int *incy) {
cblas_chemv(layout, upper_lower, *n, alpha, a, *lda, x, *incx, beta, y, *incy);
}
template <>
void hemv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n,
const std::complex<double> *alpha, const std::complex<double> *a, const int *lda,
const std::complex<double> *x, const int *incx, const std::complex<double> *beta,
std::complex<double> *y, const int *incy) {
cblas_zhemv(layout, upper_lower, *n, alpha, a, *lda, x, *incx, beta, y, *incy);
}
template <typename fp_scalar, typename fp_data>
static void her(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const fp_scalar *alpha,
const fp_data *x, const int *incx, fp_data *a, const int *lda);
template <>
void her(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const float *alpha,
const std::complex<float> *x, const int *incx, std::complex<float> *a, const int *lda) {
cblas_cher(layout, upper_lower, *n, *alpha, x, *incx, a, *lda);
}
template <>
void her(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const double *alpha,
const std::complex<double> *x, const int *incx, std::complex<double> *a, const int *lda) {
cblas_zher(layout, upper_lower, *n, *alpha, x, *incx, a, *lda);
}
template <typename fp>
static void her2(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const fp *alpha,
const fp *x, const int *incx, const fp *y, const int *incy, fp *a, const int *lda);
template <>
void her2(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n,
const std::complex<float> *alpha, const std::complex<float> *x, const int *incx,
const std::complex<float> *y, const int *incy, std::complex<float> *a, const int *lda) {
cblas_cher2(layout, upper_lower, *n, alpha, x, *incx, y, *incy, a, *lda);
}
template <>
void her2(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n,
const std::complex<double> *alpha, const std::complex<double> *x, const int *incx,
const std::complex<double> *y, const int *incy, std::complex<double> *a, const int *lda) {
cblas_zher2(layout, upper_lower, *n, alpha, x, *incx, y, *incy, a, *lda);
}
template <typename fp>
static void hpmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const fp *alpha,
const fp *a, const fp *x, const int *incx, const fp *beta, fp *y, const int *incy);
template <>
void hpmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n,
const std::complex<float> *alpha, const std::complex<float> *a,
const std::complex<float> *x, const int *incx, const std::complex<float> *beta,
std::complex<float> *y, const int *incy) {
cblas_chpmv(layout, upper_lower, *n, alpha, a, x, *incx, beta, y, *incy);
}
template <>
void hpmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n,
const std::complex<double> *alpha, const std::complex<double> *a,
const std::complex<double> *x, const int *incx, const std::complex<double> *beta,
std::complex<double> *y, const int *incy) {
cblas_zhpmv(layout, upper_lower, *n, alpha, a, x, *incx, beta, y, *incy);
}
template <typename fp_scalar, typename fp_data>
static void hpr(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const fp_scalar *alpha,
const fp_data *x, const int *incx, fp_data *a);
template <>
void hpr(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const float *alpha,
const std::complex<float> *x, const int *incx, std::complex<float> *a) {
cblas_chpr(layout, upper_lower, *n, *alpha, x, *incx, a);
}
template <>
void hpr(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const double *alpha,
const std::complex<double> *x, const int *incx, std::complex<double> *a) {
cblas_zhpr(layout, upper_lower, *n, *alpha, x, *incx, a);
}
template <typename fp>
static void hpr2(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const fp *alpha,
const fp *x, const int *incx, const fp *y, const int *incy, fp *a);
template <>
void hpr2(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n,
const std::complex<float> *alpha, const std::complex<float> *x, const int *incx,
const std::complex<float> *y, const int *incy, std::complex<float> *a) {
cblas_chpr2(layout, upper_lower, *n, alpha, x, *incx, y, *incy, a);
}
template <>
void hpr2(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n,
const std::complex<double> *alpha, const std::complex<double> *x, const int *incx,
const std::complex<double> *y, const int *incy, std::complex<double> *a) {
cblas_zhpr2(layout, upper_lower, *n, alpha, x, *incx, y, *incy, a);
}
template <typename fp>
static void sbmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const int *k,
const fp *alpha, const fp *a, const int *lda, const fp *x, const int *incx,
const fp *beta, fp *y, const int *incy);
template <>
void sbmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const int *k,
const float *alpha, const float *a, const int *lda, const float *x, const int *incx,
const float *beta, float *y, const int *incy) {
cblas_ssbmv(layout, upper_lower, *n, *k, *alpha, a, *lda, x, *incx, *beta, y, *incy);
}
template <>
void sbmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const int *k,
const double *alpha, const double *a, const int *lda, const double *x, const int *incx,
const double *beta, double *y, const int *incy) {
cblas_dsbmv(layout, upper_lower, *n, *k, *alpha, a, *lda, x, *incx, *beta, y, *incy);
}
template <typename fp>
static void symv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const fp *alpha,
const fp *a, const int *lda, const fp *x, const int *incx, const fp *beta, fp *y,
const int *incy);
template <>
void symv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const float *alpha,
const float *a, const int *lda, const float *x, const int *incx, const float *beta,
float *y, const int *incy) {
cblas_ssymv(layout, upper_lower, *n, *alpha, a, *lda, x, *incx, *beta, y, *incy);
}
template <>
void symv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const double *alpha,
const double *a, const int *lda, const double *x, const int *incx, const double *beta,
double *y, const int *incy) {
cblas_dsymv(layout, upper_lower, *n, *alpha, a, *lda, x, *incx, *beta, y, *incy);
}
template <typename fp>
static void syr(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const fp *alpha,
const fp *x, const int *incx, fp *a, const int *lda);
template <>
void syr(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const float *alpha,
const float *x, const int *incx, float *a, const int *lda) {
cblas_ssyr(layout, upper_lower, *n, *alpha, x, *incx, a, *lda);
}
template <>
void syr(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const double *alpha,
const double *x, const int *incx, double *a, const int *lda) {
cblas_dsyr(layout, upper_lower, *n, *alpha, x, *incx, a, *lda);
}
template <typename fp>
static void syr2(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const fp *alpha,
const fp *x, const int *incx, const fp *y, const int *incy, fp *a, const int *lda);
template <>
void syr2(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const float *alpha,
const float *x, const int *incx, const float *y, const int *incy, float *a,
const int *lda) {
cblas_ssyr2(layout, upper_lower, *n, *alpha, x, *incx, y, *incy, a, *lda);
}
template <>
void syr2(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const double *alpha,
const double *x, const int *incx, const double *y, const int *incy, double *a,
const int *lda) {
cblas_dsyr2(layout, upper_lower, *n, *alpha, x, *incx, y, *incy, a, *lda);
}
template <typename fp>
static void spmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const fp *alpha,
const fp *a, const fp *x, const int *incx, const fp *beta, fp *y, const int *incy);
template <>
void spmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const float *alpha,
const float *a, const float *x, const int *incx, const float *beta, float *y,
const int *incy) {
cblas_sspmv(layout, upper_lower, *n, *alpha, a, x, *incx, *beta, y, *incy);
}
template <>
void spmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const double *alpha,
const double *a, const double *x, const int *incx, const double *beta, double *y,
const int *incy) {
cblas_dspmv(layout, upper_lower, *n, *alpha, a, x, *incx, *beta, y, *incy);
}
template <typename fp>
static void spr(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const fp *alpha,
const fp *x, const int *incx, fp *a);
template <>
void spr(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const float *alpha,
const float *x, const int *incx, float *a) {
cblas_sspr(layout, upper_lower, *n, *alpha, x, *incx, a);
}
template <>
void spr(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const double *alpha,
const double *x, const int *incx, double *a) {
cblas_dspr(layout, upper_lower, *n, *alpha, x, *incx, a);
}
template <typename fp>
static void spr2(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const fp *alpha,
const fp *x, const int *incx, const fp *y, const int *incy, fp *a);
template <>
void spr2(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const float *alpha,
const float *x, const int *incx, const float *y, const int *incy, float *a) {
cblas_sspr2(layout, upper_lower, *n, *alpha, x, *incx, y, *incy, a);
}
template <>
void spr2(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, const int *n, const double *alpha,
const double *x, const int *incx, const double *y, const int *incy, double *a) {
cblas_dspr2(layout, upper_lower, *n, *alpha, x, *incx, y, *incy, a);
}
template <typename fp>
static void tbmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, CBLAS_TRANSPOSE trans,
CBLAS_DIAG unit_diag, const int *n, const int *k, const fp *a, const int *lda,
fp *x, const int *incx);
template <>
void tbmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, CBLAS_TRANSPOSE trans, CBLAS_DIAG unit_diag,
const int *n, const int *k, const float *a, const int *lda, float *x, const int *incx) {
cblas_stbmv(layout, upper_lower, trans, unit_diag, *n, *k, a, *lda, x, *incx);
}
template <>
void tbmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, CBLAS_TRANSPOSE trans, CBLAS_DIAG unit_diag,
const int *n, const int *k, const double *a, const int *lda, double *x, const int *incx) {
cblas_dtbmv(layout, upper_lower, trans, unit_diag, *n, *k, a, *lda, x, *incx);
}
template <>
void tbmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, CBLAS_TRANSPOSE trans, CBLAS_DIAG unit_diag,
const int *n, const int *k, const std::complex<float> *a, const int *lda,
std::complex<float> *x, const int *incx) {
cblas_ctbmv(layout, upper_lower, trans, unit_diag, *n, *k, a, *lda, x, *incx);
}
template <>
void tbmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, CBLAS_TRANSPOSE trans, CBLAS_DIAG unit_diag,
const int *n, const int *k, const std::complex<double> *a, const int *lda,
std::complex<double> *x, const int *incx) {
cblas_ztbmv(layout, upper_lower, trans, unit_diag, *n, *k, a, *lda, x, *incx);
}
template <typename fp>
static void tbsv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, CBLAS_TRANSPOSE trans,
CBLAS_DIAG unit_diag, const int *n, const int *k, const fp *a, const int *lda,
fp *x, const int *incx);
template <>
void tbsv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, CBLAS_TRANSPOSE trans, CBLAS_DIAG unit_diag,
const int *n, const int *k, const float *a, const int *lda, float *x, const int *incx) {
cblas_stbsv(layout, upper_lower, trans, unit_diag, *n, *k, a, *lda, x, *incx);
}
template <>
void tbsv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, CBLAS_TRANSPOSE trans, CBLAS_DIAG unit_diag,
const int *n, const int *k, const double *a, const int *lda, double *x, const int *incx) {
cblas_dtbsv(layout, upper_lower, trans, unit_diag, *n, *k, a, *lda, x, *incx);
}
template <>
void tbsv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, CBLAS_TRANSPOSE trans, CBLAS_DIAG unit_diag,
const int *n, const int *k, const std::complex<float> *a, const int *lda,
std::complex<float> *x, const int *incx) {
cblas_ctbsv(layout, upper_lower, trans, unit_diag, *n, *k, a, *lda, x, *incx);
}
template <>
void tbsv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, CBLAS_TRANSPOSE trans, CBLAS_DIAG unit_diag,
const int *n, const int *k, const std::complex<double> *a, const int *lda,
std::complex<double> *x, const int *incx) {
cblas_ztbsv(layout, upper_lower, trans, unit_diag, *n, *k, a, *lda, x, *incx);
}
template <typename fp>
static void tpmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, CBLAS_TRANSPOSE trans,
CBLAS_DIAG unit_diag, const int *n, const fp *a, fp *x, const int *incx);
template <>
void tpmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, CBLAS_TRANSPOSE trans, CBLAS_DIAG unit_diag,
const int *n, const float *a, float *x, const int *incx) {
cblas_stpmv(layout, upper_lower, trans, unit_diag, *n, a, x, *incx);
}
template <>
void tpmv(CBLAS_LAYOUT layout, CBLAS_UPLO upper_lower, CBLAS_TRANSPOSE trans, CBLAS_DIAG unit_diag,
const int *n, const double *a, double *x, const int *incx) {
cblas_dtpmv(layout, upper_lower, trans, unit_diag, *n, a, x, *incx);