Documentation
¶
Overview ¶
Package matrix provide function and methods for matrix operations Matrix operations are done on float arrays
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( //ErrOutOfRange your basic index out of range error ErrOutOfRange = errors.New("Out of Range") )
Functions ¶
This section is empty.
Types ¶
type Matrix ¶
type Matrix struct {
// contains filtered or unexported fields
}
Matrix represents matrix object
func New ¶
New returns a new matrix provided given the order . Ie rows and cols. Values are the values of a martix as cols, If less values are provided than the order zeros are used to fill the matrix .
Example ¶
package main import ( "fmt" "github.com/Duncodes/mathlib/matrix" ) func main() { m := matrix.New(1, 2, 4, 3) fmt.Println(m) }
Output: 4 3
func NewFromArray ¶
NewFromArray creates new Matrix given a 2d sclice
Example ¶
This creates a new Matrix from [][]float64
package main import ( "fmt" "github.com/Duncodes/mathlib/matrix" ) func main() { m := matrix.NewFromArray([][]float64{{1, 2}, {1, 2}}) fmt.Println(m) }
Output:
func Zero ¶
Zero creates a zero matrix
Example ¶
package main import ( "fmt" "github.com/Duncodes/mathlib/matrix" ) func main() { m := matrix.Zero(1, 3) fmt.Println(m) }
Output: 0 0 0
func (*Matrix) Get ¶
Get gets the data item in the row and col provided, Note this is zero besed indexed.Hence the first element of the matrix is accessed using Get(0,0)
func (*Matrix) Set ¶
Set changes the data value at row , col provided. Note set has a zero base index ie the first element of the first col is accessed via Set(0,0) not Set(1,1)