Documentation ¶
Index ¶
- func ReadColumn(file string, column int) ([]float64, error)
- func ReadDiag(file string) ([]float64, error)
- func ReadRow(file string, row int) ([]float64, error)
- func WriteMatrix(m *Matrix, file string) error
- type Matrix
- func (m *Matrix) Add(row, col int, value float64)
- func (m *Matrix) Col(idx int) []float64
- func (m *Matrix) Copy() *Matrix
- func (m *Matrix) Get(row, col int) float64
- func (m *Matrix) GetPtr(row, col int) *float64
- func (m *Matrix) Row(idx int) []float64
- func (m *Matrix) ScaleColumns(s []float64) *Matrix
- func (m *Matrix) ScaledColumnSums(s []float64) []float64
- func (m *Matrix) Set(row, col int, value float64)
- func (m *Matrix) Shape() (int, int)
- func (m *Matrix) Slice2d() [][]float64
- func (m *Matrix) Subtract(b *Matrix) (*Matrix, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadColumn ¶
ReadColumn reads the given (zero-based) column from the matrix in the given file. It first reads the size of the matrix, seeks than to the position of the column in the file, and finally reads it. As matlib matrices are stored in column-major order this should be efficient.
func ReadRow ¶
ReadRow reads the given row from the matrix in the given file. As matlib matrices are stored in column-major order this will make n file seeks for a matrix with n columns.
func WriteMatrix ¶
WriteMatrix writes the matrix to the given file.
Types ¶
type Matrix ¶
Matrix is a dense matrix structure that holds the data in column-major order in a linear array. Because of this lay
func MakeMatrix ¶
MakeMatrix is a convenience function for creating a matrix from a 2 dimensional float slice. It is mainly used for testing purposes.
func ReadMatrix ¶
ReadMatrix reads a full matrix from the given file.
func (*Matrix) ScaleColumns ¶
ScaleColumns scales each column i of the matrix with the factor s[i] of the given vector.
func (*Matrix) ScaledColumnSums ¶
ScaledColumnSums calculates the sum of each column i which are saled by the factor s[i] of the given vector respectively. Thus the returned result has a length wich is equal to the number of rows of the matrix.
func (*Matrix) Shape ¶
Shape returns a tuple with the number of rows and columns in the matrix, e.g.:
rows, cols := M.Shape()