Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

Commit

Permalink
Merge pull request #103 from gonum/fixsyminner
Browse files Browse the repository at this point in the history
Fix symmetric Inner
  • Loading branch information
btracey committed Feb 4, 2015
2 parents d969923 + f2bf7e6 commit 928a18b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mat64/inner.go
Expand Up @@ -35,7 +35,7 @@ func Inner(x []float64, A Matrix, y []float64) float64 {
}
yi := y[i]
if i != n-1 && yi != 0 {
sum += yi * asm.DdotInc(bmat.Data[(i+1)*bmat.Stride+i:], x[i+1:], uintptr(n-i), uintptr(bmat.Stride), 1, 0, 0)
sum += yi * asm.DdotUnitary(bmat.Data[i*bmat.Stride+i+1:i*bmat.Stride+n], x[i+1:])
}
}
case RawMatrixer:
Expand Down
8 changes: 8 additions & 0 deletions mat64/inner_test.go
Expand Up @@ -6,6 +6,7 @@ package mat64

import (
"math"
"math/rand"
"testing"

"github.com/gonum/blas/blas64"
Expand Down Expand Up @@ -94,6 +95,13 @@ func (s *S) TestInnerSym(c *check.C) {
m := NewDense(n, n, data)
ans := Inner(x, m, y)
sym := NewSymDense(n, data)
// scramble the lower half of data to ensure it is not used
for i := 1; i < n; i++ {
for j := 0; j < i; j++ {
data[i*n+j] = rand.Float64()
}
}

if math.Abs(Inner(x, sym, y)-ans) > 1e-14 {
c.Error("inner different symmetric and dense")
}
Expand Down

0 comments on commit 928a18b

Please sign in to comment.