Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable MathJax for documentation #726

Merged
merged 3 commits into from
May 28, 2024
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
18 changes: 11 additions & 7 deletions doc/DaphneDSL/Builtins.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ DaphneDSL's built-in functions can be categorized as follows:

- **`sample`**`(range:scalar, size:size, withReplacement:bool, seed:si64)`

Generates a *(`size` x 1)* column-matrix of values drawn from the range *[0, `range` - 1]*.
Generates a *(`size` x 1)* column-matrix of values drawn from the range *[0, `range - 1`]*.
The parameter `withReplacement` determines if a value can be drawn multiple times (`true`) or not (`false`).
The `seed` can be set to `-1` (randomly chooses a seed), or be provided explicitly to enable reproducible random values.

Expand Down Expand Up @@ -121,6 +121,7 @@ The following built-in functions all follow the same scheme:
### Trigonometric/Hyperbolic

`arg` unit must be radians (conversion: $x^\circ * \frac{\pi}{180^\circ} = y$ radians)

| function | meaning |
| ----- | ----- |
| **`sin`** | sine |
Expand All @@ -129,9 +130,9 @@ The following built-in functions all follow the same scheme:
| **`asin`** | arc sine (inverse of sine) |
| **`acos`** | arc cosine (inverse of cosine) |
| **`atan`** | arc tangent (inverse of tangent) |
| **`sinh`** | hyperbolic sine ($\frac{e^\text{arg}-e^\text{ - arg}}{2}$) |
| **`cosh`** | hyperbolic cosine ($\frac{e^\text{arg}+e^\text{ - arg}}{2}$) |
| **`tanh`** | hyperbolic tangent ($\frac{\text{sinh arg}}{\text{cosh arg}}$) |
| **`sinh`** | hyperbolic sine $\left( \frac{\exp(\text{arg}) \, - \, \exp(\text{ - arg})}{2} \right)$ |
| **`cosh`** | hyperbolic cosine $\left( \frac{\exp(\text{arg}) \, + \, \exp(\text{ - arg})}{2} \right)$ |
| **`tanh`** | hyperbolic tangent $\left( \frac{\text{sinh arg}}{\text{cosh arg}} \right)$ |

### Rounding

Expand Down Expand Up @@ -401,12 +402,14 @@ Note that most of these operations only have a CUDNN-based kernel for GPU execut

Returns the contingency table of two *(n x 1)* column-matrices `ys` and `xs`.
The resulting matrix `res` consists of `max(ys) + 1` rows and `max(xs) + 1` columns.
More precisely, *`res[x, y]` = |{ k | `ys[k, 0]` = y and `xs[k, 0]` = x, 0 ≤ k ≤ n-1 }| * `weight`*.
More precisely,
$\text{res}[x, y] = \left| \{ k \bigm| \text{ys}[k, 0] = y \wedge \text{xs}[k, 0] = x, \; 0 \leq k \leq n-1 \} \right| * \text{weight} \quad \forall x \in \text{xs}, y \in \text{ys}$.

In other words, starting with an all-zero result matrix, `ys` and `xs` can be thought of as lists of `y`/`x`-coordinates which indicate the result matrix's cells whose value shall be increased by `weight`.
In other words, starting with an all-zero result matrix, all pairs of values $\{ (\text{xs}[k, 0],\text{ys}[k, 0]) \mid 0 \leq k \leq n-1 \}$
are used to index the result matrix and increase the corresponding value by `weight`.
Note that `ys` and `xs` must not contain negative numbers.

The scalar weight is an optional argument and defaults to 1.0.
The scalar weight is an optional argument and defaults to `1.0`.
The weight also determines the value type of the result.

Moreover, optionally, the result shape in terms of the number of rows and columns can be specified.
Expand Down Expand Up @@ -566,6 +569,7 @@ These must be provided in a separate [`.meta`-file](/doc/FileMetaDataFormat.md).
That way, only point predicates are possible on the encoded output.

There are two results:

- The first result is the encoded data, a *(n x 1)* matrix of the codes for each element in the input `arg`.
- The second result is the decoding dictionary, a *(#distinct(`arg`) x 1)* matrix of the distinct values in `arg`.
The value at position *i* is the value that is mapped to the code *i*.
Expand Down
2 changes: 1 addition & 1 deletion doc/DaphneDSL/LanguageRef.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ So far, this is only supported for addressing columns of frames.
This is not supported for addressing columns of frames yet.

For each row/column, a single zero/one entry ("bit") must be provided.
More precisely, a (*r x 1*) matrix is required on data objects with *r* rows, and a (*c x 1*) matrix is required on data objects with *c* columns.
More precisely, a (*n x 1*) matrix is required on data objects with *n* rows, and a (*m x 1*) matrix is required on data objects with *m* columns.
Only the rows/columns with a corresponding 1-value in the bit vector are present in the result.

Note that double square brackets (`[[...]]`) must be used to distinguish indexing by bit vector from indexing by an arbitrary sequence of positions.
Expand Down
2 changes: 1 addition & 1 deletion doc/DaphneLib/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Users can easily mix and match DAPHNE computations with other Python libraries a

## Introductory Example

The following simple example script generates a *5x3* matrix of random values in *[0, 1)* using numpy, imports the data to DAPHNE, and shifts and scales the data such that each column has a mean of *0* and a standard deviation of *1*.
The following simple example script generates a *5x3* matrix of random values in $[0, 1)$ using numpy, imports the data to DAPHNE, and shifts and scales the data such that each column has a mean of *0* and a standard deviation of *1*.

```python
# (1) Import DaphneLib.
Expand Down
12 changes: 12 additions & 0 deletions doc/javascripts/mathjax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
window.MathJax = {
tex: {
inlineMath: [["\\(", "\\)"]],
displayMath: [["\\[", "\\]"]],
processEscapes: true,
processEnvironments: true
},
options: {
ignoreHtmlClass: ".*|",
processHtmlClass: "arithmatex"
}
};
6 changes: 6 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ theme:
- navigation.tabs
- navigation.tabs.sticky
markdown_extensions:
- pymdownx.arithmatex:
generic: true
- pymdownx.highlight:
anchor_linenums: true
- pymdownx.inlinehilite
Expand All @@ -35,6 +37,10 @@ markdown_extensions:
- pymdownx.striphtml
extra_css:
- stylesheets/extra.css
extra_javascript:
- javascripts/mathjax.js
- https://polyfill.io/v3/polyfill.min.js?features=es6
- https://unpkg.com/mathjax@3/es5/tex-mml-chtml.js
repo_url: https://github.com/daphne-eu/daphne
repo_name: daphne-eu/daphne
nav:
Expand Down
Loading