Skip to content

Commit

Permalink
BIE example for merge conflict, updates reqs
Browse files Browse the repository at this point in the history
  • Loading branch information
fruzsinaagocs committed Dec 4, 2024
1 parent 8224508 commit 796e63c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
41 changes: 41 additions & 0 deletions quadutils/bie.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import numpy as np
import scipt as sp

def Phi(x, y, k = 0.0):
"""
What does this function do?
Parameters
----------
x: np.array<float>
Can have shape (2, n) or (2,). In the latter case, it'll be converted
to (2, 1).
What is this variable?
y: ?
Can have shape (2, m) or (2,). In the latter case, it'll be converted
to (2, 1).
What is this variable?
k: float, optional
Default k = 0. What is this variable?
Returns
-------
phi: ?
What's this variable? What's its shape?
"""
# Reshape input vectors if given in the shape (2,). Skip if (2, n).
if x.ndim < 2:
x = x.reshape((2, -1))
if y.ndim < 2:
y = y.reshape((2, -1))
# Distance vector(s) between pairs of (x, y).
# If x is (2, n), and y is (2, m), d will still be of shape (2, n, m).
d = x[..., None] - y[:, None]
# What are these two cases?
if k == 0.0:
phi = -1/(2*np.pi)*np.log(np.linalg.norm(d, axis = 0))
else:
r = np.linalg.norm(d, axis = 0)
phi = 1j/4*sp.hankel1(0, k*r)
return phi

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
numpy
pytest
scipy
4 changes: 4 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def test_quadroots_1():
def test_chebD_1():
n = 16
D, x = ch.chebD(n)
print(x)
f = lambda x: x**2 # Test function should be differentiated exactly
interval = np.array([0, 0.5])
h = interval[1] - interval[0]
Expand All @@ -22,3 +23,6 @@ def test_chebD_1():
df_num = 2/h*D@f(x_scaled)
df_err = max(np.abs(df_ana(x_scaled) - df_num))
assert df_err < 1e-13

def test_phi_1():
pass

0 comments on commit 796e63c

Please sign in to comment.