bool WdeSBNoodleSize( OBJPTR obj, bool recreate ) { HWND hWnd; WdeSBarObject *sb_obj; if( obj == NULL ) { return( FALSE ); } sb_obj = (WdeSBarObject *)obj; if( recreate ) { Forward( obj, DESTROY_WINDOW, FALSE, NULL ); Forward( obj, CREATE_WINDOW, FALSE, NULL ); } if( Forward( (OBJPTR)sb_obj->object_handle, GET_WINDOW_HANDLE, &hWnd, NULL ) ) { WdeResInfo *rinfo; rinfo = WdeGetCurrentRes(); if( rinfo != NULL ) { RECT rect; GetWindowRect( hWnd, &rect ); MapWindowPoints( (HWND)NULL, rinfo->forms_win, (POINT *)&rect, 2 ); HideSelectBoxes(); Resize( sb_obj->control, &rect, FALSE ); WdeUpdateCDialogUnits( sb_obj->control, &rect, NULL ); ShowSelectBoxes(); } } return( TRUE ); }
Bool WdeDeleteAllObjects( void ) { OBJPTR base; OBJPTR child; if( !WdeGetNumRes() ) { return( FALSE ); } child = NULL; base = GetMainObject(); if( base == NULL ) { return( FALSE ); } Forward( base, GET_FIRST_CHILD, &child, NULL ); while( child != NULL ) { MakeObjectCurrent( child ); Destroy( child, FALSE ); Forward( base, GET_FIRST_CHILD, &child, NULL ); } MakeObjectCurrent( base ); return( TRUE ); }
Token LexicalAnalysis::GetKeywordOrIdentifier(string& _string) { while (IsAlphaOrUnderline(*m_bufferMoved)) { _string += *m_bufferMoved; if (!Forward()) return ERROR; } while (IsAlphaOrNumberOrUnderline(*m_bufferMoved)) { _string += *m_bufferMoved; if (!Forward()) return ERROR; } for (int i = 0; i < m_keywordLen; ++i) { if (_string == m_keyword[i]) { //the word is a keyword return (Token)i; } } //the word is an id return ID; }
void FFN< LayerTypes, OutputLayerType, InitializationRuleType, PerformanceFunction >::Predict(arma::mat& predictors, arma::mat& responses) { deterministic = true; arma::mat responsesTemp; ResetParameter(network); Forward(arma::mat(predictors.colptr(0), predictors.n_rows, 1, false, true), network); OutputPrediction(responsesTemp, network); responses = arma::mat(responsesTemp.n_elem, predictors.n_cols); responses.col(0) = responsesTemp.col(0); for (size_t i = 1; i < predictors.n_cols; i++) { Forward(arma::mat(predictors.colptr(i), predictors.n_rows, 1, false, true), network); responsesTemp = arma::mat(responses.colptr(i), responses.n_rows, 1, false, true); OutputPrediction(responsesTemp, network); responses.col(i) = responsesTemp.col(0); } }
void WdeWriteSymInfo( WdeInfoStruct *is, bool same_as_last, char *s ) { bool dirty; OBJPTR obj; if( is->res_info->hash_table != NULL ) { dirty = WdeIsHashTableTouched( is->res_info->hash_table ); if( dirty && (obj = GetMainObject()) != NULL ) { Forward( obj, RESOLVE_SYMBOL, NULL, NULL ); Forward( obj, RESOLVE_HELPSYMBOL, NULL, NULL ); /* JPK */ } if( !same_as_last || dirty ) { WdeAddSymbolsToComboBox( is->res_info->hash_table, WdeInfoWindow, IDB_INFO_IDSTR ); WdeUntouchHashTable( is->res_info->hash_table ); } } else { if( !same_as_last ) { SendDlgItemMessage( WdeInfoWindow, IDB_INFO_IDSTR, CB_RESETCONTENT, 0, 0 ); } } if( s != NULL ) { WdeSetComboWithStr( s, WdeInfoWindow, IDB_INFO_IDSTR ); } }
void RedIsolationPickupAutonomous() { SensorValue[Gyroscope] = 0; StartTask(KeepArmInPosition); armPosition = minArm; Intake(127); Forward(45, 125, "none"); StopMoving(); Backward(127, 90, "none"); Intake(0); StopMoving(); TurnLeftDegrees(40); armPosition = midGoalHeight; wait10Msec(70); Intake(127); Forward(100, 60, "none"); StopMoving(); armPosition = midGoalHeight - 100; wait10Msec(50); StopTask(KeepArmInPosition); StopArm(); StartTask(StayInPosition); wait10Msec(500); Intake(0); wait10Msec(1000); StopTask(StayInPosition); }
//Go to the start void GoStart(void) { int count=0; //turn left twice LeftTurn(); LeftTurn(); //go back 8 squares while(count<8) { //increment counters count++; Forward(); } //reset current count back to zero count=0; //turn left LeftTurn(); //go forward 3 squares you are at start while(count<2) { //increment counters count++; Forward(); } motor[motorB]=0; motor[motorC]=0; wait1Msec(1000); }
Vector ADFun<Base>::ForOne(const Vector &x, size_t j) { size_t j1; size_t n = Domain(); size_t m = Range(); // check Vector is Simple Vector class with Base type elements CheckSimpleVector<Base, Vector>(); CPPAD_ASSERT_KNOWN( x.size() == n, "ForOne: Length of x not equal domain dimension for f" ); CPPAD_ASSERT_KNOWN( j < n, "ForOne: the index j is not less than domain dimension for f" ); // point at which we are evaluating the second partials Forward(0, x); // direction in which are are taking the derivative Vector dx(n); for(j1 = 0; j1 < n; j1++) dx[j1] = Base(0); dx[j] = Base(1); // dimension the return value Vector dy(m); // compute the return value dy = Forward(1, dx); return dy; }
task main() { waitForStart(); Forward(1440, 100); Turn(720, 100, right); Forward(1440, 100); Turn(720,100,right); }
Vector ADFun<Base>::Hessian(const Vector &x, size_t i) { size_t j; size_t k; size_t l; size_t n = Domain(); size_t m = Range(); // check Vector is Simple Vector class with Base type elements CheckSimpleVector<Base, Vector>(); CppADUsageError( x.size() == n, "Hessian: length of x not equal domain dimension for f" ); CppADUsageError( i < m, "Hessian: index i is not less than range dimension for f" ); // point at which we are evaluating the Hessian Forward(0, x); // define the return value Vector hes(n * n); // direction vector for calls to forward Vector u(n); for(j = 0; j < n; j++) u[j] = Base(0); // direction vector for calls to reverse Vector w(m); for(l = 0; l < m; l++) w[l] = Base(0); w[i] = Base(1); // location for return values from Reverse Vector ddw(n * 2); // loop over forward direstions for(j = 0; j < n; j++) { // evaluate partials of entire function w.r.t. j-th coordinate u[j] = Base(1); Forward(1, u); u[j] = Base(0); // evaluate derivative of partial corresponding to F_i ddw = Reverse(2, w); // return desired components for(k = 0; k < n; k++) hes[k * n + j] = ddw[k * 2 + 1]; } return hes; }
void RedInteractionCurvyAutonomous() { Intake(127); Forward(127, 40, "none"); Intake(0); VariableMove(20, 127, 80); SensorValue[Gyroscope] = 0; Forward(127, 80, "none"); StopMoving(); StartTask(StayInPosition); wait10Msec(1500); StopTask(StayInPosition); }
typeMoveList *MyPositionalGain(typePos *Position, typeMoveList *List, int av) { uint64 empty = ~Position->OccupiedBW, U, T; int to, sq; typeMoveList *sm, *p, *q; int move; sm = List; for (U = ForwardShift(BitboardMyP & SecondSixthRanks) & empty; U; BitClear(sq, U)) { to = BSF(U); if (OnThirdRank(to) && Position->sq[Forward(to)] == 0) AddGain(List, (Backward(to) << 6) | Forward(to), EnumMyP, Forward(to)); AddGain(List, (Backward(to) << 6) | to, EnumMyP, to); } for (U = BitboardMyN; U; BitClear(sq, U)) { sq = BSF(U); T = AttN[sq] & empty; AddGainTo(T, EnumMyN); } for (U = BitboardMyBL; U; BitClear(sq, U)) { sq = BSF(U); T = AttB(sq) & empty; AddGainTo(T, EnumMyBL); } for (U = BitboardMyBD; U; BitClear(sq, U)) { sq = BSF(U); T = AttB(sq) & empty; AddGainTo(T, EnumMyBD); } for (U = BitboardMyR; U; BitClear(sq, U)) { sq = BSF(U); T = AttR(sq) & empty; AddGainTo(T, EnumMyR); } for (U = BitboardMyQ; U; BitClear(sq, U)) { sq = BSF(U); T = AttQ(sq) & empty; AddGainTo(T, EnumMyQ); } sq = MyKingSq; T = AttK[sq] & empty &(~OppAttacked); AddGainTo(T, EnumMyK); List->move = 0; Sort; return List; }
Vector ADFun<Base>::Hessian(const Vector &x, const Vector &w) { size_t j; size_t k; size_t n = Domain(); // check Vector is Simple Vector class with Base type elements CheckSimpleVector<Base, Vector>(); CPPAD_ASSERT_KNOWN( size_t(x.size()) == n, "Hessian: length of x not equal domain dimension for f" ); CPPAD_ASSERT_KNOWN( size_t(w.size()) == Range(), "Hessian: length of w not equal range dimension for f" ); // point at which we are evaluating the Hessian Forward(0, x); // define the return value Vector hes(n * n); // direction vector for calls to forward Vector u(n); for(j = 0; j < n; j++) u[j] = Base(0); // location for return values from Reverse Vector ddw(n * 2); // loop over forward directions for(j = 0; j < n; j++) { // evaluate partials of entire function w.r.t. j-th coordinate u[j] = Base(1); Forward(1, u); u[j] = Base(0); // evaluate derivative of partial corresponding to F_i ddw = Reverse(2, w); // return desired components for(k = 0; k < n; k++) hes[k * n + j] = ddw[k * 2 + 1]; } return hes; }
void WdeSOP( OBJPTR obj, OBJPTR parent ) { LIST *ilist, *tlist, *clist; WdeResInfo *info; RECT orect; OBJPTR sib; OBJ_ID id; bool clear; POINT origin; info = WdeGetCurrentRes(); if( info == NULL ) { return; } GetClientRect( info->edit_win, &orect ); GetOffset( &origin ); OffsetRect( &orect, origin.x, origin.y ); if( parent == NULL ) { GetObjectParent( obj, &parent ); if( parent == NULL ) { return; } } Forward( parent, GET_SUBOBJ_LIST, &tlist, NULL ); if( tlist != NULL && WdeFindObjectsInRect( &orect, &ilist, tlist ) && ilist != NULL ) { clist = NULL; tlist = NULL; for( ; ilist != NULL; ilist = ListConsume( ilist ) ) { sib = ListElement( ilist ); if( (Forward( sib, IS_OBJECT_CLEAR, &clear, NULL ) && clear) || (Forward( sib, IDENTIFY, &id, NULL ) && id == DIALOG_OBJ) ) { WdeInsertObject( &clist, sib ); } else { WdeInsertObject( &tlist, sib ); } } if( clist != NULL ) { WdeListConcat( &tlist, clist, 0 ); ListFree( clist ); } if( tlist != NULL ) { WdeReorderObjectWindows( tlist ); ListFree( tlist ); } } }
task main() { waitForStart(); //wait1Msec(20000); nMotorEncoder[Right] = 0; Forward(3100,70); nMotorEncoder[mLift] = 0; while(nMotorEncoder[mLift] < 3800) { motor[mLift] = 50; } motor[mLift] = 0; Forward(700,70); wait1Msec(1000); Turn(720,100,right); while (getSensorReading()>2){ motor[Right] = 70; motor[Left] = 70; } motor[Right]=0; motor[Left]=0; motor[mDispenser] = -50; wait1Msec(200); motor[mDispenser] = 50; wait1Msec(200); motor[mDispenser] = 0; wait1Msec(500); Forward(5700,100); motor[mIntake] = 100; wait10Msec(10); motor[mIntake] = 0; while (getSensorReading>2){ motor[Right] = 70; motor[Left] = 70; } motor[Right]=0; motor[Left]=0; motor[mDispenser] = -50; wait1Msec(200); motor[mDispenser] = 50; wait1Msec(200); motor[mDispenser] = 0; wait1Msec(500); Backward(1700,70); wait1Msec(500); }
Dtype ForwardBackwardAdv(const vector<Blob<Dtype>* > & bottom) { Dtype loss; Forward(bottom, &loss); Backward(); BackwardAdv(); return loss; }
Vector ADFun<Base>::Jacobian(const Vector &x) { size_t i; size_t n = Domain(); size_t m = Range(); CPPAD_ASSERT_KNOWN( size_t(x.size()) == n, "Jacobian: length of x not equal domain dimension for F" ); // point at which we are evaluating the Jacobian Forward(0, x); // work factor for forward mode size_t workForward = n; // work factor for reverse mode size_t workReverse = 0; for(i = 0; i < m; i++) { if( ! Parameter(i) ) ++workReverse; } // choose the method with the least work Vector jac( n * m ); if( workForward <= workReverse ) JacobianFor(*this, x, jac); else JacobianRev(*this, x, jac); return jac; }
bool Transceiver::Onward(IMFrame & frame) { if ((frame.Header.DestinationId==myId) || (myId==0)) { return false; //this frame is for me } else { if (!Connected()) { DBGERR("&NOTCNT"); return true; } if (frame.Header.ReceiverId==myId) { if (frame.Forward()) Forward(frame); else { Backward(frame); } } else { DBGERR("&NOTMY"); } return true; } }
bool WdeSetDialogMode( WORD id ) { OBJPTR obj; WdeOrderMode mode; switch( id ) { case IDM_SET_ORDER: mode = WdeSetOrder; break; case IDM_SET_TABS: mode = WdeSetTabs; break; case IDM_SET_GROUPS: mode = WdeSetGroups; break; } if( (obj = WdeGetCurrentDialog()) != NULL ) { if( Forward( obj, SET_ORDER_MODE, &mode, NULL ) ) { return( TRUE ); } } return( FALSE ); }
void FileViewList::mousePressEvent(QMouseEvent* e) { switch (e->button()) { case Qt::XButton1: emit Back(); break; case Qt::XButton2: emit Forward(); break; // enqueue to playlist with middleClick case Qt::MidButton: { QListView::mousePressEvent(e); // we need to update the menu selection menu_selection_ = selectionModel()->selection(); MimeData* data = new MimeData; data->setUrls(UrlListFromSelection()); data->enqueue_now_ = true; emit AddToPlaylist(data); break; } default: QListView::mousePressEvent(e); break; } }
Dtype ForwardBackward(const vector<Blob<Dtype>* > & bottom) { Dtype loss; Forward(bottom, &loss); //LOG(INFO)<<"Forward done"; Backward(); return loss; }
void Net::Classify(const mxArray *mx_data, mxArray *&mx_pred) { //mexPrintMsg("Start classification..."); ReadData(mx_data); size_t test_num = data_.size1(); labels_.resize(test_num, layers_.back()->length_); labels_.reorder(true, false); size_t numbatches = DIVUP(test_num, params_.batchsize_); size_t offset = 0; Mat data_batch, pred_batch; for (size_t batch = 0; batch < numbatches; ++batch) { size_t batchsize = MIN(test_num - offset, params_.batchsize_); data_batch.resize(batchsize, data_.size2()); SubSet(data_, data_batch, offset, true); InitActiv(data_batch); Forward(pred_batch, 0); SubSet(labels_, pred_batch, offset, false); offset += batchsize; if (params_.verbose_ == 2) { mexPrintInt("Batch", (int) batch + 1); } } labels_.reorder(kMatlabOrder, true); mx_pred = mexSetMatrix(labels_); //mexPrintMsg("Classification finished"); }
static double Expectation(DdNode **nodes_ex, int lenNodes) { int i; double rootProb, CLL = 0; for (i = 0; i < lenNodes; i++) { if (!Cudd_IsConstant(nodes_ex[i])) { nodesB = init_table(boolVars_ex[i]); nodesF = init_table(boolVars_ex[i]); Forward(nodes_ex[i], i); rootProb = GetOutsideExpe(nodes_ex[i], example_prob[i], i); if (rootProb <= 0.0) CLL = CLL + LOGZERO * example_prob[i]; else CLL = CLL + log(rootProb) * example_prob[i]; nodes_probs_ex[i] = rootProb; destroy_table(nodesB, boolVars_ex[i]); destroy_table(nodesF, boolVars_ex[i]); } else if (nodes_ex[i] == Cudd_ReadLogicZero(mgr_ex[i])) { CLL = CLL + LOGZERO * example_prob[i]; nodes_probs_ex[i] = 0.0; } else nodes_probs_ex[i] = 1.0; } return CLL; }
void first(){ switch(condition) { case 0: lineTracking(); switch(sensor.middle_sensor) { case 0b00001111: case 0b00011111: case 0b00111111: case 0b01111111: case 0b00011110: case 0b00111110: condition = 1; break; } break; case 1: wheels.stop(); RightTurn(); break; case 2: CheckStop(); break; case 3: Forward(); break; case 4: BackToLine(); break; case 5: LeftTurn(); break; case 6: lineTracking(); if(sensor.front_sensor == 0b00111100 || sensor.front_sensor == 0b00011100 || sensor.front_sensor == 0b00111000) { wheels.forward(0,0); condition = 6; } break; } }
Vector ADFun<Base>::RevOne(const Vector &x, size_t i) { size_t i1; size_t n = Domain(); size_t m = Range(); // check Vector is Simple Vector class with Base type elements CheckSimpleVector<Base, Vector>(); CppADUsageError( x.size() == n, "RevOne: Length of x not equal domain dimension for f" ); CppADUsageError( i < m, "RevOne: the index i is not less than range dimension for f" ); // point at which we are evaluating the derivative Forward(0, x); // component which are are taking the derivative of Vector w(m); for(i1 = 0; i1 < m; i1++) w[i1] = 0.; w[i] = Base(1); // dimension the return value Vector dw(n); // compute the return value dw = Reverse(1, w); return dw; }
WdeDialogBoxInfo *WdeGetItemDBI( WdeResDlgItem *ditem ) { WdeDialogBoxInfo *dbi; WResID *name; if( ditem == NULL ) { return( FALSE ); } if( ditem->object != NULL ) { Forward( ditem->object, GET_OBJECT_INFO, NULL, &name ); if( name != NULL ) { name = WdeCopyWResID( name ); if( name != NULL ) { if( ditem->dialog_name != NULL ) { WRMemFree( ditem->dialog_name ); } ditem->dialog_name = name; } } dbi = WdeDBIFromObject( ditem->object ); if( dbi != NULL ) { if( ditem->dialog_info != NULL ) { WdeFreeDialogBoxInfo( ditem->dialog_info ); } ditem->dialog_info = dbi; } else { return( FALSE ); } } else { dbi = ditem->dialog_info; } return( dbi ); }
void CASWEnvSpark::CreateSpark( void ) { CUtlReference<CNewParticleEffect> pEffect = CNewParticleEffect::CreateOrAggregate( NULL, "asw_env_sparks", GetAbsOrigin(), NULL ); if ( pEffect ) { pEffect->SetControlPoint( 0, GetAbsOrigin() ); pEffect->SetControlPointOrientation( 0, Forward(), -Left(), Up() ); pEffect->SetControlPoint( 2, Vector( GetRenderColorR(), GetRenderColorG(), GetRenderColorB() ) ); float flMagnitude = m_flMagnitude/100; float flElecReduction = 1.0f; float flCollide = (m_flPercentCollide/100); float flAmtElectrical = 0; if ( m_bElectrical ) { flAmtElectrical = flMagnitude; flElecReduction = 0.6; } pEffect->SetControlPoint( 3, Vector( ((1.0f-flCollide)* flMagnitude)*flElecReduction, (flCollide*flMagnitude)*flElecReduction, flMagnitude ) ); pEffect->SetControlPoint( 4, Vector( flAmtElectrical, 0, 0 ) ); //Msg( "Spark - Magnitude = %f\n", flMagnitude ); } if ( m_bPlaySound ) { EmitSound( "DoSpark" ); } }
void Net::Classify(const mxArray *mx_data, Mat &pred) { //mexPrintMsg("Start classification..."); size_t mapnum = 1; if (mexIsCell(mx_data)) { mapnum = mexGetNumel(mx_data); } mexAssert(mapnum == layers_.front()->outputmaps_, "Data must have the same number of cells as outputmaps on the first layer"); std::vector< std::vector<Mat> > data(mapnum); for (size_t i = 0; i < mapnum; ++i) { const mxArray *mx_cell; if (mexIsCell(mx_data)) { mx_cell = mxGetCell(mx_data, i); } else { mx_cell = mx_data; } std::vector<size_t> data_dim = mexGetDimensions(mx_cell); mexAssert(data_dim.size() == 3, "The data array must have 3 dimensions"); mexAssert(data_dim[0] == layers_.front()->mapsize_[0] && data_dim[1] == layers_.front()->mapsize_[1], "Data and the first layer must have equal sizes"); mexGetMatrix3D(mx_cell, data[i]); } Forward(data, pred, false); //mexPrintMsg("Classification finished"); }
void jfolo(unsigned char count){ unsigned char junction_count=0; unsigned char timer=0; Forward(); // set motor move forward // sending display to lcd takes long time // junction reading and display less frequent. // use timer variable to count 20, then read once. while(junction_count<count){ //second junction timer++; if(timer>50){ timer=0; //clear timer motor(0,0); //slow down for lcd display do{ junction_count=LSA08_GetJunction(); //check junction count }while(ERR_FLAG||(junction_count>10)); //checking no uart error lcd_goto(0); lcd_putchar('J'); lcd_num(junction_count,3); } line_follow(); //PID line follow } Brake(); __delay_ms(200); }
/*motor functions*/ void pwm_init(void) { // Setting PWM frequency PR2 = 254; //setting of PWM frequency for a FOSC of 20MHZ T2CKPS1 = 0; T2CKPS0 = 1; // Timer 2 prescale = 4. CCPR1L = 0; // Duty cycle = 0; CCPR2L = 0; TMR2ON = 1; // Turn on Timer 2. //configuration for CCP1CON P1M1 = 0; //CCP1, P1A as single output P1M0 = 0; DC1B1 = 0; // 2 LSB of 10 PWM, make it 00 DC1B0 = 0; CCP1M3 = 1; // Configure CCP1 module to operate in PWM mode. CCP1M2 = 1; CCP1M1 = 0; CCP1M0 = 0; //configuration for CCP2CON CCP2X = 0; // 2 LSB of 10 PWM, make it 00 CCP2Y = 0; CCP2M3 = 1; // Configure CCP1 module to operate in PWM mode. CCP2M2 = 1; CCP2M1 = 0; CCP2M0 = 0; //motor foward Forward(); }