integermatrixalgebra

package
v0.0.2-0...-db6250e Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: CC0-1.0, CC0-1.0, CC0-1.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreEqual

func AreEqual(x *Element, y *Element) bool

AreEqual returns true iff the matrices x and y have the same parent, and x = y.

func Ring

func Ring(R *Parent) integer.Parent

Ring returns the ring containing the entries of matrices in R.

Types

type Element

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

Element is a matrix with integer entries.

func Add

func Add(x *Element, y *Element) (*Element, error)

Add returns the sum x + y of two matrices x and y. This will return an error if x and y do not have the same parent.

func FromSlice

func FromSlice(R *Parent, S []*integer.Element) (*Element, error)

FromSlice returns a matrix in the matrix algebra R, with entries S. The entries are read row-by-row.

func Multiply

func Multiply(x *Element, y *Element) (*Element, error)

Multiply returns the product x * y of two matrices x and y. This will return an error if x and y do not have the same parent.

func Negate

func Negate(x *Element) *Element

Negate returns the negation -x of the matrix x.

func One

func One(R *Parent) *Element

One returns the identity matrix of R.

func Power

func Power(x *Element, k *integer.Element) (*Element, error)

Power returns x^k.

func PowerInt64

func PowerInt64(x *Element, k int64) (*Element, error)

PowerInt64 returns x^k.

func Subtract

func Subtract(x *Element, y *Element) (*Element, error)

Subtract returns the difference x - y of two matrices x and y. This will return an error if x and y do not have the same parent.

func Sum

func Sum(R *Parent, S ...*Element) (*Element, error)

Sum returns the sum of the matrices in the slice S. All matrices must have the same parent R. If S is empty, the zero element in R is returned.

func ToElement

func ToElement(R *Parent, x object.Element) (*Element, error)

ToElement returns x as a matrix with integer entries in R, if x can naturally be regarded as belonging there.

func Zero

func Zero(R *Parent) *Element

Zero returns the zero matrix of R.

func (*Element) Column

func (x *Element) Column(i int) ([]*integer.Element, error)

Column returns the i-th column of the matrix x. Columns are indexed from 0. It returns an error if the index i is out of range.

func (*Element) Columns

func (x *Element) Columns() [][]*integer.Element

Columns returns the columns of the matrix x.

func (*Element) Determinant

func (x *Element) Determinant() *integer.Element

Determinant returns the determinant of the matrix x.

func (*Element) Entries

func (x *Element) Entries() []*integer.Element

Entries returns the entries of the matrix x, row by row.

func (*Element) Entry

func (x *Element) Entry(i int, j int) (*integer.Element, error)

Entry returns the (i,j)-th entry of the matrix x. Rows and columns are indexed from zero. It returns an error if either i or j is negative or too large (i.e. if i and j refer to a non-existent entry of x).

func (*Element) EntryOrPanic

func (x *Element) EntryOrPanic(i int, j int) *integer.Element

EntryOrPanic returns the (i,j)-th entry of the matrix x. Rows and columns are indexed from zero. It panics error if either i or j is negative or too large (i.e. if i and j refer to a non-existent entry of x).

func (*Element) FlatEntry

func (x *Element) FlatEntry(i int) (*integer.Element, error)

FlatEntry returns the i-th entry of the matrix x, read row by row. Flat entries are indexed from zero up to (but not including) x.Len(). It returns an error if the index i is out of range.

func (*Element) FlatEntryOrPanic

func (x *Element) FlatEntryOrPanic(i int) *integer.Element

FlatEntryOrPanic returns the i-th entry of the matrix x, read row by row. Flat entries are indexed from zero up to (but not including) x.Len(). It panics if the index is out of range.

func (*Element) Hash

func (x *Element) Hash() hash.Value

Hash returns a hash value for the matrix x.

func (*Element) Inverse

func (x *Element) Inverse() (*Element, error)

Inverse returns the inverse of the matrix x, if x is invertible.

func (*Element) IsEqualTo

func (x *Element) IsEqualTo(y *Element) bool

IsEqualTo returns true iff the matrices x and y have the same parent, and x = y.

