5.9 Container construction functions
real[]
linspaced_array
(int n, data real lower, data real upper)
Create a real array of length n
of equidistantly-spaced elements between lower
and upper
real[]
linspaced_int_array
(int n, int lower, int upper)
Create a regularly spaced, increasing integer array of length n
between lower
and upper
, inclusively.
If (upper - lower) / (n - 1)
is less than one, repeat each output (n - 1) / (upper - lower)
times.
If neither (upper - lower) / (n - 1)
or (n - 1) / (upper - lower)
are integers, upper
is reduced until one of these is true.
vector
linspaced_vector
(int n, data real lower, data real upper)
Create an n
-dimensional vector of equidistantly-spaced elements between lower
and upper
row_vector
linspaced_row_vector
(int n, data real lower, data real upper)
Create an n
-dimensional row-vector of equidistantly-spaced elements between lower
and upper
int[]
one_hot_int_array
(int n, int k)
Create a one-hot encoded int array of length n
with array[k] = 1
real[]
one_hot_array
(int n, int k)
Create a one-hot encoded real array of length n
with array[k] = 1
vector
one_hot_vector
(int n, int k)
Create an n
-dimensional one-hot encoded vector with vector[k] = 1
row_vector
one_hot_row_vector
(int n, int k)
Create an n
-dimensional one-hot encoded row-vector with row_vector[k] = 1
int[]
ones_int_array
(int n)
Create an int array of length n
of all ones
real[]
ones_array
(int n)
Create a real array of length n
of all ones
vector
ones_vector
(int n)
Create an n
-dimensional vector of all ones
row_vector
ones_row_vector
(int n)
Create an n
-dimensional row-vector of all ones
int[]
zeros_int_array
(int n)
Create an int array of length n
of all zeros
real[]
zeros_array
(int n)
Create a real array of length n
of all zeros
vector
zeros_vector
(int n)
Create an n
-dimensional vector of all zeros
row_vector
zeros_row_vector
(int n)
Create an n
-dimensional row-vector of all zeros
vector
uniform_simplex
(int n)
Create an n
-dimensional simplex with elements vector[i] = 1 / n
for all \(i \in 1, \dots, n\)