This commit is contained in:
Will Charczuk 2017-04-17 12:22:44 -07:00
parent 88499d5576
commit 724d6e3c2a
3 changed files with 84 additions and 3 deletions

View file

@ -72,9 +72,6 @@ func NewFromArrays(a [][]float64) *Matrix {
return m
}
// Vector is just an array of values.
type Vector []float64
// Matrix represents a 2d dense array of floats.
type Matrix struct {
epsilon float64
@ -82,6 +79,17 @@ type Matrix struct {
rows, cols int
}
// Epsilon returns the maximum precision for math operations.
func (m *Matrix) Epsilon() float64 {
return m.epsilon
}
// WithEpsilon sets the epsilon on the matrix and returns a reference to the matrix.
func (m *Matrix) WithEpsilon(epsilon float64) *Matrix {
m.epsilon = epsilon
return m
}
// Arrays returns the matrix as a two dimensional jagged array.
func (m *Matrix) Arrays() [][]float64 {
a := make([][]float64, m.rows, m.cols)