CodeInterpreter.hh 53 KB
Newer Older
sebastien's avatar
sebastien committed
1
/*
2
 * Copyright (C) 2007-2013 Dynare Team
sebastien's avatar
sebastien committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 *
 * This file is part of Dynare.
 *
 * Dynare is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Dynare is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 */

20
21
#ifndef _CODEINTERPRETER_HH
#define _CODEINTERPRETER_HH
22
23
24
25
26
//#define DEBUGL
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <cstring>
27
#include <vector>
28
29
30
31
#ifdef LINBCG
# include "linbcg.hh"
#endif
#ifdef BYTE_CODE
32
33
34
35
36
# ifndef DEBUG_EX
#  include "mex.h"
# else
#  include "mex_interface.hh"
# endif
37
38
#endif

39
#include <stdint.h>
40

41
42
#define NEAR_ZERO (1e-12)

43
44
45
using namespace std;

/**
46
47
48
 * \enum Tags
 * \brief The differents flags of the bytecode
 */
49
50
enum Tags
  {
51
52
    FLDZ,         //!< Stores zero in the stack - 0 (0)
    FLDC,         //!< Stores a constant term in the stack - 1 (1)
53

54
55
56
57
58
59
    FDIMT,        //!< Defines the number of temporary terms - dynamic context (the period has to be indicated) - 2 (2)
    FDIMST,       //!< Defines the number of temporary terms - static context (the period hasn't to be indicated) - 3  (3)
    FLDT,         //!< Stores a temporary term in the stack - dynamic context (the period has to be indicated) - 4 (4)
    FLDST,        //!< Stores a temporary term in the stack - static context (the period hasn't to be indicated) - 5 (5)
    FSTPT,        //!< Loads a temporary term from the stack - dynamic context (the period has to be indicated) - 6 (6)
    FSTPST,       //!< Loads a temporary term from the stack - static context (the period hasn't to be indicated) - 7 (7)
60

61
62
63
64
    FLDU,         //!< Stores an element of the vector U in the stack - dynamic context (the period has to be indicated) - 8 (8)
    FLDSU,        //!< Stores an element of the vector U in the stack - static context (the period hasn't to be indicated) - 9 (9)
    FSTPU,        //!< Loads an element of the vector U from the stack - dynamic context (the period has to be indicated) - A (10)
    FSTPSU,       //!< Loads an element of the vector U from the stack - static context (the period hasn't to be indicated) - B (11)
65

66
67
68
69
70
    FLDV,         //!< Stores a variable (described in SymbolType) in the stack - dynamic context (the period has to be indicated) - C (12)
    FLDSV,        //!< Stores a variable (described in SymbolType) in the stack - static context (the period hasn't to be indicated) - D (13)
    FLDVS,        //!< Stores a variable (described in SymbolType) in the stack - dynamic context but inside the STEADYSTATE function (the period hasn't to be indicated) - E (14)
    FSTPV,        //!< Loads a variable (described in SymbolType) from the stack - dynamic context (the period has to be indicated) - F (15)
    FSTPSV,       //!< Loads a variable (described in SymbolType) from the stack - static context (the period hasn't to be indicated) - 10 (16)
71

72
73
    FLDR,         //!< Stores a residual in the stack - 11 (17)
    FSTPR,        //!< Loads a residual from the stack - 12 (18)
74

75
76
77
78
    FSTPG,        //!< Loads a derivative from the stack - 13 (19)
    FSTPG2,       //!< Loads a derivative matrix for static model from the stack - 14 (20)
    FSTPG3,       //!< Loads a derivative matrix for a dynamic model from the stack - 15 (21)
    FSTPG4,       //!< Loads a second order derivative matrix for a dynamic model from the stack - 16 (22)
79

80
81
82
    FUNARY,       //!< A Unary operator - 17 (23)
    FBINARY,      //!< A binary operator - 18 (24)
    FTRINARY,     //!< A trinary operator - 19 (25)
83

84
    FCUML,        //!< Cumulates the result - 1A (26)
85

86
87
    FJMPIFEVAL,   //!< Jump if evaluate = true - 1B (27)
    FJMP,         //!< Jump - 1C (28)
88

89
90
91
92
93
94
95
    FBEGINBLOCK,  //!< Defines the begining of a model block - 1D (29)
    FENDBLOCK,    //!< Defines the end of a model block - 1E (30)
    FENDEQU,      //!< Defines the last equation of the block. For block that has to be solved, the derivatives appear just after this flag - 1F (31)
    FEND,         //!< Defines the end of the model code - 20 (32)

    FOK,          //!< Used for debugging purpose - 21 (33)

96
97
98
99
100
101
102
103
104
105
106
    FNUMEXPR,     //!< Store the expression type and references - 22 (34)

    FCALL,        //!< Call an external function - 23 (35)
    FPUSH,        //!< Push a double in the stack - 24 (36)
    FPOP,         //!< Pop a double from the stack - 25 (37)
    FLDTEF,       //!< Stores the result of an external function in the stack - 26 (38)
    FSTPTEF,      //!< Loads the result of an external function from the stack- 27 (39)
    FLDTEFD,      //!< Stores the result of an external function in the stack - 28 (40)
    FSTPTEFD,     //!< Loads the result of an external function from the stack- 29 (41)
    FLDTEFDD,     //!< Stores the result of an external function in the stack - 28 (42)
    FSTPTEFDD     //!< Loads the result of an external function from the stack- 29 (43)
107

108
  };
109

