pub struct ParamInfo { /* private fields */ }Expand description
Information about function parameters, including their indices and whether they are constant.
§Fields
indices- The parameter indices, stored as either consecutive or disjoint rangesconstant- A vector indicating whether each parameter is constant (true) or variable (false)
Implementations§
Source§impl ParamInfo
impl ParamInfo
Sourcepub fn new(indices: impl Into<ParamIndices>, constant: Vec<bool>) -> ParamInfo
pub fn new(indices: impl Into<ParamIndices>, constant: Vec<bool>) -> ParamInfo
Creates a new ParamInfo with the given parameter indices and constant flags.
§Arguments
indices- The parameter indices (can be any type that converts toParamIndices)constant- A vector indicating whether each parameter is constant
§Returns
A new ParamInfo instance.
§Panics
The length of the constant vector should match the number of parameters in indices.
Sourcepub fn parameterized(indices: impl Into<ParamIndices>) -> ParamInfo
pub fn parameterized(indices: impl Into<ParamIndices>) -> ParamInfo
Creates a new ParamInfo where all parameters are variable (not constant).
This is a convenience method for creating parameter information where all parameters can vary during optimization or analysis.
§Arguments
indices- The parameter indices (can be any type that converts toParamIndices)
§Returns
A new ParamInfo instance with all parameters marked as variable.
Sourcepub fn to_sorted(&self) -> ParamInfo
pub fn to_sorted(&self) -> ParamInfo
Returns a new ParamInfo with its parameter indices sorted.
If the ParamIndices are Disjoint, the internal vector is sorted.
If the ParamIndices are Joint, they remain Joint as their order is inherently sorted.
The constant vector is reordered to match the new order of indices.
Sourcepub fn union(&self, other: &ParamInfo) -> ParamInfo
pub fn union(&self, other: &ParamInfo) -> ParamInfo
Unions this ParamInfo with another, combining their parameter indices and constant flags.
This operation combines parameter indices from both ParamInfo instances. If a parameter
index appears in both instances, their constant flags must match or an assertion will fail.
§Arguments
other- The otherParamInfoto concatenate with
§Returns
A new ParamInfo containing the combined parameters and their constant status.
Sourcepub fn intersect(&self, other: &ParamInfo) -> ParamInfo
pub fn intersect(&self, other: &ParamInfo) -> ParamInfo
Computes the intersection of this ParamInfo with another.
Returns a new ParamInfo containing only the parameters that are present in both
instances. The constant flags must match for common parameters.
§Arguments
other- The otherParamInfoto intersect with
§Returns
A new ParamInfo containing only the common parameters.
Sourcepub fn num_params(&self) -> usize
pub fn num_params(&self) -> usize
Returns the total number of parameters.
§Returns
The number of parameters tracked by this ParamInfo.
Sourcepub fn num_var_params(&self) -> usize
pub fn num_var_params(&self) -> usize
Returns the total number of variable parameters.
§Returns
The number of non-constant parameters tracked by this ParamInfo.
Sourcepub fn get_param_map(&self) -> Vec<u64>
pub fn get_param_map(&self) -> Vec<u64>
Returns the parameter indices as a vector of u64 values.
This is useful for interfacing with external libraries that expect parameter indices as 64-bit unsigned integers.
§Returns
A vector containing all parameter indices converted to u64.
Sourcepub fn get_const_map(&self) -> Vec<bool>
pub fn get_const_map(&self) -> Vec<bool>
Returns a copy of the constant flags for all parameters.
The returned vector has the same length as the number of parameters, where each boolean indicates whether the corresponding parameter is constant.
§Returns
A vector of boolean values indicating parameter constancy.
Sourcepub fn empty() -> ParamInfo
pub fn empty() -> ParamInfo
Creates an empty ParamInfo with no parameters.
This is useful as a default or starting point for parameter information.
§Returns
An empty ParamInfo instance.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks if this ParamInfo contains no parameters.
§Returns
true if there are no parameters, false otherwise.
Sourcepub fn sorted_non_constant(&self) -> Vec<usize>
pub fn sorted_non_constant(&self) -> Vec<usize>
Returns a sorted vector of indices for parameters that are not constant.
This is useful for optimization routines that only need to vary non-constant parameters.
§Returns
A sorted vector containing the indices of all non-constant parameters.