matrixexp

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

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

Go to latest
Published: Sep 9, 2015 License: MIT Imports: 4 Imported by: 0

README

matrixexp

Matrix Algebra Expressions

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equals

func Equals(m1, m2 MatrixExp) bool

Equals determines if two matrices are equal.

Types

type Add

type Add struct {
	Left  MatrixExp
	Right MatrixExp
}

Add represents matrix addition.

func (*Add) Add

func (m1 *Add) Add(m2 MatrixExp) MatrixExp

Add two matrices together.

func (*Add) At

func (m1 *Add) At(r, c int) float64

At returns the value at a given row, column index.

func (*Add) Copy

func (m1 *Add) Copy() MatrixExp

Copy creates a (deep) copy of the Matrix Expression.

func (*Add) Dims

func (m1 *Add) Dims() (r, c int)

Dims returns the matrix dimensions.

func (*Add) DivElem

func (m1 *Add) DivElem(m2 MatrixExp) MatrixExp

DivElem performs element-wise division.

func (*Add) Err

func (m1 *Add) Err() error

Err returns the first error encountered while constructing the matrix expression.

func (*Add) Eval

func (m1 *Add) Eval() MatrixLiteral

Eval returns a matrix literal.

func (*Add) Mul

func (m1 *Add) Mul(m2 MatrixExp) MatrixExp

Mul performs matrix multiplication.

func (*Add) MulElem

func (m1 *Add) MulElem(m2 MatrixExp) MatrixExp

MulElem performs element-wise multiplication.

func (*Add) Scale

func (m1 *Add) Scale(c float64) MatrixExp

Scale performs scalar multiplication.

func (*Add) String

func (m1 *Add) String() string

String implements the Stringer interface.

func (*Add) Sub

func (m1 *Add) Sub(m2 MatrixExp) MatrixExp

Sub subtracts the right matrix from the left matrix.

func (*Add) T

func (m1 *Add) T() MatrixExp

T transposes a matrix.

type Async

type Async struct {
	M MatrixExp
}

Async represents a matrix expression that evaluates into a Future.

func (*Async) Add

func (m1 *Async) Add(m2 MatrixExp) MatrixExp

Add two matrices together.

func (*Async) At

func (m1 *Async) At(r, c int) float64

At returns the value at a given row, column index.

func (*Async) Copy

func (m1 *Async) Copy() MatrixExp

Copy creates a (deep) copy of the Matrix Expression.

func (*Async) Dims

func (m1 *Async) Dims() (r, c int)

Dims returns the matrix dimensions.

func (*Async) DivElem

func (m1 *Async) DivElem(m2 MatrixExp) MatrixExp

DivElem performs element-wise division.

func (*Async) Err

func (m1 *Async) Err() error

Err returns the first error encountered while constructing the matrix expression.

func (*Async) Eval

func (m1 *Async) Eval() MatrixLiteral

Eval returns a matrix literal.

func (*Async) Mul

func (m1 *Async) Mul(m2 MatrixExp) MatrixExp

Mul performs matrix multiplication.

func (*Async) MulElem

func (m1 *Async) MulElem(m2 MatrixExp) MatrixExp

MulElem performs element-wise multiplication.

func (*Async) Scale

func (m1 *Async) Scale(c float64) MatrixExp

Scale performs scalar multiplication.

func (*Async) String

func (m1 *Async) String() string

String implements the Stringer interface.

func (*Async) Sub

func (m1 *Async) Sub(m2 MatrixExp) MatrixExp

Sub subtracts the right matrix from the left matrix.

func (*Async) T

func (m1 *Async) T() MatrixExp

T transposes a matrix.

type DivElem

type DivElem struct {
	Left  MatrixExp
	Right MatrixExp
}

DivElem represents element-wise division.

func (*DivElem) Add

func (m1 *DivElem) Add(m2 MatrixExp) MatrixExp

Add two matrices together.

func (*DivElem) At

func (m1 *DivElem) At(r, c int) float64

At returns the value at a given row, column index.

func (*DivElem) Copy

func (m1 *DivElem) Copy() MatrixExp

Copy creates a (deep) copy of the Matrix Expression.

func (*DivElem) Dims

func (m1 *DivElem) Dims() (r, c int)

Dims returns the matrix dimensions.

func (*DivElem) DivElem

func (m1 *DivElem) DivElem(m2 MatrixExp) MatrixExp

