#include "header.h" int main(void) { double timer[3]={0.0,0.0,0.0};//Stores the total times for f, df, and ddf individually. flagbox3 computeflags;//Accepted from standard in; do we actually bother to compute f, df, ddf? 1 if yes. if (THISISPROGRAM11) {computeflags.f0=1;computeflags.f1=0;computeflags.f2=0;} flagbox3 printflags; //Note: computeflags must be set to even reach the related printflags printflags.f0=1;//PRINT THE RESULT if 1 printflags.f1=1;//PRINT THE GRADIANT VECTOR if 1 printflags.f2=1;//PRINT THE HESSIAN MATRIX if 1 if (THISISPROGRAM11) {printflags.f0=1;printflags.f1=0;printflags.f2=0;} //PLEASE NOTICE THESE FLAGS //THEY WERE ASKED FOR IN THE SPECIFICATIONS //FOR SOME CONTROL PURPOSE //THAT I DON'T REALLY UNDERSTAND THAT WELL //SORRY //They control how it returns the results //Really, poking the computeflags would be more productive. flagbox3 modeflags; modeflags.f0=1;//Return the funk count for f in the returned flagbox3 modeflags.f1=1;//Return the funk count for df in the returned flagbox3 modeflags.f2=1;//Return the funk count for ddf in the returned flagbox3 if (THISISPROGRAM11) {modeflags.f0=1;modeflags.f1=0;modeflags.f2=0;} flagbox3 currentTallies;//Holds funk tallies; hence passed in by address. currentTallies.f0=0;//Holds current tallies for the funk calls for f. currentTallies.f1=0;//Holds current tallies for the funk calls for df. currentTallies.f2=0;//Holds current tallies for the funk calls for ddf. int individualtally=0;//If 1, will refresh the funk counts and timing counts for each new vector. vector inputvec; //A vector, to be passed about. while (feof(stdin)==0) //While we haven't exhausted the input stream { parseinput(&computeflags, &inputvec); //Get the first three inputs processinput(computeflags,&inputvec,timer,printflags, modeflags, ¤tTallies); //Process if asked to, update the tallies and time, print if asked to. scanf("\n");//Deal with the pesky newline. if(individualtally)//If we want timing for each vector { printoutput(computeflags,timer,currentTallies); //Prints the time and tallies, as asked. timer[0]=timer[1]=timer[2]=0.0;//Reset the timers. currentTallies.f0=0;//Reset the current tallies currentTallies.f1=0; currentTallies.f2=0; } destroyvec(&inputvec);//Free the memory of the input. } if(!individualtally)//If not individually, print the grand total {printoutput(computeflags,timer,currentTallies);} //Prints the time and tallies, as asked to by computeflags. return 0;//Exiting now. }