mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Change VectorTraits to VecTraits.
Matches the previous move from Tuple to Vec. We can unify on this name.
This commit is contained in:
parent
2139d93206
commit
c3fbe073e8
@ -26,7 +26,7 @@ set(headers
|
||||
TypeListTag.h
|
||||
Types.h
|
||||
TypeTraits.h
|
||||
VectorTraits.h
|
||||
VecTraits.h
|
||||
)
|
||||
|
||||
vtkm_declare_headers(${headers})
|
||||
|
@ -37,7 +37,7 @@ struct TypeTraitsRealTag {};
|
||||
struct TypeTraitsIntegerTag {};
|
||||
|
||||
/// Tag used to identify 0 dimensional types (scalars). Scalars can also be
|
||||
/// treated like vectors when used with VectorTraits. A TypeTraits class will
|
||||
/// treated like vectors when used with VecTraits. A TypeTraits class will
|
||||
/// typedef this class to DimensionalityTag.
|
||||
///
|
||||
struct TypeTraitsScalarTag {};
|
||||
|
@ -17,8 +17,8 @@
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_VectorTraits_h
|
||||
#define vtk_m_VectorTraits_h
|
||||
#ifndef vtk_m_VecTraits_h
|
||||
#define vtk_m_VecTraits_h
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
@ -29,62 +29,63 @@ namespace vtkm {
|
||||
/// A tag for vectors that are "true" vectors (i.e. have more than one
|
||||
/// component).
|
||||
///
|
||||
struct VectorTraitsTagMultipleComponents { };
|
||||
struct VecTraitsTagMultipleComponents { };
|
||||
|
||||
/// A tag for vectors that a really just scalars (i.e. have only one component)
|
||||
/// A tag for vectors that are really just scalars (i.e. have only one
|
||||
/// component)
|
||||
///
|
||||
struct VectorTraitsTagSingleComponent { };
|
||||
struct VecTraitsTagSingleComponent { };
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<vtkm::IdComponent numComponents>
|
||||
struct VectorTraitsMultipleComponentChooser
|
||||
struct VecTraitsMultipleComponentChooser
|
||||
{
|
||||
typedef VectorTraitsTagMultipleComponents Type;
|
||||
typedef VecTraitsTagMultipleComponents Type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct VectorTraitsMultipleComponentChooser<1>
|
||||
struct VecTraitsMultipleComponentChooser<1>
|
||||
{
|
||||
typedef VectorTraitsTagSingleComponent Type;
|
||||
typedef VecTraitsTagSingleComponent Type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// The VectorTraits class gives several static members that define how
|
||||
/// The VecTraits class gives several static members that define how
|
||||
/// to use a given type as a vector.
|
||||
///
|
||||
template<class VectorType>
|
||||
struct VectorTraits
|
||||
template<class VecType>
|
||||
struct VecTraits
|
||||
#ifdef VTKM_DOXYGEN_ONLY
|
||||
{
|
||||
/// Type of the components in the vector.
|
||||
///
|
||||
typedef typename VectorType::ComponentType ComponentType;
|
||||
typedef typename VecType::ComponentType ComponentType;
|
||||
|
||||
/// Number of components in the vector.
|
||||
///
|
||||
static const vtkm::IdComponent NUM_COMPONENTS = VectorType::NUM_COMPONENTS;
|
||||
static const vtkm::IdComponent NUM_COMPONENTS = VecType::NUM_COMPONENTS;
|
||||
|
||||
/// A tag specifying whether this vector has multiple components (i.e. is a
|
||||
/// "real" vector). This tag can be useful for creating specialized functions
|
||||
/// when a vector is really just a scalar.
|
||||
///
|
||||
typedef typename internal::VectorTraitsMultipleComponentChooser<
|
||||
typedef typename internal::VecTraitsMultipleComponentChooser<
|
||||
NUM_COMPONENTS>::Type HasMultipleComponents;
|
||||
|
||||
/// Returns the value in a given component of the vector.
|
||||
///
|
||||
VTKM_EXEC_CONT_EXPORT static const ComponentType &GetComponent(
|
||||
const typename boost::remove_const<VectorType>::type &vector,
|
||||
const typename boost::remove_const<VecType>::type &vector,
|
||||
vtkm::IdComponent component);
|
||||
VTKM_EXEC_CONT_EXPORT static ComponentType &GetComponent(
|
||||
typename boost::remove_const<VectorType>::type &vector,
|
||||
typename boost::remove_const<VecType>::type &vector,
|
||||
vtkm::IdComponent component);
|
||||
|
||||
/// Changes the value in a given component of the vector.
|
||||
///
|
||||
VTKM_EXEC_CONT_EXPORT static void SetComponent(VectorType &vector,
|
||||
VTKM_EXEC_CONT_EXPORT static void SetComponent(VecType &vector,
|
||||
vtkm::IdComponent component,
|
||||
ComponentType value);
|
||||
|
||||
@ -92,55 +93,55 @@ struct VectorTraits
|
||||
///
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
static vtkm::Vec<ComponentType,NUM_COMPONENTS>
|
||||
ToVec(const VectorType &vector);
|
||||
ToVec(const VecType &vector);
|
||||
};
|
||||
#else // VTKM_DOXYGEN_ONLY
|
||||
;
|
||||
#endif // VTKM_DOXYGEN_ONLY
|
||||
|
||||
// This partial specialization allows you to define a non-const version of
|
||||
// VectorTraits and have it still work for const version.
|
||||
// VecTraits and have it still work for const version.
|
||||
//
|
||||
template<typename T>
|
||||
struct VectorTraits<const T> : VectorTraits<T>
|
||||
struct VecTraits<const T> : VecTraits<T>
|
||||
{ };
|
||||
|
||||
template<typename T, vtkm::IdComponent Size>
|
||||
struct VectorTraits<vtkm::Vec<T,Size> >
|
||||
struct VecTraits<vtkm::Vec<T,Size> >
|
||||
{
|
||||
typedef vtkm::Vec<T,Size> VectorType;
|
||||
typedef vtkm::Vec<T,Size> VecType;
|
||||
|
||||
/// Type of the components in the vector.
|
||||
///
|
||||
typedef typename VectorType::ComponentType ComponentType;
|
||||
typedef typename VecType::ComponentType ComponentType;
|
||||
|
||||
/// Number of components in the vector.
|
||||
///
|
||||
static const vtkm::IdComponent NUM_COMPONENTS = VectorType::NUM_COMPONENTS;
|
||||
static const vtkm::IdComponent NUM_COMPONENTS = VecType::NUM_COMPONENTS;
|
||||
|
||||
/// A tag specifying whether this vector has multiple components (i.e. is a
|
||||
/// "real" vector). This tag can be useful for creating specialized functions
|
||||
/// when a vector is really just a scalar.
|
||||
///
|
||||
typedef typename internal::VectorTraitsMultipleComponentChooser<
|
||||
typedef typename internal::VecTraitsMultipleComponentChooser<
|
||||
NUM_COMPONENTS>::Type HasMultipleComponents;
|
||||
|
||||
/// Returns the value in a given component of the vector.
|
||||
///
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
static const ComponentType &GetComponent(const VectorType &vector,
|
||||
static const ComponentType &GetComponent(const VecType &vector,
|
||||
vtkm::IdComponent component)
|
||||
{
|
||||
return vector[component];
|
||||
}
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
static ComponentType &GetComponent(VectorType &vector, vtkm::IdComponent component) {
|
||||
static ComponentType &GetComponent(VecType &vector, vtkm::IdComponent component) {
|
||||
return vector[component];
|
||||
}
|
||||
|
||||
/// Changes the value in a given component of the vector.
|
||||
///
|
||||
VTKM_EXEC_CONT_EXPORT static void SetComponent(VectorType &vector,
|
||||
VTKM_EXEC_CONT_EXPORT static void SetComponent(VecType &vector,
|
||||
vtkm::IdComponent component,
|
||||
ComponentType value) {
|
||||
vector[component] = value;
|
||||
@ -150,20 +151,20 @@ struct VectorTraits<vtkm::Vec<T,Size> >
|
||||
///
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
static vtkm::Vec<ComponentType,NUM_COMPONENTS>
|
||||
ToVec(const VectorType &vector)
|
||||
ToVec(const VecType &vector)
|
||||
{
|
||||
return vector;
|
||||
}
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
/// Used for overriding VectorTraits for basic scalar types.
|
||||
/// Used for overriding VecTraits for basic scalar types.
|
||||
///
|
||||
template<typename ScalarType>
|
||||
struct VectorTraitsBasic {
|
||||
struct VecTraitsBasic {
|
||||
typedef ScalarType ComponentType;
|
||||
static const vtkm::IdComponent NUM_COMPONENTS = 1;
|
||||
typedef VectorTraitsTagSingleComponent HasMultipleComponents;
|
||||
typedef VecTraitsTagSingleComponent HasMultipleComponents;
|
||||
|
||||
VTKM_EXEC_CONT_EXPORT static const ComponentType &GetComponent(
|
||||
const ScalarType &vector,
|
||||
@ -191,11 +192,11 @@ struct VectorTraitsBasic {
|
||||
|
||||
#define VTKM_BASIC_TYPE_VECTOR(type) \
|
||||
template<> \
|
||||
struct VectorTraits<type> \
|
||||
: public vtkm::internal::VectorTraitsBasic<type> { }/*; \
|
||||
struct VecTraits<type> \
|
||||
: public vtkm::internal::VecTraitsBasic<type> { }/*; \
|
||||
template<> \
|
||||
struct VectorTraits<const type> \
|
||||
: public vtkm::internal::VectorTraitsBasic<type> { }*/
|
||||
struct VecTraits<const type> \
|
||||
: public vtkm::internal::VecTraitsBasic<type> { }*/
|
||||
|
||||
/// Allows you to treat basic types as if they were vectors.
|
||||
|
||||
@ -214,4 +215,4 @@ VTKM_BASIC_TYPE_VECTOR(vtkm::UInt64);
|
||||
|
||||
}
|
||||
|
||||
#endif //vtk_m_VectorTraits_h
|
||||
#endif //vtk_m_VecTraits_h
|
@ -24,7 +24,7 @@
|
||||
#include <vtkm/cont/ErrorControlBadValue.h>
|
||||
#include <vtkm/cont/ErrorControlInternal.h>
|
||||
|
||||
#include <vtkm/VectorTraits.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
#include <vtkm/internal/FunctionInterface.h>
|
||||
|
||||
@ -41,7 +41,7 @@ template<typename ValueType>
|
||||
struct CompositeVectorSwizzleFunctor
|
||||
{
|
||||
static const vtkm::IdComponent NUM_COMPONENTS =
|
||||
vtkm::VectorTraits<ValueType>::NUM_COMPONENTS;
|
||||
vtkm::VecTraits<ValueType>::NUM_COMPONENTS;
|
||||
typedef vtkm::Vec<vtkm::IdComponent, NUM_COMPONENTS> ComponentMapType;
|
||||
|
||||
// Caution! This is a reference.
|
||||
@ -56,24 +56,24 @@ struct CompositeVectorSwizzleFunctor
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
ValueType operator()(const T1 &p1) const {
|
||||
return ValueType(
|
||||
vtkm::VectorTraits<T1>::GetComponent(p1, this->SourceComponents[0]));
|
||||
vtkm::VecTraits<T1>::GetComponent(p1, this->SourceComponents[0]));
|
||||
}
|
||||
|
||||
template<typename T1, typename T2>
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
ValueType operator()(const T1 &p1, const T2 &p2) const {
|
||||
return ValueType(
|
||||
vtkm::VectorTraits<T1>::GetComponent(p1, this->SourceComponents[0]),
|
||||
vtkm::VectorTraits<T2>::GetComponent(p2, this->SourceComponents[1]));
|
||||
vtkm::VecTraits<T1>::GetComponent(p1, this->SourceComponents[0]),
|
||||
vtkm::VecTraits<T2>::GetComponent(p2, this->SourceComponents[1]));
|
||||
}
|
||||
|
||||
template<typename T1, typename T2, typename T3>
|
||||
VTKM_EXEC_CONT_EXPORT
|
||||
ValueType operator()(const T1 &p1, const T2 &p2, const T3 &p3) const {
|
||||
return ValueType(
|
||||
vtkm::VectorTraits<T1>::GetComponent(p1, this->SourceComponents[0]),
|
||||
vtkm::VectorTraits<T2>::GetComponent(p2, this->SourceComponents[1]),
|
||||
vtkm::VectorTraits<T3>::GetComponent(p3, this->SourceComponents[2]));
|
||||
vtkm::VecTraits<T1>::GetComponent(p1, this->SourceComponents[0]),
|
||||
vtkm::VecTraits<T2>::GetComponent(p2, this->SourceComponents[1]),
|
||||
vtkm::VecTraits<T3>::GetComponent(p3, this->SourceComponents[2]));
|
||||
}
|
||||
|
||||
template<typename T1, typename T2, typename T3, typename T4>
|
||||
@ -83,10 +83,10 @@ struct CompositeVectorSwizzleFunctor
|
||||
const T3 &p3,
|
||||
const T4 &p4) const {
|
||||
return ValueType(
|
||||
vtkm::VectorTraits<T1>::GetComponent(p1, this->SourceComponents[0]),
|
||||
vtkm::VectorTraits<T2>::GetComponent(p2, this->SourceComponents[1]),
|
||||
vtkm::VectorTraits<T3>::GetComponent(p3, this->SourceComponents[2]),
|
||||
vtkm::VectorTraits<T4>::GetComponent(p4, this->SourceComponents[3]));
|
||||
vtkm::VecTraits<T1>::GetComponent(p1, this->SourceComponents[0]),
|
||||
vtkm::VecTraits<T2>::GetComponent(p2, this->SourceComponents[1]),
|
||||
vtkm::VecTraits<T3>::GetComponent(p3, this->SourceComponents[2]),
|
||||
vtkm::VecTraits<T4>::GetComponent(p4, this->SourceComponents[3]));
|
||||
}
|
||||
};
|
||||
|
||||
@ -171,7 +171,7 @@ class ArrayPortalCompositeVector
|
||||
public:
|
||||
typedef typename PortalTypes::ResultType ValueType;
|
||||
static const vtkm::IdComponent NUM_COMPONENTS =
|
||||
vtkm::VectorTraits<ValueType>::NUM_COMPONENTS;
|
||||
vtkm::VecTraits<ValueType>::NUM_COMPONENTS;
|
||||
|
||||
BOOST_STATIC_ASSERT(NUM_COMPONENTS == PortalTypes::ARITY);
|
||||
|
||||
@ -222,7 +222,7 @@ class ArrayPortalCompositeVectorCont
|
||||
public:
|
||||
typedef typename FunctionInterfaceArrays::ResultType ValueType;
|
||||
static const vtkm::IdComponent NUM_COMPONENTS =
|
||||
vtkm::VectorTraits<ValueType>::NUM_COMPONENTS;
|
||||
vtkm::VecTraits<ValueType>::NUM_COMPONENTS;
|
||||
typedef vtkm::Vec<vtkm::IdComponent, NUM_COMPONENTS> ComponentMapType;
|
||||
|
||||
// If you get a compile error here, it means you probably tried to create
|
||||
@ -607,7 +607,7 @@ template<typename ArrayHandleType1,
|
||||
struct ArrayHandleCompositeVectorType
|
||||
{
|
||||
private:
|
||||
typedef typename vtkm::VectorTraits<typename ArrayHandleType1::ValueType>::ComponentType
|
||||
typedef typename vtkm::VecTraits<typename ArrayHandleType1::ValueType>::ComponentType
|
||||
ComponentType;
|
||||
typedef vtkm::Vec<ComponentType,4> Signature(
|
||||
ArrayHandleType1,ArrayHandleType2,ArrayHandleType3,ArrayHandleType4);
|
||||
@ -622,7 +622,7 @@ struct ArrayHandleCompositeVectorType<
|
||||
ArrayHandleType1,ArrayHandleType2,ArrayHandleType3>
|
||||
{
|
||||
private:
|
||||
typedef typename vtkm::VectorTraits<typename ArrayHandleType1::ValueType>::ComponentType
|
||||
typedef typename vtkm::VecTraits<typename ArrayHandleType1::ValueType>::ComponentType
|
||||
ComponentType;
|
||||
typedef vtkm::Vec<ComponentType,3> Signature(
|
||||
ArrayHandleType1,ArrayHandleType2,ArrayHandleType3);
|
||||
@ -635,7 +635,7 @@ template<typename ArrayHandleType1,
|
||||
struct ArrayHandleCompositeVectorType<ArrayHandleType1,ArrayHandleType2>
|
||||
{
|
||||
private:
|
||||
typedef typename vtkm::VectorTraits<typename ArrayHandleType1::ValueType>::ComponentType
|
||||
typedef typename vtkm::VecTraits<typename ArrayHandleType1::ValueType>::ComponentType
|
||||
ComponentType;
|
||||
typedef vtkm::Vec<ComponentType,2> Signature(
|
||||
ArrayHandleType1,ArrayHandleType2);
|
||||
@ -647,7 +647,7 @@ template<typename ArrayHandleType1>
|
||||
struct ArrayHandleCompositeVectorType<ArrayHandleType1>
|
||||
{
|
||||
private:
|
||||
typedef typename vtkm::VectorTraits<typename ArrayHandleType1::ValueType>::ComponentType
|
||||
typedef typename vtkm::VecTraits<typename ArrayHandleType1::ValueType>::ComponentType
|
||||
ComponentType;
|
||||
typedef ComponentType Signature(ArrayHandleType1);
|
||||
public:
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <vtkm/cont/internal/ArrayPortalFromIterators.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/VectorTraits.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
namespace {
|
||||
|
||||
@ -31,7 +31,7 @@ struct TemplatedTests
|
||||
static const vtkm::Id ARRAY_SIZE = 10;
|
||||
|
||||
typedef T ValueType;
|
||||
typedef typename vtkm::VectorTraits<ValueType>::ComponentType ComponentType;
|
||||
typedef typename vtkm::VecTraits<ValueType>::ComponentType ComponentType;
|
||||
|
||||
ValueType ExpectedValue(vtkm::Id index, ComponentType value)
|
||||
{
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include <vtkm/cont/internal/IteratorFromArrayPortal.h>
|
||||
|
||||
#include <vtkm/VectorTraits.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
#include <vtkm/cont/internal/ArrayPortalFromIterators.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
@ -33,7 +33,7 @@ struct TemplatedTests
|
||||
static const vtkm::Id ARRAY_SIZE = 10;
|
||||
|
||||
typedef T ValueType;
|
||||
typedef typename vtkm::VectorTraits<ValueType>::ComponentType ComponentType;
|
||||
typedef typename vtkm::VecTraits<ValueType>::ComponentType ComponentType;
|
||||
|
||||
ValueType ExpectedValue(vtkm::Id index, ComponentType value)
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ struct SortLess
|
||||
VTKM_EXEC_CONT_EXPORT bool compare(const T& a,const T& b,
|
||||
vtkm::TypeTraitsVectorTag) const
|
||||
{
|
||||
const vtkm::IdComponent SIZE = vtkm::VectorTraits<T>::NUM_COMPONENTS;
|
||||
const vtkm::IdComponent SIZE = vtkm::VecTraits<T>::NUM_COMPONENTS;
|
||||
bool valid = true;
|
||||
for(vtkm::IdComponent i=0; (i < SIZE) && valid; ++i)
|
||||
{
|
||||
@ -92,7 +92,7 @@ struct SortGreater
|
||||
VTKM_EXEC_CONT_EXPORT bool compare(const T& a,const T& b,
|
||||
vtkm::TypeTraitsVectorTag) const
|
||||
{
|
||||
const vtkm::IdComponent SIZE = vtkm::VectorTraits<T>::NUM_COMPONENTS;
|
||||
const vtkm::IdComponent SIZE = vtkm::VecTraits<T>::NUM_COMPONENTS;
|
||||
bool valid = true;
|
||||
for(vtkm::IdComponent i=0; (i < SIZE) && valid; ++i)
|
||||
{
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include <vtkm/cont/ArrayHandleCompositeVector.h>
|
||||
|
||||
#include <vtkm/VectorTraits.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
#include <vtkm/cont/DeviceAdapterSerial.h>
|
||||
#include <vtkm/cont/StorageBasic.h>
|
||||
@ -51,7 +51,7 @@ template<typename ValueType>
|
||||
vtkm::cont::ArrayHandle<ValueType, StorageTag>
|
||||
MakeInputArray(int arrayId)
|
||||
{
|
||||
typedef vtkm::VectorTraits<ValueType> VTraits;
|
||||
typedef vtkm::VecTraits<ValueType> VTraits;
|
||||
|
||||
// Create a buffer with valid test values.
|
||||
ValueType buffer[ARRAY_SIZE];
|
||||
@ -96,7 +96,7 @@ void CheckArray(const vtkm::cont::ArrayHandle<ValueType,C> &outArray,
|
||||
|
||||
typename ArrayHandleType::PortalConstControl portal =
|
||||
arrayCopy.GetPortalConstControl();
|
||||
typedef vtkm::VectorTraits<ValueType> VTraits;
|
||||
typedef vtkm::VecTraits<ValueType> VTraits;
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
||||
{
|
||||
ValueType retreivedValue = portal.Get(index);
|
||||
@ -148,19 +148,19 @@ void TryVector4(vtkm::cont::ArrayHandle<T1,StorageTag> array1,
|
||||
vtkm::IdComponent inComponents[4];
|
||||
|
||||
for (inComponents[0] = 0;
|
||||
inComponents[0] < vtkm::VectorTraits<T1>::NUM_COMPONENTS;
|
||||
inComponents[0] < vtkm::VecTraits<T1>::NUM_COMPONENTS;
|
||||
inComponents[0]++)
|
||||
{
|
||||
for (inComponents[1] = 0;
|
||||
inComponents[1] < vtkm::VectorTraits<T2>::NUM_COMPONENTS;
|
||||
inComponents[1] < vtkm::VecTraits<T2>::NUM_COMPONENTS;
|
||||
inComponents[1]++)
|
||||
{
|
||||
for (inComponents[2] = 0;
|
||||
inComponents[2] < vtkm::VectorTraits<T3>::NUM_COMPONENTS;
|
||||
inComponents[2] < vtkm::VecTraits<T3>::NUM_COMPONENTS;
|
||||
inComponents[2]++)
|
||||
{
|
||||
for (inComponents[3] = 0;
|
||||
inComponents[3] < vtkm::VectorTraits<T4>::NUM_COMPONENTS;
|
||||
inComponents[3] < vtkm::VecTraits<T4>::NUM_COMPONENTS;
|
||||
inComponents[3]++)
|
||||
{
|
||||
CheckArray(
|
||||
@ -186,15 +186,15 @@ void TryVector3(vtkm::cont::ArrayHandle<T1,StorageTag> array1,
|
||||
vtkm::IdComponent inComponents[3];
|
||||
|
||||
for (inComponents[0] = 0;
|
||||
inComponents[0] < vtkm::VectorTraits<T1>::NUM_COMPONENTS;
|
||||
inComponents[0] < vtkm::VecTraits<T1>::NUM_COMPONENTS;
|
||||
inComponents[0]++)
|
||||
{
|
||||
for (inComponents[1] = 0;
|
||||
inComponents[1] < vtkm::VectorTraits<T2>::NUM_COMPONENTS;
|
||||
inComponents[1] < vtkm::VecTraits<T2>::NUM_COMPONENTS;
|
||||
inComponents[1]++)
|
||||
{
|
||||
for (inComponents[2] = 0;
|
||||
inComponents[2] < vtkm::VectorTraits<T3>::NUM_COMPONENTS;
|
||||
inComponents[2] < vtkm::VecTraits<T3>::NUM_COMPONENTS;
|
||||
inComponents[2]++)
|
||||
{
|
||||
CheckArray(
|
||||
@ -222,11 +222,11 @@ void TryVector2(vtkm::cont::ArrayHandle<T1,StorageTag> array1,
|
||||
vtkm::IdComponent inComponents[2];
|
||||
|
||||
for (inComponents[0] = 0;
|
||||
inComponents[0] < vtkm::VectorTraits<T1>::NUM_COMPONENTS;
|
||||
inComponents[0] < vtkm::VecTraits<T1>::NUM_COMPONENTS;
|
||||
inComponents[0]++)
|
||||
{
|
||||
for (inComponents[1] = 0;
|
||||
inComponents[1] < vtkm::VectorTraits<T2>::NUM_COMPONENTS;
|
||||
inComponents[1] < vtkm::VecTraits<T2>::NUM_COMPONENTS;
|
||||
inComponents[1]++)
|
||||
{
|
||||
CheckArray(
|
||||
@ -251,7 +251,7 @@ void TryVector1(vtkm::cont::ArrayHandle<T1,StorageTag> array1)
|
||||
vtkm::IdComponent inComponents[1];
|
||||
|
||||
for (inComponents[0] = 0;
|
||||
inComponents[0] < vtkm::VectorTraits<T1>::NUM_COMPONENTS;
|
||||
inComponents[0] < vtkm::VecTraits<T1>::NUM_COMPONENTS;
|
||||
inComponents[0]++)
|
||||
{
|
||||
CheckArray(
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include <vtkm/cont/ArrayPortalToIterators.h>
|
||||
|
||||
#include <vtkm/VectorTraits.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
@ -32,7 +32,7 @@ struct TemplatedTests
|
||||
static const vtkm::Id ARRAY_SIZE = 10;
|
||||
|
||||
typedef T ValueType;
|
||||
typedef typename vtkm::VectorTraits<ValueType>::ComponentType ComponentType;
|
||||
typedef typename vtkm::VecTraits<ValueType>::ComponentType ComponentType;
|
||||
|
||||
static ValueType ExpectedValue(vtkm::Id index, ComponentType value)
|
||||
{
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <vtkm/cont/StorageBasic.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/VectorTraits.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
namespace {
|
||||
|
||||
@ -56,7 +56,7 @@ struct TemplatedTests
|
||||
return true;
|
||||
}
|
||||
|
||||
typename vtkm::VectorTraits<ValueType>::ComponentType STOLEN_ARRAY_VALUE()
|
||||
typename vtkm::VecTraits<ValueType>::ComponentType STOLEN_ARRAY_VALUE()
|
||||
{
|
||||
return 4529;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
#define VTKM_STORAGE VTKM_STORAGE_ERROR
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/VectorTraits.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/StorageImplicit.h>
|
||||
|
@ -21,6 +21,7 @@
|
||||
set(headers
|
||||
Testing.h
|
||||
OptionParser.h
|
||||
VecTraitsTests.h
|
||||
)
|
||||
|
||||
VTKM_declare_headers(${headers})
|
||||
@ -32,7 +33,7 @@ set(unit_tests
|
||||
UnitTestTypeListTag.cxx
|
||||
UnitTestTypes.cxx
|
||||
UnitTestTypeTraits.cxx
|
||||
UnitTestVectorTraits.cxx
|
||||
UnitTestVecTraits.cxx
|
||||
)
|
||||
|
||||
VTKM_unit_tests(SOURCES ${unit_tests})
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/TypeTraits.h>
|
||||
#include <vtkm/VectorTraits.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@ -303,7 +303,7 @@ bool test_equal(VectorType vector1,
|
||||
VectorType vector2,
|
||||
vtkm::Scalar tolerance = 0.0001)
|
||||
{
|
||||
typedef typename vtkm::VectorTraits<VectorType> Traits;
|
||||
typedef typename vtkm::VecTraits<VectorType> Traits;
|
||||
for (vtkm::IdComponent component = 0;
|
||||
component < Traits::NUM_COMPONENTS;
|
||||
component++)
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include <vtkm/TypeTraits.h>
|
||||
|
||||
#include <vtkm/VectorTraits.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
#include <vtkm/testing/Testing.h>
|
||||
|
||||
@ -41,14 +41,14 @@ private:
|
||||
void TestDimensionality(T, vtkm::TypeTraitsScalarTag)
|
||||
{
|
||||
std::cout << " scalar" << std::endl;
|
||||
VTKM_TEST_ASSERT(vtkm::VectorTraits<T>::NUM_COMPONENTS == 1,
|
||||
VTKM_TEST_ASSERT(vtkm::VecTraits<T>::NUM_COMPONENTS == 1,
|
||||
"Scalar type does not have one component.");
|
||||
}
|
||||
template <typename T>
|
||||
void TestDimensionality(T, vtkm::TypeTraitsVectorTag)
|
||||
{
|
||||
std::cout << " vector" << std::endl;
|
||||
VTKM_TEST_ASSERT(vtkm::VectorTraits<T>::NUM_COMPONENTS > 1,
|
||||
VTKM_TEST_ASSERT(vtkm::VecTraits<T>::NUM_COMPONENTS > 1,
|
||||
"Vector type does not have multiple components.");
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ private:
|
||||
void TestNumeric(T, vtkm::TypeTraitsIntegerTag)
|
||||
{
|
||||
std::cout << " integer" << std::endl;
|
||||
typedef typename vtkm::VectorTraits<T>::ComponentType VT;
|
||||
typedef typename vtkm::VecTraits<T>::ComponentType VT;
|
||||
VT value = VT(2.001);
|
||||
VTKM_TEST_ASSERT(value == 2, "Integer does not round to integer.");
|
||||
}
|
||||
@ -64,7 +64,7 @@ private:
|
||||
void TestNumeric(T, vtkm::TypeTraitsRealTag)
|
||||
{
|
||||
std::cout << " real" << std::endl;
|
||||
typedef typename vtkm::VectorTraits<T>::ComponentType VT;
|
||||
typedef typename vtkm::VecTraits<T>::ComponentType VT;
|
||||
VT value = VT(2.001);
|
||||
VTKM_TEST_ASSERT(test_equal(float(value), float(2.001)),
|
||||
"Real does not hold floaing point number.");
|
||||
|
@ -17,49 +17,49 @@
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
#include <vtkm/testing/VectorTraitsTests.h>
|
||||
#include <vtkm/testing/VecTraitsTests.h>
|
||||
|
||||
#include <vtkm/testing/Testing.h>
|
||||
|
||||
namespace {
|
||||
|
||||
static const vtkm::Id MAX_VECTOR_SIZE = 5;
|
||||
static const vtkm::Id VectorInit[MAX_VECTOR_SIZE] = { 42, 54, 67, 12, 78 };
|
||||
static const vtkm::Id VecInit[MAX_VECTOR_SIZE] = { 42, 54, 67, 12, 78 };
|
||||
|
||||
struct TestVectorTypeFunctor
|
||||
struct TestVecTypeFunctor
|
||||
{
|
||||
template <typename T> void operator()(const T&) const
|
||||
{
|
||||
typedef vtkm::VectorTraits<T> Traits;
|
||||
typedef vtkm::VecTraits<T> Traits;
|
||||
typedef typename Traits::ComponentType ComponentType;
|
||||
VTKM_TEST_ASSERT(Traits::NUM_COMPONENTS <= MAX_VECTOR_SIZE,
|
||||
"Need to update test for larger vectors.");
|
||||
T vector;
|
||||
for (vtkm::IdComponent index = 0; index < Traits::NUM_COMPONENTS; index++)
|
||||
{
|
||||
Traits::SetComponent(vector, index, ComponentType(VectorInit[index]));
|
||||
Traits::SetComponent(vector, index, ComponentType(VecInit[index]));
|
||||
}
|
||||
vtkm::testing::TestVectorType(vector);
|
||||
vtkm::testing::TestVecType(vector);
|
||||
}
|
||||
};
|
||||
|
||||
void TestVectorTraits()
|
||||
void TestVecTraits()
|
||||
{
|
||||
TestVectorTypeFunctor test;
|
||||
TestVecTypeFunctor test;
|
||||
vtkm::testing::Testing::TryAllTypes(test);
|
||||
std::cout << "vtkm::Vec<vtkm::Scalar, 5>" << std::endl;
|
||||
test(vtkm::Vec<vtkm::Scalar,5>());
|
||||
|
||||
vtkm::testing::TestVectorComponentsTag<vtkm::Id3>();
|
||||
vtkm::testing::TestVectorComponentsTag<vtkm::Vector3>();
|
||||
vtkm::testing::TestVectorComponentsTag<vtkm::Vector4>();
|
||||
vtkm::testing::TestVecComponentsTag<vtkm::Id3>();
|
||||
vtkm::testing::TestVecComponentsTag<vtkm::Vector3>();
|
||||
vtkm::testing::TestVecComponentsTag<vtkm::Vector4>();
|
||||
vtkm::testing::TestScalarComponentsTag<vtkm::Id>();
|
||||
vtkm::testing::TestScalarComponentsTag<vtkm::Scalar>();
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestVectorTraits(int, char *[])
|
||||
int UnitTestVecTraits(int, char *[])
|
||||
{
|
||||
return vtkm::testing::Testing::Run(TestVectorTraits);
|
||||
return vtkm::testing::Testing::Run(TestVecTraits);
|
||||
}
|
@ -17,10 +17,10 @@
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
#ifndef vtkm_testing_VectorTraitsTest_h
|
||||
#define vtkm_testing_VectorTraitsTest_h
|
||||
#ifndef vtkm_testing_VecTraitsTest_h
|
||||
#define vtkm_testing_VecTraitsTest_h
|
||||
|
||||
#include <vtkm/VectorTraits.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
#include <vtkm/TypeTraits.h>
|
||||
|
||||
@ -34,12 +34,12 @@ namespace testing {
|
||||
namespace detail {
|
||||
|
||||
inline void CompareDimensionalityTags(vtkm::TypeTraitsScalarTag,
|
||||
vtkm::VectorTraitsTagSingleComponent)
|
||||
vtkm::VecTraitsTagSingleComponent)
|
||||
{
|
||||
// If we are here, everything is fine.
|
||||
}
|
||||
inline void CompareDimensionalityTags(vtkm::TypeTraitsVectorTag,
|
||||
vtkm::VectorTraitsTagMultipleComponents)
|
||||
vtkm::VecTraitsTagMultipleComponents)
|
||||
{
|
||||
// If we are here, everything is fine.
|
||||
}
|
||||
@ -47,10 +47,10 @@ inline void CompareDimensionalityTags(vtkm::TypeTraitsVectorTag,
|
||||
/// Compares some manual arithmetic through type traits to arithmetic with
|
||||
/// the Tuple class.
|
||||
template <class T>
|
||||
static void TestVectorTypeImpl(
|
||||
static void TestVecTypeImpl(
|
||||
const typename boost::remove_const<T>::type &vector)
|
||||
{
|
||||
typedef typename vtkm::VectorTraits<T> Traits;
|
||||
typedef typename vtkm::VecTraits<T> Traits;
|
||||
typedef typename Traits::ComponentType ComponentType;
|
||||
static const int NUM_COMPONENTS = Traits::NUM_COMPONENTS;
|
||||
typedef typename boost::remove_const<T>::type NonConstT;
|
||||
@ -97,10 +97,10 @@ static void TestVectorTypeImpl(
|
||||
// This will fail to compile if the tags are wrong.
|
||||
detail::CompareDimensionalityTags(
|
||||
typename vtkm::TypeTraits<T>::DimensionalityTag(),
|
||||
typename vtkm::VectorTraits<T>::HasMultipleComponents());
|
||||
typename vtkm::VecTraits<T>::HasMultipleComponents());
|
||||
}
|
||||
|
||||
inline void CheckVectorComponentsTag(vtkm::VectorTraitsTagMultipleComponents)
|
||||
inline void CheckVecComponentsTag(vtkm::VecTraitsTagMultipleComponents)
|
||||
{
|
||||
// If we are running here, everything is fine.
|
||||
}
|
||||
@ -112,17 +112,17 @@ inline void CheckVectorComponentsTag(vtkm::VectorTraitsTagMultipleComponents)
|
||||
/// have multiple components.
|
||||
///
|
||||
template<class T>
|
||||
inline void TestVectorComponentsTag()
|
||||
inline void TestVecComponentsTag()
|
||||
{
|
||||
// This will fail to compile if the tag is wrong
|
||||
// (i.e. not vtkm::VectorTraitsTagMultipleComponents)
|
||||
detail::CheckVectorComponentsTag(
|
||||
typename vtkm::VectorTraits<T>::HasMultipleComponents());
|
||||
// (i.e. not vtkm::VecTraitsTagMultipleComponents)
|
||||
detail::CheckVecComponentsTag(
|
||||
typename vtkm::VecTraits<T>::HasMultipleComponents());
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
inline void CheckScalarComponentsTag(vtkm::VectorTraitsTagSingleComponent)
|
||||
inline void CheckScalarComponentsTag(vtkm::VecTraitsTagSingleComponent)
|
||||
{
|
||||
// If we are running here, everything is fine.
|
||||
}
|
||||
@ -132,10 +132,10 @@ inline void CheckScalarComponentsTag(vtkm::VectorTraitsTagSingleComponent)
|
||||
/// Compares some manual arithmetic through type traits to arithmetic with
|
||||
/// the Tuple class.
|
||||
template <class T>
|
||||
static void TestVectorType(const T &vector)
|
||||
static void TestVecType(const T &vector)
|
||||
{
|
||||
detail::TestVectorTypeImpl<T>(vector);
|
||||
detail::TestVectorTypeImpl<const T>(vector);
|
||||
detail::TestVecTypeImpl<T>(vector);
|
||||
detail::TestVecTypeImpl<const T>(vector);
|
||||
}
|
||||
|
||||
/// Checks to make sure that the HasMultipleComponents tag is actually for a
|
||||
@ -146,12 +146,12 @@ template<class T>
|
||||
inline void TestScalarComponentsTag()
|
||||
{
|
||||
// This will fail to compile if the tag is wrong
|
||||
// (i.e. not vtkm::VectorTraitsTagSingleComponent)
|
||||
// (i.e. not vtkm::VecTraitsTagSingleComponent)
|
||||
detail::CheckScalarComponentsTag(
|
||||
typename vtkm::VectorTraits<T>::HasMultipleComponents());
|
||||
typename vtkm::VecTraits<T>::HasMultipleComponents());
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace vtkm::testing
|
||||
|
||||
#endif //vtkm_testing_VectorTraitsTest_h
|
||||
#endif //vtkm_testing_VecTraitsTest_h
|
Loading…
Reference in New Issue
Block a user