Differences From Artifact [f3ef493314]:

To Artifact [2a8ad0f47a]:


32
33
34
35
36
37
38
39

40
41
42
43
44
45
46
32
33
34
35
36
37
38

39
40
41
42
43
44
45
46







-
+







# Heading
date=`date`

cat > $sys_rep.cc <<EOF
#include <octave/oct.h>

DEFUN_DLD ($sys_rep, args, ,
	   "$sys_rep was generated by MTT on $date")
	   "Usage: $sys_rep(x,u,t,par)\n$sys_rep was generated by MTT on $date")
{
  ColumnVector mttx = args(0).vector_value ();
  ColumnVector mttu = args(1).vector_value ();
  double mttt = args(2).double_value ();
  ColumnVector mttpar = args(3).vector_value ();

EOF
56
57
58
59
60
61
62
63

64
65
66
67
68
69
70
71
72
73
74


75
76
77
78


79
80
81
82


83
84
85
86
87
88
89
56
57
58
59
60
61
62

63
64
65
66
67
68
69
70
71
72
73

74
75
76
77


78
79
80
81


82
83
84
85
86
87
88
89
90







-
+










-
+
+


-
-
+
+


-
-
+
+







	echo "  ColumnVector mttdx ($Nx);" >> $sys_rep.cc
	;;
    cseo)
	echo "  ColumnVector mtty ($Ny);" >> $sys_rep.cc
	;;
    smx | smxa | smxax)
        Nxx=`echo "$Nx*$Nx" | bc`
	echo "  ColumnVector mtta ($Nxx);" >> $sys_rep.cc
	echo "  Matrix mtta ($Nx,$Nx);" >> $sys_rep.cc
	echo "  ColumnVector mttax ($Nx);" >> $sys_rep.cc
	;;
    *)
	
esac

#Extract Type info
echo '/* Types */'                >> $sys_rep.cc
grep typedef $sys_rep.C              >> $sys_rep.cc

#Extract the rep code and  converting [] to () and deleting mtt variables etc
#Extract the rep code converting [] to () and deleting mtt variables etc
#The awk part detects the begin and end of the relevant code.
echo "/* Representation $rep information */" >> $sys_rep.cc
awk '{
  if ($1=="}") writing=0;
  if ( (writing)&&(match($2,"mtt")!=1) ) print $0;
  if ( (match($1,"}")==1)&&(NF>1)) writing=0;
  if ( (writing) && !(match($2,"mtt[a-z]")==1) ) print $0;
  if (match($1,"{")==1) writing=1;
}' <$sys_rep.C |\
sed 's/\[\([0-9]*\)\]/(\1)/g' |\
sed 's/\[\(mmtti\)\]/(\1)/g' >> $sys_rep.cc
sed 's/\[\([a-z0-9_]*\)\]\[\([a-z0-9_]*\)\]/(\1,\2)/g' |\
sed 's/\[\([a-z_0-9]*\)\]/(\1)/g' >> $sys_rep.cc

# Tail
cat >> $sys_rep.cc <<EOF

EOF

case "$rep" in
107
108
109
110
111
112
113

114
115
116
117
108
109
110
111
112
113
114
115
116
117
118
119







+




	;;
    *)
	
esac

# Terminating }
echo "}" >> $sys_rep.cc;

# Convert to octave loadable code
echo Creating $sys_rep.oct
mkoctfile $sys_rep.cc


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