void Backward(const arma::Cube<eT>& /* unused */, const arma::Mat<eT>& gy, arma::Cube<eT>& g) { // Generate a cube from the error matrix. arma::Cube<eT> mappedError = arma::zeros<arma::cube>(outputParameter.n_rows, outputParameter.n_cols, outputParameter.n_slices); for (size_t s = 0, j = 0; s < mappedError.n_slices; s+= gy.n_cols, j++) { for (size_t i = 0; i < gy.n_cols; i++) { arma::Col<eT> temp = gy.col(i).subvec( j * outputParameter.n_rows * outputParameter.n_cols, (j + 1) * outputParameter.n_rows * outputParameter.n_cols - 1); mappedError.slice(s + i) = arma::Mat<eT>(temp.memptr(), outputParameter.n_rows, outputParameter.n_cols); } } Backward(inputParameter, mappedError, g); }
void AudioIn::getFFTdata() { if(this->data.frameIndex == 0) this->getAudioData(); fftwpp::fftw::maxthreads=get_max_threads(); unsigned int n=pow(2,17); unsigned int np=n/2+1; size_t align=sizeof(Complex); qDebug() << "Now aquiring the FFTW, building up the arrays for " << numSamples << " data!"; Array::array1<Complex> F(np,align); Array::array1<double> f(n,align); // For out-of-place transforms // array1<double> f(2*np,(double *) F()); // For in-place transforms fftwpp::rcfft1d Forward(n,f,F); fftwpp::crfft1d Backward(n,F,f); qDebug() << "Applying filtering"; this->applyHanningWindow(); QVector<double> Amplitude; qDebug() << "Putting " << numSamples << " into an array!"; for(unsigned int i = 0; i < n; i++) f[i] = this->data.recordedSamples[i]; qDebug() << "input:\n" << f[0] << '\n'; Forward.fft(f,F); qDebug() << "output:\n" << F[0].real() << ", " << F[0].imag() << '\n'; for(unsigned int i = 0; i < np; i++) Amplitude.append(F[i].real()*F[i].real()+F[i].imag()*F[i].imag()); emit this->currentSound(Amplitude); if(this->data.recordedSamples != NULL) memset(this->data.recordedSamples, 0, this->numBytes); this->data.frameIndex = 0; }
void main() { Sound_Init(&PORTC, 0); // Init Sound while(PORTA.F4==1); Sound_Play(2000,50); // 2 kHz sound ON RC0 Forward(255); // Call Forward Delay_ms(2000); Sound_Play(2000,50); // 2 kHz sound ON RC0 S_Left(255); // Call Spin Left Delay_ms(800); Sound_Play(2000,50); // 2 kHz sound ON RC0 Forward(255); // Call Forward Delay_ms(2000); Sound_Play(2000,50); // 2 kHz sound ON RC0 S_Right(255); // Call Spin Right Delay_ms(800); Sound_Play(2000,50); // 2 kHz sound ON RC0 Forward(255); // Call Forward Delay_ms(2000); Sound_Play(2000,50); // 2 kHz sound ON RC0 S_Left(255); // Call Spin Left Delay_ms(800); Sound_Play(2000,50); // 2 kHz sound ON RC0 Backward(255); // Call Backward Delay_ms(1000); Sound_Play(2000,50); // 2 kHz sound ON RC0 Motor_Stop(); // Stop all }
Dtype ForwardBackward(const vector<Blob<Dtype>* > & bottom) { Dtype loss; Forward(bottom, &loss); Backward(); return loss; }
void Net::Train(const mxArray *mx_data, const mxArray *mx_labels) { //mexPrintMsg("Start training..."); LayerFull *lastlayer = static_cast<LayerFull*>(layers_.back()); std::vector<size_t> labels_dim = mexGetDimensions(mx_labels); mexAssert(labels_dim.size() == 2, "The label array must have 2 dimensions"); mexAssert(labels_dim[0] == lastlayer->length_, "Labels and last layer must have equal number of classes"); size_t train_num = labels_dim[1]; Mat labels(labels_dim); mexGetMatrix(mx_labels, labels); classcoefs_.assign(labels_dim[0], 1); if (params_.balance_) { Mat labels_mean(labels_dim[0], 1); labels.Mean(2, labels_mean); for (size_t i = 0; i < labels_dim[0]; ++i) { mexAssert(labels_mean(i) > 0, "Balancing impossible: one of the classes is not presented"); (classcoefs_[i] /= labels_mean(i)) /= labels_dim[0]; } } if (lastlayer->function_ == "SVM") { (labels *= 2) -= 1; } 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 map = 0; map < mapnum; ++map) { const mxArray *mx_cell; if (mexIsCell(mx_data)) { mx_cell = mxGetCell(mx_data, map); } 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"); mexAssert(data_dim[2] == train_num, "All data maps and labels must have equal number of objects"); mexGetMatrix3D(mx_cell, data[map]); } size_t numbatches = ceil((double) train_num/params_.batchsize_); trainerror_.assign(params_.numepochs_ * numbatches, 0); for (size_t epoch = 0; epoch < params_.numepochs_; ++epoch) { std::vector<size_t> randind(train_num); for (size_t i = 0; i < train_num; ++i) { randind[i] = i; } if (params_.shuffle_) { std::random_shuffle(randind.begin(), randind.end()); } std::vector<size_t>::const_iterator iter = randind.begin(); for (size_t batch = 0; batch < numbatches; ++batch) { size_t batchsize = std::min(params_.batchsize_, (size_t)(randind.end() - iter)); std::vector<size_t> batch_ind = std::vector<size_t>(iter, iter + batchsize); iter = iter + batchsize; std::vector< std::vector<Mat> > data_batch(mapnum); for (size_t map = 0; map < mapnum; ++map) { data_batch[map].resize(batchsize); for (size_t i = 0; i < batchsize; ++i) { data_batch[map][i] = data[map][batch_ind[i]]; } } Mat labels_batch(labels_dim[0], batchsize); Mat pred_batch(labels_dim[0], batchsize); labels.SubMat(batch_ind, 2 ,labels_batch); UpdateWeights(false); Forward(data_batch, pred_batch, true); Backward(labels_batch, trainerror_[epoch * numbatches + batch]); UpdateWeights(true); if (params_.verbose_ == 2) { std::string info = std::string("Epoch: ") + std::to_string(epoch+1) + std::string(", batch: ") + std::to_string(batch+1); mexPrintMsg(info); } } // batch if (params_.verbose_ == 1) { std::string info = std::string("Epoch: ") + std::to_string(epoch+1); mexPrintMsg(info); } } // epoch //mexPrintMsg("Training finished"); }
Dtype ForwardBackward() { Dtype loss; Forward(&loss); Backward(); return loss; }
void ProgrammingSkillsAutonomous() { armPosition = SensorValue[ArmPoten]; SensorValue[Gyroscope] = 0; StartTask(KeepArmInPosition); // A: Pick up stack at intersection armPosition = stackHeight; Intake(127); wait10Msec(40); Forward(45, 35, "none"); // B: Forward on line to doubler, pick up doubler, stop at intersection ForwardOnLine(45, 50, "none"); Intake(0); ForwardOnLine(45, 100, "none"); ForwardOnLine(45, 40, "none"); /// Intake(127); armPosition = minArm + 20; Forward(55, 100, "Intersection"); StopMoving(); armPosition = minArm + 100; Backward(45, 10, "Intersection"): Backward(45, 7, "none"): StopMoving(); // C: Turn 90° left to face 30" goal, forward, score doubler + 5 objects in 30" goal TurnLeftDegrees(91); Intake(0); armPosition = maxArm + 50; wait10Msec(100); Forward(50, 33.5, "none"); StopMoving(); Intake(-127); wait10Msec(60); Intake(-65); wait10Msec(60); Intake(-120); wait10Msec(40); Intake(-65); wait10Msec(60); Intake(-120); wait10Msec(80); // Intake(-127); // wait10Msec(250); Intake(0); // D: Back up, lower arm, forward and pick up stack in front of 30" goal //start of what grace programmed Backward(50, 50, "Intersection"); wait10Msec(5); StopMoving(); wait10Msec(20); armPosition = stackHeight + 20; wait10Msec(90); Intake(127); Forward(35, 28, "none"): StopMoving(); // E: Back up, turn 90° right to face 11.5" goal, score 11.5" goal Backward(35, 40, "Intersection"); Backward(35, 8, "none"); StopMoving(); TurnRightDegrees(90); Intake(0); armPosition = lowGoalHeight; wait10Msec(20); Forward(35, 16, "none"); StopMoving(); wait10Msec(10); Intake(-85); wait10Msec(50); Intake(-0); wait10Msec(20); Intake(-85); wait10Msec(70); Intake(0); // F: Back up to intersection, turn 90° right, forward a lot, pick up stack, score stack on 11.5" goal Backward(85, 30, "none"); armPosition = stackHeight; // Backward(85, 50, "none"); // Backward(65, 35, "none"); // Backward(45, 40, "none"); Backward(85, 120, "none"); Backward(35, 70, "Intersection"); wait10Msec(1); StopMoving(); TurnRightDegrees(90); ForwardOnLine(35, 20, "none"); ForwardOnLine(45, 80, "none"); Intake(127); ForwardOnLine(45, 53, "none"); // armPosition = stackHeight;//// Forward(45, 40, "Intersection"); StopMoving(); armPosition = lowGoalHeight + 40; wait10Msec(40); Forward(45, 25, "none"); StopMoving(); Intake(-100); wait10Msec(55); Intake(-0); wait10Msec(20); Intake(-85); wait10Msec(55); Intake(0); // G: Back up, pick up stack in front of 11.5" goal, back up to intersection, turn 90° left Backward(55, 28, "none"); StopMoving(); armPosition = stackHeight + 20; Intake(127); Forward(45, 40, "none"); StopMoving(); Backward(55, 60, "Intersection"); Backward(45, 5, "none"); StopMoving(); TurnLeftDegrees(90); Backward(85, 40, "none"); StopMoving(); Intake(0); //======================================== PART 2 =============================================================== while (SensorValue[Bump] == 0) {} // A2: Go forward SensorValue[Gyroscope] = 0; Forward(50, 30, "none"); // B2: Forward on line to doubler, pick up doubler, stop at intersection ForwardOnLine(45, 130, "none"); // ForwardOnLine(45, 20, "none");/// Intake(127); armPosition = minArm + 40; Forward(55, 100, "Intersection"); StopMoving(); armPosition = minArm + 120; Backward(45, 10, "Intersection"): Backward(45, 5, "none"): StopMoving(); // C2: Turn 90° right to face 30" goal, forward, score doubler + 5 objects in 30" goal Intake(0); TurnRightDegrees(91); // Intake(0); StartTask(KeepArmInPosition); armPosition = maxArm + 50; wait10Msec(90); Forward(40, 40.5, "none"); StopMoving(); Intake(-100); wait10Msec(60); Intake(-55); wait10Msec(90); Intake(-100); wait10Msec(50); Intake(-55); wait10Msec(60); Intake(0); // D2: Back up, lower arm, forward and pick up stack in front of 30" goal Backward(55, 50, "Intersection"); StopMoving(); wait10Msec(20); armPosition = stackHeight; wait10Msec(100); Intake(127); Forward(45, 22, "none"): StopMoving(); // E2: Back up, turn 180° left to face 20" goal, forward and pick up 2 objects Backward(55, 50, "Intersection"); StopMoving(); TurnLeftDegrees(186); Intake(0); armPosition = stackHeight + 180; wait10Msec(10); Intake(127); Forward(55, 14, "none"); StopMoving(); wait10Msec(5); armPosition = stackHeight + 300; Backward(55, 6, "none"); armPosition = minArm + 60; wait10Msec(5); Forward(55, 30, "none"); Backward(55, 20, "none"); StopMoving(); //F2: Raise arm to midgoal height, score 2 and 2 on 20" goals armPosition = midGoalHeight + 40; wait10Msec(100); Intake(0); Forward(55, 13, "none"); StopMoving(); wait10Msec(10); Intake(-95); wait10Msec(300); /* wait10Msec(80); Intake(100); Forward(55, 27, "none"); StopMoving(); Intake(-95); wait10Msec(160); */ StopTask(KeepArmInPosition); }
Dtype ForwardBackward(const vector<Blob<Dtype>* > & bottom) { Forward(bottom); return Backward(); }
int lecteur_audio( int xp, int yp, int numero) { Rect FramePlayer(Vec2D(xp-5,yp-5),Vec2D(340,135)); FramePlayer.SetRoundness(5); FramePlayer.Draw(CouleurBleuProcedure.WithAlpha(0.7)); Rect Player(Vec2D(xp,yp),Vec2D(200,20)); Player.SetRoundness(5); Player.Draw(CouleurConfig.WithAlpha(0.8)); Player.DrawOutline(CouleurLigne); Canvas::SetClipping( xp,yp,200,20); petitdoomInspekt.Print(ol::ToString(numero+1),xp+5,yp+12); petitchiffre.Print(sound_files[numero],xp+20,yp+12); Canvas::DisableClipping(); //PLAY / Pause Rect Play(Vec2D(xp,yp+30),Vec2D(20,20)); Play.SetRoundness(4); Play.Draw(CouleurBlind.WithAlpha( player_is_playing[numero])); Play.Draw(CouleurFond.WithAlpha(0.5)); Play.DrawOutline(CouleurLigne); Line(Vec2D(xp+6,yp+34),Vec2D(xp+6,yp+46)).Draw(CouleurLigne); Line(Vec2D(xp+6,yp+34),Vec2D(xp+16,yp+40)).Draw(CouleurLigne); Line(Vec2D(xp+6,yp+46),Vec2D(xp+16,yp+40)).Draw(CouleurLigne); petitpetitchiffre.Print(time_is_for_filePos[numero],xp+120,yp+40); petitpetitchiffre.Print(time_is_for_fileTotal[numero],xp+120,yp+50); //SEEK TO 0 Rect SeekToZero(Vec2D(xp+25,yp+30),Vec2D(20,20)); SeekToZero.SetRoundness(4); SeekToZero.Draw(CouleurFond.WithAlpha(0.5)); Line(Vec2D(xp+41,yp+34),Vec2D(xp+41,yp+46)).Draw(CouleurLigne); Line(Vec2D(xp+41,yp+34),Vec2D(xp+31,yp+40)).Draw(CouleurLigne); Line(Vec2D(xp+31,yp+40),Vec2D(xp+41,yp+46)).Draw(CouleurLigne); Line(Vec2D(xp+29,yp+34),Vec2D(xp+29,yp+46)).Draw(CouleurLigne); SeekToZero.DrawOutline(CouleurLigne); if(midi_show_flash_seektouch[numero]==1){SeekToZero.Draw(CouleurFader);midi_show_flash_seektouch[numero]=0;} //GENERAL LOOP Rect GeneralLoop(Vec2D(xp+50,yp+30),Vec2D(20,20)); GeneralLoop.SetRoundness(4); GeneralLoop.Draw(CouleurFond.WithAlpha(0.5)); GeneralLoop.DrawOutline(CouleurLigne.WithAlpha(0.5)); Circle(Vec2D(xp+60,yp+40),5).Draw(CouleurFader.WithAlpha(player_is_onloop[numero])); Circle(Vec2D(xp+60,yp+40),5).DrawOutline(CouleurLigne); //SEEK TO End Rect SeekToEnd(Vec2D(xp+75,yp+30),Vec2D(20,20)); SeekToEnd.SetRoundness(4); SeekToEnd.Draw(CouleurFond.WithAlpha(0.5)); Line(Vec2D(xp+79,yp+34),Vec2D(xp+79,yp+46)).Draw(CouleurLigne); Line(Vec2D(xp+79,yp+34),Vec2D(xp+89,yp+40)).Draw(CouleurLigne); Line(Vec2D(xp+89,yp+40),Vec2D(xp+79,yp+46)).Draw(CouleurLigne); Line(Vec2D(xp+91,yp+34),Vec2D(xp+91,yp+46)).Draw(CouleurLigne); SeekToEnd.DrawOutline(CouleurLigne); //Backward position Rect Backward(Vec2D(xp,yp+60),Vec2D(28,16)); Backward.SetRoundness(0.5); Backward.Draw(CouleurFond.WithAlpha(0.5)); Backward.DrawOutline(CouleurLigne.WithAlpha(0.5)); if(midi_show_flash_backwardtouch[numero]==1){Backward.Draw(CouleurBlind);midi_show_flash_backwardtouch[numero]=0;} Line(Vec2D(xp+16,yp+62),Vec2D(xp+16,yp+74)).Draw(CouleurLigne); Line(Vec2D(xp+16,yp+62),Vec2D(xp+6,yp+68)).Draw(CouleurLigne); Line(Vec2D(xp+16,yp+74),Vec2D(xp+6,yp+68)).Draw(CouleurLigne); Line(Vec2D(xp+26,yp+62),Vec2D(xp+26,yp+74)).Draw(CouleurLigne); Line(Vec2D(xp+26,yp+62),Vec2D(xp+16,yp+68)).Draw(CouleurLigne); Line(Vec2D(xp+26,yp+74),Vec2D(xp+16,yp+68)).Draw(CouleurLigne); //Forward position Rect Forward(Vec2D(xp+35,yp+60),Vec2D(28,16)); Forward.SetRoundness(0.5); Forward.Draw(CouleurFond.WithAlpha(0.5)); Forward.DrawOutline(CouleurLigne.WithAlpha(0.5)); if(midi_show_flash_forwardtouch[numero]==1){Forward.Draw(CouleurBlind);midi_show_flash_forwardtouch[numero]=0;} Line(Vec2D(xp+36,yp+62),Vec2D(xp+36,yp+74)).Draw(CouleurLigne); Line(Vec2D(xp+36,yp+62),Vec2D(xp+46,yp+68)).Draw(CouleurLigne); Line(Vec2D(xp+36,yp+74),Vec2D(xp+46,yp+68)).Draw(CouleurLigne); Line(Vec2D(xp+46,yp+62),Vec2D(xp+46,yp+74)).Draw(CouleurLigne); Line(Vec2D(xp+46,yp+62),Vec2D(xp+56,yp+68)).Draw(CouleurLigne); Line(Vec2D(xp+46,yp+74),Vec2D(xp+56,yp+68)).Draw(CouleurLigne); //previous position Rect Previous(Vec2D(xp,yp+85),Vec2D(45,16)); Previous.SetRoundness(0.5); Previous.Draw(CouleurFond.WithAlpha(0.5)); Previous.DrawOutline(CouleurLigne.WithAlpha(0.5)); petitchiffre.Print("PREV",xp+6,yp+96); //nEXT TRACK position Rect Next(Vec2D(xp+50,yp+85),Vec2D(45,16)); Next.SetRoundness(0.5); Next.Draw(CouleurFond.WithAlpha(0.5)); Next.DrawOutline(CouleurLigne.WithAlpha(0.5)); petitchiffre.Print("NEXT",xp+56,yp+96); //NUM FICHIER Rect NumFichier(Vec2D(xp+70,yp+55),Vec2D(40,25)); NumFichier.SetRoundness(3); NumFichier.Draw(CouleurFond.WithAlpha(0.5)); neuromoyen.Print(ol::ToString(player_has_file_coming_from_pos[numero]),xp+80,yp+71); NumFichier.DrawOutline(CouleurLigne.WithAlpha(0.5)); if(window_focus_id==919 && mouse_x>xp+70 && mouse_x<xp+110 && mouse_y>yp+55 && mouse_y<yp+80) { NumFichier.DrawOutline(CouleurLigne.WithAlpha(0.5)); } //autoload cuelist //audio_auto_load Rect Autoload(Vec2D(xp,yp+110),Vec2D(28,16)); Autoload.SetRoundness(0.5); Autoload.Draw(CouleurFond.WithAlpha(0.5)); Autoload.Draw(CouleurBlind.WithAlpha(audio_autoload[numero])); Autoload.DrawOutline(CouleurLigne.WithAlpha(0.5)); Line(Vec2D(xp+3,yp+112),Vec2D(xp+20,yp+112)).Draw(CouleurLigne); Line(Vec2D(xp+20,yp+112),Vec2D(xp+20,yp+123)).Draw(CouleurLigne); Line(Vec2D(xp+20,yp+123),Vec2D(xp+27,yp+118)).Draw(CouleurLigne); Line(Vec2D(xp+13,yp+118),Vec2D(xp+20,yp+123)).Draw(CouleurLigne); //autopause Rect Autostop(Vec2D(xp+35,yp+110),Vec2D(40,16)); Autostop.SetRoundness(0.5); Autostop.Draw(CouleurFond.WithAlpha(0.5)); Autostop.Draw(CouleurBlind.WithAlpha(audio_autopause[numero])); Autostop.DrawOutline(CouleurLigne.WithAlpha(0.5)); minichiffre.Print("A.PAUSE",xp+38,yp+120); //SET cue IN Rect SetLoopIN(Vec2D(xp+210,yp),Vec2D(20,20)); SetLoopIN.SetRoundness(4); if(midi_show_flash_cueIntouch[numero]==1){SetLoopIN.Draw(CouleurBlind);midi_show_flash_cueIntouch[numero]=0;} SetLoopIN.DrawOutline(CouleurLigne); Line(Vec2D(xp+210,yp),Vec2D(xp+220,yp+10)).Draw(CouleurLigne); Line(Vec2D(xp+230,yp),Vec2D(xp+220,yp+10)).Draw(CouleurLigne); petitpetitchiffre.Print("in",xp+215,yp+17); //SET cue out Rect SetLoopOut(Vec2D(xp+235,yp),Vec2D(20,20)); SetLoopOut.SetRoundness(4); if(midi_show_flash_cueOuttouch[numero]==1){SetLoopOut.Draw(CouleurBlind);midi_show_flash_cueOuttouch[numero]=0;} SetLoopOut.DrawOutline(CouleurLigne); Line(Vec2D(xp+235,yp),Vec2D(xp+245,yp+10)).Draw(CouleurLigne); Line(Vec2D(xp+255,yp),Vec2D(xp+245,yp+10)).Draw(CouleurLigne); petitpetitchiffre.Print("out",xp+235,yp+17); //CUE ON OFF Rect CueOn(Vec2D(xp+260,yp),Vec2D(20,20)); CueOn.SetRoundness(4); CueOn.Draw(CouleurBlind.WithAlpha(player_is_onloopCue[numero])); petitpetitchiffre.Print("cue",xp+260,yp+12); CueOn.DrawOutline(CouleurLigne); petitpetitchiffre.Print(time_is_for_fileCueIn[numero],xp+234,yp+40); petitpetitchiffre.Print(time_is_for_fileCueOut[numero],xp+234,yp+50); //Seek cue Rect SeekCue(Vec2D(xp+210,yp+30),Vec2D(20,20)); SeekCue.SetRoundness(4); SeekCue.DrawOutline(CouleurLigne); if(midi_show_flash_cueSeektouch[numero]==1){SeekCue.Draw(CouleurBlind);midi_show_flash_cueSeektouch[numero]=0;} Line(Vec2D(xp+226,yp+34),Vec2D(xp+226,yp+46)).Draw(CouleurLigne); Line(Vec2D(xp+226,yp+34),Vec2D(xp+216,yp+40)).Draw(CouleurLigne); Line(Vec2D(xp+216,yp+40),Vec2D(xp+226,yp+46)).Draw(CouleurLigne); Line(Vec2D(xp+214,yp+34),Vec2D(xp+214,yp+46)).Draw(CouleurLigne); //Pitch Line(Vec2D(xp+130,yp+115),Vec2D(xp+257,yp+115)).Draw(CouleurLigne);//ligne horizontale Line(Vec2D(xp+194,yp+105),Vec2D(xp+194,yp+125)).Draw(CouleurLigne);//barre 64 Line(Vec2D(xp+257,yp+110),Vec2D(xp+257,yp+115)).Draw(CouleurLigne);//barre 127 Rect PitchPos(Vec2D(xp+120+player_pitch[numero],yp+110),Vec2D(20,10)); PitchPos.SetRoundness(4); PitchPos.Draw(CouleurBlind); PitchPos.DrawOutline(CouleurLigne); Rect PitchMidi(Vec2D(xp+130,yp+110),Vec2D(127,10)); petitpetitchiffre.Print(string_pitch[numero],(xp+130),(yp+107)); petitpetitchiffre.Print(ol::ToString(player_pitch[numero]),(xp+110),(yp+117)); raccrochage_midi_visuel_horizontal_audio (xp+130, yp+100, 620+numero, 127,10); //Pan Line(Vec2D(xp+130,yp+90),Vec2D(xp+257,yp+90)).Draw(CouleurLigne);//ligne horizontale Line(Vec2D(xp+194,yp+80),Vec2D(xp+194,yp+100)).Draw(CouleurLigne);//barre 64 Line(Vec2D(xp+257,yp+85),Vec2D(xp+257,yp+90)).Draw(CouleurLigne);//barre 127 Rect PanPos(Vec2D(xp+120+player_pan[numero],yp+85),Vec2D(20,10)); PanPos.SetRoundness(4); PanPos.Draw(CouleurBlind); PanPos.DrawOutline(CouleurLigne); Rect PanMidi(Vec2D(xp+130,yp+85),Vec2D(127,10)); petitpetitchiffre.Print(string_pan[numero],(xp+130),(yp+82)); petitpetitchiffre.Print(ol::ToString(player_pan[numero]),(xp+110),(yp+94)); raccrochage_midi_visuel_horizontal_audio (xp+130, yp+80, 624+numero, 127,10); //les faders son fader_niveau_son(xp+290,yp,numero); if(window_focus_id==919 && Midi_Faders_Affectation_Type!=0 ) { if( mouse_x>xp && mouse_x<xp+20 && mouse_y>yp+30 && mouse_y<yp+50){Play.DrawOutline(CouleurBlind);} else if(mouse_x>xp+25 && mouse_x<xp+45 && mouse_y>yp+30 && mouse_y<yp+50){SeekToZero.DrawOutline(CouleurBlind);} else if( mouse_x>xp+50 && mouse_x<xp+70 && mouse_y>yp+30 && mouse_y<yp+50){GeneralLoop.DrawOutline(CouleurBlind);} else if( mouse_x>xp+75 && mouse_x<xp+95 && mouse_y>yp+30 && mouse_y<yp+50){SeekToEnd.DrawOutline(CouleurBlind);} else if( mouse_x>xp && mouse_x<xp+28 && mouse_y>yp+60 && mouse_y<yp+76){Backward.DrawOutline(CouleurBlind);} else if ( mouse_x>xp+35 && mouse_x<xp+63 && mouse_y>yp+60 && mouse_y<yp+76){Forward.DrawOutline(CouleurBlind);} else if( mouse_x>xp && mouse_x<xp+45 && mouse_y>yp+85 && mouse_y<yp+101){Previous.DrawOutline(CouleurBlind);} else if ( mouse_x>xp+50 && mouse_x<xp+95 && mouse_y>yp+85 && mouse_y<yp+101){Next.DrawOutline(CouleurBlind);} else if ( mouse_x>xp+70 && mouse_x<xp+110 && mouse_y>yp+55 && mouse_y<yp+80) {NumFichier.DrawOutline(CouleurBlind);} else if ( mouse_x>xp && mouse_x<xp+28 && mouse_y>yp+110 && mouse_y<yp+126){Autoload.DrawOutline(CouleurBlind);} else if ( mouse_x>xp+35 && mouse_x<xp+75 && mouse_y>yp+110 && mouse_y<yp+126){Autostop.DrawOutline(CouleurBlind);} else if ( mouse_x>xp+210 && mouse_x<xp+240 && mouse_y>yp && mouse_y<yp+20) {SetLoopIN.DrawOutline(CouleurBlind);} else if( mouse_x>xp+235 && mouse_x<xp+255 && mouse_y>yp && mouse_y<yp+20) {SetLoopOut.DrawOutline(CouleurBlind);} else if( mouse_x>xp+260 && mouse_x<xp+280 && mouse_y>yp && mouse_y<yp+20){CueOn.DrawOutline(CouleurBlind);} else if( mouse_x>xp+210 && mouse_x<xp+230 && mouse_y>yp+30 && mouse_y<yp+50){SeekCue.DrawOutline(CouleurBlind);} else if ( mouse_x>xp+120+player_pitch[numero] && mouse_x<xp+150+player_pitch[numero] && mouse_y>yp+110 && mouse_y<yp+120) {PitchMidi.DrawOutline(CouleurBlind);} else if (mouse_x>xp+120+player_pan[numero] && mouse_x<xp+150+player_pan[numero] && mouse_y>yp+85 && mouse_y<yp+95) {PanMidi.DrawOutline(CouleurBlind);} } return(0); }
task main() { int distance=0; int add=0; nMotorEncoder[mRight] = 0; while(SensorValue(IR) != 5) { motor[mLeft] = 30; motor[mRight] = 30; } motor[mLeft] = 0; motor[mRight] = 0; wait1Msec(500); distance = nMotorEncoder[mRight]; if(abs(distance) <= 4500) { add = 300; } else { add = -200; } if(add > 0) { Forward(add, 30); } else { Backward(abs(add), 30); } wait1Msec(500); servo[AutoHook] = 0; wait1Msec(1000); servo[AutoHook] = 250; wait1Msec(500); Backward(abs(distance) + add, 30); wait1Msec(500); Turn(1640, 100, right); motor[mRight] = 0; motor[mLeft] = 0; wait1Msec(500); //goes backwards and towards the ramp Backward(4000,50); motor[mRight] = 0; motor[mLeft] = 0; wait1Msec(500); //turns towards the ramp Turn(1900, 100, right); motor[mRight] = 0; motor[mLeft] = 0; wait1Msec(500); //goes onto the ramp Backward(4500,100); }
/** \brief Return the opposite direction. E.g. <c>opposite (forward)</c> returns \c backward and vice versa. */ inline Backward opposite (Forward) { return Backward(); }
typeMoveList *MyOrdinary(typePos *Position, typeMoveList *List) { uint64 empty = ~Position->OccupiedBW, U, T, Rook, Bishop, Pawn; int to, sq, opks = OppKingSq; if (CastleOO && ((Position->OccupiedBW | OppAttacked) & WhiteF1G1) == 0) MoveAdd(List, FlagOO | (WhiteE1 << 6) | WhiteG1, EnumMyK, WhiteG1, 0); if (CastleOOO && (Position->OccupiedBW & WhiteB1C1D1) == 0 && (OppAttacked & WhiteC1D1) == 0) MoveAdd(List, FlagOO | (WhiteE1 << 6) | WhiteC1, EnumMyK, WhiteC1, 0); Pawn = MyAttackedPawns[opks]; if (BitboardMyQ | BitboardMyR) Rook = AttR(opks); if (BitboardMyQ | BitboardMyB) Bishop = AttB(opks); for (U = ForwardShift(BitboardMyP & SecondSixthRanks) & empty; U; BitClear(sq, U)) { to = BSF(U); if (OnThirdRank(to) && Position->sq[Forward(to)] == 0) MoveAdd(List, (Backward(to) << 6) | Forward(to), EnumMyP, Forward(to), Pawn); MoveAdd(List, (Backward(to) << 6) | to, EnumMyP, to, Pawn); } for (U = BitboardMyQ; U; BitClear(sq, U)) { sq = BSF(U); T = AttQ(sq) & empty; MovesTo(T, EnumMyQ, Rook | Bishop); } for (U = BitboardMyR; U; BitClear(sq, U)) { sq = BSF(U); T = AttR(sq) & empty; MovesTo(T, EnumMyR, Rook); } for (U = BitboardMyB; U; BitClear(sq, U)) { sq = BSF(U); T = AttB(sq) & empty; MovesTo(T, ((SqSet[sq] & Black) ? EnumMyBD : EnumMyBL), Bishop); } sq = BSF(BitboardMyK); T = AttK[sq] & empty &(~OppAttacked); MovesTo(T, EnumMyK, 0); for (U = BitboardMyN; U; BitClear(sq, U)) { sq = BSF(U); T = AttN[sq] & empty; MovesTo(T, EnumMyN, AttN[opks]); } for (U = BitboardMyP & BitBoardSeventhRank; U; BitClear(sq, U)) { sq = BSF(U); to = Forward(sq); if (Position->sq[to] == 0) UnderProm(); to = ForwardLeft(sq); if (sq != WhiteA7 && SqSet[to] & OppOccupied) UnderProm(); to = ForwardRight(sq); if (sq != WhiteH7 && SqSet[to] & OppOccupied) UnderProm(); } List->move = 0; return List; }
/* ---------- page/scroll keys ----------- */ static int DoScrolling(WINDOW wnd, int c, PARAM p2) { switch (c) { case PGUP: case PGDN: if (isMultiLine(wnd)) BaseWndProc(EDITBOX, wnd, KEYBOARD, c, p2); break; case CTRL_PGUP: case CTRL_PGDN: BaseWndProc(EDITBOX, wnd, KEYBOARD, c, p2); break; case HOME: Home(wnd); break; case END: End(wnd); break; case CTRL_FWD: NextWord(wnd); break; case CTRL_BS: PrevWord(wnd); break; case CTRL_HOME: if (isMultiLine(wnd)) { SendMessage(wnd, SCROLLDOC, TRUE, 0); wnd->CurrLine = 0; wnd->WndRow = 0; } Home(wnd); break; case CTRL_END: if (isMultiLine(wnd) && wnd->WndRow+wnd->wtop+1 < wnd->wlines && wnd->wlines > 0) { SendMessage(wnd, SCROLLDOC, FALSE, 0); SetLinePointer(wnd, wnd->wlines-1); wnd->WndRow = min(ClientHeight(wnd)-1, wnd->wlines-1); Home(wnd); } End(wnd); break; case UP: if (isMultiLine(wnd)) Upward(wnd); break; case DN: if (isMultiLine(wnd)) Downward(wnd); break; case FWD: Forward(wnd); break; case BS: Backward(wnd); break; default: return FALSE; } if (!KeyBoardMarking && TextBlockMarked(wnd)) { ClearTextBlock(wnd); SendMessage(wnd, PAINT, 0, 0); } SendMessage(wnd, KEYBOARD_CURSOR, WndCol, wnd->WndRow); return TRUE; }
typeMoveList *MyEvasion(typePos *Position, typeMoveList *List, uint64 c2) { uint64 U, T, att, mask; int sq, to, fr, c, king, pi; king = MyKingSq; att = MyKingCheck; sq = BSF(att); pi = Position->sq[sq]; mask = (~OppAttacked) &(((pi == EnumOppP) ? AttK[king] : 0) | Evade(king, sq)) & (~MyOccupied) &c2; BitClear(sq, att); if (att) { sq = BSF(att); pi = Position->sq[sq]; mask = mask &(PieceIsOppPawn(pi) | Evade(king, sq)); sq = king; AddTo(mask, CaptureValue[EnumMyK][c]); List->move = 0; return List; } c2 &= InterPose(king, sq); sq = king; AddTo(mask, CaptureValue[EnumMyK][c]); if (!c2) { List->move = 0; return List; } if (CaptureRight &(c2 & OppOccupied)) { to = BSF(c2 & OppOccupied); c = Position->sq[to]; if (EighthRank(to)) { Add(List, FlagPromQ | FromLeft(to) | to, (0x20 << 24) + CaptureValue[EnumMyP][c]); Add(List, FlagPromN | FromLeft(to) | to, 0); Add(List, FlagPromR | FromLeft(to) | to, 0); Add(List, FlagPromB | FromLeft(to) | to, 0); } else Add(List, FromLeft(to) | to, CaptureValue[EnumMyP][c]); } if (CaptureLeft &(c2 & OppOccupied)) { to = BSF(c2 & OppOccupied); c = Position->sq[to]; if (EighthRank(to)) { Add(List, FlagPromQ | FromRight(to) | to, (0x20 << 24) + CaptureValue[EnumMyP][c]); Add(List, FlagPromN | FromRight(to) | to, 0); Add(List, FlagPromR | FromRight(to) | to, 0); Add(List, FlagPromB | FromRight(to) | to, 0); } else Add(List, FromRight(to) | to, CaptureValue[EnumMyP][c]); } to = Position->Dyn->ep; if (to) { if (CaptureRight & SqSet[to] && SqSet[Backward(to)] & c2) Add(List, FlagEP | FromLeft(to) | to, CaptureValue[EnumMyP][EnumOppP]); if (CaptureLeft & SqSet[to] && SqSet[Backward(to)] & c2) Add(List, FlagEP | FromRight(to) | to, CaptureValue[EnumMyP][EnumOppP]); } T = BitboardMyP & BackShift((c2 & OppOccupied) ^ c2); while (T) { fr = BSF(T); BitClear(fr, T); if (SeventhRank(fr)) { Add(List, FlagPromQ | (fr << 6) | Forward(fr), CaptureValue[EnumMyP][0]); Add(List, FlagPromN | (fr << 6) | Forward(fr), 0); Add(List, FlagPromR | (fr << 6) | Forward(fr), 0); Add(List, FlagPromB | (fr << 6) | Forward(fr), 0); } else Add(List, (fr << 6) | Forward(fr), CaptureValue[EnumMyP][0]); } T = BitboardMyP & BackShift2((c2 & OppOccupied) ^ c2) & SecondRank & BackShift(~Position->OccupiedBW); while (T) { fr = BSF(T); BitClear(fr, T); Add(List, (fr << 6) | Forward2(fr), CaptureValue[EnumMyP][0]); } for (U = BitboardMyN; U; BitClear(sq, U)) { sq = BSF(U); T = AttN[sq] & c2; AddTo(T, CaptureValue[EnumMyN][c]); } for (U = BitboardMyB; U; BitClear(sq, U)) { sq = BSF(U); T = AttB(sq) & c2; AddTo(T, CaptureValue[EnumMyBL][c]); } for (U = BitboardMyR; U; BitClear(sq, U)) { sq = BSF(U); T = AttR(sq) & c2; AddTo(T, CaptureValue[EnumMyR][c]); } for (U = BitboardMyQ; U; BitClear(sq, U)) { sq = BSF(U); T = AttQ(sq) & c2; AddTo(T, CaptureValue[EnumMyQ][c]); } List->move = 0; return List; }
void CBKInfEngine::BackwardFixLag() { ////////////////////////////////////////////////////////////////////////// // Backward step for fixed-lag smoothing procedure ////////////////////////////////////////////////////////////////////////// PNL_CHECK_LEFT_BORDER(m_CurrentTime, m_Lag); if( m_Lag ) { int currentTimeTmp = GetTime(); CRing<CJtreeInfEngine *>::iterator tmpInfIter = m_JTreeInfIter; CRing< distrPVector >::iterator tmpDistrIter = m_CDistrOnSepIter; CRing<CJtreeInfEngine*> ringEng; ringEng.assign( 2 , NULL ); CRing<CJtreeInfEngine *>::iterator ringEngIter = ringEng.begin(); *ringEngIter = CJtreeInfEngine::Copy(*m_JTreeInfIter); ringEngIter++; BackwardT(); distrPVector tmpDistr(GetNumOfClusters(), (CDistribFun* const)NULL); int i; for( i = 0; i < GetLag(); i++ ) { if( i < GetLag() - 1 ) { *ringEngIter = CJtreeInfEngine::Copy(*(m_JTreeInfIter-1)); int j; for( j = 0; j < GetNumOfClusters(); j++ ) { tmpDistr[j] = (*m_CDistrOnSepIter)[j]->Clone(); } } Backward(); //CJtreeInfEngine::Release(&(*(m_JTreeInfIter + 1))); delete (*(m_JTreeInfIter + 1)); ringEngIter++; *(m_JTreeInfIter + 1) = *ringEngIter; if( i < GetLag() - 1 ) { int j; for( j = 0; j < GetNumOfClusters(); j++ ) { delete (*(m_CDistrOnSepIter+1))[j]; (*(m_CDistrOnSepIter+1))[j]=tmpDistr[j]; } } } m_CDistrOnSepIter = tmpDistrIter; m_JTreeInfIter = tmpInfIter; m_CurrentTime = currentTimeTmp; } else { BackwardT(); } }
UINT32 CCoder::GetOptimal(UINT32 &aBackRes) { if(m_OptimumEndIndex != m_OptimumCurrentIndex) { UINT32 aLen = m_Optimum[m_OptimumCurrentIndex].PosPrev - m_OptimumCurrentIndex; aBackRes = m_Optimum[m_OptimumCurrentIndex].BackPrev; m_OptimumCurrentIndex = m_Optimum[m_OptimumCurrentIndex].PosPrev; return aLen; } m_OptimumCurrentIndex = 0; m_OptimumEndIndex = 0; GetBacks(UINT32(m_BlockStartPostion + m_CurrentBlockUncompressedSize)); UINT32 aLenMain = m_LongestMatchLength; UINT32 aBackMain = m_LongestMatchDistance; if(aLenMain < kMatchMinLen) return 1; if(aLenMain >= m_MatchLengthEdge) { aBackRes = aBackMain; MovePos(aLenMain - 1); return aLenMain; } m_Optimum[1].Price = m_LiteralPrices[m_MatchFinder.GetIndexByte(0 - m_AdditionalOffset)]; m_Optimum[1].PosPrev = 0; m_Optimum[2].Price = kIfinityPrice; m_Optimum[2].PosPrev = 1; for(UINT32 i = kMatchMinLen; i <= aLenMain; i++) { m_Optimum[i].PosPrev = 0; m_Optimum[i].BackPrev = m_MatchDistances[i]; m_Optimum[i].Price = m_LenPrices[i - kMatchMinLen] + m_PosPrices[GetPosSlot(m_MatchDistances[i])]; } UINT32 aCur = 0; UINT32 aLenEnd = aLenMain; while(true) { aCur++; if(aCur == aLenEnd) return Backward(aBackRes, aCur); GetBacks(UINT32(m_BlockStartPostion + m_CurrentBlockUncompressedSize + aCur)); UINT32 aNewLen = m_LongestMatchLength; if(aNewLen >= m_MatchLengthEdge) return Backward(aBackRes, aCur); UINT32 aCurPrice = m_Optimum[aCur].Price; UINT32 aCurAnd1Price = aCurPrice + m_LiteralPrices[m_MatchFinder.GetIndexByte(aCur - m_AdditionalOffset)]; COptimal &anOptimum = m_Optimum[aCur + 1]; if (aCurAnd1Price < anOptimum.Price) { anOptimum.Price = aCurAnd1Price; anOptimum.PosPrev = aCur; } if (aNewLen < kMatchMinLen) continue; if(aCur + aNewLen > aLenEnd) { if (aCur + aNewLen > kNumOpts - 1) aNewLen = kNumOpts - 1 - aCur; UINT32 aLenEndNew = aCur + aNewLen; if (aLenEnd < aLenEndNew) { for(UINT32 i = aLenEnd + 1; i <= aLenEndNew; i++) m_Optimum[i].Price = kIfinityPrice; aLenEnd = aLenEndNew; } } for(UINT32 aLenTest = kMatchMinLen; aLenTest <= aNewLen; aLenTest++) { UINT16 aCurBack = m_MatchDistances[aLenTest]; UINT32 aCurAndLenPrice = aCurPrice + m_LenPrices[aLenTest - kMatchMinLen] + m_PosPrices[GetPosSlot(aCurBack)]; COptimal &anOptimum = m_Optimum[aCur + aLenTest]; if (aCurAndLenPrice < anOptimum.Price) { anOptimum.Price = aCurAndLenPrice; anOptimum.PosPrev = aCur; anOptimum.BackPrev = aCurBack; } } } }
TreeNode* Parser::Statement() { kdDebug(0)<<"Parser::Statement()"<<endl; while (currentToken.type == tokEOL) getToken(); // statements can allways start on newlines switch (currentToken.type) { case tokLearn : return Learn(); break; case tokIf : return If(); break; case tokFor : return For(); break; case tokForEach : return ForEach(); break; case tokWhile : return While(); break; case tokRun : return ExternalRun(); break; case tokReturn : return Return(); break; case tokBreak : return Break(); break; case tokUnknown : return Other(); break; //assignment or function call case tokClear : return Clear(); break; case tokGo : return Go(); break; case tokGoX : return GoX(); break; case tokGoY : return GoY(); break; case tokForward : return Forward(); break; case tokBackward : return Backward(); break; case tokDirection : return Direction(); break; case tokTurnLeft : return TurnLeft(); break; case tokTurnRight : return TurnRight(); break; case tokCenter : return Center(); break; case tokSetPenWidth : return SetPenWidth(); break; case tokPenUp : return PenUp(); break; case tokPenDown : return PenDown(); break; case tokSetFgColor : return SetFgColor(); break; case tokSetBgColor : return SetBgColor(); break; case tokResizeCanvas : return ResizeCanvas(); break; case tokSpriteShow : return SpriteShow(); break; case tokSpriteHide : return SpriteHide(); break; case tokSpritePress : return SpritePress(); break; case tokSpriteChange : return SpriteChange(); break; case tokPrint : return Print(); break; case tokInputWindow : return InputWindow(); break; case tokMessage : return Message(); break; case tokFontType : return FontType(); break; case tokFontSize : return FontSize(); break; case tokRepeat : return Repeat(); break; case tokRandom : return Random(); break; case tokWait : return Wait(); break; case tokWrapOn : return WrapOn(); break; case tokWrapOff : return WrapOff(); break; case tokReset : return Reset(); break; case tokEOF : return EndOfFile(); break; case tokEnd : Error(currentToken, i18n("Cannot understand ']'"), 1050); getToken(); return new TreeNode(currentToken, Unknown); break; case tokBegin : Error(currentToken, i18n("Cannot understand '['"), 1050); getToken(); return new TreeNode(currentToken, Unknown); break; default : break; } if (currentToken.type != tokEnd) { Error(currentToken, i18n("Cannot understand '%1'").arg(currentToken.look), 1060); } getToken(); return new TreeNode(currentToken, Unknown); // fall-though for unknowns }
void Grid<Ndim>::MakeFilter(const double sigma){ unsigned int nzp=nnz/2+1; size_t align=sizeof(Complex); if(!filter && !filterrc) { filter=new array3<Complex>; filter->Allocate(nnx,nny,nnz); filterrc=new array3<Complex>; filterrc->Allocate(nnx,nny,nzp,align); } int nfx,nfy,nfz; nfx=(nnx % 2 == 0)? nnx/2: nnx/2+1; nfy=(nny % 2 == 0)? nny/2: nny/2+1; nfz=(nnz % 2 == 0)? nnz/2: nnz/2+1; array3<Complex> & Mfilter=*filter; array3<Complex> & Mfilterrc=*filterrc; fft3d Forward3(nnx,nny,nnz,-1); fft3d Backward3(nnx,nny,nnz,1); Mfilter=Complex(0.0,0.0); double dx=co[0][0]/static_cast<double> (nnx); double dy=co[1][1]/static_cast<double> (nny); double dz=co[2][2]/static_cast<double> (nnz); int mx=static_cast<int> (3.0*sigma/dx); int my=static_cast<int> (3.0*sigma/dy); int mz=static_cast<int> (3.0*sigma/dz); double xa,ya,za; double sum=0.0; for(int i=-mx;i<=mx;i++){ int ia=(i<0)?i+nnx:i; double xd=static_cast<double> (i)/static_cast<double> (nnx); for(int j=-my;j<=my;j++){ int ja=(j<0)?j+nny:j; double yd=static_cast<double> (j)/static_cast<double> (nny); for(int k=-mz;k<=mz;k++){ int ka=(k<0)?k+nnz:k; double zd=static_cast<double> (k)/static_cast<double> (nnz); xa=co[XX][XX]*xd+co[XX][YY]*yd+co[XX][ZZ]*zd; ya=co[YY][XX]*xd+co[YY][YY]*yd+co[YY][ZZ]*zd; za=co[ZZ][XX]*xd+co[ZZ][YY]*yd+co[ZZ][ZZ]*zd; double rs=xa*xa+ya*ya+za*za; double fact1=exp(-rs/(2.0*sigma*sigma)); Mfilter[ia][ja][ka].real()=fact1; Mfilter(ia,ja,ka).imag()=0; sum+=fact1; } } } for(unsigned int i=0;i<nnx;i++) for(unsigned int j=0;j<nny;j++) for(unsigned int k=0;k<nnz;k++){ Mfilter(i,j,k).real()=Mfilter(i,j,k).real()/sum; } array3<double> ro(nnx,nny,nnz,align); array3<Complex> rok(nnx,nny,nzp,align); rcfft3d Forward(nnz,ro,Mfilterrc); crfft3d Backward(nnz,Mfilterrc,ro); int nx0=static_cast<int>(nnx); int ny0=static_cast<int>(nny); int nz0=static_cast<int>(nnz); for(int i=0;i<nx0;i++) for(int j=0;j<ny0;j++) for(int k=0;k<nz0;k++){ ro[i][j][k]=Mfilter[i][j][k].real(); } Forward.fft(ro,Mfilterrc); Forward3.fft(Mfilter); }