⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functional.cpp

📁 基于"trace transform"的识别2D图像的C++源程序
💻 CPP
字号:
//Copyright(c)2004  Alexander Kadyrov
/* without arguments this program prints list of all functionals;
   
   with arguments it is used by matlab program testTr.m.

   this program writes files in form  testTr*.txt.
   the first argument is a functional number.
   Example:
   functional 33
   will write in  testTrName.txt the name of the functional
           and in testTrAtts.txt it attributes
   
   if three arguments are involved, then it computes this functional,
   Example
   functional 33 0 47
   will take 47 values of a trace from file testTr.txt, which should be prepared beforehand,
   These values will be considered as unsigned char, since the second argument is 0.
   Another option for the second argument is 2, this means that numbers are double.
   Result of computing will be written into testTrOut.txt, as three numbers:
    first number: functional 33 computed for the trace
    second number: functional 33 computed for the inverted trace (ie ordered backward)
    third number: functional 33 computed for the minus inverted trace

The forth parameter, it present, is integer "lbeg", starting argument of the trace
Default lbeg=0
*/

#include "unit2.h"
#include "objects0.h"
using namespace std;

#undef  TYPEtr
#define TYPEtr unsigned char
#undef  typetr   //0="unsigned char",1="int",2="double",
#define typetr 0 // corresponds "unsigned char"
#undef  TYPEsr
#define TYPEsr int
#undef  out
#define out    int
//Rules here: 
//if TYPEtr=uchar or TYPEtr=integer type, then TYPEsr=int
//if TYPEtr=double, then TYPEsr=double
//out=TYPEsr; out is used for finding sum,max, etc.
namespace TRACE{ 
#include "modioperandi0.h"
}
#undef  TYPEtr
#define TYPEtr double
#undef  typetr   //0="unsigned char",1="int",2="double",
#define typetr 2 // corresponds "double"
#undef  TYPEsr
#define TYPEsr double
#undef  out
#define out    double
namespace DIAM{ 
#include "modioperandi0.h"
}

int main(int argc, char *argv[ ] ){
//{for(int i=0;i<argc;i++) {NPV(i) PV(argv[i])};}  //???
attFill(); 
if (argc EQ 1)// functional listing
{ printf("    List of functionals\n");
  printf("      kind=1 means 'invariant';  kind=2 meand 'sensitive'\n");
  for(int k=2;k<Amount;k++)
  if (attIsfnl[k])
  { printf("fnlNo.%d kind=%d",k,attKind[k]); 
    PN PS(attName[k]);PN



  }//if attIsfnl[k]




return (0);
}//END functional listing



if (argc EQ 2)// writing attributes
{  
int f=atoi(argv[1]);//functional number
//writing attribute name:
FILE *File; if( (File  = fopen( "testTrName.txt", "w" )) == NULL ) 
  {printf("\n\7 ???File '%s' was not opened\n","testTrName.txt");exit(1);}  
fprintf(File,"%s",attName[f]);
double atts[30];int k=0;
atts[k++]=attIsfnl[f];
atts[k++]=attKind[f];
atts[k++]=attGray[f];
atts[k++]=attBack[f];
atts[k++]=attSack[f];

atts[k++]=attHasKappa[f];
atts[k++]=attKappa[f];
atts[k++]=attHasLambda[f];
atts[k++]=attLambda[f];
atts[k++]=attBlank[f];
atts[k++]=attIsInteger[f];

writeMatrixDouble("testTrAtts.txt",k,1,atts);
exit(0);
}//END writing attributes
int functional=atoi(argv[1]),//functional number
    type=atoi(argv[2]);//type of the trace
    L=atoi(argv[3]);//length of the trace
int Lbeg=0; if (argc EQ 5) Lbeg=atoi(argv[4]);
{using namespace TRACE;
               UfVArrAssign(); // this must be before !!  before fillcomputedby(); 
                 fillcomputedby();// before fillcomputedby(); 
 }
double *functionalvalues=new double[3];
if (!(type EQ 0 || type EQ 2)) 
{PN;PS("\7 ERROR in functional.cpp: Type should be 0(uint) or 2(double)");exit(1);}
if (type EQ 0)// 0="unsigned char" valued function
{using namespace TRACE;
int LstageList=1,*stageList=new int[1]; stageList[0]=functional;
int NonBackSack=1;//-Back
composingListModiOperandi(LstageList,stageList, NonBackSack);
dlt=1.;make_oaKcorr();
tr=Read_uchar("testTr.txt",L); lbeg=Lbeg;lend=L-1;dlt=1; ML=L;
objectsMemoryConstructor();// needs ML
computeObjects_giveBackAdj();//tr,lbeg,lend,L,dlt; - should be defined
functionalvalues[0]=o[functional];
functionalvalues[1]=a[functional];

NonBackSack=2;//-Sack
composingListModiOperandi(LstageList,stageList, NonBackSack);
computeObjects_giveSackAdj();//tr,lbeg,lend,L,dlt; - should be defined
functionalvalues[2]=a[functional];
}


if (type EQ 2)// 
{using namespace DIAM;
int LstageList=1,*stageList=new int[1]; stageList[0]=functional;
int NonBackSack=1;//-Back
UfVArrAssign(); 
composingListModiOperandi(LstageList,stageList, NonBackSack);
dlt=1.;make_oaKcorr();
tr=Read_double("testTr.txt",L); lbeg=Lbeg;lend=L-1;dlt=1; ML=L;
objectsMemoryConstructor();// needs ML
computeObjects_giveBackAdj();//tr,lbeg,lend,L,dlt; - should be defined
functionalvalues[0]=o[functional];
functionalvalues[1]=a[functional];

NonBackSack=2;//-Sack
composingListModiOperandi(LstageList,stageList, NonBackSack);
computeObjects_giveSackAdj();//tr,lbeg,lend,L,dlt; - should be defined
functionalvalues[2]=a[functional];
//PN
//PA(tr,0,L-1);
//NPV(functionalvalues[0]) NPV(functionalvalues[1])NPV(functionalvalues[2])
}

writeMatrixDouble("testTrOut.txt",3,1,functionalvalues);
return (0);
}//int main(){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -