Documentation
¶
Index ¶
- func Add[T constraints.Number](ctx context.Context, s, m Matrix[T], mask Mask, matrix Matrix[T])
- func Apply[T constraints.Number](ctx context.Context, in Matrix[T], mask Mask, u unaryop.UnaryOp[T], ...)
- func Compare(ctx context.Context, s, m MatrixLogical[rune]) int
- func Default[T any]() T
- func DefaultMonoIDAddition[T constraints.Number]() binaryop.MonoID[T]
- func DefaultMonoIDMaximum[T constraints.Number]() binaryop.MonoID[T]
- func ElementWiseMatrixAdd[T constraints.Number](ctx context.Context, s, m Matrix[T], mask Mask, matrix Matrix[T])
- func ElementWiseMatrixMultiply[T constraints.Number](ctx context.Context, s, m Matrix[T], mask Mask, matrix Matrix[T])
- func ElementWiseVectorAdd[T constraints.Number](ctx context.Context, s, m Vector[T], mask Mask, vector Vector[T])
- func ElementWiseVectorMultiply[T constraints.Number](ctx context.Context, s, m Vector[T], mask Mask, vector Vector[T])
- func Equal[T constraints.Type](ctx context.Context, s, m MatrixLogical[T]) bool
- func Greater(ctx context.Context, s, m MatrixLogical[rune]) bool
- func IsSparseMatrix[T constraints.Type](s MatrixLogical[T]) bool
- func IsZero[T comparable](v T) bool
- func Less(ctx context.Context, s, m MatrixLogical[rune]) bool
- func MatrixMatrixMultiply[T constraints.Number](ctx context.Context, s, m Matrix[T], mask Mask, matrix Matrix[T])
- func MatrixVectorMultiply[T constraints.Number](ctx context.Context, s Matrix[T], m Vector[T], mask Mask, vector Vector[T])
- func Negative[T constraints.Number](ctx context.Context, s Matrix[T], mask Mask, matrix Matrix[T])
- func NewContext(ctx context.Context, mode Mode) context.Context
- func NotEqual[T constraints.Type](ctx context.Context, s, m MatrixLogical[T]) bool
- func ReduceMatrixToScalar[T constraints.Number](ctx context.Context, s MatrixLogical[T], mask Mask) T
- func ReduceMatrixToScalarWithMonoID[T constraints.Number](ctx context.Context, s MatrixLogical[T], monoID binaryop.MonoID[T], mask Mask) T
- func ReduceVectorToScalar[T constraints.Number](ctx context.Context, s VectorLogial[T], mask Mask) T
- func ReduceVectorToScalarWithMonoID[T constraints.Number](ctx context.Context, s VectorLogial[T], monoID binaryop.MonoID[T], mask Mask) T
- func RegisterMatrix(matrix reflect.Type)
- func String(ctx context.Context, s MatrixLogical[rune]) string
- func Subtract[T constraints.Number](ctx context.Context, s, m Matrix[T], mask Mask, matrix Matrix[T])
- func Transpose[T constraints.Type](ctx context.Context, s MatrixLogical[T], mask Mask, matrix MatrixLogical[T])
- func VectorMatrixMultiply[T constraints.Number](ctx context.Context, s Vector[T], m Matrix[T], mask Mask, vector Vector[T])
- func Zero[T any]() T
- type CSCMatrix
- func (s *CSCMatrix[T]) Add(m Matrix[T]) Matrix[T]
- func (s *CSCMatrix[T]) At(r, c int) (value T)
- func (s *CSCMatrix[T]) Clear()
- func (s *CSCMatrix[T]) Columns() int
- func (s *CSCMatrix[T]) ColumnsAt(c int) VectorLogial[T]
- func (s *CSCMatrix[T]) Copy() Matrix[T]
- func (s *CSCMatrix[T]) CopyLogical() MatrixLogical[T]
- func (s *CSCMatrix[T]) Element(r, c int) (b bool)
- func (s *CSCMatrix[T]) Enumerate() Enumerate[T]
- func (s *CSCMatrix[T]) Equal(m MatrixLogical[T]) bool
- func (s *CSCMatrix[T]) Map() Map[T]
- func (s *CSCMatrix[T]) Multiply(m Matrix[T]) Matrix[T]
- func (s *CSCMatrix[T]) Negative() MatrixLogical[T]
- func (s *CSCMatrix[T]) NotEqual(m MatrixLogical[T]) bool
- func (s *CSCMatrix[T]) Rows() int
- func (s *CSCMatrix[T]) RowsAt(r int) VectorLogial[T]
- func (s *CSCMatrix[T]) RowsAtToArray(r int) []T
- func (s *CSCMatrix[T]) Scalar(alpha T) Matrix[T]
- func (s *CSCMatrix[T]) Set(r, c int, value T)
- func (s *CSCMatrix[T]) SetReturnPointer(r, c int, value T) (pointer int, start int)
- func (s *CSCMatrix[T]) Size() int
- func (s *CSCMatrix[T]) Subtract(m Matrix[T]) Matrix[T]
- func (s *CSCMatrix[T]) Transpose() MatrixLogical[T]
- func (s *CSCMatrix[T]) Update(r, c int, f func(T) T)
- func (s *CSCMatrix[T]) UpdateReturnPointer(r, c int, f func(T) T) (pointer int, start int)
- func (s *CSCMatrix[T]) Values() int
- type CSRMatrix
- func (s *CSRMatrix[T]) Add(m Matrix[T]) Matrix[T]
- func (s *CSRMatrix[T]) At(r, c int) (value T)
- func (s *CSRMatrix[T]) Clear()
- func (s *CSRMatrix[T]) Columns() int
- func (s *CSRMatrix[T]) ColumnsAt(c int) VectorLogial[T]
- func (s *CSRMatrix[T]) Copy() Matrix[T]
- func (s *CSRMatrix[T]) CopyLogical() MatrixLogical[T]
- func (s *CSRMatrix[T]) Element(r, c int) (b bool)
- func (s *CSRMatrix[T]) Enumerate() Enumerate[T]
- func (s *CSRMatrix[T]) Equal(m MatrixLogical[T]) bool
- func (s *CSRMatrix[T]) Map() Map[T]
- func (s *CSRMatrix[T]) Multiply(m Matrix[T]) Matrix[T]
- func (s *CSRMatrix[T]) Negative() MatrixLogical[T]
- func (s *CSRMatrix[T]) NotEqual(m MatrixLogical[T]) bool
- func (s *CSRMatrix[T]) Rows() int
- func (s *CSRMatrix[T]) RowsAt(r int) VectorLogial[T]
- func (s *CSRMatrix[T]) RowsAtToArray(r int) []T
- func (s *CSRMatrix[T]) Scalar(alpha T) Matrix[T]
- func (s *CSRMatrix[T]) Set(r, c int, value T)
- func (s *CSRMatrix[T]) SetReturnPointer(r, c int, value T) (pointer int, start int)
- func (s *CSRMatrix[T]) Size() int
- func (s *CSRMatrix[T]) Subtract(m Matrix[T]) Matrix[T]
- func (s *CSRMatrix[T]) Transpose() MatrixLogical[T]
- func (s *CSRMatrix[T]) Update(r, c int, f func(T) T)
- func (s *CSRMatrix[T]) UpdateReturnPointer(r, c int, f func(T) T) (pointer int, start int)
- func (s *CSRMatrix[T]) Values() int
- type Context
- type DenseMatrix
- func (s *DenseMatrix[T]) At(r, c int) T
- func (s *DenseMatrix[T]) Clear()
- func (s *DenseMatrix[T]) Columns() int
- func (s *DenseMatrix[T]) ColumnsAt(c int) VectorLogial[T]
- func (s *DenseMatrix[T]) CopyLogical() MatrixLogical[T]
- func (s *DenseMatrix[T]) Enumerate() Enumerate[T]
- func (s *DenseMatrix[T]) Equal(m MatrixLogical[T]) bool
- func (s *DenseMatrix[T]) NotEqual(m MatrixLogical[T]) bool
- func (s *DenseMatrix[T]) RawMatrix() [][]T
- func (s *DenseMatrix[T]) Rows() int
- func (s *DenseMatrix[T]) RowsAt(r int) VectorLogial[T]
- func (s *DenseMatrix[T]) RowsAtToArray(r int) []T
- func (s *DenseMatrix[T]) Set(r, c int, value T)
- func (s *DenseMatrix[T]) Size() int
- func (s *DenseMatrix[T]) Transpose() MatrixLogical[T]
- func (s *DenseMatrix[T]) Update(r, c int, f func(T) T)
- func (s *DenseMatrix[T]) Values() int
- type DenseMatrixNumber
- func (s *DenseMatrixNumber[T]) Add(m Matrix[T]) Matrix[T]
- func (s *DenseMatrixNumber[T]) Copy() Matrix[T]
- func (s *DenseMatrixNumber[T]) Element(r, c int) bool
- func (s *DenseMatrixNumber[T]) Map() Map[T]
- func (s *DenseMatrixNumber[T]) Multiply(m Matrix[T]) Matrix[T]
- func (s *DenseMatrixNumber[T]) Negative() MatrixLogical[T]
- func (s *DenseMatrixNumber[T]) Scalar(alpha T) Matrix[T]
- func (s *DenseMatrixNumber[T]) Subtract(m Matrix[T]) Matrix[T]
- type DenseVector
- func (s *DenseVector[T]) At(r, c int) (value T)
- func (s *DenseVector[T]) AtVec(i int) T
- func (s *DenseVector[T]) Clear()
- func (s *DenseVector[T]) Columns() int
- func (s *DenseVector[T]) ColumnsAt(c int) VectorLogial[T]
- func (s *DenseVector[T]) CopyLogical() MatrixLogical[T]
- func (s *DenseVector[T]) Enumerate() Enumerate[T]
- func (s *DenseVector[T]) Equal(m MatrixLogical[T]) bool
- func (s *DenseVector[T]) Length() int
- func (s *DenseVector[T]) NotEqual(m MatrixLogical[T]) bool
- func (s *DenseVector[T]) ReSize(size int) int
- func (s *DenseVector[T]) Rows() int
- func (s *DenseVector[T]) RowsAt(r int) VectorLogial[T]
- func (s *DenseVector[T]) RowsAtToArray(r int) []T
- func (s *DenseVector[T]) Set(r, c int, value T)
- func (s *DenseVector[T]) SetVec(i int, value T)
- func (s *DenseVector[T]) Size() int
- func (s *DenseVector[T]) Transpose() MatrixLogical[T]
- func (s *DenseVector[T]) Update(r, c int, f func(T) T)
- func (s *DenseVector[T]) Values() int
- type DenseVectorNumber
- func (s *DenseVectorNumber[T]) Add(m Matrix[T]) Matrix[T]
- func (s *DenseVectorNumber[T]) Copy() Matrix[T]
- func (s *DenseVectorNumber[T]) Element(r, c int) bool
- func (s *DenseVectorNumber[T]) Map() Map[T]
- func (s *DenseVectorNumber[T]) Multiply(m Matrix[T]) Matrix[T]
- func (s *DenseVectorNumber[T]) Negative() MatrixLogical[T]
- func (s *DenseVectorNumber[T]) Scalar(alpha T) Matrix[T]
- func (s *DenseVectorNumber[T]) Subtract(m Matrix[T]) Matrix[T]
- type EmptyMask
- type Enumerate
- type Map
- type Mask
- type MaskLogical
- type Matrix
- type MatrixCompressed
- type MatrixLogical
- type MatrixRune
- type Mode
- type MutexMatrix
- func (s *MutexMatrix[T]) Add(m Matrix[T]) Matrix[T]
- func (s *MutexMatrix[T]) At(r, c int) T
- func (s *MutexMatrix[T]) Clear()
- func (s *MutexMatrix[T]) Columns() int
- func (s *MutexMatrix[T]) ColumnsAt(c int) VectorLogial[T]
- func (s *MutexMatrix[T]) Copy() MatrixLogical[T]
- func (s *MutexMatrix[T]) Element(r, c int) bool
- func (s *MutexMatrix[T]) Enumerate() Enumerate[T]
- func (s *MutexMatrix[T]) Equal(m MatrixLogical[T]) bool
- func (s *MutexMatrix[T]) Map() Map[T]
- func (s *MutexMatrix[T]) Multiply(m Matrix[T]) Matrix[T]
- func (s *MutexMatrix[T]) Negative() MatrixLogical[T]
- func (s *MutexMatrix[T]) NotEqual(m MatrixLogical[T]) bool
- func (s *MutexMatrix[T]) Rows() int
- func (s *MutexMatrix[T]) RowsAt(r int) VectorLogial[T]
- func (s *MutexMatrix[T]) RowsAtToArray(r int) []T
- func (s *MutexMatrix[T]) Scalar(alpha T) Matrix[T]
- func (s *MutexMatrix[T]) Set(r, c int, value T)
- func (s *MutexMatrix[T]) Size() int
- func (s *MutexMatrix[T]) Subtract(m Matrix[T]) Matrix[T]
- func (s *MutexMatrix[T]) Transpose() MatrixLogical[T]
- func (s *MutexMatrix[T]) Update(r, c int, f func(T) T)
- func (s *MutexMatrix[T]) Values() int
- type SparseVector
- func (s *SparseVector[T]) Add(m Matrix[T]) Matrix[T]
- func (s *SparseVector[T]) At(r, c int) (value T)
- func (s *SparseVector[T]) AtVec(i int) T
- func (s *SparseVector[T]) Clear()
- func (s *SparseVector[T]) Columns() int
- func (s *SparseVector[T]) ColumnsAt(c int) VectorLogial[T]
- func (s *SparseVector[T]) Copy() Matrix[T]
- func (s *SparseVector[T]) CopyLogical() MatrixLogical[T]
- func (s *SparseVector[T]) Element(r, c int) bool
- func (s *SparseVector[T]) Enumerate() Enumerate[T]
- func (s *SparseVector[T]) Equal(m MatrixLogical[T]) bool
- func (s *SparseVector[T]) Length() int
- func (s *SparseVector[T]) Map() Map[T]
- func (s *SparseVector[T]) Multiply(m Matrix[T]) Matrix[T]
- func (s *SparseVector[T]) Negative() MatrixLogical[T]
- func (s *SparseVector[T]) NotEqual(m MatrixLogical[T]) bool
- func (s *SparseVector[T]) Rows() int
- func (s *SparseVector[T]) RowsAt(r int) VectorLogial[T]
- func (s *SparseVector[T]) RowsAtToArray(r int) []T
- func (s *SparseVector[T]) Scalar(alpha T) Matrix[T]
- func (s *SparseVector[T]) Set(r, c int, value T)
- func (s *SparseVector[T]) SetVec(i int, value T)
- func (s *SparseVector[T]) Size() int
- func (s *SparseVector[T]) Subtract(m Matrix[T]) Matrix[T]
- func (s *SparseVector[T]) Transpose() MatrixLogical[T]
- func (s *SparseVector[T]) Update(r, c int, f func(T) T)
- func (s *SparseVector[T]) Values() int
- type Vector
- type VectorLogial
- type VectorRune
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
func Apply[T constraints.Number](ctx context.Context, in Matrix[T], mask Mask, u unaryop.UnaryOp[T], matrix Matrix[T])
Apply modifies edge weights by the UnaryOperator
C ⊕= f(A)
func Compare ¶
func Compare(ctx context.Context, s, m MatrixLogical[rune]) int
Compare returns an integer comparing two matrices lexicographically.
func DefaultMonoIDAddition ¶
func DefaultMonoIDAddition[T constraints.Number]() binaryop.MonoID[T]
func DefaultMonoIDMaximum ¶
func DefaultMonoIDMaximum[T constraints.Number]() binaryop.MonoID[T]
func ElementWiseMatrixAdd ¶
func ElementWiseMatrixAdd[T constraints.Number](ctx context.Context, s, m Matrix[T], mask Mask, matrix Matrix[T])
ElementWiseMatrixAdd Element-wise addition on a matrix
eWiseMult
func ElementWiseMatrixMultiply ¶
func ElementWiseMatrixMultiply[T constraints.Number](ctx context.Context, s, m Matrix[T], mask Mask, matrix Matrix[T])
ElementWiseMatrixMultiply Element-wise multiplication on a matrix
eWiseMult
func ElementWiseVectorAdd ¶
func ElementWiseVectorAdd[T constraints.Number](ctx context.Context, s, m Vector[T], mask Mask, vector Vector[T])
ElementWiseVectorAdd Element-wise addition on a vector
eWiseMult
func ElementWiseVectorMultiply ¶
func ElementWiseVectorMultiply[T constraints.Number](ctx context.Context, s, m Vector[T], mask Mask, vector Vector[T])
ElementWiseVectorMultiply Element-wise multiplication on a vector
eWiseMult
func Equal ¶
func Equal[T constraints.Type](ctx context.Context, s, m MatrixLogical[T]) bool
Equal the two matrices are equal
func IsSparseMatrix ¶
func IsSparseMatrix[T constraints.Type](s MatrixLogical[T]) bool
IsSparseMatrix is 's' a sparse matrix
func IsZero ¶
func IsZero[T comparable](v T) bool
func MatrixMatrixMultiply ¶
func MatrixMatrixMultiply[T constraints.Number](ctx context.Context, s, m Matrix[T], mask Mask, matrix Matrix[T])
MatrixMatrixMultiply multiplies a matrix by another matrix
mxm
func MatrixVectorMultiply ¶
func MatrixVectorMultiply[T constraints.Number](ctx context.Context, s Matrix[T], m Vector[T], mask Mask, vector Vector[T])
MatrixVectorMultiply multiplies a matrix by a vector
mxv
func NewContext ¶
NewContext returns a Context
func NotEqual ¶
func NotEqual[T constraints.Type](ctx context.Context, s, m MatrixLogical[T]) bool
NotEqual the two matrices are not equal
func ReduceMatrixToScalar ¶
func ReduceMatrixToScalar[T constraints.Number](ctx context.Context, s MatrixLogical[T], mask Mask) T
ReduceMatrixToScalar perform's a reduction on the Matrix
func ReduceMatrixToScalarWithMonoID ¶
func ReduceMatrixToScalarWithMonoID[T constraints.Number](ctx context.Context, s MatrixLogical[T], monoID binaryop.MonoID[T], mask Mask) T
ReduceMatrixToScalarWithMonoID perform's a reduction on the Matrix monoid used in the element-wise reduction operation
func ReduceVectorToScalar ¶
func ReduceVectorToScalar[T constraints.Number](ctx context.Context, s VectorLogial[T], mask Mask) T
ReduceVectorToScalar perform's a reduction on the Matrix
func ReduceVectorToScalarWithMonoID ¶
func ReduceVectorToScalarWithMonoID[T constraints.Number](ctx context.Context, s VectorLogial[T], monoID binaryop.MonoID[T], mask Mask) T
ReduceVectorToScalarWithMonoID perform's a reduction on the Matrix monoid used in the element-wise reduction operation
func RegisterMatrix ¶
RegisterMatrix add's the sparse matrix to the registry
func Subtract ¶
func Subtract[T constraints.Number](ctx context.Context, s, m Matrix[T], mask Mask, matrix Matrix[T])
Subtract subtracts one matrix from another matrix
func Transpose ¶
func Transpose[T constraints.Type](ctx context.Context, s MatrixLogical[T], mask Mask, matrix MatrixLogical[T])
Transpose swaps the rows and columns
C ⊕= Aᵀ
func VectorMatrixMultiply ¶
func VectorMatrixMultiply[T constraints.Number](ctx context.Context, s Vector[T], m Matrix[T], mask Mask, vector Vector[T])
VectorMatrixMultiply multiplies a vector by a matrix
vxm
Types ¶
type CSCMatrix ¶
type CSCMatrix[T constraints.Number] struct { // contains filtered or unexported fields }
CSCMatrix compressed storage by columns (CSC)
func NewCSCMatrix ¶
func NewCSCMatrix[T constraints.Number](r, c int) *CSCMatrix[T]
NewCSCMatrix returns a CSCMatrix
func NewCSCMatrixFromArray ¶
func NewCSCMatrixFromArray[T constraints.Number](data [][]T) *CSCMatrix[T]
NewCSCMatrixFromArray returns a CSCMatrix
func (*CSCMatrix[T]) Clear ¶
func (s *CSCMatrix[T]) Clear()
Clear removes all elements from a matrix
func (*CSCMatrix[T]) ColumnsAt ¶
func (s *CSCMatrix[T]) ColumnsAt(c int) VectorLogial[T]
ColumnsAt return the columns at c-th
func (*CSCMatrix[T]) CopyLogical ¶
func (s *CSCMatrix[T]) CopyLogical() MatrixLogical[T]
Copy copies the matrix
func (*CSCMatrix[T]) Element ¶
Element of the mask for each tuple that exists in the matrix for which the value of the tuple cast to Boolean is true
func (*CSCMatrix[T]) Enumerate ¶
Enumerate iterates through all non-zero elements, order is not guaranteed
func (*CSCMatrix[T]) Equal ¶
func (s *CSCMatrix[T]) Equal(m MatrixLogical[T]) bool
Equal the two matrices are equal
func (*CSCMatrix[T]) Map ¶
Map replace each element with the result of applying a function to its value
func (*CSCMatrix[T]) Negative ¶
func (s *CSCMatrix[T]) Negative() MatrixLogical[T]
Negative the negative of a matrix
func (*CSCMatrix[T]) NotEqual ¶
func (s *CSCMatrix[T]) NotEqual(m MatrixLogical[T]) bool
NotEqual the two matrices are not equal
func (*CSCMatrix[T]) RowsAt ¶
func (s *CSCMatrix[T]) RowsAt(r int) VectorLogial[T]
RowsAt return the rows at r-th
func (*CSCMatrix[T]) RowsAtToArray ¶
RowsAtToArray return the rows at r-th
func (*CSCMatrix[T]) SetReturnPointer ¶
func (*CSCMatrix[T]) Transpose ¶
func (s *CSCMatrix[T]) Transpose() MatrixLogical[T]
Transpose swaps the rows and columns
func (*CSCMatrix[T]) UpdateReturnPointer ¶
type CSRMatrix ¶
type CSRMatrix[T constraints.Number] struct { // contains filtered or unexported fields }
CSRMatrix compressed storage by rows (CSR)
func NewCSRMatrix ¶
func NewCSRMatrix[T constraints.Number](r, c int) *CSRMatrix[T]
NewCSRMatrix returns a CSRMatrix
func NewCSRMatrixFromArray ¶
func NewCSRMatrixFromArray[T constraints.Number](data [][]T) *CSRMatrix[T]
NewCSRMatrixFromArray returns a CSRMatrix
func (*CSRMatrix[T]) Clear ¶
func (s *CSRMatrix[T]) Clear()
Clear removes all elements from a matrix
func (*CSRMatrix[T]) ColumnsAt ¶
func (s *CSRMatrix[T]) ColumnsAt(c int) VectorLogial[T]
ColumnsAt return the columns at c-th
func (*CSRMatrix[T]) CopyLogical ¶
func (s *CSRMatrix[T]) CopyLogical() MatrixLogical[T]
Copy copies the matrix
func (*CSRMatrix[T]) Element ¶
Element of the mask for each tuple that exists in the matrix for which the value of the tuple cast to Boolean is true
func (*CSRMatrix[T]) Enumerate ¶
Enumerate iterates through all non-zero elements, order is not guaranteed
func (*CSRMatrix[T]) Equal ¶
func (s *CSRMatrix[T]) Equal(m MatrixLogical[T]) bool
Equal the two matrices are equal
func (*CSRMatrix[T]) Map ¶
Map replace each element with the result of applying a function to its value
func (*CSRMatrix[T]) Negative ¶
func (s *CSRMatrix[T]) Negative() MatrixLogical[T]
Negative the negative of a matrix
func (*CSRMatrix[T]) NotEqual ¶
func (s *CSRMatrix[T]) NotEqual(m MatrixLogical[T]) bool
NotEqual the two matrices are not equal
func (*CSRMatrix[T]) RowsAt ¶
func (s *CSRMatrix[T]) RowsAt(r int) VectorLogial[T]
RowsAt return the rows at r-th
func (*CSRMatrix[T]) RowsAtToArray ¶
RowsAtToArray return the rows at r-th
func (*CSRMatrix[T]) SetReturnPointer ¶
func (*CSRMatrix[T]) Transpose ¶
func (s *CSRMatrix[T]) Transpose() MatrixLogical[T]
Transpose swaps the rows and columns
func (*CSRMatrix[T]) UpdateReturnPointer ¶
type DenseMatrix ¶
type DenseMatrix[T constraints.Type] struct { // contains filtered or unexported fields }
DenseMatrix a dense matrix
func NewDenseMatrix ¶
func NewDenseMatrix[T constraints.Type](r, c int) *DenseMatrix[T]
NewDenseMatrix returns a DenseMatrix
func NewDenseMatrixFromArray ¶
func NewDenseMatrixFromArray[T constraints.Number](data [][]T) *DenseMatrix[T]
NewDenseMatrixFromArray returns a DenseMatrix
func (*DenseMatrix[T]) At ¶
func (s *DenseMatrix[T]) At(r, c int) T
At returns the value of a matrix element at r-th, c-th
func (*DenseMatrix[T]) Clear ¶
func (s *DenseMatrix[T]) Clear()
Clear removes all elements from a matrix
func (*DenseMatrix[T]) Columns ¶
func (s *DenseMatrix[T]) Columns() int
Columns the number of columns of the matrix
func (*DenseMatrix[T]) ColumnsAt ¶
func (s *DenseMatrix[T]) ColumnsAt(c int) VectorLogial[T]
ColumnsAt return the columns at c-th
func (*DenseMatrix[T]) CopyLogical ¶
func (s *DenseMatrix[T]) CopyLogical() MatrixLogical[T]
Copy copies the matrix
func (*DenseMatrix[T]) Enumerate ¶
func (s *DenseMatrix[T]) Enumerate() Enumerate[T]
Enumerate iterates through all non-zero elements, order is not guaranteed
func (*DenseMatrix[T]) Equal ¶
func (s *DenseMatrix[T]) Equal(m MatrixLogical[T]) bool
Equal the two matrices are equal
func (*DenseMatrix[T]) NotEqual ¶
func (s *DenseMatrix[T]) NotEqual(m MatrixLogical[T]) bool
NotEqual the two matrices are not equal
func (*DenseMatrix[T]) RawMatrix ¶
func (s *DenseMatrix[T]) RawMatrix() [][]T
RawMatrix returns the raw matrix
func (*DenseMatrix[T]) Rows ¶
func (s *DenseMatrix[T]) Rows() int
Rows the number of rows of the matrix
func (*DenseMatrix[T]) RowsAt ¶
func (s *DenseMatrix[T]) RowsAt(r int) VectorLogial[T]
RowsAt return the rows at r-th
func (*DenseMatrix[T]) RowsAtToArray ¶
func (s *DenseMatrix[T]) RowsAtToArray(r int) []T
RowsAtToArray return the rows at r-th
func (*DenseMatrix[T]) Set ¶
func (s *DenseMatrix[T]) Set(r, c int, value T)
Set sets the value at r-th, c-th of the matrix
func (*DenseMatrix[T]) Transpose ¶
func (s *DenseMatrix[T]) Transpose() MatrixLogical[T]
Transpose swaps the rows and columns
func (*DenseMatrix[T]) Update ¶
func (s *DenseMatrix[T]) Update(r, c int, f func(T) T)
Update does a At and Set on the matrix element at r-th, c-th
func (*DenseMatrix[T]) Values ¶
func (s *DenseMatrix[T]) Values() int
Values the number of elements in the matrix
type DenseMatrixNumber ¶
type DenseMatrixNumber[T constraints.Number] struct { DenseMatrix[T] }
func NewDenseMatrixFromArrayN ¶
func NewDenseMatrixFromArrayN[T constraints.Number](data [][]T) *DenseMatrixNumber[T]
NewDenseMatrixFromArray returns a DenseMatrix
func NewDenseMatrixN ¶
func NewDenseMatrixN[T constraints.Number](r, c int) *DenseMatrixNumber[T]
func (*DenseMatrixNumber[T]) Add ¶
func (s *DenseMatrixNumber[T]) Add(m Matrix[T]) Matrix[T]
Add addition of a matrix by another matrix
func (*DenseMatrixNumber[T]) Copy ¶
func (s *DenseMatrixNumber[T]) Copy() Matrix[T]
func (*DenseMatrixNumber[T]) Element ¶
func (s *DenseMatrixNumber[T]) Element(r, c int) bool
Element of the mask for each tuple that exists in the matrix for which the value of the tuple cast to Boolean is true
func (*DenseMatrixNumber[T]) Map ¶
func (s *DenseMatrixNumber[T]) Map() Map[T]
Map replace each element with the result of applying a function to its value
func (*DenseMatrixNumber[T]) Multiply ¶
func (s *DenseMatrixNumber[T]) Multiply(m Matrix[T]) Matrix[T]
Multiply multiplies a matrix by another matrix
func (*DenseMatrixNumber[T]) Negative ¶
func (s *DenseMatrixNumber[T]) Negative() MatrixLogical[T]
Negative the negative of a matrix
func (*DenseMatrixNumber[T]) Scalar ¶
func (s *DenseMatrixNumber[T]) Scalar(alpha T) Matrix[T]
Scalar multiplication of a matrix by alpha
func (*DenseMatrixNumber[T]) Subtract ¶
func (s *DenseMatrixNumber[T]) Subtract(m Matrix[T]) Matrix[T]
Subtract subtracts one matrix from another matrix
type DenseVector ¶
type DenseVector[T constraints.Type] struct { // contains filtered or unexported fields }
DenseVector a vector
func NewDenseVector ¶
func NewDenseVector[T constraints.Type](l int) *DenseVector[T]
NewDenseVector returns a DenseVector
func NewDenseVectorFromArray ¶
func NewDenseVectorFromArray[T constraints.Type](data []T) *DenseVector[T]
NewDenseVectorFromArray returns a SparseVector
func (*DenseVector[T]) At ¶
func (s *DenseVector[T]) At(r, c int) (value T)
At returns the value of a vector element at r-th, c-th
func (*DenseVector[T]) AtVec ¶
func (s *DenseVector[T]) AtVec(i int) T
AtVec returns the value of a vector element at i-th
func (*DenseVector[T]) Clear ¶
func (s *DenseVector[T]) Clear()
Clear removes all elements from a vector
func (*DenseVector[T]) Columns ¶
func (s *DenseVector[T]) Columns() int
Columns the number of columns of the vector
func (*DenseVector[T]) ColumnsAt ¶
func (s *DenseVector[T]) ColumnsAt(c int) VectorLogial[T]
ColumnsAt return the columns at c-th
func (*DenseVector[T]) CopyLogical ¶
func (s *DenseVector[T]) CopyLogical() MatrixLogical[T]
Copy copies the vector
func (*DenseVector[T]) Enumerate ¶
func (s *DenseVector[T]) Enumerate() Enumerate[T]
Enumerate iterates through all non-zero elements, order is not guaranteed
func (*DenseVector[T]) Equal ¶
func (s *DenseVector[T]) Equal(m MatrixLogical[T]) bool
Equal the two vectors are equal
func (*DenseVector[T]) NotEqual ¶
func (s *DenseVector[T]) NotEqual(m MatrixLogical[T]) bool
NotEqual the two vectors are not equal
func (*DenseVector[T]) ReSize ¶
func (s *DenseVector[T]) ReSize(size int) int
Re-size the vector, will cut if the new size is smaller than the old size
func (*DenseVector[T]) Rows ¶
func (s *DenseVector[T]) Rows() int
Rows the number of rows of the vector
func (*DenseVector[T]) RowsAt ¶
func (s *DenseVector[T]) RowsAt(r int) VectorLogial[T]
RowsAt return the rows at r-th
func (*DenseVector[T]) RowsAtToArray ¶
func (s *DenseVector[T]) RowsAtToArray(r int) []T
RowsAtToArray return the rows at r-th
func (*DenseVector[T]) Set ¶
func (s *DenseVector[T]) Set(r, c int, value T)
Set sets the value at r-th, c-th of the vector
func (*DenseVector[T]) SetVec ¶
func (s *DenseVector[T]) SetVec(i int, value T)
SetVec sets the value at i-th of the vector
func (*DenseVector[T]) Transpose ¶
func (s *DenseVector[T]) Transpose() MatrixLogical[T]
Transpose swaps the rows and columns
func (*DenseVector[T]) Update ¶
func (s *DenseVector[T]) Update(r, c int, f func(T) T)
Update does a At and Set on the vector element at r-th, c-th
func (*DenseVector[T]) Values ¶
func (s *DenseVector[T]) Values() int
Values the number of elements in the vector
type DenseVectorNumber ¶
type DenseVectorNumber[T constraints.Number] struct { DenseVector[T] }
func NewDenseVectorFromArrayN ¶
func NewDenseVectorFromArrayN[T constraints.Number](data []T) *DenseVectorNumber[T]
NewDenseVectorFromArray returns a SparseVector
func NewDenseVectorN ¶
func NewDenseVectorN[T constraints.Number](l int) *DenseVectorNumber[T]
func (*DenseVectorNumber[T]) Add ¶
func (s *DenseVectorNumber[T]) Add(m Matrix[T]) Matrix[T]
Add addition of a vector by another vector
func (*DenseVectorNumber[T]) Copy ¶
func (s *DenseVectorNumber[T]) Copy() Matrix[T]
func (*DenseVectorNumber[T]) Element ¶
func (s *DenseVectorNumber[T]) Element(r, c int) bool
Element of the mask for each tuple that exists in the matrix for which the value of the tuple cast to Boolean is true
func (*DenseVectorNumber[T]) Map ¶
func (s *DenseVectorNumber[T]) Map() Map[T]
Map replace each element with the result of applying a function to its value
func (*DenseVectorNumber[T]) Multiply ¶
func (s *DenseVectorNumber[T]) Multiply(m Matrix[T]) Matrix[T]
Multiply multiplies a vector by another vector
func (*DenseVectorNumber[T]) Negative ¶
func (s *DenseVectorNumber[T]) Negative() MatrixLogical[T]
Negative the negative of a metrix
func (*DenseVectorNumber[T]) Scalar ¶
func (s *DenseVectorNumber[T]) Scalar(alpha T) Matrix[T]
Scalar multiplication of a vector by alpha
func (*DenseVectorNumber[T]) Subtract ¶
func (s *DenseVectorNumber[T]) Subtract(m Matrix[T]) Matrix[T]
Subtract subtracts one vector from another vector
type EmptyMask ¶
type EmptyMask struct {
// contains filtered or unexported fields
}
EmptyMask is a mask with no elements but will always returns false
type Enumerate ¶
type Enumerate[T constraints.Type] interface { // HasNext checks for the next element in the matrix HasNext() bool // Next move the iterator over the matrix Next() (r, c int, v T) }
Enumerate iterates over the matrix
type Map ¶
type Map[T constraints.Type] interface { // HasNext checks for the next element in the matrix HasNext() bool // Map move the iterator and uses a higher order function to changes the elements current value Map(func(r, c int, v T) T) }
Map replace each element with the result of applying a function to its value
type Mask ¶
type Mask interface { MaskLogical // Element of the mask for each tuple that exists in the matrix for which the value of the tuple cast to Boolean is true Element(r, c int) bool }
type MaskLogical ¶
type MaskLogical interface { // Columns the number of columns of the mask Columns() int // Rows the number of rows of the mask Rows() int }
Mask is used to control how computed values are stored in the output from a method
type Matrix ¶
type Matrix[T constraints.Number] interface { Mask MatrixLogical[T] // Copy copies the matrix Copy() Matrix[T] // Scalar multiplication of a matrix by alpha Scalar(alpha T) Matrix[T] // Multiply multiplies a matrix by another matrix // C = AB Multiply(m Matrix[T]) Matrix[T] // Add addition of a matrix by another matrix Add(m Matrix[T]) Matrix[T] // Subtract subtracts one matrix from another matrix Subtract(m Matrix[T]) Matrix[T] // Negative the negative of a matrix Negative() MatrixLogical[T] // Map iterates and replace each element with the result of applying a function to its value Map() Map[T] }
Matrix interface
func TransposeToCSC ¶
TransposeToCSC swaps the rows and columns and returns a compressed storage by columns (CSC) matrix
func TransposeToCSR ¶
TransposeToCSR swaps the rows and columns and returns a compressed storage by rows (CSR) matrix
type MatrixCompressed ¶
type MatrixLogical ¶
type MatrixLogical[T constraints.Type] interface { // contains filtered or unexported methods }
type MatrixRune ¶
type MatrixRune interface {
// contains filtered or unexported methods
}
type MutexMatrix ¶
type MutexMatrix[T constraints.Number] struct { sync.RWMutex // contains filtered or unexported fields }
MutexMatrix a matrix wrapper that has a mutex lock support
func NewMutexMatrix ¶
func NewMutexMatrix[T constraints.Number](matrix Matrix[T]) *MutexMatrix[T]
NewMutexMatrix returns a MutexMatrix
func (*MutexMatrix[T]) Add ¶
func (s *MutexMatrix[T]) Add(m Matrix[T]) Matrix[T]
Add addition of a matrix by another matrix
func (*MutexMatrix[T]) At ¶
func (s *MutexMatrix[T]) At(r, c int) T
At returns the value of a matrix element at r-th, c-th
func (*MutexMatrix[T]) Clear ¶
func (s *MutexMatrix[T]) Clear()
Clear removes all elements from a matrix
func (*MutexMatrix[T]) Columns ¶
func (s *MutexMatrix[T]) Columns() int
Columns the number of columns of the matrix
func (*MutexMatrix[T]) ColumnsAt ¶
func (s *MutexMatrix[T]) ColumnsAt(c int) VectorLogial[T]
ColumnsAt return the columns at c-th
func (*MutexMatrix[T]) Copy ¶
func (s *MutexMatrix[T]) Copy() MatrixLogical[T]
Copy copies the matrix
func (*MutexMatrix[T]) Element ¶
func (s *MutexMatrix[T]) Element(r, c int) bool
Element of the mask for each tuple that exists in the matrix for which the value of the tuple cast to Boolean is true
func (*MutexMatrix[T]) Enumerate ¶
func (s *MutexMatrix[T]) Enumerate() Enumerate[T]
Enumerate iterates through all non-zero elements, order is not guaranteed
func (*MutexMatrix[T]) Equal ¶
func (s *MutexMatrix[T]) Equal(m MatrixLogical[T]) bool
Equal the two matrices are equal
func (*MutexMatrix[T]) Map ¶
func (s *MutexMatrix[T]) Map() Map[T]
Map replace each element with the result of applying a function to its value
func (*MutexMatrix[T]) Multiply ¶
func (s *MutexMatrix[T]) Multiply(m Matrix[T]) Matrix[T]
Multiply multiplies a matrix by another matrix
func (*MutexMatrix[T]) Negative ¶
func (s *MutexMatrix[T]) Negative() MatrixLogical[T]
Negative the negative of a matrix
func (*MutexMatrix[T]) NotEqual ¶
func (s *MutexMatrix[T]) NotEqual(m MatrixLogical[T]) bool
NotEqual the two matrices are not equal
func (*MutexMatrix[T]) Rows ¶
func (s *MutexMatrix[T]) Rows() int
Rows the number of rows of the matrix
func (*MutexMatrix[T]) RowsAt ¶
func (s *MutexMatrix[T]) RowsAt(r int) VectorLogial[T]
RowsAt return the rows at r-th
func (*MutexMatrix[T]) RowsAtToArray ¶
func (s *MutexMatrix[T]) RowsAtToArray(r int) []T
RowsAtToArray return the rows at r-th
func (*MutexMatrix[T]) Scalar ¶
func (s *MutexMatrix[T]) Scalar(alpha T) Matrix[T]
Scalar multiplication of a matrix by alpha
func (*MutexMatrix[T]) Set ¶
func (s *MutexMatrix[T]) Set(r, c int, value T)
Set sets the value at r-th, c-th of the matrix
func (*MutexMatrix[T]) Subtract ¶
func (s *MutexMatrix[T]) Subtract(m Matrix[T]) Matrix[T]
Subtract subtracts one matrix from another matrix
func (*MutexMatrix[T]) Transpose ¶
func (s *MutexMatrix[T]) Transpose() MatrixLogical[T]
Transpose swaps the rows and columns
func (*MutexMatrix[T]) Update ¶
func (s *MutexMatrix[T]) Update(r, c int, f func(T) T)
Update does a At and Set on the matrix element at r-th, c-th
func (*MutexMatrix[T]) Values ¶
func (s *MutexMatrix[T]) Values() int
Values the number of elements in the matrix
type SparseVector ¶
type SparseVector[T constraints.Number] struct { // contains filtered or unexported fields }
SparseVector compressed storage by indices
func NewSparseVector ¶
func NewSparseVector[T constraints.Number](l int) *SparseVector[T]
NewSparseVector returns a SparseVector
func NewSparseVectorFromArray ¶
func NewSparseVectorFromArray[T constraints.Number](data []T) *SparseVector[T]
NewSparseVectorFromArray returns a SparseVector
func (*SparseVector[T]) Add ¶
func (s *SparseVector[T]) Add(m Matrix[T]) Matrix[T]
Add addition of a metrix by another metrix
func (*SparseVector[T]) At ¶
func (s *SparseVector[T]) At(r, c int) (value T)
At returns the value of a vector element at r-th, c-th
func (*SparseVector[T]) AtVec ¶
func (s *SparseVector[T]) AtVec(i int) T
AtVec returns the value of a vector element at i-th
func (*SparseVector[T]) Clear ¶
func (s *SparseVector[T]) Clear()
Clear removes all elements from a vector
func (*SparseVector[T]) Columns ¶
func (s *SparseVector[T]) Columns() int
Columns the number of columns of the vector
func (*SparseVector[T]) ColumnsAt ¶
func (s *SparseVector[T]) ColumnsAt(c int) VectorLogial[T]
ColumnsAt return the columns at c-th
func (*SparseVector[T]) CopyLogical ¶
func (s *SparseVector[T]) CopyLogical() MatrixLogical[T]
func (*SparseVector[T]) Element ¶
func (s *SparseVector[T]) Element(r, c int) bool
Element of the mask for each tuple that exists in the matrix for which the value of the tuple cast to Boolean is true
func (*SparseVector[T]) Enumerate ¶
func (s *SparseVector[T]) Enumerate() Enumerate[T]
Enumerate iterates through all non-zero elements, order is not guaranteed
func (*SparseVector[T]) Equal ¶
func (s *SparseVector[T]) Equal(m MatrixLogical[T]) bool
Equal the two metrics are equal
func (*SparseVector[T]) Map ¶
func (s *SparseVector[T]) Map() Map[T]
Map replace each element with the result of applying a function to its value
func (*SparseVector[T]) Multiply ¶
func (s *SparseVector[T]) Multiply(m Matrix[T]) Matrix[T]
Multiply multiplies a vector by another vector
func (*SparseVector[T]) Negative ¶
func (s *SparseVector[T]) Negative() MatrixLogical[T]
Negative the negative of a metrix
func (*SparseVector[T]) NotEqual ¶
func (s *SparseVector[T]) NotEqual(m MatrixLogical[T]) bool
NotEqual the two metrix are not equal
func (*SparseVector[T]) Rows ¶
func (s *SparseVector[T]) Rows() int
Rows the number of rows of the vector
func (*SparseVector[T]) RowsAt ¶
func (s *SparseVector[T]) RowsAt(r int) VectorLogial[T]
RowsAt return the rows at r-th
func (*SparseVector[T]) RowsAtToArray ¶
func (s *SparseVector[T]) RowsAtToArray(r int) []T
RowsAtToArray return the rows at r-th
func (*SparseVector[T]) Scalar ¶
func (s *SparseVector[T]) Scalar(alpha T) Matrix[T]
Scalar multiplication of a vector by alpha
func (*SparseVector[T]) Set ¶
func (s *SparseVector[T]) Set(r, c int, value T)
Set sets the value at r-th, c-th of the vector
func (*SparseVector[T]) SetVec ¶
func (s *SparseVector[T]) SetVec(i int, value T)
SetVec sets the value at i-th of the vector
func (*SparseVector[T]) Subtract ¶
func (s *SparseVector[T]) Subtract(m Matrix[T]) Matrix[T]
Subtract subtracts one metrix from another metrix
func (*SparseVector[T]) Transpose ¶
func (s *SparseVector[T]) Transpose() MatrixLogical[T]
Transpose swaps the rows and columns
func (*SparseVector[T]) Update ¶
func (s *SparseVector[T]) Update(r, c int, f func(T) T)
Update does a At and Set on the vector element at r-th, c-th
func (*SparseVector[T]) Values ¶
func (s *SparseVector[T]) Values() int
Values the number of non-zero elements in the Vector
type Vector ¶
type Vector[T constraints.Number] interface { Matrix[T] // contains filtered or unexported methods }
func ReduceMatrixToVector ¶
ReduceMatrixToVector perform's a reduction on the Matrix
type VectorLogial ¶
type VectorLogial[T constraints.Type] interface { MatrixLogical[T] // contains filtered or unexported methods }
type VectorRune ¶
type VectorRune interface { MatrixLogical[rune] Compare(v VectorRune) int // contains filtered or unexported methods }