vtkm::Vec now supports +=, -=, *=, and /=.

It is common to write template code that needs to operate across both
scalar and vector values. To facilitate code like this we are required
to provide these common operators.
This commit is contained in:
Robert Maynard 2016-11-11 16:26:20 -05:00
parent 7a52fa3940
commit 9caabf97ce

@ -491,6 +491,16 @@ public:
return result;
}
VTKM_EXEC_CONT_EXPORT
DerivedClass& operator+=(const DerivedClass& other)
{
for (vtkm::IdComponent i = 0; i < Size; ++i)
{
this->Components[i] += other[i];
}
return *static_cast<DerivedClass*>(this);
}
VTKM_EXEC_CONT_EXPORT
DerivedClass operator-(const DerivedClass& other) const
{
@ -502,6 +512,16 @@ public:
return result;
}
VTKM_EXEC_CONT_EXPORT
DerivedClass& operator-=(const DerivedClass& other)
{
for (vtkm::IdComponent i = 0; i < Size; ++i)
{
this->Components[i] -= other[i];
}
return *static_cast<DerivedClass*>(this);
}
VTKM_EXEC_CONT_EXPORT
DerivedClass operator*(const DerivedClass& other) const
{
@ -513,6 +533,16 @@ public:
return result;
}
VTKM_EXEC_CONT_EXPORT
DerivedClass& operator*=(const DerivedClass& other)
{
for (vtkm::IdComponent i = 0; i < Size; ++i)
{
this->Components[i] *= other[i];
}
return *static_cast<DerivedClass*>(this);
}
VTKM_EXEC_CONT_EXPORT
DerivedClass operator/(const DerivedClass& other) const
{
@ -524,6 +554,16 @@ public:
return result;
}
VTKM_EXEC_CONT_EXPORT
DerivedClass& operator/=(const DerivedClass& other)
{
for (vtkm::IdComponent i = 0; i < Size; ++i)
{
this->Components[i] /= other[i];
}
return *static_cast<DerivedClass*>(this);
}
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
#pragma GCC diagnostic pop
#endif // gcc || clang