Overview
Comment:Zapped () in functions for sh compatibility
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: daf52efc94c26ffa9901874cc07e042470cd79a335d2035d525694e9ad507770
User & Date: gawthrop@users.sourceforge.net on 2000-12-04 08:52:40
Other Links: branch diff | manifest | tags
Context
2000-12-04
10:59:40
*** empty log message *** check-in: b9e3c0ebd6 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
08:52:40
Zapped () in functions for sh compatibility check-in: daf52efc94 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
08:36:23
Declare pi check-in: 1b7f8cc0fb user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/mtt_header from [2bdf0aef7a] to [b3875f1f0b].

8
9
10
11
12
13
14



15
16
17
18
19
20
21
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.20  2000/12/04 08:19:27  peterg
## Added switch declarations - in logic.cc
##
## Revision 1.19  2000/12/03 16:11:43  peterg
## Corrected bug in logic declatations
##
## Revision 1.18  2000/12/03 16:06:22  peterg
## Fixed bug in generating dummies
## Added logic declarations
##
271
272
273
274
275
276
277
278


279
280
281
282
283
284
285
274
275
276
277
278
279
280

281
282
283
284
285
286
287
288
289







-
+
+







	echo Language $language not supported - sorry; exit 1
esac

if [ "$rep" = "simpar" ]; then
   output=${output}${map}    # Output is simpar_map in this case
fi

function zero_matrices(){
function zero_matrices
{
## Set matrices to zero
echo
 ## echo '## Set matrices to zero'
for name in $zeromatrices; do
    case $name in
	a)
	    N=$Nx; M=$Nx
299
300
301
302
303
304
305
306


307
308
309
310
311
312
313
303
304
305
306
307
308
309

310
311
312
313
314
315
316
317
318







-
+
+







	*)
	    
    esac
    echo "   mtt$name = zeros($N,$M);"
done
}

function declare_dummies(){
function declare_dummies
{
# Get the dummies
dummies="mtt_tmp"
rm -f mtt_dummies
for dummy in $dummies; do
    grep "${dummy}[0-9]* " < ${fun_name}.m |\
    awk '{ 
          # if (match(dummy,$1)==1)
324
325
326
327
328
329
330
331


332
333
334
335
336
337
338

339


340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355


356
357
358
359
360
361
362
329
330
331
332
333
334
335

336
337
338
339
340
341
342
343
344
345

346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362

363
364
365
366
367
368
369
370
371







-
+
+







+
-
+
+















-
+
+







EOF

for dummy in $dummy_list; do
    echo '  ' $var_declaration $dummy';'
done
} # declare_dummies

function declare_switches {
function declare_switches 
{
cat <<EOF

$Lc  Declarations of switches $Rc
EOF
 strip_comments <${system}_switch.txt |\
 awk '{printf("  double %s_logic = 0;\n", tolower($1))}' 
} # declare_switches

function declare_vars(){
function declare_vars
{
# Grab the names
names=`awk '{if ($1==var_type) print tolower($4)}' var_type=$1 ${system}_struc.txt`

# Comments
cat <<EOF

$Lc  Declarations for $1 names $Rc
EOF
# Declarations
for name in $names; do
    echo '  '$var_declaration $name';'
done
}


function array2constant() {
function array2constant
{
# Parameters
if [ "$parameters" = "yes" ]; then
cat <<EOF

$Lc Parameters $Rc
EOF
sympar2par_txt2m ${system} ""  "$constant_declaration" "$minusone"
405
406
407
408
409
410
411
412

413
414
415
416
417
418
419
414
415
416
417
418
419
420

421
422
423
424
425
426
427
428







-
+









zero_matrices;

}

# Argument specific stuff
function get_arg_specific_stuff ()
function get_arg_specific_stuff 
{
    arg_name=${1:-""}
    case ${arg_name} in
	mtta | mtte)
	    arg_type="Matrix"
	    arg_size="(MTTNX,MTTNX)"
	    ;;
459
460
461
462
463
464
465
466

467
468
469
470
471
472
473
474
475
476
477
478
479
480
481

482
483
484
485
486
487
488
468
469
470
471
472
473
474

475
476
477
478
479
480
481
482
483
484
485
486
487
488
489

490
491
492
493
494
495
496
497







-
+














-
+







	    ;;
	*)
	    echo "Argument ${arg} not supported - sorry"; exit 1
    esac
}


function get_field ()
function get_field 
{ # parse comma separated string
    s=${1:-""}					# comma separated string
    i=${2:-0}					# field number in string

    if [ 0 -eq ${i} ]; then			# return number of fields
	echo ${s} |\
	awk -F\, '{ print NF }'
    else					# return ith field
	echo ${s} |\
	awk -F\, -v i=${i} '{ print $i }'
    fi
}


function get_extra_fields ()
function get_extra_fields 
{ # return list of words in s2 and not in s1
    s1=${1:-""}					# comma separated list
    s2=${2:-""}					# comma separated list

    c1=$(get_field ${s1} 0)			# count words in s1
    c2=$(get_field ${s2} 0)			# count words in s2
	
509
510
511
512
513
514
515
516

517
518
519
520
521
522
523
518
519
520
521
522
523
524

525
526
527
528
529
530
531
532







-
+







	    fi
        fi
    done
    echo ${ans}
}


function write_DLD_header ()
function write_DLD_header
{
    cat <<EOF

#include <octave/oct.h>
#include <octave/ov-struct.h>
#include <octave/toplev.h>
#include <math.h>
534
535
536
537
538
539
540
541

542
543
544
545
546
547
548
543
544
545
546
547
548
549

550
551
552
553
554
555
556
557







-
+








  octave_value_list retval;

EOF
}


function map_DLD_inputs ()
function 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
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
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







-
+













-
+







		;;
	esac
    done
    printf "\n"
}	


function declare_DLD_outputs ()
function declare_DLD_outputs 
{
    s=${1:-""}					# comma separated output list
    c=$(get_field ${s} 0)			# count of outputs
    i=0
    while [ ${i} -lt ${c} ]; do
	i=$((${i} + 1))
	w=$(get_field ${s} ${i})		# argument name
	get_arg_specific_stuff ${w}
	printf "  ${arg_type}\t${w}\t${arg_size};\n"
    done
}


function return_DLD_outputs ()
function return_DLD_outputs 
{
    s=${1:-""}					# comma separated output list
    c=$(get_field ${s} 0)			# count of outputs
    i=0
    cat <<EOF

// END Code


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