#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: smc_r2tex
# Reduce constrained-state matrices to LaTex constrained-state matrices.
# P.J.Gawthrop  January 8th 1997
# Copyright (c) P.J.Gawthrop, 1997

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.2  2000/08/24 11:43:42  peterg
## Include subs file
##
## Revision 1.1  1998/01/22 13:25:55  peterg
## Initial revision
##
###############################################################


# Inform user
echo Creating $1_smc.tex

# Remove the old log file
rm -f smc_r2tex.log

# Use reduce to accomplish the transformation
$SYMBOLIC >smc_r2tex.log<< EOF

%Read the definitions file
in "$1_def.r";

%Read the smconical-form matrices file
in "$1_smc.r";

%Read the substitution file
in "$1_subs.r";

%Read the simplification file
in "$1_simp.r";

%Read the formatting function
in "$MTTPATH/trans/latex_matrix.r";

OFF Echo;
OFF Nat;
OFF EXP;
%ON Rounded;
%Precision 5;


OUT "$1_smc.tex";

%Write out the canonical matrices
write "%Canonical-form  matrices $1";
write "%File: $1_smc.tex";
write"";


% Controllable form
MTT_Matrix := MTTA_c$ 
MTT_Matrix_name := "MTTA_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTB_c$ 
MTT_Matrix_name := "MTTB_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := 1$
LaTeX_Matrix()$

MTT_Matrix := MTTC_c$ 
MTT_Matrix_name := "MTTC_c"$
MTT_Matrix_n := 1$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

MTT_Matrix := MTTD_c$ 
MTT_Matrix_name := "MTTD_c"$
MTT_Matrix_n := 1$
MTT_Matrix_m := 1$
LaTeX_Matrix()$

write "%  - Controllability matrix";
MTT_Matrix := MTTCon$ 
MTT_Matrix_name := "MTTCon"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  -Controllability matrix - controller form";
MTT_Matrix := MTTCon_c$ 
MTT_Matrix_name := "MTTCon_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$

write "%  - Transformation matrix - controller form";
MTT_Matrix := MTTT_c$ 
MTT_Matrix_name := "MTTT_c"$
MTT_Matrix_n := MTTNx$
MTT_Matrix_m := MTTNx$
LaTeX_Matrix()$


SHUT "$1_smc.tex";
quit;
EOF
