Go to the documentation of this file.
18 #ifndef viskores_cont_ArrayRangeComputeTemplate_h
19 #define viskores_cont_ArrayRangeComputeTemplate_h
44 struct ComputeRangeOptionsDecorator
46 bool IgnoreInf =
false;
48 template <
typename SrcPortal,
typename MaskPortal>
55 using InValueType =
typename SrcPortal::ValueType;
63 if ((this->Mask.GetNumberOfValues() != 0) && (this->Mask.Get(idx) == 0))
68 const auto& inVal = this->Src.Get(idx);
73 if (viskores::IsNan(val) || (this->IgnoreInf && !viskores::IsFinite(val)))
80 outVal[0][i] = outVal[1][i] = val;
88 template <
typename SrcPortal,
typename GhostPortal>
89 Functor<SrcPortal, GhostPortal> CreateFunctor(
const SrcPortal& sp,
const GhostPortal& gp)
const
91 return { sp, gp, this->IgnoreInf };
95 template <
typename ArrayHandleType>
96 struct ArrayValueIsNested
98 static constexpr
bool Value =
99 !viskores::internal::IsFlatVec<typename ArrayHandleType::ValueType>::value;
102 template <typename ArrayHandleType, bool IsNested = ArrayValueIsNested<ArrayHandleType>::Value>
105 template <
typename ArrayHandleType>
106 struct NestedToFlat<ArrayHandleType, true>
108 static auto Transform(
const ArrayHandleType& in)
111 ArrayHandleType>(in);
115 template <
typename ArrayHandleType>
116 struct NestedToFlat<ArrayHandleType, false>
118 static auto Transform(
const ArrayHandleType& in) {
return in; }
121 template <
typename ArrayHandleType>
122 inline auto NestedToFlatTransform(
const ArrayHandleType& input)
131 template <
typename T,
typename S>
135 bool computeFiniteRange,
154 auto flattened = NestedToFlatTransform(input);
155 ComputeRangeOptionsDecorator decorator{ computeFiniteRange };
178 struct ScalarMagnitudeFunctor
180 template <
typename T>
189 struct MagnitudeSquareFunctor
191 template <
typename T>
199 result += comp * comp;
205 template <
typename ArrayHandleType>
208 const ArrayHandleType& input,
210 bool computeFiniteRange,
214 auto rangeAH = ArrayRangeComputeGeneric(mag, maskArray, computeFiniteRange, device);
215 return rangeAH.ReadPortal().Get(0);
218 template <
typename ArrayHandleType>
221 const ArrayHandleType& input,
223 bool computeFiniteRange,
227 auto rangeAH = ArrayRangeComputeGeneric(magsqr, maskArray, computeFiniteRange, device);
229 if (range.IsNonEmpty())
240 template <
typename T,
typename S>
244 bool computeFiniteRange,
258 auto flattened = NestedToFlatTransform(input);
259 return ArrayRangeComputeMagnitudeGenericImpl(
264 template <
typename S>
265 struct ArrayRangeComputeImpl
267 template <
typename T>
271 bool computeFiniteRange,
274 return viskores::cont::internal::ArrayRangeComputeGeneric(
275 input, maskArray, computeFiniteRange, device);
279 template <
typename S>
280 struct ArrayRangeComputeMagnitudeImpl
282 template <
typename T>
285 bool computeFiniteRange,
288 return viskores::cont::internal::ArrayRangeComputeMagnitudeGeneric(
289 input, maskArray, computeFiniteRange, device);
300 template <
typename T,
typename S>
303 bool computeFiniteRange =
false,
310 template <
typename T,
typename S>
314 bool computeFiniteRange =
false,
319 return internal::ArrayRangeComputeImpl<S>{}(input, maskArray, computeFiniteRange, device);
322 template <
typename T,
typename S>
336 template <
typename T,
typename S>
339 bool computeFiniteRange =
false,
346 template <
typename T,
typename S>
350 bool computeFiniteRange =
false,
355 return internal::ArrayRangeComputeMagnitudeImpl<S>{}(
356 input, maskArray, computeFiniteRange, device);
359 template <
typename T,
typename S>
369 template <
typename ArrayHandleType>
370 VISKORES_DEPRECATED(2.1,
"Use precompiled ArrayRangeCompute or ArrayRangeComputeTemplate.")
372 const ArrayHandleType& input,
381 #define VISKORES_ARRAY_RANGE_COMPUTE_DCLR(...) \
382 viskores::cont::ArrayHandle<viskores::Range> viskores::cont::ArrayRangeComputeTemplate( \
383 const viskores::cont::ArrayHandle<__VA_ARGS__>&, \
384 const viskores::cont::ArrayHandle<viskores::UInt8>&, \
386 viskores::cont::DeviceAdapterId)
388 #define VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(...) \
389 viskores::Range viskores::cont::ArrayRangeComputeMagnitudeTemplate( \
390 const viskores::cont::ArrayHandle<__VA_ARGS__>&, \
391 const viskores::cont::ArrayHandle<viskores::UInt8>&, \
393 viskores::cont::DeviceAdapterId)
395 #define VISKORES_ARRAY_RANGE_COMPUTE_INT_SCALARS(modifiers, ...) \
396 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Int8, __VA_ARGS__); \
397 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::Int8, __VA_ARGS__); \
398 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::UInt8, __VA_ARGS__); \
399 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::UInt8, __VA_ARGS__); \
400 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Int16, __VA_ARGS__); \
401 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::Int16, __VA_ARGS__); \
402 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::UInt16, __VA_ARGS__); \
403 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::UInt16, __VA_ARGS__); \
404 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Int32, __VA_ARGS__); \
405 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::Int32, __VA_ARGS__); \
406 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::UInt32, __VA_ARGS__); \
407 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::UInt32, __VA_ARGS__); \
408 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Int64, __VA_ARGS__); \
409 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::Int64, __VA_ARGS__); \
410 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::UInt64, __VA_ARGS__); \
411 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::UInt64, __VA_ARGS__)
413 #define VISKORES_ARRAY_RANGE_COMPUTE_FLOAT_SCALARS(modifiers, ...) \
414 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Float32, __VA_ARGS__); \
415 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::Float32, __VA_ARGS__); \
416 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Float64, __VA_ARGS__); \
417 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::Float64, __VA_ARGS__)
419 #define VISKORES_ARRAY_RANGE_COMPUTE_BOOL_SCALARS(modifiers, ...) \
420 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(bool, __VA_ARGS__); \
421 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(bool, __VA_ARGS__)
423 #define VISKORES_ARRAY_RANGE_COMPUTE_OTHER_SCALARS(modifiers, ...) \
424 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(char, __VA_ARGS__); \
425 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(char, __VA_ARGS__); \
426 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(signed VISKORES_UNUSED_INT_TYPE, __VA_ARGS__); \
427 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(signed VISKORES_UNUSED_INT_TYPE, __VA_ARGS__); \
428 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(unsigned VISKORES_UNUSED_INT_TYPE, __VA_ARGS__); \
429 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(unsigned VISKORES_UNUSED_INT_TYPE, __VA_ARGS__)
431 #define VISKORES_ARRAY_RANGE_COMPUTE_ALL_SCALARS(modifiers, ...) \
432 VISKORES_ARRAY_RANGE_COMPUTE_INT_SCALARS(modifiers, __VA_ARGS__); \
433 VISKORES_ARRAY_RANGE_COMPUTE_FLOAT_SCALARS(modifiers, __VA_ARGS__); \
434 VISKORES_ARRAY_RANGE_COMPUTE_BOOL_SCALARS(modifiers, __VA_ARGS__); \
435 VISKORES_ARRAY_RANGE_COMPUTE_OTHER_SCALARS(modifiers, __VA_ARGS__)
437 #define VISKORES_ARRAY_RANGE_COMPUTE_INT_VECN(modifiers, N, ...) \
438 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Vec<viskores::Int8, N>, __VA_ARGS__); \
439 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::Vec<viskores::Int8, N>, __VA_ARGS__); \
440 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Vec<viskores::UInt8, N>, __VA_ARGS__); \
441 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::Vec<viskores::UInt8, N>, __VA_ARGS__); \
442 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Vec<viskores::Int16, N>, __VA_ARGS__); \
443 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::Vec<viskores::Int16, N>, __VA_ARGS__); \
444 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Vec<viskores::UInt16, N>, __VA_ARGS__); \
445 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::Vec<viskores::UInt16, N>, \
447 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Vec<viskores::Int32, N>, __VA_ARGS__); \
448 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::Vec<viskores::Int32, N>, __VA_ARGS__); \
449 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Vec<viskores::UInt32, N>, __VA_ARGS__); \
450 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::Vec<viskores::UInt32, N>, \
452 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Vec<viskores::Int64, N>, __VA_ARGS__); \
453 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::Vec<viskores::Int64, N>, __VA_ARGS__); \
454 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Vec<viskores::UInt64, N>, __VA_ARGS__); \
455 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::Vec<viskores::UInt64, N>, __VA_ARGS__)
457 #define VISKORES_ARRAY_RANGE_COMPUTE_FLOAT_VECN(modifiers, N, ...) \
458 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Vec<viskores::Float32, N>, __VA_ARGS__); \
459 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::Vec<viskores::Float32, N>, \
461 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Vec<viskores::Float64, N>, __VA_ARGS__); \
462 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::Vec<viskores::Float64, N>, __VA_ARGS__)
464 #define VISKORES_ARRAY_RANGE_COMPUTE_BOOL_VECN(modifiers, N, ...) \
465 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Vec<bool, N>, __VA_ARGS__); \
466 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::Vec<bool, N>, __VA_ARGS__)
468 #define VISKORES_ARRAY_RANGE_COMPUTE_OTHER_VECN(modifiers, N, ...) \
469 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Vec<char, N>, __VA_ARGS__); \
470 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR(viskores::Vec<char, N>, __VA_ARGS__); \
471 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Vec<signed VISKORES_UNUSED_INT_TYPE, N>, \
473 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR( \
474 viskores::Vec<signed VISKORES_UNUSED_INT_TYPE, N>, __VA_ARGS__); \
475 modifiers VISKORES_ARRAY_RANGE_COMPUTE_DCLR(viskores::Vec<unsigned VISKORES_UNUSED_INT_TYPE, N>, \
477 modifiers VISKORES_ARRAY_RANGE_COMPUTE_MAG_DCLR( \
478 viskores::Vec<unsigned VISKORES_UNUSED_INT_TYPE, N>, __VA_ARGS__)
480 #define VISKORES_ARRAY_RANGE_COMPUTE_ALL_VECN(modifiers, N, ...) \
481 VISKORES_ARRAY_RANGE_COMPUTE_INT_VECN(modifiers, N, __VA_ARGS__); \
482 VISKORES_ARRAY_RANGE_COMPUTE_FLOAT_VECN(modifiers, N, __VA_ARGS__); \
483 VISKORES_ARRAY_RANGE_COMPUTE_BOOL_VECN(modifiers, N, __VA_ARGS__); \
484 VISKORES_ARRAY_RANGE_COMPUTE_OTHER_VECN(modifiers, N, __VA_ARGS__)
491 struct StorageTagSOA;
493 template <
typename ST1,
typename ST2,
typename ST3>
494 struct StorageTagCartesianProduct;
496 struct StorageTagConstant;
498 struct StorageTagCounting;
500 struct StorageTagXGCCoordinates;
502 struct StorageTagStride;
554 extern template VISKORES_CONT_TEMPLATE_EXPORT,
565 StorageTagXGCCoordinates);
645 #endif //viskores_cont_ArrayRangeComputeTemplate_h
viskores::Range ArrayRangeComputeMagnitudeTemplate(const viskores::cont::ArrayHandle< T, S > &input, bool computeFiniteRange=false, viskores::cont::DeviceAdapterId device=viskores::cont::DeviceAdapterTagAny{})
Templated version of ArrayRangeComputeMagnitude.
Definition: ArrayRangeComputeTemplate.h:337
ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:447
#define VISKORES_LOG_SCOPE(level,...)
Definition: Logging.h:219
auto Transform(const TupleType &&tuple, Function &&f) -> decltype(Apply(tuple, detail::TupleTransformFunctor(), std::forward< Function >(f)))
Construct a new viskores::Tuple by applying a function to each value.
Definition: Tuple.h:221
viskores::Float64 Min
The minumum value of the range (inclusive).
Definition: Range.h:42
Cast the values of an array to the specified type, on demand.
Definition: ArrayHandleCast.h:151
Definition: ArrayHandleConstant.h:35
viskores::VecTraitsTagSingleComponent HasMultipleComponents
A tag specifying whether this vector has multiple components (i.e.
Definition: VecTraits.h:113
static U Reduce(viskores::cont::DeviceAdapterId devId, const viskores::cont::ArrayHandle< T, CIn > &input, U initialValue)
Definition: Algorithm.h:672
#define VISKORES_ARRAY_RANGE_COMPUTE_FLOAT_SCALARS(modifiers,...)
Definition: ArrayRangeComputeTemplate.h:413
A tag for vectors that are "true" vectors (i.e.
Definition: VecTraits.h:31
Tag for a device adapter used to specify that any device may be used for an operation.
Definition: DeviceAdapterTag.h:194
#define VISKORES_ARRAY_RANGE_COMPUTE_INT_SCALARS(modifiers,...)
Definition: ArrayRangeComputeTemplate.h:395
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
A tag for the basic implementation of a Storage object.
Definition: ArrayHandle.h:53
#define VISKORES_EXEC_CONT
Definition: ExportMacros.h:60
viskores::Float32 Sqrt(viskores::Float32 x)
Definition: Math.h:951
viskores::Float64 Max
Tha maximum value of the range (inclusive).
Definition: Range.h:44
static const ComponentType & GetComponent(const T &vector, viskores::IdComponent)
Returns the value in a given component of the vector.
Definition: VecTraits.h:125
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
static constexpr viskores::IdComponent GetNumberOfComponents(const T &)
Returns the number of components in the given vector.
Definition: VecTraits.h:102
Groups connected points that have the same field value.
Definition: Atomic.h:27
static constexpr viskores::IdComponent NUM_COMPONENTS
Number of components in the vector.
Definition: VecTraits.h:93
Traits that can be queried to treat any type as a Vec.
Definition: VecTraits.h:69
#define VISKORES_DEPRECATED(...)
Definition: Deprecated.h:156
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
#define VISKORES_ASSERT(condition)
Definition: Assert.h:51
WritePortalType WritePortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:468
#define VISKORES_ARRAY_RANGE_COMPUTE_OTHER_SCALARS(modifiers,...)
Definition: ArrayRangeComputeTemplate.h:423
An object used to specify a device.
Definition: DeviceAdapterTag.h:66
Represent a continuous scalar range of values.
Definition: Range.h:39
ArrayHandleDecorator< typename std::decay< DecoratorImplT >::type, typename std::decay< ArrayTs >::type... > make_ArrayHandleDecorator(viskores::Id numValues, DecoratorImplT &&f, ArrayTs &&... arrays)
Create an ArrayHandleDecorator with the specified number of values that uses the provided DecoratorIm...
Definition: ArrayHandleDecorator.h:713
#define VISKORES_ARRAY_RANGE_COMPUTE_ALL_VECN(modifiers, N,...)
Definition: ArrayRangeComputeTemplate.h:480
#define VISKORES_ARRAY_RANGE_COMPUTE_FLOAT_VECN(modifiers, N,...)
Definition: ArrayRangeComputeTemplate.h:457
#define VISKORES_INSTANTIATION_BEGIN
The following empty macros are instantiation delimiters used by vtk_add_instantiations at CMake/Visko...
Definition: Instantiations.h:55
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
detail::FloatingPointReturnType< T >::Type Magnitude(const T &x)
Returns the magnitude of a vector.
Definition: VectorAnalysis.h:108
@ Perf
General timing data and algorithm flow information, such as filter execution, worklet dispatches,...
Definition: ArrayHandleCartesianProduct.h:169
#define VISKORES_ARRAY_RANGE_COMPUTE_INT_VECN(modifiers, N,...)
Definition: ArrayRangeComputeTemplate.h:437
viskores::cont::ArrayHandle< viskores::Range > ArrayRangeComputeTemplate(const viskores::cont::ArrayHandle< T, S > &input, bool computeFiniteRange=false, viskores::cont::DeviceAdapterId device=viskores::cont::DeviceAdapterTagAny{})
Templated version of ArrayRangeCompute.
Definition: ArrayRangeComputeTemplate.h:301
#define VISKORES_INSTANTIATION_END
Definition: Instantiations.h:56
viskores::cont::ArrayHandleTransform< HandleType, FunctorType > make_ArrayHandleTransform(HandleType handle, FunctorType functor)
make_ArrayHandleTransform is convenience function to generate an ArrayHandleTransform.
Definition: ArrayHandleTransform.h:495
#define VISKORES_ARRAY_RANGE_COMPUTE_OTHER_VECN(modifiers, N,...)
Definition: ArrayRangeComputeTemplate.h:468
#define VISKORES_ARRAY_RANGE_COMPUTE_ALL_SCALARS(modifiers,...)
Definition: ArrayRangeComputeTemplate.h:431
double Float64
Base type to use for 64-bit floating-point numbers.
Definition: Types.h:169
Definition: ArrayHandleCounting.h:35
viskores::cont::ArrayHandle< viskores::Range > ArrayRangeCompute(const viskores::cont::UnknownArrayHandle &array, bool computeFiniteRange=false, viskores::cont::DeviceAdapterId device=viskores::cont::DeviceAdapterTagAny{})
Compute the range of the data in an array handle.
A short fixed-length array.
Definition: Types.h:365
Binary Predicate that takes two arguments argument x, and y and returns a viskores::Vec<T,...
Definition: BinaryOperators.h:120