当前位置: 首页>>代码示例>>C++>>正文


C++ Solver函数代码示例

本文整理汇总了C++中Solver函数的典型用法代码示例。如果您正苦于以下问题:C++ Solver函数的具体用法?C++ Solver怎么用?C++ Solver使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Solver函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: solve

void
UPolynomial<T>::
solve(const RationalFunctionP& rf, RootStack& stack)
{
	typedef SYNAPS::Seq<RootType>		RootSeq;

    AssertMsg(stack.empty(), "Stack must be empty before solve");

	RootSeq seq_num = SYNAPS::solve(SynapsTraits<T>::convert(rf.numerator()), Solver());
	RootSeq seq_den = SYNAPS::solve(SynapsTraits<T>::convert(rf.denominator()), Solver());

	// TODO: assert that all roots in seq_den have positive multiplicity
	// TODO: deal with multiplicities for the numerator
	for (typename RootSeq::const_reverse_iterator cur = seq_num.rbegin(); 
												  cur != seq_num.rend(); 
												  ++cur)
	{
		if (SynapsTraits<T>::multiplicity(*cur) % 2 != 0)
		{		
			if (!stack.empty() && stack.top() == *cur)			// get rid of even multiplicities
				// TODO: add logging information for this
				stack.pop();
			else
				stack.push(*cur);
		}
	}
}
开发者ID:Magnulas,项目名称:pmex,代码行数:27,代码来源:polynomial.hpp

示例2: AreInputsStandard

bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
{
    if (tx.IsCoinBase())
        return true; // Coinbases don't use vin normally

    for (unsigned int i = 0; i < tx.vin.size(); i++)
    {
        const CTxOut& prev = mapInputs.GetOutputFor(tx.vin[i]);

        std::vector<std::vector<unsigned char> > vSolutions;
        txnouttype whichType;
        // get the scriptPubKey corresponding to this input:
        const CScript& prevScript = prev.scriptPubKey;
        if (!Solver(prevScript, whichType, vSolutions))
            return false;
        int nArgsExpected = ScriptSigArgsExpected(whichType, vSolutions);
        if (nArgsExpected < 0)
            return false;

        // Transactions with extra stuff in their scriptSigs are
        // non-standard. Note that this EvalScript() call will
        // be quick, because if there are any operations
        // beside "push data" in the scriptSig
        // IsStandardTx() will have already returned false
        // and this method isn't called.
        std::vector<std::vector<unsigned char> > stack;
        if (!EvalScript(stack, tx.vin[i].scriptSig, SCRIPT_VERIFY_NONE, BaseSignatureChecker()))
            return false;

        if (whichType == TX_SCRIPTHASH)
        {
            if (stack.empty())
                return false;
            CScript subscript(stack.back().begin(), stack.back().end());
            std::vector<std::vector<unsigned char> > vSolutions2;
            txnouttype whichType2;
            if (Solver(subscript, whichType2, vSolutions2))
            {
                int tmpExpected = ScriptSigArgsExpected(whichType2, vSolutions2);
                if (tmpExpected < 0)
                    return false;
                nArgsExpected += tmpExpected;
            }
            else
            {
                // Any other Script with less than 15 sigops OK:
                unsigned int sigops = subscript.GetSigOpCount(true);
                // ... extra data left on the stack after execution is OK, too:
                return (sigops <= MAX_P2SH_SIGOPS);
            }
        }

        if (stack.size() != (unsigned int)nArgsExpected)
            return false;
    }

    return true;
}
开发者ID:MasterX1582,项目名称:bitcoin-becoin,代码行数:58,代码来源:policy.cpp

示例3: AreInputsStandard

bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
{
    if (tx.IsCoinBase())
        return true; // Coinbases don't use vin normally

    for (unsigned int i = 0; i < tx.vin.size(); i++)
    {
        const CTxOut& prev = mapInputs.AccessCoin(tx.vin[i].prevout).out;

        std::vector<std::vector<unsigned char> > vSolutions;
        txnouttype whichType;
        // get the scriptPubKey corresponding to this input:
        const CScript& prevScript = prev.scriptPubKey;
        if (!Solver(prevScript, whichType, vSolutions))
            return false;

        if (whichType == TX_SCRIPTHASH)
        {
            std::vector<std::vector<unsigned char> > stack;
            // convert the scriptSig into a stack, so we can inspect the redeemScript
            if (!EvalScript(stack, tx.vin[i].scriptSig, SCRIPT_VERIFY_NONE, BaseSignatureChecker(), SIGVERSION_BASE))
                return false;
            if (stack.empty())
                return false;
            CScript subscript(stack.back().begin(), stack.back().end());
            if (subscript.GetSigOpCount(true) > MAX_P2SH_SIGOPS) {
                return false;
            }
        }
    }

    return true;
}
开发者ID:bsjung,项目名称:bitcoin,代码行数:33,代码来源:policy.cpp

示例4: Solver

void Solver()
{
    int i, j, k;
    if(FullFill())
    {
        OutputSudoku();
        return;
    }
    for(i=0; i<9; i++)
    {
        for(j=0; j<9; j++)
        {
            if(Sudoku[i][j]==0)
            {
                for(k=1; k<10; k++)
                {
                    if(Check(i, j, k))
                    {
                        Sudoku[i][j]=k;
                        Solver();
                    }
                }
                if(k==10)
                {
                    Sudoku[i][j]=0;
                    return;
                }
            }
        }
    }
}
开发者ID:Karikaturist,项目名称:WPC,代码行数:31,代码来源:OLIMEX_WPC28_Sudoku_Miller.c

示例5: Dispatcher

bool PhysicsEngine::Init(double dGravity, double dTimeStep,
                         double nMaxSubSteps){
  timestep_    = dTimeStep;
  gravity_acc_     = dGravity;
  time_max_substeps_ = nMaxSubSteps;

  // Physics stuff
  // See http://bulletphysics.org/mediawiki-1.5.8/index.php/Hello_World

  std::shared_ptr<btCollisionDispatcher> Dispatcher(
      new btCollisionDispatcher(&collision_configuration_) );
  bt_dispatcher_ = Dispatcher;

  std::shared_ptr<btDbvtBroadphase> Broadphase( new btDbvtBroadphase );
  bt_broadphase_ = Broadphase;

  std::shared_ptr<btSequentialImpulseConstraintSolver> Solver(
      new btSequentialImpulseConstraintSolver );
  bt_solver_ = Solver;
  std::shared_ptr<btDiscreteDynamicsWorld> DWorld(
      new btDiscreteDynamicsWorld(bt_dispatcher_.get(),
                                  bt_broadphase_.get(),
                                  bt_solver_.get(),
                                  &collision_configuration_) );
  dynamics_world_ = DWorld;
  dynamics_world_->setGravity( btVector3(0, 0,  gravity_acc_) );
  dynamics_world_->setDebugDrawer( &debug_drawer_ );
  dynamics_world_->getDebugDrawer()->
      setDebugMode(btIDebugDraw::DBG_DrawWireframe +
                   btIDebugDraw::DBG_FastWireframe +
                   btIDebugDraw::DBG_DrawConstraints);
  vehicle_raycaster_ = new btDefaultVehicleRaycaster(dynamics_world_.get());
  return true;
}
开发者ID:arpg,项目名称:simba,代码行数:34,代码来源:PhysicsEngine.cpp

示例6: root

SynapsTraits<QQ>::RootType
SynapsTraits<QQ>::
root(const CoefficientType& r)
{
	ZZ p[2] = { -SYNAPS::numerator(r), SYNAPS::denominator(r) };
	return SYNAPS::solve(SolverPolynomial(2, p), Solver(), 0); 
}
开发者ID:Magnulas,项目名称:pmex,代码行数:7,代码来源:polynomial.hpp

示例7: film

