Skip to content
Snippets Groups Projects
Bin.h 2.27 KiB
Newer Older
  • Learn to ignore specific revisions
  • // ************************************************************************** //
    
    //  BornAgain: simulate and fit scattering at grazing incidence
    //
    
    //! @file      Tools/inc/Bin.h
    
    //! @brief     Defines structs Bin1D, Bin1DCVector
    //!
    
    //! @homepage  http://apps.jcns.fz-juelich.de/BornAgain
    
    //! @license   GNU General Public License v3 or higher (see COPYING)
    
    //! @copyright Forschungszentrum Jülich GmbH 2013
    //! @authors   Scientific Computing Group at MLZ Garching
    
    //! @authors   C. Durniak, G. Pospelov, W. Van Herck, J. Wuttke
    
    //
    // ************************************************************************** //
    
    
    
    //! @class Bin1D
    //! @ingroup tools_internal
    //! @brief One dimensional bin with left and right bounds.
    
    struct Bin1D
    {
        double m_lower;  //!< lower bound of the bin
        double m_upper;  //!< upper bound of the bin
        double getMidPoint() const { return (m_lower + m_upper)/2.0; }
    };
    
    
    
    //! @class Bin1DCVector
    //! @ingroup tools_internal
    //! @brief An one-dimensional range of cvector_t's
    
        Bin1DCVector() : m_q_lower(), m_q_upper() {}
    
    Wuttke, Joachim's avatar
    Wuttke, Joachim committed
        Bin1DCVector(const cvector_t& lower, const cvector_t& upper)
    
    Wuttke, Joachim's avatar
    Wuttke, Joachim committed
        Bin1DCVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin);
    
        cvector_t getMidPoint() const { return (m_q_lower + m_q_upper)/2.0; }
    
        cvector_t getDelta() const { return m_q_upper - m_q_lower; }
    
        cvector_t m_q_lower;  //!< lower bound of the bin
        cvector_t m_q_upper;  //!< upper bound of the bin
    
    Wuttke, Joachim's avatar
    Wuttke, Joachim committed
    inline bool operator==(const Bin1D& left, const Bin1D& right)
    
    {
        if (std::abs(left.m_lower - right.m_lower) > Numeric::double_epsilon) return false;
        if (std::abs(left.m_upper - right.m_upper) > Numeric::double_epsilon) return false;
        return true;
    }
    
    
    Wuttke, Joachim's avatar
    Wuttke, Joachim committed
    inline bool operator!=(const Bin1D& left, const Bin1D& right) {
    
    //! creation on Bin1DCVector from alpha and phi bins
    
    Wuttke, Joachim's avatar
    Wuttke, Joachim committed
    inline Bin1DCVector::Bin1DCVector(double wavelength, const Bin1D& alpha_bin, const Bin1D& phi_bin) : m_q_lower(), m_q_upper()
    
    {
        m_q_lower.setLambdaAlphaPhi(wavelength, alpha_bin.m_lower, phi_bin.m_lower);
        m_q_upper.setLambdaAlphaPhi(wavelength, alpha_bin.m_upper, phi_bin.m_upper);
    }