<commit_before>/*  This file is part of the Vc library.

    Copyright (C) 2009-2012 <NAME> <<EMAIL>>

    Vc is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as
    published by the Free Software Foundation, either version 3 of
    the License, or (at your option) any later version.

    Vc is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with Vc.  If not, see <http://www.gnu.org/licenses/>.

*/

#include "unittest.h"
#include <iostream>

using namespace Vc;

enum {
    VectorSizeFactor = short_v::Size / int_v::Size
};

void testSigned()
{
    for (int start = -32000; start < 32000; start += 5) {
        int_v a[VectorSizeFactor];
        for (int i = 0; i < VectorSizeFactor; ++i) {
            a[i] = int_v(IndexesFromZero) + int_v::Size * i + start;
        }
        short_v b(a);
        COMPARE(b, short_v(IndexesFromZero) + start);

        // false positive: warning: ‘c’ is used uninitialized in this function
        int_v c[VectorSizeFactor];
        b.expand(c);
        for (int i = 0; i < VectorSizeFactor; ++i) {
            COMPARE(c[i], int_v(IndexesFromZero) + int_v::Size * i + start);
        }
    }
}

void testUnsigned()
{
#if defined(VC_IMPL_SSE4_1) || defined(VC_IMPL_AVX)
    for (unsigned int start = 0; start < 64000; start += 5) {
#else
    for (unsigned int start = 0; start < 32000; start += 5) {
#endif
        uint_v a[VectorSizeFactor];
        for (unsigned int i = 0; i < VectorSizeFactor; ++i) {
            a[i] = uint_v(IndexesFromZero) + uint_v::Size * i + start;
        }
        ushort_v b(a);
        COMPARE(b, ushort_v(IndexesFromZero) + start);

        // false positive: warning: ‘c’ is used uninitialized in this function
        uint_v c[VectorSizeFactor];
        b.expand(c);
        for (unsigned int i = 0; i < VectorSizeFactor; ++i) {
            COMPARE(c[i], uint_v(IndexesFromZero) + uint_v::Size * i + start);
        }
    }
    for (unsigned int start = 32000; start < 64000; start += 5) {
        ushort_v b(IndexesFromZero);
        b += start;
        COMPARE(b, ushort_v(IndexesFromZero) + start);

        // false positive: warning: ‘c’ may be used uninitialized in this function
        uint_v c[VectorSizeFactor];
        b.expand(c);
        for (unsigned int i = 0; i < VectorSizeFactor; ++i) {
            COMPARE(c[i], uint_v(IndexesFromZero) + uint_v::Size * i + start);
        }
    }
}

int main()
{
    runTest(testSigned);
    runTest(testUnsigned);
    return 0;
}<commit_msg>add small test for double_v -> float_v merge<commit_after>/*  This file is part of the Vc library.

    Copyright (C) 2009-2012 <NAME> <<EMAIL>>

    Vc is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as
    published by the Free Software Foundation, either version 3 of
    the License, or (at your option) any later version.

    Vc is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with Vc.  If not, see <http://www.gnu.org/licenses/>.

*/

#include "unittest.h"
#include <iostream>

using namespace Vc;

enum {
    VectorSizeFactor = short_v::Size / int_v::Size
};

void testSigned()
{
    for (int start = -32000; start < 32000; start += 5) {
        int_v a[VectorSizeFactor];
        for (int i = 0; i < VectorSizeFactor; ++i) {
            a[i] = int_v(IndexesFromZero) + int_v::Size * i + start;
        }
        short_v b(a);
        COMPARE(b, short_v(IndexesFromZero) + start);

        // false positive: warning: ‘c’ is used uninitialized in this function
        int_v c[VectorSizeFactor];
        b.expand(c);
        for (int i = 0; i < VectorSizeFactor; ++i) {
            COMPARE(c[i], int_v(IndexesFromZero) + int_v::Size * i + start);
        }
    }
}

void testUnsigned()
{
#if defined(VC_IMPL_SSE4_1) || defined(VC_IMPL_AVX)
    for (unsigned int start = 0; start < 64000; start += 5) {
#else
    for (unsigned int start = 0; start < 32000; start += 5) {
#endif
        uint_v a[VectorSizeFactor];
        for (unsigned int i = 0; i < VectorSizeFactor; ++i) {
            a[i] = uint_v(IndexesFromZero) + uint_v::Size * i + start;
        }
        ushort_v b(a);
        COMPARE(b, ushort_v(IndexesFromZero) + start);

        // false positive: warning: ‘c’ is used uninitialized in this function
        uint_v c[VectorSizeFactor];
        b.expand(c);
        for (unsigned int i = 0; i < VectorSizeFactor; ++i) {
            COMPARE(c[i], uint_v(IndexesFromZero) + uint_v::Size * i + start);
        }
    }
    for (unsigned int start = 32000; start < 64000; start += 5) {
        ushort_v b(IndexesFromZero);
        b += start;
        COMPARE(b, ushort_v(IndexesFromZero) + start);

        // false positive: warning: ‘c’ may be used uninitialized in this function
        uint_v c[VectorSizeFactor];
        b.expand(c);
        for (unsigned int i = 0; i < VectorSizeFactor; ++i) {
            COMPARE(c[i], uint_v(IndexesFromZero) + uint_v::Size * i + start);
        }
    }
}

void testFloat()
{
    enum {
        SizeFactor = float_v::Size / double_v::Size
    };
    double_v d[SizeFactor];
    for (int i = 0; i < SizeFactor; ++i) {
        d[i] = double_v::Random();
    }
    float_v f(d);
    for (int i = 0; i < float_v::Size; ++i) {
        COMPARE(f[i], float(d[i / double_v::Size][i % double_v::Size]));
    }
}

int main()
{
    runTest(testSigned);
    runTest(testUnsigned);
    runTest(testFloat);
    return 0;
}
{'fraction_non_alphanumeric': 0.11600928074245939, 'fraction_numerical': 0.017898574743122307, 'mean_word_length': 2.5541813898704357, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5737438', 'n_tokens_mistral': 2065, 'n_tokens_neox': 1965, 'n_words': 633}