double FilmMinimizerTM::func(const gsl_vector * x, void * params)
{
	double ret=100; int status;
	FilmFuncParams* p=(FilmFuncParams*)params;
	double &n1=p->n1, &n3=p->n3, &k=p->k, *bettaexp=p->bettaexp;
	FilmParams film(x);

	DispEqTMSolver Solver(DispEqTMFuncParams(n1, film.n, n3, k*film.H));
	if( (status=Solver.Run(n3,film.n, 1e-6)) ==GSL_SUCCESS) 
	{
		int i,j,roots_n=Solver.roots.GetSize(),betta_n=Solver.min_roots; double cur_ret;
		for(i=0;i<=roots_n-betta_n;i++)
		{
			cur_ret=0;			
			for(j=0;j<betta_n;j++)
			{
				cur_ret+=abs(Solver.roots[j+i]-bettaexp[j]);
			}
			if(cur_ret<ret) 
			{
				ret=cur_ret;
				p->betta_teor.RemoveAll(); betta_info t;
				for(j=0;j<betta_n;j++)
				{
					t.val=Solver.roots[j+i]; t.n=j+i; p->betta_teor.Add(t);
				}
			}
		}
	}
	func_call_cntr+=DispEqTMSolver::func_call_cntr;
	return ret;
}
开发者ID:mar80nik,项目名称:Tracker,代码行数:32,代码来源:metricon.cpp

示例8: ExtractDestination

bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet)
{
    std::vector<valtype> vSolutions;
    txnouttype whichType;
    if (!Solver(scriptPubKey, whichType, vSolutions))
        return false;

    if (whichType == TX_PUBKEY)
    {
        CPubKey pubKey(vSolutions[0]);
        if (!pubKey.IsValid())
            return false;

        addressRet = pubKey.GetID();
        return true;
    }
    else if (whichType == TX_PUBKEYHASH)
    {
        addressRet = CKeyID(uint160(vSolutions[0]));
        return true;
    }
    else if (whichType == TX_SCRIPTHASH)
    {
        addressRet = CScriptID(uint160(vSolutions[0]));
        return true;
    }
    // Multisig txns have more than one address...
    return false;
}
开发者ID:syscoin,项目名称:syscoin2,代码行数:29,代码来源:standard.cpp

示例9: SignStep

/**
 * Sign scriptPubKey using signature made with creator.
 * Signatures are returned in scriptSigRet (or returns false if scriptPubKey can't be signed),
 * unless whichTypeRet is TX_SCRIPTHASH, in which case scriptSigRet is the redemption script.
 * Returns false if scriptPubKey could not be completely satisfied.
 */
static bool SignStep(const SigningProvider& provider, const BaseSignatureCreator& creator, const CScript& scriptPubKey,
                     std::vector<valtype>& ret, txnouttype& whichTypeRet, SigVersion sigversion)
{
    CScript scriptRet;
    uint160 h160;
    ret.clear();

    std::vector<valtype> vSolutions;
    if (!Solver(scriptPubKey, whichTypeRet, vSolutions))
        return false;

    CKeyID keyID;
    switch (whichTypeRet)
    {
    case TX_NONSTANDARD:
    case TX_NULL_DATA:
    case TX_WITNESS_UNKNOWN:
        return false;
    case TX_PUBKEY:
        keyID = CPubKey(vSolutions[0]).GetID();
        return Sign1(provider, keyID, creator, scriptPubKey, ret, sigversion);
    case TX_PUBKEYHASH:
        keyID = CKeyID(uint160(vSolutions[0]));
        if (!Sign1(provider, keyID, creator, scriptPubKey, ret, sigversion))
            return false;
        else
        {
            CPubKey vch;
            provider.GetPubKey(keyID, vch);
            ret.push_back(ToByteVector(vch));
        }
        return true;
    case TX_SCRIPTHASH:
        if (provider.GetCScript(uint160(vSolutions[0]), scriptRet)) {
            ret.push_back(std::vector<unsigned char>(scriptRet.begin(), scriptRet.end()));
            return true;
        }
        return false;

    case TX_MULTISIG:
        ret.push_back(valtype()); // workaround CHECKMULTISIG bug
        return (SignN(provider, vSolutions, creator, scriptPubKey, ret, sigversion));

    case TX_WITNESS_V0_KEYHASH:
        ret.push_back(vSolutions[0]);
        return true;

    case TX_WITNESS_V0_SCRIPTHASH:
        CRIPEMD160().Write(&vSolutions[0][0], vSolutions[0].size()).Finalize(h160.begin());
        if (provider.GetCScript(h160, scriptRet)) {
            ret.push_back(std::vector<unsigned char>(scriptRet.begin(), scriptRet.end()));
            return true;
        }
        return false;

    default:
        return false;
    }
}
开发者ID:CryptoRekt,项目名称:VERGE,代码行数:65,代码来源:sign.cpp

