Du befindest dich hier: FSI Informatik » Prüfungsfragen und Altklausuren » Prüfungen im Bachelor-Studium (1. - 5. Semester) » algoks » Forendiskussionen (Übersicht)
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
Nächste Überarbeitung | Vorherige Überarbeitung | ||
pruefungen:bachelor:algoks:loesungws12 [07.02.2014 13:24] – angelegt Dawodo | pruefungen:bachelor:algoks:loesungws12 [11.02.2017 11:26] (aktuell) – soeren563 | ||
---|---|---|---|
Zeile 82: | Zeile 82: | ||
**a)** | **a)** | ||
- | x = (-1, 2, -1, 2)^T | + | x = (1, 2, -1, 2)^T |
**b)** | **b)** | ||
Zeile 116: | Zeile 116: | ||
**c)** | **c)** | ||
- | s_0 = (-4, 2)^T \\ | + | s_0 = (-4, -2)^T \\ |
t_0 = 1/2 \\ | t_0 = 1/2 \\ | ||
x_1 = (-1, 0)^T | x_1 = (-1, 0)^T | ||
Zeile 123: | Zeile 123: | ||
< | < | ||
- | |x_i+1 - x*| <= c * |x_i - x*| | + | |x_i+1 - x*| <= c * |x_i - x*| , wobei 0<c<1 |
</ | </ | ||
Zeile 171: | Zeile 171: | ||
< | < | ||
l(x) = {3/2x + 1/2 für -1 <= x < 1 | l(x) = {3/2x + 1/2 für -1 <= x < 1 | ||
- | | + | |
</ | </ | ||
**c)** | **c)** | ||
- | ... | + | l_0: 1/6 * (x-1)(x-2) \\ |
+ | l_1: -1/2 * (x+1)(x-2) \\ | ||
+ | l_2: 1/3 * (x+1)(x-1) \\ | ||
+ | |||
+ | L(x) = y_0 * l_0(x) + y_1 * l_1(x) + y_2 * l_2(x) | ||
**d)** | **d)** | ||
Zeile 184: | Zeile 188: | ||
n_2(x) = (x + 1) * (x - 1) | n_2(x) = (x + 1) * (x - 1) | ||
- | a_0 = 3/2 \\ | + | a_0 = -1 \\ |
- | a_1 = 1/6 | + | a_1 = 3/2 \\ |
+ | a_2 = 1/6 | ||
==== Aufgabe 9 - Programmierung: | ==== Aufgabe 9 - Programmierung: | ||
Zeile 195: | Zeile 200: | ||
float f_t = (1-s) * m_t0.f(t) + s * m_t1.f(t); | float f_t = (1-s) * m_t0.f(t) + s * m_t1.f(t); | ||
float f_s = (1-t) * m_s0.f(s) + t * m_s1.f(s); | float f_s = (1-t) * m_s0.f(s) + t * m_s1.f(s); | ||
- | float f_st = (1-t) * (1-s) * m_t0.f(0) + (1-s) * t * m_s1.f(0) + | + | float f_st = (1-t) * (1-s) * m_t0.f(0) + (1-s) * t * m_t0.f(1) + |
(1-t) * s * m_t1.f(0) + t * s * m_t1.f(1); | (1-t) * s * m_t1.f(0) + t * s * m_t1.f(1); | ||
Zeile 208: | Zeile 213: | ||
float f_t = (-1) * m_t0.f(t) + m_t1.f(t); | float f_t = (-1) * m_t0.f(t) + m_t1.f(t); | ||
float f_s = (1-t) * m_s0.d(s) + t * m_s1.d(s); | float f_s = (1-t) * m_s0.d(s) + t * m_s1.d(s); | ||
- | float f_st = (1-t) * (-1) * m_t0.f(0) + (-1) * t * m_s1.f(0) + | + | float f_st = (1-t) * (-1) * m_t0.f(0) + (-1) * t * m_t0.f(1) + |
(1-t) * m_t1.f(0) + t * m_t1.f(1); | (1-t) * m_t1.f(0) + t * m_t1.f(1); | ||
Zeile 234: | Zeile 239: | ||
<code cpp> | <code cpp> | ||
float CCSMatrix:: | float CCSMatrix:: | ||
- | for(int | + | for(int |
- | if(_rowIndices[rowP] == i) | + | if(_rowIndices[colP] == i) |
- | return _values[rowP]; | + | return _values[colP]; |
} | } | ||
Zeile 243: | Zeile 248: | ||
</ | </ | ||
- | **b)** | + | **c)** |
<code cpp> | <code cpp> | ||
Zeile 252: | Zeile 257: | ||
_values = new float[_nonZeroElements]; | _values = new float[_nonZeroElements]; | ||
_rowIndices = new int[_nonZeroElements]; | _rowIndices = new int[_nonZeroElements]; | ||
- | _colPtr = new int[width + 1]; | + | _colPtr = new int[_width |
int t = 0; | int t = 0; | ||
+ | _colPtr[0] = 0; | ||
for(int c = 0; c < _width; c++) { | for(int c = 0; c < _width; c++) { | ||
Zeile 261: | Zeile 267: | ||
if(el != 0) { | if(el != 0) { | ||
_values[t] = elem; | _values[t] = elem; | ||
- | _rowIndives[t] = r; | + | _rowIndices[t] = r; |
t++; | t++; | ||
} | } | ||
} | } | ||
- | _colPtr[c] = t; | + | _colPtr[c+1] = t; |
} | } | ||
} | } | ||
</ | </ | ||
- | **b)** | + | **d)** |
<code cpp> | <code cpp> | ||
Zeile 280: | Zeile 286: | ||
float sum = 0.0f; | float sum = 0.0f; | ||
- | for(int | + | for(int |
- | float v = other._values[rowP]; | + | float v = other._values[colP]; |
- | sum += v * getEntry(r, other._rowIndices[rowP]); | + | sum += v * getEntry(r, other._rowIndices[colP]); |
} | } | ||
result.setEntry(r, | result.setEntry(r, | ||
- | if(sum == 0) { | + | |
- | result._nonZeroElements++; | + | |
- | + | ||
} | } | ||
} | } | ||
} | } | ||
</ | </ |