void dfs_loop(graph_matrix g, int *degree, int beg, stack<int>& path) {//返回的path中从底至顶 逆序存储着欧拉回路的所有顶点下标号 //对path出栈即可得到欧拉回路 path初始为空 path.push(beg); //找出beg相邻节点中度数最大的节点 对他进行下一次dfs int d_max = max_degree(g, degree, beg); //终止递归条件 若beg没有邻节点则递归搜索结束 if(d_max == -1) return; //每次从当前节点向外找一条新的边 //并将当前走过的路删除 g.g_m[beg][d_max] = 0; g.g_m[d_max][beg] = 0; //当前节点和下一个节点的度数也减1 -- degree[beg]; -- degree[d_max]; dfs_loop(g, degree, d_max, path); }
static __inline__ mp_limb_t choose_prime_and_degree(p_k_pk_t* pp,nmod_t* mod,n_primes_rev_t it, const mpz_t divisor) { mp_limb_t r,t=1,r_mod_p; for(;;) { if( (pp->p = n_primes_rev_next(it)) == 1 ) { flint_printf("Exception (choose_prime_and_degree): " "Prime set exhausted\n"); abort(); } if( pp->p >= (UWORD(1)<<(FLINT_BITS/2)) ) { pp->k=1; r=r_mod_p=mpz_fdiv_ui( divisor, pp->p_deg_k=pp->p ); t=0; } else { max_degree( pp ); r=mpz_fdiv_ui( divisor, pp->p_deg_k ); r_mod_p=r % pp->p; } if(r_mod_p) { if(t) count_leading_zeros( t, pp->p_deg_k ); mod->n = pp->p_deg_k << t; invert_limb(mod->ninv, mod->n); #if SPEEDUP_NMOD_RED3 t = - mod->n; mod->norm = n_mulmod_preinv_4arg( t,t, mod->n,mod->ninv ); #else mod->norm = 0; #endif return inv_mod_pk_4arg(r,r_mod_p,pp[0],mod[0]); } } }
void create_flat_capped_surface_test() { typedef eli::geom::surface::piecewise_capped_surface_creator<data_type, 3, tolerance_type> capped_creator_type; piecewise_surface_type s_orig; bool rtn_flag; // create cylinder with both ends open { typedef eli::geom::surface::piecewise_general_skinning_surface_creator<data_type, 3, tolerance_type> skinning_creator_type; typedef typename eli::geom::surface::connection_data<data__, 3, tolerance_type> rib_data_type; typedef typename rib_data_type::curve_type rib_curve_type; index_type nsegs(2); std::vector<rib_data_type> ribs(nsegs+1); std::vector<typename skinning_creator_type::index_type> max_degree(nsegs); std::vector<data_type> u(nsegs+1); rib_curve_type rc1, rc2, rc3; skinning_creator_type gc; // create the 3 ribs { eli::geom::curve::piecewise_circle_creator<data_type, 3, tolerance_type> circle_creator; point_type start, origin; // set the parameters for first circle u[0]=-1; start << 1, 0, 0; origin << 0, 0, 0; // create the first circle circle_creator.set(start, origin); rtn_flag = circle_creator.create(rc1); TEST_ASSERT(rtn_flag); // set the parameters for second circle u[1]=1; start << 1, 0, 1; origin << 0, 0, 1; // create the second circle circle_creator.set(start, origin); rtn_flag = circle_creator.create(rc2); TEST_ASSERT(rtn_flag); // set the parameters for third circle u[2]=2; start << 1, 0, 3; origin << 0, 0, 3; // create the third circle circle_creator.set(start, origin); rtn_flag = circle_creator.create(rc3); TEST_ASSERT(rtn_flag); } // set the rib data ribs[0].set_f(rc1); ribs[1].set_f(rc2); ribs[2].set_f(rc3); // set the maximum degrees of each segment max_degree[0]=0; // create the cylinder rtn_flag=gc.set_conditions(ribs, max_degree, false); TEST_ASSERT(rtn_flag); gc.set_u0(u[0]); gc.set_segment_du(u[1]-u[0], 0); gc.set_segment_du(u[2]-u[1], 1); rtn_flag = gc.create(s_orig); TEST_ASSERT(rtn_flag); // if (rtn_flag && (typeid(data_type)==typeid(float))) // { // std::cout.flush(); // eli::test::octave_start(1); // eli::test::octave_print(1, ribs[0].get_f(), "rib0", true); // eli::test::octave_print(1, ribs[1].get_f(), "rib1", true); // eli::test::octave_print(1, ribs[2].get_f(), "rib2", true); // eli::test::octave_print(1, s_orig, "surf", true); // eli::test::octave_finish(1); // } } // cap umin edge { piecewise_surface_type s_umin_cap(s_orig); capped_creator_type cc; rtn_flag = cc.set_conditions(s_umin_cap, 0.5, capped_creator_type::CAP_UMIN); TEST_ASSERT(rtn_flag); rtn_flag = cc.create(s_umin_cap); TEST_ASSERT(rtn_flag); // if (rtn_flag && (typeid(data_type)==typeid(float))) // { // std::cout.flush(); // eli::test::octave_start(1); // eli::test::octave_print(1, s_umin_cap, "surf", true); // eli::test::octave_finish(1); // } } // cap umax edge { piecewise_surface_type s_umax_cap(s_orig); capped_creator_type cc; rtn_flag = cc.set_conditions(s_umax_cap, 0.5, capped_creator_type::CAP_UMAX); TEST_ASSERT(rtn_flag); rtn_flag = cc.create(s_umax_cap); TEST_ASSERT(rtn_flag); // if (rtn_flag && (typeid(data_type)==typeid(float))) // { // std::cout.flush(); // eli::test::octave_start(1); // eli::test::octave_print(1, s_umax_cap, "surf", true); // eli::test::octave_finish(1); // } } // cap umin & umax edge { piecewise_surface_type s_uminmax_cap(s_orig); capped_creator_type cc; rtn_flag = cc.set_conditions(s_uminmax_cap, 0.5, capped_creator_type::CAP_UMIN); TEST_ASSERT(rtn_flag); rtn_flag = cc.create(s_uminmax_cap); TEST_ASSERT(rtn_flag); rtn_flag = cc.set_conditions(s_uminmax_cap, 0.5, capped_creator_type::CAP_UMAX); TEST_ASSERT(rtn_flag); rtn_flag = cc.create(s_uminmax_cap); TEST_ASSERT(rtn_flag); if (rtn_flag && (typeid(data_type)==typeid(float))) { std::cout.flush(); eli::test::octave_start(1); eli::test::octave_print(1, s_uminmax_cap, "surf", true); eli::test::octave_finish(1); } } }