/** * Sets the working directory of the application. * * Makes the working directory the root directory of installation and makes * sure there is a bin directory. */ void GcbApp::SetWorkingDirectory() { wxString cwd = wxGetCwd(); if (cwd.Find("bin") >= 0) { if (!wxSetWorkingDirectory("..")) { wxMessageBox("Failed to set working directory."); WTL("Failed to set working directory."); throw std::exception(); } else {} } else {} if (!wxDir::Exists("bin")) { wxMessageBox("The bin directory does not exist."); WTL("The bin directory does not exist."); throw std::exception(); } else {} }
void Sylvester ( Int m, ElementalMatrix<F>& WPre, ElementalMatrix<F>& X, SignCtrl<Base<F>> ctrl ) { EL_DEBUG_CSE DistMatrixReadProxy<F,F,MC,MR> WProx( WPre ); auto& W = WProx.Get(); const Grid& g = W.Grid(); Sign( W, ctrl ); DistMatrix<F> WTL(g), WTR(g), WBL(g), WBR(g); PartitionDownDiagonal ( W, WTL, WTR, WBL, WBR, m ); // WTL and WBR should be the positive and negative identity, WBL should be // zero, and WTR should be -2 X Copy( WTR, X ); X *= -F(1)/F(2); // TODO: Think of how to probe for checks on other quadrants. // Add UpdateDiagonal routine to avoid explicit identity Axpy? /* typedef Base<F> Real; UpdateDiagonal( WTL, F(-1) ); const Real errorWTL = FrobeniusNorm( WTL ); const Int n = W.Height() - m; UpdateDiagonal( WBR, F(1) ); const Real errorWBR = FrobeniusNorm( WBR ); const Real errorWBL = FrobeniusNorm( WBL ); */ }
/** * Initializes the main game frame. */ void GcbApp::InitializeGameFrame() { try { tcDisplayModes::Get()->LoadModeFromOptions(); int windowedMode = tcOptions::Get()->windowedMode; if (windowedMode) { int x, y; wxSize size; wxClientDisplayRect(&x, &y, &size.x, &size.y); // account for task bar size long frameStyle = wxDEFAULT_FRAME_STYLE; gameFrame = new tcGame(wxPoint(0,0), size, frameStyle); } else { long frameStyle = wxNO_FULL_REPAINT_ON_RESIZE; gameFrame = new tcGame(wxPoint(0,0), wxGetDisplaySize(), frameStyle); } gameFrame->Init(); } catch(...) { wxMessageBox("The game frame failed to initialize."); WTL("The game frame failed to initialize."); throw std::exception(); } }
void Riccati ( ElementalMatrix<F>& WPre, ElementalMatrix<F>& X, SignCtrl<Base<F>> ctrl ) { DEBUG_CSE DistMatrixReadProxy<F,F,MC,MR> WProx( WPre ); auto& W = WProx.Get(); const Grid& g = W.Grid(); Sign( W, ctrl ); const Int n = W.Height()/2; DistMatrix<F> WTL(g), WTR(g), WBL(g), WBR(g); PartitionDownDiagonal ( W, WTL, WTR, WBL, WBR, n ); // (ML, MR) = sgn(W) - I ShiftDiagonal( W, F(-1) ); // Solve for X in ML X = -MR DistMatrix<F> ML(g), MR(g); PartitionRight( W, ML, MR, n ); MR *= -1; ls::Overwrite( NORMAL, ML, MR, X ); }
inline int Lyapunov( const DistMatrix<F>& A, const DistMatrix<F>& C, DistMatrix<F>& X ) { #ifndef RELEASE CallStackEntry cse("Sylvester"); if( A.Height() != A.Width() ) LogicError("A must be square"); if( C.Height() != A.Height() || C.Width() != A.Height() ) LogicError("C must conform with A"); if( A.Grid() != C.Grid() ) LogicError("A and C must have the same grid"); #endif const Grid& g = A.Grid(); const Int m = A.Height(); DistMatrix<F> W(g), WTL(g), WTR(g), WBL(g), WBR(g); Zeros( W, 2*m, 2*m ); PartitionDownDiagonal ( W, WTL, WTR, WBL, WBR, m ); WTL = A; Adjoint( A, WBR ); Scale( F(-1), WBR ); WTR = C; Scale( F(-1), WTR ); return Sylvester( m, W, X ); }
void tcOptionsView::OnLButtonDown(wxMouseEvent& event) { bool bButtonClicked; int nOption, nValue; if (!mbActive) { event.Skip(); return; } wxPoint pos = event.GetPosition(); if (OnLButtonDownSlider(pos)) { return; } int startMapMode = mpOptions->mnMapMode; // TranslatePoint(point); // adjust for flipped up/down bButtonClicked = ButtonContainingPoint(pos, nOption, nValue); if (bButtonClicked) { if ((nOption >= int(mpOptions->maOptionInfo.size()))|| (nValue >= mpOptions->maOptionInfo[nOption].mnStateCount)) { WTL("tcOptionsView::OnLButtonDown error"); return; } mpOptions->maOptionInfo[nOption].mnValue = nValue; if (mpOptions->maOptionInfo[nOption].associatedInt != NULL) { *mpOptions->maOptionInfo[nOption].associatedInt = nValue; } mpOptions->Serialize(false); // create new options file tcSound::Get()->PlayEffect("MutedBeep"); } else { /* Now this uses tcXmlWindow button bar to switch back to start // switch back to start view if no buttons clicked (for now) wxCommandEvent command(wxEVT_COMMAND_BUTTON_CLICKED, ID_STARTVIEW) ; command.SetEventObject(this); AddPendingEvent(command); */ } if (mpOptions->mnMapMode != startMapMode) { wxCommandEvent command(wxEVT_COMMAND_BUTTON_CLICKED, ID_REFRESHMAPS); command.SetEventObject(this); AddPendingEvent(command); } }
/** * Cleans up upon application exiting. * * This handles application level shut down only. The gameFrame * destructor and all window destructors are automatically called * by wxWindows after falling out of MainLoop(). * * @return An integer representing the status of wxApp::OnExit(). */ int GcbApp::OnExit() { if (errStream != NULL) { fclose(errStream); } if (outStream != NULL) { fclose(outStream); } WTL("FCLOSE"); // special string to close file delete eventLoop; eventLoop = 0; return wxApp::OnExit(); }