golis

package module
v0.0.0-...-ade3df6 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2018 License: MIT Imports: 11 Imported by: 0

README

Coverage Status Build Status Go Report Card GoDoc GitHub license

golis

Golang implementation of lis

Install golis
go get -u github.com/Konstantin8105/golis
Install lis

See documentation of lis software.

Example of install in UserDirectory:

# clone Git repository
git clone https://github.com/anishida/lis.git

# enter in folder
cd lis

# run configuration with quadriple precision
./configure --prefix=<<UserDirectory>>/lis --enable-quad --enable-omp

# install
make install

Example of install in folder $GOPATH/src/github.com/Konstantin8105/golis/bin/:

./.travis.sh

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
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

func ParseSparseMatrix(b []byte) (mat.Matrix, error)

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

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.

Jump to

Keyboard shortcuts

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