Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions brainpy/integrators/fde/GL.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,15 @@ def __init__(self, f, alpha, num_memory, inits, dt=None, name=None):
# binomial coefficients
bc = (1 - (1 + self.alpha.reshape((-1, 1))) / jnp.arange(1, num_memory + 1))
bc = jnp.cumprod(jnp.vstack([jnp.ones_like(self.alpha), bc.T]), axis=0)
self.binomial_coef = jnp.flip(bc[1:], axis=0)
self._binomial_coef = jnp.flip(bc[1:], axis=0)

# integral function
self.set_integral(self._integral_func)

@property
def binomial_coef(self):
return bm.as_numpy(jnp.flip(self._binomial_coef, axis=0))

def _integral_func(self, *args, **kwargs):
# format arguments
all_args = format_args(args, kwargs, self.arguments)
Expand All @@ -173,7 +177,7 @@ def _integral_func(self, *args, **kwargs):
integrals = []
idx = (self._idx + bm.arange(self.num_memory)) % self.num_memory
for i, var in enumerate(self.variables):
summation = self.binomial_coef[:, i] @ self.delays[var][idx]
summation = self._binomial_coef[:, i] @ self.delays[var][idx]
integral = (dt ** self.alpha[i]) * devs[var] - summation
self.delays[var][self._idx[0]] = integral
integrals.append(integral)
Expand Down
5 changes: 5 additions & 0 deletions brainpy/integrators/fde/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
from brainpy.errors import UnsupportedError


__all__ = [
'FDEIntegrator'
]


class FDEIntegrator(Integrator):
"""Numerical integrator for fractional differential equations (FEDs).

Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The code of BrainPy is open-sourced at GitHub:
tutorial_toolbox/ode_numerical_solvers
tutorial_toolbox/sde_numerical_solvers
tutorial_toolbox/dde_numerical_solvers
tutorial_toolbox/fde_numerical_solvers
tutorial_toolbox/joint_equations
tutorial_toolbox/synaptic_connections
tutorial_toolbox/synaptic_weights
Expand Down
702 changes: 702 additions & 0 deletions docs/tutorial_toolbox/fde_numerical_solvers.ipynb

Large diffs are not rendered by default.