Differences From Artifact [7f1f1540c3]:

To Artifact [c6ddc893b1]:


1
2
3
4
5
6
7
8
9
10



11
12
13
14
15
16
17
#!/bin/sh

# Generates function header for a computer language
# PJ Gawthrop May 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.5  1998/07/25 20:42:30  peterg
## No assignements for switch either
##
## Revision 1.4  1998/07/25 10:43:10  peterg
## No assignments of x or u if sm rep.
##
## Revision 1.3  1998/07/19 15:52:15  peterg










>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh

# Generates function header for a computer language
# PJ Gawthrop May 1998

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.6  1998/07/27 20:30:39  peterg
## Mods for dm rep - no globals ...
##
## Revision 1.5  1998/07/25 20:42:30  peterg
## No assignements for switch either
##
## Revision 1.4  1998/07/25 10:43:10  peterg
## No assignments of x or u if sm rep.
##
## Revision 1.3  1998/07/19 15:52:15  peterg
32
33
34
35
36
37
38

39
40
41
42
43
44
45
language=$3
args=$4
output=$5
extras=$6

case $language in
    m)

	ext='m';
	Lc='#';
	Rc='#';
	Lb='(';
	Rb=')';
	;;
    c)







>







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
language=$3
args=$4
output=$5
extras=$6

case $language in
    m)
	modeline='% -*-octave-*- Put Emacs into octave-mode';
	ext='m';
	Lc='#';
	Rc='#';
	Lb='(';
	Rb=')';
	;;
    c)
55
56
57
58
59
60
61



62
63
64
65
66
67
68
	Rc='*/';
	Lb='[';
	Rb=']';
	;;
    *)
	echo Language $language not supported - sorry; exit 1
esac




######### Octave (matlab) code
if [ "$language" = m ]; then
cat <<EOF
function $output = $1_$rep($args);
% $output = $1_$rep($args);
%System $system, representation $rep, language $language;







>
>
>







59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
	Rc='*/';
	Lb='[';
	Rb=']';
	;;
    *)
	echo Language $language not supported - sorry; exit 1
esac

# Appropriate emacs mode line
echo $modeline

######### Octave (matlab) code
if [ "$language" = m ]; then
cat <<EOF
function $output = $1_$rep($args);
% $output = $1_$rep($args);
%System $system, representation $rep, language $language;
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
$extras
EOF
fi

# Globals
sympar2global_txt2lang $1 $language

if [ "$language" = "c" ] || [ "$language" = "m" ]; then
  if [ "$rep" != "sm" ]&&[ "$rep" != "dm" ]&&[ "$rep" != "switch" ]; then
  # Common part - ode (c and m)
  # Use octave for this bit - needs the definition file
  $MATRIX -q  <<EOF 
    %System structure
    [nx,ny,nu,nz,nyz] = $1_def;

  printf("$Lc====== Set up the state variables ======$Rc\n");
  for i = 1:nx
    printf("  mttx%i = mttx$Lb%i$Rb;\n",i,i);
  end;
  printf("\n");

  printf("$Lc====== Set up the input variables ======$Rc\n");
  for i = 1:nu
  printf("  mttu%i = mttu$Lb%i$Rb;\n",i,i);
  end;
  printf("\n");

EOF
 fi
fi
#if [ "$language" = "java" ]; then

#$MATRIX -q <<EOF   
#    printf("JAVA\n");
#EOF

#fi








|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
$extras
EOF
fi

# Globals
sympar2global_txt2lang $1 $language

## if [ "$language" = "c" ] || [ "$language" = "m" ]; then
##   if [ "$rep" != "sm" ]&&[ "$rep" != "dm" ]&&[ "$rep" != "switch" ]; then
##   # Common part - ode (c and m)
##   # Use octave for this bit - needs the definition file
##   $MATRIX -q  <<EOF 
##     %System structure
##     [nx,ny,nu,nz,nyz] = $1_def;
## 
##   printf("$Lc====== Set up the state variables ======$Rc\n");
##   for i = 1:nx
##     printf("  mttx%i = mttx$Lb%i$Rb;\n",i,i);
##   end;
##   printf("\n");
## 
##   printf("$Lc====== Set up the input variables ======$Rc\n");
##   for i = 1:nu
##   printf("  mttu%i = mttu$Lb%i$Rb;\n",i,i);
##   end;
##   printf("\n");
## 
## EOF
##  fi
## fi
## #if [ "$language" = "java" ]; then

#$MATRIX -q <<EOF   
#    printf("JAVA\n");
#EOF

#fi


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]