codac 2.0.0
Loading...
Searching...
No Matches
codac2::FlatInputLayout Class Reference

Flattened layout associated with an analytic function input domain. More...

#include <codac2_analytic_flat_input_layout.h>

Public Member Functions

 FlatInputLayout (const FunctionArgsList &args)
 Builds the flattened layout associated with a function argument list.
Index size () const
 Returns the total number of scalar inputs in the flattened domain.
bool same_domain_as (const FlatInputLayout &other) const
 Tests whether two layouts describe the same flattened input domain.
bool same_domain_as (const FunctionArgsList &other_args) const
 Tests whether this layout matches the flattened domain induced by a function argument list.
Index flat_index_of (const ScalarVar &x) const
 Returns the flat index associated with a scalar input variable.
Index flat_index_of (const VectorVar &x, Index i) const
 Returns the flat index associated with a direct component of a vector input variable.
Index flat_index_of (const MatrixVar &x, Index i, Index j) const
 Returns the flat index associated with a direct component of a matrix input variable.
bool flat_index_of (const ScalarExpr &x, Index &flat_index) const
 Tries to resolve a scalar input expression into a flat input index.
const FlatInputBindingbinding_of (const ExprID &id) const
 Returns the binding associated with an input expression identifier.
const FlatInputBindingfind_binding (const ExprID &id) const
 Returns the binding associated with an input expression identifier, if any.

Detailed Description

Flattened layout associated with an analytic function input domain.

This class provides a canonical flattened representation of a function argument list. Each scalar, vector or matrix input argument is assigned a contiguous block of scalar indices.

Constructor & Destructor Documentation

◆ FlatInputLayout()

codac2::FlatInputLayout::FlatInputLayout ( const FunctionArgsList & args)
explicit

Builds the flattened layout associated with a function argument list.

Parameters
argsFunction argument list.

Member Function Documentation

◆ size()

Index codac2::FlatInputLayout::size ( ) const

Returns the total number of scalar inputs in the flattened domain.

Returns
Flattened input domain size.

◆ same_domain_as() [1/2]

bool codac2::FlatInputLayout::same_domain_as ( const FlatInputLayout & other) const

Tests whether two layouts describe the same flattened input domain.

Here, only the total number of flattened scalar inputs matters.

Parameters
otherOther flattened layout.
Returns
True if both layouts describe the same flattened input domain.

◆ same_domain_as() [2/2]

bool codac2::FlatInputLayout::same_domain_as ( const FunctionArgsList & other_args) const

Tests whether this layout matches the flattened domain induced by a function argument list.

Parameters
other_argsFunction argument list.
Returns
True if both domains are identical once flattened.

◆ flat_index_of() [1/4]

Index codac2::FlatInputLayout::flat_index_of ( const ScalarVar & x) const

Returns the flat index associated with a scalar input variable.

This method is restricted to scalar variables appearing directly in the function argument list.

Parameters
xScalar input variable.
Returns
Flat index associated with x.

◆ flat_index_of() [2/4]

Index codac2::FlatInputLayout::flat_index_of ( const VectorVar & x,
Index i ) const

Returns the flat index associated with a direct component of a vector input variable.

Parameters
xVector input variable.
iComponent index.
Returns
Flat index associated with x[i].

◆ flat_index_of() [3/4]

Index codac2::FlatInputLayout::flat_index_of ( const MatrixVar & x,
Index i,
Index j ) const

Returns the flat index associated with a direct component of a matrix input variable.

Parameters
xMatrix input variable.
iRow index.
jColumn index.
Returns
Flat index associated with x(i,j).

◆ flat_index_of() [4/4]

bool codac2::FlatInputLayout::flat_index_of ( const ScalarExpr & x,
Index & flat_index ) const

Tries to resolve a scalar input expression into a flat input index.

Supported expressions are:

  • a scalar input variable;
  • a direct component of a vector input variable;
  • a direct component of a matrix input variable.
Parameters
xScalar input expression.
flat_indexOutput flat input index.
Returns
True if x could be resolved into a flat input index.

◆ binding_of()

const FlatInputBinding & codac2::FlatInputLayout::binding_of ( const ExprID & id) const

Returns the binding associated with an input expression identifier.

Parameters
idInput expression identifier.
Returns
Binding associated with id.

◆ find_binding()

const FlatInputBinding * codac2::FlatInputLayout::find_binding ( const ExprID & id) const

Returns the binding associated with an input expression identifier, if any.

Parameters
idInput expression identifier.
Returns
Pointer to the associated binding, or nullptr if id does not belong to the layout.

The documentation for this class was generated from the following file: