/
BLAS.java
1981 lines (1894 loc) · 83.6 KB
/
BLAS.java
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 (c) 2010-2021 Haifeng Li. All rights reserved.
*
* Smile is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Smile is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Smile. If not, see <https://www.gnu.org/licenses/>.
*/
package smile.math.blas;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import org.bytedeco.javacpp.DoublePointer;
/**
* Basic Linear Algebra Subprograms. BLAS is a specification that prescribes
* a set of low-level routines for performing common linear algebra operations
* such as vector addition, scalar multiplication, dot products, linear
* combinations, and matrix multiplication. They are the de facto standard
* low-level routines for linear algebra libraries.
*
* @author Haifeng Li
*/
public interface BLAS {
/** The default BLAS engine. */
BLAS engine = getInstance();
/**
* Creates an instance.
* @return a BLAS instance.
*/
static BLAS getInstance() {
return new smile.math.blas.openblas.OpenBLAS();
}
/**
* Sums the absolute values of the elements of a vector.
* When working backward ({@code incx < 0}), each routine starts at the end of the
* vector and moves backward.
*
* @param n Number of vector elements to be summed.
*
* @param x Array of dimension {@code (n-1) * abs(incx)+ 1}.
* Vector that contains elements to be summed.
*
* @param incx Increment between elements of x.
* If {@code incx = 0}, the results will be unpredictable.
*
* @return Sum of the absolute values of the elements of the vector x.
* If {@code n <= 0}, DASUM is set to 0.
*/
double asum(int n, double[] x, int incx);
/**
* Sums the absolute values of the elements of a vector.
* When working backward ({@code incx < 0}), each routine starts at the end of the
* vector and moves backward.
*
* @param n Number of vector elements to be summed.
*
* @param x Array of dimension {@code (n-1) * abs(incx)+ 1}.
* Vector that contains elements to be summed.
*
* @param incx Increment between elements of x.
* If {@code incx = 0}, the results will be unpredictable.
*
* @return Sum of the absolute values of the elements of the vector x.
* If {@code n <= 0}, DASUM is set to 0.
*/
float asum(int n, float[] x, int incx);
/**
* Sums the absolute values of the elements of a vector.
*
* @param x Vector that contains elements to be summed.
*
* @return Sum of the absolute values of the elements of the vector x.
*/
default double asum(double[] x) {
return asum(x.length, x, 1);
}
/**
* Sums the absolute values of the elements of a vector.
*
* @param x Vector that contains elements to be summed.
*
* @return Sum of the absolute values of the elements of the vector x.
*/
default float asum(float[] x) {
return asum(x.length, x, 1);
}
/**
* Computes a constant alpha times a vector x plus a vector y.
* The result overwrites the initial values of vector y.
* incx and incy specify the increment between two consecutive
* elements of respectively vector x and y. When working backward
* ({@code incx < 0 or incy < 0}), each routine starts at the end of the
* vector and moves backward.
* <p>
* When {@code n <= 0}, or {@code alpha = 0.}, this routine returns immediately
* with no change in its arguments.
*
* @param n Number of elements in the vectors. If {@code n <= 0}, these routines
* return without any computation.
*
* @param alpha If {@code alpha = 0} this routine returns without any computation.
*
* @param x Input array of dimension {@code (n-1) * |incx| + 1}. Contains the
* vector to be scaled before summation.
*
* @param incx Increment between elements of x.
* If {@code incx = 0}, the results will be unpredictable.
*
* @param y Input and output array of dimension {@code (n-1) * |incy| + 1}.
* Before calling the routine, y contains the vector to be summed.
* After the routine ends, y contains the result of the summation.
*
* @param incy Increment between elements of y.
* If {@code incy = 0}, the results will be unpredictable.
*/
void axpy(int n, double alpha, double[] x, int incx, double[] y, int incy);
/**
* Computes a constant alpha times a vector x plus a vector y.
* The result overwrites the initial values of vector y.
* incx and incy specify the increment between two consecutive
* elements of respectively vector x and y. When working backward
* ({@code incx < 0 or incy < 0}), each routine starts at the end of the
* vector and moves backward.
* <p>
* When {@code n <= 0, or alpha = 0.}, this routine returns immediately
* with no change in its arguments.
*
* @param n Number of elements in the vectors. If {@code n <= 0}, these routines
* return without any computation.
*
* @param alpha If {@code alpha = 0} this routine returns without any computation.
*
* @param x Input array of dimension {@code (n-1) * |incx| + 1.} Contains the
* vector to be scaled before summation.
*
* @param incx Increment between elements of x.
* If {@code incx = 0}, the results will be unpredictable.
*
* @param y Input and output array of dimension {@code (n-1) * |incy| + 1}.
* Before calling the routine, y contains the vector to be summed.
* After the routine ends, y contains the result of the summation.
*
* @param incy Increment between elements of y.
* If {@code incy = 0}, the results will be unpredictable.
*/
void axpy(int n, float alpha, float[] x, int incx, float[] y, int incy);
/**
* Computes a constant alpha times a vector x plus a vector y.
* The result overwrites the initial values of vector y.
* <p>
* When {@code alpha = 0.}, this routine returns immediately
* with no change in its arguments.
*
* @param alpha If {@code alpha = 0} this routine returns without any computation.
*
* @param x The vector to be scaled before summation.
*
* @param y Input and output array.
* Before calling the routine, y contains the vector to be summed.
* After the routine ends, y contains the result of the summation.
*/
default void axpy(double alpha, double[] x, double[] y) {
axpy(x.length, alpha, x, 1, y, 1);
}
/**
* Computes a constant alpha times a vector x plus a vector y.
* The result overwrites the initial values of vector y.
* <p>
* When {@code alpha = 0.}, this routine returns immediately
* with no change in its arguments.
*
* @param alpha If {@code alpha = 0} this routine returns without any computation.
*
* @param x The vector to be scaled before summation.
*
* @param y Input and output array.
* Before calling the routine, y contains the vector to be summed.
* After the routine ends, y contains the result of the summation.
*/
default void axpy(float alpha, float[] x, float[] y) {
axpy(x.length, alpha, x, 1, y, 1);
}
/**
* Computes the dot product of two vectors.
* incx and incy specify the increment between two consecutive
* elements of respectively vector x and y. When working backward
* ({@code incx < 0 or incy < 0}), each routine starts at the end of the
* vector and moves backward.
*
* @param n Number of elements in the vectors.
*
* @param x Input array of dimension {@code (n-1) * |incx| + 1}.
* Array x contains the first vector operand.
*
* @param incx Increment between elements of x.
* If {@code incx = 0}, the results will be unpredictable.
*
* @param y Input array of dimension {@code (n-1) * |incy| + 1}.
* Array y contains the second vector operand.
*
* @param incy Increment between elements of y.
* If {@code incy = 0}, the results will be unpredictable.
*
* @return dot product. If {@code n <= 0}, return 0.
*/
double dot(int n, double[] x, int incx, double[] y, int incy);
/**
* Computes the dot product of two vectors.
* incx and incy specify the increment between two consecutive
* elements of respectively vector x and y. When working backward
* ({@code incx < 0 or incy < 0}), each routine starts at the end of the
* vector and moves backward.
*
* @param n Number of elements in the vectors.
*
* @param x Input array of dimension {@code (n-1) * |incx| + 1}.
* Array x contains the first vector operand.
*
* @param incx Increment between elements of x.
* If {@code incx = 0}, the results will be unpredictable.
*
* @param y Input array of dimension {@code (n-1) * |incy| + 1}.
* Array y contains the second vector operand.
*
* @param incy Increment between elements of y.
* If {@code incy = 0}, the results will be unpredictable.
*
* @return dot product. If {@code n <= 0}, return 0.
*/
float dot(int n, float[] x, int incx, float[] y, int incy);
/**
* Computes the dot product of two vectors.
*
* @param x Array x contains the first vector operand.
*
* @param y Array y contains the second vector operand.
*
* @return dot product. If {@code n <= 0}, return 0.
*/
default double dot(double[] x, double[] y) {
return dot(x.length, x, 1, y, 1);
}
/**
* Computes the dot product of two vectors.
*
* @param x Array x contains the first vector operand.
*
* @param y Array y contains the second vector operand.
*
* @return dot product. If {@code n <= 0}, return 0.
*/
default float dot(float[] x, float[] y) {
return dot(x.length, x, 1, y, 1);
}
/**
* Computes the Euclidean (L2) norm of a vector.
*
* @param n Number of elements in the vectors.
*
* @param x Input array of dimension {@code (n-1) * |incx| + 1}.
* Array x contains the vector operand.
*
* @param incx Increment between elements of x.
* If {@code incx = 0}, the results will be unpredictable.
*
* @return Euclidean norm. If {@code n <= 0}, return 0.
*/
double nrm2(int n, double[] x, int incx);
/**
* Computes the Euclidean (L2) norm of a vector.
*
* @param n Number of elements in the vectors.
*
* @param x Input array of dimension {@code (n-1) * |incx| + 1}.
* Array x contains the vector operand.
*
* @param incx Increment between elements of x.
* If {@code incx = 0}, the results will be unpredictable.
*
* @return Euclidean norm. If {@code n <= 0}, return 0.
*/
float nrm2(int n, float[] x, int incx);
/**
* Computes the Euclidean (L2) norm of a vector.
*
* @param x Array x contains the vector operand.
*
* @return Euclidean norm.
*/
default double nrm2(double[] x) {
return nrm2(x.length, x, 1);
}
/**
* Computes the Euclidean (L2) norm of a vector.
*
* @param x Array x contains the vector operand.
*
* @return Euclidean norm.
*/
default float nrm2(float[] x) {
return nrm2(x.length, x, 1);
}
/**
* Scales a vector with a scalar.
*
* @param n Number of elements in the vectors.
*
* @param alpha The scaling factor.
*
* @param x Input and output array of dimension {@code (n-1) * |incx| + 1}.
* Vector to be scaled.
*
* @param incx Increment between elements of x.
* If {@code incx = 0}, the results will be unpredictable.
*/
void scal(int n, double alpha, double[] x, int incx);
/**
* Scales a vector with a scalar.
*
* @param n Number of elements in the vectors.
*
* @param alpha The scaling factor.
*
* @param x Input and output array of dimension {@code (n-1) * |incx| + 1}.
* Vector to be scaled.
*
* @param incx Increment between elements of x.
* If {@code incx = 0}, the results will be unpredictable.
*/
void scal(int n, float alpha, float[] x, int incx);
/**
* Scales a vector with a scalar.
*
* @param alpha The scaling factor.
*
* @param x Input and output vector to be scaled.
*/
default void scal(double alpha, double[] x) {
scal(x.length, alpha, x, 1);
}
/**
* Scales a vector with a scalar.
*
* @param alpha The scaling factor.
*
* @param x Input and output vector to be scaled.
*/
default void scal(float alpha, float[] x) {
scal(x.length, alpha, x, 1);
}
/**
* Swaps two vectors.
* incx and incy specify the increment between two consecutive
* elements of respectively vector x and y. When working backward
* ({@code incx < 0 or incy < 0}), each routine starts at the end of the
* vector and moves backward.
*
* @param n Number of elements in the vectors.
*
* @param x Input and output array of dimension {@code (n-1) * |incx| + 1}.
* Vector to be swapped.
*
* @param incx Increment between elements of x.
* If {@code incx = 0}, the results will be unpredictable.
*
* @param y Input and output array of dimension {@code (n-1) * |incy| + 1}.
* Vector to be swapped.
*
* @param incy Increment between elements of y.
* If {@code incy = 0}, the results will be unpredictable.
*/
void swap(int n, double[] x, int incx, double[] y, int incy);
/**
* Swaps two vectors.
* incx and incy specify the increment between two consecutive
* elements of respectively vector x and y. When working backward
* ({@code incx < 0 or incy < 0}), each routine starts at the end of the
* vector and moves backward.
*
* @param n Number of elements in the vectors.
*
* @param x Input and output array of dimension {@code (n-1) * |incx| + 1}.
* Vector to be swapped.
*
* @param incx Increment between elements of x.
* If {@code incx = 0}, the results will be unpredictable.
*
* @param y Input and output array of dimension {@code (n-1) * |incy| + 1}.
* Vector to be swapped.
*
* @param incy Increment between elements of y.
* If {@code incy = 0}, the results will be unpredictable.
*/
void swap(int n, float[] x, int incx, float[] y, int incy);
/**
* Swaps two vectors.
*
* @param x Input and output vector to be swapped.
*
* @param y Input and output vector to be swapped.
*/
default void swap(double[] x, double[] y) {
swap(x.length, x, 1, y, 1);
}
/**
* Swaps two vectors.
*
* @param x Input and output vector to be swapped.
*
* @param y Input and output vector to be swapped.
*/
default void swap(float[] x, float[] y) {
swap(x.length, x, 1, y, 1);
}
/**
* Searches a vector for the first occurrence of the maximum absolute
* value.
*
* @param n Number of elements in the vectors.
*
* @param x Input array of dimension {@code (n-1) * |incx| + 1}.
* Vector to be searched.
*
* @param incx Increment between elements of x.
* If {@code incx = 0}, the results will be unpredictable.
*
* @return The first index of the maximum absolute value of vector x.
* If {@code n <= 0}, return 0.
*/
long iamax(int n, double[] x, int incx);
/**
* Searches a vector for the first occurrence of the maximum absolute
* value.
*
* @param n Number of elements in the vectors.
*
* @param x Input array of dimension {@code (n-1) * |incx| + 1}.
* Vector to be searched.
*
* @param incx Increment between elements of x.
* If {@code incx = 0}, the results will be unpredictable.
*
* @return The first index of the maximum absolute value of vector x.
* If {@code n <= 0}, return 0.
*/
long iamax(int n, float[] x, int incx);
/**
* Searches a vector for the first occurrence of the maximum absolute
* value.
*
* @param x Vector to be searched.
*
* @return The first index of the maximum absolute value of vector x.
*/
default long iamax(double[] x) {
return iamax(x.length, x, 1);
}
/**
* Searches a vector for the first occurrence of the maximum absolute
* value.
*
* @param x Vector to be searched.
*
* @return The first index of the maximum absolute value of vector x.
*/
default long iamax(float[] x) {
return iamax(x.length, x, 1);
}
/**
* Performs the matrix-vector operation.
* <pre>{@code
* y := alpha*A*x + beta*y
* }</pre>
* or
* <pre>{@code
* y := alpha*A'*x + beta*y
* }</pre>
* where alpha and beta are scalars, x and y are vectors and A is an m by
* n matrix.
*
* @param layout matrix layout.
* @param trans normal, transpose, or conjugate transpose
* operation on the matrix.
* @param m the number of rows of the matrix A.
* @param n the number of columns of the matrix A.
* @param alpha the scalar alpha.
* @param A the leading m by n part of the array A must contain
* the matrix of coefficients.
* @param lda the leading dimension of A as declared in the caller.
* LDA must be at least {@code max(1, m)}. The leading dimension
* parameter allows use of BLAS/LAPACK routines on a submatrix
* of a larger matrix.
* @param x array of dimension at least {@code (1 + (n - 1) * abs(incx))}
* when {@code trans = 'N' or 'n'} and
* at least {@code (1 + (m - 1) * abs(incx))} otherwise.
* @param incx the increment for the elements of x, which must not be zero.
* @param beta the scalar beta. When beta is supplied as zero,
* y need not be set on input.
* @param y array of dimension at least {@code (1 + (m - 1) * abs(incy))}
* when {@code trans = 'N' or 'n'} and
* at least {@code (1 + (n - 1) * abs(incy))} otherwise.
* @param incy the increment for the elements of y, which must not be zero.
*/
void gemv(Layout layout, Transpose trans, int m, int n, double alpha, double[] A, int lda, double[] x, int incx, double beta, double[] y, int incy);
/**
* Performs the matrix-vector operation.
* <pre>{@code
* y := alpha*A*x + beta*y
* }</pre>
* or
* <pre>{@code
* y := alpha*A'*x + beta*y
* }</pre>
* where alpha and beta are scalars, x and y are vectors and A is an m by
* n matrix.
*
* @param layout matrix layout.
* @param trans normal, transpose, or conjugate transpose
* operation on the matrix.
* @param m the number of rows of the matrix A.
* @param n the number of columns of the matrix A.
* @param alpha the scalar alpha.
* @param A the leading m by n part of the array A must contain
* the matrix of coefficients.
* @param lda the leading dimension of A as declared in the caller.
* LDA must be at least max(1, m). The leading dimension
* parameter allows use of BLAS/LAPACK routines on a submatrix
* of a larger matrix.
* @param x array of dimension at least {@code (1 + (n - 1) * abs(incx))}
* when {@code trans = 'N' or 'n'} and
* at least {@code (1 + (m - 1) * abs(incx))} otherwise.
* @param incx the increment for the elements of x, which must not be zero.
* @param beta the scalar beta. When beta is supplied as zero,
* y need not be set on input.
* @param y array of dimension at least {@code (1 + (m - 1) * abs(incy))}
* when {@code trans = 'N' or 'n'} and
* at least {@code (1 + (n - 1) * abs(incy))} otherwise.
* @param incy the increment for the elements of y, which must not be zero.
*/
void gemv(Layout layout, Transpose trans, int m, int n, double alpha, DoubleBuffer A, int lda, DoubleBuffer x, int incx, double beta, DoubleBuffer y, int incy);
/**
* Performs the matrix-vector operation.
* <pre>{@code
* y := alpha*A*x + beta*y
* }</pre>
* or
* <pre>{@code
* y := alpha*A'*x + beta*y
* }</pre>
* where alpha and beta are scalars, x and y are vectors and A is an m by
* n matrix.
*
* @param layout matrix layout.
* @param trans normal, transpose, or conjugate transpose
* operation on the matrix.
* @param m the number of rows of the matrix A.
* @param n the number of columns of the matrix A.
* @param alpha the scalar alpha.
* @param A the leading m by n part of the array A must contain
* the matrix of coefficients.
* @param lda the leading dimension of A as declared in the caller.
* LDA must be at least max(1, m). The leading dimension
* parameter allows use of BLAS/LAPACK routines on a submatrix
* of a larger matrix.
* @param x array of dimension at least {@code (1 + (n - 1) * abs(incx))}
* when {@code trans = 'N' or 'n'} and
* at least {@code (1 + (m - 1) * abs(incx))} otherwise.
* @param incx the increment for the elements of x, which must not be zero.
* @param beta the scalar beta. When beta is supplied as zero,
* y need not be set on input.
* @param y array of dimension at least {@code (1 + (m - 1) * abs(incy))}
* when {@code trans = 'N' or 'n'} and
* at least {@code (1 + (n - 1) * abs(incy))} otherwise.
* @param incy the increment for the elements of y, which must not be zero.
*/
void gemv(Layout layout, Transpose trans, int m, int n, double alpha, DoublePointer A, int lda, DoublePointer x, int incx, double beta, DoublePointer y, int incy);
/**
* Performs the matrix-vector operation.
* <pre>{@code
* y := alpha*A*x + beta*y
* }</pre>
* or
* <pre>{@code
* y := alpha*A'*x + beta*y
* }</pre>
* where alpha and beta are scalars, x and y are vectors and A is an m by
* n matrix.
*
* @param layout matrix layout.
* @param trans normal, transpose, or conjugate transpose
* operation on the matrix.
* @param m the number of rows of the matrix A.
* @param n the number of columns of the matrix A.
* @param alpha the scalar alpha.
* @param A the leading m by n part of the array A must contain
* the matrix of coefficients.
* @param lda the leading dimension of A as declared in the caller.
* LDA must be at least max(1, m). The leading dimension
* parameter allows use of BLAS/LAPACK routines on a submatrix
* of a larger matrix.
* @param x array of dimension at least {@code (1 + (n - 1) * abs(incx))}
* when {@code trans = 'N' or 'n'} and
* at least {@code (1 + (m - 1)*abs(incx))} otherwise.
* @param incx the increment for the elements of x, which must not be zero.
* @param beta the scalar beta. When beta is supplied as zero,
* y need not be set on input.
* @param y array of dimension at least {@code (1 + (m - 1) * abs(incy))}
* when {@code trans = 'N' or 'n'} and
* at least {@code (1 + (n - 1) * abs(incy))} otherwise.
* @param incy the increment for the elements of y, which must not be zero.
*/
void gemv(Layout layout, Transpose trans, int m, int n, float alpha, float[] A, int lda, float[] x, int incx, float beta, float[] y, int incy);
/**
* Performs the matrix-vector operation.
* <pre>{@code
* y := alpha*A*x + beta*y
* }</pre>
* or
* <pre>{@code
* y := alpha*A'*x + beta*y
* }</pre>
* where alpha and beta are scalars, x and y are vectors and A is an m by
* n matrix.
*
* @param layout matrix layout.
* @param trans normal, transpose, or conjugate transpose
* operation on the matrix.
* @param m the number of rows of the matrix A.
* @param n the number of columns of the matrix A.
* @param alpha the scalar alpha.
* @param A the leading m by n part of the array A must contain
* the matrix of coefficients.
* @param lda the leading dimension of A as declared in the caller.
* LDA must be at least max(1, m). The leading dimension
* parameter allows use of BLAS/LAPACK routines on a submatrix
* of a larger matrix.
* @param x array of dimension at least {@code (1 + (n - 1) * abs(incx))}
* when {@code trans = 'N' or 'n'} and
* at least {@code (1 + (m - 1) * abs(incx))} otherwise.
* @param incx the increment for the elements of x, which must not be zero.
* @param beta the scalar beta. When beta is supplied as zero,
* y need not be set on input.
* @param y array of dimension at least {@code (1 + (m - 1) * abs(incy))}
* when {@code trans = 'N' or 'n'} and
* at least {@code (1 + (n - 1) * abs(incy))} otherwise.
* @param incy the increment for the elements of y, which must not be zero.
*/
void gemv(Layout layout, Transpose trans, int m, int n, float alpha, FloatBuffer A, int lda, FloatBuffer x, int incx, float beta, FloatBuffer y, int incy);
/**
* Performs the matrix-vector operation using a symmetric matrix.
* <pre>{@code
* y := alpha*A*x + beta*y
* }</pre>
* or
* <pre>{@code
* y := alpha*A'*x + beta*y
* }</pre>
* where alpha and beta are scalars, x and y are vectors and A is an m by
* n matrix.
*
* @param layout matrix layout.
* @param uplo the upper or lower triangular part of the matrix A is
* to be referenced.
* @param n the number of rows/columns of the symmetric matrix A.
* @param alpha the scalar alpha.
* @param A the symmetric matrix.
* @param lda the leading dimension of A as declared in the caller.
* @param x array of dimension at least {@code (1 + (n - 1) * abs(incx))}.
* @param incx the increment for the elements of x, which must not be zero.
* @param beta the scalar beta. When beta is supplied as zero,
* y need not be set on input.
* @param y array of dimension at least {@code (1 + (n - 1) * abs(incy))}.
* @param incy the increment for the elements of y, which must not be zero.
*/
void symv(Layout layout, UPLO uplo, int n, double alpha, double[] A, int lda, double[] x, int incx, double beta, double[] y, int incy);
/**
* Performs the matrix-vector operation using a symmetric matrix.
* <pre>{@code
* y := alpha*A*x + beta*y
* }</pre>
* or
* <pre>{@code
* y := alpha*A'*x + beta*y
* }</pre>
* where alpha and beta are scalars, x and y are vectors and A is an m by
* n matrix.
*
* @param layout matrix layout.
* @param uplo the upper or lower triangular part of the matrix A is
* to be referenced.
* @param n the number of rows/columns of the symmetric matrix A.
* @param alpha the scalar alpha.
* @param A the symmetric matrix.
* @param lda the leading dimension of A as declared in the caller.
* @param x array of dimension at least {@code (1 + (n - 1) * abs(incx))}.
* @param incx the increment for the elements of x, which must not be zero.
* @param beta the scalar beta. When beta is supplied as zero,
* y need not be set on input.
* @param y array of dimension at least {@code (1 + (n - 1) * abs(incy))}.
* @param incy the increment for the elements of y, which must not be zero.
*/
void symv(Layout layout, UPLO uplo, int n, double alpha, DoubleBuffer A, int lda, DoubleBuffer x, int incx, double beta, DoubleBuffer y, int incy);
/**
* Performs the matrix-vector operation using a symmetric matrix.
* <pre>{@code
* y := alpha*A*x + beta*y
* }</pre>
* or
* <pre>{@code
* y := alpha*A'*x + beta*y
* }</pre>
* where alpha and beta are scalars, x and y are vectors and A is an m by
* n matrix.
*
* @param layout matrix layout.
* @param uplo the upper or lower triangular part of the matrix A is
* to be referenced.
* @param n the number of rows/columns of the symmetric matrix A.
* @param alpha the scalar alpha.
* @param A the symmetric matrix.
* @param lda the leading dimension of A as declared in the caller.
* @param x array of dimension at least {@code (1 + (n - 1) * abs(incx))}.
* @param incx the increment for the elements of x, which must not be zero.
* @param beta the scalar beta. When beta is supplied as zero,
* y need not be set on input.
* @param y array of dimension at least {@code (1 + (n - 1) * abs(incy))}.
* @param incy the increment for the elements of y, which must not be zero.
*/
void symv(Layout layout, UPLO uplo, int n, double alpha, DoublePointer A, int lda, DoublePointer x, int incx, double beta, DoublePointer y, int incy);
/**
* Performs the matrix-vector operation using a symmetric matrix.
* <pre>{@code
* y := alpha*A*x + beta*y
* }</pre>
* or
* <pre>{@code
* y := alpha*A'*x + beta*y
* }</pre>
* where alpha and beta are scalars, x and y are vectors and A is an m by
* n matrix.
*
* @param layout matrix layout.
* @param uplo the upper or lower triangular part of the matrix A is
* to be referenced.
* @param n the number of rows/columns of the symmetric matrix A.
* @param alpha the scalar alpha.
* @param A the symmetric matrix.
* @param lda the leading dimension of A as declared in the caller.
* @param x array of dimension at least {@code (1 + (n - 1) * abs(incx))}.
* @param incx the increment for the elements of x, which must not be zero.
* @param beta the scalar beta. When beta is supplied as zero,
* y need not be set on input.
* @param y array of dimension at least {@code (1 + (n - 1) * abs(incy))}.
* @param incy the increment for the elements of y, which must not be zero.
*/
void symv(Layout layout, UPLO uplo, int n, float alpha, float[] A, int lda, float[] x, int incx, float beta, float[] y, int incy);
/**
* Performs the matrix-vector operation using a symmetric matrix.
* <pre>{@code
* y := alpha*A*x + beta*y
* }</pre>
* or
* <pre>{@code
* y := alpha*A'*x + beta*y
* }</pre>
* where alpha and beta are scalars, x and y are vectors and A is an m by
* n matrix.
*
* @param layout matrix layout.
* @param uplo the upper or lower triangular part of the matrix A is
* to be referenced.
* @param n the number of rows/columns of the symmetric matrix A.
* @param alpha the scalar alpha.
* @param A the symmetric matrix.
* @param lda the leading dimension of A as declared in the caller.
* @param x array of dimension at least {@code (1 + (n - 1) * abs(incx))}.
* @param incx the increment for the elements of x, which must not be zero.
* @param beta the scalar beta. When beta is supplied as zero,
* y need not be set on input.
* @param y array of dimension at least {@code (1 + (n - 1) * abs(incy))}.
* @param incy the increment for the elements of y, which must not be zero.
*/
void symv(Layout layout, UPLO uplo, int n, float alpha, FloatBuffer A, int lda, FloatBuffer x, int incx, float beta, FloatBuffer y, int incy);
/**
* Performs the matrix-vector operation using a symmetric packed matrix.
* <pre>{@code
* y := alpha*A*x + beta*y
* }</pre>
* or
* <pre>{@code
* y := alpha*A'*x + beta*y
* }</pre>
* where alpha and beta are scalars, x and y are vectors and A is an m by
* n matrix.
*
* @param layout matrix layout.
* @param uplo the upper or lower triangular part of the matrix A is
* to be referenced.
* @param n the number of rows/columns of the symmetric matrix A.
* @param alpha the scalar alpha.
* @param A the symmetric packed matrix.
* @param x array of dimension at least {@code (1 + (n - 1) * abs(incx))}.
* @param incx the increment for the elements of x, which must not be zero.
* @param beta the scalar beta. When beta is supplied as zero,
* y need not be set on input.
* @param y array of dimension at least {@code (1 + (n - 1) * abs(incy))}.
* @param incy the increment for the elements of y, which must not be zero.
*/
void spmv(Layout layout, UPLO uplo, int n, double alpha, double[] A, double[] x, int incx, double beta, double[] y, int incy);
/**
* Performs the matrix-vector operation using a symmetric packed matrix.
* <pre>{@code
* y := alpha*A*x + beta*y
* }</pre>
* or
* <pre>{@code
* y := alpha*A'*x + beta*y
* }</pre>
* where alpha and beta are scalars, x and y are vectors and A is an m by
* n matrix.
*
* @param layout matrix layout.
* @param uplo the upper or lower triangular part of the matrix A is
* to be referenced.
* @param n the number of rows/columns of the symmetric matrix A.
* @param alpha the scalar alpha.
* @param A the symmetric packed matrix.
* @param x array of dimension at least {@code (1 + (n - 1) * abs(incx))}.
* @param incx the increment for the elements of x, which must not be zero.
* @param beta the scalar beta. When beta is supplied as zero,
* y need not be set on input.
* @param y array of dimension at least {@code (1 + (n - 1) * abs(incy))}.
* @param incy the increment for the elements of y, which must not be zero.
*/
void spmv(Layout layout, UPLO uplo, int n, double alpha, DoubleBuffer A, DoubleBuffer x, int incx, double beta, DoubleBuffer y, int incy);
/**
* Performs the matrix-vector operation using a symmetric packed matrix.
* <pre>{@code
* y := alpha*A*x + beta*y
* }</pre>
* or
* <pre>{@code
* y := alpha*A'*x + beta*y
* }</pre>
* where alpha and beta are scalars, x and y are vectors and A is an m by
* n matrix.
*
* @param layout matrix layout.
* @param uplo the upper or lower triangular part of the matrix A is
* to be referenced.
* @param n the number of rows/columns of the symmetric matrix A.
* @param alpha the scalar alpha.
* @param A the symmetric packed matrix.
* @param x array of dimension at least {@code (1 + (n - 1) * abs(incx))}.
* @param incx the increment for the elements of x, which must not be zero.
* @param beta the scalar beta. When beta is supplied as zero,
* y need not be set on input.
* @param y array of dimension at least {@code (1 + (n - 1) * abs(incy))}.
* @param incy the increment for the elements of y, which must not be zero.
*/
void spmv(Layout layout, UPLO uplo, int n, float alpha, float[] A, float[] x, int incx, float beta, float[] y, int incy);
/**
* Performs the matrix-vector operation using a symmetric packed matrix.
* <pre>{@code
* y := alpha*A*x + beta*y
* }</pre>
* or
* <pre>{@code
* y := alpha*A'*x + beta*y
* }</pre>
* where alpha and beta are scalars, x and y are vectors and A is an m by
* n matrix.
*
* @param layout matrix layout.
* @param uplo the upper or lower triangular part of the matrix A is
* to be referenced.
* @param n the number of rows/columns of the symmetric matrix A.
* @param alpha the scalar alpha.
* @param A the symmetric packed matrix.
* @param x array of dimension at least {@code (1 + (n - 1) * abs(incx))}.
* @param incx the increment for the elements of x, which must not be zero.
* @param beta the scalar beta. When beta is supplied as zero,
* y need not be set on input.
* @param y array of dimension at least {@code (1 + (n - 1) * abs(incy))}
* @param incy the increment for the elements of y, which must not be zero.
*/
void spmv(Layout layout, UPLO uplo, int n, float alpha, FloatBuffer A, FloatBuffer x, int incx, float beta, FloatBuffer y, int incy);
/**
* Performs the matrix-vector operation using a triangular matrix.
* <pre>{@code
* x := A*x
* }</pre>
* or
* <pre>{@code
* x := A'*x
* }</pre>
*
* @param layout matrix layout.
* @param uplo the upper or lower triangular part of the matrix A is
* to be referenced.
* @param trans normal, transpose, or conjugate transpose
* operation on the matrix.
* @param diag unit diagonal or not.
* @param n the number of rows/columns of the triangular matrix A.
* @param A the symmetric matrix.
* @param lda the leading dimension of A as declared in the caller.
* @param x array of dimension at least {@code (1 + (n - 1) * abs(incx))}
* when {@code trans = 'N' or 'n'} and
* at least {@code (1 + (m - 1) * abs(incx))} otherwise.
* @param incx the increment for the elements of x, which must not be zero.
*/
void trmv(Layout layout, UPLO uplo, Transpose trans, Diag diag, int n, double[] A, int lda, double[] x, int incx);
/**
* Performs the matrix-vector operation using a triangular matrix.
* <pre>{@code
* x := A*x
* }</pre>
* or
* <pre>{@code
* x := A'*x
* }</pre>
*
* @param layout matrix layout.
* @param uplo the upper or lower triangular part of the matrix A is
* to be referenced.
* @param trans normal, transpose, or conjugate transpose
* operation on the matrix.
* @param diag unit diagonal or not.
* @param n the number of rows/columns of the triangular matrix A.
* @param A the symmetric matrix.
* @param lda the leading dimension of A as declared in the caller.
* @param x array of dimension at least {@code (1 + (n - 1) * abs(incx))}
* when {@code trans = 'N' or 'n'} and
* at least {@code (1 + (m - 1) * abs(incx))} otherwise.
* @param incx the increment for the elements of x, which must not be zero.
*/
void trmv(Layout layout, UPLO uplo, Transpose trans, Diag diag, int n, DoubleBuffer A, int lda, DoubleBuffer x, int incx);
/**
* Performs the matrix-vector operation using a triangular matrix.
* <pre>{@code
* x := A*x
* }</pre>
* or
* <pre>{@code