diff --git a/semester3/numcs/numcs-summary.pdf b/semester3/numcs/numcs-summary.pdf index 85db7ad..2dc3d2c 100644 Binary files a/semester3/numcs/numcs-summary.pdf and b/semester3/numcs/numcs-summary.pdf differ diff --git a/semester3/numcs/parts/00_introduction/02_matrix-multiplication.tex b/semester3/numcs/parts/00_introduction/02_matrix-multiplication.tex index 48eaa8d..4a28269 100644 --- a/semester3/numcs/parts/00_introduction/02_matrix-multiplication.tex +++ b/semester3/numcs/parts/00_introduction/02_matrix-multiplication.tex @@ -104,7 +104,7 @@ def fast_kron_vector_product(A: np.ndarray, B: np.ndarray, x: np.ndarray): # This will actually crash if x.shape[0] is not divisible by A.shape[0] bx = B * x.reshape(A.shape[0], round(x.shape[0] / A.shape[0])) # Then multiply a with the resulting vector - y = A * bx + y = A @ bx \end{code} Um die oben erwähnte Laufzeit zu erreichen muss erst ein neuer Vektor berechnet werden, oben im Code \verb|bx| genannt, der eine Multiplikation von \verb|Bx_i| als Einträge hat. diff --git a/semester3/numcs/parts/01_interpolation/00_polynomial/03_lagrange-and-barzycentric-formula.tex b/semester3/numcs/parts/01_interpolation/00_polynomial/03_lagrange-and-barzycentric-formula.tex index 5d3304a..aeb8f45 100644 --- a/semester3/numcs/parts/01_interpolation/00_polynomial/03_lagrange-and-barzycentric-formula.tex +++ b/semester3/numcs/parts/01_interpolation/00_polynomial/03_lagrange-and-barzycentric-formula.tex @@ -58,7 +58,6 @@ oder das ganze mithilfe von Numpy: for k in range(n): # Vectorized differences between $x_k$ and all $x$s differences = x[k] - x - # Remove the $k$-th element (and handle edge cases for $k = 0$ and $k = n - 1$) if k < n - 1 and k > 0: diff_processed = np.concatenate((differences[:k], differences[(k + 1) :])) @@ -70,6 +69,20 @@ oder das ganze mithilfe von Numpy: return barweight \end{code} +Gleiche funktion, etwas kürzer: + +\begin{code}{python} + def barycentric_weights(x: np.ndarray) -> np.ndarray: + n = len(x) + w = np.ones(n) # = barweight + # Compute the (non-inverted) product, avoiding case (x[i] - x[i]) = 0 + for i in range(0, n, 1): + if (i-1 > 0): w[0:(i-1)] *= (x[0:(i-1)] - x[i]) + if (i+1 < n): w[i+1:n] *= (x[i+1:n] - x[i]) + # Invert all at once + return 1/w +\end{code} + Mit dem können wir dann ein Polynom mit der baryzentrischen Interpolationsformel interpolieren: \setcounter{numberingConfig}{0} \begin{formula}[]{Baryzentrische Interpolationsformel} @@ -94,17 +107,6 @@ Eine weitere Anwendung der Formel ist als Ausganspunkt für die Spektralmethode barweight: np.ndarray, x: np.ndarray ): - """Compute an Interpolation polynomial p(x) using the barycentric interpolation formula - - Args: - data_point_x: The data points' x-coordinate from which to interpolate (Stützstellen) - data_point_y: The data points' y-coordinates (Stützwerte) - barweight: Barycentric weights - x: The argument of the polynomial (the x in p(x)) - - Returns: - The Interpolation polynomial evaluated at each x - """ p_x = np.zeros_like(x) n = data_point_x.shape[0] diff --git a/semester3/numcs/parts/01_interpolation/01_trigonometric/01_dft.tex b/semester3/numcs/parts/01_interpolation/01_trigonometric/01_dft.tex index 467d063..510568c 100644 --- a/semester3/numcs/parts/01_interpolation/01_trigonometric/01_dft.tex +++ b/semester3/numcs/parts/01_interpolation/01_trigonometric/01_dft.tex @@ -1,7 +1,10 @@ \subsection{Diskrete Fourier Transformation} % NOTE: I'll do these 2 subchapters. Based on the lecture, we can leave out quite a lot here. -Lecture: 3.2.1 eigentlich nur Endergebnis wichtig. 3.2.2 viel anschaulicher und theo. Grundlage für Anwendung. 3.2.3 zeigt kurz code. +% Lecture: 3.2.1 eigentlich nur Endergebnis wichtig. 3.2.2 viel anschaulicher und theo. Grundlage für Anwendung. 3.2.3 zeigt kurz code. % 1/sqrt(N) ist numerisch sehr schwer, d.h. wenn möglich nie nutzen. (d.h. ist bem 3.2.8 genau so definiert) -% Bsp. 3.2.23 wichtig: zeigt anschaulich wieso DFT genial ist. -% NOTE: script p.74 sum transformation has errors. he said he'll fix. \ No newline at end of file +% Viele gute Bsps in 2.3.3, würde ich aber nicht hier übernehmen +% NOTE: script p.74 sum transformation has errors. he said he'll fix. + +% 2.3.4 relativ wichtig (Einführung Faltungen), tendenziell viel +% 2.4 FFT wichtig, aber kurz