How to display progress of scipy.optimize function?

As mg007 suggested, some of the scipy.optimize routines allow for a callback function (unfortunately leastsq does not permit this at the moment). Below is an example using the “fmin_bfgs” routine where I use a callback function to display the current value of the arguments and the value of the objective function at each iteration. import … Read more

How to position the input text cursor in C?

If you are under some Unix terminal (xterm, gnome-terminal …), you can use console codes: #include <stdio.h> #define clear() printf(“\033[H\033[J”) #define gotoxy(x,y) printf(“\033[%d;%dH”, (y), (x)) int main(void) { int number; clear(); printf( “Enter your number in the box below\n” “+—————–+\n” “| |\n” “+—————–+\n” ); gotoxy(2, 3); scanf(“%d”, &number); return 0; } Or using Box-drawing characters: … Read more

Visual Studio 2012 C++ Standard Output

If your program is linked with /SUBSYSTEM:WINDOWS you will not see the console output unless you allocate a console. Here is code for the allocate console option. With this method you should not need to change your linker settings or create a WinMain. static void OpenConsole() { int outHandle, errHandle, inHandle; FILE *outFile, *errFile, *inFile; … Read more