mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Add vtkm/BinaryOperators header.
Currently includes the following predicates: - Sum - Product - Maximum - Minimum - BitwiseAnd - BitwiseOr - BitwiseXor
This commit is contained in:
parent
f20b1ea99a
commit
8839e8a019
116
vtkm/BinaryOperators.h
Normal file
116
vtkm/BinaryOperators.h
Normal file
@ -0,0 +1,116 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//
|
||||
// Copyright 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_BinaryOperators_h
|
||||
#define vtk_m_BinaryOperators_h
|
||||
|
||||
#include <vtkm/internal/ExportMacros.h>
|
||||
|
||||
namespace vtkm {
|
||||
|
||||
/// Binary Predicate that takes two arguments argument \c x, and \c y and
|
||||
/// returns sum (addition) of the two values.
|
||||
/// Note: Requires Type \p T implement the + operator.
|
||||
struct Sum
|
||||
{
|
||||
template<typename T>
|
||||
VTKM_EXEC_CONT_EXPORT T operator()(const T& x, const T& y) const
|
||||
{
|
||||
return x + y;
|
||||
}
|
||||
};
|
||||
|
||||
/// Binary Predicate that takes two arguments argument \c x, and \c y and
|
||||
/// returns product (multiplication) of the two values.
|
||||
/// Note: Requires Type \p T implement the * operator.
|
||||
struct Product
|
||||
{
|
||||
template<typename T>
|
||||
VTKM_EXEC_CONT_EXPORT T operator()(const T& x, const T& y) const
|
||||
{
|
||||
return x * y;
|
||||
}
|
||||
};
|
||||
|
||||
/// Binary Predicate that takes two arguments argument \c x, and \c y and
|
||||
/// returns the \c x if x > y otherwise returns \c y.
|
||||
/// Note: Requires Type \p T implement the < operator.
|
||||
//needs to be full length to not clash with vtkm::math function Max.
|
||||
struct Maximum
|
||||
{
|
||||
template<typename T>
|
||||
VTKM_EXEC_CONT_EXPORT T operator()(const T& x, const T& y) const
|
||||
{
|
||||
return x < y ? y: x;
|
||||
}
|
||||
};
|
||||
|
||||
/// Binary Predicate that takes two arguments argument \c x, and \c y and
|
||||
/// returns the \c x if x < y otherwise returns \c y.
|
||||
/// Note: Requires Type \p T implement the < operator.
|
||||
//needs to be full length to not clash with vtkm::math function Min.
|
||||
struct Minimum
|
||||
{
|
||||
template<typename T>
|
||||
VTKM_EXEC_CONT_EXPORT T operator()(const T& x, const T& y) const
|
||||
{
|
||||
return x < y ? x: y;
|
||||
}
|
||||
};
|
||||
|
||||
/// Binary Predicate that takes two arguments argument \c x, and \c y and
|
||||
/// returns the bitwise operation <tt>x&y</tt>
|
||||
/// Note: Requires Type \p T implement the & operator.
|
||||
struct BitwiseAnd
|
||||
{
|
||||
template<typename T>
|
||||
VTKM_EXEC_CONT_EXPORT T operator()(const T& x, const T& y) const
|
||||
{
|
||||
return x & y;
|
||||
}
|
||||
};
|
||||
|
||||
/// Binary Predicate that takes two arguments argument \c x, and \c y and
|
||||
/// returns the bitwise operation <tt>x|y</tt>
|
||||
/// Note: Requires Type \p T implement the | operator.
|
||||
struct BitwiseOr
|
||||
{
|
||||
template<typename T>
|
||||
VTKM_EXEC_CONT_EXPORT T operator()(const T& x, const T& y) const
|
||||
{
|
||||
return x | y;
|
||||
}
|
||||
};
|
||||
|
||||
/// Binary Predicate that takes two arguments argument \c x, and \c y and
|
||||
/// returns the bitwise operation <tt>x^y</tt>
|
||||
/// Note: Requires Type \p T implement the ^ operator.
|
||||
struct BitwiseXor
|
||||
{
|
||||
template<typename T>
|
||||
VTKM_EXEC_CONT_EXPORT T operator()(const T& x, const T& y) const
|
||||
{
|
||||
return x ^ y;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace vtkm
|
||||
|
||||
#endif //vtk_m_BinaryOperators_h
|
@ -20,7 +20,7 @@
|
||||
#ifndef vtk_m_BinaryPredicates_h
|
||||
#define vtk_m_BinaryPredicates_h
|
||||
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/internal/ExportMacros.h>
|
||||
|
||||
namespace vtkm {
|
||||
|
||||
|
@ -22,6 +22,7 @@ include_directories(${Boost_INCLUDE_DIRS})
|
||||
|
||||
set(headers
|
||||
BinaryPredicates.h
|
||||
BinaryOperators.h
|
||||
CellType.h
|
||||
Extent.h
|
||||
ListTag.h
|
||||
|
Loading…
Reference in New Issue
Block a user