mat: address review comments
MODIFY
mat/index_bound_checks.go
mat/index_bound_checks.go
@@ -197,7 +197,7 @@ func (s *SymBandDense) at(i, j int) float64 {
i, j = j, i
}
pj := j - i
- if pj < 0 || s.mat.K+1 <= pj {
+ if s.mat.K+1 <= pj {
return 0
}
return s.mat.Data[i*s.mat.Stride+pj]
@@ -220,7 +220,7 @@ func (s *SymBandDense) set(i, j int, v float64) {
i, j = j, i
}
pj := j - i
- if pj < 0 || s.mat.K+1 <= pj {
+ if s.mat.K+1 <= pj {
panic(ErrBandSet)
}
s.mat.Data[i*s.mat.Stride+pj] = v

MODIFY
mat/index_no_bound_checks.go
mat/index_no_bound_checks.go
@@ -198,7 +198,7 @@ func (s *SymBandDense) at(i, j int) float64 {
i, j = j, i
}
pj := j - i
- if pj < 0 || s.mat.K+1 <= pj {
+ if s.mat.K+1 <= pj {
return 0
}
return s.mat.Data[i*s.mat.Stride+pj]
@@ -221,7 +221,7 @@ func (s *SymBandDense) set(i, j int, v float64) {
i, j = j, i
}
pj := j - i
- if pj < 0 || s.mat.K+1 <= pj {
+ if s.mat.K+1 <= pj {
panic(ErrBandSet)
}
s.mat.Data[i*s.mat.Stride+pj] = v

MODIFY
mat/symband.go
mat/symband.go
@@ -88,7 +88,8 @@ func NewSymBandDense(n, k int, data []float64) *SymBandDense {
}
// NewDiagonal is a convenience function that returns a diagonal matrix represented by a
-// SymBandDense. The length of data must be n otherwise NewDiagonal will panic.
+// SymBandDense. The length of data must be n or data must be nil, otherwise NewDiagonal
+// will panic.
func NewDiagonal(n int, data []float64) *SymBandDense {
return NewSymBandDense(n, 0, data)
}

mat: address review comments