// ----------------------------------------------------------------------------- // CLandmarksCategoriesView::DoActivateL // // (other items were commented in a header). // ----------------------------------------------------------------------------- // void CLandmarksCategoriesView::DoActivateL( const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/) { if (!iContainer) { iContainer = new (ELeave) CLandmarksCategoriesContainer( *this, *iEngine, *(MenuBar())); iContainer->SetMopParent(this); iContainer->ConstructL(ClientRect()); } // Enable receiving of keyboard events. AppUi()->AddToStackL(*this, iContainer); // Make view visible. iContainer->MakeVisible(ETrue); // Notify that this view is active. TBool isActive = ETrue; iEngine->NotifyViewActivated(Id(), isActive); }
void Cell::reinit( const Eref& cell, ProcPtr p ) //~ void Cell::reinit( const Eref& cell, const Qinfo* q ) { cout << ".. Cell::reinit()" << endl; //~ if ( q->protectedAddToStructuralQ() ) //~ return; // Delete existing solver //~ string solverPath = cell.id().path() + "/" + solverName_; //~ Id solver( solverPath ); //~ if ( solver.path() == solverPath ) //~ solver.destroy(); if ( method_ == "ee" ) return; // Find any compartment that is a descendant of this cell Id seed = findCompt( cell.id() ); if ( seed == Id() ) // No compartment found. return; setupSolver( cell.id(), seed ); }
bool Shell::innerMove( Id orig, ObjId newParent ) { static const Finfo* pf = Neutral::initCinfo()->findFinfo( "parentMsg" ); static const DestFinfo* pf2 = dynamic_cast< const DestFinfo* >( pf ); static const FuncId pafid = pf2->getFid(); static const Finfo* f1 = Neutral::initCinfo()->findFinfo( "childOut" ); assert( !( orig == Id() ) ); assert( !( newParent.element() == 0 ) ); ObjId mid = orig.element()->findCaller( pafid ); Msg::deleteMsg( mid ); Msg* m = new OneToAllMsg( newParent.eref(), orig.element(), 0 ); assert( m ); if ( !f1->addMsg( pf, m->mid(), newParent.element() ) ) { cout << "move: Error: unable to add parent->child msg from " << newParent.element()->getName() << " to " << orig.element()->getName() << "\n"; return 0; } return 1; }
void Leftist::Lnode::Picture (int level, char const * stg) { int ii; for (ii=1; ii < level; ii++) cout << stg; cout << "Token: " << Id() << ", " << "Time: " << time << ", " << "Event: "; char egg [TINY_BFR_SIZ+1]; if (event_id >= 0) cout << event_id; else { strncpy(egg, fn_descr, TINY_BFR_SIZ); egg [TINY_BFR_SIZ] = 0; cout << "'" << egg << "'"; } cout << "\n"; if (lson) lson->Picture (level+1, "'' "); if (rson) rson->Picture (level+1, "`` "); }
/** * Static utility function. Attaches child element to parent element. * Must only be called from functions executing in parallel on all nodes, * as it does a local message addition * MsgIndex is needed to be sure that the same msg identifies parent-child * connection on all nodes. */ bool Shell::adopt( ObjId parent, Id child, unsigned int msgIndex ) { static const Finfo* pf = Neutral::initCinfo()->findFinfo( "parentMsg" ); // static const DestFinfo* pf2 = dynamic_cast< const DestFinfo* >( pf ); // static const FuncId pafid = pf2->getFid(); static const Finfo* f1 = Neutral::initCinfo()->findFinfo( "childOut" ); assert( !( child.element() == 0 ) ); assert( !( child == Id() ) ); assert( !( parent.element() == 0 ) ); Msg* m = new OneToAllMsg( parent.eref(), child.element(), msgIndex ); assert( m ); // cout << myNode_ << ", Shell::adopt: mid = " << m->mid() << ", pa =" << parent << "." << parent()->getName() << ", kid=" << child << "." << child()->getName() << "\n"; if ( !f1->addMsg( pf, m->mid(), parent.element() ) ) { cout << "move: Error: unable to add parent->child msg from " << parent.element()->getName() << " to " << child.element()->getName() << "\n"; return 0; } return 1; }
void Volume::Dump(const char* aLabel) const { LOG("%s: Volume: %s (%d) is %s and %s @ %s gen %d locked %d", aLabel, NameStr(), Id(), StateStr(), MediaPresent() ? "inserted" : "missing", MountPoint().get(), MountGeneration(), (int)IsMountLocked()); LOG("%s: Sharing %s Mounting %s Formating %s Unmounting %s", aLabel, CanBeShared() ? (IsSharingEnabled() ? (IsSharing() ? "en-y" : "en-n") : "dis") : "x", IsMountRequested() ? "req" : "n", IsFormatRequested() ? (IsFormatting() ? "req-y" : "req-n") : (IsFormatting() ? "y" : "n"), IsUnmountRequested() ? (IsUnmounting() ? "req-y" : "req-n") : (IsUnmounting() ? "y" : "n")); }
unsigned short int AddFile(boost::filesystem::path p, unsigned short int top, std::string prefix, file_list& files) { if(Contains(p.string(), files)) return Id(p.string(), files); file_info temp; temp.fileID = files.size()+1; temp.parentID = top; if(!boost::filesystem::exists(p)) temp.file = false; else if(boost::filesystem::is_directory(boost::filesystem::status(p))) temp.file = false; else temp.file = true; strcpy(temp.filename, p.filename().string().c_str()); strcpy(temp.fullname, p.string().c_str()); std::cout << "Adding " << prefix << temp.fullname << " to archive\n"; files.push_back(temp); return temp.fileID; }
// ----------------------------------------------------------------------------- // CMceMicSource::SetGainL // ----------------------------------------------------------------------------- // EXPORT_C void CMceMicSource::SetGainL( TInt aGain ) { MCECLI_DEBUG("CMceMicSource::SetGainL, Entry"); MCECLI_DEBUG_DVALUE("gain", aGain); if ( MCE_ENDPOINT_ITC_ALLOWED( *this ) ) { CMceSession* session = iStream->Session(); TMceIds ids; session->PrepareForITC( ids ); ids.iMediaID = iStream->Id(); ids.iSourceID = Id(); TMceItcArgTInt gain( aGain ); session->ITCSender().WriteL( ids, EMceItcSetGain, gain ); } FLAT_DATA( iGain ) = aGain; MCECLI_DEBUG("CMceMicSource::SetGainL, Exit"); }
Id SigNeur::findSoma( const vector< Id >& compts ) { double maxDia = 0; Id maxCompt; vector< Id > somaCompts; // Theoretically possible to have an array. for ( vector< Id >::const_iterator i = compts.begin(); i != compts.end(); ++i ) { string className = i->eref()->className(); if ( className == "Compartment" || className == "SymCompartment" ) { string name = i->eref().e->name(); if ( name == "soma" || name == "Soma" || name == "SOMA" ) somaCompts.push_back( *i ); double dia; get< double >( i->eref(), "diameter", dia ); if ( dia > maxDia ) maxCompt = *i; } } if ( somaCompts.size() == 1 ) // First, go by name. return somaCompts[0]; if ( somaCompts.size() == 0 & maxCompt.good() ) //if no name, use maxdia return maxCompt; if ( somaCompts.size() > 1 ) { // Messy but unlikely cases. if ( maxCompt.good() ) { if ( find( somaCompts.begin(), somaCompts.end(), maxCompt ) != somaCompts.end() ) return maxCompt; else cout << "Error, soma '" << somaCompts.front().path() << "' != biggest compartment '" << maxCompt.path() << "'\n"; } return somaCompts[0]; // Should never happen, but an OK response. } cout << "Error: SigNeur::findSoma failed to find soma\n"; return Id(); }
void ForceConst::Svd(){ int n=Rms.dim1(); int StartLoop=static_cast<int> (Percent*n); Array2D<double> U, V, S; Array1D<double> s; /* for(int i=0;i<n;i++) for(int j=0;j<n;j++) { Rms[i][j]=Rms[i][j]*100.0; if(Dist[i][j] > 0.6) { cout << i << " " << j << " " << Dist[i][j] << endl; Rms[i][j]=0.0; } } */ SVD<double> G(Rms); G.getU(U); G.getV(V); G.getS(S); G.getSingularValues(s); Array2D<double> Sm1(n,n), Ks(n,n), Rms_b(n,n), V1(n,n), U1(n,n), Id(n,n); for(int i=StartLoop;i<n;i++) S[i][i]=0.0; V1=transpose(V); U1=transpose(U); Rms_b=matmult(U,matmult(S,V1)); Sm1=S; for(int i=0;i<n;i++) Sm1[i][i]=(Sm1[i][i] == 0.0)?0.0:1.0/Sm1[i][i]; Ks=matmult(V,matmult(Sm1,U1)); Id=matmult(transpose(Ks),Rms_b); for(int i=0;i<n;i++) printf(" %5d %12.5e %12.5e \n",i,Rms[i][i],Rms_b[i][i]); // for(int i=0;i<n;i++) // for(int j=i;j<n;j++) // printf(" %5d %5d %12.4f %12.5e %12.5e \n",i,j,Dist[i][j],Ks[i][j], Rms[i][j]); }
Cold::Cold( arbiter::Endpoint& endpoint, const Builder& builder, const std::size_t clipPoolSize, const Json::Value& jsonIds) : m_endpoint(endpoint) , m_builder(builder) , m_chunkVec(getNumFastTrackers(builder.structure())) , m_chunkMap() , m_mapMutex() , m_pool(new Pool(clipPoolSize, clipQueueSize)) { if (jsonIds.isArray()) { Id id(0); const Structure& structure(m_builder.structure()); for (std::size_t i(0); i < jsonIds.size(); ++i) { id = Id(jsonIds[static_cast<Json::ArrayIndex>(i)].asString()); const ChunkInfo chunkInfo(structure.getInfo(id)); const std::size_t chunkNum(chunkInfo.chunkNum()); if (chunkNum < m_chunkVec.size()) { m_chunkVec[chunkNum].mark.store(true); } else { std::unique_ptr<CountedChunk> c(new CountedChunk()); m_chunkMap.emplace(id, std::move(c)); } } } }
/*--------------------------------------------------------------------------*/ PegTextBox::PegTextBox(const PegRect &Rect, WORD wId, WORD wStyle, PEGCHAR *Text, WORD wMaxChars) : PegWindow(Rect, wStyle), PegTextThing(Text, wStyle & (EF_EDIT|TT_COPY), PEG_TEXTBOX_FONT) { Id(wId); muColors[PCI_NORMAL] = PCLR_CLIENT; muColors[PCI_SELECTED] = PCLR_HIGH_TEXT_BACK; muColors[PCI_NTEXT] = PCLR_NORMAL_TEXT; muColors[PCI_STEXT] = PCLR_HIGH_TEXT; Type(TYPE_TEXTBOX); miTopLine = 0; miClipCount = 0; mwMaxChars = wMaxChars; miWidestLine = 0; miLeftOffset = 0; miMarkLine = -1; miLineHeight = TextHeight(lsTEST, mpFont); mpBuf = NULL; miBufLen = 0; if (wStyle & (EF_EDIT|AF_ENABLED)) { AddStatus(PSF_TAB_STOP); } else { RemoveStatus(PSF_TAB_STOP|PSF_ACCEPTS_FOCUS); } miTotalLines = 0; // configure the start of line indexes: mwLineStarts = new WORD[MAX_LINE_OFFSETS]; UpdateLineStarts(); }
void AudioBufferSourceNode::Stop(double aWhen, ErrorResult& aRv) { if (!WebAudioUtils::IsTimeValid(aWhen)) { aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR); return; } if (!mStartCalled) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return; } WEB_AUDIO_API_LOG("%f: %s %u Stop(%f)", Context()->CurrentTime(), NodeType(), Id(), aWhen); AudioNodeStream* ns = mStream; if (!ns || !Context()) { // We've already stopped and had our stream shut down return; } ns->SetStreamTimeParameter(STOP, Context(), std::max(0.0, aWhen)); }
void ReadKkit::call( const vector< string >& args) { /// call /kinetics/foo/notes LOAD notes_string_here if ( args.size() > 3 ) { unsigned int len = args[1].length(); if ( ( args[1].substr( len - 5 ) == "notes" ) && args[2] == "LOAD" ) { if ( args[3].length() == 0 ) return; //HARSHA: Added CleanPath. string objName = cleanPath(args[1].substr( 0, len - 5 )); Id test(basePath_+objName); Id obj( basePath_ + objName + "info" ); if ( obj != Id() ) { string notes = ""; string space = ""; for ( unsigned int i = 3; i < args.size(); ++i ) { unsigned int innerLength = args[i].length(); if ( innerLength == 0 ) continue; unsigned int start = 0; unsigned int end = innerLength; if ( args[i][0] == '\"' ) start = 1; if ( args[i][innerLength - 1] == '\"' ) end = innerLength - 1 - start; notes += space + args[i].substr( start, end ); space = " "; } bool OK = Field< string >::set( obj, "notes", notes ); assert( OK ); } } } }
int main(int argc, char **argv){ // (when V-REP launches this executable, V-REP will also provide the argument list) // Se reciben 9 argumentos if (argc>=1) { Npata_arg=atoi(argv[1]); } else { ROS_ERROR("Nodo 2: Indique argumentos!\n"); sleep(5000); return 0; } /*Inicio nodo de ROS*/ std::string nodeName("Nodo2_Parametrizacion_pata"); std::string Id(boost::lexical_cast<std::string>(Npata_arg)); nodeName+=Id; ros::init(argc,argv,nodeName.c_str()); ros::NodeHandle n; //ROS_INFO("Nodo2_Parametrizacion just started\n"); //Topicos susbcritos y publicados chatter_pub = n.advertise<camina::AngulosMotor>("DatosDeMotores", 100); ros::Subscriber sub = n.subscribe("datosTrayectoriaPataSalida", 100, datosCallback); ros::Subscriber subInfo=n.subscribe("/vrep/info",1,infoCallback); while (ros::ok() && simulationRunning) { ros::spinOnce(); } //ROS_INFO("Adios2!"); ros::shutdown(); return 0; }
Id ReadKkit::buildEnz( const vector< string >& args ) { string head; string clean = cleanPath( args[2] ); string tail = pathTail( clean, head ); Id pa = shell_->doFind( head ).id; assert ( pa != Id() ); double k1 = atof( args[ enzMap_[ "k1" ] ].c_str() ); double k2 = atof( args[ enzMap_[ "k2" ] ].c_str() ); double k3 = atof( args[ enzMap_[ "k3" ] ].c_str() ); // double volscale = atof( args[ enzMap_[ "vol" ] ].c_str() ); double nComplexInit = atof( args[ enzMap_[ "nComplexInit" ] ].c_str() ); // double vol = atof( args[ enzMap_[ "vol" ] ].c_str()); bool isMM = atoi( args[ enzMap_[ "usecomplex" ] ].c_str()); assert( poolVols_.find( pa ) != poolVols_.end() ); // double vol = poolVols_[ pa ]; /** * vsf is vol scale factor, which is what GENESIS stores in 'vol' field * n = vsf * conc( uM ) * Also, n = ( conc (uM) / 1e6 ) * NA * vol * so, vol = 1e6 * vsf / NA */ if ( isMM ) { Id enz = shell_->doCreate( "MMenz", pa, tail, 1 ); assert( enz != Id () ); string mmEnzPath = clean.substr( 10 ); mmEnzIds_[ mmEnzPath ] = enz; assert( k1 > EPSILON ); double Km = ( k2 + k3 ) / k1; Field< double >::set( enz, "Km", Km ); Field< double >::set( enz, "kcat", k3 ); Id info = buildInfo( enz, enzMap_, args ); numMMenz_++; return enz; } else { Id enz = shell_->doCreate( "Enz", pa, tail, 1 ); // double parentVol = Field< double >::get( pa, "volume" ); assert( enz != Id () ); string enzPath = clean.substr( 10 ); enzIds_[ enzPath ] = enz; // Need to figure out what to do about these. Perhaps it is OK // to do this assignments in raw #/cell units. Field< double >::set( enz, "k3", k3 ); Field< double >::set( enz, "k2", k2 ); Field< double >::set( enz, "k1", k1 ); string cplxName = tail + "_cplx"; string cplxPath = enzPath + "/" + cplxName; Id cplx = shell_->doCreate( "Pool", enz, cplxName, 1 ); assert( cplx != Id () ); poolIds_[ cplxPath ] = cplx; // Field< double >::set( cplx, "nInit", nComplexInit ); Field< double >::set( cplx, "nInit", nComplexInit ); // Use this later to assign mesh entries to enz cplx. enzCplxMols_.push_back( pair< Id, Id >( pa, cplx ) ); separateVols( cplx, -1 ); // -1 vol is a flag to defer mesh assignment for the cplx pool. ObjId ret = shell_->doAddMsg( "OneToAll", ObjId( enz, 0 ), "cplx", ObjId( cplx, 0 ), "reac" ); assert( ret != ObjId() ); // cplx()->showFields(); // enz()->showFields(); // pa()->showFields(); Id info = buildInfo( enz, enzMap_, args ); numEnz_++; return enz; } }
GlAlgo* GlTriangle1d::Generate(const gl_generate_args& args) const { return new _GlTriangle1d( Id(), Params().Float(GL_CYCLE_KEY), Params().Float(GL_PHASE_KEY)); }
extern "C" UNITY_INTERFACE_EXPORT int CreatePipeline() { auto pipeline = ImageProcessing::PipelineManager::Instance()->CreatePipeline(); pipeline->Start(); return pipeline->Id(); }
js::Thread::Thread(Thread&& aOther) { id_ = aOther.id_; aOther.id_ = Id(); options_ = aOther.options_; }
void RepoQuery::getId(int iCol, Id& id) { int val; getInt(iCol, val); id = Id(val); }
////////////////////////////////////////////////////////////// // Zombie conversion functions. ////////////////////////////////////////////////////////////// void ZPool::setSolver( Id solver ) { assert ( solver != Id() ); assert( solver.element()->cinfo()->isA( "SolverBase" ) ); solver_ = reinterpret_cast< SolverBase* >( solver.eref().data() ); }
bool js::Thread::joinable(LockGuard<Mutex>& lock) { return id_ != Id(); }
/////////////////////////////////////////////////////////////////////////////// /// \brief Load a set of WindowSettings from a bed. /// /// \details Each WindowSettings Id represents a stack of current and previous /// values. This allows the user to revert to previous settings if /// new settings are tried and not supported. /// /// \param bed The bed to load from. /// \param id The Id of the WindowSettings stack to load. /// /// \ingroup loading WindowSettings loadWindowSettings(bed::Bed& bed, const Id& id) { try { bed::StmtCache& cache = bed.getStmtCache(); bed::CachedStmt& stmt = cache.hold(Id(BE_WND_WINDOW_SETTINGS_SQLID_LOAD), BE_WND_WINDOW_SETTINGS_SQL_LOAD); stmt.bind(1, id.value()); if (stmt.step()) { WindowSettings ws; ws.id.bed = bed.getId(); ws.id.asset = id; ws.mode = static_cast<WindowSettings::Mode>(stmt.getInt(0)); ws.system_positioned = stmt.getBool(1); ws.save_position_on_close = stmt.getBool(2); ws.position.x = stmt.getInt(3); ws.position.y = stmt.getInt(4); ws.size.x = stmt.getInt(5); ws.size.y = stmt.getInt(6); ws.monitor_index = stmt.getInt(7); ws.refresh_rate = stmt.getUInt(8); ws.v_sync = static_cast<WindowSettings::VSyncMode>(stmt.getInt(9)); ws.msaa_level = stmt.getUInt(10); ws.red_bits = stmt.getUInt(11); ws.green_bits = stmt.getUInt(12); ws.blue_bits = stmt.getUInt(13); ws.alpha_bits = stmt.getUInt(14); ws.depth_bits = stmt.getUInt(15); ws.stencil_bits = stmt.getUInt(16); ws.srgb_capable = stmt.getBool(17); ws.use_custom_gamma = stmt.getBool(18); ws.custom_gamma = float(stmt.getDouble(19)); ws.context_version_major = stmt.getUInt(20); ws.context_version_minor = stmt.getUInt(21); ws.forward_compatible_context = stmt.getBool(22); ws.debug_context = stmt.getBool(23); ws.context_profile_type = static_cast<WindowSettings::ContextProfileType>(stmt.getInt(24)); return ws; } else throw std::runtime_error("WindowSettings record not found!"); } catch (const bed::Db::error& err) { BE_LOG(VWarning) << "Database error while loading window settings!" << BE_LOG_NL << " Bed: " << bed.getId() << BE_LOG_NL << "WindowSettings ID: " << id << BE_LOG_NL << " Exception: " << err.what() << BE_LOG_NL << " SQL: " << err.sql() << BE_LOG_END; } catch (const std::runtime_error& err) { BE_LOG(VWarning) << "Exception while loading window settings!" << BE_LOG_NL << " Bed: " << bed.getId() << BE_LOG_NL << "WindowSettings ID: " << id << BE_LOG_NL << " Exception: " << err.what() << BE_LOG_END; } return WindowSettings(); }
bool BrowsingContext::IsCached() { return sCachedBrowsingContexts->has(Id()); }
TVerdict CTcpClientTestUPnP13::RunTestL() { switch ( iState ) { case ECreateTestServer: { iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>")); iTestServer = CTestTcpServer::NewL ( *this ); iState = ECreateTestClient; iStatus = KRequestPending; Reschedule(); return EPass; } case ECreateTestClient: { iLogger.WriteFormat(_L("<i>TestServer is created..... </i>")); iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>")); THttpClientFlowQuery flowQuery ( TAppProtAddr ( KInetAddrLoop, KHttpDefaultPort ), Id (), EHttpClientFlow, THttpClientFlowQuery::ECreateNew, iChunkManager ); const TUid requestedUid = { CUPnPFlowFactory::iUid }; TNodeId factoryContainer = SockManGlobals::Get( )->GetPlaneFC( TCFPlayerRole ( TCFPlayerRole::EDataPlane ) ); RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( KActivityNull, factoryContainer ), TCFFactory::TFindOrCreatePeer ( TCFPlayerRole::EDataPlane, requestedUid, &flowQuery ).CRef () ); iState = ESendRequestData; iStatus = KRequestPending; Reschedule(); return EPass; } case ESendRequestData: { iLogger.WriteFormat(_L("<i>Client is Created</i>")); iLogger.WriteFormat(_L("<i>Send data..... </i>")); TPtrC8 data(KData1); TPtrC8 data2(KData2); TPtrC8 data3(KData3); iSSP->SetOption(KCHOptionLevel, KCHAbsoluteUri, _L8 ("http://127.0.0.1")); TCHMessageOption option ( 1, data.Length()+data2.Length()+data3.Length() ); TPckg < TCHMessageOption > optionBuf ( option ); iSSP->SetOption(KCHOptionLevel, KCHMaxLength, optionBuf); RMBufChain bodyBuf; bodyBuf.CreateL(KData1); iSSPData->Write(bodyBuf, 0, NULL); /* TCHMessageOption option2 ( 1, data2.Length() ); TPckg < TCHMessageOption > optionBuf2 ( option2 ); iSSP->SetOption(KCHOptionLevel, KCHMaxLength, optionBuf2); */ RMBufChain bodyBuf1; bodyBuf1.CreateL(KData2); iSSPData->Write(bodyBuf1, 0, NULL); /* TCHMessageOption option3 ( 1, data3.Length() ); TPckg < TCHMessageOption > optionBuf3 ( option3 ); iSSP->SetOption(KCHOptionLevel, KCHMaxLength, optionBuf3); */ RMBufChain bodyBuf2; bodyBuf2.CreateL(KData3); iSSPData->Write(bodyBuf2, 0, NULL); iState = ECleanup; iStatus = KRequestPending; Reschedule (); return EPass; } case ECleanup: { delete iTestServer; // cleanup tcp client flow delete reinterpret_cast<CHttpClientFlow*> ( iClientId.Ptr () ); iTimer.After ( iStatus, 60000000 ); //10 secs iState = EComplete; iStatus = KRequestPending; Reschedule (); return EPass; } case EComplete: { iLogger.WriteFormat(_L("<i>TestCase: Complete..... </i>")); return EPass; } default: iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>")); ASSERT(0); return EFail; } }
void Context::add(const char *id) { d.append(Id(id).uniqueIdentifier()); }
void MatrixNormTest(ofstream &_tex,__int64_t &n) { n= 12; makeLatexSection("Haar Distributed Random Orthogonal Matrix $A \\in O(n)$",_tex); _tex<<" Testing Operator Norm"<<endl<<"Number of Dimensions: "<<n<<endl<<endl; klMatrix<double> Op= IdentityMatrix<double>( n); Op= klMatrix<double>:: klLU<double> LU(Op); klMatrix<double> u =LU.operator()(); klMatrix<double> l =LU.L(); klMatrix<double> lu = l*u; LatexPrintMatrix(Op, "A",_tex); _tex<<"$Det(A) : A \\in O(n)$ = "<<Op.det()<<endl<<endl; LatexPrintMatrix(l, "L",_tex); LatexPrintMatrix(u, "U",_tex); LatexPrintMatrix(lu, "L * U ",_tex); _tex<<"$Det(L) : = "<<l.det()<<" "<<" Det(U) : = "<<u.det()<<" "<<" Det(LU) : = "<<lu.det()<<"$"<<endl<<endl; _tex<<"$||A||_{L_1}$ = "<<Op.norm()<<endl<<endl; _tex<<"$||A||_{L_{\\infty}}$ = "<<Op.norm(true)<<endl<<endl; _tex<<"$||A^{-1}||_{L_1}$ = "<<Op.inverse().norm()<<endl<<endl; _tex<<"$||A^{-1}||_{L_{\\infty}}$ = "<<Op.inverse().norm(true)<<endl<<endl; _tex<<"$||A||_{L_{\\infty}} * ||A^{-1}||_{L_{\\infty}} = "<<Op.norm(true) * Op.inverse().norm(true)<<"$"<<endl<<endl; _tex<<"$||A||_{L_1} * ||A^{-1}||_{L_1} = "<< Op.norm() * Op.inverse().norm()<<"$"<<endl<<endl; double A_f =0; for(int i=0;i<n;i++) { A_f+=Op[i].pow_alpha(2).sum(); } A_f = sqrt(A_f); _tex<<"Frobenious Norm $||A||_{\\textit{F}}$ via $\\sum\\limits_{i,j =0}^{n} \\|A_{i,j}|$ of $A \\in O(n)$ "<<A_f<<endl<<endl; _tex<<"$L_1$ condition number of Haar Distributed Random Orthogonal Matrix $A \\in O(n)$ "<<Op.ConditionNumber(1)<<endl<<endl; LatexPrintMatrix(Op, "A",_tex); _tex<<"$L_{\\infty}$ condition number of Haar Distributed Random Orthogonal Matrix $A \\in O(n)$ "<<Op.ConditionNumber()<<endl<<endl; klVector<complex<double> > eigen =Op.eigenvalues(); _tex<<"Eigenvalues of $A \\in O(n)$"<<endl<<endl; _tex<<eigen<<endl; klVector<double> argEigenvalues(n); for(int i=0;i<n;i++) { argEigenvalues[i] = std::abs(eigen[i]); } _tex<<" $|\\lambda | : \\lambda \\in \\sigma(A) , A \\in O(n)$"<<endl<<endl; _tex<<argEigenvalues<<endl<<endl; _tex<<"Calculating $A^{\\dag} A,$ we expect $A^{\\dag} A \\approx I$"<<endl<<endl; klMatrix<double> ortho(n,n); int i=0; int j=0; for(i=0;i<n;i++) { for(j=0;j<n;j++) { ortho[i][j] = Op.getColumn(i).dotBLAS(Op.getColumn(j)); } } LatexPrintMatrix(ortho,"A^{\\dag} A",_tex); //test \alpha A x + \beta y //klMatrix<float> mvpBLAS(float alpha, klMatrix<float> a,klVector<float> x, float beta,klVector<float> yi); klVector<double> Axbpy = mvpBLAS(1.0, ortho,ortho[0], 2.0,ortho[1]); //_tex<<ortho[0]<<endl; //_tex<<ortho[1]<<endl; //_tex<<Axbpy<<endl; ortho = Op; _tex<<"Calculating $A^{-1} , A \\in O(n)$."<<endl<<endl; klMatrix<double> invOrtho= Op.inverse(); LatexPrintMatrix(invOrtho,"A^{-1}",_tex); _tex<<"Calculating $A^{-1} *A , A \\in O(n)$. We expect $A^{-1} *A \\approx I$. "<<endl<<endl; LatexPrintMatrix(invOrtho*Op,"A^{-1} *A",_tex); _tex<<"Calculating SVD of $A \\in O(n)$"<<endl<<endl; { klSVD<double> SVD(Op); klMatrix<double> Sigma = SVD(); klMatrix<double> S = diag(*Sigma); klMatrix<double> U = SVD.U(); klMatrix<double> V = SVD.V(); LatexPrintMatrix(*U,"U",_tex); LatexPrintMatrix(S,"S",_tex); LatexPrintMatrix(*V,"V",_tex); LatexPrintMatrix( *(U) * (S) * *(V),"U S V",_tex); } makeLatexSection("Wishart Matrix $A \\in W(n)$",_tex); klMatrix<double> AW= SampleWishart(n); _tex<<"$L_1$ condition number of Wishart Matrix "<<AW.ConditionNumber(true)<<endl; _tex<<"$L_\infty$ condition number of Wishart Matrix "<<AW.ConditionNumber()<<endl; makeLatexSection("Gaussian Orthogonal Ensemble $A \\in GOE(n)$",_tex); klMatrix<double> A_GOE = SampleGOE(n); klMatrix<double> Ainv=A_GOE.inverse(); klMatrix<double> Id_goe=Ainv * A_GOE; Id_goe.threshold(0.001f,+0.0f); Id_goe = Id_goe + 0.0; klVector<double> x=Id_goe[0]; klVector<double> y=Id_goe[2]; _tex<<"$L_1$ condition number of GOE Matrix "<<A_GOE.ConditionNumber(true)<<endl; _tex<<"$L_\\infty$ condition number of GOE Matrix "<<A_GOE.ConditionNumber(true)<<endl; makeLatexSection("The Identity Matrix $I \\in M(n)$",_tex); klMatrix<double> Id(n,n); Id= IdentityMatrix<double>(n); _tex<<"$L_1$ condition number of $I$ = "<<Id.ConditionNumber(true)<<endl; _tex<<"$L_\\infty$ condition number of $I$ = "<<Id.ConditionNumber()<<endl; _tex.flush(); }
bool Context::contains(const char *id) const { return d.contains(Id(id).uniqueIdentifier()); }
/////////////////////////////////////////////////////////////////////////////// /// \brief Saves a set of WindowSettings to a bed. /// /// \details The bed and Id that are saved to are determined by the id field /// of the WindowSettings object passed in. If the WindowSettings /// already exist in the bed, a new history index will be created. /// /// If there is a problem saving the WindowSettings, a warning will /// be emitted, and false will be returned. /// /// \param window_settings The WindowSettings to save. /// \return \c true if the WindowSettings were saved successfully. /// /// \ingroup loading bool saveWindowSettings(const WindowSettings& window_settings) { try { std::shared_ptr<bed::Bed> bed = bed::openWritable(window_settings.id.bed); if (!bed) throw std::runtime_error("Could not open bed for writing!"); bed::Db& db = bed->getDb(); bed::Transaction transaction(db, bed::Transaction::Immediate); int history_index = 0; if (db.getInt(BE_WND_WINDOW_SETTINGS_SQL_TABLE_EXISTS, 0) == 0) { db.exec(BE_WND_WINDOW_SETTINGS_SQL_CREATE_TABLE); } else { bed::Stmt latest(db, Id(BE_WND_WINDOW_SETTINGS_SQLID_LATEST_INDEX), BE_WND_WINDOW_SETTINGS_SQL_LATEST_INDEX); latest.bind(1, window_settings.id.asset.value()); if (latest.step()) history_index = latest.getInt(0); } bed::Stmt save(db, Id(BE_WND_WINDOW_SETTINGS_SQLID_SAVE), BE_WND_WINDOW_SETTINGS_SQL_SAVE); save.bind(1, window_settings.id.asset.value()); save.bind(2, history_index + 1); save.bind(3, static_cast<int>(window_settings.mode)); save.bind(4, window_settings.system_positioned); save.bind(5, window_settings.save_position_on_close); save.bind(6, window_settings.position.x); save.bind(7, window_settings.position.y); save.bind(8, window_settings.size.x); save.bind(9, window_settings.size.y); save.bind(10, window_settings.monitor_index); save.bind(11, window_settings.refresh_rate); save.bind(12, static_cast<int>(window_settings.v_sync)); save.bind(13, window_settings.msaa_level); save.bind(14, window_settings.red_bits); save.bind(15, window_settings.green_bits); save.bind(16, window_settings.blue_bits); save.bind(17, window_settings.alpha_bits); save.bind(18, window_settings.depth_bits); save.bind(19, window_settings.stencil_bits); save.bind(20, window_settings.srgb_capable); save.bind(21, window_settings.use_custom_gamma); save.bind(22, window_settings.custom_gamma); save.bind(23, window_settings.context_version_major); save.bind(24, window_settings.context_version_minor); save.bind(25, window_settings.forward_compatible_context ? 1 : 0); save.bind(26, window_settings.debug_context ? 1 : 0); save.bind(27, static_cast<int>(window_settings.context_profile_type)); save.step(); transaction.commit(); return true; } catch (const bed::Db::error& err) { BE_LOG(VWarning) << "Database error while saving window settings!" << BE_LOG_NL << " Bed: " << window_settings.id.bed << BE_LOG_NL << "WindowSettings ID: " << window_settings.id.asset << BE_LOG_NL << " Exception: " << err.what() << BE_LOG_NL << " SQL: " << err.sql() << BE_LOG_END; } catch (const std::runtime_error& err) { BE_LOG(VWarning) << "Exception while saving window settings!" << BE_LOG_NL << " Bed: " << window_settings.id.bed << BE_LOG_NL << "WindowSettings ID: " << window_settings.id.asset << BE_LOG_NL << " Exception: " << err.what() << BE_LOG_END; } return false; }
bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *) { Context textcontext(TextEditor::Constants::C_TEXTEDITOR); Context globalcontext(Core::Constants::C_GLOBAL); ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS); ActionContainer *mbm = ActionManager::createMenu(Id(BOOKMARKS_MENU)); mbm->menu()->setTitle(tr("&Bookmarks")); mtools->addMenu(mbm); //Toggle m_toggleAction = new QAction(tr("Toggle Bookmark"), this); Command *cmd = ActionManager::registerAction(m_toggleAction, BOOKMARKS_TOGGLE_ACTION, textcontext); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+M") : tr("Ctrl+M"))); mbm->addAction(cmd); mbm->addSeparator(textcontext); //Previous m_prevAction = new QAction(tr("Previous Bookmark"), this); cmd = ActionManager::registerAction(m_prevAction, BOOKMARKS_PREV_ACTION, globalcontext); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+,") : tr("Ctrl+,"))); mbm->addAction(cmd); //Next m_nextAction = new QAction(tr("Next Bookmark"), this); cmd = ActionManager::registerAction(m_nextAction, BOOKMARKS_NEXT_ACTION, globalcontext); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Meta+.") : tr("Ctrl+."))); mbm->addAction(cmd); mbm->addSeparator(globalcontext); //Previous Doc m_docPrevAction = new QAction(tr("Previous Bookmark in Document"), this); cmd = ActionManager::registerAction(m_docPrevAction, BOOKMARKS_PREVDOC_ACTION, globalcontext); mbm->addAction(cmd); //Next Doc m_docNextAction = new QAction(tr("Next Bookmark in Document"), this); cmd = ActionManager::registerAction(m_docNextAction, BOOKMARKS_NEXTDOC_ACTION, globalcontext); mbm->addAction(cmd); m_editBookmarkAction = new QAction(tr("Edit Bookmark"), this); m_bookmarkManager = new BookmarkManager; connect(m_toggleAction, &QAction::triggered, [this]() { if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor()) m_bookmarkManager->toggleBookmark(editor->document()->filePath(), editor->currentLine()); }); connect(m_prevAction, &QAction::triggered, m_bookmarkManager, &BookmarkManager::prev); connect(m_nextAction, &QAction::triggered, m_bookmarkManager, &BookmarkManager::next); connect(m_docPrevAction, &QAction::triggered, m_bookmarkManager, &BookmarkManager::prevInDocument); connect(m_docNextAction, &QAction::triggered, m_bookmarkManager, &BookmarkManager::nextInDocument); connect(m_editBookmarkAction, &QAction::triggered, [this]() { m_bookmarkManager->editByFileAndLine(m_bookmarkMarginActionFileName, m_bookmarkMarginActionLineNumber); }); connect(m_bookmarkManager, &BookmarkManager::updateActions, this, &BookmarksPlugin::updateActions); updateActions(m_bookmarkManager->state()); addAutoReleasedObject(new BookmarkViewFactory(m_bookmarkManager)); m_bookmarkMarginAction = new QAction(this); m_bookmarkMarginAction->setText(tr("Toggle Bookmark")); connect(m_bookmarkMarginAction, &QAction::triggered, [this]() { m_bookmarkManager->toggleBookmark(m_bookmarkMarginActionFileName, m_bookmarkMarginActionLineNumber); }); // EditorManager connect(EditorManager::instance(), &EditorManager::editorAboutToClose, this, &BookmarksPlugin::editorAboutToClose); connect(EditorManager::instance(), &EditorManager::editorOpened, this, &BookmarksPlugin::editorOpened); return true; }