Documentation ¶
Overview ¶
The mat package provides an implementation of matrices and vectors that is completely immutable and focused on exposing a nice API rather than going for high performance.
Index ¶
- func Equals(a, b Matrix) bool
- func Sum(m Matrix) float64
- type Matrix
- func BlasProduct(a, b Matrix) Matrix
- func ConcatenateCols(ms ...Matrix) Matrix
- func ConcatenateRows(ms ...Matrix) Matrix
- func Dot(a, b Matrix) Matrix
- func FromFunc(rows, cols int, f func(i, j int) float64) Matrix
- func FromSlice(rows, cols int, data []float64) Matrix
- func Map(f func(float64) float64, m Matrix) Matrix
- func Minus(a, b Matrix) Matrix
- func New(rows, cols int) Matrix
- func ParallelProduct(a, b Matrix) Matrix
- func Plus(a, b Matrix) Matrix
- func Product(a, b Matrix) Matrix
- func (m Matrix) AddScalar(x float64) Matrix
- func (m Matrix) Apply(f func(i, j int) float64)
- func (m Matrix) At(i, j int) float64
- func (m Matrix) Clone() Matrix
- func (m Matrix) Cols() int
- func (m Matrix) FilterRows(f func(i int) bool) Matrix
- func (m Matrix) Reduce(zero float64, f func(x, cum float64) float64) float64
- func (m Matrix) Rows() int
- func (m Matrix) Scale(x float64) Matrix
- func (m Matrix) Set(i, j int, x float64) Matrix
- func (m Matrix) SliceCols(from, to int) Matrix
- func (m Matrix) SliceRows(from, to int) Matrix
- func (m Matrix) String() string
- func (m Matrix) Sum() float64
- func (m Matrix) T() Matrix
- func (m Matrix) ToSlice() []float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Matrix ¶
type Matrix struct {
// contains filtered or unexported fields
}
Matrix is optimized for dense matrices.
func BlasProduct ¶
BlasProduct returns the product of two matrices performed with blas.
func ConcatenateCols ¶
ConcatenateCols returns a matrix that contains the values of all of the given matrices side by side. All of the matrices need to have the same number of rows. The resulting matrix has as many columns as all of the given matrices combined, and as many rows as each one of them.
func ConcatenateRows ¶
ConcatenateRows returns a matrix that contains the values of all of the given matrices stacked verticaly. All of the matrices need to have the same number of columns. The resulting matrix has as many rows as all of the given matrices combined, and as many cols as each one of them.
func Map ¶
Map returns a new Matrix where each value is the result of calling f with the value of that position in the original matrix.
func ParallelProduct ¶
ParallelProduct returns the product of two matrices performed in parallel.
func (Matrix) At ¶
At returns the value of the cell at the given position. It panics if the position is not valid.
func (Matrix) FilterRows ¶
FilterRows returns a matrix where only the rows with an index for which f returns true have been kept.
func (Matrix) Reduce ¶
Reduce provides a functional way of reducing a function over the whole matrix. For instance: sum can be implemented as:
m.Reduce(0, func(x, cum float64) float64 {return x+cum})
func (Matrix) Set ¶
Set sets the value of the cell at the given position. It panics if the position is not valid.
func (Matrix) SliceCols ¶
SliceCols returns a new matrix that contains only the columns in between from and to, without including to. Similar to slice[from:to].
func (Matrix) SliceRows ¶
SliceRows returns a new matrix that contains only the rows in between from and to, without including to. Similar to slice[from:to].