This repository contains programs in C/C++. The C/C++ source code can be compiled from the command line or from an IDE such as Eclipse CDT. Gnuplot is the tool used to plot the output of the programs.
The GNU g++ (or gcc) compiler for C and C++ is installed by default on any Linux OS and it can be used from the command line. For the MS Windows OS the Cygwin Project provides a Linux environment with the GNU C/C++ compilers.
To compile a C source file you can use the GNU gcc compiler (or the cc compiler for C programs)
$ gcc HelloWorld.c
The output of the compilation by default is an executable file a.exe. In order to name the executable file like the source code you can use the command
$ gcc HelloWorld.c -o HelloWorld
C++ source code can be compiled using the GNU g++ compiler.
To execute a program, HelloWorld.exe for instance, use the command
$ ./HelloWorld.exe
or simply
$ ./HelloWorld
The main problem about developing using a text editor is that it is difficult to use a debugger. The GNU GDB debugger can be used with the command line (see ref.4) but you may be used to an IDE such as Eclipse, the Java IDE, that can be used to develop C/C++ application as well. One needs to install Java in order to execute the IDE, then the compiler and the debugger. In Eclipse CDT an executable is created in a project that includes all the required C or C++ files, one of which contains the main() function. If a main() function is defined in more than a file in the same project the IDE will raise an error of "multiple definitions of main". For this reason in Eclipse CDT each file containing a main() function should be in a separate project.
In this section are reported some simulations performed using the code in this repository. The details of each application are presented in a separate page with a link to the source code.
Random walk on a square lattice
Most of the software is taken from the following books:
- Kernighan, Ritchie - The C Programming Language, 2nd Ed
- Barone, Marinari, Organtini, Ricci-Tersenghi - Scientific Programming
- Gnuplotting, scientific plots using gnuplot
- Hartmann et al. - A practical guide to computer simulations
- Goldberg - What every computer scientist should know about floating-point arithmetic