Changeset 16117 for trunk/Ohana/src/opihi/cmd.data/test/gaussj.sh
- Timestamp:
- Jan 17, 2008, 12:57:48 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.data/test/gaussj.sh (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/test/gaussj.sh
r16056 r16117 3 3 test1 4 4 test2 5 end 6 5 test3 6 test4 7 test5 8 end 9 10 # a very simple diagonal matrix equation 7 11 macro test1 8 12 $PASS = 1 … … 22 26 23 27 gaussj A B 28 if (not($STATUS)) 29 $PASS = 0 30 end 24 31 25 32 if (abs(A[0][0] - 0.75) > 0.01) … … 64 71 end 65 72 73 # a very simple off-diagonal matrix equation 66 74 macro test2 67 75 $PASS = 1 … … 81 89 82 90 gaussj A B 91 if (not($STATUS)) 92 $PASS = 0 93 end 83 94 84 95 # echo A[0][0] A[0][1] A[0][2] … … 127 138 end 128 139 140 # a singular matrix equation 141 macro test3 142 $PASS = 1 143 break -auto off 144 145 mcreate A 3 3 146 create B 0 3 147 148 A[0][0] = 2 149 A[1][0] = 2 150 A[2][2] = 2 151 152 A[0][1] = -1 153 A[1][1] = -1 154 A[2][1] = -1 155 156 gaussj -q A B 157 if ($STATUS) 158 $PASS = 0 159 end 160 end 161 162 # a very large matrix equation 163 macro test4 164 $PASS = 1 165 break -auto off 166 167 $Ndim = 50 168 mcreate A $Ndim $Ndim 169 create B 0 $Ndim 170 171 # generate the diagonal + off-diagonal elements 172 for i 0 $Ndim 173 A[$i][$i] = 2.0 174 if ($i > 0) 175 A[$i][$i-1] = -1.0 176 end 177 if ($i < $Ndim - 1) 178 A[$i][$i+1] = -1.0 179 end 180 end 181 182 set inB = B 183 set inA = A 184 185 gaussj A B 186 if (not($STATUS)) 187 $PASS = 0 188 end 189 190 set meas = zero(inB) 191 for i 0 B[] 192 for j 0 B[] 193 meas[$i] = meas[$i] + inA[$i][$j] * B[$j] 194 end 195 end 196 197 for i 0 inB[] 198 if (abs(inB[$i]-meas[$i]) > 1e-3) 199 $PASS = 0 200 echo inB[$i] meas[$i] {inB[$i]-meas[$i]} 201 end 202 end 203 end 204 205 # a nearly singular matrix equation 206 macro test5 207 $PASS = 1 208 break -auto off 209 210 delete A B inA inB meas 211 212 mcreate A 3 3 213 create B 0 3 214 215 A[0][0] = 2 216 A[1][0] = 2.00001 217 A[2][2] = 2 218 219 A[0][1] = -1 220 A[1][1] = -1 221 A[2][1] = -1 222 223 set inB = B 224 set inA = A 225 226 gaussj A B 227 if (not($STATUS)) 228 $PASS = 0 229 end 230 231 set meas = zero(inB) 232 for i 0 B[] 233 for j 0 B[] 234 meas[$i] = meas[$i] + inA[$i][$j] * B[$j] 235 end 236 end 237 238 for i 0 inB[] 239 if (abs(inB[$i]-meas[$i]) > 1e-5) 240 $PASS = 0 241 end 242 end 243 end 244
Note:
See TracChangeset
for help on using the changeset viewer.
