# Backends & Features
Reefer ships with a minimal default configuration width of 32. When you need different performance or algebra sizes, toggle Cargo features to swap backends or widen the internal bitset type. This chapter summarises what each flag does, when to use it, and the chores that come with it.
## Default configuration
- **Scalar backend:** `backend_cas` -- enables the CAS-based coefficient field (`cas-rs`, `cas-compute`, and `rug`). This gives the optimiser access to symbolic evaluation and constant folding out of the box.
- **Blade mask width:** Falls back to `u8` (`BladeBits = u8`), supporting algebras with up to 8 basis vectors (`n <= 8`).
- **System requirement:** The `rug` dependency pulls in GMP/MPFR and needs the `m4` macro processor during compilation. Install it via your package manager (e.g. `sudo apt install m4` or `brew install m4`) before building.
If the defaults match your algebra (most 2D/3D examples do), you can stay here and treat Reefer like any other dependency: `cargo add reefer` and you are done.
## Selecting a scalar backend
Exactly one backend should be active at a time. The `backend_cas` feature is enabled by default; switch to `backend_egg` by disabling default features. Enabling both simultaneously will produce duplicate type definitions and break the build.
### `backend_cas` (default)
- **What you get:** A symbolic algebra field powered by CAS-RS. It performs aggressive constant folding and can represent rational coefficients exactly.
- **Trade-offs:** Missing some nice optimazations available to egg, like folding to `mul_add` expressions. There's also the external `m4` requirement mentioned above.
### `backend_egg` (experimental)
- **What you get:** An e-graph-based field that relies on the `egg` crate. The optimiser rewrites coefficient expressions using equality saturation.
- **Trade-offs:** Currently offers a smaller rule set than the CAS backend and is marked experimental in the source tree. Will likely refactor in the future to find certain optimizations that cas-rs misses. The feature is still exploratory though, expect missing rewrites.
## Controlling blade mask width
The generated algebra stores basis combinations inside a bitset type `BladeBits`. Choose the width that matches the largest blade mask you plan to represent (number of basis vectors `n` must satisfy `n <= bit_width`). Only enable one of these flags at a time; otherwise the compiler will complain about conflicting type aliases.
| `bits_u8` | `u8` | 8 |
| `bits_u16` | `u16` | 16 |
| `bits_u32` | `u32` | 32 |
| `bits_u64` | `u64` | 64 |
| `bits_u128` | `u128` | 128 |
Switching width is as simple as:
`reefer = { features = ["bits_u64"], .. }`