Documentation
¶
Index ¶
- func IsInf(f Float, sign int) bool
- func MarshalBinaryMatrix(m Matrix, w io.Writer) error
- func Print(a Matrix)
- func ReleaseDense(w *Dense)
- func ReleaseMatrix(m Matrix)
- func SameDims(a, b Matrix) bool
- func SameSize(a, b Matrix) bool
- func VectorsOfSameSize(a, b Matrix) bool
- type Coordinate
- type Dense
- func ConcatH(ms ...Matrix) *Dense
- func GetDenseWorkspace(r, c int) *Dense
- func GetEmptyDenseWorkspace(r, c int) *Dense
- func I(size int) *Dense
- func NewDense(rows, cols int, elements []Float) *Dense
- func NewEmptyDense(rows, cols int) *Dense
- func NewEmptyVecDense(size int) *Dense
- func NewInitDense(rows, cols int, val Float) *Dense
- func NewInitVecDense(size int, val Float) *Dense
- func NewScalar(n Float) *Dense
- func NewVecDense(elements []Float) *Dense
- func OneHotVecDense(size int, oneAt int) *Dense
- func (d *Dense) Abs() Matrix
- func (d *Dense) Add(other Matrix) Matrix
- func (d *Dense) AddInPlace(other Matrix) Matrix
- func (d *Dense) AddScalar(n Float) Matrix
- func (d *Dense) AddScalarInPlace(n Float) Matrix
- func (d *Dense) Apply(fn func(i, j int, v Float) Float, a Matrix)
- func (d *Dense) ApplyWithAlpha(fn func(i, j int, v Float, alpha ...Float) Float, a Matrix, alpha ...Float)
- func (d *Dense) At(i int, j int) Float
- func (d *Dense) AtVec(i int) Float
- func (d *Dense) Augment() Matrix
- func (d *Dense) ClipInPlace(min, max Float) Matrix
- func (d *Dense) Clone() Matrix
- func (d *Dense) Columns() int
- func (d *Dense) Copy(other Matrix)
- func (d *Dense) Data() []Float
- func (d *Dense) Dims() (r, c int)
- func (d *Dense) Div(other Matrix) Matrix
- func (d *Dense) DivInPlace(other Matrix) Matrix
- func (d *Dense) DoNonZero(fn func(i, j int, v Float))
- func (d *Dense) DotUnitary(other Matrix) Float
- func (d *Dense) ExtractColumn(i int) Matrix
- func (d *Dense) ExtractRow(i int) Matrix
- func (d *Dense) Format(f fmt.State, c rune)
- func (d *Dense) Inverse() Matrix
- func (d *Dense) IsScalar() bool
- func (d *Dense) IsVector() bool
- func (d *Dense) LU() (l, u, p *Dense)
- func (d *Dense) LastIndex() int
- func (d Dense) MarshalBinary() ([]byte, error)
- func (d *Dense) Max() Float
- func (d *Dense) Maximum(other Matrix) Matrix
- func (d *Dense) Min() Float
- func (d *Dense) Minimum(other Matrix) Matrix
- func (d *Dense) Mul(other Matrix) Matrix
- func (d *Dense) MulT(other Matrix) Matrix
- func (d *Dense) Norm(pow Float) Float
- func (d *Dense) Normalize2() *Dense
- func (d *Dense) OnesLike() Matrix
- func (d *Dense) Pivoting(row int) (Matrix, bool, []int)
- func (d *Dense) Pow(power Float) Matrix
- func (d *Dense) Prod(other Matrix) Matrix
- func (d *Dense) ProdInPlace(other Matrix) Matrix
- func (d *Dense) ProdMatrixScalarInPlace(m Matrix, n Float) Matrix
- func (d *Dense) ProdScalar(n Float) Matrix
- func (d *Dense) ProdScalarInPlace(n Float) Matrix
- func (d *Dense) Range(start, end int) Matrix
- func (d *Dense) Reshape(r, c int) Matrix
- func (d *Dense) Rows() int
- func (d *Dense) Scalar() Float
- func (d *Dense) Set(i int, j int, v Float)
- func (d *Dense) SetData(data []Float)
- func (d *Dense) SetVec(i int, v Float)
- func (d *Dense) Size() int
- func (d *Dense) SplitV(sizes ...int) []Matrix
- func (d *Dense) Sqrt() Matrix
- func (d *Dense) String() string
- func (d *Dense) Sub(other Matrix) Matrix
- func (d *Dense) SubInPlace(other Matrix) Matrix
- func (d *Dense) SubScalar(n Float) Matrix
- func (d *Dense) SubScalarInPlace(n Float) Matrix
- func (d *Dense) Sum() Float
- func (d Dense) SwapInPlace(r1, r2 int)
- func (d *Dense) T() Matrix
- func (d *Dense) UnmarshalBinary(data []byte) error
- func (d *Dense) View(rows, cols int) *Dense
- func (d *Dense) Zeros()
- func (d *Dense) ZerosLike() Matrix
- type Float
- func Abs(x Float) Float
- func Ceil(x Float) Float
- func Cos(x Float) Float
- func Cosh(x Float) Float
- func Cosine(x, y Matrix) Float
- func Exp(x Float) Float
- func Floor(x Float) Float
- func Inf(sign int) Float
- func Log(x Float) Float
- func Max(x, y Float) Float
- func NaN() Float
- func Pow(x, y Float) Float
- func Round(x Float) Float
- func Sin(x Float) Float
- func Sinh(x Float) Float
- func Sqrt(x Float) Float
- func Tan(x Float) Float
- func Tanh(x Float) Float
- type Matrix
- type Sparse
- func NewEmptySparse(rows, cols int) *Sparse
- func NewEmptyVecSparse(size int) *Sparse
- func NewSparse(rows, cols int, elements []Float) *Sparse
- func NewSparseFromMap(rows, cols int, elements map[Coordinate]Float) *Sparse
- func NewVecSparse(elements []Float) *Sparse
- func OneHotSparse(size int, oneAt int) *Sparse
- func (s *Sparse) Abs() Matrix
- func (s *Sparse) Add(other Matrix) Matrix
- func (s *Sparse) AddInPlace(other Matrix) Matrix
- func (s *Sparse) AddScalar(n Float) Matrix
- func (s *Sparse) AddScalarInPlace(n Float) Matrix
- func (s *Sparse) Apply(fn func(i, j int, v Float) Float, a Matrix)
- func (s *Sparse) ApplyWithAlpha(fn func(i, j int, v Float, alpha ...Float) Float, a Matrix, alpha ...Float)
- func (s *Sparse) At(i int, j int) Float
- func (s *Sparse) AtVec(i int) Float
- func (s *Sparse) ClipInPlace(min, max Float) Matrix
- func (s *Sparse) Clone() Matrix
- func (s *Sparse) Columns() int
- func (s *Sparse) Copy(other Matrix)
- func (s *Sparse) Data() []Float
- func (s *Sparse) Dims() (r, c int)
- func (s *Sparse) Div(other Matrix) Matrix
- func (s *Sparse) DivInPlace(other Matrix) Matrix
- func (s *Sparse) DoNonZero(fn func(i, j int, v Float))
- func (s *Sparse) DotUnitary(other Matrix) Float
- func (s *Sparse) Inverse() Matrix
- func (s *Sparse) IsScalar() bool
- func (s *Sparse) IsVector() bool
- func (s *Sparse) LastIndex() int
- func (s Sparse) MarshalBinary() ([]byte, error)
- func (s *Sparse) Max() Float
- func (s *Sparse) Maximum(other Matrix) Matrix
- func (s *Sparse) Min() Float
- func (s *Sparse) Minimum(other Matrix) Matrix
- func (s *Sparse) Mul(other Matrix) Matrix
- func (s *Sparse) MulT(_ Matrix) Matrix
- func (s *Sparse) Norm(pow Float) Float
- func (s *Sparse) OnesLike() Matrix
- func (s *Sparse) Pow(power Float) Matrix
- func (s *Sparse) Prod(other Matrix) Matrix
- func (s *Sparse) ProdInPlace(other Matrix) Matrix
- func (s *Sparse) ProdMatrixScalarInPlace(m Matrix, n Float) Matrix
- func (s *Sparse) ProdScalar(n Float) Matrix
- func (s *Sparse) ProdScalarInPlace(n Float) Matrix
- func (s *Sparse) Reshape(r, c int) Matrix
- func (s *Sparse) Rows() int
- func (s *Sparse) Scalar() Float
- func (s *Sparse) Set(i int, j int, v Float)
- func (s *Sparse) SetData(data []Float)
- func (s *Sparse) SetVec(i int, v Float)
- func (s *Sparse) Size() int
- func (s *Sparse) Sparsity() Float
- func (s *Sparse) SplitV(_ ...int) []Matrix
- func (s *Sparse) Sqrt() Matrix
- func (s *Sparse) String() string
- func (s *Sparse) Sub(other Matrix) Matrix
- func (s *Sparse) SubInPlace(other Matrix) Matrix
- func (s *Sparse) SubScalar(n Float) Matrix
- func (s *Sparse) SubScalarInPlace(n Float) Matrix
- func (s *Sparse) Sum() Float
- func (s *Sparse) T() Matrix
- func (s *Sparse) ToDense() *Dense
- func (s *Sparse) UnmarshalBinary(data []byte) error
- func (s *Sparse) Zeros()
- func (s *Sparse) ZerosLike() Matrix
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalBinaryMatrix ¶ added in v0.4.0
MarshalBinaryMatrix encodes a Matrix into binary form.
func ReleaseDense ¶
func ReleaseDense(w *Dense)
ReleaseDense replaces a used *Dense into the appropriate size workspace pool. ReleaseDense must not be called with a matrix where references to the underlying data slice have been kept.
func ReleaseMatrix ¶ added in v0.4.1
func ReleaseMatrix(m Matrix)
ReleaseMatrix checks whether m is a Dense matrix, and, if so, it releases is, otherwise no operation is performed.
func SameDims ¶
SameDims returns whether the two matrices have the same number of rows and columns (so also of the same size).
func VectorsOfSameSize ¶
VectorsOfSameSize returns whether the two matrices are vector of the same size.
Types ¶
type Coordinate ¶
type Coordinate struct {
I, J int
}
Coordinate represents the row I and column J of a Sparse matrix.
type Dense ¶
type Dense struct {
// contains filtered or unexported fields
}
Dense is a Matrix implementation that uses Float as data type.
func GetDenseWorkspace ¶
GetDenseWorkspace returns a *Dense of size r×c and a data slice with a cap that is less than 2*r*c. Warning, the values may not be at zero. If you need a ready-to-use matrix you can call GetEmptyDenseWorkspace().
func GetEmptyDenseWorkspace ¶
GetEmptyDenseWorkspace returns a *Dense of size r×c and a data slice with a cap that is less than 2*r*c. The returned matrix is ready-to-use (with all the values set to zeros).
func NewDense ¶
NewDense returns a new rows x cols dense matrix populated with a copy of the elements. The elements cannot be nil, panic otherwise. Use NewEmptyDense to initialize an empty matrix.
func NewEmptyDense ¶
NewEmptyDense returns a new rows x cols matrix initialized to zeros.
func NewEmptyVecDense ¶
NewEmptyVecDense returns a new vector of the given size, initialized to zeros.
func NewInitDense ¶
NewInitDense returns a new rows x cols dense matrix initialized with a constant value.
func NewInitVecDense ¶
NewInitVecDense returns a new size x 1 dense matrix initialized with a constant value.
func NewVecDense ¶
NewVecDense returns a new column vector populated with a copy of the elements. The elements cannot be nil, panic otherwise. Use NewEmptyVecDense to initialize an empty matrix.
func OneHotVecDense ¶
OneHotVecDense returns a new one-hot vector of the given size.
func (*Dense) AddInPlace ¶
AddInPlace performs the in-place addition with the other matrix.
func (*Dense) AddScalarInPlace ¶
AddScalarInPlace adds the scalar to all values of the matrix.
func (*Dense) ApplyWithAlpha ¶
func (d *Dense) ApplyWithAlpha(fn func(i, j int, v Float, alpha ...Float) Float, a Matrix, alpha ...Float)
ApplyWithAlpha executes the unary function fn, taking additional parameters alpha.
func (*Dense) At ¶
At returns the value at row i and column j. It panics if the given indices are out of range.
func (*Dense) AtVec ¶
AtVec returns the value at position i of a vector. It panics if the receiver is not a vector.
func (*Dense) ClipInPlace ¶
ClipInPlace clips in place each value of the matrix.
func (*Dense) Copy ¶
Copy copies the data from the other matrix to the receiver. It panics if the matrices have different dimensions, or if the other matrix is not Dense.
func (*Dense) Data ¶
Data returns the underlying data of the matrix, as a raw one-dimensional slice of values.
func (*Dense) Div ¶
Div returns the result of the element-wise division of the receiver by the other matrix.
func (*Dense) DivInPlace ¶
DivInPlace performs the in-place element-wise division of the receiver by the other matrix.
func (*Dense) DoNonZero ¶ added in v0.4.1
DoNonZero calls a function for each non-zero element of the matrix. The parameters of the function are the element indices and its value.
func (*Dense) DotUnitary ¶
DotUnitary returns the dot product of two vectors.
func (*Dense) ExtractColumn ¶
ExtractColumn returns a copy of the i-th column of the matrix.
func (*Dense) ExtractRow ¶
ExtractRow returns a copy of the i-th row of the matrix.
func (*Dense) Format ¶
Format implements custom formatting for represeinting a Dense matrix. Thanks to this method, a Dense matrix implements the fmt.Formatter interface.
func (*Dense) LU ¶
LU performs lower–upper (LU) decomposition of a square matrix D such as PLU = D, L is lower diagonal and U is upper diagonal, p are pivots.
func (*Dense) LastIndex ¶
LastIndex returns the last element's index, in respect of linear indexing. It returns -1 if the matrix is empty.
func (Dense) MarshalBinary ¶ added in v0.4.0
MarshalBinary marshals a Dense matrix into binary form.
func (*Dense) Mul ¶
Mul performs the multiplication row by column. If A is an i×j Matrix, and B is j×k, then the resulting Matrix C = AB will be i×k.
func (*Dense) MulT ¶
MulT performs the matrix multiplication row by column. ATB = C, where AT is the transpose of B if A is an r x c Matrix, and B is j x k, r = j the resulting Matrix C will be c x k
func (*Dense) Normalize2 ¶
Normalize2 normalizes an array with the Euclidean norm.
func (*Dense) OnesLike ¶
OnesLike returns a new Dense matrix with the same dimensions of the receiver, initialized with ones.
func (*Dense) Pivoting ¶
Pivoting returns the partial pivots of a square matrix to reorder rows. Considerate square sub-matrix from element (offset, offset).
func (*Dense) Pow ¶
Pow returns a new matrix, applying the power function with given exponent to all elements of the matrix.
func (*Dense) Prod ¶
Prod performs the element-wise product between the receiver and the other matrix.
func (*Dense) ProdInPlace ¶
ProdInPlace performs the in-place element-wise product with the other matrix.
func (*Dense) ProdMatrixScalarInPlace ¶
ProdMatrixScalarInPlace multiplies the given matrix with the value, storing the result in the receiver.
func (*Dense) ProdScalar ¶
ProdScalar returns the multiplication between the matrix and the given value.
func (*Dense) ProdScalarInPlace ¶
ProdScalarInPlace performs the in-place multiplication between the matrix and the given value.
func (*Dense) Range ¶
Range extracts data from the the Matrix from elements start (inclusive) and end (exclusive).
func (*Dense) Reshape ¶
Reshape returns a copy of the matrix. It panics if the dimensions are incompatible.
func (*Dense) Scalar ¶
Scalar returns the scalar value. It panics if the matrix does not contain exactly one element.
func (*Dense) Set ¶
Set sets the value v at row i and column j. It panics if the given indices are out of range.
func (*Dense) SetData ¶
SetData sets the values of the matrix, given a raw one-dimensional slice data representation.
func (*Dense) SetVec ¶
SetVec sets the value v at position i of a vector. It panics if the receiver is not a vector.
func (*Dense) SubInPlace ¶
SubInPlace performs the in-place subtraction with the other matrix.
func (*Dense) SubScalarInPlace ¶
SubScalarInPlace subtracts the scalar from the receiver's values.
func (Dense) SwapInPlace ¶
SwapInPlace swaps two rows of the matrix in place
func (*Dense) UnmarshalBinary ¶ added in v0.4.0
UnmarshalBinary unmarshals a binary representation of a Dense matrix.
type Float ¶
type Float = float32
Float is the main float type for the mat32 package. It is an alias for float32.
type Matrix ¶
type Matrix interface { // ZerosLike returns a new matrix with the same dimensions of the receiver, // initialized with zeroes. ZerosLike() Matrix // OnesLike returns a new matrix with the same dimensions of the receiver, // initialized with ones. OnesLike() Matrix // Clone returns a new matrix, copying all its values from the receiver. Clone() Matrix // Copy copies the data from the other matrix to the receiver. Copy(other Matrix) // Zeros sets all the values of the matrix to zero. Zeros() // Dims returns the number of rows and columns of the matrix. Dims() (r, c int) // Rows returns the number of rows of the matrix. Rows() int // Columns returns the number of columns of the matrix. Columns() int // Size returns the size of the matrix (rows × columns). Size() int // LastIndex returns the last element's index, in respect of linear indexing. // It returns -1 if the matrix is empty. LastIndex() int // Data returns the underlying data of the matrix, as a raw one-dimensional slice of values. Data() []Float // IsVector returns whether the matrix is either a row or column vector. IsVector() bool // IsScalar returns whether the matrix contains exactly one scalar value. IsScalar() bool // Scalar returns the scalar value. // It panics if the matrix does not contain exactly one element. Scalar() Float // Set sets the value v at row i and column j. Set(i int, j int, v Float) // At returns the value at row i and column j. At(i int, j int) Float // SetVec sets the value v at position i of a vector. // It panics if the receiver is not a vector. SetVec(i int, v Float) // AtVec returns the value at position i of a vector. // It panics if the receiver is not a vector. AtVec(i int) Float // T returns the transpose of the matrix. T() Matrix // Reshape returns a copy of the matrix. // It panics if the dimensions are incompatible. Reshape(r, c int) Matrix // Apply executes the unary function fn. Apply(fn func(i, j int, v Float) Float, a Matrix) // ApplyWithAlpha executes the unary function fn, taking additional parameters alpha. ApplyWithAlpha(fn func(i, j int, v Float, alpha ...Float) Float, a Matrix, alpha ...Float) // AddScalar performs the addition between the matrix and the given value. AddScalar(n Float) Matrix // AddScalarInPlace adds the scalar to all values of the matrix. AddScalarInPlace(n Float) Matrix // SubScalar performs a subtraction between the matrix and the given value. SubScalar(n Float) Matrix // SubScalarInPlace subtracts the scalar from the receiver's values. SubScalarInPlace(n Float) Matrix // ProdScalar returns the multiplication between the matrix and the given value. ProdScalar(n Float) Matrix // ProdScalarInPlace performs the in-place multiplication between the matrix and // the given value. ProdScalarInPlace(n Float) Matrix // ProdMatrixScalarInPlace multiplies the given matrix with the value, storing the // result in the receiver. ProdMatrixScalarInPlace(m Matrix, n Float) Matrix // Add returns the addition between the receiver and another matrix. Add(other Matrix) Matrix // AddInPlace performs the in-place addition with the other matrix. AddInPlace(other Matrix) Matrix // Sub returns the subtraction of the other matrix from the receiver. Sub(other Matrix) Matrix // SubInPlace performs the in-place subtraction with the other matrix. SubInPlace(other Matrix) Matrix // Prod performs the element-wise product between the receiver and the other matrix. Prod(other Matrix) Matrix // ProdInPlace performs the in-place element-wise product with the other matrix. ProdInPlace(other Matrix) Matrix // Div returns the result of the element-wise division of the receiver by the other matrix. Div(other Matrix) Matrix // DivInPlace performs the in-place element-wise division of the receiver by the other matrix. DivInPlace(other Matrix) Matrix // Mul performs the multiplication row by column. // If A is an i×j Matrix, and B is j×k, then the resulting Matrix C = AB will be i×k. Mul(other Matrix) Matrix // DotUnitary returns the dot product of two vectors. DotUnitary(other Matrix) Float // Pow returns a new matrix, applying the power function with given exponent to all elements // of the matrix. Pow(power Float) Matrix // Norm returns the vector's norm. Use pow = 2.0 to compute the Euclidean norm. Norm(pow Float) Float // Sqrt returns a new matrix applying the square root function to all elements. Sqrt() Matrix // ClipInPlace clips in place each value of the matrix. ClipInPlace(min, max Float) Matrix // SplitV extract N vectors from the Matrix. // N[i] has size sizes[i]. SplitV(sizes ...int) []Matrix // Minimum returns a new matrix containing the element-wise minima. Minimum(other Matrix) Matrix // Maximum returns a new matrix containing the element-wise maxima. Maximum(other Matrix) Matrix // MulT performs the matrix multiplication row by column. ATB = C, where AT is the transpose of B // if A is an r x c Matrix, and B is j x k, r = j the resulting Matrix C will be c x k. MulT(other Matrix) Matrix // Inverse returns the inverse of the Matrix. Inverse() Matrix // DoNonZero calls a function for each non-zero element of the matrix. // The parameters of the function are the element indices and its value. DoNonZero(fn func(i, j int, v Float)) // Abs returns a new matrix applying the absolute value function to all elements. Abs() Matrix // Sum returns the sum of all values of the matrix. Sum() Float // Max returns the maximum value of the matrix. Max() Float // Min returns the minimum value of the matrix. Min() Float // String returns a string representation of the matrix data. String() string // SetData sets the values of the matrix, given a raw one-dimensional slice // data representation. SetData(data []Float) }
The Matrix interface defines set and get methods to access its elements plus a few variants to perform linear algebra operations with other matrices, such as element-wise addition, subtraction, product and matrix-matrix multiplication.
func SqrtMatrix ¶
SqrtMatrix returns a new matrix filled with the sqrt of the values of the input matrix.
type Sparse ¶
type Sparse struct {
// contains filtered or unexported fields
}
Sparse is the implementation of a sparse matrix that uses Float as data type.
func NewEmptySparse ¶
NewEmptySparse returns a new rows x cols Sparse matrix.
func NewEmptyVecSparse ¶
NewEmptyVecSparse returns a new sparse vector of the given size.
func NewSparse ¶
NewSparse returns a new rows x cols sparse matrix populated with a copy of the non-zero elements. The elements cannot be nil, panic otherwise. Use NewEmptySparse to initialize an empty matrix.
func NewSparseFromMap ¶
func NewSparseFromMap(rows, cols int, elements map[Coordinate]Float) *Sparse
NewSparseFromMap creates a new Sparse matrix from a raw map of values.
func NewVecSparse ¶
NewVecSparse returns a new column sparse vector populated with the non-zero elements. The elements cannot be nil, panic otherwise. Use NewEmptyVecSparse to initialize an empty matrix.
func OneHotSparse ¶
OneHotSparse creates a new one-hot Sparse vector. It panics if oneAt is an invalid index.
func (*Sparse) Add ¶
Add returns the addition between the receiver and another matrix. It returns the same type of matrix of other, that is, a Dense matrix if other is Dense, or a Sparse matrix otherwise.
func (*Sparse) AddInPlace ¶
AddInPlace performs the in-place addition with the other matrix. It panics if other is not a Sparse matrix.
func (*Sparse) AddScalar ¶
AddScalar performs the addition between the matrix and the given value, returning a new Dense matrix.
func (*Sparse) AddScalarInPlace ¶
AddScalarInPlace is currently not implemented for a Sparse matrix (it always panics).
func (*Sparse) Apply ¶
Apply executes the unary function fn. Important: apply to Functions such that f(0) = 0 (i.e. Sin, Tan)
func (*Sparse) ApplyWithAlpha ¶
func (s *Sparse) ApplyWithAlpha(fn func(i, j int, v Float, alpha ...Float) Float, a Matrix, alpha ...Float)
ApplyWithAlpha is currently not implemented for a Sparse matrix (it always panics).
func (*Sparse) At ¶
At returns the value at row i and column j. It panics if the given indices are out of range.
func (*Sparse) AtVec ¶
AtVec returns the value at position i of a vector. It panics if the receiver is not a vector.
func (*Sparse) ClipInPlace ¶
ClipInPlace clips in place each value of the matrix.
func (*Sparse) Copy ¶
Copy copies the data from the other matrix to the receiver. It panics if the matrices have different dimensions, or if the other matrix is not Sparse.
func (*Sparse) Data ¶
Data returns the underlying data of the matrix, as a raw one-dimensional slice of values.
func (*Sparse) Div ¶
Div returns the result of the element-wise division of the receiver by the other matrix, returning a new Sparse matrix. It panics if other is a Sparse matrix.
func (*Sparse) DivInPlace ¶
DivInPlace is currently not implemented for a Sparse matrix (it always panics).
func (*Sparse) DoNonZero ¶
DoNonZero calls a function for each non-zero element of the matrix. The parameters of the function are the element indices and its value.
func (*Sparse) DotUnitary ¶
DotUnitary returns the dot product of two vectors.
func (*Sparse) LastIndex ¶
LastIndex returns the last element's index, in respect of linear indexing. It returns -1 if the matrix is empty.
func (Sparse) MarshalBinary ¶ added in v0.4.0
MarshalBinary marshals a Sparse matrix into binary form.
func (*Sparse) Maximum ¶
Maximum returns a new Sparse matrix initialized with the element-wise maximum value between the receiver and the other matrix.
func (*Sparse) Minimum ¶
Minimum returns a new Sparse matrix initialized with the element-wise minimum value between the receiver and the other matrix.
func (*Sparse) Mul ¶
Mul performs the multiplication row by column, returning a Dense matrix. If A is an i×j Matrix, and B is j×k, then the resulting Matrix C = AB will be i×k.
func (*Sparse) MulT ¶ added in v0.4.1
MulT is currently not implemented for a Sparse matrix (it always panics).
func (*Sparse) OnesLike ¶
OnesLike is currently not implemented for a Sparse matrix (it always panics).
func (*Sparse) Pow ¶
Pow returns a new matrix, applying the power function with given exponent to all elements of the matrix.
func (*Sparse) Prod ¶
Prod performs the element-wise product between the receiver and the other matrix, returning a new Sparse matrix.
func (*Sparse) ProdInPlace ¶
ProdInPlace performs the in-place element-wise product with the other matrix. It panics if other is not a Sparse matrix.
func (*Sparse) ProdMatrixScalarInPlace ¶
ProdMatrixScalarInPlace multiplies the given matrix with the value, storing the result in the receiver, and returning the same receiver Sparse matrix.
func (*Sparse) ProdScalar ¶
ProdScalar returns the multiplication between the matrix and the given value, returning a new Sparse matrix.
func (*Sparse) ProdScalarInPlace ¶
ProdScalarInPlace performs the in-place multiplication between the matrix and the given value, returning the same receiver Sparse matrix.
func (*Sparse) Reshape ¶
Reshape is currently not implemented for a Sparse matrix (it always panics).
func (*Sparse) Scalar ¶
Scalar returns the scalar value. It panics if the matrix does not contain exactly one element.
func (*Sparse) Set ¶
Set sets the value v at row i and column j. It panics if the given indices are out of range.
func (*Sparse) SetData ¶
SetData is currently not implemented for a Sparse matrix (it always panics).
func (*Sparse) SplitV ¶ added in v0.4.1
SplitV is currently not implemented for a Sparse matrix (it always panics).
func (*Sparse) Sub ¶
Sub returns the subtraction of the other matrix from the receiver. It returns a Dense matrix if other is Dense, or a Sparse matrix otherwise.
func (*Sparse) SubInPlace ¶
SubInPlace performs the in-place subtraction with the other matrix. It panics if other is not a Sparse matrix.
func (*Sparse) SubScalar ¶
SubScalar performs a subtraction between the matrix and the given value, returning a new Dense matrix.
func (*Sparse) SubScalarInPlace ¶
SubScalarInPlace is currently not implemented for a Sparse matrix (it always panics).
func (*Sparse) UnmarshalBinary ¶ added in v0.4.0
UnmarshalBinary unmarshals a binary representation of a Sparse matrix.