IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 17, 2008, 12:57:48 PM (19 years ago)
Author:
eugene
Message:

cleanups for gaussj, fft; update tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/test/gaussj.sh

    r16056 r16117  
    33 test1
    44 test2
    5 end
    6 
     5 test3
     6 test4
     7 test5
     8end
     9
     10# a very simple diagonal matrix equation
    711macro test1
    812 $PASS = 1
     
    2226
    2327 gaussj A B
     28 if (not($STATUS))
     29   $PASS = 0
     30 end
    2431
    2532 if (abs(A[0][0] - 0.75) > 0.01)
     
    6471end
    6572
     73# a very simple off-diagonal matrix equation
    6674macro test2
    6775 $PASS = 1
     
    8189
    8290 gaussj A B
     91 if (not($STATUS))
     92   $PASS = 0
     93 end
    8394
    8495 # echo A[0][0] A[0][1] A[0][2]
     
    127138end
    128139
     140# a singular matrix equation
     141macro 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
     160end
     161
     162# a very large matrix equation
     163macro 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
     203end
     204
     205# a nearly singular matrix equation
     206macro 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
     243end
     244
Note: See TracChangeset for help on using the changeset viewer.