Skip to content

Commit 04b5e68

Browse files
authored
Merge pull request #29 from vladimir-ch/use-gonum-scalar
Use Gonum's scalar.EqualWithinAbs
2 parents 34b61a8 + 6a4036e commit 04b5e68

File tree

6 files changed

+8
-14
lines changed

6 files changed

+8
-14
lines changed

blas/matrix.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package blas
22

33
import (
4-
"gonum.org/v1/gonum/floats"
4+
"gonum.org/v1/gonum/floats/scalar"
55
"gonum.org/v1/gonum/mat"
66
)
77

@@ -80,7 +80,7 @@ func (m *SparseMatrix) insert(i int, j int, v float64, insertionPoint int) {
8080
func (m *SparseMatrix) nnzWithin(epsilon float64) int {
8181
count := 0
8282
for _, v := range m.Data {
83-
if !floats.EqualWithinAbs(v, 0, epsilon) {
83+
if !scalar.EqualWithinAbs(v, 0, epsilon) {
8484
count++
8585
}
8686
}
@@ -102,7 +102,7 @@ func (m *SparseMatrix) Cull(epsilon float64) *SparseMatrix {
102102
for minor := startIdx; minor < endIdx; minor++ {
103103
col := m.Ind[minor]
104104
v := m.Data[minor]
105-
if !floats.EqualWithinAbs(v, 0, epsilon) {
105+
if !scalar.EqualWithinAbs(v, 0, epsilon) {
106106
newInd[curPos] = col
107107
newData[curPos] = v
108108
curPos++

cholesky.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package sparse
33
import (
44
"math"
55

6-
"github.com/gonum/floats"
6+
"gonum.org/v1/gonum/floats"
77
"gonum.org/v1/gonum/mat"
88
)
99

compressed_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package sparse
33
import (
44
"testing"
55

6-
"gonum.org/v1/gonum/floats"
6+
"gonum.org/v1/gonum/floats/scalar"
77
"gonum.org/v1/gonum/mat"
88
)
99

@@ -458,7 +458,7 @@ func TestCSTrace(t *testing.T) {
458458
for i := 0; i < test.s; i++ {
459459
checkTr += m.At(i, i)
460460
}
461-
if !floats.EqualWithinAbs(tr, checkTr, 1e-13) {
461+
if !scalar.EqualWithinAbs(tr, checkTr, 1e-13) {
462462
t.Logf("trace mismatch: %f vs %f", tr, checkTr)
463463
t.Fail()
464464
}

diagonal_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package sparse
33
import (
44
"testing"
55

6-
"gonum.org/v1/gonum/floats"
6+
"gonum.org/v1/gonum/floats/scalar"
77
"gonum.org/v1/gonum/mat"
88
)
99

@@ -148,7 +148,7 @@ func TestDIATrace(t *testing.T) {
148148
for i := 0; i < test.s; i++ {
149149
checkTr += dia.At(i, i)
150150
}
151-
if !floats.EqualWithinAbs(tr, checkTr, 1e-13) {
151+
if !scalar.EqualWithinAbs(tr, checkTr, 1e-13) {
152152
t.Logf("trace mismatch: %f vs %f", tr, checkTr)
153153
t.Fail()
154154
}

go.mod

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ module github.com/james-bowman/sparse
33
go 1.14
44

55
require (
6-
github.com/gonum/floats v0.0.0-20181209220543-c233463c7e82
7-
github.com/gonum/internal v0.0.0-20181124074243-f884aa714029 // indirect
86
golang.org/x/exp v0.0.0-20210220032938-85be41e4509f
97
gonum.org/v1/gonum v0.8.2
108
)

go.sum

-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3
44
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
55
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
66
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
7-
github.com/gonum/floats v0.0.0-20181209220543-c233463c7e82 h1:EvokxLQsaaQjcWVWSV38221VAK7qc2zhaO17bKys/18=
8-
github.com/gonum/floats v0.0.0-20181209220543-c233463c7e82/go.mod h1:PxC8OnwL11+aosOB5+iEPoV3picfs8tUpkVd0pDo+Kg=
9-
github.com/gonum/internal v0.0.0-20181124074243-f884aa714029 h1:8jtTdc+Nfj9AR+0soOeia9UZSvYBvETVHZrugUowJ7M=
10-
github.com/gonum/internal v0.0.0-20181124074243-f884aa714029/go.mod h1:Pu4dmpkhSyOzRwuXkOgAvijx4o+4YMUJJo9OvPYMkks=
117
github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
128
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
139
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=

0 commit comments

Comments
 (0)