gf2p16

package
v0.0.0-...-a776223 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MulAndAddByteSliceLE

func MulAndAddByteSliceLE(c T, in, out []byte)

MulAndAddByteSliceLE treats in and out as arrays of Ts stored in little-endian format, and adds c.Times(in<T>[i]) to out<T>[i], for each i.

func MulByteSliceLE

func MulByteSliceLE(c T, in, out []byte)

MulByteSliceLE treats in and out as arrays of Ts stored in little-endian format, and sets each out<T>[i] to c.Times(in<T>[i]).

Types

type Matrix

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

Matrix is an immutable rectangular array of elements of GF(2^16). It has just enough methods to support Reed-Solomon erasure codes.

func NewIdentityMatrix

func NewIdentityMatrix(n int) Matrix

NewIdentityMatrix returns an n x n identity matrix.

func NewMatrixFromFunction

func NewMatrixFromFunction(rows, columns int, fn func(int, int) T) Matrix

NewMatrixFromFunction returns a rows x columns matrix with elements filled in from the given function, which is passed the row index and the column index, and shouldn't rely on any particular call ordering.

func NewMatrixFromSlice

func NewMatrixFromSlice(rows, columns int, elements []T) Matrix

NewMatrixFromSlice returns a rows x columns matrix with elements taken from the given array in row-major order.

func NewZeroMatrix

func NewZeroMatrix(rows, columns int) Matrix

NewZeroMatrix returns a rows x columns matrix with every element being zero.

func (Matrix) At

func (m Matrix) At(i, j int) T

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

func (Matrix) Inverse

func (m Matrix) Inverse() (Matrix, error)

Inverse returns the matrix inverse of m, which must be square, or an error if it is singular.

func (Matrix) RowReduceForInverse

func (m Matrix) RowReduceForInverse(n Matrix) (Matrix, error)

RowReduceForInverse runs row reduction on copies of m, which must be square, and n, which must have the same number of rows as m. The row-reduced copy of n is returned if m is non-singular; otherwise, an empty matrix and an error is returned.

Note that if n is the identity matrix, then the inverse of m is returned. This is the special case of the following fact: if n is equal to some matrix ( n_L | I ), where I is the appropriately-sized identity matrix and | denotes horizontal augmentation, then if the returned matrix is n', the matrix ( I / n' ) is the inverse of ( I / n_L | 0 / m ), where / denotes vertical augmentation.

func (Matrix) Times

func (m Matrix) Times(n Matrix) Matrix

Times returns the matrix product of m with n, which must have compatible dimensions.

type T

type T uint16

T is an element of GF(2^16).

func (T) Div

func (t T) Div(u T) T

Div returns the product of t and u^{-1} as elements of GF(2^16), if u != 0. It panics if u == 0.

func (T) Inverse

func (t T) Inverse() T

Inverse returns the multiplicative inverse of t, if t != 0. It panics if t == 0.

func (T) Minus

func (t T) Minus(u T) T

Minus returns the difference of t and u as elements of GF(2^16), which is just the bitwise xor of the two.

func (T) Plus

func (t T) Plus(u T) T

Plus returns the sum of t and u as elements of GF(2^16), which is just the bitwise xor of the two.

func (T) Pow

func (t T) Pow(p uint32) T

Pow returns the t^p as an element of GF(2^16). T(0).Pow(0) returns 1.

func (T) Times

func (t T) Times(u T) T

Times returns the product of t and u as elements of GF(2^16).

Jump to

Keyboard shortcuts

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