⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 octonion.hpp

📁 support vector clustering for vc++
💻 HPP
📖 第 1 页 / 共 5 页
字号:
                T    br = static_cast<T>(rhs.R_component_2());
                T    cr = static_cast<T>(rhs.R_component_3());
                T    dr = static_cast<T>(rhs.R_component_4());
                T    er = static_cast<T>(rhs.R_component_5());
                T    fr = static_cast<T>(rhs.R_component_6());
                T    gr = static_cast<T>(rhs.R_component_7());
                T    hr = static_cast<T>(rhs.R_component_8());
                
                T    denominator = ar*ar+br*br+cr*cr+dr*dr+er*er+fr*fr+gr*gr+hr*hr;
                
                T    at = (+a*ar+b*br+c*cr+d*dr+e*er+f*fr+g*gr+h*hr)/denominator;
                T    bt = (-a*br+b*ar-c*dr+d*cr-e*fr+f*er+g*hr-h*gr)/denominator;
                T    ct = (-a*cr+b*dr+c*ar-d*br-e*gr-f*hr+g*er+h*fr)/denominator;
                T    dt = (-a*dr-b*cr+c*br+d*ar-e*hr+f*gr-g*fr+h*er)/denominator;
                T    et = (-a*er+b*fr+c*gr+d*hr+e*ar-f*br-g*cr-h*dr)/denominator;
                T    ft = (-a*fr-b*er+c*hr-d*gr+e*br+f*ar+g*dr-h*cr)/denominator;
                T    gt = (-a*gr-b*hr-c*er+d*fr+e*cr-f*dr+g*ar+h*br)/denominator;
                T    ht = (-a*hr+b*gr-c*fr-d*er+e*dr+f*cr-g*br+h*ar)/denominator;
                
                a = at;
                b = bt;
                c = ct;
                d = dt;
                e = et;
                f = ft;
                g = gt;
                h = ht;
                
                return(*this);
            }
            
            
        protected:
            
            BOOST_OCTONION_MEMBER_DATA_GENERATOR(T)
            
            
        private:
            
        };
        
        
        // declaration of octonion specialization
        
        template<>    class octonion<float>;
        template<>    class octonion<double>;
        template<>    class octonion<long double>;
        
        
        // helper templates for converting copy constructors (declaration)
        
        namespace detail
        {
            
            template<   typename T,
                        typename U
                    >
            octonion<T>    octonion_type_converter(octonion<U> const & rhs);
        }
        
        
        // implementation of octonion specialization
        
        
#define    BOOST_OCTONION_CONSTRUCTOR_GENERATOR(type)                                                                               \
            explicit                    octonion(   type const & requested_a = static_cast<type>(0),                                \
                                                    type const & requested_b = static_cast<type>(0),                                \
                                                    type const & requested_c = static_cast<type>(0),                                \
                                                    type const & requested_d = static_cast<type>(0),                                \
                                                    type const & requested_e = static_cast<type>(0),                                \
                                                    type const & requested_f = static_cast<type>(0),                                \
                                                    type const & requested_g = static_cast<type>(0),                                \
                                                    type const & requested_h = static_cast<type>(0))                                \
            :   a(requested_a),                                                                                                     \
                b(requested_b),                                                                                                     \
                c(requested_c),                                                                                                     \
                d(requested_d),                                                                                                     \
                e(requested_e),                                                                                                     \
                f(requested_f),                                                                                                     \
                g(requested_g),                                                                                                     \
                h(requested_h)                                                                                                      \
            {                                                                                                                       \
            }                                                                                                                       \
                                                                                                                                    \
            explicit                    octonion(   ::std::complex<type> const & z0,                                                \
                                                    ::std::complex<type> const & z1 = ::std::complex<type>(),                       \
                                                    ::std::complex<type> const & z2 = ::std::complex<type>(),                       \
                                                    ::std::complex<type> const & z3 = ::std::complex<type>())                       \
            :   a(z0.real()),                                                                                                       \
                b(z0.imag()),                                                                                                       \
                c(z1.real()),                                                                                                       \
                d(z1.imag()),                                                                                                       \
                e(z2.real()),                                                                                                       \
                f(z2.imag()),                                                                                                       \
                g(z3.real()),                                                                                                       \
                h(z3.imag())                                                                                                        \
            {                                                                                                                       \
            }                                                                                                                       \
                                                                                                                                    \
            explicit                    octonion(   ::boost::math::quaternion<type> const & q0,                                     \
                                                    ::boost::math::quaternion<type> const & q1 = ::boost::math::quaternion<type>()) \
            :   a(q0.R_component_1()),                                                                                              \
                b(q0.R_component_2()),                                                                                              \
                c(q0.R_component_3()),                                                                                              \
                d(q0.R_component_4()),                                                                                              \
                e(q1.R_component_1()),                                                                                              \
                f(q1.R_component_2()),                                                                                              \
                g(q1.R_component_3()),                                                                                              \
                h(q1.R_component_4())                                                                                               \
            {                                                                                                                       \
            }
        
    
