Go to the documentation of this file.
18 #ifndef viskores_cont_ArrayHandleConstant_h
19 #define viskores_cont_ArrayHandleConstant_h
42 template <
typename ValueType>
43 struct VISKORES_ALWAYS_EXPORT ConstantFunctor
46 ConstantFunctor(
const ValueType& value = ValueType())
59 using StorageTagConstantSuperclass =
63 struct Storage<T,
viskores::cont::StorageTagConstant> : Storage<T, StorageTagConstantSuperclass<T>>
90 :
Superclass(internal::FunctorToArrayHandleImplicitBuffers(internal::ConstantFunctor<T>(value),
104 template <
typename T>
117 template <
typename T>
126 "Cannot extract component of ArrayHandleConstant without copying. "
127 "(However, the whole array does not need to be copied.)");
142 template <
typename S>
143 struct ArrayRangeComputeImpl;
146 struct VISKORES_CONT_EXPORT ArrayRangeComputeImpl<
viskores::cont::StorageTagConstant>
148 template <
typename T>
152 bool computeFiniteRange,
155 bool allMasked =
false;
159 auto ids = GetFirstAndLastUnmaskedIndices(maskArray, devId);
160 allMasked = (ids[1] < ids[0]);
166 result.
Allocate(value.GetNumberOfComponents());
171 if (allMasked || (computeFiniteRange && !viskores::IsFinite(comp)))
184 template <
typename S>
185 struct ArrayRangeComputeMagnitudeImpl;
188 struct VISKORES_CONT_EXPORT ArrayRangeComputeMagnitudeImpl<
viskores::cont::StorageTagConstant>
190 template <
typename T>
194 bool computeFiniteRange,
200 auto ids = GetFirstAndLastUnmaskedIndices(maskArray, devId);
209 return (computeFiniteRange && !viskores::IsFinite(rangeValue))
228 template <
typename T>
229 struct SerializableTypeString<
viskores::cont::ArrayHandleConstant<T>>
238 template <
typename T>
239 struct SerializableTypeString<
viskores::cont::ArrayHandle<T, viskores::cont::StorageTagConstant>>
240 : SerializableTypeString<viskores::cont::ArrayHandleConstant<T>>
249 template <
typename T>
250 struct Serialization<
viskores::cont::ArrayHandleConstant<T>>
257 static VISKORES_CONT void save(BinaryBuffer& bb,
const BaseType& obj)
259 viskoresdiy::save(bb, obj.GetNumberOfValues());
260 viskoresdiy::save(bb, obj.ReadPortal().Get(0));
275 template <
typename T>
276 struct Serialization<
viskores::cont::ArrayHandle<T, viskores::cont::StorageTagConstant>>
277 : Serialization<viskores::cont::ArrayHandleConstant<T>>
284 #endif //viskores_cont_ArrayHandleConstant_h
T load(const U &u, viskores::Id v)
Definition: FetchTagArrayDirectIn.h:44
Treat a Vec or Vec-like object as a flat Vec.
Definition: VecFlat.h:240
ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:447
typename viskores::cont::detail::GetTypeInParentheses< void(viskores::cont::ArrayHandle< T, viskores::cont::StorageTagConstant >) >::type Superclass
Definition: ArrayHandleConstant.h:85
Definition: ArrayHandleConstant.h:35
#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
viskores::cont::ArrayHandleConstant< T > make_ArrayHandleConstant(T value, viskores::Id numberOfValues)
make_ArrayHandleConstant is convenience function to generate an ArrayHandleImplicit.
Definition: ArrayHandleConstant.h:105
Definition: Particle.h:373
ArrayHandleConstant(T value, viskores::Id numberOfValues=0)
Construct a constant array containing the given value.
Definition: ArrayHandleConstant.h:89
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
#define VISKORES_CONT
Definition: ExportMacros.h:65
Groups connected points that have the same field value.
Definition: Atomic.h:27
T GetValue() const
Returns the constant value stored in this array.
Definition: ArrayHandleConstant.h:99
An array handle with a constant value.
Definition: ArrayHandleConstant.h:78
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
WritePortalType WritePortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:468
An object used to specify a device.
Definition: DeviceAdapterTag.h:66
Represent a continuous scalar range of values.
Definition: Range.h:39
This class is thrown when a Viskores function or method encounters an invalid value that inhibits pro...
Definition: ErrorBadValue.h:33
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
detail::FloatingPointReturnType< T >::Type Magnitude(const T &x)
Returns the magnitude of a vector.
Definition: VectorAnalysis.h:108
An ArrayHandle that computes values on the fly.
Definition: ArrayHandleImplicit.h:186
auto Get(const viskores::Tuple< Ts... > &tuple)
Retrieve the object from a viskores::Tuple at the given index.
Definition: Tuple.h:89
CopyFlag
Identifier used to specify whether a function should deep copy data.
Definition: Flags.h:25
double Float64
Base type to use for 64-bit floating-point numbers.
Definition: Types.h:169
viskores::cont::ArrayHandleStride< T > make_ArrayHandleStride(const viskores::cont::ArrayHandle< T, viskores::cont::StorageTagBasic > &array, viskores::Id numValues, viskores::Id stride, viskores::Id offset, viskores::Id modulo=0, viskores::Id divisor=1)
Create an array by adding a stride to a basic array.
Definition: ArrayHandleStride.h:433
viskores::cont::ArrayHandleBasic< T > make_ArrayHandle(const T *array, viskores::Id numberOfValues, viskores::CopyFlag copy)
A convenience function for creating an ArrayHandle from a standard C array.
Definition: ArrayHandleBasic.h:285