linalg

package
v0.0.0-...-d8be82f Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 9 Imported by: 0

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
}

matrix represents an augmented matrix, for reduction.

func NewMatrix

func NewMatrix(rows [][]int) *Matrix

NewMatrix creates a new matrix and returns it.

func (*Matrix) AddRow

func (m *Matrix) AddRow(r *Row)

AddRow adds a new row to the matrix. If the matrix is already reduced, it reduces it again. If the row contains a different number of coefficients from rows already in the matrix, AddRow panics.

func (*Matrix) AddRowInts

func (m *Matrix) AddRowInts(coefficients []int, constant int)

AddRowInts adds a new row to the matrix, given integer coefficients and constant. If the matrix is already reduced, it reduces it again. If the row contains a different number of coefficients from rows already in the matrix, AddRow panics.

func (*Matrix) AddRows

func (m *Matrix) AddRows(rows []*Row)

AddRows adds multiple new rows to the matrix. If the matrix is already reduced, it reduces it again. If the row contains a different number of coefficients from rows already in the matrix, AddRow panics.

func (*Matrix) Equal

func (m *Matrix) Equal(other *Matrix) bool

Equal returns true if the matrices have the same rows.

func (*Matrix) Impossible

func (m *Matrix) Impossible() bool

Impossible returns true if there are rows with impossible values: all zero coefficients adding to a non-zero constant. It performs reduction first, if it hasn't been done already.

func (*Matrix) KnownCoefficientCount

func (m *Matrix) KnownCoefficientCount() int

KnownCoefficientCount calls KnownCoefficients, but just returns the number of known coefficients.

func (*Matrix) KnownCoefficientFloats

func (m *Matrix) KnownCoefficientFloats() ([]float64, []bool)

KnownCoefficientFloats returns almost the same result as KnownCoefficients, with Rationals converted to float64s. The difference is that if the magnitude of a rational is too large to be represented as a float64, the corresponding float will be an infinity, and the corresponding boolean will be set to false if it wasn't already false.

func (*Matrix) KnownCoefficients

func (m *Matrix) KnownCoefficients() ([]*big.Rat, []bool)

KnownCoefficients reduces the matrix, and returns a slice of coefficient values and a slice of booleans denoting whether the corresponding coefficient is actually known.

func (*Matrix) NumCoefficients

func (m *Matrix) NumCoefficients() int

NumCoefficients returns the number of coefficients in the matrix.

func (*Matrix) Printable

func (m *Matrix) Printable(prefix string, brackets bool) string

Printable returns a grid representation of the matrix.

func (*Matrix) Rank

func (m *Matrix) Rank() int

Rank returns the rank of the matrix. It performs reduction first, if it hasn't been done already.

func (*Matrix) Rows

func (m *Matrix) Rows() []*Row

Rows returns the matrix's rows.

type Row

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

Row represents a row in an augmented matrix. The last (constant) column is pulled out into its own field, k.

func NewRow

func NewRow(coefficients []int, constant int) *Row

NewRow creates a new row object from integer coefficients and constant.

func (*Row) Coefficients

func (r *Row) Coefficients() []*big.Rat

Coefficients returns the coefficients of the row.

func (*Row) Constant

func (r *Row) Constant() *big.Rat

Constant returns the constant of the row.

func (*Row) NonZeroCoefficientCount

func (r *Row) NonZeroCoefficientCount() int

NonZeroCoefficientCount returns the number of non-zero coefficients in the row.

func (*Row) NumCoefficients

func (r *Row) NumCoefficients() int

NumCoefficients returns the number of coefficients in the row.

Jump to

Keyboard shortcuts

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