matrix

package module
v0.0.0-...-48f5281 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2020 License: GPL-3.0 Imports: 1 Imported by: 7

README

This lets me declare 2D matrices as slices. It allocates all the space for data as one lump and puts it in fullData which is not exported. It then allocates a slices of slices ands sets up the indexing.

Normally you say

m := newFMatrix2c (n_r, n_c)

where n_r and n_c are the number of rows and columns respectively. But to access elements like a matrix, you need to say m.Mat[i][j] to get to elements i and j.

We need to have different functions for different types, so newFMatrix(n, m) gives us a float32 matrix, but newBMatrix gives a boolean matrix.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BMatrix2d

type BMatrix2d struct {
	Mat [][]byte
	// contains filtered or unexported fields
}

BMatrix2d is a two dimensional array of bytes

func NewBMatrix2d

func NewBMatrix2d(n_r, n_c int) *BMatrix2d

NewBMatrix2d gives us a two dimensional matrix of m x n. We do not need the pointer to the backing store for simple use, but we keep it in case we want to resize the matrix

func (*BMatrix2d) Resize

func (mat *BMatrix2d) Resize(n_r, n_c int) *BMatrix2d

Resize takes a matrix and desired size. If the size is too small, it reallocates the backing array. If the size is big enough, but the dimensions are not right, it runs over the pointers and sets them. It will not reduce the space needed by a matrix.

func (*BMatrix2d) Size

func (mat *BMatrix2d) Size() (nrow, ncol int)

Size acts on a FMatrix2d pointer and returns the number of rows and number of columns

func (*BMatrix2d) String

func (mat *BMatrix2d) String() (s string)

String acts on a BMatrix2d pointer and returns a string with the Matrix printed out in a form that might be useful for debugging.

type FMatrix2d

type FMatrix2d struct {
	Mat [][]float32
	// contains filtered or unexported fields
}

------------------------------------------------------------

float32's

FMatrix2d is a two dimensional array of float32's

func NewFMatrix2d

func NewFMatrix2d(n_r, n_c int) *FMatrix2d

NewFMatrix2d gives us a two dimensional matrix of m x n. We do not need the pointer to the backing store for simple use, but we keep it in case we want to resize the matrix

func (*FMatrix2d) BackingDataString

func (mat *FMatrix2d) BackingDataString() (s string)

BackingDataString returns a string with the contents of the underlying array. It is only exported so the test file can get to it.

func (*FMatrix2d) Resize

func (mat *FMatrix2d) Resize(n_r, n_c int) *FMatrix2d

Resize takes a matrix and desired size. If the size is too small, it reallocates the backing array. If the size is big enough, but the dimensions are not right, it runs over the pointers and sets them. It will not reduce the space needed by a matrix.

func (*FMatrix2d) Size

func (mat *FMatrix2d) Size() (nrow, ncol int)

Size acts on a FMatrix2d pointer and returns the number of rows and number of columns

func (*FMatrix2d) String

func (mat *FMatrix2d) String() (s string)

String acts on a FMatrix2d pointer and returns a string with the Matrix printed out in a form that might be useful for debugging.

type IMatrix2d

type IMatrix2d struct {
	Mat [][]int32
	// contains filtered or unexported fields
}

------------------------------------------------------------

int32's

IMatrix2d is a two dimensional array of bytes

func NewIMatrix2d

func NewIMatrix2d(n_r, n_c int) *IMatrix2d

NewIMatrix2d gives us a two dimensional matrix of m x n for int32's.

func (*IMatrix2d) Resize

func (mat *IMatrix2d) Resize(n_r, n_c int) *IMatrix2d

Resize takes a matrix and desired size. If the size is too small, it reallocates the backing array. If the size is big enough, but the dimensions are not right, it runs over the pointers and sets them. It will not reduce the space needed by a matrix.

func (*IMatrix2d) Size

func (mat *IMatrix2d) Size() (nrow, ncol int)

Size acts on a IMatrix2d pointer and returns the number of rows and number of columns

Jump to

Keyboard shortcuts

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