8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# Copyright (C) 2000 by Peter J. Gawthrop
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.28 2001/01/17 21:16:15 geraint
## uncomment parameter assignments in .m reps
##
## Revision 1.27 2001/01/14 23:51:26 geraint
## declare parameters as variables instead of constants
##
## Revision 1.26 2001/01/07 21:22:47 geraint
|
>
>
>
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# Copyright (C) 2000 by Peter J. Gawthrop
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.26 2001/02/05 08:50:58 geraint
## Octave 2.1.x compatability.
##
## Revision 1.28 2001/01/17 21:16:15 geraint
## uncomment parameter assignments in .m reps
##
## Revision 1.27 2001/01/14 23:51:26 geraint
## declare parameters as variables instead of constants
##
## Revision 1.26 2001/01/07 21:22:47 geraint
|
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
|
echo ${ans}
}
write_DLD_header()
{
cat <<EOF
#include <octave/oct.h>
#include <octave/ov-struct.h>
#include <octave/toplev.h>
#include <math.h>
#include "useful-functions.hh"
#include "${system}_def.h"
#include "${system}_sympar.h"
#include "${system}_cr.h"
DEFUN_DLD (${system}_${rep}, args, ,
"Usage: [$output] = ${system}_${rep}($args)
Octave ${rep} representation of system ${system}
Generated by MTT on `date`")
{
octave_value_list retval;
EOF
}
map_DLD_inputs ()
{
s=${1:-""} # comma separated input list
if [ -z ${s:-""} ];then return; fi
c=`get_field ${s} 0` # count of inputs
i=0
printf " if (${c} != args.length ()) usage (\"${fun_name} expected ${c} argument(s): ${s}\");\n\n"
while [ ${i} -lt ${c} ]; do
j=${i}
i=`expr ${i} + 1`
w=`get_field ${s} ${i}` # argument name
get_arg_specific_stuff ${w}
case ${arg_type} in
"const double")
printf " ${arg_type}\t${w}\t= args(${j}).double_value ();\n"
;;
ColumnVector | Matrix | *)
printf " ${arg_type}\t${w}\t= args(${j}).%s ();\n" ${vector_value}
;;
esac
done
printf "\n"
}
declare_DLD_outputs ()
{
s=${1:-""} # comma separated output list
c=`get_field ${s} 0` # count of outputs
|
|
<
>
<
<
>
>
|
|
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
|
echo ${ans}
}
write_DLD_header()
{
cat <<EOF
#ifndef STANDALONE
#include <octave/oct.h>
#include <octave/ov-struct.h>
#include <octave/toplev.h>
#include <math.h>
#include "useful-functions.hh"
#include "${system}_cr.h"
#include "${system}_def.h"
#include "${system}_sympar.h"
DEFUN_DLD (${system}_${rep}, args, ,
"Usage: [$output] = ${system}_${rep}($args)
Octave ${rep} representation of system ${system}
Generated by MTT on `date`")
{
octave_value_list retval;
#endif // ! STANDALONE
EOF
}
map_DLD_inputs ()
{
s=${1:-""} # comma separated input list
if [ -z ${s:-""} ];then return; fi
printf "#ifndef STANDALONE\n"
c=`get_field ${s} 0` # count of inputs
i=0
printf " if (${c} != args.length ()) usage (\"${fun_name} expected ${c} argument(s): ${s}\");\n\n"
while [ ${i} -lt ${c} ]; do
j=${i}
i=`expr ${i} + 1`
w=`get_field ${s} ${i}` # argument name
get_arg_specific_stuff ${w}
case ${arg_type} in
"const double")
printf " ${arg_type}\t${w}\t= args(${j}).double_value ();\n"
;;
ColumnVector | Matrix | *)
printf " ${arg_type}\t${w}\t= args(${j}).%s ();\n" ${vector_value}
;;
esac
done
printf "#endif // ! STANDALONE\n\n"
}
declare_DLD_outputs ()
{
s=${1:-""} # comma separated output list
c=`get_field ${s} 0` # count of outputs
|
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
|
return_DLD_outputs ()
{
s=${1:-""} # comma separated output list
c=`get_field ${s} 0` # count of outputs
i=0
cat <<EOF
// END Code
EOF
while [ ${i} -lt ${c} ]; do
j=${i}
i=`expr ${i} + 1`
w=`get_field ${s} ${i}`
printf " retval (${j})\t= octave_value (${w});\n"
done
printf "\n return (retval);\n}\n"
}
# Header information
cat<<EOF
$modeline
$function $declaration
$Lc $declaration
$Lc System $system, representation $rep, language $language; $Rc
$Lc File $1_$rep.$language; $Rc
$Lc Generated by MTT on `date`; $Rc
EOF
if [ ${language} = "oct" ];then
write_DLD_header
map_DLD_inputs ${args}
undeclared=`get_extra_fields ${args:-"nil"} ${output:-"nil"}`
declare_DLD_outputs ${undeclared}
array2constant
case ${arg_type} in
Matrix)
printf " ${w}\t\t\t= zeros ${arg_size};\n"
;;
*)
;;
esac
cat <<EOF
// BEGIN Code
EOF
return_DLD_outputs ${output}
else
if [ -n "$noglobals" ]; then
cat<<EOF
## Horrible fudge to make mtt_m2p work
global ...
|
|
>
>
|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
|
return_DLD_outputs ()
{
s=${1:-""} # comma separated output list
c=`get_field ${s} 0` # count of outputs
i=0
cat <<EOF
\/\/ END Code
#ifndef STANDALONE
EOF
while [ ${i} -lt ${c} ]; do
j=${i}
i=`expr ${i} + 1`
w=`get_field ${s} ${i}`
printf " retval (${j})\t= octave_value (${w});\n"
done
cat <<EOF
return (retval);
}
#endif // ! STANDALONE
EOF
}
write_standalone_header ()
{
get_arg_specific_stuff ${output}
cat <<EOF
#ifdef STANDALONE
#include <octave/oct.h>
#include <octave/ov-struct.h>
#include "useful-functions.hh"
#include "${system}_cr.h"
#include "${system}_def.h"
#include "${system}_sympar.h"
${arg_type} F${system}_${rep} (
EOF
if [ -z ${args:-""} ]; then
printf "\tvoid"
else
c=`get_field ${args:-""} 0`
i=0
while [ ${i} -lt ${c} ]; do
i=`expr ${i} + 1`
if [ ${i} -lt ${c} ]; then
comma=","
else
comma=""
fi
w=`get_field ${args} ${i}`
get_arg_specific_stuff ${w}
printf "\t${arg_type}\t&${w}${comma}\n"
done
fi
cat <<EOF
)
{
#endif // STANDALONE
EOF
}
return_standalone_output ()
{
cat <<EOF
#ifdef STANDALONE
return ${output};
}
#endif // STANDALONE
EOF
}
# Header information
cat<<EOF
$modeline
$function $declaration
$Lc $declaration
$Lc System $system, representation $rep, language $language; $Rc
$Lc File $1_$rep.$language; $Rc
$Lc Generated by MTT on `date`; $Rc
EOF
if [ ${language} = "oct" ];then
write_standalone_header
write_DLD_header
map_DLD_inputs ${args}
undeclared=`get_extra_fields ${args:-"nil"} ${output:-"nil"}`
declare_DLD_outputs ${undeclared}
array2constant
case ${arg_type} in
Matrix)
printf " ${w}\t\t\t= zeros ${arg_size};\n"
;;
*)
;;
esac
cat <<EOF
// BEGIN Code
EOF
return_DLD_outputs ${output}
return_standalone_output
else
if [ -n "$noglobals" ]; then
cat<<EOF
## Horrible fudge to make mtt_m2p work
global ...
|