fill
¶
Header: "NeoN/fields/fieldFreeFunctions.hpp"
Description¶
The function fill
fills the entire field with a given value or a subfield with a given value if a range is defined.
Definition¶
-
template<typename ValueType>
void NeoN::fill(Vector<ValueType> &a, const std::type_identity_t<ValueType> value, std::pair<size_t, size_t> range = {0, 0})¶ Fill the field with a scalar value using a specific executor.
- Parameters:
field – The field to fill.
value – The scalar value to fill the field with.
range – The range to fill the field in. If not provided, the whole field is filled.
Example¶
// or any other executor CPUExecutor, SerialExecutor
NeoN::Executor = NeoN::GPUExecutor{};
NeoN::Vector<NeoN::scalar> field(exec, 2);
NeoN::fill(field, 1.0);
NeoN::fill(field, 2.0, {1, 2}); // fill a subfield with a value
// copy to host
auto hostVector = field.copyToHost();
for (auto i = 0; i < field.size(); ++i)
{
std::cout << hostVector[i] << std::endl;
}
// prints:
// 1.0
// 2.0