<commit_before>
#ifndef SCM_MATH_VEC_H_INCLUDED
#define SCM_MATH_VEC_H_INCLUDED

#include <cassert>

#include <boost/static_assert.hpp>

namespace math
{
    template<typename scm_scalar, unsigned dim>
    class vec
    {
    public:
        vec() {}
        vec(const vec<scm_scalar, dim>& v) {
            for(unsigned i = 0; i < dim; i++) {
                vec_array[i] = v.vec_array[i];
            }
        }
        explicit vec(const scm_scalar s) {
            for(unsigned i = 0; i < dim; i++) {
                vec_array[i] = s;
            }
        }

        vec<scm_scalar, dim>& operator=(const vec<scm_scalar, dim>& rhs) { 
            for(unsigned i = 0; i < dim; i++) {
                vec_array[i] = rhs.vec_array[i];
            }

            return (*this);
        }

        scm_scalar& operator[](const unsigned i) { assert(i < dim); return (vec_array[i]); }
        const scm_scalar& operator[](const unsigned i) const { assert(i < dim); return (vec_array[i]); }

        //// do not instantiiate!
        //BOOST_STATIC_ASSERT(sizeof(scm_scalar) == 0);
        scm_scalar  vec_array[dim];
    };

#if 0 // convenience
    template<typename scm_scalar>
    class vec<scm_scalar, 1>
    {
    public:
        vec() {}
        vec(const vec<scm_scalar, 1>& v) : x(v.x) {}
        explicit vec(const scm_scalar s) : x(s) {}
        
        vec<scm_scalar, 1>& operator=(const vec<scm_scalar, 1>& rhs) { x = rhs.x; return (*this); }

        scm_scalar& operator[](const unsigned i) { assert(i < 1); return (vec_array[i]); }
        const scm_scalar& operator[](const unsigned i) const { assert(i < 1); return (vec_array[i]); }

        // data definition
        union
        {
            struct
            {
                scm_scalar x;
            };
            scm_scalar  vec_array[1];
        };
    protected:
    private:
    }; // class vec1
#endif

    template<typename scm_scalar>
    class vec<scm_scalar, 2>
    {
    public:
        vec() {}
        vec(const vec<scm_scalar, 2>& v) : x(v.x), y(v.y) {}
        explicit vec(const scm_scalar s) : x(s), y(s) {}
        explicit vec(const scm_scalar s, const scm_scalar t) : x(s), y(t) {}

        vec<scm_scalar, 2>& operator=(const vec<scm_scalar, 2>& rhs) { x = rhs.x; y = rhs.y; return (*this); }

        scm_scalar& operator[](const unsigned i) { assert(i < 2); return (vec_array[i]); }
        const scm_scalar& operator[](const unsigned i) const { assert(i < 2); return (vec_array[i]); }

        // data definition
        union
        {
            struct
            {
                scm_scalar x;
                scm_scalar y;
            };
            scm_scalar  vec_array[2];
        };
    protected:
    private:
    }; // class vec2
    
    template<typename scm_scalar>
    class vec<scm_scalar, 3>
    {
    public:
        vec() {}
        vec(const vec<scm_scalar, 3>& v) : x(v.x), y(v.y), z(v.z) {}
        explicit vec(const scm_scalar s) : x(s), y(s), z(s) {}
        explicit vec(const scm_scalar s, const scm_scalar t, const scm_scalar u) : x(s), y(t), z(u) {}

        vec<scm_scalar, 3>& operator=(const vec<scm_scalar, 3>& rhs) { x = rhs.x; y = rhs.y; z = rhs.z; return (*this); }

        scm_scalar& operator[](const unsigned i) { assert(i < 3); return (vec_array[i]); }
        const scm_scalar& operator[](const unsigned i) const { assert(i < 3); return (vec_array[i]); }

        // data definition
        union
        {
            struct
            {
                scm_scalar x;
                scm_scalar y;
                scm_scalar z;
            };
            scm_scalar  vec_array[3];
        };
    protected:
    private:
    }; // class vec3

    template<typename scm_scalar>
    class vec<scm_scalar, 4>
    {
    public:
        vec() {}
        vec(const vec<scm_scalar, 4>& v) : x(v.x), y(v.y), z(v.z), w(v.w) {}
        explicit vec(const scm_scalar s) : x(s), y(s), z(s), w(s) {}
        explicit vec(const scm_scalar s, const scm_scalar t, const scm_scalar u, const scm_scalar v) : x(s), y(t), z(u), w(v) {}
        explicit vec(const vec<scm_scalar, 3>& v) : x(v.x), y(v.y), z(v.z), w(scm_scalar(1)) {}
        explicit vec(const vec<scm_scalar, 3>& v, const scm_scalar s) : x(v.x), y(v.y), z(v.z), w(s) {}

        vec<scm_scalar, 4>& operator=(const vec<scm_scalar, 4>& rhs) { x = rhs.x; y = rhs.y; z = rhs.z; w = rhs.w; return (*this); }

        scm_scalar& operator[](const unsigned i) { assert(i < 4); return (vec_array[i]); }
        const scm_scalar& operator[](const unsigned i) const { assert(i < 4); return (vec_array[i]); }

        // data definition
        union
        {
            struct
            {
                scm_scalar x;
                scm_scalar y;
                scm_scalar z;
                scm_scalar w;
            };
            scm_scalar  vec_array[4];
        };
    protected:
    private:
    }; // class vec4


} // math

#include "math_vec.inl"

#endif // SCM_MATH_VEC_H_INCLUDED

<commit_msg>small fix at core math lib<commit_after>
#ifndef SCM_MATH_VEC_H_INCLUDED
#define SCM_MATH_VEC_H_INCLUDED

#include <cassert>

#include <boost/static_assert.hpp>

