How to run C# code?
Recently, I have received many questions on how one can run the C# codes to replicate my research results and to extend them to other applications. While C# makes the computations very efficient, it is not the most friendly language for the end users, especially for the ones that have little experience with programming. Nevertheless, the overall process is quite simple and I outline it below. It should work for any OS.C# programming language is set of commands and structures which make the algorithms intuitive and understandable for humans. Although it is low-level, meaning that its operations are very closely linked to the core computer architecture, the machines cannot understand them instantly. To make the C# programs understandable for your computer, you will need to compile them.
There are multiple C# compilers available, some of them even available online. I typically use the GCC compiler (gcc.gnu.org). It is cross-platform and is very well documented. After you download and install the compiler, you are just a step away from running the C# programs.
Suppose you wish to run the 3-variate sharpened Diks-Wolski test. Firstly, download the
dp3_gaussian.ccode from marcinwolski.org/codes/, and save it to some directory, say
C:\codes. Secondly, open either terminal on Mac OS, or command line prompt on Windows (in Start menu type
cmdand hit enter). Navigate to your directory as
cd C:\codesThirdly, compile the program by typing
gcc dp3_gaussian.c -o dp3_gaussian -lmFlag
-ogives the output file and
-lmtell the compiler to use some of the mathematical libraries, which are sometimes given by default. If you see no errors, you may run the executable file, which was created by the compiler, as
./dp3_gaussianOn Windows you may need to drop the two escape characters at the beginning and simply execute
dp3_gaussianOn the other hand, if you get compilation errors, read them carefully and try to address the problems being mentioned. Typically they will have to do with wrong paths, file names or permissions in the directory.