#! /bin/sh
######################################
##### Model Transformation Tools #####
######################################
# Bourne shell script: cse_r2tex
# Reduce constrained-state to LaTex constrained-state equations.
# P.J.Gawthrop 10th May 199, 8th August 1991, April 1994, Jan 1995
# Copyright (c) P.J.Gawthrop, 1991, 1994.
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
# Revision 1.3 1996/11/12 09:53:59 peterg
# Reads in the params.r file now.
#
# Revision 1.2 1996/11/12 09:11:20 peterg
# Removed all the hoorrible name changes
#
# Revision 1.1 1996/11/05 09:19:28 peterg
# Initial revision
#
###############################################################
#Inform user
echo Creating $1_cse.tex
# Remove the old log file
rm -f cse_r2tex.log
# Use reduce to accomplish the transformation
reduce >cse_r2tex.log << EOF
%Read the definitions file
in "$1_def.r";
%Read the parameter file
in "$1_params.r";
%Read the simplification file
in "$1_simp.r";
%Read the constrained-state equations file
in "$1_cse.r";
OFF Echo;
OFF Nat;
%%%%OFF Exp; ON GCD;
%ON Rounded;
%Precision 5;
OUT "$1_cse.tex";
%Write out the constrained-state equations.
write "%File: $1_cse.tex";
write "%constrained-state equations";
IF MTTNx>0 THEN
FOR Row := 1:MTTNx DO
BEGIN
write"\begin{equation}";
write "\dot MTTEX", Row, " = ";
write "{";
write MTTEdX(Row,1);
write "}";
write"\end{equation}";
END;
IF MTTNy>0 THEN
FOR Row := 1:MTTNy DO
BEGIN
write"\begin{equation}";
write "MTTy", Row, " = ";
write "{";
write MTTy(Row,1);
write "}";
write"\end{equation}";
END;
IF MTTNx NEQ 0 THEN
BEGIN
write "% - E matrix";
write "\begin{equation}";
write "MTTE = \begin{pmatrix}";
FOR Row := 1:MTTNx DO
BEGIN
FOR Col := 1:MTTNx DO
BEGIN
Write "{", MTTE(Row,Col), "}";
IF Col<MTTNx THEN Write "&"
END;
IF Row<MTTNx THEN Write "\cr";
END;
Write "\end{pmatrix}";
write "\end{equation}";
END;
%write "% - E matrix";
%write "\begin{eqnarray}";
% FOR Row := 1:MTTNx DO
% BEGIN
% FOR Col := 1:MTTNx DO %IF MTTE(Row,Col) NEQ 0 THEN
% BEGIN
% Write "MTTE", Row, Col, " &=& {", MTTE(Row,Col), "}";
% IF Row<MTTNx OR Col<MTTNx THEN Write "\cr";
% END;
% END;
%write "\end{eqnarray}";
SHUT "$1_cse.tex";
quit;
EOF