1
# ---------------------------------------------------------------------------
3
# - afnix:mth module algebra test unit -
4
# ---------------------------------------------------------------------------
5
# - This program is free software; you can redistribute it and/or modify -
6
# - it provided that this copyright notice is kept intact. -
8
# - This program is distributed in the hope that it will be useful, but -
9
# - without any warranty; without even the implied warranty of -
10
# - merchantability or fitness for a particular purpose. In no event shall -
11
# - the copyright holder be liable for any direct, indirect, incidental or -
12
# - special damages arising in any way out of the use of this software. -
13
# ---------------------------------------------------------------------------
14
# - copyright (c) 1999-2015 amaury darsch -
15
# ---------------------------------------------------------------------------
17
# @info qmr krylov solver test unit
18
# @author amaury darsch
21
interp:library "afnix-mth"
23
# this procedure checks the qmr solver with a matrix
24
const mth-qmr-ckt-3 nil {
26
const am (afnix:mth:Rmatrix 3)
32
# create the initial vector
33
const bv (afnix:mth:Rvector 3)
35
# create the result vector
36
const rv (afnix:mth:Rvector 3)
40
# create a tqmr solver
41
trans slv (afnix:mth:Tqmr am)
42
slv:set-max-iterations 6
44
trans xv (slv:solve bv)
46
assert true (xv:?= rv)
47
# create a preconditioner vector
48
const mv (afnix:mth:Rvector 3)
52
# create a tqmr solver
53
trans slv (afnix:mth:Tqmr am mv)
54
slv:set-max-iterations 6
56
trans xv (slv:solve bv)
58
assert true (xv:?= rv)
61
# this procedure checks the qmr with a matrix
62
const mth-qmr-ckt-9 nil {
64
const am (afnix:mth:Rmatrix 9)
85
# create the initial vector
86
const bv (afnix:mth:Rvector 9)
88
# create the result vector
89
const rv (afnix:mth:Rvector 9)
99
# create a tqmr solver
100
trans slv (afnix:mth:Tqmr am)
101
slv:set-max-iterations 18
103
trans xv (slv:solve bv)
105
assert true (xv:?= rv)
106
# create a preconditioner vector
107
const mv (afnix:mth:Rvector 9)
117
# create a tqmr solver
118
trans slv (afnix:mth:Tqmr am mv)
119
slv:set-max-iterations 18
121
trans xv (slv:solve bv)
123
assert true (xv:?= rv)
126
# this procedure checks the qmr with a random matrix
127
const mth-qmr-rnd (size) {
130
# create a random matrix and vector
131
const am (afnix:mth:get-random-r-matrix size 100.0 true)
132
const rv (afnix:mth:get-random-r-vector size 100.0)
134
# check matrix and vector size
135
assert size (am:get-row-size)
136
assert size (am:get-col-size)
137
assert size (rv:get-size)
139
# create an linear system vector
141
# create a tqmr solver
142
trans slv (afnix:mth:Tqmr am)
143
slv:set-max-iterations mni
145
assert true (afnix:mth:tqmr-p slv)
146
assert true (afnix:mth:solver-p slv)
147
assert true (afnix:mth:iterative-p slv)
148
assert "Tqmr" (slv:repr)
150
trans xv (slv:solve bv)
152
assert true (rv:?= xv)