DivElem performs element-wise division.

func (*DivElem) Err

func (m1 *DivElem) Err() error

Err returns the first error encountered while constructing the matrix expression.

func (*DivElem) Eval

func (m1 *DivElem) Eval() MatrixLiteral

Eval returns a matrix literal.

func (*DivElem) Mul

func (m1 *DivElem) Mul(m2 MatrixExp) MatrixExp

Mul performs matrix multiplication.

func (*DivElem) MulElem

func (m1 *DivElem) MulElem(m2 MatrixExp) MatrixExp

MulElem performs element-wise multiplication.

func (*DivElem) Scale

func (m1 *DivElem) Scale(c float64) MatrixExp

Scale performs scalar multiplication.

func (*DivElem) String

func (m1 *DivElem) String() string

String implements the Stringer interface.

func (*DivElem) Sub

func (m1 *DivElem) Sub(m2 MatrixExp) MatrixExp

Sub subtracts the right matrix from the left matrix.

func (*DivElem) T

func (m1 *DivElem) T() MatrixExp

T transposes a matrix.

type ErrDimMismatch

type ErrDimMismatch struct {
	R1, C1 int
	R2, C2 int
}

ErrDimMismatch happens when two matrices cannot be operated on due to differnt sizes. For example, you can't perform element-wise multiplication between a 2x2 matrix and a 3x3 matrix.

func (ErrDimMismatch) Error

func (e ErrDimMismatch) Error() string

type ErrInnerDimMismatch

type ErrInnerDimMismatch struct {
	C, R int
}

ErrInnerDimMismatch happens when you try to use matrix multiplication on two matrices that have different inner dimensions.

func (ErrInnerDimMismatch) Error

func (e ErrInnerDimMismatch) Error() string

type ErrInvalidCols

type ErrInvalidCols int

ErrInvalidCols happens when a literal has a negative number of columns.

func (ErrInvalidCols) Error

func (e ErrInvalidCols) Error() string

type ErrInvalidDataLen

type ErrInvalidDataLen struct {
	GotLen, WantLen int
}

ErrInvalidDataLen happens when the slice of data is too small to fit all of the values that can be addressed in the matrix.

func (ErrInvalidDataLen) Error

func (e ErrInvalidDataLen) Error() string

type ErrInvalidRows

type ErrInvalidRows int

ErrInvalidRows happens when a literal has a negative number of rows.

func (ErrInvalidRows) Error

func (e ErrInvalidRows) Error() string

type ErrInvalidStride

type ErrInvalidStride int

ErrInvalidStride happens when a literal has a nonpositive stride.

func (ErrInvalidStride) Error

func (e ErrInvalidStride) Error() string

type ErrStrideLessThanCols

type ErrStrideLessThanCols struct {
	Stride, Cols int
}

ErrStrideLessThanCols happens when a literal has stride less than columns.

func (ErrStrideLessThanCols) Error

func (e ErrStrideLessThanCols) Error() string

type Future

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

Future is a matrix literal that is asynchronously evaluating.

func NewFuture

func NewFuture(M MatrixExp) *Future

NewFuture constructs a Future MatrixLiteral from a Matrix Expression and then begins evaluating it.

func (*Future) Add

func (m1 *Future) Add(m2 MatrixExp) MatrixExp

Add two matrices together.

func (*Future) AsGeneral

func (m1 *Future) AsGeneral() blas64.General

AsGeneral returns the matrix as a blas64.General (not a copy!)

func (*Future) AsVector

func (m1 *Future) AsVector() []float64

AsVector returns a copy of the values in the matrix as a []float64, in row order.

func (*Future) At

func (m1 *Future) At(r, c int) float64

At returns the value at a given row, column index.

func (*Future) Copy

func (m1 *Future) Copy() MatrixExp

Copy creates a (deep) copy of the Matrix Expression.

func (*Future) Dims

func (m1 *Future) Dims() (r, c int)

Dims returns the matrix dimensions.

func (*Future) DivElem

func (m1 *Future) DivElem(m2 MatrixExp) MatrixExp

DivElem performs element-wise division.

func (*Future) Err

func (m1 *Future) Err() error

Err returns the first error encountered while constructing the matrix expression.

func (*Future) Eval

func (m1 *Future) Eval() MatrixLiteral

Eval returns a matrix literal.

