github.com/jingcheng-WU/gonum@v0.9.1-0.20210323123734-f1a2a11a8f7b/blas/blas.go (about)

     1  // Copyright ©2013 The Gonum Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:generate ./conversions.bash
     6  
     7  package blas
     8  
     9  // Flag constants indicate Givens transformation H matrix state.
    10  type Flag int
    11  
    12  const (
    13  	Identity    Flag = -2 // H is the identity matrix; no rotation is needed.
    14  	Rescaling   Flag = -1 // H specifies rescaling.
    15  	OffDiagonal Flag = 0  // Off-diagonal elements of H are non-unit.
    16  	Diagonal    Flag = 1  // Diagonal elements of H are non-unit.
    17  )
    18  
    19  // SrotmParams contains Givens transformation parameters returned
    20  // by the Float32 Srotm method.
    21  type SrotmParams struct {
    22  	Flag
    23  	H [4]float32 // Column-major 2 by 2 matrix.
    24  }
    25  
    26  // DrotmParams contains Givens transformation parameters returned
    27  // by the Float64 Drotm method.
    28  type DrotmParams struct {
    29  	Flag
    30  	H [4]float64 // Column-major 2 by 2 matrix.
    31  }
    32  
    33  // Transpose specifies the transposition operation of a matrix.
    34  type Transpose byte
    35  
    36  const (
    37  	NoTrans   Transpose = 'N'
    38  	Trans     Transpose = 'T'
    39  	ConjTrans Transpose = 'C'
    40  )
    41  
    42  // Uplo specifies whether a matrix is upper or lower triangular.
    43  type Uplo byte
    44  
    45  const (
    46  	Upper Uplo = 'U'
    47  	Lower Uplo = 'L'
    48  	All   Uplo = 'A'
    49  )
    50  
    51  // Diag specifies whether a matrix is unit triangular.
    52  type Diag byte
    53  
    54  const (
    55  	NonUnit Diag = 'N'
    56  	Unit    Diag = 'U'
    57  )
    58  
    59  // Side specifies from which side a multiplication operation is performed.
    60  type Side byte
    61  
    62  const (
    63  	Left  Side = 'L'
    64  	Right Side = 'R'
    65  )
    66  
    67  // Float32 implements the single precision real BLAS routines.
    68  type Float32 interface {
    69  	Float32Level1
    70  	Float32Level2
    71  	Float32Level3
    72  }
    73  
    74  // Float32Level1 implements the single precision real BLAS Level 1 routines.
    75  type Float32Level1 interface {
    76  	Sdsdot(n int, alpha float32, x []float32, incX int, y []float32, incY int) float32
    77  	Dsdot(n int, x []float32, incX int, y []float32, incY int) float64
    78  	Sdot(n int, x []float32, incX int, y []float32, incY int) float32
    79  	Snrm2(n int, x []float32, incX int) float32
    80  	Sasum(n int, x []float32, incX int) float32
    81  	Isamax(n int, x []float32, incX int) int
    82  	Sswap(n int, x []float32, incX int, y []float32, incY int)
    83  	Scopy(n int, x []float32, incX int, y []float32, incY int)
    84  	Saxpy(n int, alpha float32, x []float32, incX int, y []float32, incY int)
    85  	Srotg(a, b float32) (c, s, r, z float32)
    86  	Srotmg(d1, d2, b1, b2 float32) (p SrotmParams, rd1, rd2, rb1 float32)
    87  	Srot(n int, x []float32, incX int, y []float32, incY int, c, s float32)
    88  	Srotm(n int, x []float32, incX int, y []float32, incY int, p SrotmParams)
    89  	Sscal(n int, alpha float32, x []float32, incX int)
    90  }
    91  
    92  // Float32Level2 implements the single precision real BLAS Level 2 routines.
    93  type Float32Level2 interface {
    94  	Sgemv(tA Transpose, m, n int, alpha float32, a []float32, lda int, x []float32, incX int, beta float32, y []float32, incY int)
    95  	Sgbmv(tA Transpose, m, n, kL, kU int, alpha float32, a []float32, lda int, x []float32, incX int, beta float32, y []float32, incY int)
    96  	Strmv(ul Uplo, tA Transpose, d Diag, n int, a []float32, lda int, x []float32, incX int)
    97  	Stbmv(ul Uplo, tA Transpose, d Diag, n, k int, a []float32, lda int, x []float32, incX int)
    98  	Stpmv(ul Uplo, tA Transpose, d Diag, n int, ap []float32, x []float32, incX int)
    99  	Strsv(ul Uplo, tA Transpose, d Diag, n int, a []float32, lda int, x []float32, incX int)
   100  	Stbsv(ul Uplo, tA Transpose, d Diag, n, k int, a []float32, lda int, x []float32, incX int)
   101  	Stpsv(ul Uplo, tA Transpose, d Diag, n int, ap []float32, x []float32, incX int)
   102  	Ssymv(ul Uplo, n int, alpha float32, a []float32, lda int, x []float32, incX int, beta float32, y []float32, incY int)
   103  	Ssbmv(ul Uplo, n, k int, alpha float32, a []float32, lda int, x []float32, incX int, beta float32, y []float32, incY int)
   104  	Sspmv(ul Uplo, n int, alpha float32, ap []float32, x []float32, incX int, beta float32, y []float32, incY int)
   105  	Sger(m, n int, alpha float32, x []float32, incX int, y []float32, incY int, a []float32, lda int)
   106  	Ssyr(ul Uplo, n int, alpha float32, x []float32, incX int, a []float32, lda int)
   107  	Sspr(ul Uplo, n int, alpha float32, x []float32, incX int, ap []float32)
   108  	Ssyr2(ul Uplo, n int, alpha float32, x []float32, incX int, y []float32, incY int, a []float32, lda int)
   109  	Sspr2(ul Uplo, n int, alpha float32, x []float32, incX int, y []float32, incY int, a []float32)
   110  }
   111  
   112  // Float32Level3 implements the single precision real BLAS Level 3 routines.
   113  type Float32Level3 interface {
   114  	Sgemm(tA, tB Transpose, m, n, k int, alpha float32, a []float32, lda int, b []float32, ldb int, beta float32, c []float32, ldc int)
   115  	Ssymm(s Side, ul Uplo, m, n int, alpha float32, a []float32, lda int, b []float32, ldb int, beta float32, c []float32, ldc int)
   116  	Ssyrk(ul Uplo, t Transpose, n, k int, alpha float32, a []float32, lda int, beta float32, c []float32, ldc int)
   117  	Ssyr2k(ul Uplo, t Transpose, n, k int, alpha float32, a []float32, lda int, b []float32, ldb int, beta float32, c []float32, ldc int)
   118  	Strmm(s Side, ul Uplo, tA Transpose, d Diag, m, n int, alpha float32, a []float32, lda int, b []float32, ldb int)
   119  	Strsm(s Side, ul Uplo, tA Transpose, d Diag, m, n int, alpha float32, a []float32, lda int, b []float32, ldb int)
   120  }
   121  
   122  // Float64 implements the single precision real BLAS routines.
   123  type Float64 interface {
   124  	Float64Level1
   125  	Float64Level2
   126  	Float64Level3
   127  }
   128  
   129  // Float64Level1 implements the double precision real BLAS Level 1 routines.
   130  type Float64Level1 interface {
   131  	Ddot(n int, x []float64, incX int, y []float64, incY int) float64
   132  	Dnrm2(n int, x []float64, incX int) float64
   133  	Dasum(n int, x []float64, incX int) float64
   134  	Idamax(n int, x []float64, incX int) int
   135  	Dswap(n int, x []float64, incX int, y []float64, incY int)
   136  	Dcopy(n int, x []float64, incX int, y []float64, incY int)
   137  	Daxpy(n int, alpha float64, x []float64, incX int, y []float64, incY int)
   138  	Drotg(a, b float64) (c, s, r, z float64)
   139  	Drotmg(d1, d2, b1, b2 float64) (p DrotmParams, rd1, rd2, rb1 float64)
   140  	Drot(n int, x []float64, incX int, y []float64, incY int, c float64, s float64)
   141  	Drotm(n int, x []float64, incX int, y []float64, incY int, p DrotmParams)
   142  	Dscal(n int, alpha float64, x []float64, incX int)
   143  }
   144  
   145  // Float64Level2 implements the double precision real BLAS Level 2 routines.
   146  type Float64Level2 interface {
   147  	Dgemv(tA Transpose, m, n int, alpha float64, a []float64, lda int, x []float64, incX int, beta float64, y []float64, incY int)
   148  	Dgbmv(tA Transpose, m, n, kL, kU int, alpha float64, a []float64, lda int, x []float64, incX int, beta float64, y []float64, incY int)
   149  	Dtrmv(ul Uplo, tA Transpose, d Diag, n int, a []float64, lda int, x []float64, incX int)
   150  	Dtbmv(ul Uplo, tA Transpose, d Diag, n, k int, a []float64, lda int, x []float64, incX int)
   151  	Dtpmv(ul Uplo, tA Transpose, d Diag, n int, ap []float64, x []float64, incX int)
   152  	Dtrsv(ul Uplo, tA Transpose, d Diag, n int, a []float64, lda int, x []float64, incX int)
   153  	Dtbsv(ul Uplo, tA Transpose, d Diag, n, k int, a []float64, lda int, x []float64, incX int)
   154  	Dtpsv(ul Uplo, tA Transpose, d Diag, n int, ap []float64, x []float64, incX int)
   155  	Dsymv(ul Uplo, n int, alpha float64, a []float64, lda int, x []float64, incX int, beta float64, y []float64, incY int)
   156  	Dsbmv(ul Uplo, n, k int, alpha float64, a []float64, lda int, x []float64, incX int, beta float64, y []float64, incY int)
   157  	Dspmv(ul Uplo, n int, alpha float64, ap []float64, x []float64, incX int, beta float64, y []float64, incY int)
   158  	Dger(m, n int, alpha float64, x []float64, incX int, y []float64, incY int, a []float64, lda int)
   159  	Dsyr(ul Uplo, n int, alpha float64, x []float64, incX int, a []float64, lda int)
   160  	Dspr(ul Uplo, n int, alpha float64, x []float64, incX int, ap []float64)
   161  	Dsyr2(ul Uplo, n int, alpha float64, x []float64, incX int, y []float64, incY int, a []float64, lda int)
   162  	Dspr2(ul Uplo, n int, alpha float64, x []float64, incX int, y []float64, incY int, a []float64)
   163  }
   164  
   165  // Float64Level3 implements the double precision real BLAS Level 3 routines.
   166  type Float64Level3 interface {
   167  	Dgemm(tA, tB Transpose, m, n, k int, alpha float64, a []float64, lda int, b []float64, ldb int, beta float64, c []float64, ldc int)
   168  	Dsymm(s Side, ul Uplo, m, n int, alpha float64, a []float64, lda int, b []float64, ldb int, beta float64, c []float64, ldc int)
   169  	Dsyrk(ul Uplo, t Transpose, n, k int, alpha float64, a []float64, lda int, beta float64, c []float64, ldc int)
   170  	Dsyr2k(ul Uplo, t Transpose, n, k int, alpha float64, a []float64, lda int, b []float64, ldb int, beta float64, c []float64, ldc int)
   171  	Dtrmm(s Side, ul Uplo, tA Transpose, d Diag, m, n int, alpha float64, a []float64, lda int, b []float64, ldb int)
   172  	Dtrsm(s Side, ul Uplo, tA Transpose, d Diag, m, n int, alpha float64, a []float64, lda int, b []float64, ldb int)
   173  }
   174  
   175  // Complex64 implements the single precision complex BLAS routines.
   176  type Complex64 interface {
   177  	Complex64Level1
   178  	Complex64Level2
   179  	Complex64Level3
   180  }
   181  
   182  // Complex64Level1 implements the single precision complex BLAS Level 1 routines.
   183  type Complex64Level1 interface {
   184  	Cdotu(n int, x []complex64, incX int, y []complex64, incY int) (dotu complex64)
   185  	Cdotc(n int, x []complex64, incX int, y []complex64, incY int) (dotc complex64)
   186  	Scnrm2(n int, x []complex64, incX int) float32
   187  	Scasum(n int, x []complex64, incX int) float32
   188  	Icamax(n int, x []complex64, incX int) int
   189  	Cswap(n int, x []complex64, incX int, y []complex64, incY int)
   190  	Ccopy(n int, x []complex64, incX int, y []complex64, incY int)
   191  	Caxpy(n int, alpha complex64, x []complex64, incX int, y []complex64, incY int)
   192  	Cscal(n int, alpha complex64, x []complex64, incX int)
   193  	Csscal(n int, alpha float32, x []complex64, incX int)
   194  }
   195  
   196  // Complex64Level2 implements the single precision complex BLAS routines Level 2 routines.
   197  type Complex64Level2 interface {
   198  	Cgemv(tA Transpose, m, n int, alpha complex64, a []complex64, lda int, x []complex64, incX int, beta complex64, y []complex64, incY int)
   199  	Cgbmv(tA Transpose, m, n, kL, kU int, alpha complex64, a []complex64, lda int, x []complex64, incX int, beta complex64, y []complex64, incY int)
   200  	Ctrmv(ul Uplo, tA Transpose, d Diag, n int, a []complex64, lda int, x []complex64, incX int)
   201  	Ctbmv(ul Uplo, tA Transpose, d Diag, n, k int, a []complex64, lda int, x []complex64, incX int)
   202  	Ctpmv(ul Uplo, tA Transpose, d Diag, n int, ap []complex64, x []complex64, incX int)
   203  	Ctrsv(ul Uplo, tA Transpose, d Diag, n int, a []complex64, lda int, x []complex64, incX int)
   204  	Ctbsv(ul Uplo, tA Transpose, d Diag, n, k int, a []complex64, lda int, x []complex64, incX int)
   205  	Ctpsv(ul Uplo, tA Transpose, d Diag, n int, ap []complex64, x []complex64, incX int)
   206  	Chemv(ul Uplo, n int, alpha complex64, a []complex64, lda int, x []complex64, incX int, beta complex64, y []complex64, incY int)
   207  	Chbmv(ul Uplo, n, k int, alpha complex64, a []complex64, lda int, x []complex64, incX int, beta complex64, y []complex64, incY int)
   208  	Chpmv(ul Uplo, n int, alpha complex64, ap []complex64, x []complex64, incX int, beta complex64, y []complex64, incY int)
   209  	Cgeru(m, n int, alpha complex64, x []complex64, incX int, y []complex64, incY int, a []complex64, lda int)
   210  	Cgerc(m, n int, alpha complex64, x []complex64, incX int, y []complex64, incY int, a []complex64, lda int)
   211  	Cher(ul Uplo, n int, alpha float32, x []complex64, incX int, a []complex64, lda int)
   212  	Chpr(ul Uplo, n int, alpha float32, x []complex64, incX int, a []complex64)
   213  	Cher2(ul Uplo, n int, alpha complex64, x []complex64, incX int, y []complex64, incY int, a []complex64, lda int)
   214  	Chpr2(ul Uplo, n int, alpha complex64, x []complex64, incX int, y []complex64, incY int, ap []complex64)
   215  }
   216  
   217  // Complex64Level3 implements the single precision complex BLAS Level 3 routines.
   218  type Complex64Level3 interface {
   219  	Cgemm(tA, tB Transpose, m, n, k int, alpha complex64, a []complex64, lda int, b []complex64, ldb int, beta complex64, c []complex64, ldc int)
   220  	Csymm(s Side, ul Uplo, m, n int, alpha complex64, a []complex64, lda int, b []complex64, ldb int, beta complex64, c []complex64, ldc int)
   221  	Csyrk(ul Uplo, t Transpose, n, k int, alpha complex64, a []complex64, lda int, beta complex64, c []complex64, ldc int)
   222  	Csyr2k(ul Uplo, t Transpose, n, k int, alpha complex64, a []complex64, lda int, b []complex64, ldb int, beta complex64, c []complex64, ldc int)
   223  	Ctrmm(s Side, ul Uplo, tA Transpose, d Diag, m, n int, alpha complex64, a []complex64, lda int, b []complex64, ldb int)
   224  	Ctrsm(s Side, ul Uplo, tA Transpose, d Diag, m, n int, alpha complex64, a []complex64, lda int, b []complex64, ldb int)
   225  	Chemm(s Side, ul Uplo, m, n int, alpha complex64, a []complex64, lda int, b []complex64, ldb int, beta complex64, c []complex64, ldc int)
   226  	Cherk(ul Uplo, t Transpose, n, k int, alpha float32, a []complex64, lda int, beta float32, c []complex64, ldc int)
   227  	Cher2k(ul Uplo, t Transpose, n, k int, alpha complex64, a []complex64, lda int, b []complex64, ldb int, beta float32, c []complex64, ldc int)
   228  }
   229  
   230  // Complex128 implements the double precision complex BLAS routines.
   231  type Complex128 interface {
   232  	Complex128Level1
   233  	Complex128Level2
   234  	Complex128Level3
   235  }
   236  
   237  // Complex128Level1 implements the double precision complex BLAS Level 1 routines.
   238  type Complex128Level1 interface {
   239  	Zdotu(n int, x []complex128, incX int, y []complex128, incY int) (dotu complex128)
   240  	Zdotc(n int, x []complex128, incX int, y []complex128, incY int) (dotc complex128)
   241  	Dznrm2(n int, x []complex128, incX int) float64
   242  	Dzasum(n int, x []complex128, incX int) float64
   243  	Izamax(n int, x []complex128, incX int) int
   244  	Zswap(n int, x []complex128, incX int, y []complex128, incY int)
   245  	Zcopy(n int, x []complex128, incX int, y []complex128, incY int)
   246  	Zaxpy(n int, alpha complex128, x []complex128, incX int, y []complex128, incY int)
   247  	Zscal(n int, alpha complex128, x []complex128, incX int)
   248  	Zdscal(n int, alpha float64, x []complex128, incX int)
   249  }
   250  
   251  // Complex128Level2 implements the double precision complex BLAS Level 2 routines.
   252  type Complex128Level2 interface {
   253  	Zgemv(tA Transpose, m, n int, alpha complex128, a []complex128, lda int, x []complex128, incX int, beta complex128, y []complex128, incY int)
   254  	Zgbmv(tA Transpose, m, n int, kL int, kU int, alpha complex128, a []complex128, lda int, x []complex128, incX int, beta complex128, y []complex128, incY int)
   255  	Ztrmv(ul Uplo, tA Transpose, d Diag, n int, a []complex128, lda int, x []complex128, incX int)
   256  	Ztbmv(ul Uplo, tA Transpose, d Diag, n, k int, a []complex128, lda int, x []complex128, incX int)
   257  	Ztpmv(ul Uplo, tA Transpose, d Diag, n int, ap []complex128, x []complex128, incX int)
   258  	Ztrsv(ul Uplo, tA Transpose, d Diag, n int, a []complex128, lda int, x []complex128, incX int)
   259  	Ztbsv(ul Uplo, tA Transpose, d Diag, n, k int, a []complex128, lda int, x []complex128, incX int)
   260  	Ztpsv(ul Uplo, tA Transpose, d Diag, n int, ap []complex128, x []complex128, incX int)
   261  	Zhemv(ul Uplo, n int, alpha complex128, a []complex128, lda int, x []complex128, incX int, beta complex128, y []complex128, incY int)
   262  	Zhbmv(ul Uplo, n, k int, alpha complex128, a []complex128, lda int, x []complex128, incX int, beta complex128, y []complex128, incY int)
   263  	Zhpmv(ul Uplo, n int, alpha complex128, ap []complex128, x []complex128, incX int, beta complex128, y []complex128, incY int)
   264  	Zgeru(m, n int, alpha complex128, x []complex128, incX int, y []complex128, incY int, a []complex128, lda int)
   265  	Zgerc(m, n int, alpha complex128, x []complex128, incX int, y []complex128, incY int, a []complex128, lda int)
   266  	Zher(ul Uplo, n int, alpha float64, x []complex128, incX int, a []complex128, lda int)
   267  	Zhpr(ul Uplo, n int, alpha float64, x []complex128, incX int, a []complex128)
   268  	Zher2(ul Uplo, n int, alpha complex128, x []complex128, incX int, y []complex128, incY int, a []complex128, lda int)
   269  	Zhpr2(ul Uplo, n int, alpha complex128, x []complex128, incX int, y []complex128, incY int, ap []complex128)
   270  }
   271  
   272  // Complex128Level3 implements the double precision complex BLAS Level 3 routines.
   273  type Complex128Level3 interface {
   274  	Zgemm(tA, tB Transpose, m, n, k int, alpha complex128, a []complex128, lda int, b []complex128, ldb int, beta complex128, c []complex128, ldc int)
   275  	Zsymm(s Side, ul Uplo, m, n int, alpha complex128, a []complex128, lda int, b []complex128, ldb int, beta complex128, c []complex128, ldc int)
   276  	Zsyrk(ul Uplo, t Transpose, n, k int, alpha complex128, a []complex128, lda int, beta complex128, c []complex128, ldc int)
   277  	Zsyr2k(ul Uplo, t Transpose, n, k int, alpha complex128, a []complex128, lda int, b []complex128, ldb int, beta complex128, c []complex128, ldc int)
   278  	Ztrmm(s Side, ul Uplo, tA Transpose, d Diag, m, n int, alpha complex128, a []complex128, lda int, b []complex128, ldb int)
   279  	Ztrsm(s Side, ul Uplo, tA Transpose, d Diag, m, n int, alpha complex128, a []complex128, lda int, b []complex128, ldb int)
   280  	Zhemm(s Side, ul Uplo, m, n int, alpha complex128, a []complex128, lda int, b []complex128, ldb int, beta complex128, c []complex128, ldc int)
   281  	Zherk(ul Uplo, t Transpose, n, k int, alpha float64, a []complex128, lda int, beta float64, c []complex128, ldc int)
   282  	Zher2k(ul Uplo, t Transpose, n, k int, alpha complex128, a []complex128, lda int, b []complex128, ldb int, beta float64, c []complex128, ldc int)
   283  }