//获取电量0-100% u8 getBatteryValue() { u32 v = toVoltage(ADC.getADCValue(1)); v = RV(v); if (v < Lbattery)return 0; if (v > Hbattery)v = Hbattery; return (v - Lbattery) * 100 / (Hbattery - Lbattery); }
std::vector< std::pair<Vector3d, double> > SurfaceCard::getMacrobodyPlaneParams() const { std::vector< std::pair< Vector3d, double> > ret; if( mnemonic == "box" ){ Vector3d corner( args ); const Vector3d v[3] = {Vector3d(args,3), Vector3d(args,6), Vector3d(args,9)}; // face order: v1 -v1 v2 -v2 v3 -v3 for( int i = 0; i < 3; ++i ){ Vector3d p = corner + v[i]; ret.push_back( std::make_pair( v[i].normalize(), v[i].projection( p ).length() ) ); ret.push_back( std::make_pair( -v[i].normalize(), v[i].projection( p ).length()-v[i].length() ) ); } } else if( mnemonic == "rpp" ){ Vector3d min( args.at(0), args.at(2), args.at(4) ); Vector3d max( args.at(1), args.at(3), args.at(5) ); for( int i = 0; i < 3; ++i ){ Vector3d v; v.v[i] = 1; ret.push_back( std::make_pair( v.normalize(), max.v[i] )); ret.push_back( std::make_pair(-v.normalize(), min.v[i] )); } } else if( mnemonic == "hex" || mnemonic == "rhp" ){ Vector3d vertex( args ), height( args,3 ), RV( args, 6 ), SV, TV; if( args.size() == 9 ){ SV = RV.rotate_about(height, 60); TV = RV.rotate_about(height, 120); } else{ SV = Vector3d( args, 9 ); TV = Vector3d( args, 12 ); } double len = RV.projection( vertex+RV ).length(); ret.push_back( std::make_pair( RV.normalize(), len ) ); ret.push_back( std::make_pair(-RV.normalize(), len - 2.0 * RV.length() )); len = SV.projection( vertex+SV ).length(); ret.push_back( std::make_pair( SV.normalize(), len ) ); ret.push_back( std::make_pair(-SV.normalize(), len - 2.0 * SV.length() )); len = TV.projection( vertex+TV ).length(); ret.push_back( std::make_pair( TV.normalize(), len ) ); ret.push_back( std::make_pair(-TV.normalize(), len - 2.0 * TV.length() )); len = height.projection( vertex+height ).length(); ret.push_back( std::make_pair( height.normalize(), len ) ); ret.push_back( std::make_pair(-height.normalize(), len - height.length() )); } else{ throw std::runtime_error("Tried to get macrobody plane normals of unsupported surface!" ); } return ret; }
char *riscv_isa_string(RISCVCPU *cpu) { int i; const size_t maxlen = sizeof("rv128") + sizeof(riscv_exts) + 1; char *isa_str = g_new(char, maxlen); char *p = isa_str + snprintf(isa_str, maxlen, "rv%d", TARGET_LONG_BITS); for (i = 0; i < sizeof(riscv_exts); i++) { if (cpu->env.misa & RV(riscv_exts[i])) { *p++ = qemu_tolower(riscv_exts[i]); } } *p = '\0'; return isa_str; }
IGL_INLINE Eigen::MatrixXd igl::rotate_vectors( const Eigen::MatrixXd& V, const Eigen::VectorXd& A, const Eigen::MatrixXd& B1, const Eigen::MatrixXd& B2) { Eigen::MatrixXd RV(V.rows(),V.cols()); for (unsigned i=0; i<V.rows();++i) { double norm = V.row(i).norm(); // project onto the tangent plane and convert to angle double a = atan2(B2.row(i).dot(V.row(i)),B1.row(i).dot(V.row(i))); // rotate a += (A.size() == 1) ? A(0) : A(i); // move it back to global coordinates RV.row(i) = norm*cos(a) * B1.row(i) + norm*sin(a) * B2.row(i); } return RV; }
/* * local optimizations, most of which are probably * machine independent */ NODE * optim(NODE *p) { int o, ty; NODE *sp, *q; OFFSZ sz; int i; if (odebug) return(p); ty = coptype(p->n_op); if( ty == LTYPE ) return(p); if( ty == BITYPE ) p->n_right = optim(p->n_right); p->n_left = optim(p->n_left); /* collect constants */ again: o = p->n_op; switch(o){ case SCONV: if (concast(p->n_left, p->n_type)) { q = p->n_left; nfree(p); p = q; break; } /* FALLTHROUGH */ case PCONV: if (p->n_type != VOID) p = clocal(p); break; case FORTCALL: p->n_right = fortarg( p->n_right ); break; case ADDROF: if (LO(p) == TEMP) break; if( LO(p) != NAME ) cerror( "& error" ); if( !andable(p->n_left) && !statinit) break; LO(p) = ICON; setuleft: /* paint over the type of the left hand side with the type of the top */ p->n_left->n_type = p->n_type; p->n_left->n_df = p->n_df; p->n_left->n_ap = p->n_ap; q = p->n_left; nfree(p); p = q; break; case NOT: case UMINUS: case COMPL: if (LCON(p) && conval(p->n_left, o, p->n_left)) p = nfree(p); break; case UMUL: /* Do not discard ADDROF TEMP's */ if (LO(p) == ADDROF && LO(p->n_left) != TEMP) { q = p->n_left->n_left; nfree(p->n_left); nfree(p); p = q; break; } if( LO(p) != ICON ) break; LO(p) = NAME; goto setuleft; case RS: if (LCON(p) && RCON(p) && conval(p->n_left, o, p->n_right)) goto zapright; sz = tsize(p->n_type, p->n_df, p->n_ap); if (LO(p) == RS && RCON(p->n_left) && RCON(p) && (RV(p) + RV(p->n_left)) < sz) { /* two right-shift by constants */ RV(p) += RV(p->n_left); p->n_left = zapleft(p->n_left); } #if 0 else if (LO(p) == LS && RCON(p->n_left) && RCON(p)) { RV(p) -= RV(p->n_left); if (RV(p) < 0) o = p->n_op = LS, RV(p) = -RV(p); p->n_left = zapleft(p->n_left); } #endif if (RO(p) == ICON) { if (RV(p) < 0) { RV(p) = -RV(p); p->n_op = LS; goto again; } #ifdef notyet /* must check for side effects, --a >> 32; */ if (RV(p) >= tsize(p->n_type, p->n_df, p->n_sue) && ISUNSIGNED(p->n_type)) { /* ignore signed shifts */ /* too many shifts */ tfree(p->n_left); nfree(p->n_right); p->n_op = ICON; p->n_lval = 0; p->n_sp = NULL; } else #endif /* avoid larger shifts than type size */ if (RV(p) >= sz) { RV(p) = RV(p) % sz; werror("shift larger than type"); } if (RV(p) == 0) p = zapleft(p); } break; case LS: if (LCON(p) && RCON(p) && conval(p->n_left, o, p->n_right)) goto zapright; sz = tsize(p->n_type, p->n_df, p->n_ap); if (LO(p) == LS && RCON(p->n_left) && RCON(p)) { /* two left-shift by constants */ RV(p) += RV(p->n_left); p->n_left = zapleft(p->n_left); } #if 0 else if (LO(p) == RS && RCON(p->n_left) && RCON(p)) { RV(p) -= RV(p->n_left); p->n_left = zapleft(p->n_left); } #endif if (RO(p) == ICON) { if (RV(p) < 0) { RV(p) = -RV(p); p->n_op = RS; goto again; } #ifdef notyet /* must check for side effects */ if (RV(p) >= tsize(p->n_type, p->n_df, p->n_sue)) { /* too many shifts */ tfree(p->n_left); nfree(p->n_right); p->n_op = ICON; p->n_lval = 0; p->n_sp = NULL; } else #endif /* avoid larger shifts than type size */ if (RV(p) >= sz) { RV(p) = RV(p) % sz; werror("shift larger than type"); } if (RV(p) == 0) p = zapleft(p); } break; case MINUS: if (LCON(p) && RCON(p) && p->n_left->n_sp == p->n_right->n_sp) { /* link-time constants, but both are the same */ /* solve it now by forgetting the symbols */ p->n_left->n_sp = p->n_right->n_sp = NULL; } if( !nncon(p->n_right) ) break; RV(p) = -RV(p); o = p->n_op = PLUS; case MUL: /* * Check for u=(x-y)+z; where all vars are pointers to * the same struct. This has two advantages: * 1: avoid a mul+div * 2: even if not allowed, people may get surprised if this * calculation do not give correct result if using * unaligned structs. */ if (p->n_type == INTPTR && RCON(p) && LO(p) == DIV && RCON(p->n_left) && RV(p) == RV(p->n_left) && LO(p->n_left) == MINUS) { q = p->n_left->n_left; if (q->n_left->n_type == PTR+STRTY && q->n_right->n_type == PTR+STRTY && strmemb(q->n_left->n_ap) == strmemb(q->n_right->n_ap)) { p = zapleft(p); p = zapleft(p); } } /* FALLTHROUGH */ case PLUS: case AND: case OR: case ER: /* commutative ops; for now, just collect constants */ /* someday, do it right */ if( nncon(p->n_left) || ( LCON(p) && !RCON(p) ) ) SWAP( p->n_left, p->n_right ); /* make ops tower to the left, not the right */ if( RO(p) == o ){ NODE *t1, *t2, *t3; t1 = p->n_left; sp = p->n_right; t2 = sp->n_left; t3 = sp->n_right; /* now, put together again */ p->n_left = sp; sp->n_left = t1; sp->n_right = t2; sp->n_type = p->n_type; p->n_right = t3; } if(o == PLUS && LO(p) == MINUS && RCON(p) && RCON(p->n_left) && conval(p->n_right, MINUS, p->n_left->n_right)){ zapleft: q = p->n_left->n_left; nfree(p->n_left->n_right); nfree(p->n_left); p->n_left = q; } if( RCON(p) && LO(p)==o && RCON(p->n_left) && conval( p->n_right, o, p->n_left->n_right ) ){ goto zapleft; } else if( LCON(p) && RCON(p) && conval( p->n_left, o, p->n_right ) ){ zapright: nfree(p->n_right); q = makety(p->n_left, p->n_type, p->n_qual, p->n_df, p->n_ap); nfree(p); p = clocal(q); break; } /* change muls to shifts */ if( o == MUL && nncon(p->n_right) && (i=ispow2(RV(p)))>=0){ if( i == 0 ) { /* multiplication by 1 */ goto zapright; } o = p->n_op = LS; p->n_right->n_type = INT; p->n_right->n_df = NULL; RV(p) = i; } /* change +'s of negative consts back to - */ if( o==PLUS && nncon(p->n_right) && RV(p)<0 ){ RV(p) = -RV(p); o = p->n_op = MINUS; } /* remove ops with RHS 0 */ if ((o == PLUS || o == MINUS || o == OR || o == ER) && nncon(p->n_right) && RV(p) == 0) { goto zapright; } break; case DIV: if( nncon( p->n_right ) && p->n_right->n_lval == 1 ) goto zapright; if (LCON(p) && RCON(p) && conval(p->n_left, DIV, p->n_right)) goto zapright; if (RCON(p) && ISUNSIGNED(p->n_type) && (i=ispow2(RV(p))) > 0) { p->n_op = RS; RV(p) = i; q = p->n_right; if(tsize(q->n_type, q->n_df, q->n_ap) > SZINT) p->n_right = makety(q, INT, 0, 0, 0); break; } break; case MOD: if (RCON(p) && ISUNSIGNED(p->n_type) && ispow2(RV(p)) > 0) { p->n_op = AND; RV(p) = RV(p) -1; break; } break; case EQ: case NE: case LT: case LE: case GT: case GE: case ULT: case ULE: case UGT: case UGE: if( !LCON(p) ) break; /* exchange operands */ sp = p->n_left; p->n_left = p->n_right; p->n_right = sp; p->n_op = revrel[p->n_op - EQ ]; break; #ifdef notyet case ASSIGN: /* Simple test to avoid two branches */ if (RO(p) != NE) break; q = p->n_right; if (RCON(q) && RV(q) == 0 && LO(q) == AND && RCON(q->n_left) && (i = ispow2(RV(q->n_left))) && q->n_left->n_type == INT) { q->n_op = RS; RV(q) = i; } break; #endif } return(p); }
void mul(zz_pX& U, zz_pX& V, const zz_pXMatrix& M) // (U, V)^T = M*(U, V)^T { long d = deg(U) - deg(M(1,1)); long k = NextPowerOfTwo(d - 1); // When the GCD algorithm is run on polynomials of degree n, n-1, // where n is a power of two, then d-1 is likely to be a power of two. // It would be more natural to set k = NextPowerOfTwo(d+1), but this // would be much less efficient in this case. long n = (1L << k); long xx; zz_p a0, a1, b0, b1, c0, d0, u0, u1, v0, v1, nu0, nu1, nv0; zz_p t1, t2; if (n == d-1) xx = 1; else if (n == d) xx = 2; else xx = 3; switch (xx) { case 1: GetCoeff(a0, M(0,0), 0); GetCoeff(a1, M(0,0), 1); GetCoeff(b0, M(0,1), 0); GetCoeff(b1, M(0,1), 1); GetCoeff(c0, M(1,0), 0); GetCoeff(d0, M(1,1), 0); GetCoeff(u0, U, 0); GetCoeff(u1, U, 1); GetCoeff(v0, V, 0); GetCoeff(v1, V, 1); mul(t1, (a0), (u0)); mul(t2, (b0), (v0)); add(t1, t1, t2); nu0 = t1; mul(t1, (a1), (u0)); mul(t2, (a0), (u1)); add(t1, t1, t2); mul(t2, (b1), (v0)); add(t1, t1, t2); mul(t2, (b0), (v1)); add(t1, t1, t2); nu1 = t1; mul(t1, (c0), (u0)); mul(t2, (d0), (v0)); add (t1, t1, t2); nv0 = t1; break; case 2: GetCoeff(a0, M(0,0), 0); GetCoeff(b0, M(0,1), 0); GetCoeff(u0, U, 0); GetCoeff(v0, V, 0); mul(t1, (a0), (u0)); mul(t2, (b0), (v0)); add(t1, t1, t2); nu0 = t1; break; case 3: break; } fftRep RU(INIT_SIZE, k), RV(INIT_SIZE, k), R1(INIT_SIZE, k), R2(INIT_SIZE, k); TofftRep(RU, U, k); TofftRep(RV, V, k); TofftRep(R1, M(0,0), k); mul(R1, R1, RU); TofftRep(R2, M(0,1), k); mul(R2, R2, RV); add(R1, R1, R2); FromfftRep(U, R1, 0, d); TofftRep(R1, M(1,0), k); mul(R1, R1, RU); TofftRep(R2, M(1,1), k); mul(R2, R2, RV); add(R1, R1, R2); FromfftRep(V, R1, 0, d-1); // now fix-up results switch (xx) { case 1: GetCoeff(u0, U, 0); sub(u0, u0, nu0); SetCoeff(U, d-1, u0); SetCoeff(U, 0, nu0); GetCoeff(u1, U, 1); sub(u1, u1, nu1); SetCoeff(U, d, u1); SetCoeff(U, 1, nu1); GetCoeff(v0, V, 0); sub(v0, v0, nv0); SetCoeff(V, d-1, v0); SetCoeff(V, 0, nv0); break; case 2: GetCoeff(u0, U, 0); sub(u0, u0, nu0); SetCoeff(U, d, u0); SetCoeff(U, 0, nu0); break; } }
namespace oglplus { #if !OGLPLUS_NO_VARIADIC_TEMPLATES && !OGLPLUS_NO_GLFUNC_CHECKS template <typename RV, typename ... Params> inline auto _checked_glfunc( RV (GLAPIENTRY *pfn)(Params...), const char* ) -> decltype(pfn) { return pfn; } template <typename RV, typename ... Params> inline auto _checked_glfunc( RV (* GLAPIENTRY *ppfn)(Params...), const char* func_name ) -> decltype(*ppfn) { OGLPLUS_HANDLE_ERROR_IF( (!ppfn || !*ppfn), GL_INVALID_OPERATION, MissingFunction::Message(), MissingFunction, GLFunc(func_name) ); return *ppfn; } #ifndef OGLPLUS_GLFUNC #define OGLPLUS_GLFUNC(FUNCNAME) \
double Controller::update(Angle angle, double speed, double inReward, vec inLmr, int color) { if(t%inv_sampling_rate == 0 && !SILENT){ pi_array = join_rows(pi_array, pin->get_output()); if(gvlearn_on){ gv_array = join_rows(gv_array, gvl->w(0)); } if(lvlearn_on){ for(int i = 0; i < lv_array.size(); i++) lv_array.at(i) = join_rows(lv_array.at(i), lvl->w(i)); ref_array = join_rows(ref_array, lvl->RefPI()); } } t++; /*** Check, if inward ***/ if(t > t_home || accum_reward(0) > 1.){ inward = 1.; //printf("t= %u > %u or sum(R)= %g\n", t, t_home, accum_reward(0)); } /*** Path Integration Mechanism ***/ if(pin_on) pin->update(angle, speed); if(gvlearn_on && gl_w > 0.) pi_w = HV().len() * (1. - expl_factor(0))*(1.-accu(lv_value)); else pi_w = 0.0; pi_m = ((HV().ang()).i() - angle).S(); //NEW PI COMMAND if(homing_on && inward!=0.){ //printf("this should not be! %g\n", inward); pi_w = 0.5; pi_m = ((HV().ang()).i() - angle).S(); rand_m = 0.0;//0.25; } if(pi_w < 0.) pi_w = 0.; output_hv = pi_w * pi_m; /*** Reward and value update ***/ if(lvlearn_on){ for(int i = 0; i < num_lv_units; i++) lv_value(i) = 1. - exp(-0.5*lvl->eligibility_value(i)); } delta_beta = mu_beta*((1./expl_beta) + lambda * value(0) * expl_factor(0)); if(beta_on) expl_beta += delta_beta; if(expl_factor(0) < 0.0001 && delta_beta < 0.01) beta_on = false; for(int i = 0; i < num_colors; i++){ if(i == color){ reward(i) = inReward; if(inward==0.){ value(i) = (reward(i) /*+ accu(lv_value)*/) + disc_factor * value(i); if(!const_expl) expl_factor(i) = exp(- expl_beta * value(i)); else expl_factor(i) += d_expl_factor(i); expl_factor.elem( find(expl_factor > 1.) ).ones(); //clip expl expl_factor.elem( find(expl_factor < 0.) ).zeros(); //clip expl } } else{ reward(i) = 0.0; } } accum_reward += reward; /*** Global Vector Learning Circuits TODO ***/ if(gvlearn_on){ for(int i = 0; i < num_colors; i++){ gvl->update(pin->get_output(), reward(i), expl_factor(i)); cGV.at(i) = (GV(i) - HV()); } gl_w = (1. - inward)*GV(0).len() * (1.-expl_factor(0)); gl_m = (GV(0).ang() - angle).S(); //NEW GV COMMAND } //stream << cGV.at(0).ang().deg() << endl; output_gv = gl_w * gl_m; /*** Local Vector Learning Circuits TODO ***/ if(lvlearn_on){ lvl->update(angle, speed, inReward, inLmr); rl_m = 0.0; rl_w = (1. - inward); for(int i = 0; i < num_lv_units; i++){ //cLV.at(i) = (LV(i) - HV()); if(inward == 0.){ gl_w = 0.0; pi_w = 0.0; rl_m += lv_value(i) * (LV().len()*(LV().ang() - angle).S() + RV().len()*(RV().ang().i() - angle).S()); } } //if(VERBOSE && t%100==0) //printf("t = %u\tHV = (%f, %f)\tLV = (%f, %f)\tRV = (%f, %f)\n", t, HV().ang().deg(), HV().len(), LV().ang().deg(), LV().len(), RV().ang().deg(), RV().len()); output_lv = rl_w * rl_m; } else output_lv = 0.; /*** Random foraging ***/ if(lvlearn_on){ rand_w = (1. - inward)*0.6*expl_factor(0)*(1.-accu(lv_value)); } else rand_w = (1. - inward)*0.6*expl_factor(0); rand_m = randn(0.0, 1.); if(inward == 1) rand_m = 0.; output_rand = rand_w * rand_m; /*** Navigation Control Output ***/ output = output_rand + output_hv + output_gv + output_lv; //output = output_rand + output_hv + 0.0 + output_lv; // Route formation return output; }
void mul(ZZ_pX& U, ZZ_pX& V, const ZZ_pXMatrix& M) // (U, V)^T = M*(U, V)^T { long d = deg(U) - deg(M(1,1)); long k = NextPowerOfTwo(d - 1); // When the GCD algorithm is run on polynomials of degree n, n-1, // where n is a power of two, then d-1 is likely to be a power of two. // It would be more natural to set k = NextPowerOfTwo(d+1), but this // would be much less efficient in this case. // We optimize this case, as it does sometimes arise naturally // in some situations. long n = (1L << k); long xx; ZZ_p a0, a1, b0, b1, c0, d0, u0, u1, v0, v1, nu0, nu1, nv0; NTL_ZZRegister(t1); NTL_ZZRegister(t2); if (n == d-1) xx = 1; else if (n == d) xx = 2; else xx = 3; switch (xx) { case 1: GetCoeff(a0, M(0,0), 0); GetCoeff(a1, M(0,0), 1); GetCoeff(b0, M(0,1), 0); GetCoeff(b1, M(0,1), 1); GetCoeff(c0, M(1,0), 0); GetCoeff(d0, M(1,1), 0); GetCoeff(u0, U, 0); GetCoeff(u1, U, 1); GetCoeff(v0, V, 0); GetCoeff(v1, V, 1); mul(t1, rep(a0), rep(u0)); mul(t2, rep(b0), rep(v0)); add(t1, t1, t2); conv(nu0, t1); mul(t1, rep(a1), rep(u0)); mul(t2, rep(a0), rep(u1)); add(t1, t1, t2); mul(t2, rep(b1), rep(v0)); add(t1, t1, t2); mul(t2, rep(b0), rep(v1)); add(t1, t1, t2); conv(nu1, t1); mul(t1, rep(c0), rep(u0)); mul(t2, rep(d0), rep(v0)); add (t1, t1, t2); conv(nv0, t1); break; case 2: GetCoeff(a0, M(0,0), 0); GetCoeff(b0, M(0,1), 0); GetCoeff(u0, U, 0); GetCoeff(v0, V, 0); mul(t1, rep(a0), rep(u0)); mul(t2, rep(b0), rep(v0)); add(t1, t1, t2); conv(nu0, t1); break; case 3: break; } FFTRep RU(INIT_SIZE, k), RV(INIT_SIZE, k), R1(INIT_SIZE, k), R2(INIT_SIZE, k); ToFFTRep(RU, U, k); ToFFTRep(RV, V, k); ToFFTRep(R1, M(0,0), k); mul(R1, R1, RU); ToFFTRep(R2, M(0,1), k); mul(R2, R2, RV); add(R1, R1, R2); FromFFTRep(U, R1, 0, d); ToFFTRep(R1, M(1,0), k); mul(R1, R1, RU); ToFFTRep(R2, M(1,1), k); mul(R2, R2, RV); add(R1, R1, R2); FromFFTRep(V, R1, 0, d-1); // now fix-up results switch (xx) { case 1: GetCoeff(u0, U, 0); sub(u0, u0, nu0); SetCoeff(U, d-1, u0); SetCoeff(U, 0, nu0); GetCoeff(u1, U, 1); sub(u1, u1, nu1); SetCoeff(U, d, u1); SetCoeff(U, 1, nu1); GetCoeff(v0, V, 0); sub(v0, v0, nv0); SetCoeff(V, d-1, v0); SetCoeff(V, 0, nv0); break; case 2: GetCoeff(u0, U, 0); sub(u0, u0, nu0); SetCoeff(U, d, u0); SetCoeff(U, 0, nu0); break; } }
const RV coordinates(const int & i,const int & j,const int & k) { return RV(-.5*lx_+i*deltax_,-.5*ly_+j*deltay_,-.5*lz_+k*deltaz_); };
/**************************************************************************** * Registry Parameters Table * * This table contains a list of all of the configuration parameters * that the driver supports. The driver will attempt to find these * parameters in the registry and use the registry value for these * parameters. If the parameter is not found in the registry, then the * default value is used. */ static CONFIG_PARAM paramTable[] = { /*------------------------------------------------------------------------------ *- Registry Name --------- Type -- Where to store it --------- Deflt Min Max - *------------------------------------------------------------------------------*/ /* Connection Services */ RV(bkScanEnable, tDEC, CFG(bkScanEnable), 1, 0, 1), RV(bkScanPeriod, tDEC, CFG(bkScanPeriod), 60, 0, 65535), /* Initialization Phase */ RV(byPassWmi , tDEC, CFG(byPassWmi), 0, 0, 1), RV(discTimeout, tDEC, CFG(discTimeout), 10, 0, 60), RV(resetPowerState, tDEC, CFG(resetPowerState), 1, 0, 2), RV(suspendMode, tDEC, CFG(suspendMode), 0, 0, 2), RV(wifiOnOffMode, tDEC, CFG(wifiOnOffMode), 0, 0, 2), RV(currentPowerState, tDEC, CFG(currentPowerState), 1, 0, 1), RV(ibssChannel, tDEC, CFG(ibssChannel), 0, 0, 6000000), RV(powerSaveMode, tDEC, CFG(powerSaveMode), 2, 0, 2), RV(wmmConfig, tDEC, CFG(wmmConfig), 1, 0, 1), RV(enableUARTprint, tDEC, CFG(enableUARTprint), 0, 0, 1), RV(connectCtrlFlags, tDEC, CFG(connectCtrlFlags), 0, 0, 0xFFFF), RV(wowEnable, tDEC, CFG(wowEnable), 0, 0, 1),
/**************************************************************************** * Registry Parameters Table * * This table contains a list of all of the configuration parameters * that the driver supports. The driver will attempt to find these * parameters in the registry and use the registry value for these * parameters. If the parameter is not found in the registry, then the * default value is used. */ static CONFIG_PARAM paramTable[] = { /*------------------------------------------------------------------------------ *- Registry Name --------- Type -- Where to store it --------- Deflt Min Max - *------------------------------------------------------------------------------*/ /* Connection Services */ RV(bkScanEnable, tDEC, CFG(bkScanEnable), 0, 0, 1), RV(bkScanPeriod, tDEC, CFG(bkScanPeriod), 5, 0, 65535), /* Security */ RV(wpaEnabled, tDEC, CFG(wpaEnabled), 0, 0, 1), RV(wpa2Enabled, tDEC, CFG(wpa2Enabled), 0, 0, 1), /* Initialization Phase */ RV(defaultApp , tDEC, CFG(defaultApp), 1, 0, 1), RV(byPassWmi , tDEC, CFG(byPassWmi), 0, 0, 1), RV(discTimeout, tDEC, CFG(discTimeout), 0, 0, 60), RV(resetPowerState, tDEC, CFG(resetPowerState), 1, 0, 1), RV(ibssChannel, tDEC, CFG(ibssChannel), 0, 0, 6000000), RV(powerSaveMode, tDEC, CFG(powerSaveMode), 2, 0, 2), };
/**************************************************************************** * Registry Parameters Table * * This table contains a list of all of the configuration parameters * that the driver supports. The driver will attempt to find these * parameters in the registry and use the registry value for these * parameters. If the parameter is not found in the registry, then the * default value is used. */ static CONFIG_PARAM paramTable[] = { /*------------------------------------------------------------------------------ *- Registry Name --------- Type -- Where to store it --------- Deflt Min Max - *------------------------------------------------------------------------------*/ /* Connection Services */ RV(bkScanEnable, tDEC, CFG(bkScanEnable), 1, 0, 1), RV(bkScanPeriod, tDEC, CFG(bkScanPeriod), 5, 0, 65535), /* Security */ RV(wpaEnabled, tDEC, CFG(wpaEnabled), 0, 0, 1), RV(wpa2Enabled, tDEC, CFG(wpa2Enabled), 0, 0, 1), /* Initialization Phase */ RV(defaultApp, tDEC, CFG(defaultApp), 1, 0, 1), RV(byPassWmi , tDEC, CFG(byPassWmi), 0, 0, 1), RV(discTimeout, tDEC, CFG(discTimeout), 5, 0, 60), RV(resetPowerState, tDEC, CFG(resetPowerState), 1, 0, 1), RV(ibssChannel, tDEC, CFG(ibssChannel), 0, 0, 6000000), RV(powerSaveMode, tDEC, CFG(powerSaveMode), 2, 0, 2), RV(nodeAge, tDEC, CFG(nodeAge), 12000, 3000, 15000), RV(tcmd, tDEC, CFG(tcmd), 0, 0, 1),
static int _find_middle_snake(const void *a,int aoff,int n, const void *b,int boff,int m, MatchContext *ctx, MiddleSnake *ms) { int delta,odd,mid,d; delta=n - m; odd=delta & 1; mid=(n+m) / 2; mid += odd; _setv(ctx,1,0,0); _setv(ctx,delta - 1,1,n); for(d=0; d <= mid; d++) { int k,x,y; if((2 * d - 1) >= ctx->dmax) { return ctx->dmax; } for(k=d; k >= -d; k -= 2) { if(k==-d ||(k != d && FV(k - 1)<FV(k+1))) { x=FV(k+1); } else { x=FV(k - 1)+1; } y=x - k; ms->x=x; ms->y=y; const unsigned char *a0=(const unsigned char *)a+aoff; const unsigned char *b0=(const unsigned char *)b+boff; while(x<n && y<m && a0[x]==b0[y]) { x++; y++; } _setv(ctx,k,0,x); if(odd && k >=(delta -(d - 1)) && k <=(delta +(d - 1))) { if(x >= RV(k)) { ms->u=x; ms->v=y; return 2 * d - 1; } } } for(k=d; k >= -d; k -= 2) { int kr=(n - m)+k; if(k==d ||(k != -d && RV(kr - 1)<RV(kr+1))) { x=RV(kr - 1); } else { x=RV(kr+1) - 1; } y=x - kr; ms->u=x; ms->v=y; const unsigned char *a0=(const unsigned char *)a+aoff; const unsigned char *b0=(const unsigned char *)b+boff; while(x > 0 && y > 0 && a0[x - 1]==b0[y - 1]) { x--; y--; } _setv(ctx,kr,1,x); if(!odd && kr >= -d && kr <= d) { if(x <= FV(kr)) { ms->x=x; ms->y=y; return 2 * d; } } } } errno=EFAULT; return -1; }