IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16117


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

cleanups for gaussj, fft; update tests

Location:
trunk/Ohana/src/opihi
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/Makefile

    r16107 r16117  
    4242$(SRC)/erase.$(ARCH).o          \
    4343$(SRC)/extract.$(ARCH).o        \
    44 $(SRC)/fft1d.old.$(ARCH).o              \
    4544$(SRC)/fft1d.$(ARCH).o          \
    46 $(SRC)/fft2d.old.$(ARCH).o              \
    4745$(SRC)/fft2d.$(ARCH).o          \
    4846$(SRC)/fit2d.$(ARCH).o          \
  • trunk/Ohana/src/opihi/cmd.data/gaussj.c

    r16059 r16117  
    55  float *m, *v;
    66  double **a, **b;
    7   int i, j, N, status;
     7  int i, j, N, status, QUIET;
    88  Vector *B;
    99  Buffer *A;
     10
     11  QUIET = FALSE;
     12  if ((N = get_argument (argc, argv, "-q"))) {
     13    QUIET = TRUE;
     14    remove_argument (N, &argc, argv);
     15  }
    1016
    1117  if (argc != 3) goto usage;
     
    5056  free (b);
    5157
    52   if (!status) {
     58  if (!status && !QUIET) {
    5359      gprint (GP_ERR, "failure in matrix solution\n");
    5460  }
  • trunk/Ohana/src/opihi/cmd.data/init.c

    r16107 r16117  
    2626int erase            PROTO((int, char **));
    2727int extract          PROTO((int, char **));
    28 int fft1dold         PROTO((int, char **));
    2928int fft1d            PROTO((int, char **));
    3029int fft2d            PROTO((int, char **));
    31 int fft2dold         PROTO((int, char **));
    3230int fit2d            PROTO((int, char **));
    3331int fit              PROTO((int, char **));
     
    147145  {"erase",        erase,            "erase objects on an overlay"},
    148146  {"extract",      extract,          "extract a portion of a buffer into another buffer"},
    149   {"fft1dold",     fft1dold,         "fft on the pixel-stream in an image"},
    150147  {"fft1d",        fft1d,            "fft on the pixel-stream in an image"},
    151148  {"fft2d",        fft2d,            "fft on an image"},
    152   {"fft2dold",     fft2dold,         "fft on an image"},
    153149  {"fit",          fit,              "fit polynomial to vector pair"},
    154150  {"fit2d",        fit2d,            "fit 2-d polynomial to vector triplet"},
  • trunk/Ohana/src/opihi/cmd.data/test/fft1d.sh

    r16099 r16117  
    1515 fft1d f 0 to Frn Fin
    1616
    17  fft1dold f 0 to Fro Fio
    18 
    1917 clear
    2018 section a 0.0 0.0 1.0 0.5
    2119 lim t Fro; box; plot -pt 7 -c blue t Fro; plot -pt 2 -c red t Frn
    22 
    23  section b 0.0 0.5 1.0 0.5
    24  lim t Fio; box; plot -pt 7 -c blue t Fio; plot -pt 2 -c red t Fin
    2520end
  • 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
  • trunk/Ohana/src/opihi/include/data.h

    r16107 r16117  
    8888int IsBinary (int N, int *Nbit);
    8989
    90 // fftold.c
    91 void fftold (float *Data, int N, int isign);
    92 void fftNold (float *data, int *nn, int ndim, int isign);
    93 int IsBinaryOld (int N);
    94 
    9590/* in gaussj.c */
    9691int gaussj (double **a, int n, double **b, int m);
  • trunk/Ohana/src/opihi/lib.data/Makefile

    r16099 r16117  
    1919$(SDIR)/page.$(ARCH).o                  \
    2020$(SDIR)/fft.$(ARCH).o                   \
    21 $(SDIR)/fftold.$(ARCH).o                        \
    2221$(SDIR)/svdcmp.$(ARCH).o                \
    2322$(SDIR)/convert.$(ARCH).o               \
Note: See TracChangeset for help on using the changeset viewer.