codac 2.0.0
Loading...
Searching...
No Matches
codac2_analytic_flat_input_layout.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include <typeindex>
13#include <unordered_map>
14
16#include "codac2_AnalyticType.h"
17#include "codac2_ExprBase.h"
19
20namespace codac2
21{
22 class ScalarVar;
23 class VectorVar;
24 class MatrixVar;
25
39 {
40 std::type_index type = typeid(ScalarType);
41 Index offset = 0;
42 Index rows = 1;
43 Index cols = 1;
44
50 bool is_scalar() const;
51
57 bool is_vector() const;
58
64 bool is_matrix() const;
65 };
66
75 {
76 public:
77
83 explicit FlatInputLayout(const FunctionArgsList& args);
84
90 Index size() const;
91
100 bool same_domain_as(const FlatInputLayout& other) const;
101
108 bool same_domain_as(const FunctionArgsList& other_args) const;
109
119 Index flat_index_of(const ScalarVar& x) const;
120
128 Index flat_index_of(const VectorVar& x, Index i) const;
129
138 Index flat_index_of(const MatrixVar& x, Index i, Index j) const;
139
152 bool flat_index_of(const ScalarExpr& x, Index& flat_index) const;
153
160 const FlatInputBinding& binding_of(const ExprID& id) const;
161
168 const FlatInputBinding* find_binding(const ExprID& id) const;
169
170 private:
171
172 std::unordered_map<Index,FlatInputBinding> _bindings;
173 Index _size = 0;
174 };
175}
A class representing a unique identifier for expressions.
Definition codac2_ExprBase.h:34
bool same_domain_as(const FlatInputLayout &other) const
Tests whether two layouts describe the same flattened input domain.
Index flat_index_of(const VectorVar &x, Index i) const
Returns the flat index associated with a direct component of a vector input variable.
FlatInputLayout(const FunctionArgsList &args)
Builds the flattened layout associated with a function argument list.
Index flat_index_of(const ScalarVar &x) const
Returns the flat index associated with a scalar input variable.
Index size() const
Returns the total number of scalar inputs in the flattened domain.
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 FlatInputBinding * find_binding(const ExprID &id) const
Returns the binding associated with an input expression identifier, if any.
bool same_domain_as(const FunctionArgsList &other_args) const
Tests whether this layout matches the flattened domain induced by a function argument list.
const FlatInputBinding & binding_of(const ExprID &id) const
Returns the binding associated with an input expression identifier.
A container class to manage a collection of function arguments.
Definition codac2_FunctionArgsList.h:25
Definition codac2_OctaSym.h:21
Binding information associated with one input argument in a flattened input domain.
Definition codac2_analytic_flat_input_layout.h:39
bool is_vector() const
Tests whether the binding corresponds to a vector input argument.
Index rows
Number of rows of the argument block.
Definition codac2_analytic_flat_input_layout.h:42
std::type_index type
Analytic type of the bound input argument.
Definition codac2_analytic_flat_input_layout.h:40
bool is_scalar() const
Tests whether the binding corresponds to a scalar input argument.
Index cols
Number of columns of the argument block.
Definition codac2_analytic_flat_input_layout.h:43
bool is_matrix() const
Tests whether the binding corresponds to a matrix input argument.
Index offset
First scalar index of the argument in the flattened domain.
Definition codac2_analytic_flat_input_layout.h:41