intmat

package module
v0.0.0-...-fe0dc60 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2021 License: MIT Imports: 4 Imported by: 0

README

intmat

Sparse Mat lib for integers

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Matrix

type Matrix struct {
	// contains filtered or unexported fields
}

func Copy

func Copy(m *Matrix) *Matrix

Copy will create a NEW matrix that will have all the same values as m.

func Identity

func Identity(size int) *Matrix

Identity create an identity matrix (one's on the diagonal).

func NewMat

func NewMat(rows, cols int, values ...int) *Matrix

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 NewMatFromVec

func NewMatFromVec(vec *Vector) *Matrix

func (*Matrix) Add

func (mat *Matrix) Add(a, b *Matrix)

Add stores the addition of a and b in this matrix.

func (*Matrix) And

func (mat *Matrix) And(a, b *Matrix)

And executes a piecewise logical AND on the two matrices and stores the values in this matrix.

func (*Matrix) At

func (mat *Matrix) At(i, j int) int

At returns the value at row index i and column index j.

func (*Matrix) Column

func (mat *Matrix) Column(j int) *TransposedVector

Column returns a map containing the non zero row indices as the keys and it's associated values.

func (*Matrix) Dims

func (mat *Matrix) Dims() (int, int)

Dims returns the dimensions of the matrix.

func (*Matrix) Equals

func (mat *Matrix) Equals(m *Matrix) bool

Equals return true if the m matrix has the same shape and values as this matrix.

func (*Matrix) MarshalJSON

func (mat *Matrix) MarshalJSON() ([]byte, error)

func (*Matrix) Mul

func (mat *Matrix) Mul(a, b *Matrix)

Mul multiplies two matrices and stores the values in this matrix.

func (*Matrix) Negate

func (mat *Matrix) Negate()

Negate performs a piecewise logical negation.

func (*Matrix) Or

func (mat *Matrix) Or(a, b *Matrix)

Or executes a piecewise logical OR on the two matrices and stores the values in this matrix.

func (*Matrix) Row

func (mat *Matrix) Row(i int) *Vector

Row returns a map containing the non zero column indices as the keys and it's associated values.

func (*Matrix) Set

func (mat *Matrix) Set(i, j, value int)

Set sets the value at row index i and column index j to value.

func (*Matrix) SetColumn

func (mat *Matrix) SetColumn(j int, vec *TransposedVector)

SetColumn sets the values in column j. The values' keys are expected to be row indices.

func (*Matrix) SetMatrix

func (mat *Matrix) SetMatrix(a *Matrix, iOffset, jOffset int)

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 (*Matrix) SetRow

func (mat *Matrix) SetRow(i int, vec *Vector)

SetRow sets the values in row i. The values' keys are expected to be column indices.

func (*Matrix) Slice

func (mat *Matrix) Slice(i, j, rows, cols int) *Matrix

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 (Matrix) String

func (mat Matrix) String() string

String returns a string representation of this matrix.

func (*Matrix) T

func (mat *Matrix) T() *Matrix

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 (*Matrix) UnmarshalJSON

func (mat *Matrix) UnmarshalJSON(bytes []byte) error

func (*Matrix) XOr

func (mat *Matrix) XOr(a, b *Matrix)

XOr executes a piecewise logical XOR on the two matrices and stores the values in this matrix.

func (*Matrix) Zeroize

func (mat *Matrix) Zeroize()

Zeroize take the current matrix sets all values to 0.

func (*Matrix) ZeroizeRange

func (mat *Matrix) ZeroizeRange(i, j, rows, cols int)

ZeroizeRange take the current matrix sets values inside the range to zero.

type TransposedVector

type TransposedVector struct {
	// contains filtered or unexported fields
}

func CopyTVec

func CopyTVec(a *TransposedVector) *TransposedVector

func NewTVec

func NewTVec(length int, values ...int) *TransposedVector

func (*TransposedVector) Add

func (tvec *TransposedVector) Add(a, b *TransposedVector)

func (*TransposedVector) And

func (tvec *TransposedVector) And(a, b *TransposedVector)

func (*TransposedVector) At

func (tvec *TransposedVector) At(j int) int

At returns the value at index i.

func (*TransposedVector) Equals

func (tvec *TransposedVector) Equals(v *TransposedVector) bool

func (*TransposedVector) Len

func (tvec *TransposedVector) Len() int

func (*TransposedVector) MarshalJSON

func (tvec *TransposedVector) MarshalJSON() ([]byte, error)

func (*TransposedVector) MulVec

func (tvec *TransposedVector) MulVec(a *Matrix, b *TransposedVector)

func (*TransposedVector) Negate

func (tvec *TransposedVector) Negate()

func (*TransposedVector) NonzeroValues

func (tvec *TransposedVector) NonzeroValues() (indexToValues map[int]int)

func (*TransposedVector) Or

func (tvec *TransposedVector) Or(a, b *TransposedVector)

func (*TransposedVector) Set

func (tvec *TransposedVector) Set(j, value int)

Set sets the value at row index i and column index j to value.

func (*TransposedVector) SetVec

func (tvec *TransposedVector) SetVec(a *TransposedVector, j int)

SetVec replaces the values of this vector with the values of from vector a.

func (*TransposedVector) Slice

func (tvec *TransposedVector) Slice(j, len int) *TransposedVector

Slice creates a slice of the TransposedVector. The slice will be connected to the original TransposedVector, changes to one causes changes in the other.

func (*TransposedVector) String

func (tvec *TransposedVector) String() string

func (*TransposedVector) T

func (tvec *TransposedVector) T() *Vector

func (*TransposedVector) UnmarshalJSON

func (tvec *TransposedVector) UnmarshalJSON(bytes []byte) error

func (*TransposedVector) XOr

func (tvec *TransposedVector) XOr(a, b *TransposedVector)

type Vector

type Vector struct {
	// contains filtered or unexported fields
}

func CopyVec

func CopyVec(a *Vector) *Vector

func NewVec

func NewVec(length int, values ...int) *Vector

func (*Vector) Add

func (vec *Vector) Add(a, b *Vector)

func (*Vector) And

func (vec *Vector) And(a, b *Vector)

func (*Vector) At

func (vec *Vector) At(i int) int

At returns the value at index i.

func (*Vector) Dot

func (vec *Vector) Dot(a *Vector) int

func (*Vector) Equals

func (vec *Vector) Equals(v *Vector) bool

func (*Vector) Len

func (vec *Vector) Len() int

func (*Vector) MarshalJSON

func (vec *Vector) MarshalJSON() ([]byte, error)

func (*Vector) Mul

func (vec *Vector) Mul(vec2 *Vector, mat *Matrix)

func (*Vector) Negate

func (vec *Vector) Negate()

func (*Vector) NonzeroValues

func (vec *Vector) NonzeroValues() (indexToValues map[int]int)

func (*Vector) Or

func (vec *Vector) Or(a, b *Vector)

func (*Vector) Set

func (vec *Vector) Set(i, value int)

Set sets the value at row index i and column index j to value.

func (*Vector) SetVec

func (vec *Vector) SetVec(a *Vector, i int)

SetVec replaces the values of this vector with the values of from vector a.

func (*Vector) Slice

func (vec *Vector) Slice(i, len int) *Vector

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 (*Vector) String

func (vec *Vector) String() string

String returns a string representation of this vector.

func (*Vector) T

func (vec *Vector) T() *TransposedVector

func (*Vector) UnmarshalJSON

func (vec *Vector) UnmarshalJSON(bytes []byte) error

func (*Vector) XOr

func (vec *Vector) XOr(a, b *Vector)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL