github.com/gopherd/gonum@v0.0.4/blas/gonum/level2cmplx64.go (about)

     1  // Code generated by "go generate github.com/gopherd/gonum/blas/gonum”; DO NOT EDIT.
     2  
     3  // Copyright ©2017 The Gonum Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  package gonum
     8  
     9  import (
    10  	cmplx "github.com/gopherd/gonum/internal/cmplx64"
    11  
    12  	"github.com/gopherd/gonum/blas"
    13  	"github.com/gopherd/gonum/internal/asm/c64"
    14  )
    15  
    16  var _ blas.Complex64Level2 = Implementation{}
    17  
    18  // Cgbmv performs one of the matrix-vector operations
    19  //  y = alpha * A * x + beta * y   if trans = blas.NoTrans
    20  //  y = alpha * Aᵀ * x + beta * y  if trans = blas.Trans
    21  //  y = alpha * Aᴴ * x + beta * y  if trans = blas.ConjTrans
    22  // where alpha and beta are scalars, x and y are vectors, and A is an m×n band matrix
    23  // with kL sub-diagonals and kU super-diagonals.
    24  //
    25  // Complex64 implementations are autogenerated and not directly tested.
    26  func (Implementation) Cgbmv(trans blas.Transpose, m, n, kL, kU int, alpha complex64, a []complex64, lda int, x []complex64, incX int, beta complex64, y []complex64, incY int) {
    27  	switch trans {
    28  	default:
    29  		panic(badTranspose)
    30  	case blas.NoTrans, blas.Trans, blas.ConjTrans:
    31  	}
    32  	if m < 0 {
    33  		panic(mLT0)
    34  	}
    35  	if n < 0 {
    36  		panic(nLT0)
    37  	}
    38  	if kL < 0 {
    39  		panic(kLLT0)
    40  	}
    41  	if kU < 0 {
    42  		panic(kULT0)
    43  	}
    44  	if lda < kL+kU+1 {
    45  		panic(badLdA)
    46  	}
    47  	if incX == 0 {
    48  		panic(zeroIncX)
    49  	}
    50  	if incY == 0 {
    51  		panic(zeroIncY)
    52  	}
    53  
    54  	// Quick return if possible.
    55  	if m == 0 || n == 0 {
    56  		return
    57  	}
    58  
    59  	// For zero matrix size the following slice length checks are trivially satisfied.
    60  	if len(a) < lda*(min(m, n+kL)-1)+kL+kU+1 {
    61  		panic(shortA)
    62  	}
    63  	var lenX, lenY int
    64  	if trans == blas.NoTrans {
    65  		lenX, lenY = n, m
    66  	} else {
    67  		lenX, lenY = m, n
    68  	}
    69  	if (incX > 0 && len(x) <= (lenX-1)*incX) || (incX < 0 && len(x) <= (1-lenX)*incX) {
    70  		panic(shortX)
    71  	}
    72  	if (incY > 0 && len(y) <= (lenY-1)*incY) || (incY < 0 && len(y) <= (1-lenY)*incY) {
    73  		panic(shortY)
    74  	}
    75  
    76  	// Quick return if possible.
    77  	if alpha == 0 && beta == 1 {
    78  		return
    79  	}
    80  
    81  	var kx int
    82  	if incX < 0 {
    83  		kx = (1 - lenX) * incX
    84  	}
    85  	var ky int
    86  	if incY < 0 {
    87  		ky = (1 - lenY) * incY
    88  	}
    89  
    90  	// Form y = beta*y.
    91  	if beta != 1 {
    92  		if incY == 1 {
    93  			if beta == 0 {
    94  				for i := range y[:lenY] {
    95  					y[i] = 0
    96  				}
    97  			} else {
    98  				c64.ScalUnitary(beta, y[:lenY])
    99  			}
   100  		} else {
   101  			iy := ky
   102  			if beta == 0 {
   103  				for i := 0; i < lenY; i++ {
   104  					y[iy] = 0
   105  					iy += incY
   106  				}
   107  			} else {
   108  				if incY > 0 {
   109  					c64.ScalInc(beta, y, uintptr(lenY), uintptr(incY))
   110  				} else {
   111  					c64.ScalInc(beta, y, uintptr(lenY), uintptr(-incY))
   112  				}
   113  			}
   114  		}
   115  	}
   116  
   117  	nRow := min(m, n+kL)
   118  	nCol := kL + 1 + kU
   119  	switch trans {
   120  	case blas.NoTrans:
   121  		iy := ky
   122  		if incX == 1 {
   123  			for i := 0; i < nRow; i++ {
   124  				l := max(0, kL-i)
   125  				u := min(nCol, n+kL-i)
   126  				aRow := a[i*lda+l : i*lda+u]
   127  				off := max(0, i-kL)
   128  				xtmp := x[off : off+u-l]
   129  				var sum complex64
   130  				for j, v := range aRow {
   131  					sum += xtmp[j] * v
   132  				}
   133  				y[iy] += alpha * sum
   134  				iy += incY
   135  			}
   136  		} else {
   137  			for i := 0; i < nRow; i++ {
   138  				l := max(0, kL-i)
   139  				u := min(nCol, n+kL-i)
   140  				aRow := a[i*lda+l : i*lda+u]
   141  				off := max(0, i-kL) * incX
   142  				jx := kx
   143  				var sum complex64
   144  				for _, v := range aRow {
   145  					sum += x[off+jx] * v
   146  					jx += incX
   147  				}
   148  				y[iy] += alpha * sum
   149  				iy += incY
   150  			}
   151  		}
   152  	case blas.Trans:
   153  		if incX == 1 {
   154  			for i := 0; i < nRow; i++ {
   155  				l := max(0, kL-i)
   156  				u := min(nCol, n+kL-i)
   157  				aRow := a[i*lda+l : i*lda+u]
   158  				off := max(0, i-kL) * incY
   159  				alphaxi := alpha * x[i]
   160  				jy := ky
   161  				for _, v := range aRow {
   162  					y[off+jy] += alphaxi * v
   163  					jy += incY
   164  				}
   165  			}
   166  		} else {
   167  			ix := kx
   168  			for i := 0; i < nRow; i++ {
   169  				l := max(0, kL-i)
   170  				u := min(nCol, n+kL-i)
   171  				aRow := a[i*lda+l : i*lda+u]
   172  				off := max(0, i-kL) * incY
   173  				alphaxi := alpha * x[ix]
   174  				jy := ky
   175  				for _, v := range aRow {
   176  					y[off+jy] += alphaxi * v
   177  					jy += incY
   178  				}
   179  				ix += incX
   180  			}
   181  		}
   182  	case blas.ConjTrans:
   183  		if incX == 1 {
   184  			for i := 0; i < nRow; i++ {
   185  				l := max(0, kL-i)
   186  				u := min(nCol, n+kL-i)
   187  				aRow := a[i*lda+l : i*lda+u]
   188  				off := max(0, i-kL) * incY
   189  				alphaxi := alpha * x[i]
   190  				jy := ky
   191  				for _, v := range aRow {
   192  					y[off+jy] += alphaxi * cmplx.Conj(v)
   193  					jy += incY
   194  				}
   195  			}
   196  		} else {
   197  			ix := kx
   198  			for i := 0; i < nRow; i++ {
   199  				l := max(0, kL-i)
   200  				u := min(nCol, n+kL-i)
   201  				aRow := a[i*lda+l : i*lda+u]
   202  				off := max(0, i-kL) * incY
   203  				alphaxi := alpha * x[ix]
   204  				jy := ky
   205  				for _, v := range aRow {
   206  					y[off+jy] += alphaxi * cmplx.Conj(v)
   207  					jy += incY
   208  				}
   209  				ix += incX
   210  			}
   211  		}
   212  	}
   213  }
   214  
   215  // Cgemv performs one of the matrix-vector operations
   216  //  y = alpha * A * x + beta * y   if trans = blas.NoTrans
   217  //  y = alpha * Aᵀ * x + beta * y  if trans = blas.Trans
   218  //  y = alpha * Aᴴ * x + beta * y  if trans = blas.ConjTrans
   219  // where alpha and beta are scalars, x and y are vectors, and A is an m×n dense matrix.
   220  //
   221  // Complex64 implementations are autogenerated and not directly tested.
   222  func (Implementation) Cgemv(trans blas.Transpose, m, n int, alpha complex64, a []complex64, lda int, x []complex64, incX int, beta complex64, y []complex64, incY int) {
   223  	switch trans {
   224  	default:
   225  		panic(badTranspose)
   226  	case blas.NoTrans, blas.Trans, blas.ConjTrans:
   227  	}
   228  	if m < 0 {
   229  		panic(mLT0)
   230  	}
   231  	if n < 0 {
   232  		panic(nLT0)
   233  	}
   234  	if lda < max(1, n) {
   235  		panic(badLdA)
   236  	}
   237  	if incX == 0 {
   238  		panic(zeroIncX)
   239  	}
   240  	if incY == 0 {
   241  		panic(zeroIncY)
   242  	}
   243  
   244  	// Quick return if possible.
   245  	if m == 0 || n == 0 {
   246  		return
   247  	}
   248  
   249  	// For zero matrix size the following slice length checks are trivially satisfied.
   250  	var lenX, lenY int
   251  	if trans == blas.NoTrans {
   252  		lenX = n
   253  		lenY = m
   254  	} else {
   255  		lenX = m
   256  		lenY = n
   257  	}
   258  	if len(a) < lda*(m-1)+n {
   259  		panic(shortA)
   260  	}
   261  	if (incX > 0 && len(x) <= (lenX-1)*incX) || (incX < 0 && len(x) <= (1-lenX)*incX) {
   262  		panic(shortX)
   263  	}
   264  	if (incY > 0 && len(y) <= (lenY-1)*incY) || (incY < 0 && len(y) <= (1-lenY)*incY) {
   265  		panic(shortY)
   266  	}
   267  
   268  	// Quick return if possible.
   269  	if alpha == 0 && beta == 1 {
   270  		return
   271  	}
   272  
   273  	var kx int
   274  	if incX < 0 {
   275  		kx = (1 - lenX) * incX
   276  	}
   277  	var ky int
   278  	if incY < 0 {
   279  		ky = (1 - lenY) * incY
   280  	}
   281  
   282  	// Form y = beta*y.
   283  	if beta != 1 {
   284  		if incY == 1 {
   285  			if beta == 0 {
   286  				for i := range y[:lenY] {
   287  					y[i] = 0
   288  				}
   289  			} else {
   290  				c64.ScalUnitary(beta, y[:lenY])
   291  			}
   292  		} else {
   293  			iy := ky
   294  			if beta == 0 {
   295  				for i := 0; i < lenY; i++ {
   296  					y[iy] = 0
   297  					iy += incY
   298  				}
   299  			} else {
   300  				if incY > 0 {
   301  					c64.ScalInc(beta, y, uintptr(lenY), uintptr(incY))
   302  				} else {
   303  					c64.ScalInc(beta, y, uintptr(lenY), uintptr(-incY))
   304  				}
   305  			}
   306  		}
   307  	}
   308  
   309  	if alpha == 0 {
   310  		return
   311  	}
   312  
   313  	switch trans {
   314  	default:
   315  		// Form y = alpha*A*x + y.
   316  		iy := ky
   317  		if incX == 1 {
   318  			for i := 0; i < m; i++ {
   319  				y[iy] += alpha * c64.DotuUnitary(a[i*lda:i*lda+n], x[:n])
   320  				iy += incY
   321  			}
   322  			return
   323  		}
   324  		for i := 0; i < m; i++ {
   325  			y[iy] += alpha * c64.DotuInc(a[i*lda:i*lda+n], x, uintptr(n), 1, uintptr(incX), 0, uintptr(kx))
   326  			iy += incY
   327  		}
   328  		return
   329  
   330  	case blas.Trans:
   331  		// Form y = alpha*Aᵀ*x + y.
   332  		ix := kx
   333  		if incY == 1 {
   334  			for i := 0; i < m; i++ {
   335  				c64.AxpyUnitary(alpha*x[ix], a[i*lda:i*lda+n], y[:n])
   336  				ix += incX
   337  			}
   338  			return
   339  		}
   340  		for i := 0; i < m; i++ {
   341  			c64.AxpyInc(alpha*x[ix], a[i*lda:i*lda+n], y, uintptr(n), 1, uintptr(incY), 0, uintptr(ky))
   342  			ix += incX
   343  		}
   344  		return
   345  
   346  	case blas.ConjTrans:
   347  		// Form y = alpha*Aᴴ*x + y.
   348  		ix := kx
   349  		if incY == 1 {
   350  			for i := 0; i < m; i++ {
   351  				tmp := alpha * x[ix]
   352  				for j := 0; j < n; j++ {
   353  					y[j] += tmp * cmplx.Conj(a[i*lda+j])
   354  				}
   355  				ix += incX
   356  			}
   357  			return
   358  		}
   359  		for i := 0; i < m; i++ {
   360  			tmp := alpha * x[ix]
   361  			jy := ky
   362  			for j := 0; j < n; j++ {
   363  				y[jy] += tmp * cmplx.Conj(a[i*lda+j])
   364  				jy += incY
   365  			}
   366  			ix += incX
   367  		}
   368  		return
   369  	}
   370  }
   371  
   372  // Cgerc performs the rank-one operation
   373  //  A += alpha * x * yᴴ
   374  // where A is an m×n dense matrix, alpha is a scalar, x is an m element vector,
   375  // and y is an n element vector.
   376  //
   377  // Complex64 implementations are autogenerated and not directly tested.
   378  func (Implementation) Cgerc(m, n int, alpha complex64, x []complex64, incX int, y []complex64, incY int, a []complex64, lda int) {
   379  	if m < 0 {
   380  		panic(mLT0)
   381  	}
   382  	if n < 0 {
   383  		panic(nLT0)
   384  	}
   385  	if lda < max(1, n) {
   386  		panic(badLdA)
   387  	}
   388  	if incX == 0 {
   389  		panic(zeroIncX)
   390  	}
   391  	if incY == 0 {
   392  		panic(zeroIncY)
   393  	}
   394  
   395  	// Quick return if possible.
   396  	if m == 0 || n == 0 {
   397  		return
   398  	}
   399  
   400  	// For zero matrix size the following slice length checks are trivially satisfied.
   401  	if (incX > 0 && len(x) <= (m-1)*incX) || (incX < 0 && len(x) <= (1-m)*incX) {
   402  		panic(shortX)
   403  	}
   404  	if (incY > 0 && len(y) <= (n-1)*incY) || (incY < 0 && len(y) <= (1-n)*incY) {
   405  		panic(shortY)
   406  	}
   407  	if len(a) < lda*(m-1)+n {
   408  		panic(shortA)
   409  	}
   410  
   411  	// Quick return if possible.
   412  	if alpha == 0 {
   413  		return
   414  	}
   415  
   416  	var kx, jy int
   417  	if incX < 0 {
   418  		kx = (1 - m) * incX
   419  	}
   420  	if incY < 0 {
   421  		jy = (1 - n) * incY
   422  	}
   423  	for j := 0; j < n; j++ {
   424  		if y[jy] != 0 {
   425  			tmp := alpha * cmplx.Conj(y[jy])
   426  			c64.AxpyInc(tmp, x, a[j:], uintptr(m), uintptr(incX), uintptr(lda), uintptr(kx), 0)
   427  		}
   428  		jy += incY
   429  	}
   430  }
   431  
   432  // Cgeru performs the rank-one operation
   433  //  A += alpha * x * yᵀ
   434  // where A is an m×n dense matrix, alpha is a scalar, x is an m element vector,
   435  // and y is an n element vector.
   436  //
   437  // Complex64 implementations are autogenerated and not directly tested.
   438  func (Implementation) Cgeru(m, n int, alpha complex64, x []complex64, incX int, y []complex64, incY int, a []complex64, lda int) {
   439  	if m < 0 {
   440  		panic(mLT0)
   441  	}
   442  	if n < 0 {
   443  		panic(nLT0)
   444  	}
   445  	if lda < max(1, n) {
   446  		panic(badLdA)
   447  	}
   448  	if incX == 0 {
   449  		panic(zeroIncX)
   450  	}
   451  	if incY == 0 {
   452  		panic(zeroIncY)
   453  	}
   454  
   455  	// Quick return if possible.
   456  	if m == 0 || n == 0 {
   457  		return
   458  	}
   459  
   460  	// For zero matrix size the following slice length checks are trivially satisfied.
   461  	if (incX > 0 && len(x) <= (m-1)*incX) || (incX < 0 && len(x) <= (1-m)*incX) {
   462  		panic(shortX)
   463  	}
   464  	if (incY > 0 && len(y) <= (n-1)*incY) || (incY < 0 && len(y) <= (1-n)*incY) {
   465  		panic(shortY)
   466  	}
   467  	if len(a) < lda*(m-1)+n {
   468  		panic(shortA)
   469  	}
   470  
   471  	// Quick return if possible.
   472  	if alpha == 0 {
   473  		return
   474  	}
   475  
   476  	var kx int
   477  	if incX < 0 {
   478  		kx = (1 - m) * incX
   479  	}
   480  	if incY == 1 {
   481  		for i := 0; i < m; i++ {
   482  			if x[kx] != 0 {
   483  				tmp := alpha * x[kx]
   484  				c64.AxpyUnitary(tmp, y[:n], a[i*lda:i*lda+n])
   485  			}
   486  			kx += incX
   487  		}
   488  		return
   489  	}
   490  	var jy int
   491  	if incY < 0 {
   492  		jy = (1 - n) * incY
   493  	}
   494  	for i := 0; i < m; i++ {
   495  		if x[kx] != 0 {
   496  			tmp := alpha * x[kx]
   497  			c64.AxpyInc(tmp, y, a[i*lda:i*lda+n], uintptr(n), uintptr(incY), 1, uintptr(jy), 0)
   498  		}
   499  		kx += incX
   500  	}
   501  }
   502  
   503  // Chbmv performs the matrix-vector operation
   504  //  y = alpha * A * x + beta * y
   505  // where alpha and beta are scalars, x and y are vectors, and A is an n×n
   506  // Hermitian band matrix with k super-diagonals. The imaginary parts of
   507  // the diagonal elements of A are ignored and assumed to be zero.
   508  //
   509  // Complex64 implementations are autogenerated and not directly tested.
   510  func (Implementation) Chbmv(uplo blas.Uplo, n, k int, alpha complex64, a []complex64, lda int, x []complex64, incX int, beta complex64, y []complex64, incY int) {
   511  	switch uplo {
   512  	default:
   513  		panic(badUplo)
   514  	case blas.Upper, blas.Lower:
   515  	}
   516  	if n < 0 {
   517  		panic(nLT0)
   518  	}
   519  	if k < 0 {
   520  		panic(kLT0)
   521  	}
   522  	if lda < k+1 {
   523  		panic(badLdA)
   524  	}
   525  	if incX == 0 {
   526  		panic(zeroIncX)
   527  	}
   528  	if incY == 0 {
   529  		panic(zeroIncY)
   530  	}
   531  
   532  	// Quick return if possible.
   533  	if n == 0 {
   534  		return
   535  	}
   536  
   537  	// For zero matrix size the following slice length checks are trivially satisfied.
   538  	if len(a) < lda*(n-1)+k+1 {
   539  		panic(shortA)
   540  	}
   541  	if (incX > 0 && len(x) <= (n-1)*incX) || (incX < 0 && len(x) <= (1-n)*incX) {
   542  		panic(shortX)
   543  	}
   544  	if (incY > 0 && len(y) <= (n-1)*incY) || (incY < 0 && len(y) <= (1-n)*incY) {
   545  		panic(shortY)
   546  	}
   547  
   548  	// Quick return if possible.
   549  	if alpha == 0 && beta == 1 {
   550  		return
   551  	}
   552  
   553  	// Set up the start indices in X and Y.
   554  	var kx int
   555  	if incX < 0 {
   556  		kx = (1 - n) * incX
   557  	}
   558  	var ky int
   559  	if incY < 0 {
   560  		ky = (1 - n) * incY
   561  	}
   562  
   563  	// Form y = beta*y.
   564  	if beta != 1 {
   565  		if incY == 1 {
   566  			if beta == 0 {
   567  				for i := range y[:n] {
   568  					y[i] = 0
   569  				}
   570  			} else {
   571  				for i, v := range y[:n] {
   572  					y[i] = beta * v
   573  				}
   574  			}
   575  		} else {
   576  			iy := ky
   577  			if beta == 0 {
   578  				for i := 0; i < n; i++ {
   579  					y[iy] = 0
   580  					iy += incY
   581  				}
   582  			} else {
   583  				for i := 0; i < n; i++ {
   584  					y[iy] = beta * y[iy]
   585  					iy += incY
   586  				}
   587  			}
   588  		}
   589  	}
   590  
   591  	if alpha == 0 {
   592  		return
   593  	}
   594  
   595  	// The elements of A are accessed sequentially with one pass through a.
   596  	switch uplo {
   597  	case blas.Upper:
   598  		iy := ky
   599  		if incX == 1 {
   600  			for i := 0; i < n; i++ {
   601  				aRow := a[i*lda:]
   602  				alphaxi := alpha * x[i]
   603  				sum := alphaxi * complex(real(aRow[0]), 0)
   604  				u := min(k+1, n-i)
   605  				jy := incY
   606  				for j := 1; j < u; j++ {
   607  					v := aRow[j]
   608  					sum += alpha * x[i+j] * v
   609  					y[iy+jy] += alphaxi * cmplx.Conj(v)
   610  					jy += incY
   611  				}
   612  				y[iy] += sum
   613  				iy += incY
   614  			}
   615  		} else {
   616  			ix := kx
   617  			for i := 0; i < n; i++ {
   618  				aRow := a[i*lda:]
   619  				alphaxi := alpha * x[ix]
   620  				sum := alphaxi * complex(real(aRow[0]), 0)
   621  				u := min(k+1, n-i)
   622  				jx := incX
   623  				jy := incY
   624  				for j := 1; j < u; j++ {
   625  					v := aRow[j]
   626  					sum += alpha * x[ix+jx] * v
   627  					y[iy+jy] += alphaxi * cmplx.Conj(v)
   628  					jx += incX
   629  					jy += incY
   630  				}
   631  				y[iy] += sum
   632  				ix += incX
   633  				iy += incY
   634  			}
   635  		}
   636  	case blas.Lower:
   637  		iy := ky
   638  		if incX == 1 {
   639  			for i := 0; i < n; i++ {
   640  				l := max(0, k-i)
   641  				alphaxi := alpha * x[i]
   642  				jy := l * incY
   643  				aRow := a[i*lda:]
   644  				for j := l; j < k; j++ {
   645  					v := aRow[j]
   646  					y[iy] += alpha * v * x[i-k+j]
   647  					y[iy-k*incY+jy] += alphaxi * cmplx.Conj(v)
   648  					jy += incY
   649  				}
   650  				y[iy] += alphaxi * complex(real(aRow[k]), 0)
   651  				iy += incY
   652  			}
   653  		} else {
   654  			ix := kx
   655  			for i := 0; i < n; i++ {
   656  				l := max(0, k-i)
   657  				alphaxi := alpha * x[ix]
   658  				jx := l * incX
   659  				jy := l * incY
   660  				aRow := a[i*lda:]
   661  				for j := l; j < k; j++ {
   662  					v := aRow[j]
   663  					y[iy] += alpha * v * x[ix-k*incX+jx]
   664  					y[iy-k*incY+jy] += alphaxi * cmplx.Conj(v)
   665  					jx += incX
   666  					jy += incY
   667  				}
   668  				y[iy] += alphaxi * complex(real(aRow[k]), 0)
   669  				ix += incX
   670  				iy += incY
   671  			}
   672  		}
   673  	}
   674  }
   675  
   676  // Chemv performs the matrix-vector operation
   677  //  y = alpha * A * x + beta * y
   678  // where alpha and beta are scalars, x and y are vectors, and A is an n×n
   679  // Hermitian matrix. The imaginary parts of the diagonal elements of A are
   680  // ignored and assumed to be zero.
   681  //
   682  // Complex64 implementations are autogenerated and not directly tested.
   683  func (Implementation) Chemv(uplo blas.Uplo, n int, alpha complex64, a []complex64, lda int, x []complex64, incX int, beta complex64, y []complex64, incY int) {
   684  	switch uplo {
   685  	default:
   686  		panic(badUplo)
   687  	case blas.Upper, blas.Lower:
   688  	}
   689  	if n < 0 {
   690  		panic(nLT0)
   691  	}
   692  	if lda < max(1, n) {
   693  		panic(badLdA)
   694  	}
   695  	if incX == 0 {
   696  		panic(zeroIncX)
   697  	}
   698  	if incY == 0 {
   699  		panic(zeroIncY)
   700  	}
   701  
   702  	// Quick return if possible.
   703  	if n == 0 {
   704  		return
   705  	}
   706  
   707  	// For zero matrix size the following slice length checks are trivially satisfied.
   708  	if len(a) < lda*(n-1)+n {
   709  		panic(shortA)
   710  	}
   711  	if (incX > 0 && len(x) <= (n-1)*incX) || (incX < 0 && len(x) <= (1-n)*incX) {
   712  		panic(shortX)
   713  	}
   714  	if (incY > 0 && len(y) <= (n-1)*incY) || (incY < 0 && len(y) <= (1-n)*incY) {
   715  		panic(shortY)
   716  	}
   717  
   718  	// Quick return if possible.
   719  	if alpha == 0 && beta == 1 {
   720  		return
   721  	}
   722  
   723  	// Set up the start indices in X and Y.
   724  	var kx int
   725  	if incX < 0 {
   726  		kx = (1 - n) * incX
   727  	}
   728  	var ky int
   729  	if incY < 0 {
   730  		ky = (1 - n) * incY
   731  	}
   732  
   733  	// Form y = beta*y.
   734  	if beta != 1 {
   735  		if incY == 1 {
   736  			if beta == 0 {
   737  				for i := range y[:n] {
   738  					y[i] = 0
   739  				}
   740  			} else {
   741  				for i, v := range y[:n] {
   742  					y[i] = beta * v
   743  				}
   744  			}
   745  		} else {
   746  			iy := ky
   747  			if beta == 0 {
   748  				for i := 0; i < n; i++ {
   749  					y[iy] = 0
   750  					iy += incY
   751  				}
   752  			} else {
   753  				for i := 0; i < n; i++ {
   754  					y[iy] = beta * y[iy]
   755  					iy += incY
   756  				}
   757  			}
   758  		}
   759  	}
   760  
   761  	if alpha == 0 {
   762  		return
   763  	}
   764  
   765  	// The elements of A are accessed sequentially with one pass through
   766  	// the triangular part of A.
   767  
   768  	if uplo == blas.Upper {
   769  		// Form y when A is stored in upper triangle.
   770  		if incX == 1 && incY == 1 {
   771  			for i := 0; i < n; i++ {
   772  				tmp1 := alpha * x[i]
   773  				var tmp2 complex64
   774  				for j := i + 1; j < n; j++ {
   775  					y[j] += tmp1 * cmplx.Conj(a[i*lda+j])
   776  					tmp2 += a[i*lda+j] * x[j]
   777  				}
   778  				aii := complex(real(a[i*lda+i]), 0)
   779  				y[i] += tmp1*aii + alpha*tmp2
   780  			}
   781  		} else {
   782  			ix := kx
   783  			iy := ky
   784  			for i := 0; i < n; i++ {
   785  				tmp1 := alpha * x[ix]
   786  				var tmp2 complex64
   787  				jx := ix
   788  				jy := iy
   789  				for j := i + 1; j < n; j++ {
   790  					jx += incX
   791  					jy += incY
   792  					y[jy] += tmp1 * cmplx.Conj(a[i*lda+j])
   793  					tmp2 += a[i*lda+j] * x[jx]
   794  				}
   795  				aii := complex(real(a[i*lda+i]), 0)
   796  				y[iy] += tmp1*aii + alpha*tmp2
   797  				ix += incX
   798  				iy += incY
   799  			}
   800  		}
   801  		return
   802  	}
   803  
   804  	// Form y when A is stored in lower triangle.
   805  	if incX == 1 && incY == 1 {
   806  		for i := 0; i < n; i++ {
   807  			tmp1 := alpha * x[i]
   808  			var tmp2 complex64
   809  			for j := 0; j < i; j++ {
   810  				y[j] += tmp1 * cmplx.Conj(a[i*lda+j])
   811  				tmp2 += a[i*lda+j] * x[j]
   812  			}
   813  			aii := complex(real(a[i*lda+i]), 0)
   814  			y[i] += tmp1*aii + alpha*tmp2
   815  		}
   816  	} else {
   817  		ix := kx
   818  		iy := ky
   819  		for i := 0; i < n; i++ {
   820  			tmp1 := alpha * x[ix]
   821  			var tmp2 complex64
   822  			jx := kx
   823  			jy := ky
   824  			for j := 0; j < i; j++ {
   825  				y[jy] += tmp1 * cmplx.Conj(a[i*lda+j])
   826  				tmp2 += a[i*lda+j] * x[jx]
   827  				jx += incX
   828  				jy += incY
   829  			}
   830  			aii := complex(real(a[i*lda+i]), 0)
   831  			y[iy] += tmp1*aii + alpha*tmp2
   832  			ix += incX
   833  			iy += incY
   834  		}
   835  	}
   836  }
   837  
   838  // Cher performs the Hermitian rank-one operation
   839  //  A += alpha * x * xᴴ
   840  // where A is an n×n Hermitian matrix, alpha is a real scalar, and x is an n
   841  // element vector. On entry, the imaginary parts of the diagonal elements of A
   842  // are ignored and assumed to be zero, on return they will be set to zero.
   843  //
   844  // Complex64 implementations are autogenerated and not directly tested.
   845  func (Implementation) Cher(uplo blas.Uplo, n int, alpha float32, x []complex64, incX int, a []complex64, lda int) {
   846  	switch uplo {
   847  	default:
   848  		panic(badUplo)
   849  	case blas.Upper, blas.Lower:
   850  	}
   851  	if n < 0 {
   852  		panic(nLT0)
   853  	}
   854  	if lda < max(1, n) {
   855  		panic(badLdA)
   856  	}
   857  	if incX == 0 {
   858  		panic(zeroIncX)
   859  	}
   860  
   861  	// Quick return if possible.
   862  	if n == 0 {
   863  		return
   864  	}
   865  
   866  	// For zero matrix size the following slice length checks are trivially satisfied.
   867  	if (incX > 0 && len(x) <= (n-1)*incX) || (incX < 0 && len(x) <= (1-n)*incX) {
   868  		panic(shortX)
   869  	}
   870  	if len(a) < lda*(n-1)+n {
   871  		panic(shortA)
   872  	}
   873  
   874  	// Quick return if possible.
   875  	if alpha == 0 {
   876  		return
   877  	}
   878  
   879  	var kx int
   880  	if incX < 0 {
   881  		kx = (1 - n) * incX
   882  	}
   883  	if uplo == blas.Upper {
   884  		if incX == 1 {
   885  			for i := 0; i < n; i++ {
   886  				if x[i] != 0 {
   887  					tmp := complex(alpha*real(x[i]), alpha*imag(x[i]))
   888  					aii := real(a[i*lda+i])
   889  					xtmp := real(tmp * cmplx.Conj(x[i]))
   890  					a[i*lda+i] = complex(aii+xtmp, 0)
   891  					for j := i + 1; j < n; j++ {
   892  						a[i*lda+j] += tmp * cmplx.Conj(x[j])
   893  					}
   894  				} else {
   895  					aii := real(a[i*lda+i])
   896  					a[i*lda+i] = complex(aii, 0)
   897  				}
   898  			}
   899  			return
   900  		}
   901  
   902  		ix := kx
   903  		for i := 0; i < n; i++ {
   904  			if x[ix] != 0 {
   905  				tmp := complex(alpha*real(x[ix]), alpha*imag(x[ix]))
   906  				aii := real(a[i*lda+i])
   907  				xtmp := real(tmp * cmplx.Conj(x[ix]))
   908  				a[i*lda+i] = complex(aii+xtmp, 0)
   909  				jx := ix + incX
   910  				for j := i + 1; j < n; j++ {
   911  					a[i*lda+j] += tmp * cmplx.Conj(x[jx])
   912  					jx += incX
   913  				}
   914  			} else {
   915  				aii := real(a[i*lda+i])
   916  				a[i*lda+i] = complex(aii, 0)
   917  			}
   918  			ix += incX
   919  		}
   920  		return
   921  	}
   922  
   923  	if incX == 1 {
   924  		for i := 0; i < n; i++ {
   925  			if x[i] != 0 {
   926  				tmp := complex(alpha*real(x[i]), alpha*imag(x[i]))
   927  				for j := 0; j < i; j++ {
   928  					a[i*lda+j] += tmp * cmplx.Conj(x[j])
   929  				}
   930  				aii := real(a[i*lda+i])
   931  				xtmp := real(tmp * cmplx.Conj(x[i]))
   932  				a[i*lda+i] = complex(aii+xtmp, 0)
   933  			} else {
   934  				aii := real(a[i*lda+i])
   935  				a[i*lda+i] = complex(aii, 0)
   936  			}
   937  		}
   938  		return
   939  	}
   940  
   941  	ix := kx
   942  	for i := 0; i < n; i++ {
   943  		if x[ix] != 0 {
   944  			tmp := complex(alpha*real(x[ix]), alpha*imag(x[ix]))
   945  			jx := kx
   946  			for j := 0; j < i; j++ {
   947  				a[i*lda+j] += tmp * cmplx.Conj(x[jx])
   948  				jx += incX
   949  			}
   950  			aii := real(a[i*lda+i])
   951  			xtmp := real(tmp * cmplx.Conj(x[ix]))
   952  			a[i*lda+i] = complex(aii+xtmp, 0)
   953  
   954  		} else {
   955  			aii := real(a[i*lda+i])
   956  			a[i*lda+i] = complex(aii, 0)
   957  		}
   958  		ix += incX
   959  	}
   960  }
   961  
   962  // Cher2 performs the Hermitian rank-two operation
   963  //  A += alpha * x * yᴴ + conj(alpha) * y * xᴴ
   964  // where alpha is a scalar, x and y are n element vectors and A is an n×n
   965  // Hermitian matrix. On entry, the imaginary parts of the diagonal elements are
   966  // ignored and assumed to be zero. On return they will be set to zero.
   967  //
   968  // Complex64 implementations are autogenerated and not directly tested.
   969  func (Implementation) Cher2(uplo blas.Uplo, n int, alpha complex64, x []complex64, incX int, y []complex64, incY int, a []complex64, lda int) {
   970  	switch uplo {
   971  	default:
   972  		panic(badUplo)
   973  	case blas.Upper, blas.Lower:
   974  	}
   975  	if n < 0 {
   976  		panic(nLT0)
   977  	}
   978  	if lda < max(1, n) {
   979  		panic(badLdA)
   980  	}
   981  	if incX == 0 {
   982  		panic(zeroIncX)
   983  	}
   984  	if incY == 0 {
   985  		panic(zeroIncY)
   986  	}
   987  
   988  	// Quick return if possible.
   989  	if n == 0 {
   990  		return
   991  	}
   992  
   993  	// For zero matrix size the following slice length checks are trivially satisfied.
   994  	if (incX > 0 && len(x) <= (n-1)*incX) || (incX < 0 && len(x) <= (1-n)*incX) {
   995  		panic(shortX)
   996  	}
   997  	if (incY > 0 && len(y) <= (n-1)*incY) || (incY < 0 && len(y) <= (1-n)*incY) {
   998  		panic(shortY)
   999  	}
  1000  	if len(a) < lda*(n-1)+n {
  1001  		panic(shortA)
  1002  	}
  1003  
  1004  	// Quick return if possible.
  1005  	if alpha == 0 {
  1006  		return
  1007  	}
  1008  
  1009  	var kx, ky int
  1010  	var ix, iy int
  1011  	if incX != 1 || incY != 1 {
  1012  		if incX < 0 {
  1013  			kx = (1 - n) * incX
  1014  		}
  1015  		if incY < 0 {
  1016  			ky = (1 - n) * incY
  1017  		}
  1018  		ix = kx
  1019  		iy = ky
  1020  	}
  1021  	if uplo == blas.Upper {
  1022  		if incX == 1 && incY == 1 {
  1023  			for i := 0; i < n; i++ {
  1024  				if x[i] != 0 || y[i] != 0 {
  1025  					tmp1 := alpha * x[i]
  1026  					tmp2 := cmplx.Conj(alpha) * y[i]
  1027  					aii := real(a[i*lda+i]) + real(tmp1*cmplx.Conj(y[i])) + real(tmp2*cmplx.Conj(x[i]))
  1028  					a[i*lda+i] = complex(aii, 0)
  1029  					for j := i + 1; j < n; j++ {
  1030  						a[i*lda+j] += tmp1*cmplx.Conj(y[j]) + tmp2*cmplx.Conj(x[j])
  1031  					}
  1032  				} else {
  1033  					aii := real(a[i*lda+i])
  1034  					a[i*lda+i] = complex(aii, 0)
  1035  				}
  1036  			}
  1037  			return
  1038  		}
  1039  		for i := 0; i < n; i++ {
  1040  			if x[ix] != 0 || y[iy] != 0 {
  1041  				tmp1 := alpha * x[ix]
  1042  				tmp2 := cmplx.Conj(alpha) * y[iy]
  1043  				aii := real(a[i*lda+i]) + real(tmp1*cmplx.Conj(y[iy])) + real(tmp2*cmplx.Conj(x[ix]))
  1044  				a[i*lda+i] = complex(aii, 0)
  1045  				jx := ix + incX
  1046  				jy := iy + incY
  1047  				for j := i + 1; j < n; j++ {
  1048  					a[i*lda+j] += tmp1*cmplx.Conj(y[jy]) + tmp2*cmplx.Conj(x[jx])
  1049  					jx += incX
  1050  					jy += incY
  1051  				}
  1052  			} else {
  1053  				aii := real(a[i*lda+i])
  1054  				a[i*lda+i] = complex(aii, 0)
  1055  			}
  1056  			ix += incX
  1057  			iy += incY
  1058  		}
  1059  		return
  1060  	}
  1061  
  1062  	if incX == 1 && incY == 1 {
  1063  		for i := 0; i < n; i++ {
  1064  			if x[i] != 0 || y[i] != 0 {
  1065  				tmp1 := alpha * x[i]
  1066  				tmp2 := cmplx.Conj(alpha) * y[i]
  1067  				for j := 0; j < i; j++ {
  1068  					a[i*lda+j] += tmp1*cmplx.Conj(y[j]) + tmp2*cmplx.Conj(x[j])
  1069  				}
  1070  				aii := real(a[i*lda+i]) + real(tmp1*cmplx.Conj(y[i])) + real(tmp2*cmplx.Conj(x[i]))
  1071  				a[i*lda+i] = complex(aii, 0)
  1072  			} else {
  1073  				aii := real(a[i*lda+i])
  1074  				a[i*lda+i] = complex(aii, 0)
  1075  			}
  1076  		}
  1077  		return
  1078  	}
  1079  	for i := 0; i < n; i++ {
  1080  		if x[ix] != 0 || y[iy] != 0 {
  1081  			tmp1 := alpha * x[ix]
  1082  			tmp2 := cmplx.Conj(alpha) * y[iy]
  1083  			jx := kx
  1084  			jy := ky
  1085  			for j := 0; j < i; j++ {
  1086  				a[i*lda+j] += tmp1*cmplx.Conj(y[jy]) + tmp2*cmplx.Conj(x[jx])
  1087  				jx += incX
  1088  				jy += incY
  1089  			}
  1090  			aii := real(a[i*lda+i]) + real(tmp1*cmplx.Conj(y[iy])) + real(tmp2*cmplx.Conj(x[ix]))
  1091  			a[i*lda+i] = complex(aii, 0)
  1092  		} else {
  1093  			aii := real(a[i*lda+i])
  1094  			a[i*lda+i] = complex(aii, 0)
  1095  		}
  1096  		ix += incX
  1097  		iy += incY
  1098  	}
  1099  }
  1100  
  1101  // Chpmv performs the matrix-vector operation
  1102  //  y = alpha * A * x + beta * y
  1103  // where alpha and beta are scalars, x and y are vectors, and A is an n×n
  1104  // Hermitian matrix in packed form. The imaginary parts of the diagonal
  1105  // elements of A are ignored and assumed to be zero.
  1106  //
  1107  // Complex64 implementations are autogenerated and not directly tested.
  1108  func (Implementation) Chpmv(uplo blas.Uplo, n int, alpha complex64, ap []complex64, x []complex64, incX int, beta complex64, y []complex64, incY int) {
  1109  	switch uplo {
  1110  	default:
  1111  		panic(badUplo)
  1112  	case blas.Upper, blas.Lower:
  1113  	}
  1114  	if n < 0 {
  1115  		panic(nLT0)
  1116  	}
  1117  	if incX == 0 {
  1118  		panic(zeroIncX)
  1119  	}
  1120  	if incY == 0 {
  1121  		panic(zeroIncY)
  1122  	}
  1123  
  1124  	// Quick return if possible.
  1125  	if n == 0 {
  1126  		return
  1127  	}
  1128  
  1129  	// For zero matrix size the following slice length checks are trivially satisfied.
  1130  	if len(ap) < n*(n+1)/2 {
  1131  		panic(shortAP)
  1132  	}
  1133  	if (incX > 0 && len(x) <= (n-1)*incX) || (incX < 0 && len(x) <= (1-n)*incX) {
  1134  		panic(shortX)
  1135  	}
  1136  	if (incY > 0 && len(y) <= (n-1)*incY) || (incY < 0 && len(y) <= (1-n)*incY) {
  1137  		panic(shortY)
  1138  	}
  1139  
  1140  	// Quick return if possible.
  1141  	if alpha == 0 && beta == 1 {
  1142  		return
  1143  	}
  1144  
  1145  	// Set up the start indices in X and Y.
  1146  	var kx int
  1147  	if incX < 0 {
  1148  		kx = (1 - n) * incX
  1149  	}
  1150  	var ky int
  1151  	if incY < 0 {
  1152  		ky = (1 - n) * incY
  1153  	}
  1154  
  1155  	// Form y = beta*y.
  1156  	if beta != 1 {
  1157  		if incY == 1 {
  1158  			if beta == 0 {
  1159  				for i := range y[:n] {
  1160  					y[i] = 0
  1161  				}
  1162  			} else {
  1163  				for i, v := range y[:n] {
  1164  					y[i] = beta * v
  1165  				}
  1166  			}
  1167  		} else {
  1168  			iy := ky
  1169  			if beta == 0 {
  1170  				for i := 0; i < n; i++ {
  1171  					y[iy] = 0
  1172  					iy += incY
  1173  				}
  1174  			} else {
  1175  				for i := 0; i < n; i++ {
  1176  					y[iy] *= beta
  1177  					iy += incY
  1178  				}
  1179  			}
  1180  		}
  1181  	}
  1182  
  1183  	if alpha == 0 {
  1184  		return
  1185  	}
  1186  
  1187  	// The elements of A are accessed sequentially with one pass through ap.
  1188  
  1189  	var kk int
  1190  	if uplo == blas.Upper {
  1191  		// Form y when ap contains the upper triangle.
  1192  		// Here, kk points to the current diagonal element in ap.
  1193  		if incX == 1 && incY == 1 {
  1194  			for i := 0; i < n; i++ {
  1195  				tmp1 := alpha * x[i]
  1196  				y[i] += tmp1 * complex(real(ap[kk]), 0)
  1197  				var tmp2 complex64
  1198  				k := kk + 1
  1199  				for j := i + 1; j < n; j++ {
  1200  					y[j] += tmp1 * cmplx.Conj(ap[k])
  1201  					tmp2 += ap[k] * x[j]
  1202  					k++
  1203  				}
  1204  				y[i] += alpha * tmp2
  1205  				kk += n - i
  1206  			}
  1207  		} else {
  1208  			ix := kx
  1209  			iy := ky
  1210  			for i := 0; i < n; i++ {
  1211  				tmp1 := alpha * x[ix]
  1212  				y[iy] += tmp1 * complex(real(ap[kk]), 0)
  1213  				var tmp2 complex64
  1214  				jx := ix
  1215  				jy := iy
  1216  				for k := kk + 1; k < kk+n-i; k++ {
  1217  					jx += incX
  1218  					jy += incY
  1219  					y[jy] += tmp1 * cmplx.Conj(ap[k])
  1220  					tmp2 += ap[k] * x[jx]
  1221  				}
  1222  				y[iy] += alpha * tmp2
  1223  				ix += incX
  1224  				iy += incY
  1225  				kk += n - i
  1226  			}
  1227  		}
  1228  		return
  1229  	}
  1230  
  1231  	// Form y when ap contains the lower triangle.
  1232  	// Here, kk points to the beginning of current row in ap.
  1233  	if incX == 1 && incY == 1 {
  1234  		for i := 0; i < n; i++ {
  1235  			tmp1 := alpha * x[i]
  1236  			var tmp2 complex64
  1237  			k := kk
  1238  			for j := 0; j < i; j++ {
  1239  				y[j] += tmp1 * cmplx.Conj(ap[k])
  1240  				tmp2 += ap[k] * x[j]
  1241  				k++
  1242  			}
  1243  			aii := complex(real(ap[kk+i]), 0)
  1244  			y[i] += tmp1*aii + alpha*tmp2
  1245  			kk += i + 1
  1246  		}
  1247  	} else {
  1248  		ix := kx
  1249  		iy := ky
  1250  		for i := 0; i < n; i++ {
  1251  			tmp1 := alpha * x[ix]
  1252  			var tmp2 complex64
  1253  			jx := kx
  1254  			jy := ky
  1255  			for k := kk; k < kk+i; k++ {
  1256  				y[jy] += tmp1 * cmplx.Conj(ap[k])
  1257  				tmp2 += ap[k] * x[jx]
  1258  				jx += incX
  1259  				jy += incY
  1260  			}
  1261  			aii := complex(real(ap[kk+i]), 0)
  1262  			y[iy] += tmp1*aii + alpha*tmp2
  1263  			ix += incX
  1264  			iy += incY
  1265  			kk += i + 1
  1266  		}
  1267  	}
  1268  }
  1269  
  1270  // Chpr performs the Hermitian rank-1 operation
  1271  //  A += alpha * x * xᴴ
  1272  // where alpha is a real scalar, x is a vector, and A is an n×n hermitian matrix
  1273  // in packed form. On entry, the imaginary parts of the diagonal elements are
  1274  // assumed to be zero, and on return they are set to zero.
  1275  //
  1276  // Complex64 implementations are autogenerated and not directly tested.
  1277  func (Implementation) Chpr(uplo blas.Uplo, n int, alpha float32, x []complex64, incX int, ap []complex64) {
  1278  	switch uplo {
  1279  	default:
  1280  		panic(badUplo)
  1281  	case blas.Upper, blas.Lower:
  1282  	}
  1283  	if n < 0 {
  1284  		panic(nLT0)
  1285  	}
  1286  	if incX == 0 {
  1287  		panic(zeroIncX)
  1288  	}
  1289  
  1290  	// Quick return if possible.
  1291  	if n == 0 {
  1292  		return
  1293  	}
  1294  
  1295  	// For zero matrix size the following slice length checks are trivially satisfied.
  1296  	if (incX > 0 && len(x) <= (n-1)*incX) || (incX < 0 && len(x) <= (1-n)*incX) {
  1297  		panic(shortX)
  1298  	}
  1299  	if len(ap) < n*(n+1)/2 {
  1300  		panic(shortAP)
  1301  	}
  1302  
  1303  	// Quick return if possible.
  1304  	if alpha == 0 {
  1305  		return
  1306  	}
  1307  
  1308  	// Set up start index in X.
  1309  	var kx int
  1310  	if incX < 0 {
  1311  		kx = (1 - n) * incX
  1312  	}
  1313  
  1314  	// The elements of A are accessed sequentially with one pass through ap.
  1315  
  1316  	var kk int
  1317  	if uplo == blas.Upper {
  1318  		// Form A when upper triangle is stored in AP.
  1319  		// Here, kk points to the current diagonal element in ap.
  1320  		if incX == 1 {
  1321  			for i := 0; i < n; i++ {
  1322  				xi := x[i]
  1323  				if xi != 0 {
  1324  					aii := real(ap[kk]) + alpha*real(cmplx.Conj(xi)*xi)
  1325  					ap[kk] = complex(aii, 0)
  1326  
  1327  					tmp := complex(alpha, 0) * xi
  1328  					a := ap[kk+1 : kk+n-i]
  1329  					x := x[i+1 : n]
  1330  					for j, v := range x {
  1331  						a[j] += tmp * cmplx.Conj(v)
  1332  					}
  1333  				} else {
  1334  					ap[kk] = complex(real(ap[kk]), 0)
  1335  				}
  1336  				kk += n - i
  1337  			}
  1338  		} else {
  1339  			ix := kx
  1340  			for i := 0; i < n; i++ {
  1341  				xi := x[ix]
  1342  				if xi != 0 {
  1343  					aii := real(ap[kk]) + alpha*real(cmplx.Conj(xi)*xi)
  1344  					ap[kk] = complex(aii, 0)
  1345  
  1346  					tmp := complex(alpha, 0) * xi
  1347  					jx := ix + incX
  1348  					a := ap[kk+1 : kk+n-i]
  1349  					for k := range a {
  1350  						a[k] += tmp * cmplx.Conj(x[jx])
  1351  						jx += incX
  1352  					}
  1353  				} else {
  1354  					ap[kk] = complex(real(ap[kk]), 0)
  1355  				}
  1356  				ix += incX
  1357  				kk += n - i
  1358  			}
  1359  		}
  1360  		return
  1361  	}
  1362  
  1363  	// Form A when lower triangle is stored in AP.
  1364  	// Here, kk points to the beginning of current row in ap.
  1365  	if incX == 1 {
  1366  		for i := 0; i < n; i++ {
  1367  			xi := x[i]
  1368  			if xi != 0 {
  1369  				tmp := complex(alpha, 0) * xi
  1370  				a := ap[kk : kk+i]
  1371  				for j, v := range x[:i] {
  1372  					a[j] += tmp * cmplx.Conj(v)
  1373  				}
  1374  
  1375  				aii := real(ap[kk+i]) + alpha*real(cmplx.Conj(xi)*xi)
  1376  				ap[kk+i] = complex(aii, 0)
  1377  			} else {
  1378  				ap[kk+i] = complex(real(ap[kk+i]), 0)
  1379  			}
  1380  			kk += i + 1
  1381  		}
  1382  	} else {
  1383  		ix := kx
  1384  		for i := 0; i < n; i++ {
  1385  			xi := x[ix]
  1386  			if xi != 0 {
  1387  				tmp := complex(alpha, 0) * xi
  1388  				a := ap[kk : kk+i]
  1389  				jx := kx
  1390  				for k := range a {
  1391  					a[k] += tmp * cmplx.Conj(x[jx])
  1392  					jx += incX
  1393  				}
  1394  
  1395  				aii := real(ap[kk+i]) + alpha*real(cmplx.Conj(xi)*xi)
  1396  				ap[kk+i] = complex(aii, 0)
  1397  			} else {
  1398  				ap[kk+i] = complex(real(ap[kk+i]), 0)
  1399  			}
  1400  			ix += incX
  1401  			kk += i + 1
  1402  		}
  1403  	}
  1404  }
  1405  
  1406  // Chpr2 performs the Hermitian rank-2 operation
  1407  //  A += alpha * x * yᴴ + conj(alpha) * y * xᴴ
  1408  // where alpha is a complex scalar, x and y are n element vectors, and A is an
  1409  // n×n Hermitian matrix, supplied in packed form. On entry, the imaginary parts
  1410  // of the diagonal elements are assumed to be zero, and on return they are set to zero.
  1411  //
  1412  // Complex64 implementations are autogenerated and not directly tested.
  1413  func (Implementation) Chpr2(uplo blas.Uplo, n int, alpha complex64, x []complex64, incX int, y []complex64, incY int, ap []complex64) {
  1414  	switch uplo {
  1415  	default:
  1416  		panic(badUplo)
  1417  	case blas.Upper, blas.Lower:
  1418  	}
  1419  	if n < 0 {
  1420  		panic(nLT0)
  1421  	}
  1422  	if incX == 0 {
  1423  		panic(zeroIncX)
  1424  	}
  1425  	if incY == 0 {
  1426  		panic(zeroIncY)
  1427  	}
  1428  
  1429  	// Quick return if possible.
  1430  	if n == 0 {
  1431  		return
  1432  	}
  1433  
  1434  	// For zero matrix size the following slice length checks are trivially satisfied.
  1435  	if (incX > 0 && len(x) <= (n-1)*incX) || (incX < 0 && len(x) <= (1-n)*incX) {
  1436  		panic(shortX)
  1437  	}
  1438  	if (incY > 0 && len(y) <= (n-1)*incY) || (incY < 0 && len(y) <= (1-n)*incY) {
  1439  		panic(shortY)
  1440  	}
  1441  	if len(ap) < n*(n+1)/2 {
  1442  		panic(shortAP)
  1443  	}
  1444  
  1445  	// Quick return if possible.
  1446  	if alpha == 0 {
  1447  		return
  1448  	}
  1449  
  1450  	// Set up start indices in X and Y.
  1451  	var kx int
  1452  	if incX < 0 {
  1453  		kx = (1 - n) * incX
  1454  	}
  1455  	var ky int
  1456  	if incY < 0 {
  1457  		ky = (1 - n) * incY
  1458  	}
  1459  
  1460  	// The elements of A are accessed sequentially with one pass through ap.
  1461  
  1462  	var kk int
  1463  	if uplo == blas.Upper {
  1464  		// Form A when upper triangle is stored in AP.
  1465  		// Here, kk points to the current diagonal element in ap.
  1466  		if incX == 1 && incY == 1 {
  1467  			for i := 0; i < n; i++ {
  1468  				if x[i] != 0 || y[i] != 0 {
  1469  					tmp1 := alpha * x[i]
  1470  					tmp2 := cmplx.Conj(alpha) * y[i]
  1471  					aii := real(ap[kk]) + real(tmp1*cmplx.Conj(y[i])) + real(tmp2*cmplx.Conj(x[i]))
  1472  					ap[kk] = complex(aii, 0)
  1473  					k := kk + 1
  1474  					for j := i + 1; j < n; j++ {
  1475  						ap[k] += tmp1*cmplx.Conj(y[j]) + tmp2*cmplx.Conj(x[j])
  1476  						k++
  1477  					}
  1478  				} else {
  1479  					ap[kk] = complex(real(ap[kk]), 0)
  1480  				}
  1481  				kk += n - i
  1482  			}
  1483  		} else {
  1484  			ix := kx
  1485  			iy := ky
  1486  			for i := 0; i < n; i++ {
  1487  				if x[ix] != 0 || y[iy] != 0 {
  1488  					tmp1 := alpha * x[ix]
  1489  					tmp2 := cmplx.Conj(alpha) * y[iy]
  1490  					aii := real(ap[kk]) + real(tmp1*cmplx.Conj(y[iy])) + real(tmp2*cmplx.Conj(x[ix]))
  1491  					ap[kk] = complex(aii, 0)
  1492  					jx := ix + incX
  1493  					jy := iy + incY
  1494  					for k := kk + 1; k < kk+n-i; k++ {
  1495  						ap[k] += tmp1*cmplx.Conj(y[jy]) + tmp2*cmplx.Conj(x[jx])
  1496  						jx += incX
  1497  						jy += incY
  1498  					}
  1499  				} else {
  1500  					ap[kk] = complex(real(ap[kk]), 0)
  1501  				}
  1502  				ix += incX
  1503  				iy += incY
  1504  				kk += n - i
  1505  			}
  1506  		}
  1507  		return
  1508  	}
  1509  
  1510  	// Form A when lower triangle is stored in AP.
  1511  	// Here, kk points to the beginning of current row in ap.
  1512  	if incX == 1 && incY == 1 {
  1513  		for i := 0; i < n; i++ {
  1514  			if x[i] != 0 || y[i] != 0 {
  1515  				tmp1 := alpha * x[i]
  1516  				tmp2 := cmplx.Conj(alpha) * y[i]
  1517  				k := kk
  1518  				for j := 0; j < i; j++ {
  1519  					ap[k] += tmp1*cmplx.Conj(y[j]) + tmp2*cmplx.Conj(x[j])
  1520  					k++
  1521  				}
  1522  				aii := real(ap[kk+i]) + real(tmp1*cmplx.Conj(y[i])) + real(tmp2*cmplx.Conj(x[i]))
  1523  				ap[kk+i] = complex(aii, 0)
  1524  			} else {
  1525  				ap[kk+i] = complex(real(ap[kk+i]), 0)
  1526  			}
  1527  			kk += i + 1
  1528  		}
  1529  	} else {
  1530  		ix := kx
  1531  		iy := ky
  1532  		for i := 0; i < n; i++ {
  1533  			if x[ix] != 0 || y[iy] != 0 {
  1534  				tmp1 := alpha * x[ix]
  1535  				tmp2 := cmplx.Conj(alpha) * y[iy]
  1536  				jx := kx
  1537  				jy := ky
  1538  				for k := kk; k < kk+i; k++ {
  1539  					ap[k] += tmp1*cmplx.Conj(y[jy]) + tmp2*cmplx.Conj(x[jx])
  1540  					jx += incX
  1541  					jy += incY
  1542  				}
  1543  				aii := real(ap[kk+i]) + real(tmp1*cmplx.Conj(y[iy])) + real(tmp2*cmplx.Conj(x[ix]))
  1544  				ap[kk+i] = complex(aii, 0)
  1545  			} else {
  1546  				ap[kk+i] = complex(real(ap[kk+i]), 0)
  1547  			}
  1548  			ix += incX
  1549  			iy += incY
  1550  			kk += i + 1
  1551  		}
  1552  	}
  1553  }
  1554  
  1555  // Ctbmv performs one of the matrix-vector operations
  1556  //  x = A * x   if trans = blas.NoTrans
  1557  //  x = Aᵀ * x  if trans = blas.Trans
  1558  //  x = Aᴴ * x  if trans = blas.ConjTrans
  1559  // where x is an n element vector and A is an n×n triangular band matrix, with
  1560  // (k+1) diagonals.
  1561  //
  1562  // Complex64 implementations are autogenerated and not directly tested.
  1563  func (Implementation) Ctbmv(uplo blas.Uplo, trans blas.Transpose, diag blas.Diag, n, k int, a []complex64, lda int, x []complex64, incX int) {
  1564  	switch trans {
  1565  	default:
  1566  		panic(badTranspose)
  1567  	case blas.NoTrans, blas.Trans, blas.ConjTrans:
  1568  	}
  1569  	switch uplo {
  1570  	default:
  1571  		panic(badUplo)
  1572  	case blas.Upper, blas.Lower:
  1573  	}
  1574  	switch diag {
  1575  	default:
  1576  		panic(badDiag)
  1577  	case blas.NonUnit, blas.Unit:
  1578  	}
  1579  	if n < 0 {
  1580  		panic(nLT0)
  1581  	}
  1582  	if k < 0 {
  1583  		panic(kLT0)
  1584  	}
  1585  	if lda < k+1 {
  1586  		panic(badLdA)
  1587  	}
  1588  	if incX == 0 {
  1589  		panic(zeroIncX)
  1590  	}
  1591  
  1592  	// Quick return if possible.
  1593  	if n == 0 {
  1594  		return
  1595  	}
  1596  
  1597  	// For zero matrix size the following slice length checks are trivially satisfied.
  1598  	if len(a) < lda*(n-1)+k+1 {
  1599  		panic(shortA)
  1600  	}
  1601  	if (incX > 0 && len(x) <= (n-1)*incX) || (incX < 0 && len(x) <= (1-n)*incX) {
  1602  		panic(shortX)
  1603  	}
  1604  
  1605  	// Set up start index in X.
  1606  	var kx int
  1607  	if incX < 0 {
  1608  		kx = (1 - n) * incX
  1609  	}
  1610  
  1611  	switch trans {
  1612  	case blas.NoTrans:
  1613  		if uplo == blas.Upper {
  1614  			if incX == 1 {
  1615  				for i := 0; i < n; i++ {
  1616  					xi := x[i]
  1617  					if diag == blas.NonUnit {
  1618  						xi *= a[i*lda]
  1619  					}
  1620  					kk := min(k, n-i-1)
  1621  					for j, aij := range a[i*lda+1 : i*lda+kk+1] {
  1622  						xi += x[i+j+1] * aij
  1623  					}
  1624  					x[i] = xi
  1625  				}
  1626  			} else {
  1627  				ix := kx
  1628  				for i := 0; i < n; i++ {
  1629  					xi := x[ix]
  1630  					if diag == blas.NonUnit {
  1631  						xi *= a[i*lda]
  1632  					}
  1633  					kk := min(k, n-i-1)
  1634  					jx := ix + incX
  1635  					for _, aij := range a[i*lda+1 : i*lda+kk+1] {
  1636  						xi += x[jx] * aij
  1637  						jx += incX
  1638  					}
  1639  					x[ix] = xi
  1640  					ix += incX
  1641  				}
  1642  			}
  1643  		} else {
  1644  			if incX == 1 {
  1645  				for i := n - 1; i >= 0; i-- {
  1646  					xi := x[i]
  1647  					if diag == blas.NonUnit {
  1648  						xi *= a[i*lda+k]
  1649  					}
  1650  					kk := min(k, i)
  1651  					for j, aij := range a[i*lda+k-kk : i*lda+k] {
  1652  						xi += x[i-kk+j] * aij
  1653  					}
  1654  					x[i] = xi
  1655  				}
  1656  			} else {
  1657  				ix := kx + (n-1)*incX
  1658  				for i := n - 1; i >= 0; i-- {
  1659  					xi := x[ix]
  1660  					if diag == blas.NonUnit {
  1661  						xi *= a[i*lda+k]
  1662  					}
  1663  					kk := min(k, i)
  1664  					jx := ix - kk*incX
  1665  					for _, aij := range a[i*lda+k-kk : i*lda+k] {
  1666  						xi += x[jx] * aij
  1667  						jx += incX
  1668  					}
  1669  					x[ix] = xi
  1670  					ix -= incX
  1671  				}
  1672  			}
  1673  		}
  1674  	case blas.Trans:
  1675  		if uplo == blas.Upper {
  1676  			if incX == 1 {
  1677  				for i := n - 1; i >= 0; i-- {
  1678  					kk := min(k, n-i-1)
  1679  					xi := x[i]
  1680  					for j, aij := range a[i*lda+1 : i*lda+kk+1] {
  1681  						x[i+j+1] += xi * aij
  1682  					}
  1683  					if diag == blas.NonUnit {
  1684  						x[i] *= a[i*lda]
  1685  					}
  1686  				}
  1687  			} else {
  1688  				ix := kx + (n-1)*incX
  1689  				for i := n - 1; i >= 0; i-- {
  1690  					kk := min(k, n-i-1)
  1691  					jx := ix + incX
  1692  					xi := x[ix]
  1693  					for _, aij := range a[i*lda+1 : i*lda+kk+1] {
  1694  						x[jx] += xi * aij
  1695  						jx += incX
  1696  					}
  1697  					if diag == blas.NonUnit {
  1698  						x[ix] *= a[i*lda]
  1699  					}
  1700  					ix -= incX
  1701  				}
  1702  			}
  1703  		} else {
  1704  			if incX == 1 {
  1705  				for i := 0; i < n; i++ {
  1706  					kk := min(k, i)
  1707  					xi := x[i]
  1708  					for j, aij := range a[i*lda+k-kk : i*lda+k] {
  1709  						x[i-kk+j] += xi * aij
  1710  					}
  1711  					if diag == blas.NonUnit {
  1712  						x[i] *= a[i*lda+k]
  1713  					}
  1714  				}
  1715  			} else {
  1716  				ix := kx
  1717  				for i := 0; i < n; i++ {
  1718  					kk := min(k, i)
  1719  					jx := ix - kk*incX
  1720  					xi := x[ix]
  1721  					for _, aij := range a[i*lda+k-kk : i*lda+k] {
  1722  						x[jx] += xi * aij
  1723  						jx += incX
  1724  					}
  1725  					if diag == blas.NonUnit {
  1726  						x[ix] *= a[i*lda+k]
  1727  					}
  1728  					ix += incX
  1729  				}
  1730  			}
  1731  		}
  1732  	case blas.ConjTrans:
  1733  		if uplo == blas.Upper {
  1734  			if incX == 1 {
  1735  				for i := n - 1; i >= 0; i-- {
  1736  					kk := min(k, n-i-1)
  1737  					xi := x[i]
  1738  					for j, aij := range a[i*lda+1 : i*lda+kk+1] {
  1739  						x[i+j+1] += xi * cmplx.Conj(aij)
  1740  					}
  1741  					if diag == blas.NonUnit {
  1742  						x[i] *= cmplx.Conj(a[i*lda])
  1743  					}
  1744  				}
  1745  			} else {
  1746  				ix := kx + (n-1)*incX
  1747  				for i := n - 1; i >= 0; i-- {
  1748  					kk := min(k, n-i-1)
  1749  					jx := ix + incX
  1750  					xi := x[ix]
  1751  					for _, aij := range a[i*lda+1 : i*lda+kk+1] {
  1752  						x[jx] += xi * cmplx.Conj(aij)
  1753  						jx += incX
  1754  					}
  1755  					if diag == blas.NonUnit {
  1756  						x[ix] *= cmplx.Conj(a[i*lda])
  1757  					}
  1758  					ix -= incX
  1759  				}
  1760  			}
  1761  		} else {
  1762  			if incX == 1 {
  1763  				for i := 0; i < n; i++ {
  1764  					kk := min(k, i)
  1765  					xi := x[i]
  1766  					for j, aij := range a[i*lda+k-kk : i*lda+k] {
  1767  						x[i-kk+j] += xi * cmplx.Conj(aij)
  1768  					}
  1769  					if diag == blas.NonUnit {
  1770  						x[i] *= cmplx.Conj(a[i*lda+k])
  1771  					}
  1772  				}
  1773  			} else {
  1774  				ix := kx
  1775  				for i := 0; i < n; i++ {
  1776  					kk := min(k, i)
  1777  					jx := ix - kk*incX
  1778  					xi := x[ix]
  1779  					for _, aij := range a[i*lda+k-kk : i*lda+k] {
  1780  						x[jx] += xi * cmplx.Conj(aij)
  1781  						jx += incX
  1782  					}
  1783  					if diag == blas.NonUnit {
  1784  						x[ix] *= cmplx.Conj(a[i*lda+k])
  1785  					}
  1786  					ix += incX
  1787  				}
  1788  			}
  1789  		}
  1790  	}
  1791  }
  1792  
  1793  // Ctbsv solves one of the systems of equations
  1794  //  A * x = b   if trans == blas.NoTrans
  1795  //  Aᵀ * x = b  if trans == blas.Trans
  1796  //  Aᴴ * x = b  if trans == blas.ConjTrans
  1797  // where b and x are n element vectors and A is an n×n triangular band matrix
  1798  // with (k+1) diagonals.
  1799  //
  1800  // On entry, x contains the values of b, and the solution is
  1801  // stored in-place into x.
  1802  //
  1803  // No test for singularity or near-singularity is included in this
  1804  // routine. Such tests must be performed before calling this routine.
  1805  //
  1806  // Complex64 implementations are autogenerated and not directly tested.
  1807  func (Implementation) Ctbsv(uplo blas.Uplo, trans blas.Transpose, diag blas.Diag, n, k int, a []complex64, lda int, x []complex64, incX int) {
  1808  	switch trans {
  1809  	default:
  1810  		panic(badTranspose)
  1811  	case blas.NoTrans, blas.Trans, blas.ConjTrans:
  1812  	}
  1813  	switch uplo {
  1814  	default:
  1815  		panic(badUplo)
  1816  	case blas.Upper, blas.Lower:
  1817  	}
  1818  	switch diag {
  1819  	default:
  1820  		panic(badDiag)
  1821  	case blas.NonUnit, blas.Unit:
  1822  	}
  1823  	if n < 0 {
  1824  		panic(nLT0)
  1825  	}
  1826  	if k < 0 {
  1827  		panic(kLT0)
  1828  	}
  1829  	if lda < k+1 {
  1830  		panic(badLdA)
  1831  	}
  1832  	if incX == 0 {
  1833  		panic(zeroIncX)
  1834  	}
  1835  
  1836  	// Quick return if possible.
  1837  	if n == 0 {
  1838  		return
  1839  	}
  1840  
  1841  	// For zero matrix size the following slice length checks are trivially satisfied.
  1842  	if len(a) < lda*(n-1)+k+1 {
  1843  		panic(shortA)
  1844  	}
  1845  	if (incX > 0 && len(x) <= (n-1)*incX) || (incX < 0 && len(x) <= (1-n)*incX) {
  1846  		panic(shortX)
  1847  	}
  1848  
  1849  	// Set up start index in X.
  1850  	var kx int
  1851  	if incX < 0 {
  1852  		kx = (1 - n) * incX
  1853  	}
  1854  
  1855  	switch trans {
  1856  	case blas.NoTrans:
  1857  		if uplo == blas.Upper {
  1858  			if incX == 1 {
  1859  				for i := n - 1; i >= 0; i-- {
  1860  					kk := min(k, n-i-1)
  1861  					var sum complex64
  1862  					for j, aij := range a[i*lda+1 : i*lda+kk+1] {
  1863  						sum += x[i+1+j] * aij
  1864  					}
  1865  					x[i] -= sum
  1866  					if diag == blas.NonUnit {
  1867  						x[i] /= a[i*lda]
  1868  					}
  1869  				}
  1870  			} else {
  1871  				ix := kx + (n-1)*incX
  1872  				for i := n - 1; i >= 0; i-- {
  1873  					kk := min(k, n-i-1)
  1874  					var sum complex64
  1875  					jx := ix + incX
  1876  					for _, aij := range a[i*lda+1 : i*lda+kk+1] {
  1877  						sum += x[jx] * aij
  1878  						jx += incX
  1879  					}
  1880  					x[ix] -= sum
  1881  					if diag == blas.NonUnit {
  1882  						x[ix] /= a[i*lda]
  1883  					}
  1884  					ix -= incX
  1885  				}
  1886  			}
  1887  		} else {
  1888  			if incX == 1 {
  1889  				for i := 0; i < n; i++ {
  1890  					kk := min(k, i)
  1891  					var sum complex64
  1892  					for j, aij := range a[i*lda+k-kk : i*lda+k] {
  1893  						sum += x[i-kk+j] * aij
  1894  					}
  1895  					x[i] -= sum
  1896  					if diag == blas.NonUnit {
  1897  						x[i] /= a[i*lda+k]
  1898  					}
  1899  				}
  1900  			} else {
  1901  				ix := kx
  1902  				for i := 0; i < n; i++ {
  1903  					kk := min(k, i)
  1904  					var sum complex64
  1905  					jx := ix - kk*incX
  1906  					for _, aij := range a[i*lda+k-kk : i*lda+k] {
  1907  						sum += x[jx] * aij
  1908  						jx += incX
  1909  					}
  1910  					x[ix] -= sum
  1911  					if diag == blas.NonUnit {
  1912  						x[ix] /= a[i*lda+k]
  1913  					}
  1914  					ix += incX
  1915  				}
  1916  			}
  1917  		}
  1918  	case blas.Trans:
  1919  		if uplo == blas.Upper {
  1920  			if incX == 1 {
  1921  				for i := 0; i < n; i++ {
  1922  					if diag == blas.NonUnit {
  1923  						x[i] /= a[i*lda]
  1924  					}
  1925  					kk := min(k, n-i-1)
  1926  					xi := x[i]
  1927  					for j, aij := range a[i*lda+1 : i*lda+kk+1] {
  1928  						x[i+1+j] -= xi * aij
  1929  					}
  1930  				}
  1931  			} else {
  1932  				ix := kx
  1933  				for i := 0; i < n; i++ {
  1934  					if diag == blas.NonUnit {
  1935  						x[ix] /= a[i*lda]
  1936  					}
  1937  					kk := min(k, n-i-1)
  1938  					xi := x[ix]
  1939  					jx := ix + incX
  1940  					for _, aij := range a[i*lda+1 : i*lda+kk+1] {
  1941  						x[jx] -= xi * aij
  1942  						jx += incX
  1943  					}
  1944  					ix += incX
  1945  				}
  1946  			}
  1947  		} else {
  1948  			if incX == 1 {
  1949  				for i := n - 1; i >= 0; i-- {
  1950  					if diag == blas.NonUnit {
  1951  						x[i] /= a[i*lda+k]
  1952  					}
  1953  					kk := min(k, i)
  1954  					xi := x[i]
  1955  					for j, aij := range a[i*lda+k-kk : i*lda+k] {
  1956  						x[i-kk+j] -= xi * aij
  1957  					}
  1958  				}
  1959  			} else {
  1960  				ix := kx + (n-1)*incX
  1961  				for i := n - 1; i >= 0; i-- {
  1962  					if diag == blas.NonUnit {
  1963  						x[ix] /= a[i*lda+k]
  1964  					}
  1965  					kk := min(k, i)
  1966  					xi := x[ix]
  1967  					jx := ix - kk*incX
  1968  					for _, aij := range a[i*lda+k-kk : i*lda+k] {
  1969  						x[jx] -= xi * aij
  1970  						jx += incX
  1971  					}
  1972  					ix -= incX
  1973  				}
  1974  			}
  1975  		}
  1976  	case blas.ConjTrans:
  1977  		if uplo == blas.Upper {
  1978  			if incX == 1 {
  1979  				for i := 0; i < n; i++ {
  1980  					if diag == blas.NonUnit {
  1981  						x[i] /= cmplx.Conj(a[i*lda])
  1982  					}
  1983  					kk := min(k, n-i-1)
  1984  					xi := x[i]
  1985  					for j, aij := range a[i*lda+1 : i*lda+kk+1] {
  1986  						x[i+1+j] -= xi * cmplx.Conj(aij)
  1987  					}
  1988  				}
  1989  			} else {
  1990  				ix := kx
  1991  				for i := 0; i < n; i++ {
  1992  					if diag == blas.NonUnit {
  1993  						x[ix] /= cmplx.Conj(a[i*lda])
  1994  					}
  1995  					kk := min(k, n-i-1)
  1996  					xi := x[ix]
  1997  					jx := ix + incX
  1998  					for _, aij := range a[i*lda+1 : i*lda+kk+1] {
  1999  						x[jx] -= xi * cmplx.Conj(aij)
  2000  						jx += incX
  2001  					}
  2002  					ix += incX
  2003  				}
  2004  			}
  2005  		} else {
  2006  			if incX == 1 {
  2007  				for i := n - 1; i >= 0; i-- {
  2008  					if diag == blas.NonUnit {
  2009  						x[i] /= cmplx.Conj(a[i*lda+k])
  2010  					}
  2011  					kk := min(k, i)
  2012  					xi := x[i]
  2013  					for j, aij := range a[i*lda+k-kk : i*lda+k] {
  2014  						x[i-kk+j] -= xi * cmplx.Conj(aij)
  2015  					}
  2016  				}
  2017  			} else {
  2018  				ix := kx + (n-1)*incX
  2019  				for i := n - 1; i >= 0; i-- {
  2020  					if diag == blas.NonUnit {
  2021  						x[ix] /= cmplx.Conj(a[i*lda+k])
  2022  					}
  2023  					kk := min(k, i)
  2024  					xi := x[ix]
  2025  					jx := ix - kk*incX
  2026  					for _, aij := range a[i*lda+k-kk : i*lda+k] {
  2027  						x[jx] -= xi * cmplx.Conj(aij)
  2028  						jx += incX
  2029  					}
  2030  					ix -= incX
  2031  				}
  2032  			}
  2033  		}
  2034  	}
  2035  }
  2036  
  2037  // Ctpmv performs one of the matrix-vector operations
  2038  //  x = A * x   if trans = blas.NoTrans
  2039  //  x = Aᵀ * x  if trans = blas.Trans
  2040  //  x = Aᴴ * x  if trans = blas.ConjTrans
  2041  // where x is an n element vector and A is an n×n triangular matrix, supplied in
  2042  // packed form.
  2043  //
  2044  // Complex64 implementations are autogenerated and not directly tested.
  2045  func (Implementation) Ctpmv(uplo blas.Uplo, trans blas.Transpose, diag blas.Diag, n int, ap []complex64, x []complex64, incX int) {
  2046  	switch uplo {
  2047  	default:
  2048  		panic(badUplo)
  2049  	case blas.Upper, blas.Lower:
  2050  	}
  2051  	switch trans {
  2052  	default:
  2053  		panic(badTranspose)
  2054  	case blas.NoTrans, blas.Trans, blas.ConjTrans:
  2055  	}
  2056  	switch diag {
  2057  	default:
  2058  		panic(badDiag)
  2059  	case blas.NonUnit, blas.Unit:
  2060  	}
  2061  	if n < 0 {
  2062  		panic(nLT0)
  2063  	}
  2064  	if incX == 0 {
  2065  		panic(zeroIncX)
  2066  	}
  2067  
  2068  	// Quick return if possible.
  2069  	if n == 0 {
  2070  		return
  2071  	}
  2072  
  2073  	// For zero matrix size the following slice length checks are trivially satisfied.
  2074  	if len(ap) < n*(n+1)/2 {
  2075  		panic(shortAP)
  2076  	}
  2077  	if (incX > 0 && len(x) <= (n-1)*incX) || (incX < 0 && len(x) <= (1-n)*incX) {
  2078  		panic(shortX)
  2079  	}
  2080  
  2081  	// Set up start index in X.
  2082  	var kx int
  2083  	if incX < 0 {
  2084  		kx = (1 - n) * incX
  2085  	}
  2086  
  2087  	// The elements of A are accessed sequentially with one pass through A.
  2088  
  2089  	if trans == blas.NoTrans {
  2090  		// Form x = A*x.
  2091  		if uplo == blas.Upper {
  2092  			// kk points to the current diagonal element in ap.
  2093  			kk := 0
  2094  			if incX == 1 {
  2095  				x = x[:n]
  2096  				for i := range x {
  2097  					if diag == blas.NonUnit {
  2098  						x[i] *= ap[kk]
  2099  					}
  2100  					if n-i-1 > 0 {
  2101  						x[i] += c64.DotuUnitary(ap[kk+1:kk+n-i], x[i+1:])
  2102  					}
  2103  					kk += n - i
  2104  				}
  2105  			} else {
  2106  				ix := kx
  2107  				for i := 0; i < n; i++ {
  2108  					if diag == blas.NonUnit {
  2109  						x[ix] *= ap[kk]
  2110  					}
  2111  					if n-i-1 > 0 {
  2112  						x[ix] += c64.DotuInc(ap[kk+1:kk+n-i], x, uintptr(n-i-1), 1, uintptr(incX), 0, uintptr(ix+incX))
  2113  					}
  2114  					ix += incX
  2115  					kk += n - i
  2116  				}
  2117  			}
  2118  		} else {
  2119  			// kk points to the beginning of current row in ap.
  2120  			kk := n*(n+1)/2 - n
  2121  			if incX == 1 {
  2122  				for i := n - 1; i >= 0; i-- {
  2123  					if diag == blas.NonUnit {
  2124  						x[i] *= ap[kk+i]
  2125  					}
  2126  					if i > 0 {
  2127  						x[i] += c64.DotuUnitary(ap[kk:kk+i], x[:i])
  2128  					}
  2129  					kk -= i
  2130  				}
  2131  			} else {
  2132  				ix := kx + (n-1)*incX
  2133  				for i := n - 1; i >= 0; i-- {
  2134  					if diag == blas.NonUnit {
  2135  						x[ix] *= ap[kk+i]
  2136  					}
  2137  					if i > 0 {
  2138  						x[ix] += c64.DotuInc(ap[kk:kk+i], x, uintptr(i), 1, uintptr(incX), 0, uintptr(kx))
  2139  					}
  2140  					ix -= incX
  2141  					kk -= i
  2142  				}
  2143  			}
  2144  		}
  2145  		return
  2146  	}
  2147  
  2148  	if trans == blas.Trans {
  2149  		// Form x = Aᵀ*x.
  2150  		if uplo == blas.Upper {
  2151  			// kk points to the current diagonal element in ap.
  2152  			kk := n*(n+1)/2 - 1
  2153  			if incX == 1 {
  2154  				for i := n - 1; i >= 0; i-- {
  2155  					xi := x[i]
  2156  					if diag == blas.NonUnit {
  2157  						x[i] *= ap[kk]
  2158  					}
  2159  					if n-i-1 > 0 {
  2160  						c64.AxpyUnitary(xi, ap[kk+1:kk+n-i], x[i+1:n])
  2161  					}
  2162  					kk -= n - i + 1
  2163  				}
  2164  			} else {
  2165  				ix := kx + (n-1)*incX
  2166  				for i := n - 1; i >= 0; i-- {
  2167  					xi := x[ix]
  2168  					if diag == blas.NonUnit {
  2169  						x[ix] *= ap[kk]
  2170  					}
  2171  					if n-i-1 > 0 {
  2172  						c64.AxpyInc(xi, ap[kk+1:kk+n-i], x, uintptr(n-i-1), 1, uintptr(incX), 0, uintptr(ix+incX))
  2173  					}
  2174  					ix -= incX
  2175  					kk -= n - i + 1
  2176  				}
  2177  			}
  2178  		} else {
  2179  			// kk points to the beginning of current row in ap.
  2180  			kk := 0
  2181  			if incX == 1 {
  2182  				x = x[:n]
  2183  				for i := range x {
  2184  					if i > 0 {
  2185  						c64.AxpyUnitary(x[i], ap[kk:kk+i], x[:i])
  2186  					}
  2187  					if diag == blas.NonUnit {
  2188  						x[i] *= ap[kk+i]
  2189  					}
  2190  					kk += i + 1
  2191  				}
  2192  			} else {
  2193  				ix := kx
  2194  				for i := 0; i < n; i++ {
  2195  					if i > 0 {
  2196  						c64.AxpyInc(x[ix], ap[kk:kk+i], x, uintptr(i), 1, uintptr(incX), 0, uintptr(kx))
  2197  					}
  2198  					if diag == blas.NonUnit {
  2199  						x[ix] *= ap[kk+i]
  2200  					}
  2201  					ix += incX
  2202  					kk += i + 1
  2203  				}
  2204  			}
  2205  		}
  2206  		return
  2207  	}
  2208  
  2209  	// Form x = Aᴴ*x.
  2210  	if uplo == blas.Upper {
  2211  		// kk points to the current diagonal element in ap.
  2212  		kk := n*(n+1)/2 - 1
  2213  		if incX == 1 {
  2214  			for i := n - 1; i >= 0; i-- {
  2215  				xi := x[i]
  2216  				if diag == blas.NonUnit {
  2217  					x[i] *= cmplx.Conj(ap[kk])
  2218  				}
  2219  				k := kk + 1
  2220  				for j := i + 1; j < n; j++ {
  2221  					x[j] += xi * cmplx.Conj(ap[k])
  2222  					k++
  2223  				}
  2224  				kk -= n - i + 1
  2225  			}
  2226  		} else {
  2227  			ix := kx + (n-1)*incX
  2228  			for i := n - 1; i >= 0; i-- {
  2229  				xi := x[ix]
  2230  				if diag == blas.NonUnit {
  2231  					x[ix] *= cmplx.Conj(ap[kk])
  2232  				}
  2233  				jx := ix + incX
  2234  				k := kk + 1
  2235  				for j := i + 1; j < n; j++ {
  2236  					x[jx] += xi * cmplx.Conj(ap[k])
  2237  					jx += incX
  2238  					k++
  2239  				}
  2240  				ix -= incX
  2241  				kk -= n - i + 1
  2242  			}
  2243  		}
  2244  	} else {
  2245  		// kk points to the beginning of current row in ap.
  2246  		kk := 0
  2247  		if incX == 1 {
  2248  			x = x[:n]
  2249  			for i, xi := range x {
  2250  				for j := 0; j < i; j++ {
  2251  					x[j] += xi * cmplx.Conj(ap[kk+j])
  2252  				}
  2253  				if diag == blas.NonUnit {
  2254  					x[i] *= cmplx.Conj(ap[kk+i])
  2255  				}
  2256  				kk += i + 1
  2257  			}
  2258  		} else {
  2259  			ix := kx
  2260  			for i := 0; i < n; i++ {
  2261  				xi := x[ix]
  2262  				jx := kx
  2263  				for j := 0; j < i; j++ {
  2264  					x[jx] += xi * cmplx.Conj(ap[kk+j])
  2265  					jx += incX
  2266  				}
  2267  				if diag == blas.NonUnit {
  2268  					x[ix] *= cmplx.Conj(ap[kk+i])
  2269  				}
  2270  				ix += incX
  2271  				kk += i + 1
  2272  			}
  2273  		}
  2274  	}
  2275  }
  2276  
  2277  // Ctpsv solves one of the systems of equations
  2278  //  A * x = b   if trans == blas.NoTrans
  2279  //  Aᵀ * x = b  if trans == blas.Trans
  2280  //  Aᴴ * x = b  if trans == blas.ConjTrans
  2281  // where b and x are n element vectors and A is an n×n triangular matrix in
  2282  // packed form.
  2283  //
  2284  // On entry, x contains the values of b, and the solution is
  2285  // stored in-place into x.
  2286  //
  2287  // No test for singularity or near-singularity is included in this
  2288  // routine. Such tests must be performed before calling this routine.
  2289  //
  2290  // Complex64 implementations are autogenerated and not directly tested.
  2291  func (Implementation) Ctpsv(uplo blas.Uplo, trans blas.Transpose, diag blas.Diag, n int, ap []complex64, x []complex64, incX int) {
  2292  	switch uplo {
  2293  	default:
  2294  		panic(badUplo)
  2295  	case blas.Upper, blas.Lower:
  2296  	}
  2297  	switch trans {
  2298  	default:
  2299  		panic(badTranspose)
  2300  	case blas.NoTrans, blas.Trans, blas.ConjTrans:
  2301  	}
  2302  	switch diag {
  2303  	default:
  2304  		panic(badDiag)
  2305  	case blas.NonUnit, blas.Unit:
  2306  	}
  2307  	if n < 0 {
  2308  		panic(nLT0)
  2309  	}
  2310  	if incX == 0 {
  2311  		panic(zeroIncX)
  2312  	}
  2313  
  2314  	// Quick return if possible.
  2315  	if n == 0 {
  2316  		return
  2317  	}
  2318  
  2319  	// For zero matrix size the following slice length checks are trivially satisfied.
  2320  	if len(ap) < n*(n+1)/2 {
  2321  		panic(shortAP)
  2322  	}
  2323  	if (incX > 0 && len(x) <= (n-1)*incX) || (incX < 0 && len(x) <= (1-n)*incX) {
  2324  		panic(shortX)
  2325  	}
  2326  
  2327  	// Set up start index in X.
  2328  	var kx int
  2329  	if incX < 0 {
  2330  		kx = (1 - n) * incX
  2331  	}
  2332  
  2333  	// The elements of A are accessed sequentially with one pass through ap.
  2334  
  2335  	if trans == blas.NoTrans {
  2336  		// Form x = inv(A)*x.
  2337  		if uplo == blas.Upper {
  2338  			kk := n*(n+1)/2 - 1
  2339  			if incX == 1 {
  2340  				for i := n - 1; i >= 0; i-- {
  2341  					aii := ap[kk]
  2342  					if n-i-1 > 0 {
  2343  						x[i] -= c64.DotuUnitary(x[i+1:n], ap[kk+1:kk+n-i])
  2344  					}
  2345  					if diag == blas.NonUnit {
  2346  						x[i] /= aii
  2347  					}
  2348  					kk -= n - i + 1
  2349  				}
  2350  			} else {
  2351  				ix := kx + (n-1)*incX
  2352  				for i := n - 1; i >= 0; i-- {
  2353  					aii := ap[kk]
  2354  					if n-i-1 > 0 {
  2355  						x[ix] -= c64.DotuInc(x, ap[kk+1:kk+n-i], uintptr(n-i-1), uintptr(incX), 1, uintptr(ix+incX), 0)
  2356  					}
  2357  					if diag == blas.NonUnit {
  2358  						x[ix] /= aii
  2359  					}
  2360  					ix -= incX
  2361  					kk -= n - i + 1
  2362  				}
  2363  			}
  2364  		} else {
  2365  			kk := 0
  2366  			if incX == 1 {
  2367  				for i := 0; i < n; i++ {
  2368  					if i > 0 {
  2369  						x[i] -= c64.DotuUnitary(x[:i], ap[kk:kk+i])
  2370  					}
  2371  					if diag == blas.NonUnit {
  2372  						x[i] /= ap[kk+i]
  2373  					}
  2374  					kk += i + 1
  2375  				}
  2376  			} else {
  2377  				ix := kx
  2378  				for i := 0; i < n; i++ {
  2379  					if i > 0 {
  2380  						x[ix] -= c64.DotuInc(x, ap[kk:kk+i], uintptr(i), uintptr(incX), 1, uintptr(kx), 0)
  2381  					}
  2382  					if diag == blas.NonUnit {
  2383  						x[ix] /= ap[kk+i]
  2384  					}
  2385  					ix += incX
  2386  					kk += i + 1
  2387  				}
  2388  			}
  2389  		}
  2390  		return
  2391  	}
  2392  
  2393  	if trans == blas.Trans {
  2394  		// Form x = inv(Aᵀ)*x.
  2395  		if uplo == blas.Upper {
  2396  			kk := 0
  2397  			if incX == 1 {
  2398  				for j := 0; j < n; j++ {
  2399  					if diag == blas.NonUnit {
  2400  						x[j] /= ap[kk]
  2401  					}
  2402  					if n-j-1 > 0 {
  2403  						c64.AxpyUnitary(-x[j], ap[kk+1:kk+n-j], x[j+1:n])
  2404  					}
  2405  					kk += n - j
  2406  				}
  2407  			} else {
  2408  				jx := kx
  2409  				for j := 0; j < n; j++ {
  2410  					if diag == blas.NonUnit {
  2411  						x[jx] /= ap[kk]
  2412  					}
  2413  					if n-j-1 > 0 {
  2414  						c64.AxpyInc(-x[jx], ap[kk+1:kk+n-j], x, uintptr(n-j-1), 1, uintptr(incX), 0, uintptr(jx+incX))
  2415  					}
  2416  					jx += incX
  2417  					kk += n - j
  2418  				}
  2419  			}
  2420  		} else {
  2421  			kk := n*(n+1)/2 - n
  2422  			if incX == 1 {
  2423  				for j := n - 1; j >= 0; j-- {
  2424  					if diag == blas.NonUnit {
  2425  						x[j] /= ap[kk+j]
  2426  					}
  2427  					if j > 0 {
  2428  						c64.AxpyUnitary(-x[j], ap[kk:kk+j], x[:j])
  2429  					}
  2430  					kk -= j
  2431  				}
  2432  			} else {
  2433  				jx := kx + (n-1)*incX
  2434  				for j := n - 1; j >= 0; j-- {
  2435  					if diag == blas.NonUnit {
  2436  						x[jx] /= ap[kk+j]
  2437  					}
  2438  					if j > 0 {
  2439  						c64.AxpyInc(-x[jx], ap[kk:kk+j], x, uintptr(j), 1, uintptr(incX), 0, uintptr(kx))
  2440  					}
  2441  					jx -= incX
  2442  					kk -= j
  2443  				}
  2444  			}
  2445  		}
  2446  		return
  2447  	}
  2448  
  2449  	// Form x = inv(Aᴴ)*x.
  2450  	if uplo == blas.Upper {
  2451  		kk := 0
  2452  		if incX == 1 {
  2453  			for j := 0; j < n; j++ {
  2454  				if diag == blas.NonUnit {
  2455  					x[j] /= cmplx.Conj(ap[kk])
  2456  				}
  2457  				xj := x[j]
  2458  				k := kk + 1
  2459  				for i := j + 1; i < n; i++ {
  2460  					x[i] -= xj * cmplx.Conj(ap[k])
  2461  					k++
  2462  				}
  2463  				kk += n - j
  2464  			}
  2465  		} else {
  2466  			jx := kx
  2467  			for j := 0; j < n; j++ {
  2468  				if diag == blas.NonUnit {
  2469  					x[jx] /= cmplx.Conj(ap[kk])
  2470  				}
  2471  				xj := x[jx]
  2472  				ix := jx + incX
  2473  				k := kk + 1
  2474  				for i := j + 1; i < n; i++ {
  2475  					x[ix] -= xj * cmplx.Conj(ap[k])
  2476  					ix += incX
  2477  					k++
  2478  				}
  2479  				jx += incX
  2480  				kk += n - j
  2481  			}
  2482  		}
  2483  	} else {
  2484  		kk := n*(n+1)/2 - n
  2485  		if incX == 1 {
  2486  			for j := n - 1; j >= 0; j-- {
  2487  				if diag == blas.NonUnit {
  2488  					x[j] /= cmplx.Conj(ap[kk+j])
  2489  				}
  2490  				xj := x[j]
  2491  				for i := 0; i < j; i++ {
  2492  					x[i] -= xj * cmplx.Conj(ap[kk+i])
  2493  				}
  2494  				kk -= j
  2495  			}
  2496  		} else {
  2497  			jx := kx + (n-1)*incX
  2498  			for j := n - 1; j >= 0; j-- {
  2499  				if diag == blas.NonUnit {
  2500  					x[jx] /= cmplx.Conj(ap[kk+j])
  2501  				}
  2502  				xj := x[jx]
  2503  				ix := kx
  2504  				for i := 0; i < j; i++ {
  2505  					x[ix] -= xj * cmplx.Conj(ap[kk+i])
  2506  					ix += incX
  2507  				}
  2508  				jx -= incX
  2509  				kk -= j
  2510  			}
  2511  		}
  2512  	}
  2513  }
  2514  
  2515  // Ctrmv performs one of the matrix-vector operations
  2516  //  x = A * x   if trans = blas.NoTrans
  2517  //  x = Aᵀ * x  if trans = blas.Trans
  2518  //  x = Aᴴ * x  if trans = blas.ConjTrans
  2519  // where x is a vector, and A is an n×n triangular matrix.
  2520  //
  2521  // Complex64 implementations are autogenerated and not directly tested.
  2522  func (Implementation) Ctrmv(uplo blas.Uplo, trans blas.Transpose, diag blas.Diag, n int, a []complex64, lda int, x []complex64, incX int) {
  2523  	switch trans {
  2524  	default:
  2525  		panic(badTranspose)
  2526  	case blas.NoTrans, blas.Trans, blas.ConjTrans:
  2527  	}
  2528  	switch uplo {
  2529  	default:
  2530  		panic(badUplo)
  2531  	case blas.Upper, blas.Lower:
  2532  	}
  2533  	switch diag {
  2534  	default:
  2535  		panic(badDiag)
  2536  	case blas.NonUnit, blas.Unit:
  2537  	}
  2538  	if n < 0 {
  2539  		panic(nLT0)
  2540  	}
  2541  	if lda < max(1, n) {
  2542  		panic(badLdA)
  2543  	}
  2544  	if incX == 0 {
  2545  		panic(zeroIncX)
  2546  	}
  2547  
  2548  	// Quick return if possible.
  2549  	if n == 0 {
  2550  		return
  2551  	}
  2552  
  2553  	// For zero matrix size the following slice length checks are trivially satisfied.
  2554  	if len(a) < lda*(n-1)+n {
  2555  		panic(shortA)
  2556  	}
  2557  	if (incX > 0 && len(x) <= (n-1)*incX) || (incX < 0 && len(x) <= (1-n)*incX) {
  2558  		panic(shortX)
  2559  	}
  2560  
  2561  	// Set up start index in X.
  2562  	var kx int
  2563  	if incX < 0 {
  2564  		kx = (1 - n) * incX
  2565  	}
  2566  
  2567  	// The elements of A are accessed sequentially with one pass through A.
  2568  
  2569  	if trans == blas.NoTrans {
  2570  		// Form x = A*x.
  2571  		if uplo == blas.Upper {
  2572  			if incX == 1 {
  2573  				for i := 0; i < n; i++ {
  2574  					if diag == blas.NonUnit {
  2575  						x[i] *= a[i*lda+i]
  2576  					}
  2577  					if n-i-1 > 0 {
  2578  						x[i] += c64.DotuUnitary(a[i*lda+i+1:i*lda+n], x[i+1:n])
  2579  					}
  2580  				}
  2581  			} else {
  2582  				ix := kx
  2583  				for i := 0; i < n; i++ {
  2584  					if diag == blas.NonUnit {
  2585  						x[ix] *= a[i*lda+i]
  2586  					}
  2587  					if n-i-1 > 0 {
  2588  						x[ix] += c64.DotuInc(a[i*lda+i+1:i*lda+n], x, uintptr(n-i-1), 1, uintptr(incX), 0, uintptr(ix+incX))
  2589  					}
  2590  					ix += incX
  2591  				}
  2592  			}
  2593  		} else {
  2594  			if incX == 1 {
  2595  				for i := n - 1; i >= 0; i-- {
  2596  					if diag == blas.NonUnit {
  2597  						x[i] *= a[i*lda+i]
  2598  					}
  2599  					if i > 0 {
  2600  						x[i] += c64.DotuUnitary(a[i*lda:i*lda+i], x[:i])
  2601  					}
  2602  				}
  2603  			} else {
  2604  				ix := kx + (n-1)*incX
  2605  				for i := n - 1; i >= 0; i-- {
  2606  					if diag == blas.NonUnit {
  2607  						x[ix] *= a[i*lda+i]
  2608  					}
  2609  					if i > 0 {
  2610  						x[ix] += c64.DotuInc(a[i*lda:i*lda+i], x, uintptr(i), 1, uintptr(incX), 0, uintptr(kx))
  2611  					}
  2612  					ix -= incX
  2613  				}
  2614  			}
  2615  		}
  2616  		return
  2617  	}
  2618  
  2619  	if trans == blas.Trans {
  2620  		// Form x = Aᵀ*x.
  2621  		if uplo == blas.Upper {
  2622  			if incX == 1 {
  2623  				for i := n - 1; i >= 0; i-- {
  2624  					xi := x[i]
  2625  					if diag == blas.NonUnit {
  2626  						x[i] *= a[i*lda+i]
  2627  					}
  2628  					if n-i-1 > 0 {
  2629  						c64.AxpyUnitary(xi, a[i*lda+i+1:i*lda+n], x[i+1:n])
  2630  					}
  2631  				}
  2632  			} else {
  2633  				ix := kx + (n-1)*incX
  2634  				for i := n - 1; i >= 0; i-- {
  2635  					xi := x[ix]
  2636  					if diag == blas.NonUnit {
  2637  						x[ix] *= a[i*lda+i]
  2638  					}
  2639  					if n-i-1 > 0 {
  2640  						c64.AxpyInc(xi, a[i*lda+i+1:i*lda+n], x, uintptr(n-i-1), 1, uintptr(incX), 0, uintptr(ix+incX))
  2641  					}
  2642  					ix -= incX
  2643  				}
  2644  			}
  2645  		} else {
  2646  			if incX == 1 {
  2647  				for i := 0; i < n; i++ {
  2648  					if i > 0 {
  2649  						c64.AxpyUnitary(x[i], a[i*lda:i*lda+i], x[:i])
  2650  					}
  2651  					if diag == blas.NonUnit {
  2652  						x[i] *= a[i*lda+i]
  2653  					}
  2654  				}
  2655  			} else {
  2656  				ix := kx
  2657  				for i := 0; i < n; i++ {
  2658  					if i > 0 {
  2659  						c64.AxpyInc(x[ix], a[i*lda:i*lda+i], x, uintptr(i), 1, uintptr(incX), 0, uintptr(kx))
  2660  					}
  2661  					if diag == blas.NonUnit {
  2662  						x[ix] *= a[i*lda+i]
  2663  					}
  2664  					ix += incX
  2665  				}
  2666  			}
  2667  		}
  2668  		return
  2669  	}
  2670  
  2671  	// Form x = Aᴴ*x.
  2672  	if uplo == blas.Upper {
  2673  		if incX == 1 {
  2674  			for i := n - 1; i >= 0; i-- {
  2675  				xi := x[i]
  2676  				if diag == blas.NonUnit {
  2677  					x[i] *= cmplx.Conj(a[i*lda+i])
  2678  				}
  2679  				for j := i + 1; j < n; j++ {
  2680  					x[j] += xi * cmplx.Conj(a[i*lda+j])
  2681  				}
  2682  			}
  2683  		} else {
  2684  			ix := kx + (n-1)*incX
  2685  			for i := n - 1; i >= 0; i-- {
  2686  				xi := x[ix]
  2687  				if diag == blas.NonUnit {
  2688  					x[ix] *= cmplx.Conj(a[i*lda+i])
  2689  				}
  2690  				jx := ix + incX
  2691  				for j := i + 1; j < n; j++ {
  2692  					x[jx] += xi * cmplx.Conj(a[i*lda+j])
  2693  					jx += incX
  2694  				}
  2695  				ix -= incX
  2696  			}
  2697  		}
  2698  	} else {
  2699  		if incX == 1 {
  2700  			for i := 0; i < n; i++ {
  2701  				for j := 0; j < i; j++ {
  2702  					x[j] += x[i] * cmplx.Conj(a[i*lda+j])
  2703  				}
  2704  				if diag == blas.NonUnit {
  2705  					x[i] *= cmplx.Conj(a[i*lda+i])
  2706  				}
  2707  			}
  2708  		} else {
  2709  			ix := kx
  2710  			for i := 0; i < n; i++ {
  2711  				jx := kx
  2712  				for j := 0; j < i; j++ {
  2713  					x[jx] += x[ix] * cmplx.Conj(a[i*lda+j])
  2714  					jx += incX
  2715  				}
  2716  				if diag == blas.NonUnit {
  2717  					x[ix] *= cmplx.Conj(a[i*lda+i])
  2718  				}
  2719  				ix += incX
  2720  			}
  2721  		}
  2722  	}
  2723  }
  2724  
  2725  // Ctrsv solves one of the systems of equations
  2726  //  A * x = b   if trans == blas.NoTrans
  2727  //  Aᵀ * x = b  if trans == blas.Trans
  2728  //  Aᴴ * x = b  if trans == blas.ConjTrans
  2729  // where b and x are n element vectors and A is an n×n triangular matrix.
  2730  //
  2731  // On entry, x contains the values of b, and the solution is
  2732  // stored in-place into x.
  2733  //
  2734  // No test for singularity or near-singularity is included in this
  2735  // routine. Such tests must be performed before calling this routine.
  2736  //
  2737  // Complex64 implementations are autogenerated and not directly tested.
  2738  func (Implementation) Ctrsv(uplo blas.Uplo, trans blas.Transpose, diag blas.Diag, n int, a []complex64, lda int, x []complex64, incX int) {
  2739  	switch trans {
  2740  	default:
  2741  		panic(badTranspose)
  2742  	case blas.NoTrans, blas.Trans, blas.ConjTrans:
  2743  	}
  2744  	switch uplo {
  2745  	default:
  2746  		panic(badUplo)
  2747  	case blas.Upper, blas.Lower:
  2748  	}
  2749  	switch diag {
  2750  	default:
  2751  		panic(badDiag)
  2752  	case blas.NonUnit, blas.Unit:
  2753  	}
  2754  	if n < 0 {
  2755  		panic(nLT0)
  2756  	}
  2757  	if lda < max(1, n) {
  2758  		panic(badLdA)
  2759  	}
  2760  	if incX == 0 {
  2761  		panic(zeroIncX)
  2762  	}
  2763  
  2764  	// Quick return if possible.
  2765  	if n == 0 {
  2766  		return
  2767  	}
  2768  
  2769  	// For zero matrix size the following slice length checks are trivially satisfied.
  2770  	if len(a) < lda*(n-1)+n {
  2771  		panic(shortA)
  2772  	}
  2773  	if (incX > 0 && len(x) <= (n-1)*incX) || (incX < 0 && len(x) <= (1-n)*incX) {
  2774  		panic(shortX)
  2775  	}
  2776  
  2777  	// Set up start index in X.
  2778  	var kx int
  2779  	if incX < 0 {
  2780  		kx = (1 - n) * incX
  2781  	}
  2782  
  2783  	// The elements of A are accessed sequentially with one pass through A.
  2784  
  2785  	if trans == blas.NoTrans {
  2786  		// Form x = inv(A)*x.
  2787  		if uplo == blas.Upper {
  2788  			if incX == 1 {
  2789  				for i := n - 1; i >= 0; i-- {
  2790  					aii := a[i*lda+i]
  2791  					if n-i-1 > 0 {
  2792  						x[i] -= c64.DotuUnitary(x[i+1:n], a[i*lda+i+1:i*lda+n])
  2793  					}
  2794  					if diag == blas.NonUnit {
  2795  						x[i] /= aii
  2796  					}
  2797  				}
  2798  			} else {
  2799  				ix := kx + (n-1)*incX
  2800  				for i := n - 1; i >= 0; i-- {
  2801  					aii := a[i*lda+i]
  2802  					if n-i-1 > 0 {
  2803  						x[ix] -= c64.DotuInc(x, a[i*lda+i+1:i*lda+n], uintptr(n-i-1), uintptr(incX), 1, uintptr(ix+incX), 0)
  2804  					}
  2805  					if diag == blas.NonUnit {
  2806  						x[ix] /= aii
  2807  					}
  2808  					ix -= incX
  2809  				}
  2810  			}
  2811  		} else {
  2812  			if incX == 1 {
  2813  				for i := 0; i < n; i++ {
  2814  					if i > 0 {
  2815  						x[i] -= c64.DotuUnitary(x[:i], a[i*lda:i*lda+i])
  2816  					}
  2817  					if diag == blas.NonUnit {
  2818  						x[i] /= a[i*lda+i]
  2819  					}
  2820  				}
  2821  			} else {
  2822  				ix := kx
  2823  				for i := 0; i < n; i++ {
  2824  					if i > 0 {
  2825  						x[ix] -= c64.DotuInc(x, a[i*lda:i*lda+i], uintptr(i), uintptr(incX), 1, uintptr(kx), 0)
  2826  					}
  2827  					if diag == blas.NonUnit {
  2828  						x[ix] /= a[i*lda+i]
  2829  					}
  2830  					ix += incX
  2831  				}
  2832  			}
  2833  		}
  2834  		return
  2835  	}
  2836  
  2837  	if trans == blas.Trans {
  2838  		// Form x = inv(Aᵀ)*x.
  2839  		if uplo == blas.Upper {
  2840  			if incX == 1 {
  2841  				for j := 0; j < n; j++ {
  2842  					if diag == blas.NonUnit {
  2843  						x[j] /= a[j*lda+j]
  2844  					}
  2845  					if n-j-1 > 0 {
  2846  						c64.AxpyUnitary(-x[j], a[j*lda+j+1:j*lda+n], x[j+1:n])
  2847  					}
  2848  				}
  2849  			} else {
  2850  				jx := kx
  2851  				for j := 0; j < n; j++ {
  2852  					if diag == blas.NonUnit {
  2853  						x[jx] /= a[j*lda+j]
  2854  					}
  2855  					if n-j-1 > 0 {
  2856  						c64.AxpyInc(-x[jx], a[j*lda+j+1:j*lda+n], x, uintptr(n-j-1), 1, uintptr(incX), 0, uintptr(jx+incX))
  2857  					}
  2858  					jx += incX
  2859  				}
  2860  			}
  2861  		} else {
  2862  			if incX == 1 {
  2863  				for j := n - 1; j >= 0; j-- {
  2864  					if diag == blas.NonUnit {
  2865  						x[j] /= a[j*lda+j]
  2866  					}
  2867  					xj := x[j]
  2868  					if j > 0 {
  2869  						c64.AxpyUnitary(-xj, a[j*lda:j*lda+j], x[:j])
  2870  					}
  2871  				}
  2872  			} else {
  2873  				jx := kx + (n-1)*incX
  2874  				for j := n - 1; j >= 0; j-- {
  2875  					if diag == blas.NonUnit {
  2876  						x[jx] /= a[j*lda+j]
  2877  					}
  2878  					if j > 0 {
  2879  						c64.AxpyInc(-x[jx], a[j*lda:j*lda+j], x, uintptr(j), 1, uintptr(incX), 0, uintptr(kx))
  2880  					}
  2881  					jx -= incX
  2882  				}
  2883  			}
  2884  		}
  2885  		return
  2886  	}
  2887  
  2888  	// Form x = inv(Aᴴ)*x.
  2889  	if uplo == blas.Upper {
  2890  		if incX == 1 {
  2891  			for j := 0; j < n; j++ {
  2892  				if diag == blas.NonUnit {
  2893  					x[j] /= cmplx.Conj(a[j*lda+j])
  2894  				}
  2895  				xj := x[j]
  2896  				for i := j + 1; i < n; i++ {
  2897  					x[i] -= xj * cmplx.Conj(a[j*lda+i])
  2898  				}
  2899  			}
  2900  		} else {
  2901  			jx := kx
  2902  			for j := 0; j < n; j++ {
  2903  				if diag == blas.NonUnit {
  2904  					x[jx] /= cmplx.Conj(a[j*lda+j])
  2905  				}
  2906  				xj := x[jx]
  2907  				ix := jx + incX
  2908  				for i := j + 1; i < n; i++ {
  2909  					x[ix] -= xj * cmplx.Conj(a[j*lda+i])
  2910  					ix += incX
  2911  				}
  2912  				jx += incX
  2913  			}
  2914  		}
  2915  	} else {
  2916  		if incX == 1 {
  2917  			for j := n - 1; j >= 0; j-- {
  2918  				if diag == blas.NonUnit {
  2919  					x[j] /= cmplx.Conj(a[j*lda+j])
  2920  				}
  2921  				xj := x[j]
  2922  				for i := 0; i < j; i++ {
  2923  					x[i] -= xj * cmplx.Conj(a[j*lda+i])
  2924  				}
  2925  			}
  2926  		} else {
  2927  			jx := kx + (n-1)*incX
  2928  			for j := n - 1; j >= 0; j-- {
  2929  				if diag == blas.NonUnit {
  2930  					x[jx] /= cmplx.Conj(a[j*lda+j])
  2931  				}
  2932  				xj := x[jx]
  2933  				ix := kx
  2934  				for i := 0; i < j; i++ {
  2935  					x[ix] -= xj * cmplx.Conj(a[j*lda+i])
  2936  					ix += incX
  2937  				}
  2938  				jx -= incX
  2939  			}
  2940  		}
  2941  	}
  2942  }