<commit_before>// Morton Curve utility
// -----------------------------------------------------------------------------
// Copyright (C) 2012, See authors
//
// This program is open source and distributed under the New BSD License. See
// license for more detail.
// -----------------------------------------------------------------------------

#ifndef _GPU_DACRT_MORTON_CURVE_H_
#define _GPU_DACRT_MORTON_CURVE_H_

namespace Utils {

    class Morton {
    public:
        /**
         * Insert a 0 bit after each of the 16 low bits of x
         *
         * source: http://fgiesen.wordpress.com/2009/12/13/decoding-morton-codes/
         */
        inline static unsigned int Part1By1(unsigned int x) {
            x &= 0x0000ffff;                  // x = ---- ---- ---- ---- fedc ba98 7654 3210
            x = (x ^ (x <<  8)) & 0x00ff00ff; // x = ---- ---- fedc ba98 ---- ---- 7654 3210
            x = (x ^ (x <<  4)) & 0x0f0f0f0f; // x = ---- fedc ---- ba98 ---- 7654 ---- 3210
            x = (x ^ (x <<  2)) & 0x33333333; // x = --fe --dc --ba --98 --76 --54 --32 --10
            x = (x ^ (x <<  1)) & 0x55555555; // x = -f-e -d-c -b-a -9-8 -7-6 -5-4 -3-2 -1-0
            return x;
        }

        /**
         * "Insert" two 0 bits after each of the 10 low bits of x<commit_msg>Encode x y z u and v as morton code<commit_after>// Morton Curve utility
// -----------------------------------------------------------------------------
// Copyright (C) 2012, See authors
//
// This program is open source and distributed under the New BSD License. See
// license for more detail.
// -----------------------------------------------------------------------------

#ifndef _GPU_DACRT_MORTON_CURVE_H_
#define _GPU_DACRT_MORTON_CURVE_H_

namespace Utils {

    class Morton {
    public:
        
        inline static unsigned int Encode(const unsigned int x, const unsigned int y, const unsigned int z, 
                                          const unsigned int u, const unsigned int v) {
            return (PartBy4(x) << 4) + (PartBy4(y) << 3) + (PartBy4(z) << 2) +
                (PartBy4(u) << 1) + PartBy4(v);
        }
        
        /**
         * Insert a 0 bit after each of the 16 low bits of x
         *
         * source: http://fgiesen.wordpress.com/2009/12/13/decoding-morton-codes/
         */
        inline static unsigned int Part1By1(unsigned int x) {
            x &= 0x0000ffff;                  // x = ---- ---- ---- ---- fedc ba98 7654 3210
            x = (x ^ (x <<  8)) & 0x00ff00ff; // x = ---- ---- fedc ba98 ---- ---- 7654 3210
            x = (x ^ (x <<  4)) & 0x0f0f0f0f; // x = ---- fedc ---- ba98 ---- 7654 ---- 3210
            x = (x ^ (x <<  2)) & 0x33333333; // x = --fe --dc --ba --98 --76 --54 --32 --10
            x = (x ^ (x <<  1)) & 0x55555555; // x = -f-e -d-c -b-a -9-8 -7-6 -5-4 -3-2 -1-0
            return x;
        }

        /**
         * "Insert" two 0 bits after each of the 10 low bits of x
{'fraction_non_alphanumeric': 0.25016880486158, 'fraction_numerical': 0.07528696826468602, 'mean_word_length': 1.0590687977762334, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5746973', 'n_tokens_mistral': 1079, 'n_tokens_neox': 904, 'n_words': 296}