예제 #1
0
        static BOOST_FORCEINLINE Vector sincos( input_t const & input, Vector & cosine )
        {
            typedef typename Vector::value_type scalar_t;

            long double const omega_scale( input.omega_scale );
            long double const N          ( input.N           );
            int         const index      ( input.index       );

            Vector sine;

            for ( int i( 0 ); i < Vector::static_size; ++i )
            {
                //...zzz...should only 'upgrade' float to double and double to long double...
                //...zzz...nt2 doesn't seem to support the long double data type...
                /*long*/ double const omega( ( index + i ) * omega_scale * full_circle() / N );
                /*long*/ double precise_sin;
                /*long*/ double precise_cos;
                nt2::sincospi( omega, precise_sin, precise_cos );

                sine  [ i ] = static_cast<scalar_t>( precise_sin );
                cosine[ i ] = static_cast<scalar_t>( precise_cos );
            }

            return sine;
        }
예제 #2
0
// intensity different in node link
double dynamics_mul::intensity_energy(Node_key nid, Vec2 new_pos){
    double E = 0.0;
    for (auto hew = s_dsc->walker(nid); !hew.full_circle(); hew = hew.circulate_vertex_cw()) {
        auto fid = hew.face();
        Vec2_array tris;
        tris.push_back(new_pos);
        tris.push_back(s_dsc->get_pos(hew.vertex()));
        tris.push_back(s_dsc->get_pos(hew.next().vertex()));

        double ci = mean_inten_[s_dsc->get_label(fid)];
        
        Vec2 min(INFINITY, INFINITY), max(-INFINITY, -INFINITY);
        for (auto p: tris){
            min[0] = std::min(min[0], p[0]);
            min[1] = std::min(min[1], p[1]);
            max[0] = std::max(max[0], p[0]);
            max[1] = std::max(max[1], p[1]);
        }
        
        for (int i = floor(min[0]); i < ceil(max[0]); i++) {
            for (int j = floor(min[1]); j < ceil(max[1]); j++) {
                if (helper_t::is_point_in_tri(Vec2(i,j), tris)) {
                    double I = s_img->get_intensity(i, j);
                    E += (I - ci)*(I-ci);
                }
            }
        }
    }
    
    return E;
}
예제 #3
0
// Interface length in node link
double dynamics_mul::curve_length(Node_key nid, Vec2 new_pos){
    double L = 0.0;
    
    for (auto hew = s_dsc->walker(nid); !hew.full_circle(); hew = hew.circulate_vertex_cw()) {
        if (s_dsc->is_interface(hew.halfedge())) {
            L += (s_dsc->get_pos(hew.vertex()) - new_pos).length();
        }
    }
    
    return L;
}
예제 #4
0
        static BOOST_FORCEINLINE Vector sincos( input_t const & input, Vector & cosine )
        {
            Vector sine;

        #if defined( _MSC_VER ) && defined( _M_IX86 )
            Vector::value_type * const p_sine  ( sine  .data() );
            Vector::value_type * const p_cosine( cosine.data() );

            // http://software.intel.com/en-us/forums/showthread.php?t=74354
            // http://www.devmaster.net/forums/showthread.php?t=5784

            unsigned int const vector_size( Vector::static_size );
            long double  const omega_scale( input.omega_scale   );
            long double  const N          ( input.N             );
            unsigned int       local_index( input.index         );
            __asm
            {
                mov ecx, vector_size
                mov edx, p_sine
                mov edi, p_cosine
            sincos_loop:
                fldpi
                fldpi
                fadd
                //...zzz...direct version seems to work the same?
                //fld [omega_scale]
                //fmul
                //fild [local_index]
                //fmul
                //fld [N]
                //fdiv
                fmul  [omega_scale]
                fimul [local_index]
                fdiv  [N]
                fsincos
                fstp [edi]
                add edi, 4
                fstp [edx]
                add edx, 4

                inc [local_index]
                dec ecx
                jnz sincos_loop
            }

        #else // 32 bit x86 MSVC

            long double const omega_scale( input.omega_scale );
            long double const N          ( input.N           );
            int         const index      ( input.index       );

            for ( unsigned i( 0 ); i < Vector::static_size; ++i )
            {
                long double const omega( ( index + i ) * omega_scale * full_circle() / N );

                sine  [ i ] = std::sin( omega );
                cosine[ i ] = std::cos( omega );
            }

        #endif // 32 bit x86 MSVC

            return sine;
        }