func (*Future) Mul

func (m1 *Future) Mul(m2 MatrixExp) MatrixExp

Mul performs matrix multiplication.

func (*Future) MulElem

func (m1 *Future) MulElem(m2 MatrixExp) MatrixExp

MulElem performs element-wise multiplication.

func (*Future) Scale

func (m1 *Future) Scale(c float64) MatrixExp

Scale performs scalar multiplication.

func (*Future) Set

func (m1 *Future) Set(r, c int, v float64)

Set changes the value at a given row, column index.

func (*Future) String

func (m1 *Future) String() string

String implements the Stringer interface.

func (*Future) Sub

func (m1 *Future) Sub(m2 MatrixExp) MatrixExp

Sub subtracts the right matrix from the left matrix.

func (*Future) T

func (m1 *Future) T() MatrixExp

T transposes a matrix.

type General

type General struct {
	blas64.General
}

General is a typical matrix literal.

func (*General) Add

func (m1 *General) Add(m2 MatrixExp) MatrixExp

Add two matrices together.

func (*General) AsGeneral

func (m1 *General) AsGeneral() blas64.General

AsGeneral returns the matrix as a blas64.General (not a copy!)

func (*General) AsVector

func (m1 *General) AsVector() []float64

AsVector returns a copy of the values in the matrix as a []float64, in row order.

func (*General) At

func (m1 *General) At(r, c int) float64

At returns the value at a given row, column index.

func (*General) Copy

func (m1 *General) Copy() MatrixExp

Copy creates a (deep) copy of the Matrix Expression.

func (*General) Dims

func (m1 *General) Dims() (r, c int)

Dims returns the matrix dimensions.

func (*General) DivElem

func (m1 *General) DivElem(m2 MatrixExp) MatrixExp

DivElem performs element-wise division.

func (*General) Err

func (m1 *General) Err() error

Err returns the first error encountered while constructing the matrix expression.

func (*General) Eval

func (m1 *General) Eval() MatrixLiteral

Eval returns a matrix literal.

func (*General) Mul

func (m1 *General) Mul(m2 MatrixExp) MatrixExp

Mul performs matrix multiplication.

func (*General) MulElem

func (m1 *General) MulElem(m2 MatrixExp) MatrixExp

MulElem performs element-wise multiplication.

func (*General) Scale

func (m1 *General) Scale(c float64) MatrixExp

Scale performs scalar multiplication.

func (*General) Set

func (m1 *General) Set(r, c int, v float64)

Set changes the value at a given row, column index.

func (*General) String

func (m1 *General) String() string

String implements the Stringer interface.

func (*General) Sub

func (m1 *General) Sub(m2 MatrixExp) MatrixExp

Sub subtracts the right matrix from the left matrix.

func (*General) T

func (m1 *General) T() MatrixExp

T transposes a matrix.

type MatrixExp

type MatrixExp interface {
	// Stringer interface
	String() string

	// not a part of the algebra, but very helpful
	Dims() (r, c int)    // matrix dimensions
	At(r, c int) float64 // get a value from a given row, column index

	Eval() MatrixLiteral // Evaluates the matrix expression, producing a Matrix literal.
	Copy() MatrixExp     // creates a (deep) copy of the matrix expression

	Err() error // returns the first error encountered while constructing the matrix expression.

	// Matrix Algebra
	T() MatrixExp                // transpose
	Add(MatrixExp) MatrixExp     // matrix addition
	Sub(MatrixExp) MatrixExp     // matrix subtraction
	Scale(float64) MatrixExp     // scalar multiplication
	Mul(MatrixExp) MatrixExp     // matrix multiplication
	MulElem(MatrixExp) MatrixExp // element-wise multiplication
	DivElem(MatrixExp) MatrixExp // element-wise division

}

MatrixExp represents any mathematical matrix expression, and defines its Algebra.

type MatrixLiteral

type MatrixLiteral interface {
	MatrixExp

	AsVector() []float64       // vector returns all of the values in the matrix as a []float64, in row order
	AsGeneral() blas64.General // returns a Matrix as a MatrixExp.General
	Set(r, c int, v float64)   // set a specific row, column to value
}

MatrixLiteral is a literal matrix, which can be converted to a blas64.General.

type Mul

type Mul struct {
	Left  MatrixExp
	Right MatrixExp
}

Mul represents matrix multiplication.

func (*Mul) Add

func (m1 *Mul) Add(m2 MatrixExp) MatrixExp

Add two matrices together.

func (*Mul) At

func (m1 *Mul) At(r, c int) float64

At returns the value at a given row, column index.

func (*Mul) Copy

func (m1 *Mul) Copy() MatrixExp

Copy creates a (deep) copy of the Matrix Expression.

func (*Mul) Dims

func (m1 *Mul) Dims() (r, c int)

Dims returns the matrix dimensions.

func (*Mul) DivElem

func (m1 *Mul) DivElem(m2 MatrixExp) MatrixExp

DivElem performs element-wise division.

func (*Mul) Err

func (m1 *Mul) Err() error

Err returns the first error encountered while constructing the matrix expression.

func (*Mul) Eval

func (m1 *Mul) Eval() MatrixLiteral

Eval returns a matrix literal.

func (*Mul) Mul

func (m1 *Mul) Mul(m2 MatrixExp) MatrixExp

Mul performs matrix multiplication.

func (*Mul) MulElem

func (m1 *Mul) MulElem(m2 MatrixExp) MatrixExp

MulElem performs element-wise multiplication.

func (*Mul) Scale

func (m1 *Mul) Scale(c float64) MatrixExp

Scale performs scalar multiplication.

func (*Mul) String

func (m1 *Mul) String() string

String implements the Stringer interface.

func (*Mul) Sub

func (m1 *Mul) Sub(m2 MatrixExp) MatrixExp

Sub subtracts the right matrix from the left matrix.

func (*Mul) T

func (m1 *Mul) T() MatrixExp

T transposes a matrix.

type MulElem

type MulElem struct {
	Left  MatrixExp
	Right MatrixExp
}

MulElem represents element-wise multiplication.

func (*MulElem) Add

func (m1 *MulElem) Add(m2 MatrixExp) MatrixExp

Add two matrices together.

func (*MulElem) At

func (m1 *MulElem) At(r, c int) float64

At returns the value at a given row, column index.

func (*MulElem) Copy

func (m1 *MulElem) Copy() MatrixExp

Copy creates a (deep) copy of the Matrix Expression.

func (*MulElem) Dims

func (m1 *MulElem) Dims() (r, c int)

Dims returns the matrix dimensions.

func (*MulElem) DivElem

func (m1 *MulElem) DivElem(m2 MatrixExp) MatrixExp

DivElem performs element-wise division.

func (*MulElem) Err

func (m1 *MulElem) Err() error

Err returns the first error encountered while constructing the matrix expression.

func (*MulElem) Eval

func (m1 *MulElem) Eval() MatrixLiteral

Eval returns a matrix literal.

func (*MulElem) Mul

func (m1 *MulElem) Mul(m2 MatrixExp) MatrixExp

Mul performs matrix multiplication.

func (*MulElem) MulElem

func (m1 *MulElem) MulElem(m2 MatrixExp) MatrixExp

MulElem performs element-wise multiplication.

func (*MulElem) Scale

func (m1 *MulElem) Scale(c float64) MatrixExp

Scale performs scalar multiplication.

func (*MulElem) String

func (m1 *MulElem) String() string

String implements the Stringer interface.

func (*MulElem) Sub

func (m1 *MulElem) Sub(m2 MatrixExp) MatrixExp

Sub subtracts the right matrix from the left matrix.

func (*MulElem) T

func (m1 *MulElem) T() MatrixExp

T transposes a matrix.

type Scale

type Scale struct {
	C float64
	M MatrixExp
}

Scale represents scalar multiplication.

func (*Scale) Add

func (m1 *Scale) Add(m2 MatrixExp) MatrixExp

Add two matrices together.

func (*Scale) At

func (m1 *Scale) At(r, c int) float64

At returns the value at a given row, column index.

func (*Scale) Copy

func (m1 *Scale) Copy() MatrixExp

Copy creates a (deep) copy of the Matrix Expression.

func (*Scale) Dims

func (m1 *Scale) Dims() (r, c int)

Dims returns the matrix dimensions.

func (*Scale) DivElem

func (m1 *Scale) DivElem(m2 MatrixExp) MatrixExp

DivElem performs element-wise division.

func (*Scale) Err

func (m1 *Scale) Err() error

Err returns the first error encountered while constructing the matrix expression.

func (*Scale) Eval

func (m1 *Scale) Eval() MatrixLiteral

Eval returns a matrix literal.

func (*Scale) Mul

func (m1 *Scale) Mul(m2 MatrixExp) MatrixExp

Mul performs matrix multiplication.

func (*Scale) MulElem

func (m1 *Scale) MulElem(m2 MatrixExp) MatrixExp

MulElem performs element-wise multiplication.

func (*Scale) Scale

func (m1 *Scale) Scale(c float64) MatrixExp

Scale performs scalar multiplication.

func (*Scale) String

func (m1 *Scale) String() string

String implements the Stringer interface.

func (*Scale) Sub

func (m1 *Scale) Sub(m2 MatrixExp) MatrixExp

Sub subtracts the right matrix from the left matrix.

func (*Scale) T

func (m1 *Scale) T() MatrixExp

T transposes a matrix.

type Sub

type Sub struct {
	Left  MatrixExp
	Right MatrixExp
}

Sub represents matrix subtraction.

func (*Sub) Add

func (m1 *Sub) Add(m2 MatrixExp) MatrixExp

Add two matrices together.

func (*Sub) At

func (m1 *Sub) At(r, c int) float64

At returns the value at a given row, column index.

func (*Sub) Copy

func (m1 *Sub) Copy() MatrixExp

Copy creates a (deep) copy of the Matrix Expression.

func (*Sub) Dims

func (m1 *Sub) Dims() (r, c int)

Dims returns the matrix dimensions.

func (*Sub) DivElem

func (m1 *Sub) DivElem(m2 MatrixExp) MatrixExp

DivElem performs element-wise division.

func (*Sub) Err

func (m1 *Sub) Err() error

Err returns the first error encountered while constructing the matrix expression.

func (*Sub) Eval

func (m1 *Sub) Eval() MatrixLiteral

Eval returns a matrix literal.

func (*Sub) Mul

func (m1 *Sub) Mul(m2 MatrixExp) MatrixExp

Mul performs matrix multiplication.

func (*Sub) MulElem

func (m1 *Sub) MulElem(m2 MatrixExp) MatrixExp

MulElem performs element-wise multiplication.

func (*Sub) Scale

func (m1 *Sub) Scale(c float64) MatrixExp

Scale performs scalar multiplication.

func (*Sub) String

func (m1 *Sub) String() string

String implements the Stringer interface.

func (*Sub) Sub

func (m1 *Sub) Sub(m2 MatrixExp) MatrixExp

Sub subtracts the right matrix from the left matrix.

func (*Sub) T

func (m1 *Sub) T() MatrixExp

T transposes a matrix.

type T

type T struct {
	M MatrixExp
}

T represents a transposed matrix expression.

func (*T) Add

func (m1 *T) Add(m2 MatrixExp) MatrixExp

Add two matrices together.

func (*T) At

func (m1 *T) At(r, c int) float64

At returns the value at a given row, column index.

func (*T) Copy

func (m1 *T) Copy() MatrixExp

Copy creates a (deep) copy of the Matrix Expression.

func (*T) Dims

func (m1 *T) Dims() (r, c int)

Dims returns the matrix dimensions.

func (*T) DivElem

func (m1 *T) DivElem(m2 MatrixExp) MatrixExp

DivElem performs element-wise division.

func (*T) Err

func (m1 *T) Err() error

Err returns the first error encountered while constructing the matrix expression.

func (*T) Eval

func (m1 *T) Eval() MatrixLiteral

Eval returns a matrix literal.

func (*T) Mul

func (m1 *T) Mul(m2 MatrixExp) MatrixExp

Mul performs matrix multiplication.

func (*T) MulElem

func (m1 *T) MulElem(m2 MatrixExp) MatrixExp

MulElem performs element-wise multiplication.

func (*T) Scale

func (m1 *T) Scale(c float64) MatrixExp

Scale performs scalar multiplication.

func (*T) String

func (m1 *T) String() string

String implements the Stringer interface.

func (*T) Sub

func (m1 *T) Sub(m2 MatrixExp) MatrixExp

Sub subtracts the right matrix from the left matrix.

func (*T) T

func (m1 *T) T() MatrixExp

T transposes a matrix.

Directories

Path Synopsis
Package serial implements a matrix expression compiler.
Package serial implements a matrix expression compiler.

Jump to

Keyboard shortcuts

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