Overview
Comment:Removed octave_value_list wrappers from standalone.exe - speed improvements
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 2b317a41b75754f6b9b4f26498cad3d4ef57e6c151d0898c67f84912f3902e9e
User & Date: geraint@users.sourceforge.net on 2001-02-14 06:06:34
Other Links: branch diff | manifest | tags
Context
2001-02-17
03:48:17
Use assignment LHS to gather tmp variable names.
Prevents collection of long expressions, eg: tmp34*(tmp75
check-in: f4fd201171 user: geraint@users.sourceforge.net tags: origin/master, trunk
2001-02-14
06:06:34
Removed octave_value_list wrappers from standalone.exe - speed improvements check-in: 2b317a41b7 user: geraint@users.sourceforge.net tags: origin/master, trunk
2001-02-11
07:08:59
Static declarations of octave_value_lists: small .exe speed improvement check-in: f58032ca4b user: geraint@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/make_ode2odes from [8b403736a0] to [491cacbcda].

1
2
3
4
5
6
7
8
9
10
11



12
13
14
15
16
17
18
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21











+
+
+







#! /bin/sh

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

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.48  2001/02/11 07:08:59  geraint
## Static declarations of octave_value_lists: small .exe speed improvement
##
## Revision 1.47  2001/02/11 05:25:52  geraint
## Reduced number of matrix operations during .oct simulation data write
##
## Revision 1.46  2001/02/05 08:32:31  geraint
## typo
##
## Revision 1.45  2001/02/05 04:32:35  geraint
268
269
270
271
272
273
274
275
276
277
278
279
280




281
282
283
284
285





286
287
288
289
290
291
292
293
294
295
296
297












































298
299

300
301
302


303
304

305



306
307
308
309
310
311
312
313
314
315
316

317
318
319
320
321


322
323

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
363
364

365
366
367
368
369



370
371
372
373
374
375
376
377
378
379
380
381

382
383
384
385
386


387
388

389



390
391
392
393
394
395
396
397
398
399
400

401
402
403
404
405
406
407
408

409

410
411
412

413
414
415
416
417
418
419
420
421
422

423
424
425
426
427
428
429


430
431
432
433
434
435
436
437
438
439

440
441
442
443
444


445
446

447



448
449
450
451
452
453
454
455
456
457
458

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
489
490

491
492
493
494
495


496
497

498



499
500
501
502
503
504
505
506
507
508
509
510

511
512
513
514
515
516
517


518
519
520
521
522
523
524
271
272
273
274
275
276
277


278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295












296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
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


363
364
365

366
367
368
369
370
371
372
373
374
375



376

377
378
379
380
381

382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400



401

402
403
404
405
406

407
408
409
410
411
412
413
414
415
416
417
418
419
420
421



422

423
424
425
426
427


428
429
430

431
432
433
434
435
436
437
438
439
440



441

442
443
444
445
446
447
448

449

450
451
452
453

454
455
456
457
458
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
489
490
491



492

493
494
495
496
497


498
499
500

501
502
503
504
505
506
507
508
509
510



511

512
513
514
515
516

517
518


519

520
521
522
523
524

525
526
527
528
529


530
531
532

533
534
535
536
537
538
539
540
541
542




543

544
545
546
547
548
549
550


551
552
553
554
555
556
557
558
559







-
-




+
+
+
+





+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


+

-
-
+
+

-
+

+
+
+





-
-
-

-

+



-
-
+
+

-
+

+
+
+





-
-
-

-

+



-
+







+
+
+








-
-
-

-

+



-
+





+
+
+






-
-
-

-

+



-
-
+
+

-
+

+
+
+





-
-
-

-

+





-

-
+

+

-

+





-
-

-
-
+
-
-
-
-
-
-

+
+








-

+



-
-
+
+

-
+

+
+
+





-
-
-

-

+



-
-
+
+

-
+

+
+
+





-
-
-

-

+



-
+

-
-

-
+

+
+

-

+



-
-
+
+

-
+

+
+
+





-
-
-
-

-

+





-
-
+
+







else
    vector_value=vector_value
    feval_header=toplev.h
fi

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

#include <octave/${feval_header}>
#include <octave/ov-struct.h>
#include <octave/oct-map.h>
#include <octave/lo-mappers.h>
#include <octave/variables.h>

#ifndef STANDALONE
#include <octave/${feval_header}>
#endif

#include "${sys}_def.h"
#include "${sys}_sympar.h"

#ifdef STANDALONE
extern ColumnVector Fmtt_euler (	ColumnVector &x,
					const ColumnVector &dx,
					const double &ddt,
					const int &nx,
					const ColumnVector &open_switches);
#define DECLARE(name) extern octave_value_list F##name (const octave_value_list &, int);
DECLARE(mtt_euler)
DECLARE(mtt_implicit)
DECLARE(${sys}_${ode})
DECLARE(${sys}_${odeo})
DECLARE(${sys}_input)
DECLARE(${sys}_numpar)
DECLARE(${sys}_simpar)
DECLARE(${sys}_smxa)
DECLARE(${sys}_smxax)
DECLARE(${sys}_state)
DECLARE(${sys}_logic)
 
extern ColumnVector Fmtt_implicit (	ColumnVector &x,
				   	const ColumnVector &dx,
				   	const Matrix &AA,
				   	const ColumnVector &AAx,
				   	const double &ddt,
				   	const int &nx,
				   	const ColumnVector &open_switches);

extern ColumnVector F${sys}_${ode} (	ColumnVector &x,
				    	ColumnVector &u,
				    	const double &t,
				    	ColumnVector &par);

extern ColumnVector F${sys}_${odeo} (	ColumnVector &x,
				     	ColumnVector &u,
				     	const double &t,
				     	ColumnVector &par);

extern ColumnVector F${sys}_input (	ColumnVector &x,
					ColumnVector &y,
				   	const double &t,
				   	ColumnVector &par);

extern ColumnVector F${sys}_numpar (	void);

extern Octave_map F${sys}_simpar (     	void);

extern Matrix F${sys}_smxa (		ColumnVector &x,
			    		ColumnVector &u,
			    		const double &t,
			    		ColumnVector &par);

extern ColumnVector F${sys}_smxax (	ColumnVector &x,
				   	ColumnVector &u,
				   	const double &t,
				   	ColumnVector &par);

extern ColumnVector F${sys}_state (	ColumnVector &x);

extern ColumnVector F${sys}_logic (	ColumnVector &x,
				   	ColumnVector &u,
				   	const double &t,
				   	ColumnVector &par);
#endif // STANDALONE


inline ColumnVector
mtt_${ode} (const ColumnVector &x,
	    const ColumnVector &u,
mtt_${ode} (ColumnVector &x,
	    ColumnVector &u,
	    const double &t,
	    const ColumnVector &par)
	    ColumnVector &par)
{
#ifdef STANDALONE
  return F${sys}_${ode} (x, u, t, par);
#else
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (u);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
#ifdef STANDALONE
  f = F${sys}_${ode} (args, 1);
#else
  f = feval ("${sys}_${ode}", args, 1);
#endif
  return f(0).${vector_value} ();
#endif
}

inline ColumnVector
mtt_${odeo} (const ColumnVector &x,
	     const ColumnVector &u,
mtt_${odeo} (ColumnVector &x,
	     ColumnVector &u,
	     const double &t,
	     const ColumnVector &par)
	     ColumnVector &par)
{
#ifdef STANDALONE
  return F${sys}_${odeo} (x, u, t, par);
#else
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (u);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
#ifdef STANDALONE
  f = F${sys}_${odeo} (args, 1);
#else
  f = feval ("${sys}_${odeo}", args, 1);
#endif
  return f(0).${vector_value} ();
#endif
}

inline ColumnVector
mtt_implicit (const ColumnVector &x,
mtt_implicit (ColumnVector &x,
	      const ColumnVector &dx,
	      const Matrix &AA,
	      const ColumnVector &AAx,
	      const double &ddt,
	      const int &nx,
	      const ColumnVector &open_switches)
{
#ifdef STANDALONE
  return Fmtt_implicit (x, dx, AA, AAx, ddt, nx, open_switches);
#else
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (dx);
  args (2) = octave_value (AA);
  args (3) = octave_value (AAx);
  args (4) = octave_value (ddt);
  args (5) = octave_value ((double)nx);
  args (6) = octave_value (open_switches);
#ifdef STANDALONE
  f = Fmtt_implicit (args, 1);
#else
  f = feval ("mtt_implicit", args, 1);
#endif
  return f(0).${vector_value} ();
#endif
}

inline ColumnVector
mtt_euler (const ColumnVector &x,
mtt_euler (ColumnVector &x,
	   const ColumnVector &dx,
	   const double &ddt,
	   const int &nx,
	   const ColumnVector &open_switches)
{
#ifdef STANDALONE
  return Fmtt_euler (x, dx, ddt, nx, open_switches);
#else
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (dx);
  args (2) = octave_value (ddt);
  args (3) = octave_value ((double)nx);
  args (4) = octave_value (open_switches);
#ifdef STANDALONE
  f = Fmtt_euler (args, 1);
#else
  f = feval ("mtt_euler", args, 1);
#endif
  return f(0).${vector_value} ();
#endif
}

inline ColumnVector
mtt_input (const ColumnVector &x,
	   const ColumnVector &y,
mtt_input (ColumnVector &x,
	   ColumnVector &y,
	   const double &t,
	   const ColumnVector &par)
	   ColumnVector &par)
{
#ifdef STANDALONE
  return F${sys}_input (x, y, t, par);
#else
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (y);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
#ifdef STANDALONE
  f = F${sys}_input (args, 1);
#else
  f = feval ("${sys}_input", args, 1);
#endif
  return f(0).${vector_value} ();
#endif
}

inline ColumnVector
mtt_numpar (void)
{
  static octave_value_list args, f;
#ifdef STANDALONE
  f = F${sys}_numpar (args, 1);
  return F${sys}_numpar ();
#else
  static octave_value_list args, f;
  f = feval ("${sys}_numpar", args, 1);
#endif
  return f(0).${vector_value} ();
#endif
}

inline Octave_map
mtt_simpar (void)
{
  static octave_value_list args;
  static Octave_map f;
#ifdef STANDALONE
  f["first"]		= F${sys}_simpar (args, 1)(0).map_value ()["first"];
  f["dt"]		= F${sys}_simpar (args, 1)(0).map_value ()["dt"];
  return F${sys}_simpar ();
  f["last"]		= F${sys}_simpar (args, 1)(0).map_value ()["last"];
  f["stepfactor"]     	= F${sys}_simpar (args, 1)(0).map_value ()["stepfactor"];
  f["wmin"]		= F${sys}_simpar (args, 1)(0).map_value ()["wmin"];
  f["wmax"]		= F${sys}_simpar (args, 1)(0).map_value ()["wmax"];
  f["wsteps"]		= F${sys}_simpar (args, 1)(0).map_value ()["wsteps"];
  f["input"]		= F${sys}_simpar (args, 1)(0).map_value ()["input"];
#else
  static octave_value_list args;
  static Octave_map f;
  f["first"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["first"];
  f["dt"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["dt"];
  f["last"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["last"];
  f["stepfactor"]     	= feval ("${sys}_simpar", args, 1)(0).map_value ()["stepfactor"];
  f["wmin"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["wmin"];
  f["wmax"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["wmax"];
  f["wsteps"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["wsteps"];
  f["input"]		= feval ("${sys}_simpar", args, 1)(0).map_value ()["input"];
#endif
  return (f);
#endif
}

inline Matrix
mtt_smxa (const ColumnVector &x,
	  const ColumnVector &u,
mtt_smxa (ColumnVector &x,
	  ColumnVector &u,
	  const double &t,
	  const ColumnVector &par)
	  ColumnVector &par)
{
#ifdef STANDALONE
  return F${sys}_smxa (x, u, t, par);
#else
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (u);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
#ifdef STANDALONE
  f = F${sys}_smxa (args, 1);
#else
  f = feval ("${sys}_smxa", args, 1);
#endif
  return f(0).matrix_value ();
#endif
}

inline ColumnVector
mtt_smxax (const ColumnVector &x,
	   const ColumnVector &u,
mtt_smxax (ColumnVector &x,
	   ColumnVector &u,
	   const double &t,
	   const ColumnVector &par)
	   ColumnVector &par)
{
#ifdef STANDALONE
  return F${sys}_smxax (x, u, t, par);
#else
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (u);
  args (2) = octave_value (t);
  args (3) = octave_value (par);
#ifdef STANDALONE
  f = F${sys}_smxax (args, 1);
#else
  f = feval ("${sys}_smxax", args, 1);
#endif
  return f(0).${vector_value} ();
#endif
}

inline ColumnVector
mtt_state (const ColumnVector &x)
mtt_state (ColumnVector &x)
{
  static octave_value_list args, f;
  args (0) = octave_value (x);
#ifdef STANDALONE
  f = F${sys}_state (args, 1);
  return F${sys}_state (x);
#else
  static octave_value_list args, f;
  args (0) = octave_value (x);
  f = feval ("${sys}_state", args, 1);
#endif
  return f(0).${vector_value} ();
#endif
}

inline ColumnVector
mtt_logic (const ColumnVector &x,
	   const ColumnVector &u,
mtt_logic (ColumnVector &x,
	   ColumnVector &u,
	   const double &t,
	   const ColumnVector &par)
	   ColumnVector &par)
{
#ifdef STANDALONE
  return F${sys}_logic (x, u, t, par);
#else
  static octave_value_list args, f;
  args (0) = octave_value (x);
  args (1) = octave_value (u);
  args (2) = octave_value (t);
  args (3) = octave_value (par);

#ifdef STANDALONE
  f = F${sys}_logic (args, 1);
#else
  f = feval ("${sys}_logic", args, 1);
#endif
  return f(0).${vector_value} ();
#endif
}


inline void
mtt_write (const double &t,
	   const ColumnVector &x,
	   const ColumnVector &y,
	   ColumnVector &x,
	   ColumnVector &y,
	   const int &nrows)
{
  static Matrix data;
  static int row;
  const int nx = x.length (), ny = y.length ();
  register int col = 0;

539
540
541
542
543
544
545
546



547
548
549
550
551
552
553

554
555
556
557
558
559
560
561
562
563

564
565
566
567
568
569
570
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







-
+
+
+






-
+









-
+







    cout << data << endl;
#else // ! STANDALONE
  set_global_value ("MTT_data", data);
#endif

}


#ifdef STANDALONE
int main (void) {
#else
DEFUN_DLD (${sys}_ode2odes, args, ,
"Octave ode2odes representation of system 
Usage: ${sys}_ode2odes (x, par, simpar)
")
{
  static octave_value_list retval;

#endif // STANDALONE
  static ColumnVector	x;
  static ColumnVector	par;
  static Octave_map	simpar;

  static double
    first	= 0.0,
    dt		= 0.0,
    last	= 0.0,
    stepfactor	= 0.0;

#ifndef STANDALONE
  int nargin = args.length ();
  switch (nargin)
    {
    case 3:
      first		= args (2).map_value ()["first"].double_value ();
      dt		= args (2).map_value ()["dt"].double_value ();
      last		= args (2).map_value ()["last"].double_value ();
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
622
623
624
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







+






+





-
+







      dt		= mtt_simpar ()["dt"].double_value ();
      last		= mtt_simpar ()["last"].double_value ();
      stepfactor     	= mtt_simpar ()["stepfactor"].double_value ();
      par    		= mtt_numpar ();
      x      		= args (0).${vector_value} ();
      break;
    case 0:
#endif // ! STANDALONE
      first		= mtt_simpar ()["first"].double_value ();
      dt		= mtt_simpar ()["dt"].double_value ();
      last		= mtt_simpar ()["last"].double_value ();
      stepfactor     	= mtt_simpar ()["stepfactor"].double_value ();
      par    		= mtt_numpar ();
      x      		= mtt_state (par);
#ifndef STANDALONE
      break;
    default:
      usage("${sys}_ode2odes (x par simpar)", nargin);
      error("aborting.");
    }

#endif // STANDALONE
  static ColumnVector	dx (MTTNX);
  static ColumnVector	u (MTTNU);
  static ColumnVector	y (MTTNY);

  static Matrix	AA (MTTNX, MTTNX);
  static ColumnVector	AAx (MTTNX);
  
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
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







+
+
+




-
-
-
+
-
-
-
-
-

-













      open_switches = mtt_logic (x, u, t, par);
      x =  $algorithm; 
      t += ddt;
      j++;
      j = (j == static_cast<int> (stepfactor)) ? 0 : j;
    }

#ifdef STANDALONE
  return 0;
#else
  retval (0) = octave_value (y);
  retval (1) = octave_value (x);
  retval (2) = octave_value (t);
  return (retval);
}

#ifdef STANDALONE
#endif // STANDALONE
int main (void)
{
  octave_value_list args;
  F${sys}_ode2odes (args, 3);
  return 0;
}
#endif
EOF
}

case ${lang} in
    m)
        make_m	
	;;
    cc)
	make_cc
	;;
    *)
	echo Language ${lang} is not supported
esac

Modified mttroot/mtt/bin/trans/mtt_header from [7675745543] to [0b46b8b3ac].

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.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
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"

#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;
#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 "\n"
    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
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
\/\/ 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
    printf "\n  return (retval);\n}\n"
  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 ...

Modified mttroot/mtt/lib/cc/mtt_euler.cc from [f6571d33a4] to [ad70b69412].

1
2








3
4
5
6
7

8
9
10
11
12
13


14
15
16
17
18


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34



35

36
1
2
3
4
5
6
7
8
9
10
11
12
13
14

15
16
17
18
19


20
21
22
23
24
25

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

43
44
45
46
47
48


+
+
+
+
+
+
+
+




-
+




-
-
+
+




-
+
+















-
+
+
+

+

#include <octave/oct.h>

#ifdef STANDALONE
ColumnVector Fmtt_euler (      ColumnVector	&x,
			 const ColumnVector	&dx,
			 const double		&ddt,
			 const int		&Nx,
			 const ColumnVector	&openx)
{
#else // !STANDALONE
DEFUN_DLD (mtt_euler, args, ,
	   "euler integration method")
{
#ifdef OCTAVE_DEV
  ColumnVector		x	= args(0).column_vector_value ();
  static ColumnVector  	x	= args(0).column_vector_value ();
  const ColumnVector	dx	= args(1).column_vector_value ();
  const double		ddt	= args(2).double_value ();
  const int		Nx	= static_cast<int> (args(3).double_value ());
  const ColumnVector   	openx	= args(4).column_vector_value ();
#else
  const ColumnVector	x	= args(0).vector_value ();
#else // !OCTAVE_DEV
  static ColumnVector	x	= args(0).vector_value ();
  const ColumnVector   	dx	= args(1).vector_value ();
  const double		ddt	= args(2).double_value ();
  const int		Nx	= static_cast<int> (args(3).double_value ());
  const ColumnVector   	openx	= args(4).vector_value ();
#endif
#endif // OCTAVE_DEV
#endif // STANDALONE

  register int i, n;
  
  n = Nx;
  for (i = 0; i < Nx; i++)
    {
      if (0 != openx (i))
	{
	  x (i) = 0.0;
	}
      else
	{
	  x (i) += dx (i) * ddt;
	}
    }
  
#ifdef STANDALONE
  return x;
#else // !STANDALONE  
  return octave_value (x);
#endif // STANDALONE
}

Modified mttroot/mtt/lib/cc/mtt_implicit.cc from [38a166bc2b] to [daf2306c04].

53
54
55
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
53
54
55
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
91
92
93
94
95
96
97







+
+
+
+
+
+
+
+
+
+











-
+







-
+
+







	return result;
    }

  int rank;
  return a.lssolve (b, info, rank);
}

#ifdef STANDALONE
ColumnVector Fmtt_implicit (      ColumnVector	&x,
			    const ColumnVector	&dx,
			    const Matrix	&AA,
			    const ColumnVector	&AAx,
			    const double	&t,
			    const int		&Nx,
			    const ColumnVector	&openx)
{
#else // !STANDALONE
DEFUN_DLD (mtt_implicit, args, ,
	   "implicit integration method")
{
#ifdef OCTAVE_DEV
  static ColumnVector  	x	= args(0).column_vector_value ();
  const ColumnVector	dx	= args(1).column_vector_value ();
  const Matrix		AA	= args(2).matrix_value ();
  const ColumnVector	AAx	= args(3).column_vector_value ();
  const double		t	= args(4).double_value ();
  const int		Nx	= (int) (args(5).double_value ());
  const ColumnVector	openx	= args(6).column_vector_value ();
#else
#else // !OCTAVE_DEV
  static ColumnVector	x	= args(0).vector_value ();
  const ColumnVector	dx	= args(1).vector_value ();
  const Matrix		AA	= args(2).matrix_value ();
  const ColumnVector	AAx	= args(3).vector_value ();
  const double		t	= args(4).double_value ();
  const int		Nx	= (int) (args(5).double_value ());
  const ColumnVector	openx	= args(6).vector_value ();
#endif
#endif // OCTAVE_DEV
#endif // STANDALONE

  register int i, n;
  register int col_old, col_new;
  register int row_old, row_new;

  n = Nx;
  for (i = 0; i < Nx; i++)
129
130
131
132
133
134
135



136
137
138
139


140
141
142
143
144
145
146
147
148
149
150



151
152







+
+
+

-
-
-
+
+
	}
      else
	{
	  x (row_old) = 0.0;
	}
    }

#ifdef STANDALONE
  return x;
#else // !STANDALONE
  return octave_value (x);
}


#endif // STANDALONE
}

Modified mttroot/mtt/lib/rep/standalone_rep.make from [289159fe61] to [cd1b8e12fb].

1
2
3
4
5
6
7
8

9
10
11

12
13
14
15
16
17
18
1
2
3
4
5
6
7

8
9
10

11
12
13
14
15
16
17
18







-
+


-
+







# -*-makefile-*-

.POSIX:

MTTFLAGS	= -q -u -oct $(OPTS)

# Adapt according to local set-up and mkoctfile
CC		= g++
CXX		= g++
CXXFLAGS	= $(DEBUG) $(OPTIM) $(DEFINES) $(ARCHFLAGS) -fno-rtti -fno-exceptions -fno-implicit-templates

DEBUG		= -v -pg -g
DEBUG		= -g
OPTIM		= -O3

PREFIX		= /usr/local

INCLUDES	= -I$(PREFIX)/include/octave

OCTAVE_SRC_PATH	= $(PREFIX)/src/octave
34
35
36
37
38
39
40
41

42
43
44
45
46
47
48
34
35
36
37
38
39
40

41
42
43
44
45
46
47
48







-
+







DEFINES   = -DSTANDALONE -DOCTAVE_DEV
endif

all: $(SYS)_standalone.$(LANG)

$(SYS)_standalone.exe: $(SYS)_ode2odes.cc $(SYS)_def.h $(SYS)_sympar.h
	cp $(MTT_LIB)/cc/*.cc .
	$(CC) *.cc -o $@ $(CXXFLAGS) $(INCLUDES) $(LIBOCTAVE) $(LIBKPATHSEA) $(LIBREADLINE) $(LIBBLAS) $(LIBF2C) $(LIBRARIES)
	$(CXX) *.cc -o $@ $(CXXFLAGS) $(INCLUDES) $(LIBOCTAVE) $(LIBKPATHSEA) $(LIBREADLINE) $(LIBBLAS) $(LIBF2C) $(LIBRARIES)

.PHONY: $(SYS)_standalone.clean

$(SYS)_ode2odes.cc:
	mtt $(MTTFLAGS) $(SYS) ode2odes m

$(SYS)_def.h:


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