예제 #1
0
void Grandf::initialize()
{
    setDeckContents();

    const qreal distx = 1.4;
    const qreal targetOffset = 1.5 * distx;

    for ( int i = 0; i < 4; ++i )
    {
        target[i] = new PatPile( this, i + 1, QString("target%1").arg(i) );
        target[i]->setPileRole(PatPile::Foundation);
        target[i]->setLayoutPos(targetOffset+i*distx, 0);
        target[i]->setSpread(0, 0);
        target[i]->setKeyboardSelectHint( KCardPile::NeverFocus );
        target[i]->setKeyboardDropHint( KCardPile::ForceFocusTop );
    }

    for ( int i = 0; i < 7; ++i )
    {
        store[i] = new PatPile( this, 5 + i, QString("store%1").arg(i) );
        store[i]->setPileRole(PatPile::Tableau);
        store[i]->setLayoutPos(distx*i, 1.2);
        store[i]->setAutoTurnTop(true);
        store[i]->setBottomPadding( 4 );
        store[i]->setHeightPolicy( KCardPile::GrowDown );
        store[i]->setKeyboardSelectHint( KCardPile::FreeFocus );
        store[i]->setKeyboardDropHint( KCardPile::AutoFocusTop );
    }

    setActions(DealerScene::Hint | DealerScene::Demo | DealerScene::Redeal);
    setSolver( new GrandfSolver( this ) );
}
예제 #2
0
Gypsy::Gypsy( )
    : DealerScene(  )
{
    const qreal dist_x = 11.1;
    const qreal dist_y = 11.1;

    Deck::create_deck(this, 2);
    Deck::deck()->setPilePos(1 + dist_x / 2 + 8*dist_x, 4 * dist_y + 2 );

    connect(Deck::deck(), SIGNAL(clicked(Card*)), SLOT(newCards()));

    for (int i=0; i<8; i++) {
        target[i] = new Pile(i+1, this);
        target[i]->setPilePos(1 +dist_x*(8+(i/4)), 1 + (i%4)*dist_y);
        target[i]->setAddType(Pile::KlondikeTarget);
        target[i]->setObjectName( QString( "target%1" ).arg( i ) );
    }

    for (int i=0; i<8; i++) {
        store[i] = new Pile(9+i, this);
        store[i]->setPilePos(1+dist_x*i, 1);
        store[i]->setAddType(Pile::GypsyStore);
        store[i]->setRemoveType(Pile::FreecellStore);
        store[i]->setReservedSpace( QSizeF( 10, 20 ) );
        store[i]->setObjectName( QString( "store%1" ).arg( i ) );
    }

    setActions(DealerScene::Hint | DealerScene::Demo | DealerScene::Deal);
    setSolver( new GypsySolver( this ) );
}
예제 #3
0
Clock::Clock( )
    : DealerScene( )
{
    const qreal dist_x = 11.1;
    const qreal dist_y = 11.1;

    Deck::create_deck(this);
    Deck::deck()->setPos(1, 1+dist_y*3);
    Deck::deck()->hide();

    for (int i=0; i<12; i++) {
        target[i] = new Pile(i+1, this);
        const double ys[12] = {   0./96,  15./96,  52./96, 158./96, 264./96, 301./96, 316./96, 301./96, 264./96, 158./96,  52./96,  15./96};
        const double xs[12] = { 200./72, 280./72, 360./72, 400./72, 360./72, 280./72, 200./72, 120./72, 40./72, 0./72, 40./72, 120./72};
        target[i]->setPilePos(1.2 + 10 * 24 / 5 + xs[i] * 10, 1 + ys[i] * 10);
        target[i]->setCheckIndex(1);
        target[i]->setTarget(true);
        target[i]->setRemoveFlags(Pile::disallow);
        target[i]->setObjectName( QString( "target%1" ).arg( i ) );
    }

    for (int i=0; i<8; i++) {
        store[i] = new Pile(14+i, this);
        store[i]->setPilePos(1.2+dist_x*(i%4), 1 + 10 * 5 / 2 * (i/4));
        store[i]->setAddFlags(Pile::addSpread);
        store[i]->setCheckIndex(0);
        store[i]->setReservedSpace( QSizeF( 10, 18 ) );
        store[i]->setObjectName( QString( "store%1" ).arg( i ) );
    }

    setActions(DealerScene::Hint | DealerScene::Demo);
    setSolver( new ClockSolver( this ) );
}
예제 #4
0
void ofxRParticleSystem::init()
{
    uniqueIDs = 0;
    count = new float;
    
    damping = new float;
    restitution = new float;
    accLimit = new float;
    velLimit = new float;
    dt = new float;
    
    setDt(1.0);
    setCount(0);
    setDamping(.25);
    setRestitution(1.0);
    setAccelerationLimit(5.0);
    setVelocityLimit(10.0);
    
    renderer = new ofxRParticleRenderer();
    renderer->setParticlesPtr(&particles);

    solver = NULL;
    solver = new ofxSolver(1);
    setSolver(*solver);
}
예제 #5
0
파일: EigenSOE.cpp 프로젝트: lcpt/xc
XC::EigenSolver &XC::EigenSOE::newSolver(const std::string &type)
  {
    if(type=="band_arpack_solver")
      setSolver(new BandArpackSolver());
    else if(type=="band_arpackpp_solver")
      setSolver(new BandArpackppSolver());
    else if(type=="sym_band_eigen_solver")
      setSolver(new SymBandEigenSolver());
    else if(type=="full_gen_eigen_solver")
      setSolver(new FullGenEigenSolver());
    else if(type=="sym_arpack_solver")
      setSolver(new SymArpackSolver());
    else
      std::cerr << "Solver of type: '"
                << type << "' unknown." << std::endl;
    assert(theSolver);
    return *theSolver;
  }