sebastien's avatar
sebastien committed
110
111
enum BlockType
  {
112
113
114
115
    SIMULTANS,  //!< Simultaneous time separable block
    PROLOGUE,   //!< Prologue block (one equation at the beginning, later merged)
    EPILOGUE,   //!< Epilogue block (one equation at the beginning, later merged)
    SIMULTAN    //!< Simultaneous time unseparable block
sebastien's avatar
sebastien committed
116
117
  };

118
119
120
121
enum EquationType
  {
    E_UNKNOWN,              //!< Unknown equation type
    E_EVALUATE,             //!< Simple evaluation, normalized variable on left-hand side
ferhat's avatar
ferhat committed
122
    E_EVALUATE_S,           //!< Simple evaluation, normalize using the first order derivative
123
124
125
    E_SOLVE                 //!< No simple evaluation of the equation, it has to be solved
  };

126
127
128
129
enum BlockSimulationType
  {
    UNKNOWN,                      //!< Unknown simulation type
    EVALUATE_FORWARD,             //!< Simple evaluation, normalized variable on left-hand side, forward
130
    EVALUATE_BACKWARD,            //!< Simple evaluation, normalized variable on left-hand side, backward
131
    SOLVE_FORWARD_SIMPLE,         //!< Block of one equation, newton solver needed, forward
132
133
    SOLVE_BACKWARD_SIMPLE,        //!< Block of one equation, newton solver needed, backward
    SOLVE_TWO_BOUNDARIES_SIMPLE,  //!< Block of one equation, newton solver needed, forward & ackward
134
    SOLVE_FORWARD_COMPLETE,       //!< Block of several equations, newton solver needed, forward
135
    SOLVE_BACKWARD_COMPLETE,      //!< Block of several equations, newton solver needed, backward
136
    SOLVE_TWO_BOUNDARIES_COMPLETE //!< Block of several equations, newton solver needed, forward and backwar
137
  };
138

139
//! Enumeration of possible symbol types
sebastien's avatar
sebastien committed
140
/*! Warning: do not to change existing values for 0 to 4: the values matter for homotopy_setup command */
141
enum SymbolType
142
  {
143
144
145
146
147
148
149
150
    eEndogenous = 0,                //!< Endogenous
    eExogenous = 1,                 //!< Exogenous
    eExogenousDet = 2,              //!< Exogenous deterministic
    eParameter = 4,                 //!< Parameter
    eModelLocalVariable = 10,       //!< Local variable whose scope is model (pound expression)
    eModFileLocalVariable = 11,     //!< Local variable whose scope is mod file (model excluded)
    eExternalFunction = 12,         //!< External (user-defined) function
    eTrend = 13,                    //!< Trend variable
151
152
    eStatementDeclaredVariable = 14, //!< Local variable assigned within a Statement (see subsample statement for example)
    eLogTrend = 15                  //!< Log-trend variable
153
154
  };

155
156
157
158
159
enum ExpressionType
  {
    TemporaryTerm,
    ModelEquation,
    FirstEndoDerivative,
160
    FirstOtherEndoDerivative,
161
162
163
164
165
166
167
168
169
170
171
172
173
    FirstExoDerivative,
    FirstExodetDerivative,
    FirstParamDerivative,
    SecondEndoDerivative,
    SecondExoDerivative,
    SecondExodetDerivative,
    SecondParamDerivative,
    ThirdEndoDerivative,
    ThirdExoDerivative,
    ThirdExodetDerivative,
    ThirdParamDerivative
  };

174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
enum UnaryOpcode
  {
    oUminus,
    oExp,
    oLog,
    oLog10,
    oCos,
    oSin,
    oTan,
    oAcos,
    oAsin,
    oAtan,
    oCosh,
    oSinh,
    oTanh,
    oAcosh,
    oAsinh,
    oAtanh,
192
    oSqrt,
193
194
    oAbs,
    oSign,
195
    oSteadyState,
196
197
    oSteadyStateParamDeriv, // for the derivative of the STEADY_STATE operator w.r.t. to a parameter
    oSteadyStateParam2ndDeriv, // for the 2nd derivative of the STEADY_STATE operator w.r.t. to a parameter
198
199
    oExpectation,
    oErf
200
  };
sebastien's avatar
sebastien committed
201

202
203
204
205
206
207
208
enum BinaryOpcode
  {
    oPlus,
    oMinus,
    oTimes,
    oDivide,
    oPower,
209
    oPowerDeriv, // for the derivative of the power function (see trac ticket #78)
210
211
212
213
214
215
216
217
    oEqual,
    oMax,
    oMin,
    oLess,
    oGreater,
    oLessEqual,
    oGreaterEqual,
    oEqualEqual,
218
    oDifferent
219
220
  };

sebastien's avatar
sebastien committed
221
222
enum TrinaryOpcode
  {
223
224
    oNormcdf,
    oNormpdf
sebastien's avatar
sebastien committed
225
226
  };

227
228
229
230
231
232
233
234
235
236
237
enum external_function_type
{
  ExternalFunctionWithoutDerivative,
  ExternalFunctionWithFirstDerivative,
  ExternalFunctionWithFirstandSecondDerivative,
  ExternalFunctionNumericalFirstDerivative,
  ExternalFunctionFirstDerivative,
  ExternalFunctionNumericalSecondDerivative,
  ExternalFunctionSecondDerivative
};

