Assignment 'Getting started'

This assignment is a quick walkthrough based on Ch. 0 from the lecture notes. Read that for more details. All parts below except the last one are optional if you feel you are more than comfortable already with your current account settings.
To boot this year's machines into linux you have to restart them and select Linux in the boot menu. After Linux has successfully been started, you can login using your SOLIS id/password.
Apart from MATLAB usage, most work is done from a terminal. To open a terminal, right click anywhere on the desktop and select open terminal. A screen pops up showing you the default shell, which interprets and executes your keyboard input. One can do a lot from shell, from basic commands like directory listing and navigation (ls ,cd), to running programs (e.g., firefox), running programs in the background (e.g., firefox&), or to do more complex chaining of utilities (like ls *.c | xargs -n 1 gcc -c). There are a lot of online sources on how to efficiently use the shell and command-line Linux utilities.

Use a good shell

Using a good shell saves you a lot of typing. We recommend using bash which should be the default shell on this year's computers. If this is not the case; this shell can be started by simply typing bash and hit enter. If you want bash to become your standard shell, use the chsh command below (notice the backquotes, left of the 1-key):

$ chsh `whoami`
Please enter password:

To accept the default, simply press return.
Login shell [/usr/local/bin/bash]: /bin/bash

Log out of the system and re-logon to make this change active. (Note: actual output of chsh might differ on your current machine.)
Next, open a new terminal and open the (new) file .bashrc in your home directory:

bash-3.00$ nedit ~/.bashrc &

Copy the following line into it. Save and exit.

PS1='\[\033[0;31m\][\u@\h:\w]\$\[\033[0m\] '
In a terminal, issue the following command, and notice how your prompt changes:
bash-3.00$ source ~/.bashrc
[labsc@oeleboeter:~]$

You now have an informative prompt, and a shell in which you can use the arrow-up and -down keys to recall commands you entered before. Also, try to hit [Tab] while typing in your terminal to autocomplete filenames and commands.

Use a good editor

An intuitive, but also powerful editor is gedit. It can be started from a terminal as follows:

[labsc@oeleboeter:~]$ gedit &

Another intuitive text editor is NEdit, play around with both gedit and NEdit to see which editor suits your needs best.

[labsc@oeleboeter:~]$ nedit &

Customize NEdit the first time by making the following settings:

Preferences > Default Settings > Auto Indent > Smart
Preferences > Default Settings > Tab Stops... > Tab spacing: 4
Preferences > Default Settings > Tab Stops... > 'Use Tab characters...' checked
Preferences > Default Settings > Syntax Highlighting > On
Preferences > Default Settings > Statistics Line
Preferences > Default Settings > Show Line Numbers
Preferences > Default Settings > Show Matching (..) > Delimiter

Preferences > Save Defaults

These settings will be active the next time you start NEdit. Good terminal-based editors are vim or emacs. Knowledge of terminal-based editors is very useful if you want to remotely work on a Linux-based server via, for example, ssh.

Organise your files

Put your files in appropriate directories. The following is just a suggestion:

[labsc@oeleboeter:~]$ cd ~
[labsc@oeleboeter:~]$ mkdir labsci
# The two main topics will create their own subdirs.

Software for the first topic

For RNG and Monte Carlo there is already a framework available for the software. Download rngmc.tar.gz and save it into your rng/ directory. Then extract the files from this archive:

[labsc@oeleboeter:~]$ cd labsci
[labsc@oeleboeter:~/labsci]$ tar zxvf rngmc.tar.gz

Now test if the extracted software works:

[labsc@oeleboeter:~/labsci]$ cd rngmc
[labsc@oeleboeter:~/labsci/rngmc]$ make
[labsc@oeleboeter:~/labsci/rngmc]$ ./rand 100
[labsc@oeleboeter:~/labsci/rngmc]$ cat randdata.txt
Note: If you get an error about a missing libgsl or similar, extend the library path as follows:
[labsc@oeleboeter:~/labsci/rngmc]$ LD_LIBRARY_PATH=/usr/local/lib
[labsc@oeleboeter:~/labsci/rngmc]$ export LD_LIBRARY_PATH

You have to extend the library path each shell session (i.e., whenever you start a new shell). As an alternative you can include this commands in the file .bashrc (as appears to have been done for the Unix and the Scientific Linux systems). This file contains the defaults for the bash shell.

What did each of the above steps do? Figure that out, you'll be using them a lot the first few weeks. Note that since we have yet to implement the RNGs themselves, rand will only write zeros to randdata.txt. Have a look at the code in rand.cc, and figure out what is missing in the implementation. The code documentation and appendix C can help understanding the RNG code and class structure easily. At this point, if you are unfamiliar with C or C++, we recommend you at least have a quick look at Section 0.2 of the course book or follow the C++ tutorial. Appendix B may also be useful.

Two-dimensional data

Currently, the rand program writes all generated numbers to a text file with one long column. Later, we will use the numbers to form coordinates, e.g., in 2D. Although one can of course always post-process the data file, it is more intuitive to show the two coordinates of a point together on one line. The function print2file2d contained in the file util.cc does this, but is incomplete. Finish it. (Consult Sec. 0.2.5 if necessary.)
Optionally, make the function even more generic, by adding a numberofcolumns variable that prints the numbers as if they come from 3D, 4D, etc.
Make rand.cc call your new print2file2d function and check if it functions properly.

Visualise

Investigate points in the file you just wrote with the MATLAB function plotpoints. The following will get you started:

[labsc@oeleboeter:~/labsci/rngmc]$ matlab &
Matlab will then start up. When ready, try:
» help plotpoints
This will give a description on how to use the plotpoints function. Remember the help command in case you encounter a new or unfamiliar function in Matlab.

Hand in

You don't have to hand in anything for this assignment.