diff --git a/pocketfft_hdronly.h b/pocketfft_hdronly.h index e821e6220950b24dea662774243940247931b1aa..81b3be9e7bbd4df29d1812fde0e84902f39c41a8 100644 --- a/pocketfft_hdronly.h +++ b/pocketfft_hdronly.h @@ -1,18 +1,46 @@ /* - * This file is part of pocketfft. - * Licensed under a 3-clause BSD style license - see LICENSE.md - */ - -/* - * Main implementation file. - * - * Copyright (C) 2004-2019 Max-Planck-Society - * \author Martin Reinecke - */ +This file is part of pocketfft. + +Copyright (C) 2010-2019 Max-Planck-Society +Author: Martin Reinecke + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. +* Neither the name of the copyright holder nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ #ifndef POCKETFFT_HDRONLY_H #define POCKETFFT_HDRONLY_H +#ifndef __cplusplus +#error This file is C++ and requires a C++ compiler +#endif + +#if __cplusplus < 201103L +#error This file requires at least C++11 support +#endif + #include #include #include @@ -2409,6 +2437,7 @@ template void c2c(const shape_t &shape, const stride_t &stride_in, const std::complex *data_in, std::complex *data_out, T fct) { using namespace detail; + if (util::prod(shape)==0) return; util::sanity_check(shape, stride_in, stride_out, data_in==data_out, axes); ndarr> ain(data_in, shape, stride_in), aout(data_out, shape, stride_out); @@ -2420,9 +2449,12 @@ template void r2c(const shape_t &shape_in, const T *data_in, std::complex *data_out, T fct) { using namespace detail; + if (util::prod(shape_in)==0) return; util::sanity_check(shape_in, stride_in, stride_out, false, axis); ndarr ain(data_in, shape_in, stride_in); - ndarr> aout(data_out, shape_in, stride_out); // FIXME + shape_t shape_out(shape_in); + shape_out[axis] = shape_in[axis]/2 + 1; + ndarr> aout(data_out, shape_out, stride_out); general_r2c(ain, aout, axis, fct); } @@ -2431,6 +2463,7 @@ template void r2c(const shape_t &shape_in, const T *data_in, std::complex *data_out, T fct) { using namespace detail; + if (util::prod(shape_in)==0) return; util::sanity_check(shape_in, stride_in, stride_out, false, axes); r2c(shape_in, stride_in, stride_out, axes.back(), data_in, data_out, fct); if (axes.size()==1) return; @@ -2447,6 +2480,7 @@ template void c2r(const shape_t &shape_out, const std::complex *data_in, T *data_out, T fct) { using namespace detail; + if (util::prod(shape_out)==0) return; util::sanity_check(shape_out, stride_in, stride_out, false, axis); shape_t shape_in(shape_out); shape_in[axis] = shape_out[axis]/2 + 1; @@ -2460,6 +2494,7 @@ template void c2r(const shape_t &shape_out, const std::complex *data_in, T *data_out, T fct) { using namespace detail; + if (util::prod(shape_out)==0) return; if (axes.size()==1) { c2r(shape_out, stride_in, stride_out, axes[0], data_in, data_out, fct); @@ -2486,6 +2521,7 @@ template void r2r_fftpack(const shape_t &shape, bool forward, const T *data_in, T *data_out, T fct) { using namespace detail; + if (util::prod(shape)==0) return; util::sanity_check(shape, stride_in, stride_out, data_in==data_out, axis); ndarr ain(data_in, shape, stride_in), aout(data_out, shape, stride_out); general_r(ain, aout, axis, forward, fct); @@ -2496,6 +2532,7 @@ template void r2r_hartley(const shape_t &shape, const T *data_in, T *data_out, T fct) { using namespace detail; + if (util::prod(shape)==0) return; util::sanity_check(shape, stride_in, stride_out, data_in==data_out, axes); ndarr ain(data_in, shape, stride_in), aout(data_out, shape, stride_out); general_hartley(ain, aout, axes, fct);