Skip to content

Commit

Permalink
Add examples using operators.
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelburbulla committed Feb 16, 2024
1 parent 1b98f06 commit 760ff53
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/continuity/pde/grad.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ def forward(self, x: Tensor, u: Tensor, y: Optional[Tensor] = None) -> Tensor:
def grad(u: Callable[[Tensor], Tensor]) -> Callable[[Tensor], Tensor]:
"""Compute the gradient of a function.
Example:
Computing the gradient of the output function of an operator:
```python
v = lambda y: operator(x, u, y)
g = grad(v)(y)
```
Args:
u: Function to compute the gradient of.
Expand Down Expand Up @@ -92,6 +99,13 @@ def forward(self, x: Tensor, u: Tensor, y: Optional[Tensor] = None) -> Tensor:
def div(u: Callable[[Tensor], Tensor]) -> Callable[[Tensor], Tensor]:
"""Compute the divergence of a function.
Example:
Computing the divergence of the output function of an operator:
```python
v = lambda y: operator(x, u, y)
d = div(v)(y)
```
Args:
u: Function to compute the divergence of.
Expand Down

0 comments on commit 760ff53

Please sign in to comment.