238
239
240
241
242
243
244
245
246
247
248
249
enum PriorDistributions
  {
    eNoShape = 0,
    eBeta = 1,
    eGamma = 2,
    eNormal = 3,
    eInvGamma = 4,
    eInvGamma1 = 4,
    eUniform = 5,
    eInvGamma2 = 6
  };

250
251
252
253
struct Block_contain_type
{
  int Equation, Variable, Own_Derivative;
};
254

255
#pragma pack(push, 1)
256
257
258
259
260
class TagWithoutArgument
{
protected:
  uint8_t op_code;
public:
261
262
  inline
  TagWithoutArgument(uint8_t op_code_arg) : op_code(op_code_arg)
263
264
265
  {
  };
  inline void
266
  write(ostream &CompileCode, unsigned int &instruction_number)
267
268
  {
    CompileCode.write(reinterpret_cast<char *>(this), sizeof(*this));
269
    instruction_number++;
270
  };
271
272
273
274
275
276
277
278
279
};

template < class T1 >
class TagWithOneArgument
{
protected:
  uint8_t op_code;
  T1 arg1;
public:
280
281
  inline
  TagWithOneArgument(uint8_t op_code_arg) : op_code(op_code_arg)
282
283
  {
  };
284
285
  inline
  TagWithOneArgument(uint8_t op_code_arg, T1 arg_arg1) : op_code(op_code_arg), arg1(arg_arg1)
286
287
288
  {
  };
  inline void
289
  write(ostream &CompileCode, unsigned int &instruction_number)
290
291
  {
    CompileCode.write(reinterpret_cast<char *>(this), sizeof(TagWithOneArgument));
292
    instruction_number++;
293
  };
294
295
296
297
298
299
300
301
302
303
};

template < class T1, class T2 >
class TagWithTwoArguments
{
protected:
  uint8_t op_code;
  T1 arg1;
  T2 arg2;
public:
304
305
  inline
  TagWithTwoArguments(uint8_t op_code_arg) : op_code(op_code_arg)
306
307
  {
  };
308
309
  inline
  TagWithTwoArguments(uint8_t op_code_arg, T1 arg_arg1, T2 arg_arg2) : op_code(op_code_arg), arg1(arg_arg1), arg2(arg_arg2)
310
311
312
  {
  };
  inline void
313
  write(ostream &CompileCode, unsigned int &instruction_number)
314
315
  {
    CompileCode.write(reinterpret_cast<char *>(this), sizeof(*this));
316
    instruction_number++;
317
  };
318
319
320
321
322
323
324
325
326
327
328
};

template < class T1, class T2, class T3 >
class TagWithThreeArguments
{
protected:
  uint8_t op_code;
  T1 arg1;
  T2 arg2;
  T3 arg3;
public:
329
330
  inline
  TagWithThreeArguments(uint8_t op_code_arg) : op_code(op_code_arg)
331
332
  {
  };
333
334
  inline
  TagWithThreeArguments(uint8_t op_code_arg, T1 arg_arg1, T2 arg_arg2, T3 arg_arg3) : op_code(op_code_arg), arg1(arg_arg1), arg2(arg_arg2), arg3(arg_arg3)
335
336
337
  {
  };
  inline void
338
  write(ostream &CompileCode, unsigned int &instruction_number)
339
340
  {
    CompileCode.write(reinterpret_cast<char *>(this), sizeof(*this));
341
    instruction_number++;
342
  };
343
344
};

345
346
347
348
349
350
351
352
353
354
template < class T1, class T2, class T3, class T4 >
class TagWithFourArguments
{
protected:
  uint8_t op_code;
  T1 arg1;
  T2 arg2;
  T3 arg3;
  T4 arg4;
public:
355
356
  inline
  TagWithFourArguments(uint8_t op_code_arg) : op_code(op_code_arg)
357
358
  {
  };
359
360
  inline
  TagWithFourArguments(uint8_t op_code_arg, T1 arg_arg1, T2 arg_arg2, T3 arg_arg3, T4 arg_arg4) : op_code(op_code_arg), arg1(arg_arg1), arg2(arg_arg2), arg3(arg_arg3), arg4(arg_arg4)
361
362
363
364
365
366
367
368
369
370
  {
  };
  inline void
  write(ostream &CompileCode, unsigned int &instruction_number)
  {
    CompileCode.write(reinterpret_cast<char *>(this), sizeof(*this));
    instruction_number++;
  };
};

371
372
373
class FLDZ_ : public TagWithoutArgument
{
public:
374
375
  inline
  FLDZ_() : TagWithoutArgument(FLDZ)
376
377
  {
  };
378
379
380
381
382
};

class FEND_ : public TagWithoutArgument
{
public:
383
384
  inline
  FEND_() : TagWithoutArgument(FEND)
385
386
  {
  };
387
388
389
390
391
};

class FENDBLOCK_ : public TagWithoutArgument
{
public:
392
393
  inline
  FENDBLOCK_() : TagWithoutArgument(FENDBLOCK)
394
395
  {
  };
396
397
398
399
400
};

class FENDEQU_ : public TagWithoutArgument
{
public:
401
402
  inline
  FENDEQU_() : TagWithoutArgument(FENDEQU)
403
404
  {
  };
405
406
407
408
409
};

class FCUML_ : public TagWithoutArgument
{
public:
410
411
  inline
  FCUML_() : TagWithoutArgument(FCUML)
412
413
  {
  };
414
415
};

416
417
418
class FPUSH_ : public TagWithoutArgument
{
public:
419
420
  inline
  FPUSH_() : TagWithoutArgument(FPUSH)
421
422
423
424
425
426
427
  {
  };
};

class FPOP_ : public TagWithoutArgument
{
public:
428
429
  inline
  FPOP_() : TagWithoutArgument(FPOP)
430
431
432
433
  {
  };
};

434
435
436
class FDIMT_ : public TagWithOneArgument<unsigned int>
{
public:
437
438
  inline
  FDIMT_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FDIMT)
439
440
  {
  };
441
442
  inline
  FDIMT_(unsigned int size_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FDIMT, size_arg)
443
444
445
446
447
448
449
  {
  };
  inline unsigned int
  get_size()
  {
    return arg1;
  };
450
451
452
453
454
};

class FDIMST_ : public TagWithOneArgument<unsigned int>
{
public:
455
456
  inline
  FDIMST_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FDIMST)
457
458
  {
  };
459
460
  inline
  FDIMST_(const unsigned int size_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FDIMST, size_arg)
461
462
463
464
465
466
467
  {
  };
  inline unsigned int
  get_size()
  {
    return arg1;
  };
468
469
470
471
472
};

class FLDC_ : public TagWithOneArgument<double>
{
public:
473
474
  inline
  FLDC_() : TagWithOneArgument<double>::TagWithOneArgument(FLDC)
475
476
  {
  };
477
478
  inline
  FLDC_(const double value_arg) : TagWithOneArgument<double>::TagWithOneArgument(FLDC, value_arg)
479
480
481
482
483
484
485
  {
  };
  inline double
  get_value()
  {
    return arg1;
  };
486
487
488
489
490
};

class FLDU_ : public TagWithOneArgument<unsigned int>
{
public:
491
492
  inline
  FLDU_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDU)
493
494
  {
  };
495
496
  inline
  FLDU_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDU, pos_arg)
497
498
499
500
501
502
503
  {
  };
  inline unsigned int
  get_pos()
  {
    return arg1;
  };
504
505
506
507
508
};

class FLDSU_ : public TagWithOneArgument<unsigned int>
{
public:
509
510
  inline
  FLDSU_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDSU)
511
512
  {
  };
513
514
  inline
  FLDSU_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDSU, pos_arg)
515
516
517
518
519
520
521
  {
  };
  inline unsigned int
  get_pos()
  {
    return arg1;
  };
522
523
524
525
526
};

class FLDR_ : public TagWithOneArgument<unsigned int>
{
public:
527
528
  inline
  FLDR_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDR)
529
530
  {
  };
531
532
  inline
  FLDR_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDR, pos_arg)
533
534
535
536
537
538
539
  {
  };
  inline unsigned int
  get_pos()
  {
    return arg1;
  };
540
541
542
543
544
};

class FLDT_ : public TagWithOneArgument<unsigned int>
{
public:
545
546
  inline
  FLDT_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDT)
547
548
  {
  };
549
550
  inline
  FLDT_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDT, pos_arg)
551
552
553
554
555
556
557
  {
  };
  inline unsigned int
  get_pos()
  {
    return arg1;
  };
558
559
560
561
562
};

class FLDST_ : public TagWithOneArgument<unsigned int>
{
public:
563
564
  inline
  FLDST_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDST)
565
566
  {
  };
567
568
  inline
  FLDST_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDST, pos_arg)
569
570
571
572
573
574
575
  {
  };
  inline unsigned int
  get_pos()
  {
    return arg1;
  };
576
577
578
579
580
};

class FSTPT_ : public TagWithOneArgument<unsigned int>
{
public:
581
582
  inline
  FSTPT_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPT)
583
584
  {
  };
585
586
  inline
  FSTPT_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPT, pos_arg)
587
588
589
590
591
592
593
  {
  };
  inline unsigned int
  get_pos()
  {
    return arg1;
  };
594
595
596
597
598
};

class FSTPST_ : public TagWithOneArgument<unsigned int>
{
public:
599
600
  inline
  FSTPST_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPST)
601
602
  {
  };
603
604
  inline
  FSTPST_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPST, pos_arg)
605
606
607
608
609
610
611
  {
  };
  inline unsigned int
  get_pos()
  {
    return arg1;
  };
612
613
614
615
616
};

class FSTPR_ : public TagWithOneArgument<unsigned int>
{
public:
617
618
  inline
  FSTPR_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPR)
619
620
  {
  };
621
622
  inline
  FSTPR_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPR, pos_arg)
623
624
625
626
627
628
629
  {
  };
  inline unsigned int
  get_pos()
  {
    return arg1;
  };
630
631
632
633
634
};

class FSTPU_ : public TagWithOneArgument<unsigned int>
{
public:
635
636
  inline
  FSTPU_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPU)
637
638
  {
  };
639
640
  inline
  FSTPU_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPU, pos_arg)
641
642
643
644
645
646
647
  {
  };
  inline unsigned int
  get_pos()
  {
    return arg1;
  };
648
649
650
651
652
};

class FSTPSU_ : public TagWithOneArgument<unsigned int>
{
public:
653
654
  inline
  FSTPSU_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPSU)
655
656
  {
  };
657
658
  inline
  FSTPSU_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPSU, pos_arg)
659
660
661
662
663
664
665
  {
  };
  inline unsigned int
  get_pos()
  {
    return arg1;
  };
666
667
668
669
670
};

class FSTPG_ : public TagWithOneArgument<unsigned int>
{
public:
671
672
  inline
  FSTPG_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPG, 0)
673
674
  {
  };
675
676
  inline
  FSTPG_(const unsigned int pos_arg) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPG, pos_arg)
