We are very happy to announce that the next release of Cmdstan (2.24.1) is now available on Github.

You can find it here: https://github.com/stan-dev/cmdstan/releases/tag/v2.24.1

There were ~150 pull requests merged for this release, code was contributed by 17 developers:

@Adam_Haber , @andrjohns, @bbbales2, @Bob_Carpenter, @charlesm93, Christopher22 , @simon, HaoZeke, @IvanYashchuk , @mitzimorris , @nhuurre, @peterwicksstringfield, @rybern, @serban-nicusor, @SteveBronder, @tadej and @rok_cesnovar.

Also huge thanks to everyone that contributed with code reviews!

**How to install?**

Download the tar.gz file from the link above, extract it and use it the way you use any Cmdstan release. We also now have an online Cmdstan guide available at https://mc-stan.org/docs/2_24/cmdstan-guide/

With cmdstanpy you can update to the new release using:

```
import cmdstanpy
cmdstanpy.install_cmdstan()
```

With cmdstanr you can update to the new release using:

```
library(cmdstanr)
install_cmdstan(release_url = "https://github.com/stan-dev/cmdstan/releases/download/v2.24.1/cmdstan-2.24.1.tar.gz")
```

# New features

This release comes with a lot of new features and bugfixes. The detailed release notes for Cmdstan and all the submodules can be found here. If you have any questions or cannot find the documentation, do not hesitate to ask. Below are some of the highlights.

### A new ODE interface

The new ODE interface is intended to make it easier to specify the ODE RHS by avoiding packing and unpacking schemes required with the old interface. It is important to switch to the new interfaces because the old interfaces are significantly slower than they were previously (we have seen up to 30%)

The new functions are:

```
vector[] ode_bdf(F f, vector y0, real t0, real[] times, ...)
vector[] ode_adams(F f, vector y0, real t0, real[] times, ...)
vector[] ode_rk45(F f, vector y0, real t0, real[] times, ...)
vector[] ode_bdf_tol(F f, vector y0, real t0, real[] times, real rel_tol, real abs_tol, int max_num_steps, ...)
vector[] ode_adams_tol(F f, vector y0, real t0, real[] times, real rel_tol, real abs_tol, int max_num_steps, ...)
vector[] ode_rk45_tol(F f, vector y0, real t0, real[] times, real rel_tol, real abs_tol, int max_num_steps, ...)
```

Where `...`

can be argument(s) of any type.

For examples converting ODEs written with the old interface to the new interface, look at the case study Upgrading to the new ODE interface.

For detailed information, check out the Ordinary Differential Equation (ODE) Solvers section in the Function Reference or the Ordinary Differential Equations section in the Userâ€™s Guide.

### Functions for Hidden Markov Models with a discrete latent variable

New signatures:

```
matrix hmm_hidden_state_prob(matrix, matrix, vector)
int[] hmm_latent_rng(matrix, matrix, vector)
real hmm_marginal(matrix, matrix, vector)
```

For detailed information, check out the Hidden Markov Models section in the Function Reference.

### Elementwise pow operator and matrix power function

The .^ operator now supports elementwise pow. The following examples are now all supported:

```
vector .^ vector
row_vector .^ row_vector
matrix .^ matrix
int .^ matrix
matrix .^ int
matrix .^ real
vector .^ real
vector[] .^ vector[]
int .^ matrix[]
row_vector[] .^ real
row_vector .^ real
...
```

A new matrix matrix_power is also available with the signature:

```
matrix matrix_power(matrix, int)
```

For detailed information, check out the Matrix Power section in the Functions Reference.

### Newton solver

The Newton solver is available via

```
vector algebra_solver_newton((vector, vector, data real[], data int[]) => vector,
vector, vector, real[], int[])
vector algebra_solver_newton((vector, vector, data real[], data int[]) => vector,
vector, vector, real[], int[], real, real,
real)
```

For detailed information, check out the Algebraic Equation Solver section in the Functions Reference.

### Support for the multinomial logit distribution

Supported signatures:

```
real multinomial_logit_log(int[], vector)
real multinomial_logit_lpmf(int[], vector)
int[] multinomial_logit_rng(vector, int)
```

For detailed information, check out the Multivariate Discrete Distributions section in the Functions Reference.

### Reverse function

Supported signatures:

```
T reverse(T)
```

T is vector, row_vector or an array of any type

For detailed information, check out the Reverse Functions section in the Functions Reference.

### Integer division operator

A new integer division operator was added: `%/%`

. Dividing integer numbers with the `/`

operator will warn.

### Pedantic mode

You can now run a pedantic check on your model that warns you about potential issues in your Stan program.

You can enable it in Cmdstan by adding a `--warn-pedantic`

flag to STANCFLAGS.

You can enable it in cmdstanr with the `stanc_options`

argument:

```
model = cmdstan_model("test.stan", stanc_options = list("warn-pedantic" = TRUE))
```

For detailed information, check out the Pedantic mode section in the Reference Manual.

### Non-scalar values in lower, upper, offset and multiplier

Non-scalar values are now allowed in lower, upper, offset and multiplier transforms if the value has the same type and size as the declared variable.

Example:

```
real L[K];
real U[K];
vector<lower = L, upper = U>[K] alpha;
```

### Faster compile times and easier handling of threading

If you are using the `g++`

C++ compiler, the Stan models should now compile ~50% faster. If you are using the `clang`

C++ compiler, the models should compile ~20% faster than with Cmdstan 2.23.

On Linux and macOS this speedup is available out of the box. On Windows, if you are using the toolchain available with RTools 4.0, you have to add

```
PRECOMPILED_HEADERS=true
```

to the `make/local`

file. This speedup is unfortunately not available with RTools 3.5 on Windows.

### A new and improved stansummary

- added option of returning custom quantiles
- separate summaries for sampler and model params
- a lot of minor improvements for stability and maintainability