示例10: CombineSignatures

SignatureData CombineSignatures(const CScript& scriptPubKey, const BaseSignatureChecker& checker,
                          const SignatureData& scriptSig1, const SignatureData& scriptSig2)
{
    txnouttype txType;
    std::vector<std::vector<unsigned char> > vSolutions;
    Solver(scriptPubKey, txType, vSolutions);

    return CombineSignatures(scriptPubKey, checker, txType, vSolutions, Stacks(scriptSig1), Stacks(scriptSig2), SIGVERSION_BASE).Output();
}
开发者ID:21E14,项目名称:bitcoin,代码行数:9,代码来源:sign.cpp

示例11: double

mat Scheme::implicitScheme(int nSteps, double tSteps, double(*u_s)(double))
{
	//input: nSteps (# of interior points), time, tSteps, u_s(x)

	double deltaX = 1.0 / (nSteps + 1);
	double deltaT = 1.0 / tSteps;
	double alpha = deltaT / pow(deltaX,2);

	vec v(nSteps), vNext(nSteps), u(nSteps);
	int printIndex = tSteps / 10;
	mat M(printIndex, nSteps);
	int index = 0;

	for( int i = 0; i < nSteps; i++)
	{
		double x = (i + 1) * deltaX;
		vNext[i] = v[i] = -u_s(x);
	}
	// Boundary conditions
	v[0] = vNext[0] = v[nSteps] = vNext[nSteps] = 0;
	
	double a = -alpha;        // diagonal element
	double b = 1 + 2*alpha;   // off-diagonal element

	Solver solv = Solver();
	for(int t = 1; t <= tSteps; t++)
	{
		solv.tridiagonalSolver(a, b, v, vNext);
		
		// Initial conditions
		vNext[0] = vNext[nSteps] = 0;
		v = vNext;

		for (int i = 0; i < nSteps; i++)
		{
			double x = (i + 1) * deltaX;
			u[i] = v[i] + u_s(x);
		}

		// Print to file !
		if (t % 10 == 0)
		{
			for (int i = 0; i < nSteps; i++)
				M(index, i) = u[i];
			index++;
		}
	}

	for (int i = 0; i < printIndex; i++)
	{
		for (int j = 0; j < nSteps; j++)
			printf("%f \t", M(i, j));
	}

	return M;	
}
开发者ID:NathalieB,项目名称:Project4,代码行数:56,代码来源:Scheme.cpp

示例12: main

int main()
{
  const int n     = 500;           // Number of atoms, molecules
  const int mt    = 20;         // Max time steps
  const int dtxyz = 100;           // Time interval to output xyz 

  int i;
  int j;

  double *x;
  double *v;
  double *f;

  const double domain = 300;       // Domain size (a.u.)
  const double dt     = 10;        // Time interval (a.u.)
  const double ms     = 0.0;       // Max speed (a.u.)
  const double em     = 1822.88839 * 28.0134; // Effective mass of N2
  const double lje    = 0.000313202;          // Lennard-Jones epsilon of N2
  const double ljs    = 6.908841465;          // Lennard-Jones sigma of N2

  #ifdef MKLRNG
  VSLStreamStatePtr stream; 

  vslNewStream(&stream, VSL_BRNG_MT19937,   5489); // Initiation, type, seed
  //vslNewStream(&stream, VSL_BRNG_SFMT19937, 5489); // Initiation, type, seed
  #endif

  x = (double *) malloc(n * 3 * sizeof(double));
  v = (double *) malloc(n * 3 * sizeof(double));
  f = (double *) malloc(n * 3 * sizeof(double));

  // Initialization


  for (i=0; i<n; i++)
    for (j=0; j<3; j++) x[i*3+j] = domain * rand() / (RAND_MAX + 1.0);

  for (i=0; i<n; i++)
    for (j=0; j<3; j++) v[i*3+j] = ms * (rand() / (RAND_MAX + 1.0) - 0.5);


  // Dynamics
  printf("#  Index    dTime    KinEng      PotEng       TotEng\n");
  for (i=0; i<mt; i++)
    {
      Force(n, lje, ljs, x, f);
      Solver(n, dt, em, x, v, f);

      Output_energy(i, n, dt, em, lje, ljs, x, v);
      if (i % dtxyz == 0) Output_xyz(i, n, x);
    }

  Output_xyz(i, n, x);

  return 0;
}
开发者ID:wbkifun,项目名称:my_stuff,代码行数:56,代码来源:Serial_LJ_01.c

