Documentation ¶
Index ¶
- type CSRMatrix
- func (mat *CSRMatrix) Add(a, b SparseMat) SparseMat
- func (mat *CSRMatrix) AddRows(i1, i2, dest int) SparseMat
- func (mat *CSRMatrix) And(a, b SparseMat) SparseMat
- func (mat *CSRMatrix) At(i, j int) int
- func (mat *CSRMatrix) Column(j int) SparseVector
- func (mat *CSRMatrix) Dims() (int, int)
- func (mat *CSRMatrix) Equals(m SparseMat) bool
- func (mat *CSRMatrix) MarshalJSON() ([]byte, error)
- func (mat *CSRMatrix) Mul(a, b SparseMat) SparseMat
- func (mat *CSRMatrix) Negate() SparseMat
- func (mat *CSRMatrix) Or(a, b SparseMat) SparseMat
- func (mat *CSRMatrix) Row(i int) SparseVector
- func (mat *CSRMatrix) Set(i, j, value int) SparseMat
- func (mat *CSRMatrix) SetColumn(j int, vec SparseVector) SparseMat
- func (mat *CSRMatrix) SetMatrix(a SparseMat, iOffset, jOffset int) SparseMat
- func (mat *CSRMatrix) SetRow(i int, vec SparseVector) SparseMat
- func (mat *CSRMatrix) Slice(i, j, rows, cols int) SparseMat
- func (mat CSRMatrix) String() string
- func (mat *CSRMatrix) SwapColumns(j1, j2 int) SparseMat
- func (mat *CSRMatrix) SwapRows(i1, i2 int) SparseMat
- func (mat *CSRMatrix) T() SparseMat
- func (mat *CSRMatrix) UnmarshalJSON(bytes []byte) error
- func (mat *CSRMatrix) XOr(a, b SparseMat) SparseMat
- func (mat *CSRMatrix) Zeroize() SparseMat
- func (mat *CSRMatrix) ZeroizeRange(i, j, rows, cols int) SparseMat
- type CSRVector
- func (vec *CSRVector) Add(a, b SparseVector) SparseVector
- func (vec *CSRVector) And(a, b SparseVector) SparseVector
- func (vec *CSRVector) At(i int) int
- func (vec *CSRVector) Dot(a SparseVector) int
- func (vec *CSRVector) Equals(v SparseVector) bool
- func (vec *CSRVector) HammingDistance(a SparseVector) int
- func (vec *CSRVector) HammingWeight() int
- func (vec *CSRVector) IsZero() bool
- func (vec *CSRVector) Len() int
- func (vec *CSRVector) MarshalJSON() ([]byte, error)
- func (vec *CSRVector) MatMul(mat SparseMat, vec2 SparseVector) SparseVector
- func (vec *CSRVector) MulMat(vec2 SparseVector, mat SparseMat) SparseVector
- func (vec *CSRVector) Negate() SparseVector
- func (vec *CSRVector) NextSet(startingIndex int) (index int, has bool)
- func (vec *CSRVector) NonzeroArray() (indices []int)
- func (vec *CSRVector) NonzeroMap() (indexToValues map[int]int)
- func (vec *CSRVector) Or(a, b SparseVector) SparseVector
- func (vec *CSRVector) Set(i, value int) SparseVector
- func (vec *CSRVector) SetVec(a SparseVector, i int) SparseVector
- func (vec *CSRVector) Slice(i, length int) SparseVector
- func (vec *CSRVector) String() string
- func (vec *CSRVector) UnmarshalJSON(bytes []byte) error
- func (vec *CSRVector) XOr(a, b SparseVector) SparseVector
- type DOKMatrix
- func (mat *DOKMatrix) Add(a, b SparseMat) SparseMat
- func (mat *DOKMatrix) AddCols(j1, j2, dest int) SparseMat
- func (mat *DOKMatrix) AddRows(i1, i2, dest int) SparseMat
- func (mat *DOKMatrix) And(a, b SparseMat) SparseMat
- func (mat *DOKMatrix) At(i, j int) int
- func (mat *DOKMatrix) Column(j int) SparseVector
- func (mat *DOKMatrix) Dims() (int, int)
- func (mat *DOKMatrix) Equals(m SparseMat) bool
- func (mat *DOKMatrix) MarshalJSON() ([]byte, error)
- func (mat *DOKMatrix) Mul(a, b SparseMat) SparseMat
- func (mat *DOKMatrix) Negate() SparseMat
- func (mat *DOKMatrix) Or(a, b SparseMat) SparseMat
- func (mat *DOKMatrix) Row(i int) SparseVector
- func (mat *DOKMatrix) Set(i, j, value int) SparseMat
- func (mat *DOKMatrix) SetColumn(j int, vec SparseVector) SparseMat
- func (mat *DOKMatrix) SetMatrix(a SparseMat, iOffset, jOffset int) SparseMat
- func (mat *DOKMatrix) SetRow(i int, vec SparseVector) SparseMat
- func (mat *DOKMatrix) Slice(i, j, rows, cols int) SparseMat
- func (mat *DOKMatrix) String() string
- func (mat *DOKMatrix) SwapColumns(j1, j2 int) SparseMat
- func (mat *DOKMatrix) SwapRows(i1, i2 int) SparseMat
- func (mat *DOKMatrix) T() SparseMat
- func (mat *DOKMatrix) UnmarshalJSON(bytes []byte) error
- func (mat *DOKMatrix) XOr(a, b SparseMat) SparseMat
- func (mat *DOKMatrix) Zeroize() SparseMat
- func (mat *DOKMatrix) ZeroizeRange(i, j, rows, cols int) SparseMat
- type DOKVector
- func (vec *DOKVector) Add(a, b SparseVector) SparseVector
- func (vec *DOKVector) And(a, b SparseVector) SparseVector
- func (vec *DOKVector) At(i int) int
- func (vec *DOKVector) Dot(a SparseVector) int
- func (vec *DOKVector) Equals(v SparseVector) bool
- func (vec *DOKVector) HammingDistance(a SparseVector) int
- func (vec *DOKVector) HammingWeight() int
- func (vec *DOKVector) IsZero() bool
- func (vec *DOKVector) Len() int
- func (vec *DOKVector) MarshalJSON() ([]byte, error)
- func (vec *DOKVector) MatMul(mat SparseMat, vec2 SparseVector) SparseVector
- func (vec *DOKVector) MulMat(vec2 SparseVector, mat SparseMat) SparseVector
- func (vec *DOKVector) Negate() SparseVector
- func (vec *DOKVector) NextSet(startingIndex int) (index int, has bool)
- func (vec *DOKVector) NonzeroArray() (indices []int)
- func (vec *DOKVector) NonzeroMap() (indexToValues map[int]int)
- func (vec *DOKVector) Or(a, b SparseVector) SparseVector
- func (vec *DOKVector) Set(i, value int) SparseVector
- func (vec *DOKVector) SetVec(a SparseVector, i int) SparseVector
- func (vec *DOKVector) Slice(i, length int) SparseVector
- func (vec *DOKVector) String() string
- func (vec *DOKVector) UnmarshalJSON(bytes []byte) error
- func (vec *DOKVector) XOr(a, b SparseVector) SparseVector
- type SparseMat
- func CSRIdentity(size int) SparseMat
- func CSRMat(rows, cols int, values ...int) SparseMat
- func CSRMatCopy(m SparseMat) SparseMat
- func CSRMatFromVec(vec SparseVector) SparseMat
- func CSRMatRandom(rows, cols int) SparseMat
- func DOKIdentity(size int) SparseMat
- func DOKMat(rows, cols int, values ...int) SparseMat
- func DOKMatCopy(m SparseMat) SparseMat
- func DOKMatFromVec(vec SparseVector) SparseMat
- func DOKMatRandom(rows, cols int) SparseMat
- type SparseVector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CSRMatrix ¶
type CSRMatrix struct {
// contains filtered or unexported fields
}
func (*CSRMatrix) AddRows ¶
AddRows is fast row operation to add two rows and put the result in a destination row.
func (*CSRMatrix) And ¶
And executes a piecewise logical AND on the two matrices and stores the values in this matrix.
func (*CSRMatrix) Column ¶
func (mat *CSRMatrix) Column(j int) SparseVector
Column returns a map containing the non zero row indices as the keys and it's associated values.
func (*CSRMatrix) Equals ¶
Equals return true if the m matrix has the same shape and values as this matrix.
func (*CSRMatrix) MarshalJSON ¶
func (*CSRMatrix) Or ¶
Or executes a piecewise logical OR on the two matrices and stores the values in this matrix.
func (*CSRMatrix) Row ¶
func (mat *CSRMatrix) Row(i int) SparseVector
Row returns a map containing the non zero column indices as the keys and it's associated values.
func (*CSRMatrix) SetColumn ¶
func (mat *CSRMatrix) SetColumn(j int, vec SparseVector) SparseMat
SetColumn sets the values in column j. The values' keys are expected to be row indices.
func (*CSRMatrix) SetMatrix ¶
SetMatrix replaces the values of this matrix with the values of from matrix a. The shape of 'a' must be less than or equal mat. If the 'a' shape is less then iOffset and jOffset can be used to place 'a' matrix in a specific location.
func (*CSRMatrix) SetRow ¶
func (mat *CSRMatrix) SetRow(i int, vec SparseVector) SparseMat
SetRow sets the values in row i. The values' keys are expected to be column indices.
func (*CSRMatrix) SwapColumns ¶
func (*CSRMatrix) UnmarshalJSON ¶
func (*CSRMatrix) XOr ¶
XOr executes a piecewise logical XOR on the two matrices and stores the values in this matrix.
func (*CSRMatrix) ZeroizeRange ¶
ZeroizeRange take the current matrix sets values inside the range to zero.
type CSRVector ¶
type CSRVector struct {
// contains filtered or unexported fields
}
func (*CSRVector) Add ¶
func (vec *CSRVector) Add(a, b SparseVector) SparseVector
func (*CSRVector) And ¶
func (vec *CSRVector) And(a, b SparseVector) SparseVector
func (*CSRVector) Dot ¶
func (vec *CSRVector) Dot(a SparseVector) int
func (*CSRVector) Equals ¶
func (vec *CSRVector) Equals(v SparseVector) bool
func (*CSRVector) HammingDistance ¶
func (vec *CSRVector) HammingDistance(a SparseVector) int
func (*CSRVector) HammingWeight ¶
func (*CSRVector) MarshalJSON ¶
func (*CSRVector) MatMul ¶
func (vec *CSRVector) MatMul(mat SparseMat, vec2 SparseVector) SparseVector
func (*CSRVector) MulMat ¶
func (vec *CSRVector) MulMat(vec2 SparseVector, mat SparseMat) SparseVector
func (*CSRVector) Negate ¶
func (vec *CSRVector) Negate() SparseVector
func (*CSRVector) NextSet ¶
NextSet returns the next bit which is set starting from startingIndex, so if the startingIndex is set it will be returned, if not it will be the next bit. If no bits are found has bool will be set to false.
func (*CSRVector) NonzeroArray ¶
func (*CSRVector) NonzeroMap ¶
func (*CSRVector) Or ¶
func (vec *CSRVector) Or(a, b SparseVector) SparseVector
func (*CSRVector) Set ¶
func (vec *CSRVector) Set(i, value int) SparseVector
Set sets the value at row index i and column index j to value.
func (*CSRVector) SetVec ¶
func (vec *CSRVector) SetVec(a SparseVector, i int) SparseVector
SetVec replaces the values of this vector with the values of from vector a.
func (*CSRVector) Slice ¶
func (vec *CSRVector) Slice(i, length int) SparseVector
Slice creates a slice of the Vector. The slice will be connected to the original Vector, changes to one causes changes in the other.
func (*CSRVector) UnmarshalJSON ¶
func (*CSRVector) XOr ¶
func (vec *CSRVector) XOr(a, b SparseVector) SparseVector
type DOKMatrix ¶
type DOKMatrix struct {
// contains filtered or unexported fields
}
func (*DOKMatrix) AddCols ¶
AddRows is fast row operation to add two rows and put the result in a destination row.
func (*DOKMatrix) AddRows ¶
AddRows is fast row operation to add two rows and put the result in a destination row.
func (*DOKMatrix) And ¶
And executes a piecewise logical AND on the two matrices and stores the values in this matrix.
func (*DOKMatrix) Column ¶
func (mat *DOKMatrix) Column(j int) SparseVector
Column returns a map containing the non zero row indices as the keys and it's associated values.
func (*DOKMatrix) Equals ¶
Equals return true if the m matrix has the same shape and values as this matrix.
func (*DOKMatrix) MarshalJSON ¶
func (*DOKMatrix) Or ¶
Or executes a piecewise logical OR on the two matrices and stores the values in this matrix.
func (*DOKMatrix) Row ¶
func (mat *DOKMatrix) Row(i int) SparseVector
Row returns a map containing the non zero column indices as the keys and it's associated values.
func (*DOKMatrix) SetColumn ¶
func (mat *DOKMatrix) SetColumn(j int, vec SparseVector) SparseMat
SetColumn sets the values in column j. The values' keys are expected to be row indices.
func (*DOKMatrix) SetMatrix ¶
SetMatrix replaces the values of this matrix with the values of from matrix a. The shape of 'a' must be less than or equal mat. If the 'a' shape is less then iOffset and jOffset can be used to place 'a' matrix in a specific location.
func (*DOKMatrix) SetRow ¶
func (mat *DOKMatrix) SetRow(i int, vec SparseVector) SparseMat
SetRow sets the values in row i. The values' keys are expected to be column indices.
func (*DOKMatrix) Slice ¶
Slice creates a slice of the matrix. The slice will be connected to the original matrix, changes to one causes changes in the other.
func (*DOKMatrix) SwapColumns ¶
func (*DOKMatrix) T ¶
T returns a matrix that is the transpose of the underlying matrix. Note the transpose is connected to matrix it is a transpose of, and changes made to one affect the other.
func (*DOKMatrix) UnmarshalJSON ¶
func (*DOKMatrix) XOr ¶
XOr executes a piecewise logical XOR on the two matrices and stores the values in this matrix.
func (*DOKMatrix) ZeroizeRange ¶
ZeroizeRange take the current matrix sets values inside the range to zero.
type DOKVector ¶
type DOKVector struct {
// contains filtered or unexported fields
}
func (*DOKVector) Add ¶
func (vec *DOKVector) Add(a, b SparseVector) SparseVector
func (*DOKVector) And ¶
func (vec *DOKVector) And(a, b SparseVector) SparseVector
func (*DOKVector) Dot ¶
func (vec *DOKVector) Dot(a SparseVector) int
func (*DOKVector) Equals ¶
func (vec *DOKVector) Equals(v SparseVector) bool
func (*DOKVector) HammingDistance ¶
func (vec *DOKVector) HammingDistance(a SparseVector) int
func (*DOKVector) HammingWeight ¶
func (*DOKVector) MarshalJSON ¶
func (*DOKVector) MatMul ¶
func (vec *DOKVector) MatMul(mat SparseMat, vec2 SparseVector) SparseVector
func (*DOKVector) MulMat ¶
func (vec *DOKVector) MulMat(vec2 SparseVector, mat SparseMat) SparseVector
func (*DOKVector) Negate ¶
func (vec *DOKVector) Negate() SparseVector
func (*DOKVector) NextSet ¶
NextSet returns the next bit which is set starting from startingIndex, so if the startingIndex is set it will be returned, if not it will be the next bit. If no bits are found has bool will be set to false.
func (*DOKVector) NonzeroArray ¶
func (*DOKVector) NonzeroMap ¶
func (*DOKVector) Or ¶
func (vec *DOKVector) Or(a, b SparseVector) SparseVector
func (*DOKVector) Set ¶
func (vec *DOKVector) Set(i, value int) SparseVector
Set sets the value at row index i and column index j to value.
func (*DOKVector) SetVec ¶
func (vec *DOKVector) SetVec(a SparseVector, i int) SparseVector
SetVec replaces the values of this vector with the values of from vector a.
func (*DOKVector) Slice ¶
func (vec *DOKVector) Slice(i, length int) SparseVector
Slice creates a slice of the Vector. The slice will be connected to the original Vector, changes to one causes changes in the other.
func (*DOKVector) UnmarshalJSON ¶
func (*DOKVector) XOr ¶
func (vec *DOKVector) XOr(a, b SparseVector) SparseVector
type SparseMat ¶
type SparseMat interface { Add(a, b SparseMat) SparseMat AddRows(i1, i2, dest int) SparseMat And(a, b SparseMat) SparseMat At(i, j int) int Column(j int) SparseVector Dims() (int, int) Equals(m SparseMat) bool MarshalJSON() ([]byte, error) Mul(a, b SparseMat) SparseMat Negate() SparseMat Or(a, b SparseMat) SparseMat Row(i int) SparseVector Set(i, j, value int) SparseMat SetColumn(j int, vec SparseVector) SparseMat SetMatrix(a SparseMat, iOffset, jOffset int) SparseMat SetRow(i int, vec SparseVector) SparseMat Slice(i, j, rows, cols int) SparseMat String() string SwapRows(i1, i2 int) SparseMat SwapColumns(j1, j2 int) SparseMat T() SparseMat UnmarshalJSON(bytes []byte) error XOr(a, b SparseMat) SparseMat Zeroize() SparseMat ZeroizeRange(i, j, rows, cols int) SparseMat }
func CSRIdentity ¶
Identity create an identity matrix (one's on the diagonal).
func CSRMat ¶
CSRMat creates a new matrix with the specified number of rows and cols. If values is empty, the matrix will be zeroized. If values are not empty it must have rows*cols items. The values are expected to be 0's or 1's anything else may have unexpected behavior matrix's methods.
func CSRMatCopy ¶
Copy will create a NEW matrix that will have all the same values as m.
func CSRMatFromVec ¶
func CSRMatFromVec(vec SparseVector) SparseMat
func CSRMatRandom ¶
CSRRandom creates a new matrix with random values
func DOKIdentity ¶
Identity create an identity matrix (one's on the diagonal).
func DOKMat ¶
NewMat creates a new matrix with the specified number of rows and cols. If values is empty, the matrix will be zeroized. If values are not empty it must have rows*cols items. The values are expected to be 0's or 1's anything else may have unexpected behavior matrix's methods.
func DOKMatCopy ¶
Copy will create a NEW matrix that will have all the same values as m.
func DOKMatFromVec ¶
func DOKMatFromVec(vec SparseVector) SparseMat
func DOKMatRandom ¶
DOKRandom creates a new matrix with random values
type SparseVector ¶
type SparseVector interface { Add(a, b SparseVector) SparseVector And(a, b SparseVector) SparseVector At(i int) int Dot(a SparseVector) int Equals(v SparseVector) bool HammingDistance(a SparseVector) int HammingWeight() int IsZero() bool Len() int MarshalJSON() ([]byte, error) MatMul(mat SparseMat, vec SparseVector) SparseVector MulMat(vec SparseVector, mat SparseMat) SparseVector Negate() SparseVector NonzeroMap() (indicesToValues map[int]int) NonzeroArray() (indices []int) NextSet(startingIndex int) (index int, has bool) Or(a, b SparseVector) SparseVector Set(i, value int) SparseVector SetVec(a SparseVector, i int) SparseVector Slice(i, length int) SparseVector String() string XOr(a, b SparseVector) SparseVector UnmarshalJSON(bytes []byte) error }
func CSRVec ¶
func CSRVec(length int, values ...int) SparseVector
func CSRVecCopy ¶
func CSRVecCopy(a SparseVector) SparseVector
func DOKVec ¶
func DOKVec(length int, values ...int) SparseVector
func DOKVecCopy ¶
func DOKVecCopy(a SparseVector) SparseVector