Documentation ¶
Index ¶
- Variables
- func Lsolve(A, b mat.Matrix, options string) (solution mat.Matrix, rhistory []float64, output string, err error)
- func ParseSparseMatrix(b []byte) (mat.Matrix, error)
- type ErrorValue
- type SparseMatrix
- func (m *SparseMatrix) Add(r, c int, value float64)
- func (m *SparseMatrix) At(r, c int) float64
- func (m *SparseMatrix) Dims() (r, c int)
- func (m *SparseMatrix) Set(r, c int, value float64)
- func (m *SparseMatrix) SetZeroForRowColumn(rc int)
- func (m *SparseMatrix) String() string
- func (m *SparseMatrix) T() mat.Matrix
- type SparseMatrixSymmetric
- func (m *SparseMatrixSymmetric) Add(r, c int, value float64)
- func (m *SparseMatrixSymmetric) At(r, c int) float64
- func (m *SparseMatrixSymmetric) Dims() (r, c int)
- func (m *SparseMatrixSymmetric) SetSym(r, c int, value float64)
- func (m *SparseMatrixSymmetric) SetZeroForRowColumn(rc int)
- func (m *SparseMatrixSymmetric) String() string
- func (m *SparseMatrixSymmetric) Symmetric() int
- func (m *SparseMatrixSymmetric) T() mat.Matrix
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var LisPath string
LisPath is location of `lis` software. For example :
golis.LisPath = "/home/user/lis/bin/"
Functions ¶
func Lsolve ¶
func Lsolve(A, b mat.Matrix, options string) ( solution mat.Matrix, rhistory []float64, output string, err error)
Lsolve returns solution matrix of iterative solve for linear system.
A * x = b
Where: A is matrix, b is right-hand vector.
Description of rhsSetting and options, see in `lis` software documentation. Some examples:
options = "-f quad" , Use quadriple precision options = "-i gmres -restart 20" , Use solver GMRES with restart 20 options = "-i bicgstab -maxiter 20000" , Use solver BiCGSTAB with max iteration 20000
func ParseSparseMatrix ¶
ParseSparseMatrix returns sparse matrix parsed from byte slice in MatrixMarket format and error, if exist
Example:
%%MatrixMarket vector coordinate real general 3 1 -5.49999999999999822364e+00 2 2.49999999999999955591e+00 3 4.99999999999999911182e+00
Types ¶
type ErrorValue ¶
type ErrorValue int
ErrorValue is error retirn value as result of `lis` software working
const ( IllOption ErrorValue = iota Breakdown OutOfMemory Maxiter NotImplemented ErrFileIO )
Constants of error values 'lis' software
func (ErrorValue) Error ¶
func (g ErrorValue) Error() string
type SparseMatrix ¶
type SparseMatrix struct {
// contains filtered or unexported fields
}
SparseMatrix is struct of sparse matrix
Example ¶
package main import ( "fmt" "os" "github.com/Konstantin8105/golis" ) func main() { s := golis.NewSparseMatrix(3, 2) for i := 0; i < 3; i++ { for j := 0; j < 2; j++ { s.Set(i, j, float64(i+j*5)) } } fmt.Fprintf(os.Stdout, "%s", s) }
Output: Amount of rows : 3 Amount of columns : 2 row column value 1 0 1.000000000000000e+00 2 0 2.000000000000000e+00 0 1 5.000000000000000e+00 1 1 6.000000000000000e+00 2 1 7.000000000000000e+00
func NewSparseMatrix ¶
func NewSparseMatrix(r, c int) *SparseMatrix
NewSparseMatrix return new sparse square matrix
func (*SparseMatrix) Add ¶
func (m *SparseMatrix) Add(r, c int, value float64)
Add is alternative of pattern m.Set(r,c, someValue + m.At(r,c)). Addition value to matrix element
func (*SparseMatrix) At ¶
func (m *SparseMatrix) At(r, c int) float64
At returns the value of a matrix element at row i, column j. It will panic if i or j are out of bounds for the matrix.
func (*SparseMatrix) Dims ¶
func (m *SparseMatrix) Dims() (r, c int)
Dims returns the dimensions of a Matrix. Where: r - amount of rows, c - amount of columns.
func (*SparseMatrix) Set ¶
func (m *SparseMatrix) Set(r, c int, value float64)
Set set value in sparse matrix by address [r,c]. If r,c outside of matrix, then create a panic. If value is not valid, then create panic.
func (*SparseMatrix) SetZeroForRowColumn ¶
func (m *SparseMatrix) SetZeroForRowColumn(rc int)
SetZeroForRowColumn set zero for all matrix element on row and column `rc`
func (*SparseMatrix) String ¶
func (m *SparseMatrix) String() string
String return standard golis string of sparse matrix
func (*SparseMatrix) T ¶
func (m *SparseMatrix) T() mat.Matrix
T returns the transpose of the Matrix. Whether T returns a copy of the underlying data is implementation dependent. This method may be implemented using the Transpose type, which provides an implicit matrix transpose.
type SparseMatrixSymmetric ¶
type SparseMatrixSymmetric struct {
// contains filtered or unexported fields
}
SparseMatrixSymmetric is struct of sparse matrix
func NewSparseMatrixSymmetric ¶
func NewSparseMatrixSymmetric(size int) *SparseMatrixSymmetric
NewSparseMatrixSymmetric return new sparse square matrix
func (*SparseMatrixSymmetric) Add ¶
func (m *SparseMatrixSymmetric) Add(r, c int, value float64)
Add is alternative of pattern m.Set(r,c, someValue + m.At(r,c)). Addition value to matrix element
func (*SparseMatrixSymmetric) At ¶
func (m *SparseMatrixSymmetric) At(r, c int) float64
At returns the value of a matrix element at row i, column j. It will panic if i or j are out of bounds for the matrix.
func (*SparseMatrixSymmetric) Dims ¶
func (m *SparseMatrixSymmetric) Dims() (r, c int)
Dims returns the dimensions of a Matrix. Where: r - amount of rows, c - amount of columns.
func (*SparseMatrixSymmetric) SetSym ¶
func (m *SparseMatrixSymmetric) SetSym(r, c int, value float64)
Set set value in sparse matrix by address [r,c]. If r,c outside of matrix, then create a panic. If value is not valid, then create panic.
func (*SparseMatrixSymmetric) SetZeroForRowColumn ¶
func (m *SparseMatrixSymmetric) SetZeroForRowColumn(rc int)
SetZeroForRowColumn set zero for all matrix element on row and column `rc`
func (*SparseMatrixSymmetric) String ¶
func (m *SparseMatrixSymmetric) String() string
func (*SparseMatrixSymmetric) Symmetric ¶
func (m *SparseMatrixSymmetric) Symmetric() int
Symmetric returns the number of rows/columns in the matrix.
func (*SparseMatrixSymmetric) T ¶
func (m *SparseMatrixSymmetric) T() mat.Matrix
T returns the transpose of the Matrix. Whether T returns a copy of the underlying data is implementation dependent. This method may be implemented using the Transpose type, which provides an implicit matrix transpose.