====================================== | # | homework | A | B | C | Σ | ====================================== | 1 | LinEq | 6 | 3 | 1 | 10 | --------------------------------------- | 2 | EVD | 6 | - | - | 6 | --------------------------------------- | 3 | LeastSquares | 6 | 3 | - | 9 | --------------------------------------- | ... | ====================================== | total points: 95 | ======================================
Introduction.
• About the course; exercises/homeworks; code repositories; examination.
• POSIX
(UNIX) systems [→];
supercomputers and clusters
[top500 supercomuters,
CSCAA].
• The Computer Language Benchmarks Game
[→]
(summary
[→]).
• We shall only use "open software" in this course
[Free software].
⊕ Exercise "posix".
Code repositories. Makefiles.
* Distributed Version Control[→]
systems and code repositories; Mercurial[→] (hg)
and Git[→] (git);
* POSIX make utility[→]
for managing projects on a computer.
* C-sharp[→]
mono[→]
framework for POSIX programming.
+ Reading:
note "make",
introduction to Git from Atlassian[→].
+ Exercises:
"git",
"hello";
- Extra reading: Chapter
"Introduction To Makefiles"[→]
in the "GNU make manual";
- Extra extra reading: Chapter
"make - maintain, update, and regenerate groups of programs",
of the POSIX standard.
+ Quiz:
!string" do?
!number" do?
echo",
"time", and
"date"
do?
echo" and
"time"
programs or shell commands?
You might want to install additional man-pages with the command
sudo apt-get install manpages-posix manpages-posix-dev
int
double
string
complex;
Scope of variables; Variable shadowing.
System.Console.Write method.
System.Math class.
$@ (the target),
$< (the first prerequisite),
$^ (all prerequisites).
System.Math class[→].
the System.Console.Write method[→] method for simple output.
$@,
$<,
$^?
$(filter %.cs,$^) ?
$(addprefix -reference:,$(filter %.dll,$^)) ?
echo '$HOME' echo "$HOME" echo '"$HOME"' echo "'$HOME'" echo `pwd`
if else;
Loops for, while, do while;
Loop foreach;
for(init;condition;increment)body"
using the while-loop.
while(condition)body" using
the for-loop.
do body while(condition)" using
the while-loop.
(condition?iftrue:iffalse)",
using the "if" statement.
Hint: google "ternary conditional".
WriteLine($"x={x:e16}");
(try google "c# standard numeric format").
WriteLine( 0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1 == 8*0.1 );Why does it produce "false" result ?
WriteLine( 0.125+0.125+0.125+0.125+0.125+0.125+0.125+0.125 == 8*0.125 );Why does this one produce "true" result?
System.Console.Out and
System.Console.In?
Main(string[]
args)"
function after the command
mono main.exe -input:in.txt -output:out.txt -numbers:1e0,2e0,3e0
getconf ARG_MAX" and/or (if you use GNU)
"echo|xargs --show-limits".
`command` and
$(command) in bash. Hint:
Bash
command substitution; POSIX
shell command substitution.
$$(command), in the Makefile? Hint:
GNU make: variables in
recipes.
pwd = a random string test: @echo pwd @echo `pwd` @echo $(pwd) @echo $$(pwd)
More C-sharp: generics; delegates; closures.
* C-sharp generics;
* Passing functions around: delegates, anonymous delegates, closures;
+ Reading:
note "generics";
note "delegates";
+ Exercise "generic list";
complex.
- Extra reading:
C-sharp generics[→];
C-sharp delegates[→];
System.Func delegate[→];
Closures in computer programming[→];
+ Quiz:
static void set_arg_to_seven(double x){ x=7; }
Is the argument variable set to seven in the caller's scope (in the
scope where the function is called)?
Explain.
static void set_arg_to_seven(double[] xs){
for(int i=0;i<xs.Length;i++)xs[i]=7; }
Are the elements of the argument array set to seven in the caller's scope?
Explain.
static void set_to_seven(double[] xs){
xs = new double[xs.Length];
for(int i=0;i<xs.Length;i++)xs[i]=7;
}
Are the elements of the argument array set to seven in the caller's scope?
Explain.
static void set_arg_to_seven(ref double x){ x=7; }
Is the argument variable set to seven in the caller's scope?
Hint: google "csharp call by reference".
int.MaxValue" equal to "2³¹-1"?
Suppose you've got the following Makefile,
T1 := target: $@ T2 = target: $@ test: @echo $(T1) @echo $(T2)what will it print and why?
make --jobs[=4];
Suppose you calculate the harmonic sum using system's
"Parallel.For"[→]
loop like this,
double sum=0;
System.Threading.Tasks.Parallel.For(1,N+1,delegate(int i){sum+=1.0/i;});
why does it run slower (and produces wrong (and somewhat random) results)
than the ordinary serial loop,
double sum=0;
for(int i=1; i<N+1; i++) {sum+=1.0/i;}
despite using more processors? (It does so in my box).