Go to the documentation of this file.
18 #ifndef viskores_cont_ArrayHandleCounting_h
19 #define viskores_cont_ArrayHandleCounting_h
43 template <
class CountingValueType>
44 class VISKORES_ALWAYS_EXPORT ArrayPortalCounting
49 using ValueType = CountingValueType;
65 ArrayPortalCounting(ValueType start, ValueType step,
viskores::Id numValues)
68 , NumberOfValues(numValues)
74 ValueType GetStart()
const {
return this->Start; }
78 ValueType GetStep()
const {
return this->Step; }
82 viskores::Id GetNumberOfValues()
const {
return this->NumberOfValues; }
88 return ValueType(this->Start + this->Step * ValueType(
static_cast<ComponentType
>(index)));
100 template <
typename T>
106 static constexpr
bool IsNumeric =
107 !std::is_same<typename TTraits::NumericTag, viskores::TypeTraitsUnknownTag>::value;
108 static constexpr
bool IsBool = std::is_same<BaseType, bool>::value;
110 static constexpr
bool value = IsNumeric && !IsBool;
116 template <
typename T>
119 static constexpr
bool value = detail::CanCountImpl<T>::value;
122 template <
typename T>
123 using StorageTagCountingSuperclass =
126 template <
typename T>
129 typename std::enable_if<CanCount<T>::value, viskores::cont::StorageTagCounting>::type>
130 : Storage<T, StorageTagCountingSuperclass<T>>
139 template <
typename CountingValueType>
151 :
Superclass(internal::PortalToArrayHandleImplicitBuffers(
152 internal::ArrayPortalCounting<CountingValueType>(start, step, length)))
163 template <
typename CountingValueType>
173 template <
typename S>
174 struct ArrayRangeComputeImpl;
179 template <
typename T>
188 result.
Allocate(Traits::NUM_COMPONENTS);
199 firstAndLast = GetFirstAndLastUnmaskedIndices(maskArray, device);
202 if (firstAndLast[1] < firstAndLast[0])
214 auto firstComponent = Traits::GetComponent(first, cIndex);
215 auto lastComponent = Traits::GetComponent(last, cIndex);
218 viskores::Max(firstComponent, lastComponent)));
238 template <
typename T>
239 struct SerializableTypeString<
viskores::cont::ArrayHandleCounting<T>>
248 template <
typename T>
249 struct SerializableTypeString<
viskores::cont::ArrayHandle<T, viskores::cont::StorageTagCounting>>
250 : SerializableTypeString<viskores::cont::ArrayHandleCounting<T>>
259 template <
typename T>
260 struct Serialization<
viskores::cont::ArrayHandleCounting<T>>
267 static VISKORES_CONT void save(BinaryBuffer& bb,
const BaseType& obj)
269 auto portal = obj.ReadPortal();
270 viskoresdiy::save(bb, portal.GetStart());
271 viskoresdiy::save(bb, portal.GetStep());
272 viskoresdiy::save(bb, portal.GetNumberOfValues());
288 template <
typename T>
289 struct Serialization<
viskores::cont::ArrayHandle<T, viskores::cont::StorageTagCounting>>
290 : Serialization<viskores::cont::ArrayHandleCounting<T>>
296 #endif //viskores_cont_ArrayHandleCounting_h
T load(const U &u, viskores::Id v)
Definition: FetchTagArrayDirectIn.h:44
ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:447
CountingValueType GetStep() const
Definition: ArrayHandleCounting.h:158
#define viskoresNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:136
Manages an array-worth of data.
Definition: ArrayHandle.h:313
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
#define VISKORES_EXEC_CONT
Definition: ExportMacros.h:60
Definition: Particle.h:373
The TypeTraits class provides helpful compile-time information about the basic types used in Viskores...
Definition: TypeTraits.h:69
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
viskores::cont::ArrayHandleCounting< CountingValueType > make_ArrayHandleCounting(CountingValueType start, CountingValueType step, viskores::Id length)
A convenience function for creating an ArrayHandleCounting.
Definition: ArrayHandleCounting.h:165
#define VISKORES_CONT
Definition: ExportMacros.h:65
Groups connected points that have the same field value.
Definition: Atomic.h:27
Traits that can be queried to treat any type as a Vec.
Definition: VecTraits.h:69
void Allocate(viskores::Id numberOfValues, viskores::CopyFlag preserve, viskores::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:504
viskores::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:482
ArrayHandleCounting is a specialization of ArrayHandle.
Definition: ArrayHandleCounting.h:140
typename viskores::cont::detail::GetTypeInParentheses< void(viskores::cont::ArrayHandle< CountingValueType, StorageTagCounting >) >::type Superclass
Definition: ArrayHandleCounting.h:147
An implementation for read-only implicit arrays.
Definition: ArrayHandleImplicit.h:94
WritePortalType WritePortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:468
ArrayHandleCounting(CountingValueType start, CountingValueType step, viskores::Id length)
Definition: ArrayHandleCounting.h:150
An object used to specify a device.
Definition: DeviceAdapterTag.h:66
Represent a continuous scalar range of values.
Definition: Range.h:39
viskores::VecFlat< T > make_VecFlat(const T &vec)
Converts a Vec-like object to a VecFlat.
Definition: VecFlat.h:297
#define VISKORES_ARRAY_HANDLE_SUBCLASS(classname, fullclasstype, superclass)
Macro to make default methods in ArrayHandle subclasses.
Definition: ArrayHandle.h:256
T ComponentType
Type of the components in the vector.
Definition: VecTraits.h:79
void Fill(const ValueType &fillValue, viskores::Id startIndex, viskores::Id endIndex, viskores::cont::Token &token) const
Fills the array with a given value.
Definition: ArrayHandle.h:568
CountingValueType GetStart() const
Definition: ArrayHandleCounting.h:156
T BaseComponentType
Base component type in the vector.
Definition: VecTraits.h:86
auto Get(const viskores::Tuple< Ts... > &tuple)
Retrieve the object from a viskores::Tuple at the given index.
Definition: Tuple.h:89
Definition: ArrayHandleCounting.h:35