func (*Element) IsOne

func (x *Element) IsOne() bool

IsOne returns true iff x is the (square) identity matrix.

func (*Element) IsSquare

func (x *Element) IsSquare() bool

IsSquare returns true iff the matrix x is square.

func (*Element) IsZero

func (x *Element) IsZero() bool

IsZero returns true iff x is the zero matrix.

func (*Element) Len

func (x *Element) Len() int

Len returns the total number of entries in the matrix x (i.e. the product of the number of rows and the number of columns).

func (*Element) Negate

func (x *Element) Negate() *Element

Negate returns the negation -x of the matrix x.

func (*Element) NumberOfColumns

func (x *Element) NumberOfColumns() int

NumberOfColumns returns the number of columns of the matrix x.

func (*Element) NumberOfRows

func (x *Element) NumberOfRows() int

NumberOfRows returns the number of rows of the matrix x.

func (*Element) Parent

func (x *Element) Parent() object.Parent

Parent returns the parent of the matrix x.

func (*Element) Power

func (x *Element) Power(k *integer.Element) (*Element, error)

Power returns x^k.

func (*Element) PowerInt64

func (x *Element) PowerInt64(k int64) (*Element, error)

PowerInt64 returns x^k.

func (*Element) Row

func (x *Element) Row(i int) ([]*integer.Element, error)

Row returns the i-th row of the matrix x. Rows are indexed from 0. It returns an error if the index i is out of range.

func (*Element) Rows

func (x *Element) Rows() [][]*integer.Element

Rows returns the rows of the matrix x.

func (*Element) ScalarMultiplyByCoefficient

func (x *Element) ScalarMultiplyByCoefficient(c *integer.Element) (*Element, error)

ScalarMultiplyByCoefficient returns c * x, where c is an element in the ring containing the entries of the matrices in R.

func (*Element) ScalarMultiplyByInt64

func (x *Element) ScalarMultiplyByInt64(n int64) *Element

ScalarMultiplyByInt64 returns the scalar multiple n * x of the matrix x with the integer n, where this is defined to be x + ... + x (n times) if n is positive, -x - ... - x (|n| times) if n is negative, and 0 if n is zero.

func (*Element) ScalarMultiplyByInteger

func (x *Element) ScalarMultiplyByInteger(n *integer.Element) *Element

ScalarMultiplyByInteger returns the scalar multiple n * x of the matrix x with the integer n, where this is defined to be x + ... + x (n times) if n is positive, -x - ... - x (|n| times) if n is negative, and 0 if n is zero.

func (*Element) String

func (x *Element) String() string

String returns a string representation of the matrix x.

func (*Element) Transpose

func (x *Element) Transpose() *Element

Transpose returns the transpose of the matrix x.

type Parent

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

Parent is the parent matrix algebra for matrices with integer entries.

func NewAlgebra

func NewAlgebra(n int) (*Parent, error)

NewAlgebra returns the algebra of n x n matrices with entries in ZZ.

func (*Parent) Add

Add returns x + y.

func (*Parent) AreEqual

func (R *Parent) AreEqual(x object.Element, y object.Element) (bool, error)

AreEqual returns true iff x and y are both contained in the parent, and x = y.

func (*Parent) Column

func (R *Parent) Column(x object.Element, i int) ([]object.Element, error)

Column returns the i-th column of the matrix x. Columns are indexed from 0. It returns an error if the index i is out of range. The entries are elements of the ring containing the entries of the matrices in R.

func (*Parent) Columns

func (R *Parent) Columns(x object.Element) ([][]object.Element, error)

Columns returns the columns of the matrix x. The entries are elements of the ring containing the entries of the matrices in R.

func (*Parent) Contains

func (R *Parent) Contains(x object.Element) bool

Contains returns true iff x is an element of this parent, or can naturally be regarded as an element of this parent.

func (*Parent) Determinant

func (R *Parent) Determinant(x object.Element) (object.Element, error)

Determinant returns the determinant of the matrix x. This is given as an element in the ring of entries.

func (*Parent) Entries

func (R *Parent) Entries(x object.Element) ([]object.Element, error)

