// // Copyright (C) 2011-15 DyND Developers // BSD 2-Clause License, see LICENSE.txt // #pragma once #include #include namespace dynd { namespace nd { template struct min_kernel : base_strided_kernel, 1> { typedef typename type_of::type src0_type; typedef src0_type dst_type; void single(char *dst, char *const *src) { if (*reinterpret_cast(src[0]) < *reinterpret_cast(dst)) { *reinterpret_cast(dst) = *reinterpret_cast(src[0]); } } void strided(char *dst, intptr_t dst_stride, char *const *src, const intptr_t *src_stride, size_t count) { char *src0 = src[0]; intptr_t src0_stride = src_stride[0]; for (size_t i = 0; i < count; ++i) { if (*reinterpret_cast(src0) < *reinterpret_cast(dst)) { *reinterpret_cast(dst) = *reinterpret_cast(src0); } dst += dst_stride; src0 += src0_stride; } } }; template <> struct min_kernel : base_strided_kernel, 1> { typedef complex src0_type; typedef src0_type dst_type; void single(char *DYND_UNUSED(dst), char *const *DYND_UNUSED(src)) { throw std::runtime_error("nd::min is not implemented for complex types"); } }; template <> struct min_kernel : base_strided_kernel, 1> { typedef complex src0_type; typedef src0_type dst_type; void single(char *DYND_UNUSED(dst), char *const *DYND_UNUSED(src)) { throw std::runtime_error("nd::min is not implemented for complex types"); } }; } // namespace dynd::nd namespace ndt { template struct traits> { static type equivalent() { return callable_type::make(ndt::make_type::dst_type>(), type(Src0TypeID)); } }; } // namespace dynd::ndt } // namespace dynd