mat: clean up Inner parameter naming
MODIFY
mat/inner.go
mat/inner.go
@@ -16,8 +16,8 @@ import (
// A is symmetric positive definite, though the operation works for any matrix A.
//
// Inner panics if x.Len != m or y.Len != n when A is an m x n matrix.
-func Inner(x Vector, A Matrix, y Vector) float64 {
- m, n := A.Dims()
+func Inner(x Vector, a Matrix, y Vector) float64 {
+ m, n := a.Dims()
if x.Len() != m {
panic(ErrShape)
}
@@ -30,10 +30,10 @@ func Inner(x Vector, A Matrix, y Vector) float64 {
var sum float64
- switch b := A.(type) {
+ switch a := a.(type) {
case RawSymmetricer:
- bmat := b.RawSymmetric()
- if bmat.Uplo != blas.Upper {
+ amat := a.RawSymmetric()
+ if amat.Uplo != blas.Upper {
// Panic as a string not a mat.Error.
panic(badSymTriangle)
}
@@ -53,12 +53,12 @@ func Inner(x Vector, A Matrix, y Vector) float64 {
if xi != 0 {
if ymat.Inc == 1 {
sum += xi * f64.DotUnitary(
- bmat.Data[i*bmat.Stride+i:i*bmat.Stride+n],
+ amat.Data[i*amat.Stride+i:i*amat.Stride+n],
ymat.Data[i:],
)
} else {
sum += xi * f64.DotInc(
- bmat.Data[i*bmat.Stride+i:i*bmat.Stride+n],
+ amat.Data[i*amat.Stride+i:i*amat.Stride+n],
ymat.Data[i*ymat.Inc:], uintptr(n-i),
1, uintptr(ymat.Inc),
0, 0,
@@ -69,12 +69,12 @@ func Inner(x Vector, A Matrix, y Vector) float64 {
if i != n-1 && yi != 0 {
if xmat.Inc == 1 {
sum += yi * f64.DotUnitary(
- bmat.Data[i*bmat.Stride+i+1:i*bmat.Stride+n],
+ amat.Data[i*amat.Stride+i+1:i*amat.Stride+n],
xmat.Data[i+1:],
)
} else {
sum += yi * f64.DotInc(
- bmat.Data[i*bmat.Stride+i+1:i*bmat.Stride+n],
+ amat.Data[i*amat.Stride+i+1:i*amat.Stride+n],
xmat.Data[(i+1)*xmat.Inc:], uintptr(n-i-1),
1, uintptr(xmat.Inc),
0, 0,
@@ -84,7 +84,7 @@ func Inner(x Vector, A Matrix, y Vector) float64 {
}
return sum
case RawMatrixer:
- bmat := b.RawMatrix()
+ amat := a.RawMatrix()
var ymat blas64.Vector
if yrv, ok := y.(RawVectorer); ok {
ymat = yrv.RawVector()
@@ -96,12 +96,12 @@ func Inner(x Vector, A Matrix, y Vector) float64 {
if xi != 0 {
if ymat.Inc == 1 {
sum += xi * f64.DotUnitary(
- bmat.Data[i*bmat.Stride:i*bmat.Stride+n],
+ amat.Data[i*amat.Stride:i*amat.Stride+n],
ymat.Data,
)
} else {
sum += xi * f64.DotInc(
- bmat.Data[i*bmat.Stride:i*bmat.Stride+n],
+ amat.Data[i*amat.Stride:i*amat.Stride+n],
ymat.Data, uintptr(n),
1, uintptr(ymat.Inc),
0, 0,
@@ -114,7 +114,7 @@ func Inner(x Vector, A Matrix, y Vector) float64 {
for i := 0; i < x.Len(); i++ {
xi := x.AtVec(i)
for j := 0; j < y.Len(); j++ {
- sum += xi * A.At(i, j) * y.AtVec(j)
+ sum += xi * a.At(i, j) * y.AtVec(j)
}
}
return sum

mat: clean up Inner parameter naming