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

Commit

Permalink
Vector.Dims() returns 0, 0 if Vector.isZero()
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-ch committed Oct 9, 2015
1 parent a30becb commit bfe594e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mat64/vector.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ func (v *Vector) ViewVec(i, n int) *Vector {
}
}

func (v *Vector) Dims() (r, c int) { return v.n, 1 }
func (v *Vector) Dims() (r, c int) {
if v.isZero() {
return 0, 0
}
return v.n, 1
}

// Len returns the length of the vector.
func (v *Vector) Len() int {
Expand Down Expand Up @@ -324,7 +329,7 @@ func (v *Vector) reuseAs(r int) {

func (v *Vector) isZero() bool {
// It must be the case that v.Dims() returns
// zeros in this case. See comment in Reset().
// zeros in this case.
return v.mat.Inc == 0
}

Expand Down

0 comments on commit bfe594e

Please sign in to comment.