Skip to content
Snippets Groups Projects
Commit 685f614a authored by Laura Christine Kühle's avatar Laura Christine Kühle
Browse files

Vectorized 'calculate_approximate_solution()'.

parent 1060e1eb
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@
from typing import Tuple
import numpy as np
from numpy import ndarray
from sympy import Symbol
from sympy import Symbol, lambdify
from .Mesh import Mesh
from .Quadrature import Quadrature
......@@ -39,18 +39,17 @@ def calculate_approximate_solution(
Array containing approximate evaluation of a function.
"""
num_points = len(points)
basis_matrix = [[basis[degree].subs(x, points[point])
for point in range(num_points)]
for point in range(len(points))]
for degree in range(polynomial_degree+1)]
approx = [[sum(projection[degree][cell] * basis_matrix[degree][point]
for degree in range(polynomial_degree+1))
for point in range(num_points)]
for cell in range(len(projection[0]))]
# basis = np.array([np.vectorize(lambdify(x, function, 'numpy'))
# for function in basis])
# basis_matrix = np.array([basis[degree](np.array(points)) for degree in
# range(polynomial_degree+1)])
return np.reshape(np.array(approx), (1, len(approx) * num_points))
approx = projection.T@basis_matrix
return np.reshape(approx, (1, approx.size))
def calculate_exact_solution(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment