bool PHIApplication::stopPhisService() { #ifdef PHIEMBEDEDSERVER return false; #else if ( !QFile::exists( _serverBin ) ) return false; QProcess proc; if ( proc.execute( _serverBin, QStringList() << L1( "-t" ) )!=0 ) return false; return true; #endif }
bool SoldierSpawnTarget::Load( const Json::Value& setters ) { std::string cursor_id; if( !Json::GetStr(setters["cursor_id"], cursor_id)) { L1("Error retrieving 'cursor_id' \n" ); return false; } mCursorId = AutoId( cursor_id ); return true; }
// // Returns a string for a HTTP-header // QString KHttpCookie::cookieStr(bool useDOMFormat) { QString result; if (useDOMFormat || (mProtocolVersion == 0)) { if ( !mName.isEmpty() ) result = mName + '='; result += mValue; } else { result = mName + '=' + mValue; if (mExplicitPath) result += L1("; $Path=\"") + mPath + L1("\""); if (!mDomain.isEmpty()) result += L1("; $Domain=\"") + mDomain + L1("\""); } return result; }
int test_string_cast_vector() { int Error = 0; glm::vec2 A1(1, 2); std::string A2 = glm::to_string(A1); Error += A2 != std::string("fvec2(1.000000, 2.000000)") ? 1 : 0; glm::vec3 B1(1, 2, 3); std::string B2 = glm::to_string(B1); Error += B2 != std::string("fvec3(1.000000, 2.000000, 3.000000)") ? 1 : 0; glm::vec4 C1(1, 2, 3, 4); std::string C2 = glm::to_string(C1); Error += C2 != std::string("fvec4(1.000000, 2.000000, 3.000000, 4.000000)") ? 1 : 0; glm::ivec2 D1(1, 2); std::string D2 = glm::to_string(D1); Error += D2 != std::string("ivec2(1, 2)") ? 1 : 0; glm::ivec3 E1(1, 2, 3); std::string E2 = glm::to_string(E1); Error += E2 != std::string("ivec3(1, 2, 3)") ? 1 : 0; glm::ivec4 F1(1, 2, 3, 4); std::string F2 = glm::to_string(F1); Error += F2 != std::string("ivec4(1, 2, 3, 4)") ? 1 : 0; glm::hvec2 G1(1, 2); std::string G2 = glm::to_string(G1); Error += G2 != std::string("hvec2(1.0000, 2.0000)") ? 1 : 0; glm::hvec3 H1(1, 2, 3); std::string H2 = glm::to_string(H1); Error += H2 != std::string("hvec3(1.0000, 2.0000, 3.0000)") ? 1 : 0; glm::hvec4 I1(1, 2, 3, 4); std::string I2 = glm::to_string(I1); Error += I2 != std::string("hvec4(1.0000, 2.0000, 3.0000, 4.0000)") ? 1 : 0; glm::dvec2 J1(1, 2); std::string J2 = glm::to_string(J1); Error += J2 != std::string("dvec2(1.000000, 2.000000)") ? 1 : 0; glm::dvec3 K1(1, 2, 3); std::string K2 = glm::to_string(K1); Error += K2 != std::string("dvec3(1.000000, 2.000000, 3.000000)") ? 1 : 0; glm::dvec4 L1(1, 2, 3, 4); std::string L2 = glm::to_string(L1); Error += L2 != std::string("dvec4(1.000000, 2.000000, 3.000000, 4.000000)") ? 1 : 0; return Error; }
void PHIDomEvent::setDropEvent( QGraphicsSceneDragDropEvent *e ) { Q_ASSERT( e ); /* DOM does not specify mouse positions in a drop event. :-( QPoint v=mapFromScene( e->scenePos() ); QPoint doc=e->scenePos().toPoint(); self.setProperty( "pageX" ), doc.x(), QScriptValue::ReadOnly ); self.setProperty( "pageY" ), doc.y(), QScriptValue::ReadOnly ); self.setProperty( "clientX" ), v.x(), QScriptValue::ReadOnly ); self.setProperty( "clientY" ), v.y(), QScriptValue::ReadOnly ); self.setProperty( "screenX" ), e->screenPos().x(), QScriptValue::ReadOnly ); self.setProperty( "screenY" ), e->screenPos().y(), QScriptValue::ReadOnly ); */ int button=0, which=0; if ( e->buttons() & Qt::LeftButton ) which=1; else if ( e->buttons() & Qt::RightButton ) { button=2; which=3; } else if ( e->buttons() & Qt::MidButton ) { button=1; which=2; } _self.setProperty( L1( "which" ), which, QScriptValue::ReadOnly ); _self.setProperty( L1( "button" ), button, QScriptValue::ReadOnly ); _self.setProperty( L1( "altKey" ), (e->modifiers() & Qt::AltModifier ? true : false), QScriptValue::ReadOnly ); _self.setProperty( L1( "ctrlKey" ), (e->modifiers() & Qt::ControlModifier ? true : false), QScriptValue::ReadOnly ); _self.setProperty( L1( "shiftKey" ), (e->modifiers() & Qt::ShiftModifier ? true : false), QScriptValue::ReadOnly ); _self.setProperty( L1( "metaKey" ), (e->modifiers() & Qt::MetaModifier ? true : false), QScriptValue::ReadOnly ); }
std::auto_ptr<Actor> SoldierSpawnSystem::Spawn( core::ClientData& clientData, map::SpawnPoint spawnPoint, std::auto_ptr<Actor> player ) { Opt<Actor> clientActor( mScene.GetActor( clientData.mClientActorGUID ) ); if( clientActor.IsValid() ) { Opt<IHealthComponent> healthC = clientActor->Get<IHealthComponent>(); if ( healthC.IsValid() && healthC->IsAlive() ) { L1( "Cannot spawn soldier for clientData (%s) current soldier still alive!\n", clientData.mClientName.c_str() ); return std::auto_ptr<Actor>(); } } else { L2( "No actor for clientData(%s). (it might be an error on revive)\n", clientData.mClientName.c_str() ); } L2( "player is valid %d", player.get() ); Opt<IPositionComponent> positionC = player->Get<IPositionComponent>(); L2( "positionC is valid %d", positionC.IsValid() ); positionC->SetX( spawnPoint.mX ); positionC->SetY( spawnPoint.mY ); //TODO: temporary till normal inventory sync // Opt<IInventoryComponent> inventoryC = player->Get<IInventoryComponent>(); // if ( inventoryC.IsValid() ) // { // inventoryC->SetSelectedWeapon( AutoId( "pistol" ) ); // } Opt<PlayerControllerComponent> playerControllerC( player->Get<IControllerComponent>() ); if ( playerControllerC.IsValid() ) { playerControllerC->mControllerId = clientData.mClientId; if ( mProgramState.mControlledActorGUID == clientData.mClientActorGUID && mProgramState.mMode != core::ProgramState::Server ) { playerControllerC->SetEnabled( true ); playerControllerC->mActive = true; mProgramState.mControlledActorGUID = player->GetGUID(); } } clientData.mClientActorGUID = player->GetGUID(); //TODO: might seek for a better place L2( "player created clientId:%d clientName:%s actorId:%d\n", clientData.mClientId, clientData.mClientName.c_str(), clientData.mClientActorGUID ); if ( mProgramState.mMode != core::ProgramState::Server && mProgramState.mClientDatas.begin()->mClientActorGUID == player->GetGUID() ) { Scene::Get().SetPlayerModels( Opt<Actor>( player.get() ) ); } EventServer<SoldierCreatedEvent>::Get().SendEvent( SoldierCreatedEvent( clientData, Opt<Actor>( player.get() ) ) ); return player; }
void WeaponLoader::BindValues() { L1( "Bind Weapon values \n" ); Bind( "shoot_cooldown", func_double( &Weapon::SetShootCooldown ) ); Bind( "shoot_alt_cooldown", func_double( &Weapon::SetShootAltCooldown ) ); Bind( "bullets", func_double( &Weapon::SetBullets ) ); Bind( "bullets", func_double( &Weapon::SetBulletsMax ) ); Bind( "shot_cost", func_int32_t( &Weapon::SetShotCost ) ); Bind( "shot_cost_alt", func_int32_t( &Weapon::SetShotCostAlt ) ); Bind( "reload_time", func_double( &Weapon::SetReloadTimeMax ) ); Bind( "static_reload", func_double( &Weapon::SetStaticReload ) ); Bind( "position_x", func_double(&Weapon::SetPositionX)); Bind( "position_y", func_double(&Weapon::SetPositionY)); std::string istr; if (Json::GetStr((*mSetters)["muzzle"], istr)) { Bind<int32_t>(&Weapon::SetMuzzleId, AutoId(istr)); } if (Json::GetStr((*mSetters)["muzzle_alt"], istr)) { Bind<int32_t>(&Weapon::SetMuzzleAltId, AutoId(istr)); } Scatter scatter; Json::GetDouble( ( *mSetters )["scatter_increase"], scatter.mIncrease ); Json::GetDouble( ( *mSetters )["scatter_alt_increase"], scatter.mAltIncrease ); Json::GetDouble( ( *mSetters )["scatter_chill"], scatter.mChill ); Json::GetDouble( ( *mSetters )["scatter_magic_number"], scatter.mMagicNumber ); L1( "Scatter in: %f %f %f %f", scatter.mIncrease, scatter.mAltIncrease, scatter.mChill, scatter.mMagicNumber ); Bind<Scatter>( &Weapon::SetScatter, scatter ); if (Json::GetStr( (*mSetters)["shot"], istr )) { Bind<int32_t>( &Weapon::SetShotId, AutoId( istr ) ); } if (Json::GetStr( (*mSetters)["shot_alt"], istr )) { Bind<int32_t>( &Weapon::SetShotAltId, AutoId( istr ) ); } }
void PlayerControllerMessageHandlerSubSystem::Execute( Message const& message ) { PlayerControllerMessage const& msg = static_cast<PlayerControllerMessage const&>( message ); // L1("executing PlayerController: %d \n",msg.mSenderId ); Opt<Actor> actor = mScene.GetActor( msg.mActorGUID ); if ( !actor.IsValid() ) { L1( "cannot find actor with GUID: (that is not possible) %d \n", msg.mActorGUID ); return; } Opt<PlayerControllerComponent> playerControllerC = actor->Get<IControllerComponent>(); if ( !playerControllerC.IsValid() ) { L1( "playercontroller is called on an actor that has no player_controller_component \n" ); return; } playerControllerC->mOrientation = msg.mOrientation / PRECISION; playerControllerC->mHeading = msg.mHeading / PRECISION; playerControllerC->mShoot = msg.mShoot; playerControllerC->mShootAlt = msg.mShootAlt; if (msg.mUseNormalItem.IsActive()) { playerControllerC->mUseNormalItem.Activate(); } else { playerControllerC->mUseNormalItem.Deactivate(); } if (msg.mUseReload.IsActive()) { playerControllerC->mUseReload.Activate(); } else { playerControllerC->mUseReload.Deactivate(); } playerControllerC->mMoving = msg.mMoving; }
int L1() { if(str[i]==',') { i++; if(S()) { if(L1()) return 1; } } return 1; }
bool SetOwnershipMessageHandlerSubSystem::ProcessPending( Message const& message ) { SetOwnershipMessage const& msg = static_cast<SetOwnershipMessage const&>( message ); Opt<Actor> actor = mScene.GetActor( msg.mActorGUID ); //guaranteed L1( "executing %s: actorGUID %d \n", __FUNCTION__, msg.mActorGUID ); Opt<PlayerControllerComponent> playerControllerC( actor->Get<IControllerComponent>() ); if ( !playerControllerC.IsValid() ) { L1( "setownership is called on an actor that is not playerControllable \n" ); return true; } playerControllerC->mControllerId = msg.mClientId; if ( msg.mClientId == mProgramState.mClientId ) { L1( "thats my id! actorguid: %d,%d \n", msg.mActorGUID, PlayerControllerComponent::GetType_static() ); Opt<Actor> oldActor = mScene.GetActor( mProgramState.mControlledActorGUID ); if ( oldActor.IsValid() ) { Opt<PlayerControllerComponent> pcc = oldActor->Get<IControllerComponent>(); if( pcc.IsValid() ) { pcc->SetEnabled( false ); pcc->mActive = false; } } mProgramState.mControlledActorGUID = msg.mActorGUID; playerControllerC->SetEnabled( true ); playerControllerC->mActive = true; mScene.SetPlayerModels( actor ); } Opt<core::ClientData> clientData( mProgramState.FindClientDataByClientId( msg.mClientId ) ); if ( clientData.IsValid() ) { clientData->mClientActorGUID = msg.mActorGUID; } return true; }
//#define DEBUG void SymList::compute_subgroup() { Matrix2D<DOUBLE> I(4, 4); I.initIdentity(); Matrix2D<DOUBLE> L1(4, 4), R1(4, 4), L2(4, 4), R2(4, 4), newL(4, 4), newR(4, 4); Matrix2D<int> tried(true_symNo, true_symNo); int i, j; int new_chain_length; while (found_not_tried(tried, i, j, true_symNo)) { tried(i, j) = 1; get_matrices(i, L1, R1); get_matrices(j, L2, R2); newL = L1 * L2; newR = R1 * R2; new_chain_length = __chain_length(i) + __chain_length(j); Matrix2D<DOUBLE> newR3 = newR; newR3.resize(3,3); if (newL.isIdentity() && newR3.isIdentity()) continue; // Try to find it in current ones bool found; found = false; for (int l = 0; l < SymsNo(); l++) { get_matrices(l, L1, R1); if (newL.equal(L1) && newR.equal(R1)) { found = true; break; } } if (!found) { //#define DEBUG #ifdef DEBUG std::cout << "Matrix size " << tried.Xdim() << " " << "trying " << i << " " << j << " " << "chain length=" << new_chain_length << std::endl; std::cout << "Result R Sh\n" << newR; #endif #undef DEBUG newR.setSmallValuesToZero(); newL.setSmallValuesToZero(); add_matrices(newL, newR, new_chain_length); tried.resize(MAT_YSIZE(tried) + 1, MAT_XSIZE(tried) + 1); } } }
void PHIDomEvent::setKeyEvent( QKeyEvent *e ) { Q_ASSERT( e ); _self.setProperty( L1( "altKey" ), (e->modifiers() & Qt::AltModifier ? true : false), QScriptValue::ReadOnly ); _self.setProperty( L1( "ctrlKey" ), (e->modifiers() & Qt::ControlModifier ? true : false), QScriptValue::ReadOnly ); _self.setProperty( L1( "shiftKey" ), (e->modifiers() & Qt::ShiftModifier ? true : false), QScriptValue::ReadOnly ); _self.setProperty( L1( "metaKey" ), (e->modifiers() & Qt::MetaModifier ? true : false), QScriptValue::ReadOnly ); int code=PHIFakeDomEvent::qtToDomKey( e->key() ); if ( !e->text().isEmpty() ) { QChar c; c=e->text().at( 0 ); code=static_cast<int>(c.unicode()); } _self.setProperty( L1( "isChar" ), !e->text().isEmpty() ); _self.setProperty( L1( "charCode" ), e->text().isEmpty() ? L1( "0" ) : e->text() ); _self.setProperty( L1( "keyCode" ), code ); _self.setProperty( L1( "which" ), code ); }
void single_test(const int n, const double alpha, reconstruct r, complex_mesh_func cmf, err_t *err) { data_t d, nd; integrate(n, alpha, r, cmf, &d); save_data("bis2.txt", &d); copy_data(&d, &nd); initial_sin4(T, &nd); save_data("none.txt", &d); err->l1 = L1(&d, &nd); err->l2 = L2(&d, &nd); err->linf = Linf(&d, &nd); free_data(&d, 1); free_data(&nd, 1); }
void OrientationMessageHandlerSubSystem::Execute( Message const& message ) { OrientationMessage const& msg = static_cast<OrientationMessage const&>( message ); if ( mProgramState.mMode == ProgramState::Server || ( mProgramState.mMode == ProgramState::Client && msg.mActorGUID != mProgramState.mControlledActorGUID ) ) { Opt<Actor> actor = mScene.GetActor( msg.mActorGUID ); if ( !actor.IsValid() ) { L1( "cannot find actor with GUID: (that is not possible) %d \n", msg.mActorGUID ); return; } Opt<IPositionComponent> positionC( actor->Get<IPositionComponent>() ); if ( !positionC.IsValid() ) { L1( "position is called on an actor that has no position_component \n" ); return; } positionC->SetOrientation( msg.mOrientation / PRECISION ); } }
bool KCookieJar::parseURL(const QString &_url, QString &_fqdn, QString &_path) { KURL kurl(_url); if (!kurl.isValid()) return false; _fqdn = kurl.host().lower(); if (kurl.port()) { if (((kurl.protocol() == L1("http")) && (kurl.port() != 80)) || ((kurl.protocol() == L1("https")) && (kurl.port() != 443))) { _fqdn = L1("%1:%2").arg(kurl.port()).arg(_fqdn); } } // Cookie spoofing protection. Since there is no way a path separator // or escape encoded character is allowed in the hostname according // to RFC 2396, reject attempts to include such things there! if(_fqdn.find('/') > -1 || _fqdn.find('%') > -1) { return false; // deny everything!! } _path = kurl.path(); if (_path.isEmpty()) _path = L1("/"); QRegExp exp(L1("[\\\\/]\\.\\.[\\\\/]")); // Weird path, cookie stealing attempt? if (exp.search(_path) != -1) return false; // Deny everything!! return true; }
void main() { Linea L1(50,80,180,200); int a,b,i; a=DETECT; initgraph(&a,&b," "); for(i=0;i<640;i++) { L1.Mover(i+3,50); delay(1); } getch(); closegraph(); }
void ClientSystem::Init() { if ( enet_initialize () != 0 ) { L1 ( "An error occurred while initializing ENet.\n" ); } atexit ( enet_deinitialize ); Connect(); mThreaded = Settings::Get().GetBool( "network.threaded", true ); mRunning = true; mWaitMillisecs = Settings::Get().GetInt( "network.wait_millisec", 10 ); if (mThreaded) { mThread = std::thread(boost::bind(&ClientSystem::UpdateThread,this)); } }
bool PHIApplication::startPhisService() { qWarning() << "phiapp start" << _serverBin; #ifdef PHIEMBEDEDSERVER return false; #else if ( !QFile::exists( _serverBin ) ) return false; qWarning() << "phiapp start" << _serverBin; QProcess proc; #ifdef Q_OS_WIN proc.execute( _serverBin, QStringList() << L1( "-i" ) ); #endif if ( proc.execute( _serverBin, QStringList() )!=0 ) return false; return true; #endif }
int Game_Engine::Intersect_Tails(const Player &_Player1, const Player &_Player2, const double &dt) { vector < Point2D < double > > V_1,V_2; V_1.clear(); V_2.clear(); Polygon2D <double> P; LightCycle _Cycle = _Player1.MyCycle; P = Polygon_from_cycle(_Cycle); V_1.push_back(P.Polygon[0]); V_1.push_back(P.Polygon[1]); _Cycle.UPD(dt); P = Polygon_from_cycle(_Cycle); V_1.push_back(P.Polygon[2]); V_1.push_back(P.Polygon[3]); Polygon2D < double > Pol1(V_1); _Cycle = _Player2.MyCycle; P = Polygon_from_cycle(_Cycle); V_2.push_back(P.Polygon[0]); V_2.push_back(P.Polygon[1]); _Cycle.UPD(dt); P = Polygon_from_cycle(_Cycle); V_2.push_back(P.Polygon[2]); V_2.push_back(P.Polygon[3]); Polygon2D < double > Pol2(V_2); if (Intersect(Pol1, Pol2)) { Line2D < double > L1(0.5*(V_1[1] + V_1[0]), 0.5*(V_1[2] + V_1[3])); Line2D < double > L2(0.5*(V_2[1] + V_2[0]), 0.5*(V_2[2] + V_2[3])); Point2D < double > Cross_P; double dist1, dist2; Cross_line(L1, L2, Cross_P); if (abs(dist(Cross_P, 0.5*(V_1[1] + V_1[0])) + this->Constants->LightCycle_Length - dist(Cross_P, 0.5*(V_1[2] + V_1[3]))) < EPS) dist1 = -dist(Cross_P, 0.5*(V_1[1] + V_1[0])); else dist1 = dist(Cross_P, 0.5*(V_1[1] + V_1[0])); if (abs(dist(Cross_P, 0.5*(V_2[1] + V_2[0])) + this->Constants->LightCycle_Length - dist(Cross_P, 0.5*(V_2[2] + V_2[3]))) < EPS) dist2 = -dist(Cross_P, 0.5*(V_2[1] + V_2[0])); else dist2 = dist(Cross_P, 0.5*(V_2[1] + V_2[0])); if (dist1 + 1.5*this->Constants->LightCycle_Length < dist2) return 1; if (dist2 + 1.5*this->Constants->LightCycle_Length < dist1) return 2; return 3; } return 0; }
PHIDomEvent::PHIDomEvent( const QString &type, PHIBaseItem *item, bool cancelable ) : QObject( item->scriptEngine() ), _item( item ), _cancelDefault( false ), _stopPropagation( false ), _cancelable( cancelable ) { //qDebug( "PHIDomEvent::PHIDomEvent()" ); _timestamp=QDateTime::currentMSecsSinceEpoch(); PHIDomItem *domItem=new PHIDomItem( item, this ); QScriptValue target=item->scriptEngine()->newQObject( domItem, QScriptEngine::QtOwnership, PHIDOMSCRIPTOPTIONS ); _self=eventToScriptValue( _item->scriptEngine(), this ); _self.setProperty( L1( "target" ), target, QScriptValue::ReadOnly ); _self.setProperty( L1( "currentTarget" ), target, QScriptValue::ReadOnly ); _self.setProperty( L1( "type" ), type, QScriptValue::ReadOnly ); _self.setProperty( L1( "bubbles" ), false, QScriptValue::ReadOnly ); _self.setProperty( L1( "cancelable" ), cancelable, QScriptValue::ReadOnly ); _self.setProperty( L1( "eventPhase" ), 1, QScriptValue::ReadOnly ); _self.setProperty( L1( "view" ), item->scriptEngine()->globalObject(), QScriptValue::ReadOnly ); _self.setProperty( L1( "detail" ), 0, QScriptValue::ReadOnly ); }
void run_stresstest_simple() { std::cout << "Running simple random address test..." << std::endl; Addr addr_space = 4*GB; size_t mem_access_cost = 500; size_t L2_direct_entries = 64; size_t L2_line_size_bytes = 128; size_t L2_associativity = 8; size_t L2_hit_cost_ticks = 50; size_t L1_direct_entries = 128; size_t L1_line_size_bytes = 64; size_t L1_associativity = 2; size_t L1_hit_cost_ticks = 3; MainMemory main_mem(addr_space, mem_access_cost); Cache L2("L2", &main_mem, L2_direct_entries, L2_associativity, L2_line_size_bytes, L2_hit_cost_ticks, IS_WRITEBACK_CACHE); Cache L1("L1", &L2, L1_direct_entries, L1_associativity, L1_line_size_bytes, L1_hit_cost_ticks, !IS_WRITEBACK_CACHE); srand((unsigned)time(0)); size_t ticks = 0; #ifdef WINTIME long int before = GetTickCount(); #else clock_t start, finish; start = clock(); #endif uint8_t *data; size_t iterations = 100*K; for (size_t i=0; i<iterations; i++) { Addr addr = (Addr)&globalmem[rand()%globalmem_size]; uint8_t line_state_req = linestates[rand()%3]; L1.line_get(addr, line_state_req, ticks, data); assert(ticks>0); ticks = 0; } #ifdef WINTIME long int after = GetTickCount(); std::cout << "Execution Time: " << (after-before) << " ms." << std::endl; #else finish = clock(); double exec_time_ms = ((double)(finish - start))*1000/CLOCKS_PER_SEC; std::cout << "Execution Time: " << exec_time_ms << " ms." << std::endl; std::cout << "that makes: " << ((double)(iterations/exec_time_ms)) << " cache queries/ms." << std::endl; #endif }
void FlashMessageHandlerSubSystem::Execute( Message const& message ) { FlashMessage const& msg = static_cast<FlashMessage const&>( message ); Opt<Actor> actor = mScene.GetActor( msg.mActorGUID ); if ( !actor.IsValid() ) { L1( "cannot find actor with GUID: (%s) %d \n", __FUNCTION__, msg.mActorGUID ); return; } Opt<IPositionComponent> positionC = actor->Get<IPositionComponent>(); if ( !positionC.IsValid() ) { return; } positionC->SetX( msg.mX / PRECISION ); positionC->SetY( msg.mY / PRECISION ); }
// Evaluate the nth order Legendre polynomial and its derivative void legendre(const dvec& a, const dvec& b, const dvec& x, dvec& L, dvec& Lp) { int n = x.size(); dvec L0(n,1.0); dvec L1(n,0.0); // Iterate over grid points for(int j=0;j<n;++j) { L1[j] = x[j]; // Iterate over polynomials for(int k=1;k<n;++k) { L[j] = a[k]*x[j]*L1[j]-b[k]*L0[j]; L0[j] = L1[j]; L1[j] = L[j]; } Lp[j] = n*(L0[j]-x[j]*L[j])/(1.0-x[j]*x[j]); } }
/*** contributions from the mirror image HIII ***/ static double strikexHIII (MagComp component, const fault_params *fault, const magnetic_params *mag, double xi, double et, double qq, double y, double z) { double val; double h = mag->dcurier; double qd = y * sd + (fault->fdepth - h) * cd; double K1_val = K1 (component, 1.0, xi, et, qq); double atan_xe_qr_val = atan_xe_qr (component, 1.0, xi, et, qq); double J1_val = J1 (component, 1.0, xi, et, qq); double M1_val = M1 (component, 1.0, xi, et, qq); double L1_val = L1 (component, 1.0, xi, et, qq); val = - alpha4 * K1_val + alpha1 * atan_xe_qr_val + alpha3 * J1_val + alpha3 * (qd * M1_val + (z - h) * L1_val * sd); return val; }
_fini( _unknown_ __ebx, // r1 _unknown_ __edx // r3 ) {// addr = 0x080483AC _unknown_ _v8; // _cfa_fffffff8 _unknown_ __ebp; // r6 _unknown_ _t3; // _t3 _unknown_ _t4; // _t4 __edx = __edx; _push(__ebx); _push(__edx); L1(); _pop(__ebx); __do_global_dtors_aux(); return; }
void ActorFactory::Init() { PathVect_t Paths; Filesys& FSys = Filesys::Get(); FSys.GetFileNames( Paths, "actors" ); for( PathVect_t::const_iterator i = Paths.begin(), e = Paths.end(); i != e; ++i ) { boost::filesystem::path const& Path = *i; if( Path.extension().string() != ".json" ) { continue; } AutoFile JsonFile = FSys.Open( *i ); if( !JsonFile.get() ) { continue; } JsonReader Reader( *JsonFile ); if( !Reader.IsValid() ) { continue; } Json::Value Root = Reader.GetRoot(); if( !Root.isArray() ) { continue; } for( Json::Value::iterator i = Root.begin(), e = Root.end(); i != e; ++i ) { Json::Value& ActorsDesc = *i; try { if( !AddActorCreatorFromOneDesc( ActorsDesc, mActorCreators ) ) { return; } } catch( std::exception const& err ) { L1( "Exception caught while parsing %s : %s", Path.generic_string().c_str(), err.what() ); } } } }
// Runge-Kutta 4 algorithm void System::RK4(){ vec2dN K1(nObj), K2(nObj), K3(nObj), K4(nObj); vec2dN L1(nObj), L2(nObj), L3(nObj), L4(nObj); vec2dN NewR(nObj), NewV(nObj); if (nObj == 1){ // If only ONE object K1 = h*derX(vec2dN(nObj)); L1 = h*(SunInf(vec2dN(nObj))); K2 = h*derX(L1*0.5); L2 = h*(SunInf(K1*0.5)); K3 = h*derX(L2*0.5); L3 = h*(SunInf(K2*0.5)); K4 = h*derX(L3); L4 = h*(SunInf(K3)); } else { // If more than one object if (!statSun){ // Sun mobile or not pressent K1 = h*derX(vec2dN(nObj)); L1 = h*derV(vec2dN(nObj)); K2 = h*derX(L1*0.5); L2 = h*derV(K1*0.5); K3 = h*derX(L2*0.5); L3 = h*derV(L2*0.5); K4 = h*derX(L3); L4 = h*derV(K4); } else { // If the sun is stationary K1 = h*derX(vec2dN(nObj)); L1 = h*(derV(vec2dN(nObj)) + SunInf(vec2dN(nObj))); K2 = h*derX(L1*0.5); L2 = h*(derV(K1*0.5) + SunInf(K1*0.5)); K3 = h*derX(L2*0.5); L3 = h*(derV(K2*0.5) + SunInf(K2*0.5)); K4 = h*derX(L3); L4 = h*(derV(K3) + SunInf(K3)); } } for (int i = 0 ; i < nObj ; i++){ NewR[i] = sys[i].relR + (K1[i] + 2*K2[i] + 2*K3[i] + K4[i])/(double)6; NewV[i] = sys[i].relV + (L1[i] + 2*L2[i] + 2*L3[i] + L4[i])/(double)6; } calc_potential(); for (int i = 0 ; i < nObj ; i++){ sys[i].update(NewR[i], NewV[i], sys[i].relT+h); } }
void test_circuit_parallel() { //circuit 1 ngac AC("ac1", 0, 5, 1); ngresistor R("r1", 370); ngled LED("LED1", 7e-3); ngground GND; ngline L0(AC.p1, GND.p1); ngline L1(AC.p2, R.p1); ngline L2(R.p2, LED.p1); ngline L3(LED.p2, AC.p1); schema SCH; SCH.AddDevices(&AC, &R, &LED, &GND, 0); SCH.AddLines(&L0, &L1, &L2, &L3, 0); circuit CIR(&SCH); CIR.Tran("20", "1m"); //circuit 2 ngac ac("ac1", 0, 5, 1); ngresistor r("r1", 370); ngled led("led1", 5e-3); ngground gnd; ngline l0(ac.p1, gnd.p1); ngline l1(ac.p2, r.p1); ngline l2(r.p2, led.p1); ngline l3(led.p2, ac.p1); schema sch; sch.AddDevices(&ac, &r, &led, &gnd, 0); sch.AddLines(&l0, &l1, &l2, &l3, 0); circuit cir(&sch); cir.Tran("20", "1m"); do { Sleep(200); } while (CIR.IsRunning() || cir.IsRunning()); }
void divide_assignment_test() { quan::length::m L1(3.); L1 /=2; QUAN_CHECK_EQUAL(L1.numeric_value() , QUAN_FLOAT_TYPE(3.) / 2); quan::length::mm L2(-2310); L2 /= 2343; QUAN_CHECK_EQUAL(L2.numeric_value() ,QUAN_FLOAT_TYPE(-2310) / 2343); quan::length::in L3(-12); L3 /= 0.1; QUAN_CHECK_EQUAL(L3.numeric_value() ,QUAN_FLOAT_TYPE(-12) / 0.1 ); quan::length::in L4(0.314142); L4 /= 3.14142; QUAN_CHECK_EQUAL(L4.numeric_value() ,QUAN_FLOAT_TYPE(0.314142) / 3.14142); }
/** @brief Cholesky factor test */ TEST_F(TestCaseInfExact, CholeskyFactorTest) { // Expected value Matrix L1(5, 5); L1 << 15.033296378372905f, 0.000000000000000f, 0.000000000000000f, 0.000000000000000f, 0.000000000000000f, 7.954233000003977f, 12.756573888848354f, 0.000000000000000f, 0.000000000000000f, 0.000000000000000f, 6.878925159482144f, 2.721575651484489f, 13.087146924501544f, 0.000000000000000f, 0.000000000000000f, 4.036549175942017f, 5.820105434875480f, 7.317399015148106f, 11.058404728090039f, 0.000000000000000f, 4.036549175942017f, 5.820105434875480f, 7.317399015148106f, 10.967975771600516f, 1.411319454917352f; // Actual value const Matrix L21(pL1->matrixL()); const Matrix L22(pL2->matrixL()); // Test TEST_MACRO::COMPARE(L21, L22, __FILE__, __LINE__); TEST_MACRO::COMPARE(L1, L21, __FILE__, __LINE__); TEST_MACRO::COMPARE(L1, L22, __FILE__, __LINE__); }