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 linear solver test unit
18
# @author amaury darsch
21
interp:library "afnix-mth"
23
# this procedure checks the linear solver with a matrix
24
const mth-lnr-ckt-3 nil {
26
const rm (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 default linear solver
41
const lnr (afnix:mth:Linear)
42
# solve the system with the linear algorithm
43
const xv (lnr:solve rm bv)
44
assert true (object-p xv)
46
assert true (xv:?= rv)
49
# this procedure checks the linear solver with a matrix
50
const mth-lnr-ckt-9 nil {
52
const rm (afnix:mth:Rmatrix 9)
73
# create the initial vector
74
const bv (afnix:mth:Rvector 9)
76
# create the result vector
77
const rv (afnix:mth:Rvector 9)
87
# create a default linear solver
88
const lnr (afnix:mth:Linear)
89
# solve the system with the linear algorithm
90
const xv (lnr:solve rm bv)
92
assert true (xv:?= rv)
95
# this procedure checks the linear solver with a random matrix
96
const mth-lnr-rnd (size) {
97
const imax (* size 10)
99
# create a random matrix and vector
100
const rm (afnix:mth:get-random-r-matrix size 100.0 true)
101
const rv (afnix:mth:get-random-r-vector size 100.0)
103
# check matrix and vector size
104
assert size (rm:get-row-size)
105
assert size (rm:get-col-size)
106
assert size (rv:get-size)
108
# create an linear system vector
110
# create a default linear solver
111
const lnr (afnix:mth:Linear)
112
# solve the system with the linear algorithm
113
const xv (lnr:solve rm bv)
115
assert true (rv:?= xv)
118
# check the linear solver