예제 #6
0
PhysicsManager::PhysicsManager() {
    btDefaultCollisionConfiguration* config = new btDefaultCollisionConfiguration();
    setCollisionConfiguration(config);
    btCollisionDispatcher* dispatcher = new btCollisionDispatcher(m_CollConf);
    setDispatcher(dispatcher);
    btBroadphaseInterface* broadphase = new btDbvtBroadphase();
    setBroadphaseInterface(broadphase);
    btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
    setSolver(solver);
}
예제 #7
0
파일: EigenSOE.cpp 프로젝트: lcpt/xc
void XC::EigenSOE::copy(const EigenSolver *newSolver)
  {
    if(newSolver)
      {
        free_mem();
        EigenSolver *tmp= newSolver->getCopy();
        if(tmp)
          setSolver(tmp);
        else
	  std::cerr << "Eigen::copy; no se pudo crear the solver."
                    << std::endl;
      }
  }
예제 #8
0
파일: fortyeight.cpp 프로젝트: KDE/kpat
void Fortyeight::initialize()
{
    const qreal dist_x = 1.11;
    const qreal smallNeg = -1e-6;

    setDeckContents( 2 );

    talon = new PatPile( this, 0, QStringLiteral("talon") );
    talon->setPileRole(PatPile::Stock);
    talon->setLayoutPos( 7 * dist_x, smallNeg );
    talon->setZValue(20);
    talon->setSpread(0, 0);
    talon->setKeyboardSelectHint( KCardPile::NeverFocus );
    talon->setKeyboardDropHint( KCardPile::NeverFocus );
    connect( talon, &KCardPile::clicked, this, &DealerScene::drawDealRowOrRedeal );

    pile = new PatPile( this, 20, QStringLiteral("pile") );
    pile->setPileRole(PatPile::Waste);
    pile->setLayoutPos( 6 * dist_x, smallNeg );
    pile->setLeftPadding( 6 * dist_x );
    pile->setWidthPolicy( KCardPile::GrowLeft );
    pile->setSpread(-0.21, 0);
    pile->setKeyboardSelectHint( KCardPile::AutoFocusTop );
    pile->setKeyboardDropHint( KCardPile::NeverFocus );

    for ( int i = 0; i < 8; ++i )
    {
        target[i] = new PatPile( this, 9 + i, QStringLiteral( "target%1" ).arg( i ) );
        target[i]->setPileRole(PatPile::Foundation);
        target[i]->setLayoutPos(dist_x*i, 0);
        target[i]->setSpread(0, 0);
        target[i]->setKeyboardSelectHint( KCardPile::NeverFocus );
        target[i]->setKeyboardDropHint( KCardPile::ForceFocusTop );
    }

    for ( int i = 0; i < 8; ++i )
    {
        stack[i] = new PatPile( this, 1 + i, QStringLiteral( "stack%1" ).arg( i ) );
        stack[i]->setPileRole(PatPile::Tableau);
        stack[i]->setLayoutPos(dist_x*i, 1.1 );
        stack[i]->setAutoTurnTop(true);
        stack[i]->setSpread(0, 0.25);
        stack[i]->setBottomPadding( 1.75 );
        stack[i]->setHeightPolicy( KCardPile::GrowDown );
        stack[i]->setKeyboardSelectHint( KCardPile::FreeFocus );
        stack[i]->setKeyboardDropHint( KCardPile::AutoFocusTop );
    }

    setActions(DealerScene::Hint | DealerScene::Demo | DealerScene::Draw);
    setSolver( new FortyeightSolver( this ) );
}
	/*! \brief Try to solve the system using all the Krylov solver with simple preconditioners
	 *
	 *
	 *
	 */
	void try_solve_ASM(Mat & A_, const Vec & b_, Vec & x_)
	{
		PETSC_SAFE_CALL(KSPSetTolerances(ksp,rtol,abstol,dtol,5));
		for (size_t i = 0 ; i < solvs.size() ; i++)
		{
			setSolver(solvs.get(i).c_str());

			// Disable convergence check
			PETSC_SAFE_CALL(KSPSetConvergenceTest(ksp,KSPConvergedSkip,NULL,NULL));

//			solve_simple(A_,b_,x_);
			solve_ASM(A_,b_,x_);
		}
	}
 bool SparseOptimizerIncremental::initSolver(int dimension, int batchEveryN)
 {
   //cerr << __PRETTY_FUNCTION__ << endl;
   slamDimension = dimension;
   if (dimension == 3) {
     setSolver(createSolver(this, "fix3_2_cholmod"));
     BlockSolver<BlockSolverTraits<3, 2> >* bs = dynamic_cast<BlockSolver<BlockSolverTraits<3, 2> >*>(solver());
     LinearSolverCholmodOnline<Matrix3d>* s = dynamic_cast<LinearSolverCholmodOnline<Matrix3d>*>(bs->linearSolver());
     _solverInterface = s;
   } else {
     setSolver(createSolver(this, "fix6_3_cholmod"));
     BlockSolver<BlockSolverTraits<6, 3> >* bs = dynamic_cast<BlockSolver<BlockSolverTraits<6, 3> >*>(solver());
     LinearSolverCholmodOnline<Matrix<double, 6, 6> >* s = dynamic_cast<LinearSolverCholmodOnline<Matrix<double, 6, 6> >*>(bs->linearSolver());
     _solverInterface = s;
   }
   _solverInterface->cmember = &_cmember;
   _solverInterface->batchEveryN = batchEveryN;
   solver()->setSchur(false);
   if (! solver()) {
     cerr << "Error allocating solver. Allocating CHOLMOD solver failed!" << endl;
     return false;
   }
   return true;
 }
