Skip to content

Add documentation for reverse() #148

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

Merged
merged 3 commits into from
Feb 24, 2020
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
26 changes: 20 additions & 6 deletions src/functions-reference/array_operations.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
```{r results='asis', echo=FALSE}
if (knitr::is_html_output()) {
cat(' * <a href="array-reductions.html">Reductions</a>\n')
cat(' * <a href="array-size-and-dimension-function.html">Array Size and Dimension Function</a>\n')
cat(' * <a href="array-broadcasting.html">Array Broadcasting</a>\n')
cat(' * <a href="array-concatenation.html">Array Concatenation</a>\n')
cat(' * <a href="array-size-and-dimension-function.html">Array size and dimension function</a>\n')
cat(' * <a href="array-broadcasting.html">Array broadcasting</a>\n')
cat(' * <a href="array-concatenation.html">Array concatenation</a>\n')
cat(' * <a href="sorting-functions.html">Sorting functions</a>\n')
cat(' * <a href="reversing-functions.html">Reversing functions</a>\n')
}
```

Expand Down Expand Up @@ -178,7 +179,7 @@ The squared Euclidean distance between x and y
`real` **`squared_distance`**`(row_vector x, row_vector[] y)`<br>\newline
The Euclidean distance between x and y

## Array Size and Dimension Function
## Array size and dimension function

The size of an array or matrix can be obtained using the `dims()`
function. The `dims()` function is defined to take an argument
Expand Down Expand Up @@ -236,7 +237,7 @@ can be any type, but the size is just the size of the top level array,
not the total number of elements contained. For example, if `x` is of
type `real[4,3]` then `size(x)` is 4.

## Array Broadcasting {#array-broadcasting}
## Array broadcasting {#array-broadcasting}

The following operations create arrays by repeating elements to fill
an array of a specified size. These operations work for all input
Expand Down Expand Up @@ -312,7 +313,7 @@ After the assignment to `b`, the value for `b[j,k,m,n]` is equal to
`a[m,n]` where it is defined, for `j` in `1:3`, `k` in `1:4`, `m` in
`1:5`, and `n` in `1:6`.

## Array Concatenation {#array-concatenation}
## Array concatenation {#array-concatenation}

<!-- T; append_array; (T x, T y); -->
\index{{\tt \bfseries append\_array }!{\tt (T x, T y): T}|hyperpage}
Expand Down Expand Up @@ -409,3 +410,16 @@ Number of components of v less than v[s]
`int` **`rank`**`(int[] v, int s)`<br>\newline
Number of components of v less than v[s]

## Reversing functions {#reversing-functions}

Stan provides functions to create a new array by reversing the order of
elements in an existing array. For example, if `v` is declared as a real
array of size 3, with values
\[ \text{v} = (1,\, -10.3,\, 20.987), \] then
\[ \mathrm{reverse(v)} = (20.987,\, -10.3,\, 1). \]

<!-- T[]; reverse; (T[] v); -->
\index{{\tt \bfseries reverse }!{\tt (T[] v): T[]}|hyperpage}

`T[]` **`reverse`**`(T[] v)`<br>\newline
Return a new array containing the elements of the argument in reverse order.
18 changes: 16 additions & 2 deletions src/functions-reference/matrix_operations.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cat(' * <a href="softmax.html">Special Matrix Functions</a>\n')
cat(' * <a href="covariance.html">Covariance Functions</a>\n')
cat(' * <a href="linear-algebra-functions-and-solvers.html">Linear Algebra Functions and Solvers</a>\n')
cat(' * <a href="sort-functions.html">Sort Functions</a>\n')
cat(' * <a href="reverse-functions.html">Reverse Functions</a>\n')
}
```

Expand Down Expand Up @@ -1544,8 +1545,8 @@ The singular values of A in descending order

## Sort Functions

see section [sorting functions](#sorting-functions) for examples of how the functions
work.
See the [sorting functions section](#sorting-functions) for examples of how
the functions work.

<!-- vector; sort_asc; (vector v); -->
\index{{\tt \bfseries sort\_asc }!{\tt (vector v): vector}|hyperpage}
Expand Down Expand Up @@ -1611,3 +1612,16 @@ Number of components of v less than v[s]
`int` **`rank`**`(row_vector v, int s)`<br>\newline
Number of components of v less than v[s]

## Reverse Functions {#reverse-functions}

<!-- vector; reverse; (vector v); -->
\index{{\tt \bfseries reverse }!{\tt (vector v): vector}|hyperpage}

`vector` **`reverse`**`(vector v)`<br>\newline
Return a new vector containing the elements of the argument in reverse order.

<!-- row_vector; reverse; (row_vector v); -->
\index{{\tt \bfseries reverse }!{\tt (row_vector v): row_vector}|hyperpage}

`row_vector` **`reverse`**`(row_vector v)`<br>\newline
Return a new row vector containing the elements of the argument in reverse order.