<commit_before>//=======================================================================
// Copyright (c) 2017 <NAME>
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

#include "egblas/pow.hpp"

template <typename T>
__global__ void pow_yx_kernel(size_t n, T alpha, const T* x, size_t incx, T* y, size_t incy) {
    auto index  = threadIdx.x + blockIdx.x * blockDim.x;
    auto stride = blockDim.x * gridDim.x;

    for (; index < n; index += stride) {
        y[incy * index] = alpha * pow(y[incy * index], x[incx * index]);
    }
}

template <>
__global__ void pow_yx_kernel(size_t n, cuComplex alpha, const cuComplex* x, size_t incx, cuComplex* y, size_t incy) {
    auto index  = threadIdx.x + blockIdx.x * blockDim.x;
    auto stride = blockDim.x * gridDim.x;

    for (; index < n; index += stride) {
        auto x_ =  x[incx * index];
        auto y_ =  y[incy * index];

        float c_abs = hypot(y_.x, y_.y);
        float c_arg = atan2f(y_.y, y_.x);

        auto logx = make_cuComplex(logf(c_abs), c_arg);
        auto ylogx = cuCmulf(x_, logx);

        float e = expf(ylogx.x);
        auto res = make_cuComplex(e * cosf(ylogx.y), e * sinf(ylogx.y));

        y[incy * index] = cuCmulf(alpha, res);
    }
}

template <>
__global__ void pow_yx_kernel(size_t n, cuDoubleComplex alpha, const cuDoubleComplex* x, size_t incx, cuDoubleComplex* y, size_t incy) {
    auto index  = threadIdx.x + blockIdx.x * blockDim.x;
    auto stride = blockDim.x * gridDim.x;

    for (; index < n; index += stride) {
        auto x_ =  x[incx * index];
        auto y_ =  y[incy * index];

        double c_abs = hypot(y_.x, y_.y);
        double c_arg = atan2(y_.y, y_.x);

        auto logx = make_cuDoubleComplex(log(c_abs), c_arg);
        auto ylogx = cuCmul(x_, logx);

        double e = expf(ylogx.x);
        auto res = make_cuDoubleComplex(e * cos(ylogx.y), e * sin(ylogx.y));

        y[incy * index] = cuCmul(alpha, res);
    }
}

template <typename T>
__global__ void pow_yx_kernel1(size_t n, const T* x, size_t incx, T* y, size_t incy) {
    auto index  = threadIdx.x + blockIdx.x * blockDim.x;
    auto stride = blockDim.x * gridDim.x;

    for (; index < n; index += stride) {
        y[incy * index] = pow(y[incy * index], x[incx * index]);
    }
}

template <>
__global__ void pow_yx_kernel1(size_t n, const cuComplex* x, size_t incx, cuComplex* y, size_t incy) {
    auto index  = threadIdx.x + blockIdx.x * blockDim.x;
    auto stride = blockDim.x * gridDim.x;

    for (; index < n; index += stride) {
        auto x_ =  x[incx * index];
        auto y_ =  y[incy * index];

        float c_abs = hypot(y_.x, y_.y);
        float c_arg = atan2f(y_.y, y_.x);

        auto logx = make_cuComplex(logf(c_abs), c_arg);

        auto ylogx = cuCmulf(x_, logx);

        float e = expf(ylogx.x);
        auto res = make_cuComplex(e * cosf(ylogx.y), e * sinf(ylogx.y));

        y[incy * index] = res;
    }
}
<commit_msg>Always use the correct pow function<commit_after>//=======================================================================
// Copyright (c) 2017 <NAME>
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

#include "egblas/pow.hpp"
template <typename T>
__global__ void pow_yx_kernel(size_t n, T alpha, const T* x, size_t incx, T* y, size_t incy);

template <>
__global__ void pow_yx_kernel(size_t n, double alpha, const double* x, size_t incx, double* y, size_t incy) {
    auto index  = threadIdx.x + blockIdx.x * blockDim.x;
    auto stride = blockDim.x * gridDim.x;

    for (; index < n; index += stride) {
        y[incy * index] = alpha * pow(y[incy * index], x[incx * index]);
    }
}

