コード例 #1
0
/**
 * Verifies script execution of the zeroth scriptPubKey of tx output and
 * zeroth scriptSig and witness of tx input.
 */
static ScriptError VerifyWithFlag(const CTransaction& output, const CMutableTransaction& input, int flags)
{
    ScriptError error;
    CTransaction inputi(input);
    bool ret = VerifyScript(inputi.vin[0].scriptSig, output.vout[0].scriptPubKey, &inputi.vin[0].scriptWitness, flags, TransactionSignatureChecker(&inputi, 0, output.vout[0].nValue), &error);
    BOOST_CHECK((ret == true) == (error == SCRIPT_ERR_OK));

    return error;
}
コード例 #2
0
ファイル: test_macII.c プロジェクト: ajsecord/liblayout
void main(int argc, char *argv[])
{
  gq_args param;
  macopt_args a ;
  double *x ;
  int n ;
  double epsilon=0.001 ;

  /* Load up the parameters of the function that you want to optimize */
  printf("============================================================\n");
  printf("= Demonstration program for macopt                         =\n");
  printf("= Solves A x = b by minimizing the function 1/2 xAx - bx   =\n");
  printf("= A must be positive definite (e.g. 2 1 1 2)               =\n");
  printf("\n  Dimension of A (eg 2)?\n");
  inputi(&(param.n));
  n=param.n; 
  param.A=dmatrix(1,n,1,n);
  param.b=dvector(1,n);
  x=dvector(1,n);
  typeindmatrix(param.A,1,n,1,n);
  printf("  b vector?\n");
  typeindvector(param.b,1,n);
  printf("  Initial condition x?\n");
  typeindvector(x,1,n);

  /* Check that the gradient_function is the gradient of the function  */
  /* You don't have to do this, but it is a good idea when debugging ! */
  maccheckgrad (  x , param.n , epsilon , 
		quadratic , (void *)(&param) , 
		vgrad_quadratic , (void *)(&param) , 
		0
		) ;

  /* initialize the arguments of the optimizer */
  macopt_defaults ( &a ) ; 

  /* modify macopt parameters from their default values */
  a.do_newitfunc = 1 ; /* this means that I want to have an auxiliary
			  subroutine executed each iteration of the 
			  optimization */
  a.newitfunc = &state_printer ; /* setting the function to be performed to
				  T_return */
  a.newitfuncarg = (void *)(&param) ;
  a.verbose = 2 ; 

  /* Do an optimization */
  macoptII ( x , param.n , 
	    vgrad_quadratic , (void *)(&param) , &a
	    ) ;

  printf("Solution:\n");
  quadratic(x,&param);
}
コード例 #3
0
ファイル: t3.c プロジェクト: kingfree/haut
int main()
{
    int n, i;
    char *s[16], t[256];
    inputi(n);
    for (i = 0; i < n; i++) {
        scanf("%s", t);
        s[i] = (char *) calloc(strlen(t), sizeof(t));
        strcpy(s[i], t);
    }
    printf("%d\n", max_len(s, n));
    return 0;
}
コード例 #4
0
ファイル: PGMain.cpp プロジェクト: glycerine/lrstar
int   PG::Start (int na, char *arg []) /* Display program information. */
{
      int i, ne, filedesc, rc;
		char dn[256], fn[256], ft[256], string[64];

      time1 = clock();

		if (!inputi ("")) PG::Terminate (0);

		line_ptr     = ::line_ptr;
		input_start  = ::input_start;
		input_end    = ::input_end;

		for (i = 0; i < 159; i++) spaces [i] = ' ';

		memory_usage  = 0;
		memory_max    = 0;
      ne            = 0;
      n_warnings    = 0;
      n_errors      = 0;

		return 1;
}
コード例 #5
0
ファイル: robTrajectory.cpp プロジェクト: Shuyoung/cisst
// Insert a function in the trajectory
robFunction::Errno robTrajectory::Insert( robFunction* function,
					  double ti, double tf ){

  // Test that the initial time and final time are coherent
  if( (ti < 0) || (tf < 0) || (tf <= ti) ){
    CMN_LOG_RUN_ERROR << CMN_LOG_DETAILS 
		      << ": " << ti << " must be less than " << tf << "." 
		      << std::endl;
    return robFunction::EFAILURE;
  }

  // Test that the function exists
  if( function == NULL ) { 
    CMN_LOG_RUN_ERROR << CMN_LOG_DETAILS 
		      << ": Function is NULL" 
		      << std::endl;
    return robFunction::EFAILURE;
  }

  // Ensure that the domain of the function matches the domain of the trajectory
  if( (function->Domain()!=Domain()) || (function->Codomain()!=Codomain()) ){
    CMN_LOG_RUN_ERROR << CMN_LOG_DETAILS 
		      << ": Spaces do not match."
		      << std::endl;
    return robFunction::EFAILURE;
  }

  // Ensure that the function is defined for ti
  robVariable inputi( ti );
  if( function->GetContext( inputi ) != robFunction::CDEFINED ){
    CMN_LOG_RUN_ERROR << CMN_LOG_DETAILS 
		      << ": Function is undefined for initial time " << ti 
		      << std::endl;
    return robFunction::EFAILURE;
  }

  // Ensure that the function is defined for tf
  robVariable inputf( tf );
  if( function->GetContext( inputf ) != robFunction::CDEFINED ){
    CMN_LOG_RUN_ERROR << CMN_LOG_DETAILS 
		      << ": Function is undefined for final time " << tf
		      << std::endl;
    return robFunction::EFAILURE;
  }

  // Create the motion segment
  robTrajectory::Segment segment( ti, tf, function );
 
  // Is this the first segment? If yes, then we can't blend. Thus insert the
  // segment as is.
  if( segments.size() == 0 ){
    segments.push_back( segment );
    return robFunction::ESUCCESS;
  }

  // Create a blender to blend the last segment and the new segment
  robTrajectory::Segment blender = GenerateBlender( segments.back(), segment );

  // now we must adjust the time of both segments...
  segments.back().tf = blender.ti;  // adjust the final time of the last segment
                                    // to the start time of the blending segment
  segment.ti = blender.tf;          // adjust the initial time of the new segment
                                    // to the final time of the blending segment
  segments.push_back( blender );    // insert the blending segment
  segments.push_back( segment );    // insert the motion segment

  return robFunction::ESUCCESS;
}  
コード例 #6
0
ファイル: LGMain.cpp プロジェクト: Kampbell/lrstar
int   LG::Start (int na, char *arg []) /* Display program information. */
{
      int i, ne, filedesc, a, x, rc;
		char dn[256], fn[256], ft[256], string[64];

      time1 = clock();
		memory_usage  		 =  0;
		memory_max    		 =  0;
      ne            		 =  0;
      n_errors      		 =  0;
		max_child_usage    =  0;
      exefid[0]          =  0;
		illegal_char_state = -1; 

		for (i = 0; i < 256; i++) spaces [i] = ' ';

		strcpy (gft, ".lgr");
		strcpy (grmfid, gdn);
		strcat (grmfid, gfn);
		strcat (grmfid, gft);

		open_con (grmfid);
		open_grm (grmfid);
		open_sta (grmfid);

		strcpy (gft, ".lex");
		strcpy (grmfid, gdn);
		strcat (grmfid, gfn);
		strcat (grmfid, gft);

		filedesc = open (grmfid, 0);	// Open .lex file first. 
		if (filedesc >= 0)				// .lex file found!
		{
			prt_log ("%s.lex file: reading ...\n", gfn);
			if (!inputi ("%%")) return 0;
			lex_input_start = input_start;
			lex_input_end   = input_end;
			lex_line_ptr    = line_ptr;
		}
		else
		{
			prt_log ("%s.lex file: not found.\n", gfn);
			prt_log ("%s.lgr file: reading ...\n\n", gfn);
			strcpy (gft, ".lgr");
			strcpy (grmfid, gdn);
			strcat (grmfid, gfn);
			strcat (grmfid, gft);
			if (!inputi ("")) return 0;
			lex_input_start = 0;
			lex_input_end   = 0;
			lex_line_ptr    = 0;
		}

		for (i = 0; i < 159; i++) spaces [i] = ' ';

		memory_usage  = 0;
		memory_max    = 0;
      ne            = 0;
      n_warnings    = 0;
      n_errors      = 0;
		return 1;
}