NEML2 1.4.0
|
A labeled axis used to associate layout of a tensor with human-interpretable names. More...
A labeled axis used to associate layout of a tensor with human-interpretable names.
A logically one-dimensional tensor requires one LabeledAxis, two-dimensional tensor requires two LabeledAxis, and so on. See Tensor labeling for a detailed explanation of tensor labeling.
All the LabeledAxis modifiers can only be used during the setup stage. Calling any modifiers after the setup stage is forbidden and will result in a runtime error in Debug mode.
All the modifiers return the modified LabeledAxis by reference, so modifiers can be chained. For example
#include <LabeledAxis.h>
Classes | |
struct | AssemblySliceCmp |
Public Types | |
typedef std::unordered_map< std::string, std::pair< Size, Size > > | AxisLayout |
Public Member Functions | |
LabeledAxis () | |
Empty constructor. | |
LabeledAxis (const LabeledAxis &other) | |
(Shallow) copy constructor | |
template<typename T > | |
LabeledAxis & | add (const LabeledAxisAccessor &accessor) |
Add a variable or subaxis. | |
LabeledAxis & | add (const LabeledAxisAccessor &accessor, Size sz) |
Add an arbitrary variable using a LabeledAxisAccessor | |
void | clear () |
Clear all internal data. | |
void | setup_layout () |
size_t | nvariable (bool recursive=true) const |
Number of variables. | |
size_t | nsubaxis (bool recursive=false) const |
Number of subaxes. | |
bool | has_item (const LabeledAxisAccessor &name) const |
Does the item exist? | |
template<typename T > | |
bool | has_variable (const LabeledAxisAccessor &var) const |
Does the variable of a given primitive type exist? | |
bool | has_variable (const LabeledAxisAccessor &var) const |
Check the existence of a variable by its LabeledAxisAccessor. | |
bool | has_subaxis (const LabeledAxisAccessor &s) const |
Check the existence of a subaxis by its LabeledAxisAccessor. | |
Size | storage_size (const LabeledAxisAccessor &name={}) const |
Get the total storage size of this axis or the storage size of an item. | |
const AxisLayout & | layout () const |
Get the layout. | |
indexing::TensorIndex | indices (const LabeledAxisAccessor &accessor) const |
Get the indices of a specific item by a LabeledAxisAccessor | |
std::vector< std::pair< indexing::TensorIndex, indexing::TensorIndex > > | common_indices (const LabeledAxis &other, bool recursive=true) const |
Get the common indices of two LabeledAxis s. | |
std::vector< LabeledAxisAccessor > | sort_by_assembly_order (const std::set< LabeledAxisAccessor > &) const |
Sort a set of LabeledAxisAccessors by their indices. | |
const std::map< std::string, Size > & | variables () const |
Get the variables. | |
std::set< LabeledAxisAccessor > | variable_names (bool recursive=true) const |
Get the variable names. | |
const std::map< std::string, std::shared_ptr< LabeledAxis > > & | subaxes () const |
Get the subaxes. | |
std::set< LabeledAxisAccessor > | subaxis_names (bool recursive=false) const |
Get subaxes' names. | |
const LabeledAxis & | subaxis (const LabeledAxisAccessor &name) const |
Get a sub-axis. | |
LabeledAxis & | subaxis (const LabeledAxisAccessor &name) |
Get a sub-axis. | |
bool | equals (const LabeledAxis &other) const |
Check to see if two LabeledAxis objects are equivalent. | |
bool | has_state () const |
bool | has_old_state () const |
bool | has_forces () const |
bool | has_old_forces () const |
bool | has_residual () const |
bool | has_parameters () const |
Friends | |
std::ostream & | operator<< (std::ostream &os, const LabeledAxis &axis) |
typedef std::unordered_map<std::string, std::pair<Size, Size> > AxisLayout |
LabeledAxis | ( | ) |
Empty constructor.
LabeledAxis | ( | const LabeledAxis & | other | ) |
(Shallow) copy constructor
|
inline |
Add a variable or subaxis.
LabeledAxis & add | ( | const LabeledAxisAccessor & | accessor, |
Size | sz ) |
Add an arbitrary variable using a LabeledAxisAccessor
void clear | ( | ) |
Clear all internal data.
std::vector< std::pair< indexing::TensorIndex, indexing::TensorIndex > > common_indices | ( | const LabeledAxis & | other, |
bool | recursive = true ) const |
Get the common indices of two LabeledAxis
s.
bool equals | ( | const LabeledAxis & | other | ) | const |
Check to see if two LabeledAxis objects are equivalent.
|
inline |
|
inline |
Does the item exist?
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Check the existence of reserved subaxes
bool has_subaxis | ( | const LabeledAxisAccessor & | s | ) | const |
Check the existence of a subaxis by its LabeledAxisAccessor.
|
inline |
Does the variable of a given primitive type exist?
bool has_variable | ( | const LabeledAxisAccessor & | var | ) | const |
Check the existence of a variable by its LabeledAxisAccessor.
indexing::TensorIndex indices | ( | const LabeledAxisAccessor & | accessor | ) | const |
Get the indices of a specific item by a LabeledAxisAccessor
|
inline |
Get the layout.
void setup_layout | ( | ) |
Setup the layout of all items recursively. The layout of each item is contiguous in memory.
std::vector< LabeledAxisAccessor > sort_by_assembly_order | ( | const std::set< LabeledAxisAccessor > & | names | ) | const |
Sort a set of LabeledAxisAccessors by their indices.
Size storage_size | ( | const LabeledAxisAccessor & | name = {} | ) | const |
Get the total storage size of this axis or the storage size of an item.
|
inline |
Get the subaxes.
LabeledAxis & subaxis | ( | const LabeledAxisAccessor & | name | ) |
Get a sub-axis.
const LabeledAxis & subaxis | ( | const LabeledAxisAccessor & | name | ) | const |
Get a sub-axis.
std::set< LabeledAxisAccessor > subaxis_names | ( | bool | recursive = false | ) | const |
Get subaxes' names.
std::set< LabeledAxisAccessor > variable_names | ( | bool | recursive = true | ) | const |
Get the variable names.
|
friend |