Documentation
¶
Index ¶
- func AreEqual(h Helper, S1 Interface, S2 Interface) (bool, error)
- func Column(i int, S Interface) ([]object.Element, error)
- func DeterminantViaLaplace(S Interface) (object.Element, error)
- func IsIdentity(S Interface) bool
- func IsZero(S Interface) bool
- func Row(i int, S Interface) ([]object.Element, error)
- func ToString(S Interface) string
- func ValidateSize(nrows int, ncols int) error
- type DotProductFunc
- type Helper
- type Interface
- func Add(h Helper, S1 Interface, S2 Interface) (Interface, error)
- func EchelonForm(h Helper, S Interface) (Interface, error)
- func IdentitySlice(h Helper, n int) (Interface, error)
- func Negate(h Helper, S Interface) (Interface, error)
- func RowRowMultiply(h Helper, S1 Interface, S2 Interface) (Interface, error)
- func ScalarMultiplyByCoefficient(h Helper, c object.Element, S Interface) (Interface, error)
- func ScalarMultiplyByInteger(h Helper, n *integer.Element, S Interface) (Interface, error)
- func Subtract(h Helper, S1 Interface, S2 Interface) (Interface, error)
- func Sum(h Helper, Es []Interface) (Interface, error)
- func Transpose(h Helper, S Interface) (Interface, error)
- func ZeroSlice(h Helper, nrows int, ncols int) (Interface, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AreEqual ¶
AreEqual returns true iff S1 = S2. If h satisfies the interface:
type AreEqualer interface {
AreEqual(S1 Interface, S2 Interface) (bool, error) // AreEqual
returns true iff S1 = S2.
}
then h's AreEqual method will be used.
func Column ¶
Column returns (a copy of) the i-th column of S. Columns are indexed from 0. It returns an error if the index i is out of range. If S satisfies the interface:
type Columner interface {
Column(i int) []object.Element // Column returns (a copy of) the
i-th column. Columns are indexed from 0. This will panic if
the index is out of range.
}
then S's Column method will be used.
func DeterminantViaLaplace ¶
DeterminantViaLaplace computes the determinant of the matrix represented by the slice of entries S using Laplace's algorithm.
func IsIdentity ¶
IsIdentity returns true iff the matrix defined by the slice of entries S is the identity matrix. If S satisfies the interface:
type IsIdentitier interface {
IsIdentity() bool // IsIdentity returns true iff the matrix
defined by the slice is the zero matrix.
}
then S's IsIdentity method will be used.
func IsZero ¶
IsZero returns true iff the matrix defined by the slice of entries S is the zero matrix. If S satisfies the interface:
type IsZeroer interface {
IsZero() bool // IsZero returns true iff the matrix defined by
the slice is the zero matrix.
}
then S's IsZero method will be used.
func Row ¶
Row returns (a copy of) the i-th row of S. Rows are indexed from 0. It returns an error if the index i is out of range. If S satisfies the interface:
type Rower interface {
Row(i int) []object.Element // Row returns (a copy of) the i-th
row. Rows are indexed from 0. This will panic if the index is
out of range.
}
then S's Row method will be used.
func ToString ¶
ToString returns a string representation of the matrix described by the slice S. If S satisfies the interface:
type PrettyPrinter interface {
PrettyPrint(i int) string // PrettyPrint returns a string
representation of the i-th entry. This will panic if the
index is out of range.
}
then S's PrettyPrint method will be used to convert the entries to strings.
func ValidateSize ¶
ValidateSize checks that the matrix size is valid (i.e. that the number of rows and number of columns are non-negative, and that the size fits in an int).
Types ¶
type DotProductFunc ¶
DotProductFunc defines a function to compute the dot-product of the i-th row with the j-th row.
type Helper ¶
type Helper interface {
Universe() ring.Interface // Universe returns the common parent of the entries.
FromSlice(S slice.Interface, nrows int, ncols int) (Interface, error) // FromSlice attempts to create a slice of entries for a matrix of size nrows x ncols, with entries in S.
}
Helper is the interface satisfied by the helper for a slice of entries of a matrix.
type Interface ¶
type Interface interface {
slice.Interface
Universe() ring.Interface // Universe returns the common parent of the entries.
NumberOfRows() int // NumberOfRows returns the number of rows of the matrix represented by these entries.
NumberOfColumns() int // NumberOfColumns returns the number of columns of the matrix represented by these entries.
}
Interface is the interface satisfied by the slice of entries of a matrix.
func Add ¶
Add returns the sum S1 + S2. If h satisfies the interface:
type Adder interface {
Add(S1 Interface, S2 Interface) (Interface, error) // Add
returns the sum S1 + S2.
}
then h's Add method will be used.
func EchelonForm ¶
EchelonForm returns the reduced row echelon form of S, or an error if reduced row echelon form is not defined or not implemented over this ground ring.
func IdentitySlice ¶
IdentitySlice returns a slice representing the n x n identity matrix, using the given helper. If h satisfies the interface:
type IdentitySlicer interface {
IdentitySlice(n int) (Interface, error) // IdentitySlice returns
a slice representing the n x n identity matrix.
}
then h's IdentitySlice method will be used.
func Negate ¶
Negate returns the negation -S. If S satisfies the interface:
type Negater interface {
Negate() Interface // Negate returns the negation of the
entries.
}
then S's Negate method will be used.
func RowRowMultiply ¶
RowRowMultiply returns the slice of entries of pair-wise dot-products of the rows of S1 and S2. That is, the returned slice has (i,j)-th entry equal to the dot-product of the i-th row of S1 with the j-th row of S2. This is equivalent to the matrix multiplication represented by S1 * Transpose(S2). Requires that S1 and S2 have the same number of columns. The returned slice will represent an nrows1 x nrow2 matrix, where nrows1 is the number of rows of S1, and nrows2 is the number of rows of S2. If h satisfies the interface:
type RowRowMultiplier interface {
RowRowMultiply(S1 Interface, S2 Interface) (Interface, error)
// RowRowMultiply returns the slice of entries of
pair-wise dot-products of the rows of S1 and S2. That
is, the returned slice has (i,j)-th entry equal to
the dot-product of the i-th row of S1 with the j-th
row of S2. This is equivalent to the matrix
multiplication represented by S1 * Transpose(S2).
Requires that S1 and S2 have the same number of
columns. The returned slice will represent an
nrows1 x nrow2 matrix, where nrows1 is the number of
rows of S1, and nrows2 is the number of rows of S2.
}
then h's RowRowMultiply method will be used. Otherwise, if h satisfies the interface:
type DotProducter interface {
DotProduct(S1 Interface, S2 Interface) (DotProductFunc, error)
// DotProduct returns a dot-product function to compute
S1[i] \dot S2[j] of the i-th row of S1 with the j-th
row of S2, where S1 and S2 are slices of entries. S1
and S2 must have the same number of columns.
}
then h's DotProduct method will be used to assist with the calculation.
func ScalarMultiplyByCoefficient ¶
ScalarMultiplyByCoefficient returns c * S, where c is an element in the ring containing the entries of S. If S satisfies the interface:
type ScalarMultiplyByCoefficienter interface {
ScalarMultiplyByCoefficient(c object.Element) (Interface, error)
// ScalarMultiplyByCoefficient of a slice S returns
c * S, where c is an element in the ring containing
the entries of S.
}
then S's ScalarMultiplyByInteger method will be used.
func ScalarMultiplyByInteger ¶
ScalarMultiplyByInteger returns n * S, where this is defined to be S + ... + S (n times) if n is positive, -S - ... - S (|n| times) if n is negative, and 0 if n is zero. If S satisfies the interface:
type ScalarMultiplyByIntegerer interface {
ScalarMultiplyByInteger(n *integer.Element) Interface
// ScalarMultiplyByInteger of a slice S returns n * S,
where this is defined to be S + ... + S (n times) if
n is positive, -S - ... - S (|n| times) if n is
negative, and 0 if n is zero.
}
then S's ScalarMultiplyByInteger method will be used.
func Subtract ¶
Subtract returns the difference S1 - S2. If h satisfies the interface:
type Subtracter interface {
Subtract(S1 Interface, S2 Interface) (Interface, error)
// Subtract returns the difference S1 - S2.
}
then h's Subtract method will be used.
func Sum ¶
Sum returns the sum of the matrices described by the slices of entries Es. The slice Es must not be empty. If h satisfies the interface:
type Sumer interface {
Sum(Es []Interface) (Interface, error) // Sum returns the sum of
the matrices described by the slices of entries Es.
The slice Es must not be empty.
}
then h's Sum method will be used.
func Transpose ¶
Transpose returns the transpose of S. If S satisfies the interface:
type Transposer interface {
Transpose() Interface // Transpose returns the transpose of the
matrix described by the slice of entries.
}
then S's Transpose method will be used.
func ZeroSlice ¶
ZeroSlice returns a slice representing the nrows x ncols zero matrix, using the given helper. If h satisfies the interface:
type ZeroSlicer interface {
ZeroSlice(nrows int, ncols int) (Interface, error) // ZeroSlice
returns a slice representing the nrows x ncols zero matrix.
}
then h's ZeroSlice method will be used.