Download 11.py from TestCaseGeneration/NumFEM_Eval: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/datasets/TestCaseGeneration/NumFEM_Eval/resolve/main/11.py
- Command line
-
hf download hf://datasets/TestCaseGeneration/NumFEM_Eval/11.py
-
curl -L -o 11.py https://huggingface.co/datasets/TestCaseGeneration/NumFEM_Eval/resolve/main/11.py
1.07 kB
| def lobatto_interval(count): | |
| from math import sqrt | |
| from numpy import array | |
| if count <= 2: | |
| p = array([-1.0, 1.0]) | |
| w = array([1.0, 1.0]) | |
| return p, w | |
| elif count == 3: | |
| p = array([-1.0, 0.0, 1.0]) | |
| w = array([1.0 / 3.0, 4.0 / 3.0, 1.0 / 3.0]) | |
| return p, w | |
| elif count == 4: | |
| p = array([-1.0, -1.0 / sqrt(5.0), 1.0 / sqrt(5.0), 1.0]) | |
| w = array([1.0 / 6.0, 5.0 / 6.0, 5.0 / 6.0, 1.0 / 6.0]) | |
| return p, w | |
| else: | |
| p = array([-1.0, -sqrt(3.0 / 7.0), 0.0, sqrt(3.0 / 7.0), 1.0]) | |
| w = array([1.0 / 10.0, 49.0 / 90.0, 32.0 / 45.0, 49.0 / 90.0, 1.0 / 10.0]) | |
| return p, w | |
| def lobatto_quad(order): | |
| from numpy import zeros | |
| (p, w) = lobatto_interval(order) | |
| size = len(p) | |
| xi = zeros(size * size) | |
| eta = zeros(size * size) | |
| weight = zeros(size * size) | |
| for i in range(size): | |
| for j in range(size): | |
| xi[i * size + j] = p[i] | |
| eta[i * size + j] = p[j] | |
| weight[i * size + j] = w[i] * w[j] | |
| return xi, eta, weight |