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*/
|