| // Copyright ©2017 The gonum Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| |
| package gonum |
| |
| import ( |
| "math/cmplx" |
| |
| "gonum.org/v1/gonum/internal/asm/c128" |
| ) |
| |
| // Zgerc performs the rank-one operation |
| // A += alpha * x * y^H |
| // where A is an m×n dense matrix, alpha is a scalar, x is an m element vector, |
| // and y is an n element vector. |
| func (Implementation) Zgerc(m, n int, alpha complex128, x []complex128, incX int, y []complex128, incY int, a []complex128, lda int) { |
| checkZMatrix('A', m, n, a, lda) |
| checkZVector('x', m, x, incX) |
| checkZVector('y', n, y, incY) |
| |
| if m == 0 || n == 0 || alpha == 0 { |
| return |
| } |
| |
| var kx, jy int |
| if incX < 0 { |
| kx = (1 - m) * incX |
| } |
| if incY < 0 { |
| jy = (1 - n) * incY |
| } |
| for j := 0; j < n; j++ { |
| if y[jy] != 0 { |
| tmp := alpha * cmplx.Conj(y[jy]) |
| c128.AxpyInc(tmp, x, a[j:], uintptr(m), uintptr(incX), uintptr(lda), uintptr(kx), 0) |
| } |
| jy += incY |
| } |
| } |
| |
| // Zgeru performs the rank-one operation |
| // A += alpha * x * y^T |
| // where A is an m×n dense matrix, alpha is a scalar, x is an m element vector, |
| // and y is an n element vector. |
| func (Implementation) Zgeru(m, n int, alpha complex128, x []complex128, incX int, y []complex128, incY int, a []complex128, lda int) { |
| checkZMatrix('A', m, n, a, lda) |
| checkZVector('x', m, x, incX) |
| checkZVector('y', n, y, incY) |
| |
| if m == 0 || n == 0 || alpha == 0 { |
| return |
| } |
| |
| var kx int |
| if incX < 0 { |
| kx = (1 - m) * incX |
| } |
| if incY == 1 { |
| for i := 0; i < m; i++ { |
| if x[kx] != 0 { |
| tmp := alpha * x[kx] |
| c128.AxpyUnitary(tmp, y[:n], a[i*lda:i*lda+n]) |
| } |
| kx += incX |
| } |
| return |
| } |
| var jy int |
| if incY < 0 { |
| jy = (1 - n) * incY |
| } |
| for i := 0; i < m; i++ { |
| if x[kx] != 0 { |
| tmp := alpha * x[kx] |
| c128.AxpyInc(tmp, y, a[i*lda:i*lda+n], uintptr(n), uintptr(incY), 1, uintptr(jy), 0) |
| } |
| kx += incX |
| } |
| } |