pub fn enumerate_indices(
index_domains: Vec<Domain>,
) -> impl Iterator<Item = Vec<Literal>>
Expand description
For some index domains, returns a list containing each of the possible indices.
Indices are traversed in row-major ordering.
This is an O(n^dim) operation, where dim is the number of dimensions in the matrix.
§Panics
- If any of the index domains are not finite or enumerable with
Domain::values
.
§Example
use conjure_core::ast::{Domain,Range,Literal,matrix};
let index_domains = vec![Domain::Bool,Domain::Int(vec![Range::Bounded(1,2)])];
let expected_indices = vec![
vec![Literal::Bool(false),Literal::Int(1)],
vec![Literal::Bool(false),Literal::Int(2)],
vec![Literal::Bool(true),Literal::Int(1)],
vec![Literal::Bool(true),Literal::Int(2)]
];
let actual_indices: Vec<_> = matrix::enumerate_indices(index_domains).collect();
assert_eq!(actual_indices, expected_indices);