Documentation ¶
Index ¶
- Variables
- type Func
- type Iterator
- type Matrix
- type MatrixBool
- func (m *MatrixBool) AddRow(row sam.SliceBool) error
- func (m *MatrixBool) AppendColumn(defaultValue bool)
- func (m *MatrixBool) Columns() int
- func (m *MatrixBool) Dimensions() (int, int)
- func (m *MatrixBool) GetColumnData(column int) (data sam.SliceBool, err error)
- func (m *MatrixBool) GetRow(row int) (sam.Slice, error)
- func (m *MatrixBool) GetValue(row, column int) (bool, error)
- func (m *MatrixBool) Iterator() *Iterator
- func (m *MatrixBool) Len() int
- func (m *MatrixBool) RemoveRow(row int) error
- func (m *MatrixBool) Rows() int
- func (m *MatrixBool) SetBackingData(data sam.SliceBool)
- func (m *MatrixBool) ToTensor() tensor.Tensor
- func (m *MatrixBool) Type() string
- func (m *MatrixBool) UpdateValue(value bool, row, column int) error
- type MatrixFloat64
- func (m *MatrixFloat64) AddRow(row []float64) error
- func (m *MatrixFloat64) AppendColumn(defaultValue float64)
- func (m *MatrixFloat64) Columns() int
- func (m *MatrixFloat64) Dimensions() (int, int)
- func (m *MatrixFloat64) GetColumnData(column int) (data sam.SliceFloat64, err error)
- func (m *MatrixFloat64) GetRow(row int) (sam.Slice, error)
- func (m *MatrixFloat64) GetValue(row, column int) (float64, error)
- func (m *MatrixFloat64) Iterator() *Iterator
- func (m *MatrixFloat64) Len() int
- func (m *MatrixFloat64) MaxSum() sam.SliceFloat64
- func (m *MatrixFloat64) MinSum() sam.SliceFloat64
- func (m *MatrixFloat64) Mode() sam.SliceFloat64
- func (m *MatrixFloat64) NonZeroRows() (*MatrixFloat64, error)
- func (m *MatrixFloat64) RemoveRow(row int) error
- func (m *MatrixFloat64) Rows() int
- func (m *MatrixFloat64) Sample(amount int) *MatrixFloat64
- func (m *MatrixFloat64) SetBackingData(data sam.SliceFloat64)
- func (m *MatrixFloat64) ToGonum() mat.Matrix
- func (m *MatrixFloat64) ToTensor() tensor.Tensor
- func (m *MatrixFloat64) Type() string
- func (m *MatrixFloat64) UpdateValue(value float64, row, column int) error
- func (m *MatrixFloat64) Values(i int) []float64
- type Sparse
- func (s *Sparse) Columns() int
- func (s *Sparse) Get(i, j int) float64
- func (s *Sparse) GetColumn(i int) rowValues
- func (s *Sparse) GetRow(i int) (columnValues, error)
- func (s *Sparse) Increment(i, j int)
- func (s *Sparse) Rows() int
- func (s *Sparse) Set(i, j int, value float64)
- func (s *Sparse) Type() string
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Func ¶
type Func func(interface{}) interface{}
Func is the basic function type for modifying the values of a matrix.
type Iterator ¶
type Iterator struct { Matrix // contains filtered or unexported fields }
Iterator is an object that can be used to traverse the rows of a matrix in order exactly once.
func (*Iterator) ApplyToColumns ¶
ApplyToColumns can be used to apply a function to the values of one or more columns in the matrix.
func (*Iterator) ApplyToMatrix ¶
ApplyToMatrix will apply the supplied function to all values in the matrix. This should only be called after the Iterator has been created and before the Next() method has been called
func (*Iterator) Next ¶
Next will set the iterator to return the next row. It returns false if the row is larger than the number of rows in the matrix.
type MatrixBool ¶
type MatrixBool struct {
// contains filtered or unexported fields
}
MatrixBool is backed by a single array.
func NewMatrixBool ¶
func NewMatrixBool(columns int) *MatrixBool
NewMatrixBool creates a Matrix with the specified column count.
func (*MatrixBool) AddRow ¶
func (m *MatrixBool) AddRow(row sam.SliceBool) error
AddRow will append the boolean array to the matrix as a new row. If the size of the row does not match the number of columns in the matrix then an ErrRowSize will be returned.
func (*MatrixBool) AppendColumn ¶
func (m *MatrixBool) AppendColumn(defaultValue bool)
AppendColumn will add a column to the matrix and place the specified default value into each row's column value.
func (*MatrixBool) Columns ¶
func (m *MatrixBool) Columns() int
Columns will return the number of columns found in the matrix.
func (*MatrixBool) Dimensions ¶
func (m *MatrixBool) Dimensions() (int, int)
Dimensions returns the number of rows and columns in the matrix: (rows, columns).
func (*MatrixBool) GetColumnData ¶
func (m *MatrixBool) GetColumnData(column int) (data sam.SliceBool, err error)
GetColumnData will return a float64 array that contains all the data points of the specified column. If the specified column is out of bounds then an ErrColumnIndex will be returned.
func (*MatrixBool) GetValue ¶
func (m *MatrixBool) GetValue(row, column int) (bool, error)
GetValue will return the boolean value found at the row and column arguments provided. It will return an error if something is invalid about either the row or column argument.
func (*MatrixBool) Iterator ¶
func (m *MatrixBool) Iterator() *Iterator
Iterator will return an object that allows row iteration of the matrix.
func (*MatrixBool) Len ¶
func (m *MatrixBool) Len() int
Len is a standard method that satisfies many common interfaces.
func (*MatrixBool) RemoveRow ¶
func (m *MatrixBool) RemoveRow(row int) error
RemoveRow will delete the row from the matrix.
func (*MatrixBool) Rows ¶
func (m *MatrixBool) Rows() int
Rows will return the number of rows found in the matrix.
func (*MatrixBool) SetBackingData ¶
func (m *MatrixBool) SetBackingData(data sam.SliceBool)
SetBackingData will replace the matrix backing array with the array provided.
func (*MatrixBool) ToTensor ¶
func (m *MatrixBool) ToTensor() tensor.Tensor
ToTensor will create and return a new Gorgonia Tensor (dense) object from the MatrixBool.
func (*MatrixBool) Type ¶
func (m *MatrixBool) Type() string
Type is the type of values in MatrixFloat64
func (*MatrixBool) UpdateValue ¶
func (m *MatrixBool) UpdateValue(value bool, row, column int) error
UpdateValue will update the value found at the provided row and column arguments. If the row or column are out of bounds for the matrix then the proper error will be returned.
type MatrixFloat64 ¶
type MatrixFloat64 struct {
// contains filtered or unexported fields
}
MatrixFloat64 is backed by a single float64 array.
func NewMatrixFloat64 ¶
func NewMatrixFloat64(columns int) *MatrixFloat64
NewMatrixFloat64 creates a Matrix with the specified column count.
func (*MatrixFloat64) AddRow ¶
func (m *MatrixFloat64) AddRow(row []float64) error
AddRow will append the float64 array to the matrix as a new row. If the size of the row does not match the number of columns in the matrix then an ErrRowSize will be returned.
func (*MatrixFloat64) AppendColumn ¶
func (m *MatrixFloat64) AppendColumn(defaultValue float64)
AppendColumn will add a column to the matrix and place the specified default value into each row's column value.
func (*MatrixFloat64) Columns ¶
func (m *MatrixFloat64) Columns() int
Columns will return the number of columns found in the matrix.
func (*MatrixFloat64) Dimensions ¶
func (m *MatrixFloat64) Dimensions() (int, int)
Dimensions returns the number of rows and columns in the matrix: (rows, columns).
func (*MatrixFloat64) GetColumnData ¶
func (m *MatrixFloat64) GetColumnData(column int) (data sam.SliceFloat64, err error)
GetColumnData will return a float64 array that contains all the data points of the specified column. If the specified column is out of bounds then an ErrColumnIndex will be returned.
func (*MatrixFloat64) GetRow ¶
func (m *MatrixFloat64) GetRow(row int) (sam.Slice, error)
GetRow will retrieve the data at the given row index.
func (*MatrixFloat64) GetValue ¶
func (m *MatrixFloat64) GetValue(row, column int) (float64, error)
GetValue will return the float64 value found at the row and column arguments provided. It will return an error if something is invalid about either the row or column argument.
func (*MatrixFloat64) Iterator ¶
func (m *MatrixFloat64) Iterator() *Iterator
Iterator will return an object that allows row iteration of the matrix.
func (*MatrixFloat64) Len ¶
func (m *MatrixFloat64) Len() int
Len is a standard method that satisfies many common interfaces.
func (*MatrixFloat64) MaxSum ¶
func (m *MatrixFloat64) MaxSum() sam.SliceFloat64
MaxSum will return the row with the greatest sum of its components.
func (*MatrixFloat64) MinSum ¶
func (m *MatrixFloat64) MinSum() sam.SliceFloat64
MinSum will return the row with the smallest sum of its components.
func (*MatrixFloat64) Mode ¶
func (m *MatrixFloat64) Mode() sam.SliceFloat64
Mode will return the "mode" of each column as a "vector" or "row".
func (*MatrixFloat64) NonZeroRows ¶
func (m *MatrixFloat64) NonZeroRows() (*MatrixFloat64, error)
NonZeroRows will return a new matrix that contains only the non-zero rows of the original matrix.
func (*MatrixFloat64) RemoveRow ¶
func (m *MatrixFloat64) RemoveRow(row int) error
RemoveRow will delete the row from the matrix.
func (*MatrixFloat64) Rows ¶
func (m *MatrixFloat64) Rows() int
Rows will return the number of rows found in the matrix.
func (*MatrixFloat64) Sample ¶
func (m *MatrixFloat64) Sample(amount int) *MatrixFloat64
Sample will grab the number of rows provided as an argument randomly. The results are returend as a new *MatrixFloat64. If the number of rows is less than zero, then zero rows will be returned. If the number of rows is equal to or greater than the number of rows already in the matrix, then a pointer to the original matrix will beb returned.
func (*MatrixFloat64) SetBackingData ¶
func (m *MatrixFloat64) SetBackingData(data sam.SliceFloat64)
SetBackingData will replace the matrix backing array with the array provided.
func (*MatrixFloat64) ToGonum ¶
func (m *MatrixFloat64) ToGonum() mat.Matrix
ToGonum will create and return a new Gonum Mat64 object from the MatrixFloat64
func (*MatrixFloat64) ToTensor ¶
func (m *MatrixFloat64) ToTensor() tensor.Tensor
ToTensor will create and return a new Gorgonia Tensor (dense) object from the MatrixFloat64.
func (*MatrixFloat64) Type ¶
func (m *MatrixFloat64) Type() string
Type is the type of values in MatrixFloat64
func (*MatrixFloat64) UpdateValue ¶
func (m *MatrixFloat64) UpdateValue(value float64, row, column int) error
UpdateValue will update the value found at the provided row and column arguments. If the row or column are out of bounds for the matrix then the proper error will be returned.
func (*MatrixFloat64) Values ¶
func (m *MatrixFloat64) Values(i int) []float64
Values is a wrapper for GetRow.
type Sparse ¶
Sparse represents a sparse matrix and should only be used when the data in the matrix is expected to be mostly zero (unset).
func (*Sparse) Get ¶
Get will return the value found at the provided coordinates. The value will return `0` if the coordinates do not exist in the matrix.
func (*Sparse) GetColumn ¶
GetColumn will return a set of row value {row, value} pairs for the specified column
func (*Sparse) GetRow ¶
GetRow will return the list of values found at row `i`. It will return a list of {column, value} pairs.
func (*Sparse) Increment ¶
Increment will add +1 to the value found at the coordinates. If the coordinates do not exist then they will be created.