~ubuntu-branches/ubuntu/wily/afnix/wily

« back to all changes in this revision

Viewing changes to src/mod/mth/tst/MTH0120.als

  • Committer: Package Import Robot
  • Author(s): Nobuhiro Iwamatsu
  • Date: 2015-07-11 02:00:35 UTC
  • mfrom: (10.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20150711020035-2nhpztq7s15qyc0v
Tags: 2.5.1-1
* New upstream release. (Closes: #789968)
* Update debian/control.
  - Update Standards-Version to 3.9.6.
* Add support mips64(el) and ppc64el. (Closes: #741508, #748146)
* Add patches/support-gcc-5.x.patch. (Closes: #777767)
  - Fix build with gcc-5.x.
* Add patches/Disable-NET0001.als.patch.
  - Disable test of NET0001.als.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ---------------------------------------------------------------------------
 
2
# - MTH0120.als                                                             -
 
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.                  -
 
7
# -                                                                         -
 
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
# ---------------------------------------------------------------------------
 
16
 
 
17
# @info   linear solver test unit
 
18
# @author amaury darsch
 
19
 
 
20
# get the module
 
21
interp:library "afnix-mth"
 
22
 
 
23
# this procedure checks the linear solver with a matrix
 
24
const mth-lnr-ckt-3 nil {
 
25
  # create 3x3 matrix
 
26
  const rm (afnix:mth:Rmatrix 3)
 
27
  rm:set 0 2     1.0
 
28
  rm:set 1 1 -1000.0
 
29
  rm:set 1 2     1.0
 
30
  rm:set 2 0     1.0
 
31
  rm:set 2 1     1.0
 
32
  # create the initial vector
 
33
  const bv (afnix:mth:Rvector 3)
 
34
  bv:set 0 5.0
 
35
  # create the result vector
 
36
  const rv (afnix:mth:Rvector 3)
 
37
  rv:set 0 -0.005
 
38
  rv:set 1  0.005
 
39
  rv:set 2  5.000
 
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)
 
45
  # verify result
 
46
  assert true (xv:?= rv)
 
47
}
 
48
 
 
49
# this procedure checks the linear solver with a matrix
 
50
const mth-lnr-ckt-9 nil {
 
51
  # create 9x9 matrix
 
52
  const rm (afnix:mth:Rmatrix 9)
 
53
  rm:set 0 0 -1000.0
 
54
  rm:set 0 5     1.0
 
55
  rm:set 0 6    -1.0
 
56
  rm:set 1 1 -1000.0
 
57
  rm:set 1 6     1.0
 
58
  rm:set 1 7    -1.0
 
59
  rm:set 2 2 -1000.0
 
60
  rm:set 2 7     1.0
 
61
  rm:set 2 8    -1.0
 
62
  rm:set 3 3 -1000.0
 
63
  rm:set 3 8     1.0
 
64
  rm:set 4 5     1.0
 
65
  rm:set 5 0     1.0
 
66
  rm:set 5 4     1.0
 
67
  rm:set 6 0    -1.0
 
68
  rm:set 6 1     1.0
 
69
  rm:set 7 1    -1.0
 
70
  rm:set 7 2     1.0
 
71
  rm:set 8 2    -1.0
 
72
  rm:set 8 3     1.0
 
73
  # create the initial vector
 
74
  const bv (afnix:mth:Rvector 9)
 
75
  bv:set 4 4.0
 
76
  # create the result vector
 
77
  const rv (afnix:mth:Rvector 9)
 
78
  rv:set 0  0.001
 
79
  rv:set 1  0.001
 
80
  rv:set 2  0.001
 
81
  rv:set 3  0.001
 
82
  rv:set 4 -0.001
 
83
  rv:set 5  4.000
 
84
  rv:set 6  3.000
 
85
  rv:set 7  2.000
 
86
  rv:set 8  1.000
 
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)
 
91
  # verify result
 
92
  assert true (xv:?= rv)
 
93
}
 
94
 
 
95
# this procedure checks the linear solver with a random matrix
 
96
const mth-lnr-rnd (size) {
 
97
  const imax (* size 10)
 
98
  
 
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)
 
102
  
 
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)
 
107
  
 
108
  # create an linear system vector
 
109
  const bv (* rm rv)
 
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)
 
114
  # check the solution
 
115
  assert true (rv:?= xv)
 
116
}
 
117
 
 
118
# check the linear solver
 
119
mth-lnr-ckt-3
 
120
mth-lnr-ckt-9
 
121
mth-lnr-rnd 50
 
122