#define    BOOST_OCTONION_MEMBER_ADD_GENERATOR_1(type)                  \
            octonion<type> &            operator += (type const & rhs)  \
            {                                                           \
                a += rhs;                                               \
                                                                        \
                return(*this);                                          \
            }
    
#define    BOOST_OCTONION_MEMBER_ADD_GENERATOR_2(type)                                  \
            octonion<type> &            operator += (::std::complex<type> const & rhs)  \
            {                                                                           \
                a += rhs.real();                                                        \
                b += rhs.imag();                                                        \
                                                                                        \
                return(*this);                                                          \
            }
    
#define    BOOST_OCTONION_MEMBER_ADD_GENERATOR_3(type)                                              \
            octonion<type> &            operator += (::boost::math::quaternion<type> const & rhs)   \
            {                                                                                       \
                a += rhs.R_component_1();                                                           \
                b += rhs.R_component_2();                                                           \
                c += rhs.R_component_3();                                                           \
                d += rhs.R_component_4();                                                           \
                                                                                                    \
                return(*this);                                                                      \
            }
    
#define    BOOST_OCTONION_MEMBER_ADD_GENERATOR_4(type)                          \
            template<typename X>                                                \
            octonion<type> &            operator += (octonion<X> const & rhs)   \
            {                                                                   \
                a += static_cast<type>(rhs.R_component_1());                    \
                b += static_cast<type>(rhs.R_component_2());                    \
                c += static_cast<type>(rhs.R_component_3());                    \
                d += static_cast<type>(rhs.R_component_4());                    \
                e += static_cast<type>(rhs.R_component_5());                    \
                f += static_cast<type>(rhs.R_component_6());                    \
                g += static_cast<type>(rhs.R_component_7());                    \
                h += static_cast<type>(rhs.R_component_8());                    \
                                                                                \
                return(*this);                                                  \
            }
    
#define    BOOST_OCTONION_MEMBER_SUB_GENERATOR_1(type)                  \
            octonion<type> &            operator -= (type const & rhs)  \
            {                                                           \
                a -= rhs;                                               \
                                                                        \
                return(*this);                                          \
            }
    
#define    BOOST_OCTONION_MEMBER_SUB_GENERATOR_2(type)                                  \
            octonion<type> &            operator -= (::std::complex<type> const & rhs)  \
            {                                                                           \
                a -= rhs.real();                                                        \
                b -= rhs.imag();                                                        \
                                                                                        \
                return(*this);                                                          \
            }
    
#define    BOOST_OCTONION_MEMBER_SUB_GENERATOR_3(type)                                              \
            octonion<type> &            operator -= (::boost::math::quaternion<type> const & rhs)   \
            {                                                                                       \
                a -= rhs.R_component_1();                                                           \
                b -= rhs.R_component_2();                                                           \
                c -= rhs.R_component_3();                                                           \
                d -= rhs.R_component_4();                                                           \
                                                                                                    \
                return(*this);                                                                      \
            }
    
#define    BOOST_OCTONION_MEMBER_SUB_GENERATOR_4(type)                        \
            template<typename X>                                              \
            octonion<type> &            operator -= (octonion<X> const & rhs) \
            {                                                                 \
                a -= static_cast<type>(rhs.R_component_1());                  \
                b -= static_cast<type>(rhs.R_component_2());                  \
                c -= static_cast<type>(rhs.R_component_3());                  \
                d -= static_cast<type>(rhs.R_component_4());                  \
                e -= static_cast<type>(rhs.R_component_5());                  \
                f -= static_cast<type>(rhs.R_component_6());                  \
                g -= static_cast<type>(rhs.R_component_7());                  \
                h -= static_cast<type>(rhs.R_component_8());                  \
                                                                              \
                return(*this);                                                \
            }
    
#define    BOOST_OCTONION_MEMBER_MUL_GENERATOR_1(type)                   \
            octonion<type> &            operator *= (type const & rhs)   \
            {                                                            \
                a *= rhs;                                                \
                b *= rhs;                                                \
                c *= rhs;                                                \
                d *= rhs;                                                \
                e *= rhs;                                                \
                f *= rhs;                                                \
                g *= rhs;                                                \
                h *= rhs;                                                \

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -