|
Peano
|
Simple SmartPointerVector class. More...
#include <SmartPointerVector.h>

Public Member Functions | |
| SmartPointerVector () InlineMethod | |
| Clang requires the always_inline attribute, as it otherwise makes weird decisions. | |
| SmartPointerVector (const Scalar *values) InlineMethod | |
| SmartPointerVector (std::initializer_list< Scalar > values) | |
| Initialisation via initialisation list. | |
| SmartPointerVector (const std::bitset< Size > &values) InlineMethod | |
| SmartPointerVector (const Scalar &initialValue) | |
| Construct new SmartPointerVector and initialize all components with initialValue. | |
| SmartPointerVector (const SmartPointerVector< Size, Scalar > &toCopy) | |
| Copy constructor to copy from any SmartPointerVector type. | |
| SmartPointerVector (const Vector< Size, Scalar > &toCopy) | |
| SmartPointerVector< Size, Scalar > & | operator= (const SmartPointerVector< Size, Scalar > &toAssign) InlineMethod |
| Assignment operator for any SmartPointerVector type. | |
| SmartPointerVector< Size, Scalar > & | operator= (const Vector< Size, Scalar > &vector) |
| Conversion assignment operator. | |
| SmartPointerVector< Size, Scalar > & | operator= (const Scalar &vector) |
| Assign all entries the same value. | |
| int | size () const |
| Returns the number of components of the SmartPointerVector. | |
| const Scalar & | operator[] (int index) const InlineMethod |
| Returns read-only ref. | |
| Scalar & | operator[] (int index) InlineMethod |
| Returns ref. | |
| const Scalar & | operator() (int index) const InlineMethod |
| Returns read-only ref. | |
| Scalar & | operator() (int index) InlineMethod |
| Returns ref. | |
| Scalar * | data () |
| This routine returns a pointer to the first data element. | |
| const Scalar * | data () const |
| Vector< Size, Scalar > | toVector () const |
Private Attributes | |
| Scalar * | _values |
| In the original vector, this is. | |
| std::shared_ptr< Scalar[] > | _dataSmartPointer |
Simple SmartPointerVector class.
Mirrors exactly tarch::la::Vector, but internally uses a smart pointer rather than a scalar. The class tries to minimise replication. Therefore, it provides extensive conversion routines to and from a normal Vector but limited functionality directly on the smart vector (where appropriate).
Definition at line 47 of file SmartPointerVector.h.
| tarch::la::SmartPointerVector< Size, Scalar >::SmartPointerVector | ( | ) |
Clang requires the always_inline attribute, as it otherwise makes weird decisions.
| tarch::la::SmartPointerVector< Size, Scalar >::SmartPointerVector | ( | const Scalar * | values | ) |
| tarch::la::SmartPointerVector< Size, Scalar >::SmartPointerVector | ( | std::initializer_list< Scalar > | values | ) |
Initialisation via initialisation list.
You can't inline an initialisation list, as the realisation of this routine relies on an iterator and the iterator within the C++ std lib won't be inlined.
| tarch::la::SmartPointerVector< Size, Scalar >::SmartPointerVector | ( | const std::bitset< Size > & | values | ) |
| tarch::la::SmartPointerVector< Size, Scalar >::SmartPointerVector | ( | const Scalar & | initialValue | ) |
Construct new SmartPointerVector and initialize all components with initialValue.
| tarch::la::SmartPointerVector< Size, Scalar >::SmartPointerVector | ( | const SmartPointerVector< Size, Scalar > & | toCopy | ) |
Copy constructor to copy from any SmartPointerVector type.
The only way to accomplish this with enable-if is to specify a second dummy argument with default value, which is (hopefully) optimized away.
| tarch::la::SmartPointerVector< Size, Scalar >::SmartPointerVector | ( | const Vector< Size, Scalar > & | toCopy | ) |
Copy constructor As we are working with smart pointers, we do not realy copy under the hood. I originally had ~~~~~~~~~~~~~~~~~~~~~~
_dataSmartPointer( toCopy._dataSmartPointer ), _values( _dataSmartPointer.get() ) { ~~~~~~~~~~~~~~~~~~~~~~
but the the compiler told me that _dataSmartPointer is not initialised at this point. Which I find weird. So now I initialise it explicitly.
| Scalar * tarch::la::SmartPointerVector< Size, Scalar >::data | ( | ) |
This routine returns a pointer to the first data element.
Not a beautiful one as it harms the OO idea, but in many cases it is convenient to have this operation.
Definition at line 213 of file SmartPointerVector.h.
References tarch::la::SmartPointerVector< Size, Scalar >::_values.
Referenced by peano4.datamodel.DaStGenToLegacyTool.DaStGenToLegacyTool::__generate_dastgen_input_file(), peano4.datamodel.DaStGenToLegacyTool.DaStGenToLegacyTool::__get_file_name(), peano4.datamodel.DaStGenToLegacyTool.DaStGenToLegacyTool::__get_full_qualified_file_name(), swift2.particle.Particle.Particle::__init__(), swift2.particle.Particle.Particle::_add_dependency_checks(), swift2.particle.Particle.Particle::_dependency_checks_modify_steps(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_boolean_array_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_boolean_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_double_array_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_double_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_enum_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_integer_array_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_integer_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_peano_double_array_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_peano_integer_array_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_string_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_user_defined_attributes(), peano4.datamodel.PatchToDoubleArray.PatchToDoubleArray::_get_dictionary_for_output(), peano4.datamodel.DaStGenToLegacyTool.DaStGenToLegacyTool::construct_output(), peano4.datamodel.DynamicArrayOverPrimitivesToStdVector.DynamicArrayOverPrimitivesToStdVector::construct_output(), peano4.datamodel.PatchToDoubleArray.PatchToDoubleArray::construct_output(), peano4.datamodel.PatchToDoubleArrayOnHeap.PatchToDoubleArrayOnHeap::construct_output(), peano4.datamodel.PatchToDoubleArrayWithSmartPointer.PatchToDoubleArrayWithSmartPointer::construct_output(), peano4.datamodel.DaStGenToLegacyTool.DaStGenToLegacyTool::get_header_file_include(), peano4.datamodel.DynamicArrayOverPrimitivesToStdVector.DynamicArrayOverPrimitivesToStdVector::get_header_file_include(), peano4.datamodel.PatchToDoubleArray.PatchToDoubleArray::get_header_file_include(), peano4.datamodel.PatchToDoubleArrayOnHeap.PatchToDoubleArrayOnHeap::get_header_file_include(), peano4.datamodel.PatchToDoubleArrayWithSmartPointer.PatchToDoubleArrayWithSmartPointer::get_header_file_include(), peano4.datamodel.DaStGenToLegacyTool.DaStGenToLegacyTool::get_stack_container(), peano4.datamodel.PatchToDoubleArray.PatchToDoubleArray::get_stack_container(), peano4.datamodel.PatchToDoubleArrayOnHeap.PatchToDoubleArrayOnHeap::get_stack_container(), peano4.datamodel.PatchToDoubleArrayWithSmartPointer.PatchToDoubleArrayWithSmartPointer::get_stack_container(), peano4.datamodel.DaStGen2.DaStGen2::hosts_smart_pointer_attribute(), swift2.particle.Particle.Particle::readme_descriptor(), swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius::set_parameters(), swift2.particle.SPHParticle.SPHParticle::set_parameters(), and swift2.particle.tests.testLeapfrogFixedTimeStepSize.testLeapfrogFixedTimeStepSize::set_parameters().

| const Scalar * tarch::la::SmartPointerVector< Size, Scalar >::data | ( | ) | const |
Definition at line 217 of file SmartPointerVector.h.
References tarch::la::SmartPointerVector< Size, Scalar >::_values.
Referenced by peano4.datamodel.DaStGenToLegacyTool.DaStGenToLegacyTool::__generate_dastgen_input_file(), peano4.datamodel.DaStGenToLegacyTool.DaStGenToLegacyTool::__get_file_name(), peano4.datamodel.DaStGenToLegacyTool.DaStGenToLegacyTool::__get_full_qualified_file_name(), swift2.particle.Particle.Particle::__init__(), swift2.particle.Particle.Particle::_add_dependency_checks(), swift2.particle.Particle.Particle::_dependency_checks_modify_steps(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_boolean_array_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_boolean_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_double_array_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_double_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_enum_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_integer_array_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_integer_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_peano_double_array_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_peano_integer_array_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_string_attributes(), swift2.particle.tests.DastgenTestDummyParticle.DastgenTestDummyParticle::_generate_user_defined_attributes(), peano4.datamodel.PatchToDoubleArray.PatchToDoubleArray::_get_dictionary_for_output(), peano4.datamodel.DaStGenToLegacyTool.DaStGenToLegacyTool::construct_output(), peano4.datamodel.DynamicArrayOverPrimitivesToStdVector.DynamicArrayOverPrimitivesToStdVector::construct_output(), peano4.datamodel.PatchToDoubleArray.PatchToDoubleArray::construct_output(), peano4.datamodel.PatchToDoubleArrayOnHeap.PatchToDoubleArrayOnHeap::construct_output(), peano4.datamodel.PatchToDoubleArrayWithSmartPointer.PatchToDoubleArrayWithSmartPointer::construct_output(), peano4.datamodel.DaStGenToLegacyTool.DaStGenToLegacyTool::get_header_file_include(), peano4.datamodel.DynamicArrayOverPrimitivesToStdVector.DynamicArrayOverPrimitivesToStdVector::get_header_file_include(), peano4.datamodel.PatchToDoubleArray.PatchToDoubleArray::get_header_file_include(), peano4.datamodel.PatchToDoubleArrayOnHeap.PatchToDoubleArrayOnHeap::get_header_file_include(), peano4.datamodel.PatchToDoubleArrayWithSmartPointer.PatchToDoubleArrayWithSmartPointer::get_header_file_include(), peano4.datamodel.DaStGenToLegacyTool.DaStGenToLegacyTool::get_stack_container(), peano4.datamodel.PatchToDoubleArray.PatchToDoubleArray::get_stack_container(), peano4.datamodel.PatchToDoubleArrayOnHeap.PatchToDoubleArrayOnHeap::get_stack_container(), peano4.datamodel.PatchToDoubleArrayWithSmartPointer.PatchToDoubleArrayWithSmartPointer::get_stack_container(), peano4.datamodel.DaStGen2.DaStGen2::hosts_smart_pointer_attribute(), swift2.particle.Particle.Particle::readme_descriptor(), swift2.particle.SPHLeapfrogFixedSearchRadius.SPHLeapfrogFixedSearchRadius::set_parameters(), swift2.particle.SPHParticle.SPHParticle::set_parameters(), and swift2.particle.tests.testLeapfrogFixedTimeStepSize.testLeapfrogFixedTimeStepSize::set_parameters().

| const Scalar & tarch::la::SmartPointerVector< Size, Scalar >::operator() | ( | int | index | ) | const |
Returns read-only ref.
to component of given index.
If we use the SmartPointerVector on the GPU, we cannot have assertions. If we use SYCL on the CPU for the multitasking, we cannot have assertions in the SYCL part either, as SYCL aims to be platform-independent, i.e. has to assume that the code generated also will be deployed to a GPU. See discussion on SYCL support.
Definition at line 187 of file SmartPointerVector.h.
References tarch::la::SmartPointerVector< Size, Scalar >::_values, assertion3, and tarch::toString().

| Scalar & tarch::la::SmartPointerVector< Size, Scalar >::operator() | ( | int | index | ) |
Returns ref.
to component of given index.
Definition at line 200 of file SmartPointerVector.h.
References tarch::la::SmartPointerVector< Size, Scalar >::_values, assertion3, and tarch::toString().

| SmartPointerVector< Size, Scalar > & tarch::la::SmartPointerVector< Size, Scalar >::operator= | ( | const Scalar & | vector | ) |
Assign all entries the same value.
As we work with smart pointers, we can return a copy here. Actually, I got some compiler errors when I tried to return a reference.
| SmartPointerVector< Size, Scalar > & tarch::la::SmartPointerVector< Size, Scalar >::operator= | ( | const SmartPointerVector< Size, Scalar > & | toAssign | ) |
Assignment operator for any SmartPointerVector type.
We do not allow assignment of a SmartPointerVector this itself. Consequently, we can insert an ivdep statement and thus allow the compiler to optimise.
| SmartPointerVector< Size, Scalar > & tarch::la::SmartPointerVector< Size, Scalar >::operator= | ( | const Vector< Size, Scalar > & | vector | ) |
Conversion assignment operator.
This operator realises an explicit copy, i.e. we assume that this already holds a valid memory region, so we can take each element of vector and copy it over.
| const Scalar & tarch::la::SmartPointerVector< Size, Scalar >::operator[] | ( | int | index | ) | const |
Returns read-only ref.
to component of given index.
Definition at line 155 of file SmartPointerVector.h.
References tarch::la::SmartPointerVector< Size, Scalar >::_values, assertion3, assertion4, and tarch::toString().

| Scalar & tarch::la::SmartPointerVector< Size, Scalar >::operator[] | ( | int | index | ) |
Returns ref.
to component of given index.
Definition at line 168 of file SmartPointerVector.h.
References tarch::la::SmartPointerVector< Size, Scalar >::_values, assertion3, and tarch::toString().

| int tarch::la::SmartPointerVector< Size, Scalar >::size | ( | ) | const |
Returns the number of components of the SmartPointerVector.
Referenced by peano4.visualisation.input.Patch.Patch::__repr__().

| Vector< Size, Scalar > tarch::la::SmartPointerVector< Size, Scalar >::toVector | ( | ) | const |
|
private |
Definition at line 58 of file SmartPointerVector.h.
|
private |
In the original vector, this is.
Definition at line 56 of file SmartPointerVector.h.
Referenced by tarch::la::SmartPointerVector< Size, Scalar >::data(), tarch::la::SmartPointerVector< Size, Scalar >::data(), tarch::la::SmartPointerVector< Size, Scalar >::operator()(), tarch::la::SmartPointerVector< Size, Scalar >::operator()(), tarch::la::SmartPointerVector< Size, Scalar >::operator[](), and tarch::la::SmartPointerVector< Size, Scalar >::operator[]().