コード例 #1
0
int MOD_OPT(ChkMix)(Option *Opt,Model *Mod)
{
  TYPEOPT* ptOpt=( TYPEOPT*)(Opt->TypeOpt);
  TYPEMOD* ptMod=( TYPEMOD*)(Mod->TypeModel);
  int status=OK;

  if (ptOpt->Maturity.Val.V_DATE<=ptMod->T.Val.V_DATE)
    {
      Fprintf(TOSCREENANDFILE,"Current date greater than maturity!\n");
      status+=1;
    };
  if ((ptOpt->DownOrUp).Val.V_BOOL==DOWN)
    {

      if ( ((ptOpt->Limit.Val.V_NUMFUNC_1)->Compute)((ptOpt->Limit.Val.V_NUMFUNC_1)->Par,ptMod->T.Val.V_DATE)>ptMod->S0.Val.V_PDOUBLE)
        {
          Fprintf(TOSCREENANDFILE,"Limit Down greater than spot!\n");
          status+=1;
        };


    }
  if ((ptOpt->DownOrUp).Val.V_BOOL==UP)
    {
      if ( ((ptOpt->Limit.Val.V_NUMFUNC_1)->Compute)((ptOpt->Limit.Val.V_NUMFUNC_1)->Par,ptMod->T.Val.V_DATE)<ptMod->S0.Val.V_PDOUBLE)
        {
          Fprintf(TOSCREENANDFILE,"Limit Up lower than spot!\n");
          status+=1;
        };

    }
  return status;
}
コード例 #2
0
ファイル: mer1d_pad.c プロジェクト: jayhsieh/premia-13
int MOD_OPT(ChkMix)(Option *Opt,Model *Mod)
{
  TYPEOPT* ptOpt=( TYPEOPT*)(Opt->TypeOpt);
  TYPEMOD* ptMod=( TYPEMOD*)(Mod->TypeModel);
  int status=OK;

  if (ptOpt->Maturity.Val.V_DATE<=ptMod->T.Val.V_DATE)
    {
      Fprintf(TOSCREENANDFILE,"Current date greater than maturity!\n");
      status+=1;
    };
  if ((ptOpt->MinOrElse).Val.V_BOOL==MINIMUM)
    {
      if ((ptOpt->PathDep.Val.V_NUMFUNC_2)->Par[4].Val.V_PDOUBLE>ptMod->S0.Val.V_PDOUBLE)
	{
	  Fprintf(TOSCREENANDFILE,"Minimum greater than spot!\n");
	  status+=1;
	};
    }
  if ((ptOpt->MinOrElse).Val.V_BOOL==MAXIMUM)
    {
      if ((ptOpt->PathDep.Val.V_NUMFUNC_2)->Par[4].Val.V_PDOUBLE<ptMod->S0.Val.V_PDOUBLE)
	{
	  Fprintf(TOSCREENANDFILE,"Maximum lower than spot!\n");
	  status+=1;
	};
    }
  return status;
}
コード例 #3
0
ファイル: intersci-n.c プロジェクト: rossdrummond/scilab
void WriteListAnalysis(FILE * f, int i, char *list_type)
{
    int k, i1;
    VARPTR var;

    i1 = i + 1;

    AddDeclare1(DEC_INT, "m%d", i1);
    AddDeclare1(DEC_INT, "n%d", i1);
    AddDeclare1(DEC_INT, "l%d", i1);
    Fprintf(f, indent, "GetRhsVar(%d,\"%s\",&m%d,&n%d,&l%d);\n", i1, list_type, i1, i1, i1);
    for (k = 0; k < nVariable; k++)
    {
        var = variables[k];
        if ((var->list_el != 0) && (strcmp(var->list_name, variables[i]->name) == 0) && var->present)
        {
            Fprintf(f, indent, "/* list element %d %s */\n", var->list_el, var->name);
            if (RHSTAB[var->type].type != var->type)
            {
                fprintf(stderr, "Bug in intersci : Something wrong in RHSTAB\n");
            }
            (*(RHSTAB[var->type].fonc)) (f, var, 0);
        }
    }
}
コード例 #4
0
ファイル: sitefcal.c プロジェクト: stefsmeets/focus_package
static void PrintList_hkl(void)
{
  int              iListFcal;
  T_ListFcal       *lfcal;
  Fprec            d, twotheta;


  Fprintf(stdout, ">Begin List_hkl\n");
  Fprintf(stdout, "#  h   k   l    d     2-Theta\n");

  lfcal = ListFcal;

  for (iListFcal = 0; iListFcal < nListFcal; iListFcal++)
  {
    if (lfcal->h || lfcal->k || lfcal->l)
    {
      twotheta = TwoThetaDeg(lfcal->Q);
      d = lfcal->Q; if (d != 0) d = 1. / sqrt(d);

      Fprintf(stdout, " %3d %3d %3d %8.4f %7.3f",
        lfcal->h, lfcal->k, lfcal->l, d, twotheta);

      putc('\n', stdout);
    }

    lfcal++;
  }

  Fprintf(stdout, ">End List_hkl\n");
  putc('\n', stdout);
}
コード例 #5
0
ファイル: bs1d_doublim.c プロジェクト: jayhsieh/premia-13
int MOD_OPT(ChkMix)(Option *Opt,Model *Mod)
{
  TYPEOPT* ptOpt=(TYPEOPT*)(Opt->TypeOpt);
  TYPEMOD* ptMod=(TYPEMOD*)(Mod->TypeModel);
  int status=OK;
	
  /*Custom*/
  if (ptOpt->Maturity.Val.V_DATE<=ptMod->T.Val.V_DATE)
    {
      Fprintf(TOSCREENANDFILE,"Current date greater than maturity!\n");
      status+=1;
    };
  if ( ((ptOpt->LowerLimit.Val.V_NUMFUNC_1)->Compute)((ptOpt->LowerLimit.Val.V_NUMFUNC_1)->Par,ptMod->T.Val.V_DATE)>ptMod->S0.Val.V_PDOUBLE && (ptOpt->Parisian).Val.V_BOOL==WRONG)
    {
      Fprintf(TOSCREENANDFILE,"Limit Down greater than spot!\n");
      status+=1;
    };
  
  if ( ((ptOpt->UpperLimit.Val.V_NUMFUNC_1)->Compute)((ptOpt->UpperLimit.Val.V_NUMFUNC_1)->Par,ptMod->T.Val.V_DATE)<ptMod->S0.Val.V_PDOUBLE && (ptOpt->Parisian).Val.V_BOOL==WRONG)
    {
      Fprintf(TOSCREENANDFILE,"Limit Up lower than spot!\n");
      status+=1; 
  };
  /*EndCustom*/

  return status;
}
コード例 #6
0
ファイル: trialoop.c プロジェクト: stefsmeets/focus_package
static void PrintPhaseCode(T_PhaseCode *code)
{
  int      iCT, iTab;

  static int TabSymbol[] =
   {
     '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
     '-', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a',
     '0'
   };


  Fprintf(stdout, "PhaseCode(");

  for (iCT = 0; iCT < nActivePhase; iCT++)
  {
    if (iCT % 72 == 0) putc('\n', stdout);

        iTab = (code[iCT] + 9) / 18;
    if (iTab >= 0 && iTab < (sizeof TabSymbol / sizeof (*TabSymbol)))
      putc(TabSymbol[iTab], stdout);
    else
      putc('~', stdout);
  }

  Fprintf(stdout, "\n)");
}
コード例 #7
0
ファイル: ftools.c プロジェクト: jayhsieh/premia-13
int FSelectPricing(char InputFile[MAX_LINE][MAX_CHAR_LINE],int user,Model *pt_model,Option *pt_option,Pricing **pricing,Pricing **result)
{
  int i=-1;
  char dummy[MAX_CHAR_X3];

  if ((strlen(pt_model->ID)+1+strlen(pt_option->ID))>=MAX_CHAR_X3)
    {
      Fprintf(TOSCREEN,"%s\n",error_msg[PATH_TOO_LONG]);
      exit(WRONG);
    }

  strcpy(dummy,pt_model->ID);
  strcat(dummy,"_");
  strcat(dummy,pt_option->ID);

  do
    { 
      i=i+1;
    }
  while ((strcmp(dummy,pricing[i]->ID)!=0) && (pricing[i+1]!=NULL));

  if (strcmp(dummy,pricing[i]->ID)==0)
    {
      *result=pricing[i];
      return ((*result)->CheckMixing)(pt_option,pt_model) ;
    }
  Fprintf(TOSCREEN,"No choice available!\n");

  return PREMIA_NONE;
}
コード例 #8
0
ファイル: engine_graphvrml.cpp プロジェクト: rauls/iReporter
void VRML_Begin( FILE *f )
{
	fprintf( f, VRML_header );
	fprintf( f, "children [\n" );
	Fprintf( f, "\t\tNavigationInfo { headlight FALSE }\n" );
	Fprintf( f, "\t\tDirectionalLight {\n\t\t direction 0 -5 1 }\n\n" );
}
コード例 #9
0
ファイル: flate.c プロジェクト: sedic/xcircuit-3.8
u_long large_deflate (u_char *compr, u_long compr_len,
	u_char *uncompr, u_long uncompr_len) {

   z_stream c_stream; /* compression stream */
   int err;

   c_stream.zalloc = (alloc_func)0;
   c_stream.zfree = (free_func)0;
   c_stream.opaque = (voidpf)0;

   err = deflateInit(&c_stream, Z_BEST_SPEED);
   if (check_error(err, "deflateInit", c_stream.msg)) return 0;

   c_stream.next_out = compr;
   c_stream.avail_out = (u_int)compr_len;

   c_stream.next_in = uncompr;
   c_stream.avail_in = (u_int)uncompr_len;
   err = deflate(&c_stream, Z_NO_FLUSH);
   if (check_error(err, "deflate", c_stream.msg)) return 0;
   if (c_stream.avail_in != 0) {
      Fprintf(stderr, "deflate not greedy");
   }

   err = deflate(&c_stream, Z_FINISH);
   if (err != Z_STREAM_END) {
      Fprintf(stderr, "deflate should report Z_STREAM_END");
   }
   err = deflateEnd(&c_stream);
   if (check_error(err, "deflateEnd", c_stream.msg)) return 0;

   /* Fprintf(stdout, "large_deflate(): OK\n"); */

   return c_stream.total_out;
}
コード例 #10
0
void GetCom(FILE *f, VARPTR var, int flag)
{
    static char C[] = "GetRhsVar(%s,\"%s\",&m%d,&n%d,&l%d);\n";
    static char LC[] = "GetListRhsVar(%s,%d,\"%s\",&m%s,&n%s,&l%s);\n";
    int i1 = var->stack_position;
    if ( flag == 1 )
    {
        sprintf(str2, "k");
    }
    else
    {
        sprintf(str2, "%d", i1);
    }
    if (var->list_el == 0 )
    {
        /** A scilab matrix argument **/
        sprintf(str1, "%d", i1);
        Fprintf(f, indent, C, str2, SGetForTypeAbrev(var), i1, i1, i1);
        /* Adding the calling sequence in the for_names  */
        ChangeForName2(var, "%s(l%s)", SGetForTypeStack(var), str1);
    }
    else
    {
        /** A scilab matrix argument inside a list **/
        sprintf(str1, "%de%d", i1, var->list_el);
        Fprintf(f, indent, LC, str2, var->list_el, SGetForTypeAbrev(var), str1, str1, str1, str1);
        /* Adding the calling sequence in the for_names  */
        ChangeForName2(var, "%s(l%s)", SGetForTypeStack(var), str1);
    }
    AddDeclare1(DEC_INT, "m%s", str1);
    AddDeclare1(DEC_INT, "n%s", str1);
    AddDeclare1(DEC_INT, "l%s", str1);
}
コード例 #11
0
void Check(FILE *f, VARPTR var, int nel)
{
    VARPTR var1 = variables[var->el[nel] - 1];
    if ( var1->nfor_name == 0)
    {
        fprintf(stderr, "Pb with element number %d [%s] of variable %s\n",
                nel + 1, var1->name, var->name);
        return;
    }
    if (isdigit(var1->name[0]) != 0)
    {
        /* the dimension of the variable is a constant int */
        if ( strcmp(var1->for_name[0], var1->name) != 0)
        {
            if (var->list_el == 0 )
            {
                Fprintf(f, indent, "CheckOneDim(%d,%d,%s,%s);\n",
                        var->stack_position,
                        nel + 1,
                        var1->for_name[0], var1->name);
            }
            else
            {
                Fprintf(f, indent, "CheckListOneDim(%s,%d,%d,%s,%s);\n",
                        str2,
                        var->list_el,
                        nel + 1,
                        var1->for_name[0], var1->name);
            }
        }
    }
}
コード例 #12
0
ファイル: dtmmap.c プロジェクト: wanghao-xznu/vte
/************************************************************************
 *									*
 * mmap_validate_opts() - Validate Memory Mapped Test Options.		*
 *									*
 * Description:								*
 *	This function verifies the options specified for memory mapped	*
 * file testing are valid.						*
 *									*
 * Inputs:	dip = The device information pointer.			*
 *									*
 * Return Value:							*
 *		Returns SUCESS / FAILURE = Valid / Invalid Options.	*
 *									*
 ************************************************************************/
