Documentation
¶
Overview ¶
Package matrix provides basic matrix operations.
Index ¶
- Variables
- type Matrix
- func Diag(es ...float64) *Matrix
- func Eye(m, n int) *Matrix
- func Load(r io.Reader) (a *Matrix, err error)
- func LoadFile(name string) (*Matrix, error)
- func NormRand(m, n int) *Matrix
- func Ones(m, n int) *Matrix
- func Rand(m, n int) *Matrix
- func Vector(es ...float64) *Matrix
- func Zeros(m, n int) *Matrix
- func (a *Matrix) Add(b *Matrix) *Matrix
- func (a *Matrix) Copy() *Matrix
- func (a *Matrix) Det() float64
- func (a *Matrix) Dim() (int, int)
- func (a *Matrix) Div(b *Matrix) *Matrix
- func (a *Matrix) Dump(w io.Writer) error
- func (a *Matrix) DumpFile(name string) error
- func (a *Matrix) Get(i, j int) float64
- func (a *Matrix) Inv() *Matrix
- func (a *Matrix) Mul(b *Matrix) *Matrix
- func (a *Matrix) Scale(s float64) *Matrix
- func (a *Matrix) Set(i, j int, e float64) *Matrix
- func (a *Matrix) String() string
- func (a *Matrix) Sub(b *Matrix) *Matrix
- func (a *Matrix) Tran() *Matrix
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidDim = errors.New("matrix: invalid dimension") ErrInvalidMatrix = errors.New("matrix: invalid matrix") ErrSingularMatrix = errors.New("matrix: singular matrix") )
Errors.
Functions ¶
This section is empty.
Types ¶
type Matrix ¶
type Matrix struct {
// contains filtered or unexported fields
}
Matrix represents a matrix.
Example ¶
package main
import (
"fmt"
"log"
"gitee.com/ofunc/matrix"
)
func main() {
const filename = "example.out"
// Create random matrix.
a := matrix.Rand(8, 8)
b := matrix.Rand(8, 8)
// Do mul operation.
c := a.Mul(b)
// DumpFile dumps the matrix to file.
if err := c.DumpFile(filename); err != nil {
log.Fatal(err)
}
// LoadFile loads the matrix from file.
d, err := matrix.LoadFile(filename)
if err != nil {
log.Fatal(err)
}
// Print the matrix.
fmt.Println(d)
}
Click to show internal directories.
Click to hide internal directories.