Entries returns the entries of the matrix x, row by row. The entries are elements of the ring containing the entries of the matrices in R.

func (*Parent) Entry

func (R *Parent) Entry(x object.Element, i int, j int) (object.Element, error)

Entry returns the (i,j)-th entry of the matrix x. Rows and columns are indexed from zero. It returns an error if either i or j is negative or too large (i.e. if i and j refer to a non-existent entry of x). The returned entry is an element of the ring containing the entries of the matrices in R.

func (*Parent) FromSlice

func (R *Parent) FromSlice(S []object.Element) (object.Element, error)

FromSlice attempts to convert the slice S to a matrix, row by row.

func (*Parent) Inverse

func (R *Parent) Inverse(x object.Element) (object.Element, error)

Inverse returns the inverse of the matrix x, if x is invertible.

func (*Parent) IsOne

func (R *Parent) IsOne(x object.Element) (bool, error)

IsOne returns true iff x is the multiplicative identity element of the ring.

func (*Parent) IsZero

func (R *Parent) IsZero(x object.Element) (bool, error)

IsZero returns true iff x is the additive identity element of the ring.

func (*Parent) Multiply

func (R *Parent) Multiply(x object.Element, y object.Element) (object.Element, error)

Multiply returns x * y.

func (*Parent) Negate

func (R *Parent) Negate(x object.Element) (object.Element, error)

Negate returns -x.

func (*Parent) NumberOfColumns

func (R *Parent) NumberOfColumns() int

NumberOfColumns returns the number of columns of a matrix in R.

func (*Parent) NumberOfRows

func (R *Parent) NumberOfRows() int

NumberOfRows returns the number of rows of a matrix in R.

func (*Parent) One

func (R *Parent) One() object.Element

One returns the multiplicative identity of the ring.

func (*Parent) Power

func (R *Parent) Power(x object.Element, k *integer.Element) (object.Element, error)

Power returns x^k.

func (*Parent) Ring

func (R *Parent) Ring() ring.Interface

Ring returns the ring containing the entries of the matrices in R.

func (*Parent) Row

func (R *Parent) Row(x object.Element, i int) ([]object.Element, error)

Row returns the i-th row of the matrix x. Rows are indexed from 0. It returns an error if the index i is out of range. The entries are elements of the ring containing the entries of the matrices in R.

func (*Parent) Rows

func (R *Parent) Rows(x object.Element) ([][]object.Element, error)

Rows returns the rows of the matrix x. The entries are elements of the ring containing the entries of the matrices in R.

func (*Parent) ScalarMultiplyByCoefficient

func (R *Parent) ScalarMultiplyByCoefficient(c object.Element, x object.Element) (object.Element, error)

ScalarMultiplyByCoefficient returns c * x, where c is an element in the ring containing the entries of the matrices in R.

func (*Parent) ScalarMultiplyByInteger

func (R *Parent) ScalarMultiplyByInteger(n *integer.Element, x object.Element) (object.Element, error)

ScalarMultiplyByInteger returns n * x, where this is defined to be:

x + ... + x (n times) 	if n > 0;
the zero element 			if n = 0;
-x - ... - x (|n| times) 	if n < 0.

func (*Parent) String

func (R *Parent) String() string

String returns a string description of this parent.

func (*Parent) Subtract

func (R *Parent) Subtract(x object.Element, y object.Element) (object.Element, error)

Subtract returns x - y.

func (*Parent) Sum

func (R *Parent) Sum(S ...object.Element) (object.Element, error)

Sum returns the sum of the elements in the slice S. The sum of the empty slice is the zero element.

func (*Parent) ToElement

func (R *Parent) ToElement(x object.Element) (object.Element, error)

ToElement returns x as an element of this parent, or an error if x cannot naturally be regarded as an element of this parent.

func (*Parent) Transpose

func (R *Parent) Transpose(x object.Element) (object.Element, error)

Transpose returns the transpose of the matrix x.

func (*Parent) Zero

func (R *Parent) Zero() object.Element

Zero returns the additive identity of the ring.

Jump to

Keyboard shortcuts

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