示例13: findOutputInTransaction

bool
findOutputInTransaction( CTransaction const & _tx, CKeyID const & _findId, std::vector< CTxOut > & _txouts, std::vector< unsigned int > & _ids )
{
	for (unsigned int i = 0; i < _tx.vout.size(); i++)
	{
		const CTxOut& txout = _tx.vout[i];

		opcodetype opcode;

		std::vector<unsigned char> data;

		CScript::const_iterator pc = txout.scriptPubKey.begin();
	//sanity check
		while( pc != txout.scriptPubKey.end() )
		{
			if (!txout.scriptPubKey.GetOp(pc, opcode, data))
				return false;
		}
		txnouttype type;

		std::vector< std:: vector<unsigned char> > vSolutions;
		if (Solver(txout.scriptPubKey, type, vSolutions) &&
			(type == TX_PUBKEY || type == TX_PUBKEYHASH))
		{
			std::vector<std::vector<unsigned char> >::iterator it = vSolutions.begin();

			while( it != vSolutions.end() )
			{
				if ( type == TX_PUBKEY )
				{
					// impossible  to be here ??
					if ( _findId == Hash160( *it ) )
					{
						_txouts.push_back( txout );
						_ids.push_back( i );
					}
				}
				else
				{
					if ( _findId == uint160( *it ) )
					{
						_txouts.push_back( txout );
						_ids.push_back( i );
					}
				}
				it++;
			}
		}

	}
	return !_txouts.empty();
}
开发者ID:salivan-ratcoin-dev-team,项目名称:dims,代码行数:52,代码来源:analyseTransaction.cpp

示例14: GetScriptForWitness

CScript GetScriptForWitness(const CScript& redeemscript)
{
    txnouttype typ;
    std::vector<std::vector<unsigned char> > vSolutions;
    if (Solver(redeemscript, typ, vSolutions)) {
        if (typ == TX_PUBKEY) {
            return GetScriptForDestination(WitnessV0KeyHash(Hash160(vSolutions[0].begin(), vSolutions[0].end())));
        } else if (typ == TX_PUBKEYHASH) {
            return GetScriptForDestination(WitnessV0KeyHash(vSolutions[0]));
        }
    }
    return GetScriptForDestination(WitnessV0ScriptHash(redeemscript));
}
开发者ID:fujicoin,项目名称:fujicoin,代码行数:13,代码来源:standard.cpp

示例15: ScriptToUniv

void ScriptToUniv(const CScript& script, UniValue& out, bool include_address)
{
    out.pushKV("asm", ScriptToAsmStr(script));
    out.pushKV("hex", HexStr(script.begin(), script.end()));

    std::vector<std::vector<unsigned char>> solns;
    txnouttype type;
    Solver(script, type, solns);
    out.pushKV("type", GetTxnOutputType(type));

    CTxDestination address;
    if (include_address && ExtractDestination(script, address)) {
        out.pushKV("address", EncodeDestination(address));
    }
}
开发者ID:machinecoin-project,项目名称:machinecoin-core,代码行数:15,代码来源:core_write.cpp


注:本文中的Solver函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。