diff --git a/benchmarks/bench_translations.py b/benchmarks/bench_translations.py index 8d6cfdd882be3c8bc91f0078e9c1f82cfc1c841c..621ac275d9eb7fcf05763cf5c62d3436dda15e6b 100644 --- a/benchmarks/bench_translations.py +++ b/benchmarks/bench_translations.py @@ -1,13 +1,10 @@ import numpy as np -import pytest -import pyopencl as cl from pyopencl.tools import ( # noqa pytest_generate_tests_for_pyopencl as pytest_generate_tests) from sumpy.expansion.multipole import ( VolumeTaylorMultipoleExpansion, H2DMultipoleExpansion, - VolumeTaylorMultipoleExpansionBase, LaplaceConformingVolumeTaylorMultipoleExpansion, HelmholtzConformingVolumeTaylorMultipoleExpansion) from sumpy.expansion.local import ( @@ -15,13 +12,11 @@ from sumpy.expansion.local import ( LaplaceConformingVolumeTaylorLocalExpansion, HelmholtzConformingVolumeTaylorLocalExpansion) -from sumpy.kernel import (LaplaceKernel, HelmholtzKernel, AxisTargetDerivative, - DirectionalSourceDerivative) +from sumpy.kernel import LaplaceKernel, HelmholtzKernel import logging logger = logging.getLogger(__name__) -import sympy import six import pymbolic.mapper.flop_counter @@ -29,6 +24,7 @@ import sumpy.symbolic as sym from sumpy.assignment_collection import SymbolicAssignmentCollection from sumpy.codegen import to_loopy_insns + class Param: def __init__(self, dim, order): self.dim = dim @@ -125,5 +121,3 @@ class Helmholtz2DTranslation(TranslationBenchmarkSuite): Param(2, 15), Param(2, 20), ] - - diff --git a/contrib/translations/PDE-reduction-symbolic.ipynb b/contrib/translations/PDE-reduction-symbolic.ipynb index bffcdf9e1e24beb09f0da9fbf50bf6d0ecdf1903..3550b0795bbf378f475db47e486472afd1e0ff48 100644 --- a/contrib/translations/PDE-reduction-symbolic.ipynb +++ b/contrib/translations/PDE-reduction-symbolic.ipynb @@ -125,7 +125,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4" + "version": "3.6.5" } }, "nbformat": 4, diff --git a/sumpy/expansion/__init__.py b/sumpy/expansion/__init__.py index 68a99197c991c5630bca8dbf6867e801f1531fc3..a40aafdea675a8ae1469ea24b87455a36ffd4b41 100644 --- a/sumpy/expansion/__init__.py +++ b/sumpy/expansion/__init__.py @@ -400,7 +400,7 @@ class LinearRecurrenceBasedExpansionTermsWrangler(ExpansionTermsWrangler): n = nullspace(pde_mat) idx = self.get_reduced_coeffs() assert len(idx) >= n.shape[1] - s = solve_symbolic(n.T[:,idx], n.T) + s = solve_symbolic(n.T[:, idx], n.T) stored_identifiers = [mis[i] for i in idx] else: s = np.eye(len(mis)) diff --git a/sumpy/tools.py b/sumpy/tools.py index 996f75f08b7812cea060fe018c8fc731e8489449..32d14bcbfcf09f48322ff285d37ba5461b12560d 100644 --- a/sumpy/tools.py +++ b/sumpy/tools.py @@ -657,50 +657,50 @@ def my_syntactic_subs(expr, subst_dict): return expr - def rref(m): - l = np.array(m, dtype=object) + mat = np.array(m, dtype=object) index = 0 - nrows = l.shape[0] - ncols = l.shape[1] + nrows = mat.shape[0] + ncols = mat.shape[1] pivot_cols = [] for i in range(ncols): if index == nrows: break pivot = nrows for k in range(index, nrows): - if l[k, i] != 0 and pivot == nrows: + if mat[k, i] != 0 and pivot == nrows: pivot = k - if abs(l[k, i]) == 1: + if abs(mat[k, i]) == 1: pivot = k break if pivot == nrows: continue if pivot != index: - l[pivot,:], l[index,:] = l[index,:].copy(), l[pivot,:].copy() + mat[[pivot, index], :] = mat[[index, pivot], :] pivot_cols.append(i) - scale = l[index, i] - t = l[index,:]//scale - not_exact = (t * scale != l[index, :]) + scale = mat[index, i] + t = mat[index, :]//scale + not_exact = (t * scale != mat[index, :]) + if (np.any(not_exact)): for j in range(ncols): if not_exact[j]: - t[j] = sym.sympify(l[index, j])/scale + t[j] = sym.sympify(mat[index, j])/scale - l[index,:] = t + mat[index, :] = t for j in range(nrows): if (j == index): continue - scale = l[j, i] + scale = mat[j, i] if scale != 0: - l[j,:] = l[j,:] - l[index,:]*scale + mat[j, :] = mat[j, :] - mat[index, :]*scale index = index + 1 - return l, pivot_cols + return mat, pivot_cols def nullspace(m): @@ -716,17 +716,17 @@ def nullspace(m): vec[free_var] = 1 for piv_row, piv_col in enumerate(pivot_cols): for pos in pivot_cols[piv_row+1:] + [free_var]: - vec[piv_col] -= mat[piv_row,pos] + vec[piv_col] -= mat[piv_row, pos] n.append(vec) return np.array(n, dtype=object).T -def solve_symbolic(A, b): - if isinstance(A, sym.Matrix): - big = A.row_join(b) +def solve_symbolic(a, b): + if isinstance(a, sym.Matrix): + big = a.row_join(b) else: - big = np.hstack((A, b)) + big = np.hstack((a, b)) red = rref(big)[0] - return red[:,big.shape[0]:] + return red[:, big.shape[0]:] # vim: fdm=marker