Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polyval operator #508

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs_input/api/polynomials/polyval.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.. _polyval_func:

polyval
=======

Evaluate a polynomial given an input sequence and coefficients

.. doxygenfunction:: polyval(const Op &op, const Coeffs &coeffs)

Examples
~~~~~~~~

.. literalinclude:: ../../../test/00_operators/OperatorTests.cu
:language: cpp
:start-after: example-begin polyval-test-1
:end-before: example-end polyval-test-1
:dedent:

18 changes: 17 additions & 1 deletion include/matx/generators/meshgrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace matx
namespace detail {

template <typename T1, int RANK, int AXIS>
class MeshGridOp {
class MeshGridOp : public BaseOp<MeshGridOp<T1, RANK, AXIS>> {
private:
T1 t1_;
std::array<index_t, RANK> shape_;
Expand Down Expand Up @@ -72,6 +72,22 @@ namespace matx
return shape_[dim];
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PreRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<T1>()) {
t1_.PreRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PostRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<T1>()) {
t1_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}

static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank() { return RANK; }
};

Expand Down
8 changes: 8 additions & 0 deletions include/matx/operators/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ namespace detail {
Exec(std::make_tuple(tmp_out_), std::forward<Executor>(ex));
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PostRun([[maybe_unused]] ShapeType &&shape, [[maybe_unused]] Executor &&ex) const noexcept
{
if constexpr (is_matx_op<OpA>()) {
a_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}

constexpr __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ index_t Size(int dim) const
{
return out_dims_[dim];
Expand Down
12 changes: 12 additions & 0 deletions include/matx/operators/ambgfun.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ namespace matx

Exec(std::make_tuple(tmp_out_), std::forward<Executor>(ex));
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PostRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<OpX>()) {
x_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}

if constexpr (is_matx_op<OpY>()) {
y_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}
};
}

Expand Down
8 changes: 8 additions & 0 deletions include/matx/operators/any.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ namespace detail {
Exec(std::make_tuple(tmp_out_), std::forward<Executor>(ex));
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PostRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<OpA>()) {
a_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}

constexpr __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ index_t Size(int dim) const
{
return out_dims_[dim];
Expand Down
32 changes: 32 additions & 0 deletions include/matx/operators/cart2sph.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,38 @@ namespace matx
index_t size3 = get_expanded_size<Rank()>(z_, dim);
return detail::matx_max(size1, size2, size3);
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PreRun([[maybe_unused]] ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<T1>()) {
x_.PreRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}

if constexpr (is_matx_op<T2>()) {
y_.PreRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}

if constexpr (is_matx_op<T3>()) {
z_.PreRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PostRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<T1>()) {
x_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}

if constexpr (is_matx_op<T2>()) {
y_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}

if constexpr (is_matx_op<T3>()) {
z_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}
};
}
/**
Expand Down
16 changes: 16 additions & 0 deletions include/matx/operators/cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ namespace matx
return static_cast<NewType>(op_(indices...));
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PreRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<T>()) {
op_.PreRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PostRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<T>()) {
op_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}

static __MATX_INLINE__ constexpr __MATX_HOST__ __MATX_DEVICE__ int32_t Rank()
{
return detail::get_rank<T>();
Expand Down
12 changes: 12 additions & 0 deletions include/matx/operators/cgsolve.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ namespace matx

Exec(std::make_tuple(tmp_out_), std::forward<Executor>(ex));
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PostRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<OpA>()) {
a_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}

if constexpr (is_matx_op<OpB>()) {
b_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}
};
}

Expand Down
12 changes: 12 additions & 0 deletions include/matx/operators/channelize_poly.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ namespace detail {
Exec(std::make_tuple(tmp_out_), std::forward<Executor>(ex));
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PostRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<OpA>()) {
a_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}

if constexpr (is_matx_op<FilterType>()) {
f_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}

constexpr __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ index_t Size(int dim) const
{
return out_dims_[dim];
Expand Down
8 changes: 8 additions & 0 deletions include/matx/operators/chol.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ namespace detail {
Exec(std::make_tuple(tmp_out_), std::forward<Executor>(ex));
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PostRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<OpA>()) {
a_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}

// Size is not relevant in eig() since there are multiple return values and it
// is not allowed to be called in larger expressions
constexpr __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ index_t Size(int dim) const
Expand Down
13 changes: 13 additions & 0 deletions include/matx/operators/corr.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,19 @@ namespace matx

Exec(std::make_tuple(tmp_out_), std::forward<Executor>(ex));
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PostRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<OpA>()) {
a_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}


if constexpr (is_matx_op<OpB>()) {
b_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}
};
}

Expand Down
8 changes: 8 additions & 0 deletions include/matx/operators/cov.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ namespace matx

Exec(std::make_tuple(tmp_out_), std::forward<Executor>(ex));
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PostRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<OpA>()) {
a_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}
};
}

Expand Down
8 changes: 8 additions & 0 deletions include/matx/operators/cumsum.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ namespace detail {
Exec(std::make_tuple(tmp_out_), std::forward<Executor>(ex));
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PostRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<OpA>()) {
a_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}

constexpr __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ index_t Size(int dim) const
{
return out_dims_[dim];
Expand Down
8 changes: 8 additions & 0 deletions include/matx/operators/det.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ namespace detail {
Exec(std::make_tuple(tmp_out_), std::forward<Executor>(ex));
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PostRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<OpA>()) {
a_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}

// Size is not relevant in det() since there are multiple return values and it
// is not allowed to be called in larger expressions
constexpr __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ index_t Size(int dim) const
Expand Down
8 changes: 8 additions & 0 deletions include/matx/operators/fft.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ namespace matx

Exec(std::make_tuple(tmp_out_), std::forward<Executor>(ex));
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PostRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<OpA>()) {
a_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}
};
}

Expand Down
8 changes: 8 additions & 0 deletions include/matx/operators/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ namespace detail {

Exec(std::make_tuple(tmp_out_), std::forward<Executor>(ex));
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PostRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<OpA>()) {
a_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}

constexpr __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ index_t Size(int dim) const
{
Expand Down
16 changes: 16 additions & 0 deletions include/matx/operators/flatten.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ namespace matx

return size;
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PreRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<T1>()) {
op1_.PreRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PostRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<T1>()) {
op1_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}
};
}

Expand Down
16 changes: 16 additions & 0 deletions include/matx/operators/hermitian.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ namespace matx
// Optimize these branches later
return (dim < (Rank() - 2)) ? op_.Size(dim) : op_.Size((dim == Rank() - 1) ? Rank() - 2 : Rank() - 1);
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PreRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<T1>()) {
op_.PreRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PostRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<T1>()) {
op_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}
};
}

Expand Down
8 changes: 8 additions & 0 deletions include/matx/operators/hist.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ namespace detail {
Exec(std::make_tuple(tmp_out_), std::forward<Executor>(ex));
}

template <typename ShapeType, typename Executor>
__MATX_INLINE__ void PostRun(ShapeType &&shape, Executor &&ex) const noexcept
{
if constexpr (is_matx_op<OpA>()) {
a_.PostRun(std::forward<ShapeType>(shape), std::forward<Executor>(ex));
}
}

constexpr __MATX_INLINE__ __MATX_HOST__ __MATX_DEVICE__ index_t Size(int dim) const
{
return out_dims_[dim];
Expand Down
Loading