/[ascend]/trunk/base/generic/packages/bisect.asc
ViewVC logotype

Annotation of /trunk/base/generic/packages/bisect.asc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 27 - (hide annotations) (download)
Thu Dec 9 18:22:50 2004 UTC (21 years ago) by aw0a
File MIME type: text/plain
File size: 1531 byte(s)
Correcting package checkin
1 aw0a 27 (* This file implements a bisection search *)
2    
3     IMPORT Bisection FROM libbisect;
4     (* Bisection is the name of the init function *)
5    
6     MODEL bisect__base;
7    
8     ninputs IS_A integer;
9     x[1..ninputs] IS_A generic_real;
10     x_par[1..ninputs] IS_A generic_real;
11    
12     END bisect__base;
13    
14     MODEL bisect;
15    
16     b IS_A bisect__base;
17     ninputs IS_A integer;
18     x[1..ninputs] IS_A generic_real;
19     x_par[1..ninputs] IS_A generic_real;
20    
21     (* wire up the terms *)
22    
23     ninputs, b.ninputs ARE_THE_SAME;
24     FOR i IN [1..ninputs] CREATE
25     x[i], b.x[i] ARE_THE_SAME;
26     x_par[i], b.x_par[i] ARE_THE_SAME;
27     END;
28    
29     y[1..ninputs] IS_A generic_real; (* this is the result vector *)
30    
31     END bisect;
32    
33    
34     MODEL test_bisect REFINES bisect;
35    
36     ninputs := 4;
37     myset IS_A set OF symbol;
38     myset := ['mary','jane','sue'];
39     multipliers[myset] IS_A generic_real;
40    
41     multipliers['mary'] := 1.0;
42     multipliers['jane'] := 2.5;
43     multipliers['sue'] := 3.9;
44    
45     INITIALIZATION
46    
47     PROCEDURE set_values;
48     x[1] := 2.3;
49     x[2] := 0.5657;
50     x[3] := 0.0;
51     x[4] := 67.893;
52     END set_values;
53    
54     PROCEDURE set_values_external;
55     FOR i IN myset DO
56     EXTERNAL do_set_values(x[1..ninputs],x_par[1..ninputs],
57     multipliers[i]);
58     END;
59     END set_values_external;
60    
61     PROCEDURE bisection;
62     EXTERNAL do_bisection(x[1..ninputs],x_par[1..ninputs],y[1..ninputs]);
63     END bisection;
64    
65     PROCEDURE all;
66     RUN set_values_external;
67     RUN bisection;
68     END all;
69    
70     END test_bisect;
71    

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22