From a362090c5a5c13f422385d69ce7f64fa13c09b9f Mon Sep 17 00:00:00 2001 From: Julian T Date: Wed, 5 Feb 2020 21:06:10 +0100 Subject: Added some exercise solutions --- sem4/embedded/m1/int/int.ino | 47 ++++++++++++++++++++++++++ sem4/hpp/m1/opgaver.md | 78 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 sem4/embedded/m1/int/int.ino create mode 100644 sem4/hpp/m1/opgaver.md (limited to 'sem4') diff --git a/sem4/embedded/m1/int/int.ino b/sem4/embedded/m1/int/int.ino new file mode 100644 index 0000000..8978be7 --- /dev/null +++ b/sem4/embedded/m1/int/int.ino @@ -0,0 +1,47 @@ +#define LEDPIN 13 +#define BUTTONPIN 2 + +#define DEBOUNCE 1 + +ISR(INT0_vect) { + static bool state = 0; + + // Toggle LEDPIN + digitalWrite(LEDPIN, state); + state = !state; + + /* + for(long i = 0; i < 1000; i++) { + Serial.print("Hej "); + Serial.println(i); + + } + */ +} + +void setup() { + + // We need to talk + Serial.begin(9600); + + // Setup pinmodes + pinMode(LEDPIN, OUTPUT); + pinMode(BUTTONPIN, INPUT_PULLUP); + + // Attach a interrupt on the button + //attachInterrupt(digitalPinToInterrupt(BUTTONPIN), testy, RISING); + + // Enable interrupt 0 + EIMSK |= 1 << INT0; + // Eable on rising edge + EICRA |= (1 << ISC01) | (1 << ISC00); + +} + +void loop() { + static int i = 0; + + //Serial.print("Cool stuff happening now "); + //Serial.println(i++); + +} diff --git a/sem4/hpp/m1/opgaver.md b/sem4/hpp/m1/opgaver.md new file mode 100644 index 0000000..959eb97 --- /dev/null +++ b/sem4/hpp/m1/opgaver.md @@ -0,0 +1,78 @@ +# Opgave 1.3.1 + +## Del. 2 + +Ud fra matrix vektor muliplication kan man sige at der ganges N^2 gange. + +Også vil man i hver række plus N-1 gang. +Så der plus'ses `(N-1)*N` gange. + +Derfor er der + +`2N^2 - N` + +Floating point operationer. + +## Del. 2 + +Her vil man bruge output buffer som intermediate variabler. + +Derfor vil der være + +``` +A x y +N^2*s + N*s + N*s = (N^2 + 2N) * s +``` + +# Opgave 1.3.3 + +``` +1. + +1 3 5 +2 4 6 + +2. + +1 2 +3 4 +5 6 + +3. + +1 4 +2 5 +3 6 + +4. + +1 2 3 +4 5 6 +``` + +# Opgave 1.3.4 + +## Del 1. + +m er row count B + +A * B = C + +``` +for column c in B index i: + for row r in A index j: + i = c' * r // ' means transponere + C[j,c] = sum(i) + end +end +``` + +# Del 2. + +A bliver addresset via kolonner, så det er bedst at bruge column major. + +B bliver via rows så det er bedst at bruge row major. + +# Del 3. +Yes because we multiply vektors together. + -- cgit v1.2.3