gonum.org/v1/gonum@v0.14.0/blas/cblas128/cblas128_test.go (about) 1 // Copyright ©2019 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 package cblas128 6 7 import ( 8 "fmt" 9 "testing" 10 11 "gonum.org/v1/gonum/blas" 12 "gonum.org/v1/gonum/blas/blas64" 13 "gonum.org/v1/gonum/blas/testblas" 14 ) 15 16 var impl = c128{} 17 18 func TestDzasum(t *testing.T) { testblas.DzasumTest(t, impl) } 19 func TestDznrm2(t *testing.T) { testblas.Dznrm2Test(t, impl) } 20 func TestIzamax(t *testing.T) { testblas.IzamaxTest(t, impl) } 21 func TestZaxpy(t *testing.T) { testblas.ZaxpyTest(t, impl) } 22 func TestZcopy(t *testing.T) { testblas.ZcopyTest(t, impl) } 23 func TestZdotc(t *testing.T) { testblas.ZdotcTest(t, impl) } 24 func TestZdotu(t *testing.T) { testblas.ZdotuTest(t, impl) } 25 func TestZdscal(t *testing.T) { testblas.ZdscalTest(t, impl) } 26 func TestZscal(t *testing.T) { testblas.ZscalTest(t, impl) } 27 func TestZswap(t *testing.T) { testblas.ZswapTest(t, impl) } 28 func TestZgbmv(t *testing.T) { testblas.ZgbmvTest(t, impl) } 29 func TestZgemv(t *testing.T) { testblas.ZgemvTest(t, impl) } 30 func TestZgerc(t *testing.T) { testblas.ZgercTest(t, impl) } 31 func TestZgeru(t *testing.T) { testblas.ZgeruTest(t, impl) } 32 func TestZhbmv(t *testing.T) { testblas.ZhbmvTest(t, impl) } 33 func TestZhemv(t *testing.T) { testblas.ZhemvTest(t, impl) } 34 func TestZher(t *testing.T) { testblas.ZherTest(t, impl) } 35 func TestZher2(t *testing.T) { testblas.Zher2Test(t, impl) } 36 func TestZhpmv(t *testing.T) { testblas.ZhpmvTest(t, impl) } 37 func TestZhpr(t *testing.T) { testblas.ZhprTest(t, impl) } 38 func TestZhpr2(t *testing.T) { testblas.Zhpr2Test(t, impl) } 39 func TestZtbmv(t *testing.T) { testblas.ZtbmvTest(t, impl) } 40 func TestZtbsv(t *testing.T) { testblas.ZtbsvTest(t, impl) } 41 func TestZtpmv(t *testing.T) { testblas.ZtpmvTest(t, impl) } 42 func TestZtpsv(t *testing.T) { testblas.ZtpsvTest(t, impl) } 43 func TestZtrmv(t *testing.T) { testblas.ZtrmvTest(t, impl) } 44 func TestZtrsv(t *testing.T) { testblas.ZtrsvTest(t, impl) } 45 func TestZgemm(t *testing.T) { testblas.ZgemmTest(t, impl) } 46 func TestZhemm(t *testing.T) { testblas.ZhemmTest(t, impl) } 47 func TestZherk(t *testing.T) { testblas.ZherkTest(t, impl) } 48 func TestZher2k(t *testing.T) { testblas.Zher2kTest(t, impl) } 49 func TestZsymm(t *testing.T) { testblas.ZsymmTest(t, impl) } 50 func TestZsyrk(t *testing.T) { testblas.ZsyrkTest(t, impl) } 51 func TestZsyr2k(t *testing.T) { testblas.Zsyr2kTest(t, impl) } 52 func TestZtrmm(t *testing.T) { testblas.ZtrmmTest(t, impl) } 53 func TestZtrsm(t *testing.T) { testblas.ZtrsmTest(t, impl) } 54 55 type c128 struct{} 56 57 var _ blas.Complex128 = c128{} 58 59 func (c128) Zdotu(n int, x []complex128, incX int, y []complex128, incY int) complex128 { 60 return Dotu(Vector{N: n, Inc: incX, Data: x}, Vector{N: n, Inc: incY, Data: y}) 61 } 62 func (c128) Zdotc(n int, x []complex128, incX int, y []complex128, incY int) complex128 { 63 return Dotc(Vector{N: n, Inc: incX, Data: x}, Vector{N: n, Inc: incY, Data: y}) 64 } 65 func (c128) Dznrm2(n int, x []complex128, incX int) float64 { 66 if incX < 0 { 67 return 0 68 } 69 return Nrm2(Vector{N: n, Inc: incX, Data: x}) 70 } 71 func (c128) Dnrm2(n int, x []float64, incX int) float64 { 72 return blas64.Nrm2(blas64.Vector{N: n, Inc: incX, Data: x}) 73 } 74 func (c128) Dzasum(n int, x []complex128, incX int) float64 { 75 if incX < 0 { 76 return 0 77 } 78 return Asum(Vector{N: n, Inc: incX, Data: x}) 79 } 80 func (c128) Izamax(n int, x []complex128, incX int) int { 81 if incX < 0 { 82 return -1 83 } 84 return Iamax(Vector{N: n, Inc: incX, Data: x}) 85 } 86 func (c128) Zswap(n int, x []complex128, incX int, y []complex128, incY int) { 87 Swap(Vector{N: n, Inc: incX, Data: x}, Vector{N: n, Inc: incY, Data: y}) 88 } 89 func (c128) Zcopy(n int, x []complex128, incX int, y []complex128, incY int) { 90 Copy(Vector{N: n, Inc: incX, Data: x}, Vector{N: n, Inc: incY, Data: y}) 91 } 92 func (c128) Zaxpy(n int, alpha complex128, x []complex128, incX int, y []complex128, incY int) { 93 Axpy(alpha, Vector{N: n, Inc: incX, Data: x}, Vector{N: n, Inc: incY, Data: y}) 94 } 95 func (c128) Zscal(n int, alpha complex128, x []complex128, incX int) { 96 if incX < 0 { 97 return 98 } 99 Scal(alpha, Vector{N: n, Inc: incX, Data: x}) 100 } 101 func (c128) Zdscal(n int, alpha float64, x []complex128, incX int) { 102 if incX < 0 { 103 return 104 } 105 Dscal(alpha, Vector{N: n, Inc: incX, Data: x}) 106 } 107 func (c128) Zgemv(tA blas.Transpose, m, n int, alpha complex128, a []complex128, lda int, x []complex128, incX int, beta complex128, y []complex128, incY int) { 108 lenX := m 109 lenY := n 110 if tA == blas.NoTrans { 111 lenX = n 112 lenY = m 113 } 114 Gemv(tA, alpha, 115 General{Rows: m, Cols: n, Data: a, Stride: lda}, 116 Vector{N: lenX, Inc: incX, Data: x}, 117 beta, 118 Vector{N: lenY, Inc: incY, Data: y}) 119 } 120 func (c128) Zgbmv(tA blas.Transpose, m, n, kL, kU int, alpha complex128, a []complex128, lda int, x []complex128, incX int, beta complex128, y []complex128, incY int) { 121 lenX := m 122 lenY := n 123 if tA == blas.NoTrans { 124 lenX = n 125 lenY = m 126 } 127 Gbmv(tA, alpha, 128 Band{Rows: m, Cols: n, KL: kL, KU: kU, Data: a, Stride: lda}, 129 Vector{N: lenX, Inc: incX, Data: x}, 130 beta, 131 Vector{N: lenY, Inc: incY, Data: y}) 132 } 133 func (c128) Ztrmv(ul blas.Uplo, tA blas.Transpose, d blas.Diag, n int, a []complex128, lda int, x []complex128, incX int) { 134 Trmv(tA, 135 Triangular{Uplo: ul, Diag: d, N: n, Data: a, Stride: lda}, 136 Vector{N: n, Inc: incX, Data: x}) 137 } 138 func (c128) Ztbmv(ul blas.Uplo, tA blas.Transpose, d blas.Diag, n, k int, a []complex128, lda int, x []complex128, incX int) { 139 Tbmv(tA, 140 TriangularBand{Uplo: ul, Diag: d, N: n, K: k, Data: a, Stride: lda}, 141 Vector{N: n, Inc: incX, Data: x}) 142 } 143 func (c128) Ztpmv(ul blas.Uplo, tA blas.Transpose, d blas.Diag, n int, ap []complex128, x []complex128, incX int) { 144 Tpmv(tA, 145 TriangularPacked{Uplo: ul, Diag: d, N: n, Data: ap}, 146 Vector{N: n, Inc: incX, Data: x}) 147 } 148 func (c128) Ztrsv(ul blas.Uplo, tA blas.Transpose, d blas.Diag, n int, a []complex128, lda int, x []complex128, incX int) { 149 Trsv(tA, 150 Triangular{Uplo: ul, Diag: d, N: n, Data: a, Stride: lda}, 151 Vector{N: n, Inc: incX, Data: x}) 152 } 153 func (c128) Ztbsv(ul blas.Uplo, tA blas.Transpose, d blas.Diag, n, k int, a []complex128, lda int, x []complex128, incX int) { 154 Tbsv(tA, 155 TriangularBand{Uplo: ul, Diag: d, N: n, K: k, Data: a, Stride: lda}, 156 Vector{N: n, Inc: incX, Data: x}) 157 } 158 func (c128) Ztpsv(ul blas.Uplo, tA blas.Transpose, d blas.Diag, n int, ap []complex128, x []complex128, incX int) { 159 Tpsv(tA, 160 TriangularPacked{Uplo: ul, Diag: d, N: n, Data: ap}, 161 Vector{N: n, Inc: incX, Data: x}) 162 } 163 func (c128) Zhemv(ul blas.Uplo, n int, alpha complex128, a []complex128, lda int, x []complex128, incX int, beta complex128, y []complex128, incY int) { 164 Hemv(alpha, 165 Hermitian{Uplo: ul, N: n, Data: a, Stride: lda}, 166 Vector{N: n, Inc: incX, Data: x}, 167 beta, 168 Vector{N: n, Inc: incY, Data: y}) 169 } 170 func (c128) Zhbmv(ul blas.Uplo, n, k int, alpha complex128, a []complex128, lda int, x []complex128, incX int, beta complex128, y []complex128, incY int) { 171 Hbmv(alpha, 172 HermitianBand{Uplo: ul, N: n, K: k, Data: a, Stride: lda}, 173 Vector{N: n, Inc: incX, Data: x}, 174 beta, 175 Vector{N: n, Inc: incY, Data: y}) 176 } 177 func (c128) Zhpmv(ul blas.Uplo, n int, alpha complex128, ap []complex128, x []complex128, incX int, beta complex128, y []complex128, incY int) { 178 Hpmv(alpha, 179 HermitianPacked{Uplo: ul, N: n, Data: ap}, 180 Vector{N: n, Inc: incX, Data: x}, 181 beta, 182 Vector{N: n, Inc: incY, Data: y}) 183 } 184 func (c128) Zgeru(m, n int, alpha complex128, x []complex128, incX int, y []complex128, incY int, a []complex128, lda int) { 185 Geru(alpha, 186 Vector{N: n, Inc: incX, Data: x}, 187 Vector{N: n, Inc: incY, Data: y}, 188 General{Rows: m, Cols: n, Data: a, Stride: lda}) 189 } 190 func (c128) Zgerc(m, n int, alpha complex128, x []complex128, incX int, y []complex128, incY int, a []complex128, lda int) { 191 Gerc(alpha, 192 Vector{N: n, Inc: incX, Data: x}, 193 Vector{N: n, Inc: incY, Data: y}, 194 General{Rows: m, Cols: n, Data: a, Stride: lda}) 195 } 196 func (c128) Zher(ul blas.Uplo, n int, alpha float64, x []complex128, incX int, a []complex128, lda int) { 197 Her(alpha, 198 Vector{N: n, Inc: incX, Data: x}, 199 Hermitian{Uplo: ul, N: n, Data: a, Stride: lda}) 200 } 201 func (c128) Zhpr(ul blas.Uplo, n int, alpha float64, x []complex128, incX int, ap []complex128) { 202 Hpr(alpha, 203 Vector{N: n, Inc: incX, Data: x}, 204 HermitianPacked{Uplo: ul, N: n, Data: ap}) 205 } 206 func (c128) Zher2(ul blas.Uplo, n int, alpha complex128, x []complex128, incX int, y []complex128, incY int, a []complex128, lda int) { 207 Her2(alpha, 208 Vector{N: n, Inc: incX, Data: x}, 209 Vector{N: n, Inc: incY, Data: y}, 210 Hermitian{Uplo: ul, N: n, Data: a, Stride: lda}) 211 } 212 func (c128) Zhpr2(ul blas.Uplo, n int, alpha complex128, x []complex128, incX int, y []complex128, incY int, a []complex128) { 213 Hpr2(alpha, 214 Vector{N: n, Inc: incX, Data: x}, 215 Vector{N: n, Inc: incY, Data: y}, 216 HermitianPacked{Uplo: ul, N: n, Data: a}) 217 } 218 func (c128) Zgemm(tA, tB blas.Transpose, m, n, k int, alpha complex128, a []complex128, lda int, b []complex128, ldb int, beta complex128, c []complex128, ldc int) { 219 am, an := m, k 220 if tA != blas.NoTrans { 221 am, an = an, am 222 } 223 bm, bn := k, n 224 if tB != blas.NoTrans { 225 bm, bn = bn, bm 226 } 227 Gemm(tA, tB, alpha, 228 General{Rows: am, Cols: an, Data: a, Stride: lda}, 229 General{Rows: bm, Cols: bn, Data: b, Stride: ldb}, 230 beta, 231 General{Rows: m, Cols: n, Data: c, Stride: ldc}) 232 } 233 func (c128) Zsymm(s blas.Side, ul blas.Uplo, m, n int, alpha complex128, a []complex128, lda int, b []complex128, ldb int, beta complex128, c []complex128, ldc int) { 234 var an int 235 switch s { 236 case blas.Left: 237 an = m 238 case blas.Right: 239 an = n 240 default: 241 panic(fmt.Sprintf("blas64: bad test: invalid side: %q", s)) 242 } 243 Symm(s, alpha, 244 Symmetric{Uplo: ul, N: an, Data: a, Stride: lda}, 245 General{Rows: m, Cols: n, Data: b, Stride: ldb}, 246 beta, 247 General{Rows: m, Cols: n, Data: c, Stride: ldc}) 248 } 249 func (c128) Zsyrk(ul blas.Uplo, t blas.Transpose, n, k int, alpha complex128, a []complex128, lda int, beta complex128, c []complex128, ldc int) { 250 am, an := n, k 251 if t != blas.NoTrans { 252 am, an = an, am 253 } 254 Syrk(t, alpha, 255 General{Rows: am, Cols: an, Data: a, Stride: lda}, 256 beta, 257 Symmetric{Uplo: ul, N: n, Data: c, Stride: ldc}) 258 } 259 func (c128) Zsyr2k(ul blas.Uplo, t blas.Transpose, n, k int, alpha complex128, a []complex128, lda int, b []complex128, ldb int, beta complex128, c []complex128, ldc int) { 260 am, an := n, k 261 if t != blas.NoTrans { 262 am, an = an, am 263 } 264 Syr2k(t, alpha, 265 General{Rows: am, Cols: an, Data: a, Stride: lda}, 266 General{Rows: am, Cols: an, Data: b, Stride: ldb}, 267 beta, 268 Symmetric{Uplo: ul, N: n, Data: c, Stride: ldc}) 269 } 270 func (c128) Zhemm(s blas.Side, ul blas.Uplo, m, n int, alpha complex128, a []complex128, lda int, b []complex128, ldb int, beta complex128, c []complex128, ldc int) { 271 var an int 272 switch s { 273 case blas.Left: 274 an = m 275 case blas.Right: 276 an = n 277 default: 278 panic(fmt.Sprintf("blas64: bad test: invalid side: %q", s)) 279 } 280 Hemm(s, alpha, 281 Hermitian{Uplo: ul, N: an, Data: a, Stride: lda}, 282 General{Rows: m, Cols: n, Data: b, Stride: ldb}, 283 beta, 284 General{Rows: m, Cols: n, Data: c, Stride: ldc}) 285 } 286 func (c128) Zherk(ul blas.Uplo, t blas.Transpose, n, k int, alpha float64, a []complex128, lda int, beta float64, c []complex128, ldc int) { 287 am, an := n, k 288 if t != blas.NoTrans { 289 am, an = an, am 290 } 291 Herk(t, alpha, 292 General{Rows: am, Cols: an, Data: a, Stride: lda}, 293 beta, 294 Hermitian{Uplo: ul, N: n, Data: c, Stride: ldc}) 295 } 296 func (c128) Zher2k(ul blas.Uplo, t blas.Transpose, n, k int, alpha complex128, a []complex128, lda int, b []complex128, ldb int, beta float64, c []complex128, ldc int) { 297 am, an := n, k 298 if t != blas.NoTrans { 299 am, an = an, am 300 } 301 Her2k(t, alpha, 302 General{Rows: am, Cols: an, Data: a, Stride: lda}, 303 General{Rows: am, Cols: an, Data: b, Stride: ldb}, 304 beta, 305 Hermitian{Uplo: ul, N: n, Data: c, Stride: ldc}) 306 } 307 func (c128) Ztrmm(s blas.Side, ul blas.Uplo, tA blas.Transpose, d blas.Diag, m, n int, alpha complex128, a []complex128, lda int, b []complex128, ldb int) { 308 var k int 309 switch s { 310 case blas.Left: 311 k = m 312 case blas.Right: 313 k = n 314 default: 315 panic(fmt.Sprintf("blas64: bad test: invalid side: %q", s)) 316 } 317 Trmm(s, tA, alpha, 318 Triangular{Uplo: ul, Diag: d, N: k, Data: a, Stride: lda}, 319 General{Rows: m, Cols: n, Data: b, Stride: ldb}) 320 } 321 func (c128) Ztrsm(s blas.Side, ul blas.Uplo, tA blas.Transpose, d blas.Diag, m, n int, alpha complex128, a []complex128, lda int, b []complex128, ldb int) { 322 var k int 323 switch s { 324 case blas.Left: 325 k = m 326 case blas.Right: 327 k = n 328 default: 329 panic(fmt.Sprintf("blas64: bad test: invalid side: %q", s)) 330 } 331 Trsm(s, tA, alpha, 332 Triangular{Uplo: ul, Diag: d, N: k, Data: a, Stride: lda}, 333 General{Rows: m, Cols: n, Data: b, Stride: ldb}) 334 }