template <>
__global__ void pow_yx_kernel(size_t n, float alpha, const float* x, size_t incx, float* y, size_t incy) {
    auto index  = threadIdx.x + blockIdx.x * blockDim.x;
    auto stride = blockDim.x * gridDim.x;

    for (; index < n; index += stride) {
        y[incy * index] = alpha * powf(y[incy * index], x[incx * index]);
    }
}

template <>
__global__ void pow_yx_kernel(size_t n, cuComplex alpha, const cuComplex* x, size_t incx, cuComplex* y, size_t incy) {
    auto index  = threadIdx.x + blockIdx.x * blockDim.x;
    auto stride = blockDim.x * gridDim.x;

    for (; index < n; index += stride) {
        auto x_ =  x[incx * index];
        auto y_ =  y[incy * index];

        float c_abs = hypot(y_.x, y_.y);
        float c_arg = atan2f(y_.y, y_.x);

        auto logx = make_cuComplex(logf(c_abs), c_arg);
        auto ylogx = cuCmulf(x_, logx);

        float e = expf(ylogx.x);
        auto res = make_cuComplex(e * cosf(ylogx.y), e * sinf(ylogx.y));

        y[incy * index] = cuCmulf(alpha, res);
    }
}

template <>
__global__ void pow_yx_kernel(size_t n, cuDoubleComplex alpha, const cuDoubleComplex* x, size_t incx, cuDoubleComplex* y, size_t incy) {
    auto index  = threadIdx.x + blockIdx.x * blockDim.x;
    auto stride = blockDim.x * gridDim.x;

    for (; index < n; index += stride) {
        auto x_ =  x[incx * index];
        auto y_ =  y[incy * index];

        double c_abs = hypot(y_.x, y_.y);
        double c_arg = atan2(y_.y, y_.x);

        auto logx = make_cuDoubleComplex(log(c_abs), c_arg);
        auto ylogx = cuCmul(x_, logx);

        double e = expf(ylogx.x);
        auto res = make_cuDoubleComplex(e * cos(ylogx.y), e * sin(ylogx.y));

        y[incy * index] = cuCmul(alpha, res);
    }
}

template <typename T>
__global__ void pow_yx_kernel1(size_t n, const T* x, size_t incx, T* y, size_t incy);

template <>
__global__ void pow_yx_kernel1(size_t n, const double* x, size_t incx, double* y, size_t incy) {
    auto index  = threadIdx.x + blockIdx.x * blockDim.x;
    auto stride = blockDim.x * gridDim.x;

    for (; index < n; index += stride) {
        y[incy * index] = pow(y[incy * index], x[incx * index]);
    }
}

template <>
__global__ void pow_yx_kernel1(size_t n, const float* x, size_t incx, float* y, size_t incy) {
    auto index  = threadIdx.x + blockIdx.x * blockDim.x;
    auto stride = blockDim.x * gridDim.x;

    for (; index < n; index += stride) {
        y[incy * index] = powf(y[incy * index], x[incx * index]);
    }
}

template <>
__global__ void pow_yx_kernel1(size_t n, const cuComplex* x, size_t incx, cuComplex* y, size_t incy) {
    auto index  = threadIdx.x + blockIdx.x * blockDim.x;
    auto stride = blockDim.x * gridDim.x;

    for (; index < n; index += stride) {
        auto x_ =  x[incx * index];
        auto y_ =  y[incy * index];

        float c_abs = hypot(y_.x, y_.y);
        float c_arg = atan2f(y_.y, y_.x);

        auto logx = make_cuComplex(logf(c_abs), c_arg);

        auto ylogx = cuCmulf(x_, logx);

        float e = expf(ylogx.x);
        auto res = make_cuComplex(e * cosf(ylogx.y), e * sinf(ylogx.y));

        y[incy * index] = res;
    }
}

{'fraction_non_alphanumeric': 0.1729524345623417, 'fraction_numerical': 0.0028145229383619475, 'mean_word_length': 2.8066416711301554, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3545864', 'n_tokens_mistral': 2714, 'n_tokens_neox': 2606, 'n_words': 698}