1 /*
2   Teem: Tools to process and visualize scientific data and images             .
3   Copyright (C) 2012, 2011, 2010, 2009  University of Chicago
4   Copyright (C) 2008, 2007, 2006, 2005  Gordon Kindlmann
5   Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998  University of Utah
6 
7   This library is free software; you can redistribute it and/or
8   modify it under the terms of the GNU Lesser General Public License
9   (LGPL) as published by the Free Software Foundation; either
10   version 2.1 of the License, or (at your option) any later version.
11   The terms of redistributing and/or modifying this software also
12   include exceptions to the LGPL that facilitate static linking.
13 
14   This library is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17   Lesser General Public License for more details.
18 
19   You should have received a copy of the GNU Lesser General Public License
20   along with this library; if not, write to Free Software Foundation, Inc.,
21   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 */
23 
24 
25 #include "teem/air.h"
26 
27 /*
28 ** Tests:
29 ** airRandMTStateNew
30 ** airRandMTStateNix
31 ** airSrandMT_r
32 ** airRandMT
33 **
34 ** Also uses:
35 ** airMopNew, airMopAdd, airMopError, airMopDone
36 */
37 
38 #define NUM 10
39 int
main(int argc,const char * argv[])40 main(int argc, const char *argv[]) {
41   airArray *mop;
42   airRandMTState *rng;
43   const char *me;
44   unsigned int rval[NUM][NUM] = {
45     {2357136044u, 2546248239u, 3071714933u, 3626093760u, 2588848963u,
46      3684848379u, 2340255427u, 3638918503u, 1819583497u, 2678185683u},
47     {1608637542u, 3421126067u, 4083286876u, 787846414u, 3143890026u,
48      3348747335u, 2571218620u, 2563451924u, 670094950u, 1914837113u},
49     {197744554u, 2405527281u, 1590178649u, 2055114040u, 1040749045u,
50      1355459964u, 2699301070u, 1591340141u, 4252490304u, 3121394926u},
51     {451710822u, 4140706415u, 550374602u, 880776961u, 375407235u,
52      576831824u, 495976644u, 1350392909u, 3211465673u, 1227650870u},
53     {2567526101u, 397661439u, 2237017401u, 316000557u, 1060138423u,
54      2802111455u, 1449535759u, 751581949u, 3635455645u, 658021748u},
55     {429171210u, 2009581671u, 1300722668u, 3858470021u, 3363216262u,
56      1963629412u, 2166299591u, 229689286u, 484002369u, 2062223911u},
57     {23250075u, 3670330222u, 1860540774u, 4216169317u, 1062279565u,
58      2886996639u, 2197431119u, 3112004045u, 3229777453u, 1632140913u},
59     {2869147098u, 1558248213u, 585501645u, 3600180646u, 2654279825u,
60      3658135664u, 287832047u, 912891514u, 2926707351u, 937957965u},
61     {1891499427u, 1885608988u, 3850740167u, 3832766153u, 2073041664u,
62      3289176644u, 989474400u, 2841420218u, 4096852366u, 1816963771u},
63     {2552602868u, 2086504389u, 219288614u, 3347214808u, 215326247u,
64      3609464630u, 3506494207u, 997691580u, 1726903302u, 3302470737u}
65   };
66   unsigned int ii, jj, rr;
67 
68   AIR_UNUSED(argc);
69   me = argv[0];
70 
71   mop = airMopNew();
72   rng = airRandMTStateNew(0);
73   airMopAdd(mop, rng, (airMopper)airRandMTStateNix, airMopAlways);
74   for (jj=0; jj<NUM; jj++) {
75     airSrandMT_r(rng, 42*jj);
76     for (ii=0; ii<NUM; ii++) {
77       rr = airUIrandMT_r(rng);
78       if (rval[jj][ii] != rr) {
79         fprintf(stderr, "%s: rval[%u][%u] %u != %u\n",
80                 me, jj, ii, rval[jj][ii], rr);
81         airMopError(mop);
82         exit(1);
83       }
84     }
85   }
86 
87   airMopOkay(mop);
88   exit(0);
89 }
90 
91 
92 
93