Debian Codegraph @

contrib/ms-sbvar/utilities_dw/test_routines/matrix_test/c++/matrix_test.hpp

raw symbols SCIP
1 /*
2 * Copyright (C) 1996-2011 Daniel Waggoner
3 *
4 * This free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * It is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * If you did not received a copy of the GNU General Public License
15 * with this software, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef __MATRIX_TEST__
19 #define __MATRIX_TEST__
20
21 #include <iostream>
22 //#include <ostream>
23 #include <math.h>
24 #include <stdlib.h>
25
26 #include "dw_matrix.h"
27 #include "dw_rand.h"
28 #include "dw_matrix_rand.h"
29 #include "dw_std.h"
30
31 using namespace std;
32
33 // throw values
34 #define ERR_INDEX_OUT_OF_RANGE 1
35 #define ERR_MEM_FAILURE 2
36 #define ERR_STRING_SYNTAX 3
37 #define ERR_NULL_TEST_SIZES 4
38 #define ERR_ARG_TYPE 5
39
40 // Argument and return types
41 #define dw_void_type 1
42 #define dw_PRECISION_type 2
43 #define dw_int_type 3
44 #define dw_TVector_type 4
45 #define dw_TMatrix_type 5
46 #define dw_int_size_type 6
47 #define dw_TMatrix_U_type 7
48 #define dw_TMatrix_L_type 8
49 #define dw_TMatrix_S_type 9
50 #define dw_TMatrix_SPD_type 10
51 #define dw_pInteger_type 11
52 #define dw_TPermutation_type 12
53
54 // Argument errors
55 #define ARG_ERR_GENERAL 0x01
56 #define ARG_ERR_SIZE 0x02
57 #define ARG_ERR_NULL 0x04
58
59 //=== TArg ======================================================================
60 class TArg
61 {
62 public:
63 virtual int type(void) = 0;
64 virtual void Allocate(void) { };
65 virtual void Initialize(void) = 0;
66 };
67
68 class TArg_pointer : public TArg
69 {
70 protected:
71 int owner;
72 int null_OK;
73 int change_OK;
74
75 public:
76 TArg_pointer() { owner=0; null_OK=0; change_OK=0; };
77
78 void SetNullOK(int b) { null_OK = b ? 1 : 0; };
79 int IsNullOK(void) { return null_OK; };
80 void SetChangeOK(int b) { change_OK = b ? 1 : 0; };
81 int IsChangeOK(void) { return change_OK; };
82 int Owner(void) { return owner; };
83
84 virtual void* address(void) = 0;
85 virtual void Free(void) = 0;
86 virtual void EquatePointers(TArg_pointer *p_arg) = 0;
87 virtual int Changed(void) = 0;
88 };
89
90 class TArg_sized
91 {
92 protected:
93 int n_sizes; // number of sizes
94 int **size; // pointer to size
95 unsigned char *size_char; // letter used to define size in argument string
96
97 public:
98 TArg_sized(int n);
99 ~TArg_sized();
100
101 int GetNumberSizes(void) { return n_sizes; };
102 void SetSizeReference(int *s, int i) { size[i]=s; };
103 int GetSizeReference(int i) { return *(size[i]); };
104 void SetSizeChar(char c, int i) { size_char[i]=c; };
105 char GetSizeChar(int i) { return size_char[i]; };
106
107 virtual int GetSize(int i) = 0;
108 };
109
110 class TArg_TMatrix : public TArg_pointer, public TArg_sized
111 {
112 protected:
113 TMatrix arg;
114 TMatrix copy;
115
116 public:
117 TArg_TMatrix() : TArg_sized(2) { arg=(TMatrix)NULL; copy=(TMatrix)NULL; };
118 ~TArg_TMatrix() { Free(); };
119
120 void CreateMatrices(int row, int col);
121 TMatrix& GetArg(void) { return arg; };
122 TMatrix& GetCopy(void) { return copy; };
123
124 // TArg virtual functions
125 virtual int type(void) { return dw_TMatrix_type; };
126 virtual void Allocate(void) { CreateMatrices(*(size[0]),*(size[1])); };
127 virtual void Initialize(void) { if (arg && owner) EquateMatrix(copy,dw_NormalMatrix(arg)); };
128
129 // Pointer virtual functions
130 virtual void* address(void) { return arg; };
131 virtual void Free(void);
132 virtual void EquatePointers(TArg_pointer* p_arg);
133 virtual int Changed(void);
134
135 // Size virtual functions
136 virtual int GetSize(int i);
137 };
138
139 class TArg_TMatrix_U : public TArg_TMatrix
140 {
141 public:
142 virtual int type(void) { return dw_TMatrix_U_type; };
143 virtual void Initialize(void);
144 virtual void EquatePointers(TArg_pointer *p_arg);
145 };
146
147 class TArg_TMatrix_L : public TArg_TMatrix
148 {
149 public:
150 virtual int type(void) { return dw_TMatrix_L_type; };
151 virtual void Initialize(void);
152 virtual void EquatePointers(TArg_pointer *p_arg);
153 };
154
155 class TArg_TMatrix_S : public TArg_TMatrix
156 {
157 public:
158 virtual int type(void) { return dw_TMatrix_S_type; };
159 virtual void Initialize(void);
160 virtual void EquatePointers(TArg_pointer *p_arg);
161 };
162
163 class TArg_TMatrix_SPD : public TArg_TMatrix_S
164 {
165 public:
166 virtual int type(void) { return dw_TMatrix_SPD_type; };
167 virtual void Initialize(void);
168 virtual void EquatePointers(TArg_pointer *p_arg);
169 };
170
171 class TArg_TVector : public TArg_pointer, public TArg_sized
172 {
173 private:
174 TVector arg;
175 TVector copy;
176
177 public:
178 TArg_TVector() : TArg_sized(1) { arg=(TVector)NULL; copy=(TVector)NULL; };
179 ~TArg_TVector() { Free(); };
180
181 void CreateVectors(int dim);
182 TVector& GetArg(void) { return arg; };
183 TVector& GetCopy(void) { return copy; };
184
185 // TArg virtual functions
186 virtual int type(void) { return dw_TVector_type; };
187 virtual void Allocate(void) { CreateVectors(*(size[0])); };
188 virtual void Initialize(void) { if (arg && owner) EquateVector(copy,dw_NormalVector(arg)); };
189
190 // Pointer virtual functions
191 virtual void* address(void) { return arg; };
192 virtual void Free(void);
193 virtual void EquatePointers(TArg_pointer* p_arg);
194 virtual int Changed(void);
195
196 // Size virtual functions
197 virtual int GetSize(int i);
198 };
199
200 class TArg_TPermutation : public TArg_pointer, public TArg_sized
201 {
202 private:
203 TPermutation arg;
204 TPermutation copy;
205
206 public:
207 TArg_TPermutation() : TArg_sized(1) { arg=(TPermutation)NULL; copy=(TPermutation)NULL; };
208 ~TArg_TPermutation() { Free(); };
209
210 void CreatePermutations(int dim);
211 TPermutation& GetArg(void) { return arg; };
212 TPermutation& GetCopy(void) { return copy; };
213
214 // TArg virtual functions
215 virtual int type(void) { return dw_TPermutation_type; };
216 virtual void Allocate(void) { CreatePermutations(*(size[0])); };
217 virtual void Initialize(void);
218
219 // Pointer virtual functions
220 virtual void* address(void) { return arg; };
221 virtual void Free(void);
222 virtual void EquatePointers(TArg_pointer* p_arg);
223 virtual int Changed(void);
224
225 // Size virtual functions
226 virtual int GetSize(int i);
227 };
228
229 class TArg_pInteger : public TArg_pointer, public TArg_sized
230 {
231 private:
232 int n;
233 int* arg;
234 int* copy;
235
236 public:
237 TArg_pInteger() : TArg_sized(1) { arg=(int*)NULL; copy=(int*)NULL; n=0; };
238 ~TArg_pInteger() { Free(); };
239
240 void CreateIntegerArray(int dim);
241 int*& GetArg(void) { return arg; };
242 int*& GetCopy(void) { return copy; };
243
244 // TArg virtual functions
245 virtual int type(void) { return dw_pInteger_type; };
246 virtual void Initialize(void);
247 virtual void EquatePointers(TArg_pointer* p_arg);
248
249 // Pointer virtual functions
250 virtual void* address(void) { return arg; };
251 virtual void Free(void);
252 virtual void Allocate(void) { CreateIntegerArray(*(size[0])); };
253 virtual int Changed(void);
254
255 // Size virtual functions
256 virtual int GetSize(int i) { if (i == 0) return n; else throw ERR_INDEX_OUT_OF_RANGE; };
257 };
258
259 class TArg_int : public TArg
260 {
261 protected:
262 int arg;
263 int copy;
264
265 public:
266 TArg_int() { arg=copy=-1; };
267
268 int& GetArg(void) { return arg; };
269 int& GetCopy(void) { return copy; };
270
271 virtual int type(void) { return dw_int_type; };
272 void Initialize(void) { arg=copy=(rand() % 10)+1; };
273 };
274
275 class TArg_int_size : public TArg_int, public TArg_sized
276 {
277 private:
278
279 public:
280 TArg_int_size() : TArg_sized(1), TArg_int() { };
281
282 // TArg virtual functions
283 virtual int type(void) { return dw_int_size_type; };
284 void Initialize(void) { arg=copy=*(size[0]); };
285
286 // Size virtual functions
287 virtual int GetSize(int i) { if (i == 0) return arg; else throw ERR_INDEX_OUT_OF_RANGE; };
288 };
289
290 class TArg_PRECISION : public TArg
291 {
292 private:
293 PRECISION arg;
294 PRECISION copy;
295
296 public:
297 TArg_PRECISION() { arg=copy=-1.0; };
298
299 PRECISION& GetArg(void) { return arg; };
300 PRECISION& GetCopy(void) { return copy; };
301
302 virtual int type(void) { return dw_PRECISION_type; };
303 void Initialize(void) { arg=copy=dw_gaussian_rnd(); };
304 };
305
306
307 //=== TReturn ===================================================================
308 class TReturn
309 {
310 public:
311 virtual int type(void) = 0;
312
313 virtual void CleanCall(void) { };
314 };
315
316 class TReturn_pointer : public TReturn
317 {
318 protected:
319 int owner;
320
321 public:
322 TReturn_pointer() { owner=0; };
323 virtual void* address(void) = 0;
324 void SetOwner(int b) { owner=b ? 1 : 0; };
325 };
326
327 class TReturn_void : public TReturn
328 {
329 public:
330 TReturn_void() { };
331 virtual int type(void) { return dw_void_type; };
332 };
333
334 class TReturn_TMatrix : public TReturn_pointer
335 {
336 protected:
337 TMatrix rtrn;
338
339 public:
340 TReturn_TMatrix() { rtrn=(TMatrix)NULL; };
341 ~TReturn_TMatrix() { if (owner && rtrn) FreeMatrix(rtrn); };
342 TMatrix& GetReturn(void) { return rtrn; };
343
344 virtual int type(void) { return dw_TMatrix_type; };
345 virtual void* address(void) { return (void*)rtrn; };
346
347 virtual void CleanCall(void)
348 { if (owner && rtrn) { FreeMatrix(rtrn); owner=0; rtrn=(TMatrix)NULL; } };
349 };
350
351 class TReturn_TVector : public TReturn_pointer
352 {
353 protected:
354 TVector rtrn;
355
356 public:
357 TReturn_TVector() { rtrn=(TVector)NULL; };
358 ~TReturn_TVector() { if (owner && rtrn) FreeVector(rtrn); };
359 TVector& GetReturn(void) { return rtrn; };
360
361 virtual int type(void) { return dw_TVector_type; };
362 virtual void* address(void) { return (void*)rtrn; };
363
364 virtual void CleanCall(void)
365 { if (owner && rtrn) { FreeVector(rtrn); owner=0; rtrn=(TVector)NULL; } };
366 };
367
368 class TReturn_TPermutation : public TReturn_pointer
369 {
370 protected:
371 TPermutation rtrn;
372
373 public:
374 TReturn_TPermutation() { rtrn=(TPermutation)NULL; };
375 ~TReturn_TPermutation() { if (owner && rtrn) FreePermutation(rtrn); };
376 TPermutation& GetReturn(void) { return rtrn; };
377
378 virtual int type(void) { return dw_TPermutation_type; };
379 virtual void* address(void) { return (void*)rtrn; };
380
381 virtual void CleanCall(void)
382 { if (owner && rtrn) { FreePermutation(rtrn); owner=0; rtrn=(TPermutation)NULL; } };
383 };
384
385 class TReturn_int : public TReturn
386 {
387 protected:
388 int rtrn;
389
390 public:
391 TReturn_int() { rtrn=-1; }
392 int& GetReturn(void) { return rtrn; };
393
394 virtual int type(void) { return dw_int_type; };
395 };
396
397 class TReturn_PRECISION : public TReturn
398 {
399 protected:
400 PRECISION rtrn;
401
402 public:
403 TReturn_PRECISION() { rtrn=-1.0; }
404 PRECISION& GetReturn(void) { return rtrn; };
405
406 virtual int type(void) { return dw_PRECISION_type; };
407 };
408
409 //=== TArgList ==================================================================
410 class TArgList
411 {
412 protected:
413 int nargs;
414 TArg **args;
415 char *arg_string;
416
417 int n_minimal_idx;
418 int *minimal_idx; // 1 <= minimal_idx[i] <= test_sizes[i][0].
419 int **test_sizes; // test_sizes[i][j] satisfies 0 <= i < n_minimal_idx and 0 <= j <= test_sizes[i][0].
420
421 int n_sizes;
422 int *sizes_idx; // 0 <= sizes_idx[i] < n_minimal_idx
423 int *correct_sizes; // correct_size[i]=test_sizes[sizes_idx[i]][minimal_idx[sizes_idx[i]]]
424 int *actual_sizes;
425
426 public:
427 TArgList() { nargs=0; args=(TArg**)NULL; arg_string=(char*)NULL; };
428 TArgList(char *string);
429 ~TArgList();
430
431 int number_args(void) {return nargs; };
432 TArg* arg(int i) { return *(args+i); };
433
434 char* GetArgumentString(void) { return arg_string; };
435 void PrintArgList(ostream &out);
436
437 int GetNumberSizes(void) { return n_sizes; };
438 int GetNumberMinimalIdx(void) { return n_minimal_idx; };
439 int* GetCorrectSizes(void) { return correct_sizes; };
440 int* GetActualSizes(void) { return actual_sizes; };
441
442 int ResetMinimalIndexes(void);
443 int IncrementMinimalIndexes(void);
444 void FreeTestSizes(void);
445 void SetTestSizes(int **ts);
446 void SetTestSizes(int n, int* ts);
447 void SetTestSizes(int min, int max);
448
449 virtual void ComputeCorrectSizes();
450 virtual void MakeSizeInvalid(int i);
451 virtual void Allocate(void);
452 virtual void Initialize(void);
453 virtual int SizesOK(void);
454 virtual int NullOK(void);
455 virtual int ArgChanged(void);
456 virtual void DefaultTestSizes(void);
457 virtual void DefaultTestSizes_Basic(void) { DefaultTestSizes(); };
458 virtual void DefaultTestSizes_InvalidSizes(void) { DefaultTestSizes(); };
459 virtual void DefaultTestSizes_InvalidNulls(void) { DefaultTestSizes(); };
460 virtual void DefaultTestSizes_EqualPointers(void) { DefaultTestSizes(); };
461 virtual void DefaultTestSizes_Speed(void) { DefaultTestSizes(); };
462 };
463
464
465 //=== TArgInc ===================================================================
466 class TArgInc
467 {
468 protected:
469 TArgList *args;
470
471 public:
472 TArgInc(TArgList* p_args);
473 TArgInc(TArgList* p_args, int** ts);
474 TArgInc(TArgList* p_args, int min, int max);
475 TArgInc(TArgList* p_args, int nts, int* ts);
476 virtual void ComputeActualSizes(void);
477 virtual int First(void) = 0;
478 virtual int Next(void) = 0;
479 };
480
481 class TArgInc_Basic : public TArgInc
482 {
483 protected:
484 int *valid_null;
485
486 public:
487 TArgInc_Basic(TArgList* p_args) : TArgInc(p_args) { valid_null=(int*)dw_malloc(args->number_args()*sizeof(int)); };
488 TArgInc_Basic(TArgList* p_args, int** ts) : TArgInc(p_args,ts) { valid_null=(int*)dw_malloc(args->number_args()*sizeof(int)); };
489 TArgInc_Basic(TArgList* p_args, int min, int max) : TArgInc(p_args,min,max)
490 { valid_null=(int*)dw_malloc(args->number_args()*sizeof(int)); };
491 TArgInc_Basic(TArgList* p_args, int nts, int* ts) : TArgInc(p_args,nts,ts)
492 { valid_null=(int*)dw_malloc(args->number_args()*sizeof(int)); };
493 ~TArgInc_Basic();
494
495 virtual int First(void);
496 virtual int Next(void);
497
498 int IncrementValidNull(void);
499 };
500
501 class TArgInc_InvalidSizes : public TArgInc
502 {
503 protected:
504 int i;
505
506 public:
507 TArgInc_InvalidSizes(TArgList* p_args) : TArgInc(p_args) { i=0; };
508 TArgInc_InvalidSizes(TArgList* p_args, int** ts) : TArgInc(p_args,ts) { i=0; };
509 TArgInc_InvalidSizes(TArgList* p_args, int min, int max) : TArgInc(p_args,min,max) { i=0; };
510 TArgInc_InvalidSizes(TArgList* p_args, int nts, int* ts) : TArgInc(p_args,nts,ts) { i=0; };
511
512 virtual void ComputeActualSizes(void);
513 virtual int First(void);
514 virtual int Next(void);
515 };
516
517 class TArgInc_InvalidNulls : public TArgInc
518 {
519 protected:
520 int i;
521
522 public:
523 TArgInc_InvalidNulls(TArgList* p_args) : TArgInc(p_args) { i=-1; };
524 TArgInc_InvalidNulls(TArgList* p_args, int** ts) : TArgInc(p_args,ts) { i=-1; };
525 TArgInc_InvalidNulls(TArgList* p_args, int min, int max) : TArgInc(p_args,min,max) { i=-1; };
526 TArgInc_InvalidNulls(TArgList* p_args, int nts, int* ts) : TArgInc(p_args,nts,ts) { i=-1; };
527
528 virtual int First(void);
529 virtual int Next(void);
530 };
531
532 class TArgInc_EqualPointers : public TArgInc
533 {
534 protected:
535 int *actual;
536 int **master;
537 int threads;
538
539 public:
540 TArgInc_EqualPointers(TArgList* p_args) : TArgInc(p_args) { SetupEqualPointers(); };
541 TArgInc_EqualPointers(TArgList* p_args, int** ts) : TArgInc(p_args,ts) { SetupEqualPointers(); };
542 TArgInc_EqualPointers(TArgList* p_args, int min, int max) : TArgInc(p_args,min,max) { SetupEqualPointers(); };
543 TArgInc_EqualPointers(TArgList* p_args, int nts, int* ts) : TArgInc(p_args,nts,ts) { SetupEqualPointers(); };
544 ~TArgInc_EqualPointers();
545
546 virtual int First(void);
547 virtual int Next(void);
548
549 void SetupEqualPointers(void);
550 int SetMaster(void);
551 int IncrementActual(void);
552 void Initialize(void);
553 };
554
555 class TArgInc_Speed : public TArgInc
556 {
557
558 public:
559 TArgInc_Speed(TArgList* p_args) : TArgInc(p_args) { };
560 TArgInc_Speed(TArgList* p_args, int** ts) : TArgInc(p_args,ts) { };
561 TArgInc_Speed(TArgList* p_args, int min, int max) : TArgInc(p_args,min,max) { };
562 TArgInc_Speed(TArgList* p_args, int nts, int* ts) : TArgInc(p_args,nts,ts) { };
563
564 virtual int First(void) { args->ResetMinimalIndexes(); ComputeActualSizes(); args->Allocate(); args->Initialize(); return 1; };
565 virtual int Next(void) { return 0; };
566 };
567
568
569 //=== TFunction =================================================================
570 class TFunction : public TArgList
571 {
572 protected:
573 TReturn *rtrn;
574
575 TArgInc *inc;
576
577 char *name;
578 int **default_test_sizes;
579
580 public:
581 TFunction(char* name_string, char *rtrn_string, char* arg_string);
582 ~TFunction();
583
584 char* GetName(void) { return name; };
585 int First(void) { return inc ? inc->First() : 0; };
586 int Next(void) { return inc ? inc->Next() : 0; };
587
588 // functions that must be defined
589 virtual int CallFunction(void) = 0;
590 virtual PRECISION ResultOK(void) = 0;
591
592 // functions may need to be redefined
593 virtual void SetReturnOwner(void);
594 virtual int ArgumentsError(void);
595 virtual void CleanCall(void) { rtrn->CleanCall(); };
596
597 virtual int TestBasic(int min=-1, int max=-1);
598 virtual int TestInvalidSizes(int min=-1, int max=-1);
599 virtual int TestInvalidNulls(int min=-1, int max=-1);
600 virtual int TestEqualPointers(int min=-1, int max=-1);
601 virtual int TestSpeed(int size=10);
602 };
603
604 #endif
605
606 /********************************************************************************
607 Virtual functions in TFunction
608
609 CallFunction - Makes the actual call to the function to be tested and calls
610 SetReturnOwner(). Returns one if the call was successful and
611 zero otherwise. This should be boilerplate from
612 matrix_test_instances.cpp and must be defined.
613
614 ResultOK - Determines if the function call correctly computed the results. The
615 return value indicates how far the results differ from the true
616 results and is compared to machine epsilon and the square root of
617 machine epsilon. In cases that this notion is not applicable, a
618 return value of 0.0 indicates success and a negative value indicates
619 failure. This function must be defined.
620
621 SetReturnOwner - Is applicable only if the TReturn class is derived from the
622 TReturn_pointer class. Determines if the return value of the
623 function needs to be freeded. If the returned pointer value is
624 not equal to the address of any of the pointer arguments passed
625 to the function, the the return will be freed. This function
626 should be redefined if the default rules do not correctly
627 determine it the returned pointer value needs to be freed.
628
629 ArgumentsError - Tries to determine if the passed arguments are valid. Checks
630 if the sizes are correct via the function SizesOK() and if null
631 pointers were correctly passed via the function NullOK(). This
632 function should be redefined if more than sizes and nulls need
633 to be checked. To change how sizes or nulls are checked, the
634 TArgList functions SizesOK() or NullOK() can be changed. A
635 return value of 0 indicates no error and a non-zero return
636 indicates the type of error encounted.
637
638 CleanCall - Performs any clean up from the function call if needed. The default
639 function will free the return value if it is a pointer and
640 SetReturnOwner() determines that the pointer need to be freeded.
641 Redefine this function to perform special cleanup.
642
643 TestBasic
644 TestInvalidSizes
645 TestInvalidNulls
646 TestEqualPointers
647 TestSpeed
648 These functions set up the test cases for the various tests. They should
649 create the appropriate TArgInc class and call the TArgInc function First().
650 These functions should be redefined only if a new derived class of TArgInc
651 needs to be used. If only the default sizes need to be changed, redefine
652 the appropriate TArgList function DefaultTestSizes(), DefaultTestSizes_Basic(),
653 DefaultTestSizes_InvalidSizes(), DefaultTestSizes_InvalidNulls(),
654 DefaultTestSizes_EqualPointers(), or DefaultTestSizes_Speed().
655
656 =================================================================================
657 Virtual functions in TArgList
658
659 Allocate - Allocates memory for each of the arguments by calling TArg function
660 Allocate() for each argument. Should be called before Initialize() is
661 called. Sizes are determined by TArgList member actual_sizes. This
662 function will rarely be redefined.
663
664 Initialize - Initializes the arguments by calling TArg function Initialize() for
665 each argument. Should be called after Allocate(). This function
666 will be redefined only if special processing is required to setup
667 the arguments.
668
669 ComputeCorrectSizes - Computes a set of valid sizes from the size information in
670 the TArgList class. This function must be redefined if
671 there is not enough information to compute all the sizes.
672
673 MakeSizeInvalid - This functions attempts to set an invalid value for a size
674 value of an argument derived from TArg_size by randomly
675 changing its value by a small amount. This function will be
676 redefined if more care is required to produce an invalid size
677 value.
678
679 SizesOK - Returns one if the sizes are all OK as determined by the size
680 information in the TArgList class. Returns zero otherwise. This
681 function must redefined if there is not enough information to
682 determine all the sizes.
683
684 NullOK - Returns one if all passed null pointers are permissible, as determined
685 by information in the TArg_pointer class. Returns zero otherwise. This
686 function will rarely be redefined.
687
688 ArgChanged - Returns one if the value of one of the arguments derived from
689 TArg_pointer has changed. This function will rarely be redefined.
690
691 DefaultTestSizes
692 DefaultTestSizes_Basic
693 DefaultTestSizes_InvalidSizes
694 DefaultTestSizes_InvalidNulls
695 DefaultTestSizes_EqualPointers
696 DefaultTestSizes_Speed
697 Determines the default size values that are permissible for each type of test.
698 These functions will be redefined is special size values are required. The
699 default size values as defined in DefaultTestSizes() are 1,2,3,7, and 10.
700 ********************************************************************************/
701
702 /********************************************************************************
703 Incrementing Arguments
704 The base of all these test routines is the ability to increment through a set
705 of argument values, testing the behavior of the function at each step. Because
706 the origins of this test bed was verification of vector and matrix functions,
707 the ability to have sized arguments and test many different combinations of
708 sizes was paramount. Also, dealing with pointer arguments was of prime
709 concern.
710
711 The basic behavior is controlled through an argument string. To illustrate
712 this, we consider the matrix function ProductMM(). Its argument string is:
713
714 "M(m,n)!+;M(m,k);M(k,n)"
715
716 The arguments are separated by semicolons. The character M denote a matrix
717 arguments and the lower case letters in parenthesis give the sizes of the
718 arguments and defines the relationship between the various sizes. For a full
719 list of argument types, see the comments before the function CheckArgString()
720 in the file matrix_test.cpp. The character '!' denotes a pointer argument that
721 can be the null pointer and the character '+' denotes a pointer argument that
722 can change in value. The size character can also take the value '?', which
723 indicates that the size relationships cannot be determined in this scheme.
724 If the size character '?' appears, then the functions ComputeCorrectSizes() and
725 SizesOK() will have to be redefined to handle these sizes.
726
727 For each distinct size character, k, m, and n in this example, the class
728 TArgList maintains a list of permissible sizes. The permissible sizes for k
729 would be in test_sizes[0], for m in test_sizes[1], and for n in test_sizes[2].
730 The number of permissible sizes for the ith size character is stored in
731 test_sizes[i][0]. The current value of the ith size character is stored in
732 minimal_idx[i] and so it must be the case that
733
734 1 <= minimal_idx[i] <= test_sizes[i][0].
735
736 The total number of sizes in this example is 6 (three sized arguments each with
737 two sizes). The array size_idx stores the size character index for each of the
738 size parameters. In this example size_idx[0]=1, size_idx[1]=2, size_idx[2]=1,
739 size_idx[3]=0, size_idx[4]=0, and size_idx[5]=2. The value of each size
740 parameter as given by the current values of the size characters is stored in
741 correct_sizes. Thus
742
743 correct_size[i]=test_sizes[sizes_idx[i]][minimal_idx[sizes_idx[i]]].
744
745 The actual value of each size parameter is given in the actual_sizes array. It
746 is these values that are are used by the TArg function Allocate() when
747 allocating memory for the arguments. Types derived from TArg_sized store the
748 address of the appropriate elements of the array actual_sizes and thus have
749 access to this information.
750
751 The functions ResetMinimalIndexes() and IncrementMinimalIndex() initialize and
752 increment the elements in minimal_idx and the function ComputeCorrectSizes()
753 fills the elements of correct_sizes. The function SizesOK() uses the values
754 of correct_sizes and sizes_idx to determine if values in actual_sizes are
755 permissible. See the function SizesOK() for details since one cannot simply
756 compare the value in actual_sizes and correct_sizes. Also, both SizesOK() and
757 ComputeCorrectSizes() must be redefined if any of the size characters are '?'.
758
759 ********************************************************************************/