int
mmap_validate_opts (struct dinfo *dip)
{
    int status = SUCCESS;

    /*
     * For memory mapped I/O, ensure the user specified a limit, and
     * that the block size is a multiple of the page size (a MUST!).
     */
    if (mmap_flag) {
	if (data_limit == INFINITY) {
	    Fprintf ("You must specify a data limit for memory mapped I/O.\n");
	    status = FAILURE;
	} else if (block_size % page_size) {
	    Fprintf (
	"Please specify a block size modulo of the page size (%d).\n", page_size);
	    status = FAILURE;
	} else if (aio_flag) {
	    Fprintf ("Cannot enable async I/O with memory mapped I/O.\n");
	    status = FAILURE;
	} else {
	    status = validate_opts (dip);
	}
    }
    return (status);
}
コード例 #13
0
ファイル: Nuc3pt.C プロジェクト: DeanHowarth/QUDA-CPS
void Nuc3ptStru::PrintTheTag(FILE *fp)
{
  G.printTag(fp);
  Fprintf(fp,"_") ;
  D.printTag(fp) ;
  if(strlen(tag)>0) Fprintf(fp,"_%s",tag) ;
} 
コード例 #14
0
ファイル: intersci-n.c プロジェクト: rossdrummond/scilab
void WriteHeader(FILE * f, char *fname0, char *fname)
{
    Fprintf(f, indent, "\nint %s%s(char *fname)\n", fname0, fname);
    Fprintf(f, indent, "{\n");
    indent++;
    WriteDeclaration(f);
}
コード例 #15
0
ファイル: sync.c プロジェクト: leifwalsh/isync
static void
flags_set_sync_p2( sync_vars_t *svars, sync_rec_t *srec, int t )
{
	int nflags, nex;

	nflags = (srec->flags | srec->aflags[t]) & ~srec->dflags[t];
	if (srec->flags != nflags) {
		debug( "  pair(%d,%d): updating flags (%u -> %u)\n", srec->uid[M], srec->uid[S], srec->flags, nflags );
		srec->flags = nflags;
		Fprintf( svars->jfp, "* %d %d %u\n", srec->uid[M], srec->uid[S], nflags );
	}
	if (t == S) {
		nex = (srec->status / S_NEXPIRE) & 1;
		if (nex != ((srec->status / S_EXPIRED) & 1)) {
			if (nex && (svars->smaxxuid < srec->uid[S]))
				svars->smaxxuid = srec->uid[S];
			Fprintf( svars->jfp, "/ %d %d\n", srec->uid[M], srec->uid[S] );
			debug( "  pair(%d,%d): expired %d (commit)\n", srec->uid[M], srec->uid[S], nex );
			srec->status = (srec->status & ~S_EXPIRED) | (nex * S_EXPIRED);
		} else if (nex != ((srec->status / S_EXPIRE) & 1)) {
			Fprintf( svars->jfp, "\\ %d %d\n", srec->uid[M], srec->uid[S] );
			debug( "  pair(%d,%d): expire %d (cancel)\n", srec->uid[M], srec->uid[S], nex );
			srec->status = (srec->status & ~S_EXPIRE) | (nex * S_EXPIRE);
		}
	}
}
コード例 #16
0
ファイル: flate.c プロジェクト: sedic/xcircuit-3.8
int check_error(int err, char *prompt, char *msg) {
   if (err != Z_OK) {
      Fprintf(stderr, "%s error: %d", prompt, err);
      if (msg) Fprintf(stderr, "(%s)", msg);
      Fprintf(stderr, "\n");
      return 1;
   }
   return 0;
}
コード例 #17
0
ファイル: ftools.c プロジェクト: jayhsieh/premia-13
int FSelectTest(char InputFile[MAX_LINE][MAX_CHAR_LINE],int user,Planning *pt_plan,
                Pricing *pt_pricing, Option *opt,Model *mod,PricingMethod *met,DynamicTest **test)
{
  int i,ii,isub,k,j;
  DynamicTest** list;
  DynamicTest* dummy;
  char line[MAX_CHAR_LINE];
  if (pt_plan->Action=='t')
    {
      Fprintf(TOSCREEN,"\n_______________________TEST CHOICE:\n\n");
      list=pt_pricing->Test;
      i=0;isub=0;
      dummy=*list;
      while ( dummy !=NULL)
        {
          if( (dummy->CheckTest)(opt,mod,met) == OK)
            {   
              for(ii=0;ii<MAX_LINE;ii++){
                j=0;
                while(j<=(signed)(strlen(InputFile[ii])-strlen((pt_pricing->Test[i])->Name)))
                  {
                    if( (j==0 || (j>0 && InputFile[i][j-1]==' ')) &&
                        ( InputFile[i][j+strlen((pt_pricing->Test[i])->Name)] == ' ' ||
                          InputFile[i][j+strlen((pt_pricing->Test[i])->Name)] == '\0')
                      ){
                      for(k=j;k<j+(signed)strlen((pt_pricing->Test[i])->Name);k++)
                        line[k-j] = InputFile[ii][k];
                      line[j+(signed)strlen((pt_pricing->Test[i])->Name)]='\0';
                      if (StrCasecmp((pt_pricing->Test[i])->Name,line) == 0){
                        *test=pt_pricing->Test[i];
                        (*test)->Init(*test, opt);
                        goto ok;
                      }
                    }
                    j++;
                  }
              }
              isub++;
            }
          i=i+1;
          list++;dummy=*list;
        }


      if (isub==0)
        {
          Fprintf(TOSCREEN,"No test available!\n");
        }
      else
        {
          Fprintf(TOSCREEN,"No tests found, exiting....\n");
        }
    }
ok:
  return OK;
}
コード例 #18
0
ファイル: sitefcal.c プロジェクト: stefsmeets/focus_package
void DoSitePhases(void)
{
  int           iCT, iCTD, code;
  T_CodeTransl  *CT;
  T_CTData      *CTD;
  Fprec         CC, R;


  if (nSite < 1) return;

  PrepListSE();

  SiteCT_Fcal(CodeTransl, nActivePhase);
  CalcCCandR(CodeTransl, nActivePhase, &CC, &R);

  Fprintf(stdout, "# SiteCT_Fcal  CC = %.6g  R = %.3f\n\n", CC, R);

  CT = CodeTransl;

  for (iCT = 0; iCT < nActivePhase; iCT++)
  {
    Phi2Phi360(CT->FcalPhi, CT->Phi360Fcal);

    if (Debug0) /* Debug: Print SitePhases */
    Fprintf(stdout, "SP  %3d %3d %3d  %3d  %8.3f\n",
      CT->FobsRaw->h, CT->FobsRaw->k, CT->FobsRaw->l,
      CT->Phi360Fcal, CT->FcalPhi / PIover180);

    if (CT->nCTData < 1)
      InternalError("CT->nCTData < 1");

    CTD = CT->CTData;

    code = CT->Phi360Fcal - CTD->TH;
    if (code < 0) code += 360;

    if (CT->FobsRaw->PhaseRestriction >= 0)
    {
      if (code != 0 && code != 180)
        CheckRestrictedPhase(CT, &code);
    }

    for (iCTD = 0; iCTD < CT->nCTData; iCTD++)
    {
      CTD->TH += code;
      if (CTD->TH >= 360) CTD->TH -= 360;

      CTD++;
    }

    CT++;
  }

  FreeListSE();
}
コード例 #19
0
ファイル: sgasciio.c プロジェクト: stefsmeets/focus_package
void ListRestCond(FILE *fpout, T_hklCond *rst, int rstn, int debug)
{
  int   i,j,n,m;
  char  hkl[3]="hkl";
  int   x[3];
  int   S[3][3];
  int   first;
  char  buf[128];


  Fprintf(fpout, "Reflections with phase restriction\n");

  for(m=0;m<rstn;m++,rst++) {
    if (!debug && !rst->Exist ) continue;
    if (debug) Sprintf(buf,"%02d%c ", rst->iSymTr, rst->Exist?' ':'-');
    else buf[0]=0;
    (void) memcpy(S,rst->Mx,sizeof(S));
    (void) memcpy(x,rst->Gl,sizeof(x));

    for(j=0; j<3; j++){
      for(n=i=0; i<3; i++) if((n=S[i][j]) != 0) break;
      if(i==3)
        Sprintf(&buf[strlen(buf)],"0");
      else {
        if (n==1) Sprintf(&buf[strlen(buf)],"%1c",hkl[i]);
        else if (n==-1) Sprintf(&buf[strlen(buf)],"-%1c",hkl[i]);
        else Sprintf(&buf[strlen(buf)],"%d%1c",n,hkl[i]);
      }
    }

    n = rst->Denom;
    Sprintf(&buf[strlen(buf)],": ");
    if(!rst->Exist) Sprintf(&buf[strlen(buf)],"<");
    for(i=0,j=0; i<3; i++) j+=abs(x[i] % n);
    if (j) {
      Sprintf(&buf[strlen(buf)],"%d deg (",180/n);
      for(i=0,first=1; i<3; i++) if(x[i] % n) {
        if(x[i] <0) Sprintf(&buf[strlen(buf)],"-");
        else if (!first) Sprintf(&buf[strlen(buf)],"+");
        if(abs(x[i]) != 1) Sprintf(&buf[strlen(buf)],"%1d",abs(x[i]));
        first=0;

        Sprintf(&buf[strlen(buf)],"%1c",hkl[i]);
      }
      Sprintf(&buf[strlen(buf)],")");
    } else {
      Sprintf(&buf[strlen(buf)],"0 deg");
    }
    if(!rst->Exist) Sprintf(&buf[strlen(buf)],">");

    Fprintf(fpout, "  %s\n", buf);
  }

  putc('\n', fpout);
}
コード例 #20
0
ファイル: opt.c プロジェクト: rossdrummond/scilab
void OptOpointer(FILE *f,VARPTR var)
{

  Fprintf(f,indent++,"if ( %sok == 0) {\n",var->name);
  Fprintf(f,indent,"%spos=iopos=iopos+1;\n",var->name);
  Fprintf(f,indent,"CreateSCO(iopos,&lr%d,%s);\n",
	  var->stack_position,data);
  AddDeclare1(DEC_INT,"lr%d",var->stack_position);
  Fprintf(f,--indent,"}\n");

}
コード例 #21
0
void AlgFourierProp::ft(FILE *fp,MomentaList& mlist)
{
  char *fname="ft(FILE*,MomentaList&)";
  VRB.Func(cname,fname);
  
  //----------------------------------------------------------------
  // begin loop over momenta
  //----------------------------------------------------------------
  int nmom;
  for( nmom=0; nmom < mlist.size(); nmom++ ) 
    {
      //------------------------------------------------------------
      // Calculate single momenta
      //------------------------------------------------------------
      
      momprop=Float(0.0);
      
      calcmom(mlist[nmom]);
      
      //------------------------------------------------------------
      // Global sum
      //------------------------------------------------------------
      
      // 288 = 4 x 3(src) x 4 x 3(snk) x 2(re/im)
      // the final argument means which direction to exclude.
      // here 99 means NO exclusion and end up to be a global sum

      slice_sum((Float*)&momprop, 288, 99);
      
      //------------------------------------------------------------
      // Output to file
      //------------------------------------------------------------
      
      int s1,c1,s2,c2;
      Fprintf(fp,"MOMENTUM= %d %d %d %d \n",
              mlist[nmom].x(),
              mlist[nmom].y(),
              mlist[nmom].z(),
              mlist[nmom].t() );
      for( s1=0; s1<4; ++s1){ 
	for( c1=0; c1<3; ++c1){
	  for( s2=0; s2<4; ++s2){ 
	    for( c2=0; c2<3; ++c2){
	      Fprintf(fp, "%-25.15e %-25.15e \n",
		      (Float)momprop.wmat().d[s1].c[c1].d[s2].c[c2].real(),
		      (Float)momprop.wmat().d[s1].c[c1].d[s2].c[c2].imag());
	    }
	  }
	}
      }
    }   // end loop over momenta
}
コード例 #22
0
ファイル: sitefcal.c プロジェクト: stefsmeets/focus_package
static void PrintProfile(const Fprec *ProfileCounts, int nProfileSteps,
                         const T_StdPeak *StdPeak)
{
  int          iPS;
  Fprec        TT, Counts, ScaleF, MaxScaledCounts, ESD;


  Fprintf(stdout, ">Begin stepscan\n");

  Fprintf(stdout, "@with g0\n");

  ScaleF = ProfileScaleFactor(ProfileCounts, nProfileSteps, StdPeak);

  MaxScaledCounts = 0.;

  for (iPS = 0; iPS < nProfileSteps; iPS++)
  {
        TT = iPS * ProfileStep;
    if (TT + ProfileStep * .5 < ProfileStart)
      continue;
    if (TT - ProfileStep * .5 > ProfileEnd)
      break;

    Counts = ProfileBackground + ProfileCounts[iPS] * ScaleF;

        ESD = AppSqrt(Counts);
    if (ESD < 0.001)
        ESD = 0.001;

    Fprintf(stdout, "%12.3f %12.2f %12.3f\n",
      TT, Counts, ESD);

    if (MaxScaledCounts < Counts)
        MaxScaledCounts = Counts;
  }

  if (MaxScaledCounts == 0.)
      MaxScaledCounts = ProfileReferenceMax;
  if (MaxScaledCounts == 0.)
      MaxScaledCounts = 1.;

  Fprintf(stdout, "&\n");
  Fprintf(stdout, "@autoscale\n");

  Fprintf(stdout, "@ world xmin %.6g\n", ProfileStart);
  Fprintf(stdout, "@ world xmax %.6g\n", ProfileEnd);
  Fprintf(stdout, "@ world ymin %.6g\n", 0.);
  Fprintf(stdout, "@ world ymax %.6g\n", MaxScaledCounts);

  Fprintf(stdout, ">End stepscan\n");
  putc('\n', stdout);
}
コード例 #23
0
ファイル: intersci-n.c プロジェクト: rossdrummond/scilab
void WriteCrossCheck(FILE * f)
{
    int i, j;
    VARPTR var;

    Fprintf(f, indent, "/* cross variable size checking */\n");
    for (i = 0; i < nVariable; i++)
    {
        var = variables[i];
        if (var->type == DIMFOREXT)
        {
            if (var->nfor_name > 1)
            {
                for (j = 1; j < var->nfor_name; j++)
                {
                    /** we do not check square variables : this is done elsewhere */
                    /* we do not check external values since they are not known here */
                    if ((var->for_name_orig[j] != var->for_name_orig[j - 1]) && (var->for_name[j - 1][1] != 'e' && var->for_name[j][1] != 'e'))
                    {
                        Fprintf(f, indent, "CheckDimProp(%d,%d,%s != %s);\n",
                                var->for_name_orig[j - 1], var->for_name_orig[j], var->for_name[j - 1], var->for_name[j]);
                    }
                }
            }
        }
        else if (var->type == SCALAR)
        {
            /** some dimensions are given by a scalar input argument **/
            if (var->nfor_name > 1)
            {
                for (j = 1; j < var->nfor_name; j++)
                {
                    int dim = 2;

                    if (var->for_name[j][0] == 'm')
                        dim = 1;
                    if (var->for_name[j][1] != 'e') /* do not check external variables */
                    {
                        if (strncmp(var->for_name[0], "istk", 4) == 0)
                            Fprintf(f, indent, "CheckOneDim(%d,%d,%s,*%s);\n", var->for_name_orig[j], dim, var->for_name[j], var->for_name[0]);
                        else
                            Fprintf(f, indent, "CheckOneDim(%d,%d,%s,%s);\n", var->for_name_orig[j], dim, var->for_name[j], var->for_name[0]);
                    }
                }
            }
        }
    }
    /*
     * FCprintf(f,"/ *       cross formal parameter checking\n");
     * FCprintf(f," *      not implemented yet * /\n");  */
}
コード例 #24
0
ファイル: model.c プロジェクト: jayhsieh/premia-13
/**
 * Generic function to replace the Show member function of
 * the model structures
 *
 * @param user : an integer TOSCREEN or TOFILE
 * @param pt_plan : pointer the planning structure
 * describing what to do
 * @param model : pointer to the model instance
 */
