linsolve: for sparse matrix
Konstantin8105 opened this issue · 1 comments
Konstantin8105 commented
Hello,
Now, design in linsolve/iterative.go is:
func Iterative(a MulVecToer, b *mat.VecDense, ...
Matrix a
have matrix interface:
type MulVecToer interface {
// MulVecTo computes A*x or Aᵀ*x and stores the result into dst.
MulVecTo(dst *mat.VecDense, trans bool, x mat.Vector)
}
For my sparse matrix in my rep cannot implement that interface MulVecToer
.
Could you replace type of variable a
into type func(trans bool, x mat.Vector)
.
So, example linsolve/iterative_example_test.go
look like:
...
ATx := func(trans bool, x mat.Vector){
a.MulVecTo(mat.NewVecDense(dim, nil), trans, x)
}
result, err := linsolve.Iterative(ATx, sys.B, &linsolve.CG{}, nil)
if err != nil {
fmt.Println("Error:", err)
return
}
...
So, design in linsolve/iterative.go in my point of view:
func Iterative(a func(trans bool, x mat.Vector), b *mat.VecDense, ...
Feel free for ignore.
Konstantin8105 commented
Excuse me, I find the solution without changes