예제 #11
0
int Process(ParametersType *Parameters, MatrixDataType *MatrixData, FemStructsType *FemStructs, 
	    FemFunctionsType *FemFunctions, FemOtherFunctionsType *FemOtherFunctions)
{
	int (*Predictor)(ParametersType *, MatrixDataType *, FemStructsType *, FemFunctionsType *, FemOtherFunctionsType *);
	
	setProblem(Parameters, FemFunctions);
	setMatrixVectorProductType(Parameters, FemFunctions);
	setSolver(Parameters,FemOtherFunctions);
	setPreconditioner(Parameters, FemFunctions);
	setScaling(Parameters, FemFunctions);
	setStabilizationForm(Parameters, FemFunctions, FemOtherFunctions, &Predictor);
	setDimensionlessness(Parameters, FemFunctions);
	set_BC_no_penetrability(Parameters, FemFunctions);
	setStopCriteria(Parameters, FemFunctions);
	Predictor(Parameters, MatrixData, FemStructs, FemFunctions, FemOtherFunctions);
	
	return 0;
}
예제 #12
0
파일: idiot.cpp 프로젝트: shlomif/kpat
void Idiot::initialize()
{
    setSceneAlignment( AlignHCenter | AlignVCenter );

    setDeckContents();

    // Create the talon to the left.
    talon = new PatPile( this, 0, QStringLiteral("talon") );
    talon->setPileRole(PatPile::Stock);
    talon->setLayoutPos(0, 0);
    talon->setSpread(0, 0);
    talon->setKeyboardSelectHint( KCardPile::NeverFocus );
    talon->setKeyboardDropHint( KCardPile::NeverFocus );
    connect(talon, &PatPile::clicked, this, &Idiot::newCards);

    const qreal distx = 1.1;

    // Create 4 piles where the cards will be placed during the game.
    for( int i = 0; i < 4; ++i )
    {
        m_play[i] = new PatPile( this, i + 1, QStringLiteral( "play%1" ).arg( i ));
        m_play[i]->setPileRole(PatPile::Tableau);
        m_play[i]->setLayoutPos(1.5 + distx * i, 0);
        m_play[i]->setBottomPadding( 2 );
        m_play[i]->setHeightPolicy( KCardPile::GrowDown );
        m_play[i]->setKeyboardSelectHint( KCardPile::AutoFocusTop );
        m_play[i]->setKeyboardDropHint( KCardPile::AutoFocusTop );
    }

    // Create the discard pile to the right
    m_away = new PatPile( this, 5, QStringLiteral("away") );
    m_away->setPileRole(PatPile::Foundation);
    m_away->setLayoutPos(1.9 + distx * 4, 0);
    m_away->setSpread(0, 0);
    m_away->setKeyboardSelectHint(KCardPile::NeverFocus);
    m_away->setKeyboardDropHint(KCardPile::ForceFocusTop);

    connect(this, &Idiot::cardClicked, this, &Idiot::tryAutomaticMove);

    setActions(DealerScene::Hint | DealerScene::Demo | DealerScene::Deal);
    setSolver( new IdiotSolver(this ) );
}
예제 #13
0
Fortyeight::Fortyeight( )
    : DealerScene()
{
    Deck::create_deck(this, 2);

    const qreal dist_x = 11.1;

    connect(Deck::deck(), SIGNAL(pressed(Card*)), SLOT(newCards()));
    connect(Deck::deck(), SIGNAL(clicked(Card*)), SLOT(deckClicked(Card*)));
    Deck::deck()->setPilePos( -2, -1);
    Deck::deck()->setZValue(20);

    pile = new HorLeftPile(20, this);
    pile->setAddFlags(Pile::addSpread | Pile::disallow);
    pile->setPilePos( -13.1, -1 );
    pile->setObjectName( "pile" );
    pile->setReservedSpace( QSizeF( -50, 10 ) );

    for (int i = 0; i < 8; i++) {

        target[i] = new Pile(9 + i, this);
        target[i]->setPilePos(1 + dist_x*i, 1);
        target[i]->setType(Pile::KlondikeTarget);
        target[i]->setObjectName( QString( "target%1" ).arg( i ) );

        stack[i] = new Pile(1 + i, this);
        stack[i]->setPilePos(1 + dist_x*i, 12 );
        stack[i]->setAddFlags(Pile::addSpread);
        stack[i]->setRemoveFlags(Pile::autoTurnTop);
        stack[i]->setCheckIndex(1);
        stack[i]->setSpread(stack[i]->spread() * 3 / 4);
        stack[i]->setObjectName( QString( "stack%1" ).arg( i ) );
        stack[i]->setReservedSpace( QSizeF( 10, 40 ) );
    }

    setActions(DealerScene::Hint | DealerScene::Demo | DealerScene::Draw);
    setSolver( new FortyeightSolver( this ) );
}
예제 #14
0
void Gypsy::initialize()
{
    const qreal dist_x = 1.11;
    const qreal dist_y = 1.11;

    setDeckContents( 2 );

    talon = new PatPile( this, 0, "talon" );
    talon->setPileRole(PatPile::Stock);
    talon->setLayoutPos(8.5 * dist_x + 0.4, 4 * dist_y);
    talon->setKeyboardSelectHint( KCardPile::NeverFocus );
    talon->setKeyboardDropHint( KCardPile::NeverFocus );
    connect( talon, SIGNAL(clicked(KCard*)), SLOT(drawDealRowOrRedeal()) );

    for ( int i = 0; i < 8; ++i )
    {
        target[i] = new PatPile( this, i + 1, QString("target%1").arg(i) );
        target[i]->setPileRole(PatPile::Foundation);
        target[i]->setLayoutPos(dist_x*(8+(i/4)) + 0.4, (i%4)*dist_y);
        target[i]->setKeyboardSelectHint( KCardPile::NeverFocus );
        target[i]->setKeyboardDropHint( KCardPile::ForceFocusTop );
    }

    for ( int i = 0; i < 8; ++i )
    {
        store[i] = new PatPile( this, 9 + i, QString("store%1").arg(i) );
        store[i]->setPileRole(PatPile::Tableau);
        store[i]->setLayoutPos(dist_x*i,0);
        store[i]->setAutoTurnTop(true);
        store[i]->setBottomPadding( 4 * dist_y );
        store[i]->setHeightPolicy( KCardPile::GrowDown );
        store[i]->setKeyboardSelectHint( KCardPile::AutoFocusDeepestRemovable );
        store[i]->setKeyboardDropHint( KCardPile::AutoFocusTop );
    }

    setActions(DealerScene::Hint | DealerScene::Demo | DealerScene::Deal);
    setSolver( new GypsySolver( this ) );
}
예제 #15
0
void simulator_setSolver(enum SOLVER solver)
{
  setSolver(solver);
}
예제 #16
0
파일: simulator.c 프로젝트: rennone/mpiFDTD
void simulator_setSolver(enum SOLVER solver)
{
  setSolver(solver);    //Solverの設定と初期化
}
예제 #17
0
파일: spider.cpp 프로젝트: KDE/kpat
void Spider::initialize()
{
    m_leg = 0;
    m_redeal = 0;

    const qreal dist_x = 1.12;
    const qreal smallNeg = -1e-6;

    m_suits = Settings::spiderSuitCount();

    m_stackFaceup = Settings::spiderStackFaceup();

    createDeck();

    // Dealing the cards out into 5 piles so the user can see how many
    // sets of 10 cards are left to be dealt out
    for( int column = 0; column < 5; ++column )
    {
        redeals[column] = new InvisiblePile( this, column + 1, QStringLiteral( "redeals%1" ).arg( column ) );
        redeals[column]->setPileRole(PatPile::Stock);
        redeals[column]->setLayoutPos( dist_x * (9 - (4.0 - column) / 3), smallNeg );
        redeals[column]->setZValue(12 * ( 5-column ));
        redeals[column]->setSpread(0, 0);
        redeals[column]->setKeyboardSelectHint( KCardPile::NeverFocus );
        redeals[column]->setKeyboardDropHint( KCardPile::NeverFocus );
        connect( redeals[column], &KCardPile::clicked, this, &DealerScene::drawDealRowOrRedeal );
    }

    // The 10 playing piles
    for( int column = 0; column < 10; ++column )
    {
        stack[column] = new PatPile( this, column + 6, QStringLiteral( "stack%1" ).arg( column ) );
        stack[column]->setPileRole(PatPile::Tableau);
        stack[column]->setLayoutPos(dist_x * column, 0);
        stack[column]->setZValue(20);
        stack[column]->setAutoTurnTop(true);
        stack[column]->setBottomPadding( 1.5 );
        stack[column]->setHeightPolicy( KCardPile::GrowDown );
        stack[column]->setKeyboardSelectHint( KCardPile::AutoFocusDeepestRemovable );
        stack[column]->setKeyboardDropHint( KCardPile::AutoFocusTop );
    }

    // The 8 'legs' so named by me because spiders have 8 legs - why
    // else the name Spider?
    for( int column = 0; column < 8; ++column )
    {
        legs[column] = new InvisiblePile( this, column + 16, QStringLiteral( "legs%1" ).arg( column ) );
        legs[column]->setPileRole(PatPile::Foundation);
        legs[column]->setLayoutPos(dist_x / 3 * column, smallNeg);
        legs[column]->setZValue(column+1);
        legs[column]->setSpread(0, 0);
        legs[column]->setZValue(14 * column);
        legs[column]->setVisible( false );
        legs[column]->setKeyboardSelectHint( KCardPile::NeverFocus );
        legs[column]->setKeyboardDropHint( KCardPile::NeverFocus );
    }

    // Moving an A-K run to a leg is not really an autoDrop - the
    // user should have no choice.
    setAutoDropEnabled(false);
    setActions(DealerScene::Hint | DealerScene::Demo | DealerScene::Deal);
    setSolver( new SpiderSolver( this ) );

    options = new KSelectAction(i18n("Spider &Options"), this );
    options->addAction( i18n("1 Suit (Easy)") );
    options->addAction( i18n("2 Suits (Medium)") );
    options->addAction( i18n("4 Suits (Hard)") );
    if ( m_suits == 1 )
        options->setCurrentItem( 0 );
    else if ( m_suits == 2 )
        options->setCurrentItem( 1 );
    else
        options->setCurrentItem( 2 );
    connect(options, static_cast<void (KSelectAction::*)(int)>(&KSelectAction::triggered), this, &Spider::gameTypeChanged);

    m_stackFaceupOption = new KSelectAction(i18n("S&tack Options"), this );
    m_stackFaceupOption->addAction( i18n("Face &Down (harder)") );
    m_stackFaceupOption->addAction( i18n("Face &Up (easier)") );
    m_stackFaceupOption->setCurrentItem( m_stackFaceup );

    connect(m_stackFaceupOption, static_cast<void (KSelectAction::*)(int)>(&KSelectAction::triggered), this, &Spider::gameTypeChanged);
}