namespace math
{
    template<typename scm_scalar, unsigned dim>
    class vec
    {
    public:
        vec() {}
        vec(const vec<scm_scalar, dim>& v) {
            for(unsigned i = 0; i < dim; i++) {
                vec_array[i] = v.vec_array[i];
            }
        }
        explicit vec(const scm_scalar s) {
            for(unsigned i = 0; i < dim; i++) {
                vec_array[i] = s;
            }
        }

        vec<scm_scalar, dim>& operator=(const vec<scm_scalar, dim>& rhs) { 
            for(unsigned i = 0; i < dim; i++) {
                vec_array[i] = rhs.vec_array[i];
            }

            return (*this);
        }

        scm_scalar& operator[](const unsigned i) { assert(i < dim); return (vec_array[i]); }
        const scm_scalar& operator[](const unsigned i) const { assert(i < dim); return (vec_array[i]); }

        //// do not instantiiate!
        //BOOST_STATIC_ASSERT(sizeof(scm_scalar) == 0);
        scm_scalar  vec_array[dim];
    };

#if 0 // convenience
    template<typename scm_scalar>
    class vec<scm_scalar, 1>
    {
    public:
        vec() {}
        vec(const vec<scm_scalar, 1>& v) : x(v.x) {}
        explicit vec(const scm_scalar s) : x(s) {}
        
        vec<scm_scalar, 1>& operator=(const vec<scm_scalar, 1>& rhs) { x = rhs.x; return (*this); }

        scm_scalar& operator[](const unsigned i) { assert(i < 1); return (vec_array[i]); }
        const scm_scalar& operator[](const unsigned i) const { assert(i < 1); return (vec_array[i]); }

        // data definition
        union
        {
            struct
            {
                scm_scalar x;
            };
            scm_scalar  vec_array[1];
        };
    protected:
    private:
    }; // class vec1
#endif

    template<typename scm_scalar>
    class vec<scm_scalar, 2>
    {
    public:
        typedef scm_scalar          component_type;

    public:
        vec() {}
        vec(const vec<scm_scalar, 2>& v) : x(v.x), y(v.y) {}
        explicit vec(const scm_scalar s) : x(s), y(s) {}
        explicit vec(const scm_scalar s, const scm_scalar t) : x(s), y(t) {}

        vec<scm_scalar, 2>& operator=(const vec<scm_scalar, 2>& rhs) { x = rhs.x; y = rhs.y; return (*this); }

        scm_scalar& operator[](const unsigned i) { assert(i < 2); return (vec_array[i]); }
        const scm_scalar& operator[](const unsigned i) const { assert(i < 2); return (vec_array[i]); }

        // data definition
        union
        {
            struct
            {
                scm_scalar x;
                scm_scalar y;
            };
            scm_scalar  vec_array[2];
        };
    protected:
    private:
    }; // class vec2
    
    template<typename scm_scalar>
    class vec<scm_scalar, 3>
    {
    public:
        typedef scm_scalar          component_type;

    public:
        vec() {}
        vec(const vec<scm_scalar, 3>& v) : x(v.x), y(v.y), z(v.z) {}
        explicit vec(const scm_scalar s) : x(s), y(s), z(s) {}
        explicit vec(const scm_scalar s, const scm_scalar t, const scm_scalar u) : x(s), y(t), z(u) {}

        vec<scm_scalar, 3>& operator=(const vec<scm_scalar, 3>& rhs) { x = rhs.x; y = rhs.y; z = rhs.z; return (*this); }

        scm_scalar& operator[](const unsigned i) { assert(i < 3); return (vec_array[i]); }
        const scm_scalar& operator[](const unsigned i) const { assert(i < 3); return (vec_array[i]); }

        // data definition
        union
        {
            struct
            {
                scm_scalar x;
                scm_scalar y;
                scm_scalar z;
            };
            scm_scalar  vec_array[3];
        };
    protected:
    private:
    }; // class vec3

    template<typename scm_scalar>
    class vec<scm_scalar, 4>
    {
    public:
        typedef scm_scalar          component_type;

    public:
        vec() {}
        vec(const vec<scm_scalar, 4>& v) : x(v.x), y(v.y), z(v.z), w(v.w) {}
        explicit vec(const scm_scalar s) : x(s), y(s), z(s), w(s) {}
        explicit vec(const scm_scalar s, const scm_scalar t, const scm_scalar u, const scm_scalar v) : x(s), y(t), z(u), w(v) {}
        explicit vec(const vec<scm_scalar, 3>& v) : x(v.x), y(v.y), z(v.z), w(scm_scalar(1)) {}
        explicit vec(const vec<scm_scalar, 3>& v, const scm_scalar s) : x(v.x), y(v.y), z(v.z), w(s) {}

        vec<scm_scalar, 4>& operator=(const vec<scm_scalar, 4>& rhs) { x = rhs.x; y = rhs.y; z = rhs.z; w = rhs.w; return (*this); }

        scm_scalar& operator[](const unsigned i) { assert(i < 4); return (vec_array[i]); }
        const scm_scalar& operator[](const unsigned i) const { assert(i < 4); return (vec_array[i]); }

        // data definition
        union
        {
            struct
            {
                scm_scalar x;
                scm_scalar y;
                scm_scalar z;
                scm_scalar w;
            };
            scm_scalar  vec_array[4];
        };
    protected:
    private:
    }; // class vec4


} // math

#include "math_vec.inl"

#endif // SCM_MATH_VEC_H_INCLUDED


{'fraction_non_alphanumeric': 0.14274509803921567, 'fraction_numerical': 0.00784313725490196, 'mean_word_length': 1.870287000562746, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 59, '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': '4012556', 'n_tokens_mistral': 3635, 'n_tokens_neox': 3518, 'n_words': 851}