static void RicochetNext (void) { if (!Solved ()) while (Undo()); NextTarget (); }
//============================================================================= int Epetra_SerialSpdDenseSolver::ApplyRefinement(void) { double DN = N_; double DNRHS = NRHS_; if (!Solved()) EPETRA_CHK_ERR(-100); // Must have an existing solution if (A_==AF_) EPETRA_CHK_ERR(-101); // Cannot apply refine if no original copy of A. if (FERR_ != 0) delete [] FERR_; // Always start with a fresh copy of FERR_, since NRHS_ may change FERR_ = new double[NRHS_]; if (BERR_ != 0) delete [] BERR_; // Always start with a fresh copy of FERR_, since NRHS_ may change BERR_ = new double[NRHS_]; AllocateWORK(); AllocateIWORK(); PORFS(SymMatrix_->UPLO(), N_, NRHS_, A_, LDA_, AF_, LDAF_, B_, LDB_, X_, LDX_, FERR_, BERR_, WORK_, IWORK_, &INFO_); SolutionErrorsEstimated_ = true; ReciprocalConditionEstimated_ = true; SolutionRefined_ = true; UpdateFlops(2.0*DN*DN*DNRHS); // Not sure of count EPETRA_CHK_ERR(INFO_); return(0); }
int main(int argc, char **argv) { int NTiles, FromCol, ToCol; setlocale(LC_ALL, ""); switch (argc) { case 1: NTiles = DEFAULTTILES; break; case 2: NTiles = atoi(argv[1]); if (NTiles > MAXTILES || NTiles < MINTILES) { fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES); ExitProgram(EXIT_FAILURE); } break; case 3: if (strcmp(argv[2], "a")) { Usage(); ExitProgram(EXIT_FAILURE); } NTiles = atoi(argv[1]); if (NTiles > MAXTILES || NTiles < MINTILES) { fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES); ExitProgram(EXIT_FAILURE); } AutoFlag = TRUE; break; default: Usage(); ExitProgram(EXIT_FAILURE); } #ifdef TRACE trace(TRACE_MAXIMUM); #endif initscr(); if (has_colors()) { int i; short bg = COLOR_BLACK; start_color(); #if HAVE_USE_DEFAULT_COLORS if (use_default_colors() == OK) bg = -1; #endif for (i = 0; i < 9; i++) init_pair((short) (i + 1), bg, TileColour[i]); } cbreak(); if (LINES < 24) { endwin(); fprintf(stderr, "Min screen length 24 lines\n"); ExitProgram(EXIT_FAILURE); } if (AutoFlag) { curs_set(0); leaveok(stdscr, TRUE); /* Attempt to remove cursor */ } InitTiles(NTiles); DisplayTiles(); if (AutoFlag) { do { noecho(); AutoMove(0, 2, NTiles); } while (!Solved(NTiles)); sleep(2); } else { echo(); for (;;) { if (GetMove(&FromCol, &ToCol)) break; if (InvalidMove(FromCol, ToCol)) { MvAddStr(STATUSLINE, 0, "Invalid Move !!"); refresh(); beep(); continue; } MakeMove(FromCol, ToCol); if (Solved(NTiles)) { MvPrintw(STATUSLINE, 0, "Well Done !! You did it in %d moves", NMoves); refresh(); sleep(5); break; } } } endwin(); ExitProgram(EXIT_SUCCESS); }
int main(int argc, char **argv) { int NTiles, FromCol, ToCol; unsigned char AutoFlag = 0; switch(argc) { case 1: NTiles = DEFAULTTILES; break; case 2: NTiles = atoi(argv[1]); if (NTiles > MAXTILES || NTiles < MINTILES) { fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES); exit(1); } break; case 3: if (strcmp(argv[2], "a")) { Usage(); exit(1); } NTiles = atoi(argv[1]); if (NTiles > MAXTILES || NTiles < MINTILES) { fprintf(stderr, "Range %d to %d\n", MINTILES, MAXTILES); exit(1); } AutoFlag = TRUE; break; default: Usage(); exit(1); } #ifdef NCURSES_VERSION trace(TRACE_MAXIMUM); #endif initscr(); if (!has_colors()) { endwin(); puts("terminal doesn't support color."); exit(1); } start_color(); { int i; for (i = 0; i < 9; i++) init_pair(i+1, COLOR_BLACK, TileColour[i]); } cbreak(); if (LINES < 24) { endwin(); fprintf(stderr, "Min screen length 24 lines\n"); exit(1); } if(AutoFlag) leaveok(stdscr, TRUE); /* Attempt to remove cursor */ InitTiles(NTiles); DisplayTiles(); if(AutoFlag) { do { noecho(); AutoMove(0, 2, NTiles); } while(!Solved(NTiles)); sleep(2); } else { for(;;) { if(GetMove(&FromCol, &ToCol)) break; if(InvalidMove(FromCol, ToCol)) { mvaddstr(STATUSLINE, 0, "Invalid Move !!"); refresh(); beep(); continue; } MakeMove(FromCol, ToCol); if(Solved(NTiles)) { mvprintw(STATUSLINE, 0, "Well Done !! You did it in %d moves", NMoves); refresh(); sleep(5); break; } } } curs_set(1); endwin(); exit(0); }
int main(int argc, char **argv) { int NTiles, FromCol, ToCol,opt; unsigned char AutoFlag = 0; if(argc<2 || argc>3){ Usage();exit(0);} while( (opt=getopt(argc,argv,"a:n:h") )!=-1) switch (opt) { case 'n': NTiles = atoi(optarg); if (NTiles > MAXTILES || NTiles < MINTILES) { fprintf(stderr, "步数从 %d 自 %d之间\n", MINTILES, MAXTILES); return EXIT_FAILURE; } AutoFlag = FALSE; break; case 'a': NTiles = atoi(optarg); if (NTiles > MAXTILES || NTiles < MINTILES) { fprintf(stderr, "步数从 %d 自 %d之间\n", MINTILES, MAXTILES); return EXIT_FAILURE; } AutoFlag = TRUE; break; case 'h': case '?': case ':': Usage(); exit(0); } initscr(); if (has_colors()) { int i; int bg = COLOR_BLACK; start_color(); if (use_default_colors() == OK) bg = -1; for (i = 0; i < 9; i++) init_pair(i + 1, bg, TileColour[i]); } cbreak(); /*LINES和COLS是Curses内部变量,用于存储当前终端的行数和列数*/ if (LINES < 24 || COLS < 80) /*标准的终端为24行80列*/ { endwin(); fprintf(stderr, "当前小于 24x80 \n"); return EXIT_FAILURE; } if (AutoFlag) { curs_set(0); leaveok(stdscr, TRUE); } InitTiles(NTiles); DisplayTiles(); if (AutoFlag) { do { noecho(); AutoMove(0, 2, NTiles); } while (!Solved(NTiles)); sleep(2); } else { echo(); for (;;) { if (GetMove(&FromCol, &ToCol)) break; if (InvalidMove(FromCol, ToCol)) { mvaddstr(STATUSLINE, 0, "移 动 无 效 !!"); refresh(); beep(); sleep(2); continue; } MakeMove(FromCol, ToCol); if (Solved(NTiles)) { mvprintw(STATUSLINE, 0, "恭喜!! 恭喜!! 你用 %d 步赢了", NMoves); refresh(); sleep(5); break; } } } endwin(); return EXIT_SUCCESS; }