<commit_before>//Copyright (C) 2011 by <NAME>
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in
//all copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//THE SOFTWARE.

#ifndef GFORT_CORE_STRUCTS_H_
#define GFORT_CORE_STRUCTS_H_

#include <cmath>

//#include <Eigen/Dense>
//#include <Eigen/Geometry>
#include <boost/numeric/ublas/vector.hpp>

namespace GFort { namespace Core
{

/// Vector class in 2 dimensions
template <typename T>
class Vector2
{
    //typedef Eigen::Matrix<T, 2, 1, 0, 2, 1> Point;
    typedef boost::numeric::ublas::vector<T> Point;

public:
    /// Constructor
    Vector2() {}

    /// Constructor
    /// @param x
    /// @param y
    Vector2(const T& x, const T& y)
    {
        this->point_[0] = x;
        this->point_[1] = y;
    }
    
    /// Copy Constructor
    /// @param p
    Vector2& operator= (const Vector2& p)
    {
        this->point_ = p.point_;
        return *this;
    }
    
    /// Gets the position.
    T X() const                         { return point_.x(); }

    /// Gets the position.
    T Y() const                         { return point_.y(); }

    /// Gets squared distance of a point p to the object. 
    /// @param p
    T Distance(const Vector2& p) const  { return std::sqrt(DistanceSquared(p)); }

    /// Gets squared distance of a point p to the object. 
    /// @param p
    T DistanceSquared(const Vector2& p) const
    { 
        return std::pow((p.point_.x() - this->point_.x()), 2)
            + std::pow((p.point_.y() - this->point_.y()), 2);
    }

public:
    Point point_;
};


/// Rectangle
template <typename T>
struct Rectangle
{
    /// Constructor
    Rectangle() {}

    /// Constructor
    /// @param x
    /// @param y
    /// @param width
    /// @param height
    Rectangle(const T& x, const T& y, const T& width, const T& height) 
    {
        position_ = Vector2<T>(x, y);
        size_ = Vector2<T>(width, height);
    }

    /// Gets the position of the rectangle.
    T X() const             { return position_.x(); }

    /// Gets the position of the rectangle.
    T Y() const             { return position_.y(); }

    /// Gets the width of the rectangle.
    T Width() const         { return size_.x(); }

    /// Gets the height of the rectangle.
    T Height() const        { return size_.y(); }

private:
    Vector2<T>   	position_;
    Vector2<T>      size_;
};

/// Line
template <typename T>
struct Line
{
    //typedef Eigen::ParametrizedLine<T, 2> LineType;

public:
    /// Constructor<commit_msg>fixed bug on using boost vector<commit_after>//Copyright (C) 2011 by <NAME>
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in
//all copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//THE SOFTWARE.

#ifndef GFORT_CORE_STRUCTS_H_
#define GFORT_CORE_STRUCTS_H_

#include <cmath>

//#include <Eigen/Dense>
//#include <Eigen/Geometry>
#include <boost/numeric/ublas/vector.hpp>

namespace GFort { namespace Core
{

/// Vector class in 2 dimensions
template <typename T>
class Vector2
{
    //typedef Eigen::Matrix<T, 2, 1, 0, 2, 1> Point;
    typedef boost::numeric::ublas::vector<T> Point;

public:
    /// Constructor
    Vector2() { this->point_.resize(2); }

    /// Constructor
    /// @param x
    /// @param y
    Vector2(const T& x, const T& y)
    {
        this->point_.resize(2);
        this->point_[0] = x;
        this->point_[1] = y;
    }
    
    /// Copy Constructor
    /// @param p
    Vector2& operator= (const Vector2& p)
    {
        this->point_ = p.point_;
        return *this;
    }
    
    /// Gets the position.
    T X() const                         { return point_[0]; }

    /// Gets the position.
    T Y() const                         { return point_[1]; }

    /// Gets squared distance of a point p to the object. 
    /// @param p
    T Distance(const Vector2& p) const  { return std::sqrt(DistanceSquared(p)); }

    /// Gets squared distance of a point p to the object. 
    /// @param p
    T DistanceSquared(const Vector2& p) const
    { 
        return std::pow((p.point_[0] - this->point_[0]), 2)
            + std::pow((p.point_[1] - this->point_[1]), 2);
    }

public:
    Point point_;
};


/// Rectangle
template <typename T>
struct Rectangle
{
    /// Constructor
    Rectangle() {}

    /// Constructor
    /// @param x
    /// @param y
    /// @param width
    /// @param height
    Rectangle(const T& x, const T& y, const T& width, const T& height) 
    {
        position_ = Vector2<T>(x, y);
        size_ = Vector2<T>(width, height);
    }

    /// Gets the position of the rectangle.
    T X() const             { return position_[0]; }

    /// Gets the position of the rectangle.
    T Y() const             { return position_[1]; }

    /// Gets the width of the rectangle.
    T Width() const         { return size_[0]; }

    /// Gets the height of the rectangle.
    T Height() const        { return size_[1]; }

private:
    Vector2<T>   	position_;
    Vector2<T>      size_;
};

/// Line
template <typename T>
struct Line
{
    //typedef Eigen::ParametrizedLine<T, 2> LineType;

public:
    /// Constructor
{'fraction_non_alphanumeric': 0.12084592145015106, 'fraction_numerical': 0.00920730830096389, 'mean_word_length': 2.3862640038967364, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 45, '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': '5680265', 'n_tokens_mistral': 2129, 'n_tokens_neox': 2012, 'n_words': 792}