677
678
679
680
681
682
683
  {
  };
  inline unsigned int
  get_pos()
  {
    return arg1;
  };
684
685
};

686
687
688
class FSTPG2_ : public TagWithTwoArguments<unsigned int, unsigned int>
{
public:
689
690
  inline
  FSTPG2_() : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments(FSTPG2, 0, 0)
691
692
  {
  };
693
694
  inline
  FSTPG2_(const unsigned int pos_arg1, const unsigned int pos_arg2) : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments(FSTPG2, pos_arg1, pos_arg2)
695
696
697
698
699
700
701
702
703
704
705
706
707
708
  {
  };
  inline unsigned int
  get_row()
  {
    return arg1;
  };
  inline unsigned int
  get_col()
  {
    return arg2;
  };
};

709
710
711
class FSTPG3_ : public TagWithFourArguments<unsigned int, unsigned int, int, unsigned int>
{
public:
712
713
  inline
  FSTPG3_() : TagWithFourArguments<unsigned int, unsigned int, int, unsigned int>::TagWithFourArguments(FSTPG3, 0, 0, 0, 0)
714
715
  {
  };
716
717
  inline
  FSTPG3_(const unsigned int pos_arg1, const unsigned int pos_arg2, const int pos_arg3, const unsigned int pos_arg4) : TagWithFourArguments<unsigned int, unsigned int, int, unsigned int>::TagWithFourArguments(FSTPG3, pos_arg1, pos_arg2, pos_arg3, pos_arg4)
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
  {
  };
  inline unsigned int
  get_row()
  {
    return arg1;
  };
  inline unsigned int
  get_col()
  {
    return arg2;
  };
  inline int
  get_lag()
  {
    return arg2;
  };
  inline unsigned int
  get_col_pos()
  {
    return arg4;
  };
};
741

742
743
744
class FUNARY_ : public TagWithOneArgument<uint8_t>
{
public:
745
746
  inline
  FUNARY_() : TagWithOneArgument<uint8_t>::TagWithOneArgument(FUNARY)
747
748
  {
  };
749
750
  inline
  FUNARY_(uint8_t op_type_arg) : TagWithOneArgument<uint8_t>::TagWithOneArgument(FUNARY, op_type_arg)
751
752
753
754
755
756
757
  {
  };
  inline uint8_t
  get_op_type()
  {
    return arg1;
  };
758
759
760
761
762
};

class FBINARY_ : public TagWithOneArgument<uint8_t>
{
public:
763
764
  inline
  FBINARY_() : TagWithOneArgument<uint8_t>::TagWithOneArgument(FBINARY)
765
766
  {
  };
767
768
  inline
  FBINARY_(const int op_type_arg) : TagWithOneArgument<uint8_t>::TagWithOneArgument(FBINARY, op_type_arg)
769
770
771
772
773
774
775
  {
  };
  inline uint8_t
  get_op_type()
  {
    return arg1;
  };
776
777
};

778
779
780
class FTRINARY_ : public TagWithOneArgument<uint8_t>
{
public:
781
782
  inline
  FTRINARY_() : TagWithOneArgument<uint8_t>::TagWithOneArgument(FTRINARY)
783
784
  {
  };
785
786
  inline
  FTRINARY_(const int op_type_arg) : TagWithOneArgument<uint8_t>::TagWithOneArgument(FTRINARY, op_type_arg)
787
788
789
790
791
792
793
794
795
  {
  };
  inline uint8_t
  get_op_type()
  {
    return arg1;
  };
};

796
797
798
class FOK_ : public TagWithOneArgument<int>
{
public:
799
800
  inline
  FOK_() : TagWithOneArgument<int>::TagWithOneArgument(FOK)
801
802
  {
  };
803
804
  inline
  FOK_(const int arg_arg) : TagWithOneArgument<int>::TagWithOneArgument(FOK, arg_arg)
805
806
807
808
809
810
811
  {
  };
  inline int
  get_arg()
  {
    return arg1;
  };
812
813
};

814
815
816
class FJMPIFEVAL_ : public TagWithOneArgument<unsigned int>
{
public:
817
818
  inline
  FJMPIFEVAL_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FJMPIFEVAL)
819
820
  {
  };
821
822
  inline
  FJMPIFEVAL_(unsigned int arg_pos) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FJMPIFEVAL, arg_pos)
823
824
825
826
827
828
829
830
831
832
833
834
  {
  };
  inline unsigned int
  get_pos()
  {
    return arg1;
  }
};

class FJMP_ : public TagWithOneArgument<unsigned int>
{
public:
835
836
  inline
  FJMP_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FJMP)
837
838
  {
  };
839
840
  inline
  FJMP_(unsigned int arg_pos) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FJMP, arg_pos)
841
842
843
844
845
846
847
848
849
  {
  };
  inline unsigned int
  get_pos()
  {
    return arg1;
  }
};

850
851
852
class FLDTEF_ : public TagWithOneArgument<unsigned int>
{
public:
853
854
  inline
  FLDTEF_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDTEF)
855
856
  {
  };
857
858
  inline
  FLDTEF_(unsigned int number) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FLDTEF, number)
859
860
861
862
863
864
865
866
867
868
869
870
  {
  };
  inline unsigned int
  get_number()
  {
    return arg1;
  }
};

class FSTPTEF_ : public TagWithOneArgument<unsigned int>
{
public:
871
872
  inline
  FSTPTEF_() : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPTEF)
873
874
  {
  };
875
876
  inline
  FSTPTEF_(unsigned int number) : TagWithOneArgument<unsigned int>::TagWithOneArgument(FSTPTEF, number)
877
878
879
880
881
882
883
884
885
886
887
888
  {
  };
  inline unsigned int
  get_number()
  {
    return arg1;
  }
};

class FLDTEFD_ : public TagWithTwoArguments<unsigned int, unsigned int>
{
public:
889
890
  inline
  FLDTEFD_() : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments(FLDTEFD)
891
892
  {
  };
893
894
  inline
  FLDTEFD_(unsigned int indx, unsigned int row) : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments(FLDTEFD, indx, row)
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
  {
  };
  inline unsigned int
  get_indx()
  {
    return arg1;
  };
  inline unsigned int
  get_row()
  {
    return arg2;
  };
};

class FSTPTEFD_ : public TagWithTwoArguments<unsigned int, unsigned int>
{
public:
912
913
  inline
  FSTPTEFD_() : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments(FSTPTEFD)
914
915
  {
  };
916
917
  inline
  FSTPTEFD_(unsigned int indx, unsigned int row) : TagWithTwoArguments<unsigned int, unsigned int>::TagWithTwoArguments(FSTPTEFD, indx, row)
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
  {
  };
  inline unsigned int
  get_indx()
  {
    return arg1;
  };
  inline unsigned int
  get_row()
  {
    return arg2;
  };
};

class FLDTEFDD_ : public TagWithThreeArguments<unsigned int, unsigned int, unsigned int>
{
public:
935
936
  inline
  FLDTEFDD_() : TagWithThreeArguments<unsigned int, unsigned int, unsigned int>::TagWithThreeArguments(FLDTEFDD)
937
938
  {
  };
939
940
  inline
  FLDTEFDD_(unsigned int indx, unsigned int row, unsigned int col) : TagWithThreeArguments<unsigned int, unsigned int, unsigned int>::TagWithThreeArguments(FLDTEFDD, indx, row, col)
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
  {
  };
  inline unsigned int
  get_indx()
  {
    return arg1;
  };
  inline unsigned int
  get_row()
  {
    return arg2;
  };
  inline unsigned int
  get_col()
  {
    return arg3;
  };
};

class FSTPTEFDD_ : public TagWithThreeArguments<unsigned int, unsigned int, unsigned int>
{
public:
963
964
  inline
  FSTPTEFDD_() : TagWithThreeArguments<unsigned int, unsigned int, unsigned int>::TagWithThreeArguments(FSTPTEFDD)
965
966
  {
  };
967
968
  inline
  FSTPTEFDD_(unsigned int indx, unsigned int row, unsigned int col) : TagWithThreeArguments<unsigned int, unsigned int, unsigned int>::TagWithThreeArguments(FSTPTEF, indx, row, col)
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
  {
  };
  inline unsigned int
  get_indx()
  {
    return arg1;
  };
  inline unsigned int
  get_row()
  {
    return arg2;
  };
  inline unsigned int
  get_col()
  {
    return arg3;
  };
};

988
989
990
class FLDVS_ : public TagWithTwoArguments<uint8_t, unsigned int>
{
public:
991
992
  inline
  FLDVS_() : TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments(FLDVS)
993
994
  {
  };
995
996
  inline
  FLDVS_(uint8_t type_arg, const unsigned int pos_arg) : TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments(FLDVS, type_arg, pos_arg)
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
  {
  };
  inline uint8_t
  get_type()
  {
    return arg1;
  };
  inline unsigned int
  get_pos()
  {
    return arg2;
  };
1009
1010
1011
1012
1013
};

class FLDSV_ : public TagWithTwoArguments<uint8_t, unsigned int>
{
public:
1014
1015
  inline
  FLDSV_() : TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments(FLDSV)
1016
1017
  {
  };
1018
1019
  inline
  FLDSV_(const uint8_t type_arg, const unsigned int pos_arg) :
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
    TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments(FLDSV, type_arg, pos_arg)
  {
  };
  inline uint8_t
  get_type()
  {
    return arg1;
  };
  inline unsigned int
  get_pos()
  {
    return arg2;
  };
1033
1034
1035
1036
1037
};

class FSTPSV_ : public TagWithTwoArguments<uint8_t, unsigned int>
{
public:
1038
1039
  inline
  FSTPSV_() : TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments(FSTPSV)
1040
1041
  {
  };
1042
1043
  inline
  FSTPSV_(const uint8_t type_arg, const unsigned int pos_arg) :
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
    TagWithTwoArguments<uint8_t, unsigned int>::TagWithTwoArguments(FSTPSV, type_arg, pos_arg)
  {
  };
  inline uint8_t
  get_type()
  {
    return arg1;
  };
  inline unsigned int
  get_pos()
  {
    return arg2;
  };
1057
1058
1059
1060
1061
};

class FLDV_ : public TagWithThreeArguments<uint8_t, unsigned int, int>
{
public:
1062
1063
  inline
  FLDV_() : TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments(FLDV)
1064
1065
  {
  };
1066
1067
  inline
  FLDV_(const int type_arg, const unsigned int pos_arg) :
1068
1069
1070
    TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments(FLDV, type_arg, pos_arg, 0)
  {
  };
1071
1072
  inline
  FLDV_(const int type_arg, const unsigned int pos_arg, const int lead_lag_arg) :
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
    TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments(FLDV, type_arg, pos_arg, lead_lag_arg)
  {
  };
  inline uint8_t
  get_type()
  {
    return arg1;
  };
  inline unsigned int
  get_pos()
  {
    return arg2;
  };
  inline int
  get_lead_lag()
  {
    return arg3;
  };
1091
1092
1093
1094
1095
};

class FSTPV_ : public TagWithThreeArguments<uint8_t, unsigned int, int>
{
public:
1096
1097
  inline
  FSTPV_() : TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments(FSTPV)
1098
1099
  {
  };
1100
1101
  inline
  FSTPV_(const int type_arg, const unsigned int pos_arg) :
1102
1103
1104
    TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments(FSTPV, type_arg, pos_arg, 0)
  {
  };
1105
1106
  inline
  FSTPV_(const int type_arg, const unsigned int pos_arg, const int lead_lag_arg) :
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
    TagWithThreeArguments<uint8_t, unsigned int, int>::TagWithThreeArguments(FSTPV, type_arg, pos_arg, lead_lag_arg)
  {
  };
  inline uint8_t
  get_type()
  {
    return arg1;
  };
  inline unsigned int
  get_pos()
  {
    return arg2;
  };
  inline int
  get_lead_lag()
  {
    return arg3;
  };
1125
1126
};

1127
1128
1129
1130
1131
1132
1133
class FCALL_ : public TagWithFourArguments<unsigned int, unsigned int, string, unsigned int>
{
  string func_name;
  string arg_func_name;
  unsigned int add_input_arguments, row, col;
  external_function_type function_type;
public:
1134
1135
  inline
  FCALL_() : TagWithFourArguments<unsigned int, unsigned int, string, unsigned int>::TagWithFourArguments(FCALL)
1136
1137
1138
1139
1140
1141
1142
  {
    arg_func_name = "";
    add_input_arguments = 0;
    row = 0;
    col = 0;
    function_type = ExternalFunctionWithoutDerivative;
  };
1143
1144
  inline
  FCALL_(unsigned int nb_output_arguments, unsigned int nb_input_arguments, string f_name, unsigned int indx) :
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
    TagWithFourArguments<unsigned int, unsigned int, string, unsigned int>::TagWithFourArguments(FCALL, nb_output_arguments, nb_input_arguments, f_name, indx)
  {
    arg_func_name = "";
    add_input_arguments = 0;
    row = 0;
    col = 0;
    function_type = ExternalFunctionWithoutDerivative;
    func_name = f_name;
  };
  inline string
  get_function_name()
  {
    //printf("get_function_name => func_name=%s\n",func_name.c_str());fflush(stdout);
    return func_name;
  };
  inline unsigned int
  get_nb_output_arguments()
  {
    return arg1;
  };
  inline unsigned int
  get_nb_input_arguments()
  {
    return arg2;
  };
  inline unsigned int
  get_indx()
  {
    return arg4;
  };
  inline void
  set_arg_func_name(string arg_arg_func_name)
  {
    arg_func_name = arg_arg_func_name;
  };
  inline string
  get_arg_func_name()
  {
    return arg_func_name;
  };
  inline void
  set_nb_add_input_arguments(unsigned int arg_add_input_arguments)
  {
    add_input_arguments = arg_add_input_arguments;
  };
  inline unsigned int
  get_nb_add_input_arguments()
  {
    return add_input_arguments;
  };
  inline void
  set_row(unsigned int arg_row)
  {
    row = arg_row;
  };
  inline unsigned int
  get_row()
  {
    return row;
  }
  inline void
  set_col(unsigned int arg_col)
  {
    col = arg_col;
  };
  inline unsigned int
  get_col()
  {
    return col;
  };
  inline void
  set_function_type(external_function_type arg_function_type)
1217
1218
1219
  {
    function_type = arg_function_type;
  };
1220
1221
  inline external_function_type
  get_function_type()
1222
1223
1224
  {
    return (function_type);
  }
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
  inline void
  write(ostream &CompileCode, unsigned int &instruction_number)
  {
    CompileCode.write(reinterpret_cast<char *>(&op_code), sizeof(op_code));
    CompileCode.write(reinterpret_cast<char *>(&arg1), sizeof(arg1));
    CompileCode.write(reinterpret_cast<char *>(&arg2), sizeof(arg2));
    CompileCode.write(reinterpret_cast<char *>(&arg4), sizeof(arg4));
    CompileCode.write(reinterpret_cast<char *>(&add_input_arguments), sizeof(add_input_arguments));
    CompileCode.write(reinterpret_cast<char *>(&row), sizeof(row));
    CompileCode.write(reinterpret_cast<char *>(&col), sizeof(col));
    CompileCode.write(reinterpret_cast<char *>(&function_type), sizeof(function_type));
1236
    size_t size = func_name.size();
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
    CompileCode.write(reinterpret_cast<char *>(&size), sizeof(int));
    const char *name = func_name.c_str();
    CompileCode.write(reinterpret_cast<const char *>(name), func_name.size());
    size = arg_func_name.size();
    CompileCode.write(reinterpret_cast<char *>(&size), sizeof(int));
    name = arg_func_name.c_str();
    CompileCode.write(reinterpret_cast<const char *>(name), arg_func_name.size());
    instruction_number++;
  };
#ifdef BYTE_CODE

