File: dynamic_model.cpp

package info (click to toggle)
dynare 4.5.7-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 49,408 kB
  • sloc: cpp: 84,998; ansic: 29,058; pascal: 13,843; sh: 4,833; objc: 4,236; yacc: 3,622; makefile: 2,278; lex: 1,541; python: 236; lisp: 69; xml: 8
file content (79 lines) | stat: -rw-r--r-- 1,403 bytes parent folder | download | duplicates (3)
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
49
50
51
52
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
/*1:*/
#line 6 "./dynamic_model.cweb"

#include "dynamic_model.h"

/*2:*/
#line 14 "./dynamic_model.cweb"

void NameList::print()const
{
for(int i= 0;i<getNum();i++)
printf("%s\n",getName(i));
}

/*:2*/
#line 9 "./dynamic_model.cweb"
;
/*3:*/
#line 22 "./dynamic_model.cweb"

void NameList::writeMat(mat_t*fd,const char*vname)const
{
int maxlen= 0;
for(int i= 0;i<getNum();i++)
if(maxlen<(int)strlen(getName(i)))
maxlen= (int)strlen(getName(i));

if(maxlen==0)
return;

char*m= new char[getNum()*maxlen];

for(int i= 0;i<getNum();i++)
for(int j= 0;j<maxlen;j++)
if(j<(int)strlen(getName(i)))
m[j*getNum()+i]= getName(i)[j];
else
m[j*getNum()+i]= ' ';

# if MATIO_MAJOR_VERSION >  1 || (MATIO_MAJOR_VERSION == 1 && MATIO_MINOR_VERSION >= 5)
size_t dims[2];
const matio_compression compression= MAT_COMPRESSION_NONE;
# else
int dims[2];
const int compression= COMPRESSION_NONE;
# endif
dims[0]= getNum();
dims[1]= maxlen;

matvar_t*v= Mat_VarCreate(vname,MAT_C_CHAR,MAT_T_UINT8,2,dims,m,0);

Mat_VarWrite(fd,v,compression);

Mat_VarFree(v);
delete[]m;
}

/*:3*/
#line 10 "./dynamic_model.cweb"
;
/*4:*/
#line 61 "./dynamic_model.cweb"

void NameList::writeMatIndices(mat_t*fd,const char*prefix)const
{
char tmp[100];
TwoDMatrix aux(1,1);
for(int i= 0;i<getNum();i++){
sprintf(tmp,"%s_i_%s",prefix,getName(i));
aux.get(0,0)= i+1;
aux.writeMat(fd,tmp);
}
}

/*:4*/
#line 11 "./dynamic_model.cweb"
;

/*:1*/