/[ascend]/trunk/models/z-emptyfor.a4c
ViewVC logotype

Contents of /trunk/models/z-emptyfor.a4c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download) (as text)
Fri Oct 29 20:54:12 2004 UTC (15 years, 9 months ago) by aw0a
File MIME type: text/x-ascend
File size: 2817 byte(s)
Setting up web subdirectory in repository
1 REQUIRE "system.a4l";
2 (* => system.a4l, basemodel.a4l *)
3 PROVIDE "z-emptyfor.a4c";
4 (*
5 * This file is part of the ASCEND Modeling Library and is released
6 * under the GNU Public License as described at the end of this file.
7 *)
8 (*
9 * This file demonstrates how associative arrays of variables and relations
10 * are handled in the case of definition over the empty set.
11 * In version ascend IV 0.8 and all previous C versions, the handling
12 * is inconsistent between FOR and non-FOR defined structures.
13 *
14 * The specified behavior is:
15 * - all cases marked (* empty *) here should compile an empty array stub.
16 * - all other cases should compile an array of the specified object even if,
17 * as in the case of ra1 and ra2, that object is not mathematically
18 * sensible. Productions such as ra1,ra2 should be allowed but warned
19 * about vociferously.
20 *
21 * An action plan to bring the compiler up to the specification is not yet
22 * in place, especially since the entire implementation strategy for
23 * associative arrays and FOR statements needs to be redesigned due to
24 * other problems in compiler instruction scheduling.
25 *)
26
27 MODEL varfor;
28 a[1..2] IS_A real;
29 b[2..1] IS_A real; (* empty_*)
30 FOR i IN [1..2] CREATE
31 c[i] IS_A real;
32 END FOR;
33
34 FOR i IN [2..1] CREATE
35 d[i] IS_A real; (* empty *)
36 END FOR;
37 END varfor;
38
39 MODEL badrelfor;
40 (* not allowed to have array of unindexed eqns. *)
41 x IS_A generic_real;
42 ra1[1..2]: x=2;
43 ra2[2..1]: x=3; (* empty*)
44 END badrelfor;
45
46 MODEL relfor;
47 x IS_A generic_real;
48 FOR i IN [1..2] CREATE
49 ra3[i]: x = i;
50 END FOR;
51 FOR i IN [2..1] CREATE
52 ra4[i]: x = i;
53 END FOR;
54 END relfor;
55
56 MODEL testfor;
57 v IS_A varfor;
58 r IS_A relfor;
59 END testfor;
60
61
62 (*
63 * z-emptyfor.a4c
64 * by Benjamin A Allan
65 * Part of the ASCEND Library
66 * $Date: 1998/06/17 19:39:35 $
67 * $Revision: 1.4 $
68 * $Author: mthomas $
69 * $Source: /afs/cs.cmu.edu/project/ascend/Repository/models/z-emptyfor.a4c,v $
70 *
71 * This file is part of the ASCEND Modeling Library.
72 *
73 * Copyright (C) 1998 Carnegie Mellon University
74 * Copyright (C) 1997 Benjamin A Allan
75 *
76 * The ASCEND Modeling Library is free software; you can redistribute
77 * it and/or modify it under the terms of the GNU General Public
78 * License as published by the Free Software Foundation; either
79 * version 2 of the License, or (at your option) any later version.
80 *
81 * The ASCEND Modeling Library is distributed in hope that it
82 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
83 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
84 * See the GNU General Public License for more details.
85 *
86 * You should have received a copy of the GNU General Public License
87 * along with the program; if not, write to the Free Software
88 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139 USA.
89 *)

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