int Show_model_gen(int user,Planning *pt_plan,Model *model)       
{
  void* pt=(model->TypeModel);
  VAR *var = ((VAR*)pt);
  VAR _bs;
  int   nvar = model->nvar, i, j;
  char *id = NULL;

  Fprintf(user,"##Model:%s\n",model->Name);

  for (i=0; i<nvar; i++)
    {
      PrintVar(pt_plan,user,&(var[i]));
      if (strncmp(var[i].Vname, "Annual Interest Rate", 20) == 0 ||
          strncmp(var[i].Vname, "Annual Dividend Rate", 20) == 0 )
        {
          if (id==NULL)
            {
              if ((id=malloc(33*sizeof(char)))==NULL)
                return MEMORY_ALLOCATION_FAILURE;
            }
          _bs.Vtype=DOUBLE;
          _bs.Val.V_DOUBLE=log(1+var[i].Val.V_DOUBLE/100);
          strcpy(id,  "-->Instantaneous");
          strcat(id, &(var[i].Vname[6]));
          _bs.Vname = id;
          _bs.Viter=FORBID;
          _bs.setter = NULL;
          _bs.Vsetable = SETABLE;
          if(var[i].Vtype==PNLVECT)
            {
              strcat(id, ": ");
              Fprintf(user, id);
              for(j=0; j<var[i].Val.V_PNLVECT->size; j++)
                {
                  _bs.Val.V_DOUBLE=log(1+var[i].Val.V_PNLVECT->array[j]/100);
                  Fprintf(user, "%f ", _bs.Val.V_DOUBLE);
                }
              Fprintf(user, "\n");
            }
          else
            {
              _bs.Val.V_DOUBLE=log(1+var[i].Val.V_DOUBLE/100);
              PrintVar(pt_plan,user,&_bs);
            }
        }
    }
  if (id!=NULL) {free(id); id=NULL;}
  return (model->Check)(user,pt_plan,model);
}
コード例 #25
0
WP_status upi_stm1_stat_get(WP_U32 stm1id,STRU_UPI_STATICS *p)
{
    WP_status status;
    WP_U16 i;
    STRU_UPI_STATICS pos_fr;
    STRU_SET_INITAIL_CONFIG *initial_cfg = npu_get_initial_cfg_info();
    WP_U32 line_index_base,line_index_counts;

    if(initial_cfg->stru_stm1_cfg_info[stm1id].E1T1type == NPU_MODE_E1)
    {
        line_index_base = stm1id*N_UFE_MAX_LINES_E1/2;
        line_index_counts = (1+stm1id)*N_UFE_MAX_LINES_E1/2;
    }
    else
    {
        line_index_base = stm1id*N_UFE_MAX_LINES_T1/2;
        line_index_counts = (1+stm1id)*N_UFE_MAX_LINES_T1/2;

    }

    if(NPU_VALID == initial_cfg->stru_stm1_cfg_info[stm1id].stm1Valid)
    {
        memset (&pos_fr, 0, sizeof(STRU_UPI_STATICS));
        for(i = line_index_base; i < line_index_counts; i ++)
        {
            if(NPU_VALID == initial_cfg->stru_stm1_cfg_info[stm1id].trunk_info[i-line_index_base].trunkValid)
            {
                memset(p, 0, sizeof(STRU_UPI_STATICS));
                status = upi_stat_get_by_trunk(i,p);
                if(-1 == status)
                {
                    continue;
                }
                if (status)
                {
                    Fprintf("Error upi_stat_get_by_trunk!\n");
                    return status;
                }
                struct_upi_statics_add(&pos_fr, p);
            }
        }
        memcpy((void *)p,(void *)&pos_fr,sizeof(pos_fr));
    }
    else
    {
        Fprintf("This stm1 %d is not configed!\n",stm1id);
        return -1;
    }
    return WP_OK;
}
コード例 #26
0
void GetSCALAR(FILE *f, VARPTR var, int flag)
{
    int i1 = var->stack_position;
    GetCom(f, var, flag);
    /* Check(f,var,0); */
    if (var->list_el == 0 )
    {
        Fprintf(f, indent, "CheckScalar(%d,m%d,n%d);\n", i1, i1, i1);
    }
    else
    {
        sprintf(str1, "%de%d", i1, var->list_el);
        Fprintf(f, indent, "CheckListScalar(%d,%d,m%s,n%s);\n", i1, var->list_el, str1, str1);
    }
}
コード例 #27
0
void CheckSquare(FILE *f, VARPTR var, char *str1_, char *str2_)
{
    if (var->el[0] != var->el[1])
    {
        return ;
    }
    if (var->list_el == 0 )
    {
        Fprintf(f, indent, "CheckSquare(%d,m%s,n%s);\n", var->stack_position, str1_, str1_);
    }
    else
    {
        Fprintf(f, indent, "CheckListSquare(%s,%d,m%s,n%s);\n", str2_, var->list_el, str1_, str1_);
    }
}
コード例 #28
0
ファイル: tile2x11.c プロジェクト: chasonr/unnethack-i18n
/* Open the given file, read & merge the colormap, convert the tiles. */
static void
process_file(char *fname)
{
    unsigned long count;

    if (!fopen_text_file(fname, RDTMODE)) {
        Fprintf(stderr, "can't open file \"%s\"\n", fname);
        exit(1);
    }
    merge_text_colormap();
    count = convert_tiles(&curr_tb, header.ntiles);
    Fprintf(stderr, "%s: %lu tiles\n", fname, count);
    header.ntiles += count;
    fclose_text_file();
}
コード例 #29
0
ファイル: method.c プロジェクト: jayhsieh/premia-13
int FixMethod(Planning *pt_plan, PricingMethod *pt_method)
{
  int i,j;
  char msg,answer;

  if (pt_plan->NumberOfMethods == 0)
    return OK;

  for (j=0; j<pt_plan->VarNumber && pt_plan->Par[j].Location->Vtype!=PREMIA_NULLTYPE; ++j){
    for (i=0; pt_method->Par[i].Vtype!=PREMIA_NULLTYPE; ++i){ 
      if (!strcmp(pt_method->Par[i].Vname,pt_plan->Par[j].Location->Vname))
	{
	  pt_plan->Par[j].Location = &pt_method->Par[i];
	  pt_method->Par[i].Viter=ALREADYITERATED+j;  
	  return DONOTITERATE; 
	}
      else if (CompareParameterNames(pt_method->Par[i].Vname,pt_plan->Par[j].Location->Vname)==OK)
	{
	  Fprintf(TOSCREEN,"\nWould you like to iterate \"%s\" like \"%s\" \n\t\t (ok: Return, no: n) ? \t",pt_method->Par[i].Vname, pt_plan->Par[j].Location->Vname);
	  answer = (char)tolower(fgetc(stdin));
	  msg = answer;
	  while( (answer != '\n') && (answer != EOF))
	    answer = (char)fgetc(stdin);
	  if (msg=='\n')
	    {
	      pt_plan->Par[j].Location = &pt_method->Par[i];
	      pt_method->Par[i].Viter=ALREADYITERATED+j;
	      return DONOTITERATE; 
	    }
	}
      else if  (pt_method->Par[i].Vtype == pt_plan->Par[j].Location->Vtype)
	{
	  Fprintf(TOSCREEN,"\nWould you like to iterate \"%s\" like \"%s\" \n\t\t (ok: Return, no: n) ? \t",pt_method->Par[i].Vname, pt_plan->Par[j].Location->Vname);
	  answer = (char)tolower(fgetc(stdin));
	  msg = answer;
	  while( (answer != '\n') && (answer != EOF))
	    answer = (char)fgetc(stdin);
	  if (msg=='\n')
	    {
	      pt_plan->Par[j].Location = &pt_method->Par[i];
	      pt_method->Par[i].Viter=ALREADYITERATED+j;
	      return DONOTITERATE;
	    }
	}
    }
  }
  return OK;
}
コード例 #30
0
ファイル: ftools.c プロジェクト: jayhsieh/premia-13
int FMoreAction(char InputFile[MAX_LINE][MAX_CHAR_LINE],int *count)
{
  //char msg='p';
  int i0=0,i,j;
  //int listline[MAX_LINE];
  if (*count==(MAX_METHODS-1))
    {
      Fprintf(TOSCREEN,"\n Max Number of Methds Reached!\n");
      //msg='n';
    }else{
      i0=0;
      for(i=0;i<MAX_LINE;i++){
        if(strlen(InputFile[i])>1){
          j=0;
          while(isalpha(InputFile[i][j])==0)
            j++;
          if(((InputFile[i][j]=='M') || (InputFile[i][j]=='m')) && ((InputFile[i][j+1]=='A')
                                                                    ||(InputFile[i][j+1]=='a'))){
            //listline[i0]=i;
            i0++;
          }
        }
      }


    }
  if(i0==(*count))
    return WRONG;
  else{
    (*count)++; 
    return OK;
  }
}