  inline uint8_t *
  load(uint8_t *code)
  {
    op_code = FCALL; code += sizeof(op_code);
    memcpy(&arg1, code, sizeof(arg1)); code += sizeof(arg1);
    memcpy(&arg2, code, sizeof(arg2)); code += sizeof(arg2);
    memcpy(&arg4, code, sizeof(arg4)); code += sizeof(arg4);
    memcpy(&add_input_arguments, code, sizeof(add_input_arguments)); code += sizeof(add_input_arguments);
    memcpy(&row, code, sizeof(row)); code += sizeof(row);
    memcpy(&col, code, sizeof(col)); code += sizeof(col);
    memcpy(&function_type, code, sizeof(function_type)); code += sizeof(function_type);
    int size;
    memcpy(&size, code, sizeof(size)); code += sizeof(size);
1261
    char *name = (char *) mxMalloc((size+1)*sizeof(char));
1262
    memcpy(name, code, size); code += size;
1263
    name[size] = 0;
1264
1265
1266
    func_name = name;
    mxFree(name);
    memcpy(&size, code, sizeof(size)); code += sizeof(size);
1267
    name = (char *) mxMalloc((size+1)*sizeof(char));
1268
    memcpy(name, code, size); code += size;
1269
    name[size] = 0;
1270
1271
1272
1273
1274
1275
1276
    arg_func_name = name;
    mxFree(name);
    return code;
  }
#endif
};

1277
1278
1279
1280
1281
1282
1283
class FNUMEXPR_ : public TagWithOneArgument<ExpressionType>
{
private:
  unsigned int equation;
  uint16_t dvariable1, dvariable2, dvariable3;
  int8_t lag1, lag2, lag3;
public:
1284
1285
  inline
  FNUMEXPR_() : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR)
1286
1287
  {
  };
1288
1289
1290
  inline
  FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type),
                                                                               dvariable1(0), dvariable2(0), dvariable3(0), lag1(0), lag2(0), lag3(0)
1291
1292
1293
  {
    equation = equation_arg;
  };
1294
1295
1296
  inline
  FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type),
                                                                                                            dvariable2(0), dvariable3(0), lag1(0), lag2(0), lag3(0)
1297
1298
1299
1300
  {
    equation = equation_arg;
    dvariable1 = dvariable1_arg;
  };
1301
1302
1303
  inline
  FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, int lag1_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type),
                                                                                                                          dvariable2(0), dvariable3(0), lag2(0), lag3(0)
1304
1305
1306
1307
1308
  {
    equation = equation_arg;
    dvariable1 = dvariable1_arg;
    lag1 = lag1_arg;
  };
1309
1310
1311
  inline
  FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, unsigned int dvariable2_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type),
                                                                                                                                         dvariable3(0), lag1(0), lag2(0), lag3(0)
1312
1313
1314
1315
1316
  {
    equation = equation_arg;
    dvariable1 = dvariable1_arg;
    dvariable2 = dvariable2_arg;
  };
1317
1318
1319
  inline
  FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, int lag1_arg, unsigned int dvariable2_arg, int lag2_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type),
                                                                                                                                                                     dvariable3(0), lag3(0)
1320
1321
1322
1323
1324
1325
1326
  {
    equation = equation_arg;
    dvariable1 = dvariable1_arg;
    lag1 = lag1_arg;
    dvariable2 = dvariable2_arg;
    lag2 = lag2_arg;
  };
1327
1328
1329
  inline
  FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, unsigned int dvariable2_arg, unsigned int dvariable3_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type),
                                                                                                                                                                      lag1(0), lag2(0), lag3(0)
1330
1331
1332
1333
1334
1335
  {
    equation = equation_arg;
    dvariable1 = dvariable1_arg;
    dvariable2 = dvariable2_arg;
    dvariable3 = dvariable3_arg;
  };
1336
1337
  inline
  FNUMEXPR_(const ExpressionType expression_type, unsigned int equation_arg, unsigned int dvariable1_arg, int lag1_arg, unsigned int dvariable2_arg, int lag2_arg, unsigned int dvariable3_arg, int lag3_arg) : TagWithOneArgument<ExpressionType>::TagWithOneArgument(FNUMEXPR, expression_type)
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
  {
    equation = equation_arg;
    dvariable1 = dvariable1_arg;
    lag1 = lag1_arg;
    dvariable2 = dvariable2_arg;
    lag2 = lag2_arg;
    dvariable3 = dvariable3_arg;
    lag3 = lag3_arg;
  };
  inline ExpressionType
  get_expression_type()
  {
    return arg1;
  }
  inline unsigned int
  get_equation()
  {
    return equation;
  };
  inline unsigned int
  get_dvariable1()
  {
    return dvariable1;
  };
  inline int
  get_lag1()
  {
    return lag1;
  };
  inline unsigned int
  get_dvariable2()
  {
    return dvariable2;
  };
  inline int
  get_lag2()
  {
    return lag2;
  };
  inline unsigned int
  get_dvariable3()
  {
    return dvariable3;
  };
  inline int
  get_lag3()
  {
    return lag3;
  };
  inline void
1388
  write(ostream &CompileCode, unsigned int &instruction_number)
1389
1390
  {
    CompileCode.write(reinterpret_cast<char *>(this), sizeof(FNUMEXPR_));
1391
    instruction_number++;
1392
1393
1394
  };
};

1395
1396
1397
1398
1399
1400
class FBEGINBLOCK_
{
private:
  uint8_t op_code;
  int size;
  uint8_t type;
1401
1402
  vector<int> variable;
  vector<int> equation;
1403
1404
1405
  vector<unsigned int> other_endogenous;
  vector<unsigned int> exogenous;
  vector<unsigned int> det_exogenous;
1406
  bool is_linear;
1407
  vector<Block_contain_type