/* **** This test is designed to test the validity of the Evaluate member of the PolyFit class **** This particular test only involves using Evaluate for a gpstk::Vectors of data with **** a blank, singular, and a normal PolyFit. **** The Evaluate is tested by using the solution to a + b*x = d */ void xPolyFit :: evalTestVector (void) { gpstk::PolyFit<double> Blank; gpstk::PolyFit<double> Single(2); gpstk::PolyFit<double> Eval(2); gpstk::Vector<double> SData(4,0.); SData[0] = 1.; SData[1] = 1.; SData[2] = 1.; SData[3] = 1.; gpstk::Vector<double> STime(4,0.); STime[0] = 0.; STime[1] = 0.; STime[2] = 0.; STime[3] = 1.; gpstk::Vector<double> EData(4,0.); EData[0] = 0.; EData[1] = 2.; EData[2] = 4.; EData[3] = -1.; gpstk::Vector<double> ETime(4,0.); ETime[0] = 3.; ETime[1] = 3.; ETime[2] = 4.; ETime[3] = 2.; Single.Add(STime,SData); Eval.Add(ETime,EData); gpstk::Vector<double> EvalSolution = Eval.Solution(); CPPUNIT_ASSERT_EQUAL(0.,Blank.Evaluate(3.)); CPPUNIT_ASSERT_EQUAL(0.,Single.Evaluate(10.)); CPPUNIT_ASSERT_DOUBLES_EQUAL(EvalSolution[0]+3.*EvalSolution[1], Eval.Evaluate(3.),1e-6); }
void RunShell() { int running = 1; char* str; char** argv; InitBackgroundProcessing(); while (running) { CheckProcessQueue(); PrintPrompt(); str = ReadInput(); argv = ParseInput(str); if (argv[0] == NULL) { // do nothing if empty arguments } else if (CheckForIOandPipeErrors(argv)) { // do nothing if IO or pipe error } else if (CheckForBackgroundErrors(argv)) { // do nothing if background processing format error } else if (strcmp(argv[0], "exit") == 0) { BigFree(argv); printf("Exiting Shell...\n"); OnExitProcessQueueWait(); exit(0); } else if (strcmp(argv[0], "cd") == 0) { if (ArraySize(argv) <= 2) { if (ArraySize(argv) == 2) ChangeDirectory(argv[1]); else ChangeDirectory(getenv("HOME")); } else { printf("Too many arguments...\n"); } } else if (strcmp(argv[0], "limits") == 0) { if (ArraySize(argv) > 1) { argv = ArrayRemoveElement(argv, 0); Limits(argv); } } else if (strcmp(argv[0], "etime") == 0) { if (ArraySize(argv) > 1) { argv = ArrayRemoveElement(argv, 0); ETime(argv); } } else if (IsExecutable(argv[0])) { int background = VecContainsStr(argv, "&"); int I_loc = VecContainsStr(argv, "<"); int O_loc = VecContainsStr(argv, ">"); int pipe_count = ArgvCountSymbol(argv, "|"); if (I_loc != -1) { argv = ExecuteExternalWithInput(argv, I_loc, background); } else if (O_loc != -1) { argv = ExecuteExternalWithOutput(argv, O_loc, background); } else if (pipe_count > 0) { argv = ExecuteExternalWithPipe(argv, pipe_count, background); } else { char* cmd = ArgvToString(argv); if (background != -1) { argv = ArrayRemoveElement(argv, background); } ExecuteExternal(argv, background, cmd); free(cmd); } } BigFree(argv); } }