matrix

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dimension

type Dimension struct {
	Width  int
	Height int
}

type Matrix

type Matrix[T constraints.Integer | constraints.Float] struct {
	Dimensions Dimension
	Values     [][]T
}

func New

func New[T constraints.Integer | constraints.Float](err *error, values ...[]T) Matrix[T]

New instantiates a Matrix with the passed values.

func NewIdentity

func NewIdentity[T constraints.Integer | constraints.Float](err *error, dim Dimension) Matrix[T]

NewIdentity instantiates an identity matrix of the specified dimensions.

func NewZero

func NewZero[T constraints.Integer | constraints.Float](err *error, dim Dimension) Matrix[T]

NewZero instantiates a zero matrix of the specified dimensions.

func (Matrix[T]) Add

func (a Matrix[T]) Add(err *error, b Matrix[T]) Matrix[T]

Add a matrix to another one. The dimensions of the matrices must match.

func (Matrix[T]) ApproxEqual

func (a Matrix[T]) ApproxEqual(b Matrix[T], errorMargin T) bool

func (Matrix[T]) Clone

func (a Matrix[T]) Clone() Matrix[T]

func (Matrix[T]) Equal

func (a Matrix[T]) Equal(b Matrix[T]) bool

func (Matrix[T]) Inverse

func (a Matrix[T]) Inverse(err *error) Matrix[T]

Inverse a matrix TODO: figure out how to handle integers properly.

func (Matrix[T]) Multiply

func (a Matrix[T]) Multiply(err *error, b Matrix[T]) Matrix[T]

Multiply multiplies the matrix by another matrix. The height of matix B must match the width of matrix A.

func (Matrix[T]) MultiplyScalar

func (a Matrix[T]) MultiplyScalar(err *error, x T) Matrix[T]

MultiplyScalar multiplies the Matrix by a scalar.

func (Matrix[T]) String

func (a Matrix[T]) String() string

func (Matrix[T]) Subtract

func (a Matrix[T]) Subtract(err *error, b Matrix[T]) Matrix[T]

Subtract a matrix from another one. The dimensions of the matrices must match.

func (Matrix[T]) Transpose

func (a Matrix[T]) Transpose(err *error) Matrix[T]

Transpose calculates the transpose of a Matrix.

Jump to

Keyboard shortcuts

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