mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
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:
parent
7a52fa3940
commit
9caabf97ce
40
vtkm/Types.h
40
vtkm/Types.h
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user