示例#1
0
static void linspace_specialization(double start, double stop, intptr_t count, nd::array& result)
{
    intptr_t stride = result.get_strides()[0];
    char *dst = result.get_readwrite_originptr();
    for (intptr_t i = 0; i < count; ++i, dst += stride) {
        double val = ((count - i - 1) * start + i * stop) / double(count - 1);
        *reinterpret_cast<double *>(dst) = val;
    }
}
示例#2
0
static void linspace_specialization(float start, float stop, intptr_t count, nd::array& result)
{
    intptr_t stride = result.get_strides()[0];
    char *dst = result.get_readwrite_originptr();
    for (intptr_t i = 0; i < count; ++i, dst += stride) {
        double val = ((count - i - 1) * double(start) + i * double(stop)) / double(count - 1);
        *reinterpret_cast<float *>(dst) = static_cast<float>(val);
    }
}
示例#3
0
static void linspace_specialization(dynd_complex<double> start, dynd_complex<double> stop, intptr_t count, nd::array& result)
{
    intptr_t stride = result.get_strides()[0];
    char *dst = result.get_readwrite_originptr();
    for (intptr_t i = 0; i < count; ++i, dst += stride) {
        dynd_complex<double> val = (double(count - i - 1) * dynd_complex<double>(start) +
                        double(i) * dynd_complex<double>(stop)) / double(count - 1);
        *reinterpret_cast<dynd_complex<double> *>(dst) = val;
    }
}