matrix

package
v0.0.0-...-6bb0399 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayToString

func ArrayToString[number Number](array []number, separator string) string

func Malloc

func Malloc[number Number](rows, cols int) ([][]number, []number, error)

allocates memory closely for contingious memory allocation afterwards

for i := range matrix {
	matrix[i] = memory[(i * cols):((i + 1) * cols)]
}

func MatrixToString

func MatrixToString[number Number](matrix [][]number, separator string) string

func ReadSlow

func ReadSlow(path string) ([][]float64, error)

func Write

func Write[number Number](path string, matrix [][]number) error

Types

type Matrix

type Matrix struct {
	Data         [][]float64
	Rows         int
	Cols         int
	Augmented    bool
	Square       bool
	Determinants []float64
	Roots        []float64
}

func NewBlankMatrix

func NewBlankMatrix(rows, cols int, augmented bool) (*Matrix, error)

func NewMatrix

func NewMatrix(data [][]float64, augmented bool) (*Matrix, error)

func (*Matrix) AddCol

func (m *Matrix) AddCol(index int)

func (*Matrix) AddRow

func (m *Matrix) AddRow(index int)

func (*Matrix) Calculate

func (m *Matrix) Calculate() ([]float64, error)

if matrix is not square, returns nil and error

matrix is square if matrix is not augmented and rows equals cols or matrix is augmented and rows equals cols - 1

calculates determinants and roots if matrix is augmented. returns determinants, not roots

if matrix is not augmented, returns [1]number. otherwise returns [cols]number

func (*Matrix) Extend

func (m *Matrix) Extend(rows, cols int)

func (*Matrix) ExtendCols

func (m *Matrix) ExtendCols(cols int)

func (*Matrix) ExtendRows

func (m *Matrix) ExtendRows(rows int)

func (*Matrix) FillRandom

func (m *Matrix) FillRandom(upper int) error

func (*Matrix) GetAdjugate

func (m *Matrix) GetAdjugate() (newMatrix [][]float64)

func (*Matrix) GetInverse

func (m *Matrix) GetInverse() (newMatrix [][]float64)

func (*Matrix) GetRoots

func (m *Matrix) GetRoots() []float64

func (*Matrix) GetTranspose

func (m *Matrix) GetTranspose() (newMatrix [][]float64)

func (*Matrix) Multiply

func (m *Matrix) Multiply(matrix *Matrix) (newMatrix [][]float64)

func (*Matrix) Reset

func (p *Matrix) Reset()

func (*Matrix) Resize

func (m *Matrix) Resize(rows, cols int)

func (*Matrix) ResizeCols

func (m *Matrix) ResizeCols(cols int)

func (*Matrix) ResizeRows

func (m *Matrix) ResizeRows(rows int)

func (*Matrix) String

func (m *Matrix) String() string

func (*Matrix) Write

func (m *Matrix) Write(data [][]float64) error

func (*Matrix) WriteBlank

func (m *Matrix) WriteBlank(rows, cols int) error

type Number

type Number interface {
	int | float64
}

Jump to

Keyboard shortcuts

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