3from .Attribute
import Attribute
4from .Double
import Double
9 An array of doubles, i.e. a vector in the mathematical sense
18 Cardinality of data. This has to be a string. Therefore it can be a
19 symbol, i.e. a name defined via ifdef somewhere in your code.
27 valid_mantissa_bits=None,
29 qualifier=Attribute.Qualifier.NONE,
32 if qualifier != Attribute.Qualifier.NONE:
33 raise NotImplementedError(
34 f
"Attribute {name}: This data type can't work with qualifiers (yet)"
36 if initval
is not None:
37 raise NotImplementedError(
38 f
"Attribute {name}: Can't generate arrays with initial values (yet)."
40 Double.__init__(self, name, ifdefs=ifdefs, qualifier=qualifier, initval=initval)
48 Cannot use the default copy constructor, as it is an array,
49 i.e. we need some manual deep copying.
54 def get_methods(self, _full_qualified_class_name, for_declaration=True):
55 accessor_name = self.
_name[:1].title() + self.
_name[1:]
57 (
"get" + accessor_name +
"() const",
"const double*"),
61 +
"(const double value["
66 (
"get" + accessor_name +
"(int index) const",
"double"),
67 (
"set" + accessor_name +
"(int index, double value)",
"void"),
76 "[[clang::truncate_mantissa("
85 return [(
"_" + self.
_name +
"[0]",
"double")]
89 name =
" _dataStore._" + self.
_name
91 name =
" _" + self.
_name
92 if signature.startswith(
"get")
and "index" in signature:
93 return " return " + name +
"[index];\n"
94 elif signature.startswith(
"set")
and "index" in signature:
95 return name +
"[index] = value;\n"
96 elif signature.startswith(
"get"):
97 return " return " + name +
";\n"
98 elif signature.startswith(
"set"):
99 return " std::copy_n(value, " + self.
_cardinality +
", " + name +
" );\n"
110 Return string representation of attribute.
114 return "_dataStore._" + self.
_name +
'[0] << ",..."'
116 return "_" + self.
_name +
'[0] << ",..."'
122 @valid_mantissa_bits.setter
128 Pass in None, if you want to use the default accuracy.
131 assert value ==
None or value > 0
An array of doubles, i.e.
get_first_plain_C_attribute(self)
For MPI for example, I need to know the first attribute.
valid_mantissa_bits(self)
get_methods(self, _full_qualified_class_name, for_declaration=True)
Return sequence of methods that are defined for this attribute.
get_to_string(self)
Return string representation of attribute.
get_native_MPI_type(self)
Return native (built-in) MPI datatype.
get_method_body(self, signature)
I hand in the method signature (see get_methods()) and wanna get the whole implementation.
use_default_copy_constructor(self)
Cannot use the default copy constructor, as it is an array, i.e.
get_plain_C_attributes(self, for_constructor=False)
Return list of n-tuples.
__init__(self, name, cardinality, valid_mantissa_bits=None, ifdefs=[], qualifier=Attribute.Qualifier.NONE, initval=None)
@Pawel Can you add some docu?
cardinality is a string (you can thus use symbols as well as long as they will be defined at compile ...