Example #1
0
  void operator() (const InputType& x, ValueType* v, JacobianType* _j) const
  {
    (*this)(x, v);

    if(_j)
    {
      JacobianType& j = *_j;

      j(0,0) = 4 * x[0] + x[1];
      j(1,0) = 3 * x[1];

      j(0,1) = x[0];
      j(1,1) = 3 * x[0] + 2 * 0.5 * x[1];

      if (inputs()>2)
      {
        j(0,2) = 0.5;
        j(1,2) = 1;
      }
      if(values()>2)
      {
        j(2,0) = 3 * x[1] * 2 * x[0];
        j(2,1) = 3 * x[0] * x[0];
      }
      if (inputs()>2 && values()>2)
      {
        j(2,0) *= x[2];
        j(2,1) *= x[2];

        j(2,2) = 3 * x[1] * x[0] * x[0];
        j(2,2) = 3 * x[1] * x[0] * x[0];
      }
    }
  }
Example #2
0
void CreatABList(ABList &L)
{
 char c[2];
 int j = 0;
 if(InitList_AB(L) == 1)
 {
  printf("建立通讯录分配空间成功,现在您可以开始输入数据建立不超过100个人的信息!n");
  
  printf("您是否想从现在开始建立?Y/N.n");
  gets(c);
  while((((c[0]=='y')||(c[0]=='Y')))&&(j<100))
  {
   printf("请输入第%d位同学的编号:",j+1);
   scanf("%d",&L.elem[j].ID);
   getchar();
   printf("第%d位同学的姓名: ",j+1);
   inputs(L.elem[j].name,10);
   printf("第%d位同学的性别: ",j+1);
   inputs(&L.elem[j].ch,1);
   printf("第%d位同学的电话: ",j+1);
   inputs(L.elem[j].phone,13);
   printf("第%d位同学的地址: ",j+1);
   inputs(L.elem[j].addr,31);
   L.length = j+1;
   j++;
   printf("是否继续??Y/N.n");
   gets(c);
  }
 }
 else{
  printf("对不起!建立通讯录分配空间失败。n");exit(1);
 } 
}
Example #3
0
void SRFlipFlop::updateLogic( ) {
  char res1 = output( 0 )->value( ); /* Q */
  char res2 = output( 1 )->value( ); /* ~Q */
  if( !isValid( ) ) {
    res1 = -1;
    res2 = -1;
  }
  else {
    if( res1 == -1 ) {
      res1 = 0;
      res2 = 0;
    }
    char s = inputs( ).at( 0 )->value( );
    char clk = inputs( ).at( 1 )->value( );
    char r = inputs( ).at( 2 )->value( );
    if( ( clk == 1 ) && ( lastClk == 0 ) ) { /* If Clock up */
      if( s && r ) { /* Not permitted */
        res1 = 1;
        res2 = 1;
      }
      else if( s != r ) {
        res1 = s;
        res2 = r;
      }
    }
    lastClk = clk;
  }
  output( 0 )->setValue( res1 );
  output( 1 )->setValue( res2 );
  /* Reference: https://pt.wikipedia.org/wiki/Flip-flop#Flip-flop_SR_Sincrono */
}
Example #4
0
void
inputs(unsigned idx, unsigned depthrem)
{

	if (depthrem == 0) {
		try();

		if (unlocked) {
			printf("Solved!\n");
			exit(0);
		}
		return;
	}

	for (unsigned i = 0; i < 256; i++) {
		Input[idx] = i;
		inputs(idx + 1, depthrem - 1);
	}
}

int
main(void)
{

	for (unsigned i = 1; i < 7; i++) {
		printf("Trying input len: %d\n", i);
		InputLen = i;
		inputs(0, i);
	}

	return 0;
}
Example #5
0
void TFlipFlop::updateLogic( ) {
  char res1 = output( 0 )->value( ); /* Q */
  char res2 = output( 1 )->value( ); /* Q */
  if( !isValid( ) ) {
    res1 = -1;
    res2 = -1;
  }
  else {
    if( res1 == -1 ) {
      res1 = 0;
      res2 = 0;
    }
    char T = inputs( ).at( 0 )->value( );
    char clk = inputs( ).at( 1 )->value( ); /* Current lock */
    char prst = inputs( ).at( 2 )->value( );
    char clr = inputs( ).at( 3 )->value( );
    if( ( clk == 1 ) && ( lastClk == 0 ) ) { /* If Clock up*/
      if( T == 1 ) { /* And T */
        res1 = !res1;
        res2 = !res1;
      }
    }
    if( ( prst == 0 ) || ( clr == 0 ) ) {
      res1 = !prst;
      res2 = !clr;
    }
    lastClk = clk;
  }
  output( 0 )->setValue( res1 );
  output( 1 )->setValue( res2 );
}
Example #6
0
void SRFlipFlop::updatePorts( ) {
  inputs( ).at( 0 )->setPos( topPosition( ), 13 ); /* S */
  inputs( ).at( 1 )->setPos( topPosition( ), 29 ); /* Clk */
  inputs( ).at( 2 )->setPos( topPosition( ), 45 ); /* R */

  output( 0 )->setPos( bottomPosition( ), 15 ); /* Q */
  output( 1 )->setPos( bottomPosition( ), 45 ); /* ~Q */
}
Example #7
0
void TFlipFlop::updatePorts( ) {
  inputs( ).at( 0 )->setPos( topPosition( ), 13 ); /* T */
  inputs( ).at( 1 )->setPos( topPosition( ), 45 ); /* Clock */
  inputs( ).at( 2 )->setPos( 32, topPosition( ) ); /* Preset */
  inputs( ).at( 3 )->setPos( 32, bottomPosition( ) ); /* Clear */

  output( 0 )->setPos( bottomPosition( ), 15 ); /* Q */
  output( 1 )->setPos( bottomPosition( ), 45 ); /* ~Q */
}
Example #8
0
    PerlinNoise::PerlinNoise()
    {
        seed_socket_ = &inputs().add("Seed", SocketType::uniform);
        seed_socket_->set_accepts(ConnectionDataType::value<long, 1>());

        // Just a vector2 to start out with
        points_socket_ = &inputs().add("Points", SocketType::attribute);
        points_socket_->set_accepts(ConnectionDataType::value<float, 2>());
        points_socket_->set_accepts(ConnectionDataType::value<float, 3>());
        points_socket_->set_accepts(ConnectionDataType::value<float, 4>());
        points_socket_->set_accepts(ConnectionDataType::value<float, 5>());
        points_socket_->set_accepts(ConnectionDataType::value<float, 6>());

        output_socket_ = &outputs().add("Output", ConnectionDataType::value<float, 1>(), SocketType::attribute);
    }
Example #9
0
SRFlipFlop::SRFlipFlop( QGraphicsItem *parent ) : GraphicElement( 3, 3, 2, 2, parent ) {
  setPixmap( QPixmap( ":/memory/SR-flipflop.png" ) );
  setRotatable( false );
  updatePorts( );
  lastClk = false;
  setPortName( "FlipFlop SR" );

  inputs( ).at( 0 )->setName( "S" );
  inputs( ).at( 1 )->setName( "Clock" );
  inputs( ).at( 2 )->setName( "R" );
  output( 0 )->setName( "Q" );
  output( 1 )->setName( "~Q" );
  inputs( ).at( 0 )->setRequired( false );
  inputs( ).at( 2 )->setRequired( false );
}
Example #10
0
AddressBook creat_e()
{
 AddressBook e;
 printf("请输入编号:");
 scanf("%d",&e.ID);
 getchar();
 printf("姓名: ");
 inputs(e.name,11);
 printf("性别: ");
 inputs(&e.ch,2);
 printf("电话: ");
 inputs(e.phone,14);
 printf("地址: ");
 inputs(e.addr,32);
 return e;
}
Example #11
0
			static void multiwayMergeFiles(
				std::vector < std::string > const & inputfilenames,
				std::string const & outputfilename
				)
			{
				typedef ::libmaus2::graph::TripleEdgeInput input_type;
				typedef input_type::unique_ptr_type input_ptr_type;
				::libmaus2::autoarray::AutoArray<input_ptr_type> inputs(inputfilenames.size());
				
				for ( uint64_t i = 0; i < inputfilenames.size(); ++i )
				{
					input_ptr_type tinputsi (
                                                new input_type ( inputfilenames[i] , 32*1024 )
                                                );
					inputs[i] = UNIQUE_PTR_MOVE(tinputsi);
				}
						
				::libmaus2::autoarray::AutoArray < ::libmaus2::graph::TripleEdge > triples(inputfilenames.size());
				::libmaus2::autoarray::AutoArray < bool > ok(inputfilenames.size());
			
				::libmaus2::graph::TripleEdgeOutputMerge output(outputfilename, 32*1024);

				for ( uint64_t i = 0; i < inputfilenames.size(); ++i )
					ok [i] = inputs[i]->getNextTriple ( triples[i] );

				while ( anyTrue ( ok ) )
				{
					uint64_t const minidx = minOk(ok,triples);
					output.write ( triples[minidx] );
					ok[minidx] = inputs[minidx]->getNextTriple( triples[minidx] );
				}
			}
Example #12
0
int main()
{
    inputs();
    printf("The answer is %f",f());
    getch();
    return 0;
}
Example #13
0
void CallbackFunctionInternal::evalD(const double** arg,
                                     double** res, int* iw, double* w) {
    // Number of inputs and outputs
    int num_in = nIn();
    int num_out = nOut();

    std::vector<DMatrix> inputs(num_in);

    // Pass the inputs to the function
    for (int i=0; i<num_in; ++i) {
        inputs[i] = DMatrix::zeros(input(i).sparsity());
        if (arg[i] != 0) {
            inputs[i].setNZ(arg[i]);
        } else {
            inputs[i].set(0.);
        }
    }

    std::vector<DMatrix> outputs = callback_(inputs);

    // Get the outputs
    for (int i=0; i<num_out; ++i) {
        if (res[i] != 0) outputs[i].getNZ(res[i]);
    }
}
Example #14
0
const uint8_t* DataIStream::_decompress(const void* data,
                                        const CompressorInfo& info,
                                        const uint32_t nChunks,
                                        const uint64_t dataSize)
{
    const uint8_t* src = reinterpret_cast<const uint8_t*>(data);
    if (info.name.empty())
        return src;

    LBASSERT(!info.name.empty());
#ifndef CO_AGGRESSIVE_CACHING
    _impl->data.clear();
#endif
    _impl->data.reset(dataSize);
    _impl->initCompressor(info);

    std::vector<std::pair<const uint8_t*, size_t>> inputs(nChunks);
    for (uint32_t i = 0; i < nChunks; ++i)
    {
        const uint64_t size = *reinterpret_cast<const uint64_t*>(src);
        src += sizeof(uint64_t);

        inputs[i] = {src, size};
        src += size;
    }

    _impl->compressor->decompress(inputs, _impl->data.getData(), dataSize);
    return _impl->data.getData();
}
ecal_data_io::entry_type ecal_data_io::get_one_entry() {
    // get the data
    ttree->GetEntry(ientry % ttree->GetEntries());
    ientry++;

    // inputs
    input_vector_type inputs{input_vector_type::Zero()};
    for (int i=0; i<samples->size(); ++i)
        inputs(i) = samples->at(i);

    // feature matrix
    extended_input_vector_type pulse_extended = extended_input_vector_type::Zero();
    double pulseShapeTemplate[num_samples+2];
    for(int i=0; i<num_samples+2; i++) {
        double x = double( IDSTART + NFREQ * (i + 3) + NFREQ - 500 / 2);
        pulseShapeTemplate[i] = fpulse.fShape(x);
        pulse_extended(i+7) = pulseShapeTemplate[i];
    }
    int activeBXs[] = { -5, -4, -3, -2, -1,  0,  1,  2,  3,  4 };
    pulse_matrix_type pulse_matrix = pulse_matrix_type::Zero();
    for (unsigned int ip=0; ip<num_pulses; ++ip) {
        int bx = activeBXs[ip];
        int first_sample_t = std::max(0, bx+3);
        int offset = 7 - 3 - bx;

        unsigned int nsample_pulse = num_samples - first_sample_t;
        pulse_matrix.col(ip).segment(first_sample_t, nsample_pulse) = pulse_extended.segment(first_sample_t + offset,
            nsample_pulse);
    }

    return {inputs, pulse_matrix};
}
Example #16
0
bool BlendEffect::load(const KXmlElement &element, const KFilterEffectLoadingContext &)
{
    if (element.tagName() != id())
        return false;

    m_blendMode = Normal; // default blend mode

    QString modeStr = element.attribute("mode");
    if (!modeStr.isEmpty()) {
        if (modeStr == "multiply")
            m_blendMode = Multiply;
        else if (modeStr == "screen")
            m_blendMode = Screen;
        else if (modeStr == "darken")
            m_blendMode = Darken;
        else if (modeStr == "lighten")
            m_blendMode = Lighten;
    }

    if (element.hasAttribute("in2")) {
        if (inputs().count() == 2)
            setInput(1, element.attribute("in2"));
        else
            addInput(element.attribute("in2"));
    }

    return true;
}
Example #17
0
void BlendEffect::save(KXmlWriter &writer)
{
    writer.startElement(BlendEffectId);

    saveCommonAttributes(writer);

    switch (m_blendMode) {
    case Normal:
        writer.addAttribute("mode", "normal");
        break;
    case Multiply:
        writer.addAttribute("mode", "multiply");
        break;
    case Screen:
        writer.addAttribute("mode", "screen");
        break;
    case Darken:
        writer.addAttribute("mode", "darken");
        break;
    case Lighten:
        writer.addAttribute("mode", "lighten");
        break;
    }

    writer.addAttribute("in2", inputs().at(1));

    writer.endElement();
}
Example #18
0
int main( int argc, char** argv)
{
	ann::FwdNet::Topology topology(3);
	topology[0]=2;
	topology[1]=2;
	topology[2]=1;
	ann::FwdNet artificialNetwork(topology);

	ann::FwdNet::TrainingDataSet trainingDataSet;
	ann::FwdNet::InputData inputs(2);
	ann::FwdNet::TargetData targets(1);

	inputs[0]=0.0;
	inputs[1]=0.0;
	targets[0]=0.0;
	trainingDataSet.push_back(std::make_pair(inputs, targets));

	inputs[0]=1.0;
	inputs[1]=1.0;
	targets[0]=0.0;
	trainingDataSet.push_back(std::make_pair(inputs, targets));

	inputs[0]=0.0;
	inputs[1]=1.0;
	targets[0]=1.0;
	trainingDataSet.push_back(std::make_pair(inputs, targets));

	inputs[0]=1.0;
	inputs[1]=0.0;
	targets[0]=1.0;
	trainingDataSet.push_back(std::make_pair(inputs, targets));

	artificialNetwork.doTraining(trainingDataSet, 0.001);

	artificialNetwork.saveGraph(std::string("FwdNet.gv"));

	ann::FwdNet::OutputData outputs;
	inputs[0]=0;
	inputs[1]=0;
	artificialNetwork.processInputs(inputs);
	artificialNetwork.getOutputs(outputs);

	inputs[0]=0;
	inputs[1]=1;
	artificialNetwork.processInputs(inputs);
	artificialNetwork.getOutputs(outputs);

	inputs[0]=1;
	inputs[1]=0;
	artificialNetwork.processInputs(inputs);
	artificialNetwork.getOutputs(outputs);

	inputs[0]=1;
	inputs[1]=1;
	artificialNetwork.processInputs(inputs);
	artificialNetwork.getOutputs(outputs);
	//artificialNetwork.dump();

	return 0;
}
Example #19
0
QString DMXUSB::inputInfo(quint32 input)
{
    QString str;

    if (input == QLCIOPlugin::invalidLine())
    {
        if (m_inputs.size() == 0)
        {
            str += QString("<BR><B>%1</B>").arg(tr("No input support available."));
            /*
            str += QString("<P>");
            str += tr("Make sure that you have your hardware firmly plugged in. "
                      "NOTE: FTDI VCP interface is not supported by this plugin.");
            str += QString("</P>");
            */
        }
    }
    else if (input < quint32(m_inputs.size()))
    {
        str += QString("<H3>%1</H3>").arg(inputs()[input]);
        str += QString("<P>");
        str += tr("Device is operating correctly.");
        str += QString("</P>");
        QString add = m_inputs[input]->additionalInfo();
        if (add.isEmpty() == false)
            str += add;
    }

    str += QString("</BODY>");
    str += QString("</HTML>");

    return str;
}
Example #20
0
void
V3NtkElaborate::elaborateFairnessL2S(V3Constraint* const constr, V3NetVec& constrList) {
   assert (V3NetUD != _saved); assert (V3NetUD != _1stSave);
   assert (V3NetUD != _inLoop); assert (V3NetUD != _looped);
   assert (constr); assert (!constr->isFSMConstr()); constrList.clear();
   elaboratePOConstraints(constr->getStart(), constr->getEnd(), constrList);
   // Create Latches for Fairness Constraints (f)
   V3BvNtk* const bvNtk = dynamic_cast<V3BvNtk*>(_ntk);
   V3NetId id; V3GateType type; V3InputVec inputs(2);
   if (bvNtk) {
      for (uint32_t i = 0; i < constrList.size(); ++i) {
         // Create Input of Latch (F) : "F || (f && _inLoop)"
         inputs.clear(); inputs.push_back(_inLoop); inputs.push_back(constrList[i]);
         type = BV_AND; id = elaborateBvGate(bvNtk, type, inputs, _netHash);
         constrList[i] = _ntk->createNet(1); assert (V3NetUD != constrList[i]);
         inputs.clear(); inputs.push_back(~constrList[i]); inputs.push_back(~id);
         type = BV_AND; id = elaborateBvGate(bvNtk, type, inputs, _netHash);
         inputs.clear(); inputs.push_back(~id); inputs.push_back(0);
         _ntk->setInput(constrList[i], inputs); _ntk->createLatch(constrList[i]);
      }
   }
   else {
      for (uint32_t i = 0; i < constrList.size(); ++i) {
         // Create Input of Latch (F) : "F || (f && _inLoop)"
         inputs.clear(); inputs.push_back(_inLoop); inputs.push_back(constrList[i]);
         type = AIG_NODE; id = elaborateAigGate(_ntk, type, inputs, _netHash);
         constrList[i] = _ntk->createNet(1); assert (V3NetUD != constrList[i]);
         inputs.clear(); inputs.push_back(~constrList[i]); inputs.push_back(~id);
         type = AIG_NODE; id = elaborateAigGate(_ntk, type, inputs, _netHash);
         inputs.clear(); inputs.push_back(~id); inputs.push_back(0);
         _ntk->setInput(constrList[i], inputs); _ntk->createLatch(constrList[i]);
      }
   }
}
Example #21
0
void CMySharkML::Features2SharkData(LabeledData<RealVector, unsigned int> &dataset,	cv::Mat &features, std::vector<int> &v_label)
{
	//copy rows of the file into the dataset
	std::size_t rows = features.rows;
	std::size_t dimensions = features.cols;
	std::vector<std::size_t> batchSizes = shark::detail::optimalBatchSizes(rows, 256);

	// Test data
	dataset = LabeledData<RealVector, unsigned int>(batchSizes.size());
	std::size_t currentRow = 0;
	for(std::size_t b = 0; b != batchSizes.size(); ++b) {
		RealMatrix& inputs = dataset.batch(b).input;
		UIntVector& labels = dataset.batch(b).label;
		inputs.resize(batchSizes[b], dimensions);
		labels.resize(batchSizes[b]);
		//copy the rows into the batch
		for(std::size_t i = 0; i != batchSizes[b]; ++i,++currentRow){
			int rawLabel = v_label[currentRow];
			labels[i] = rawLabel; 
			for(std::size_t j = 0; j != dimensions; ++j){
				inputs(i,j) = features.at<float>(currentRow, j);
			}
		}
	}

}
Example #22
0
Qt3DCore::QNodeCreatedChangeBasePtr QAction::createNodeCreationChange() const
{
    auto creationChange = Qt3DCore::QNodeCreatedChangePtr<QActionData>::create(this);
    auto &data = creationChange->data;
    data.inputIds = qIdsForNodes(inputs());
    return creationChange;
}
Example #23
0
void CompositeEffect::save(KoXmlWriter &writer)
{
    writer.startElement(CompositeEffectId);

    saveCommonAttributes(writer);

    switch (m_operation) {
    case CompositeOver:
        writer.addAttribute("operator", "over");
        break;
    case CompositeIn:
        writer.addAttribute("operator", "in");
        break;
    case CompositeOut:
        writer.addAttribute("operator", "out");
        break;
    case CompositeAtop:
        writer.addAttribute("operator", "atop");
        break;
    case CompositeXor:
        writer.addAttribute("operator", "xor");
        break;
    case Arithmetic:
        writer.addAttribute("operator", "arithmetic");
        writer.addAttribute("k1", QString("%1").arg(m_k[0]));
        writer.addAttribute("k2", QString("%1").arg(m_k[1]));
        writer.addAttribute("k3", QString("%1").arg(m_k[2]));
        writer.addAttribute("k4", QString("%1").arg(m_k[3]));
        break;
    }

    writer.addAttribute("in2", inputs().at(1));

    writer.endElement();
}
Example #24
0
void RDGpio::inputTimerData()
{
  unsigned input_mask;
  unsigned output_mask;
  unsigned mask;

  if((input_mask=inputMask())!=gpio_input_mask) {
    for(int i=0;i<inputs();i++) {
      mask=1<<i;
      if((gpio_input_mask&mask)!=(input_mask&mask)) {
	if((input_mask&mask)==0) {
	  emit inputChanged(i,false);
	}
	else {
	  emit inputChanged(i,true);
	}
      }
    }
    gpio_input_mask=input_mask;
  }
  if((output_mask=outputMask())!=gpio_output_mask) {
    for(int i=0;i<outputs();i++) {
      mask=1<<i;
      if((gpio_output_mask&mask)!=(output_mask&mask)) {
	if((output_mask&mask)==0) {
	  emit outputChanged(i,false);
	}
	else {
	  emit outputChanged(i,true);
	}
      }
    }
    gpio_output_mask=output_mask;
  }
}
Example #25
0
void MultilayerPerceptron::startTraining(const vector<MultilayerPerceptronPattern*> &ts,
										 unsigned int epochs,
										 double MSEmin,
										 double RMSEmin,
										 double CEmin,
										 double learningRate,
										 //										 TrainingAlgorithm ta,
										 StopCondition sc)
{
	size_t sTS = ts.size();
	vector<vector<double> > inputs(sTS);
	vector<vector<double> > targets(sTS);
	for(size_t i = 0; i < sTS; i++){
		inputs[i] = ts[i]->getInputs();
		targets[i] = ts[i]->getTargets();
	}

	this->ts = new TrainingSet(inputs, targets);
	mlpbpts = new MLPBackpropagationTrainingSettings(epochs,
												 MSEmin,
												 RMSEmin,
												 CEmin,
												 learningRate,
													 (StopCondition)sc);

	sa = false;
	start(LowestPriority);
	//	return startTraining(inputs, targets, epochs, MSEmin, RMSEmin, CEmin, learningRate, ta, sc);
}
 static void dense_compute_weight_gradients(Grad& grad, Inputs&& inputs, Errors& errors) {
     for (std::size_t i = 0; i < batch_size; ++i) {
         blas_ger(
             etl::dim<1>(inputs), etl::dim<1>(errors),
             1.0,
             inputs(i).memory_start(), errors(i).memory_start(), grad.memory_start());
     }
 }
Example #27
0
void node::rt_context_update (rt_process_context& ctx)
{
    for (auto& in : inputs ())
        in.rt_context_update (ctx);
    for (auto& out : outputs ())
        out.rt_context_update (ctx);
    rt_on_context_update (ctx);
}
Example #28
0
void sync_network::calculate_phases(const solve_type solver, const double t, const double step, const double int_step) {
	std::vector<double> next_phases(size(), 0);
	std::vector<void *> argv(2, NULL);

	argv[0] = (void *) this;

	unsigned int number_int_steps = (unsigned int) (step / int_step);

	for (unsigned int index = 0; index < size(); index++) {
		argv[1] = (void *) &index;

		switch(solver) {
			case solve_type::FAST: {
				double result = m_oscillators[index].phase + phase_kuramoto(t, m_oscillators[index].phase, argv);
				next_phases[index] = phase_normalization(result);
				break;
			}
			case solve_type::RK4: {
				differ_state<double> inputs(1, m_oscillators[index].phase);
				differ_result<double> outputs;

				runge_kutta_4(m_callback_solver, inputs, t, t + step, number_int_steps, false, argv, outputs);
				next_phases[index] = phase_normalization( outputs[0].state[0] );

				break;
			}
			case solve_type::RKF45: {
				differ_state<double> inputs(1, m_oscillators[index].phase);
				differ_result<double> outputs;

				runge_kutta_fehlberg_45(m_callback_solver, inputs, t, t + step, 0.00001, false, argv, outputs);
				next_phases[index] = phase_normalization( outputs[0].state[0] );

				break;
			}
			default: {
				throw std::runtime_error("Unknown type of solver");
			}
		}
	}

	/* store result */
	for (unsigned int index = 0; index < size(); index++) {
		m_oscillators[index].phase = next_phases[index];
	}
}
Example #29
0
  void operator() (const Matrix<T,InputsAtCompileTime,1>& x, Matrix<T,ValuesAtCompileTime,1>* _v) const
  {
    Matrix<T,ValuesAtCompileTime,1>& v = *_v;

    v[0] = 2 * x[0] * x[0] + x[0] * x[1];
    v[1] = 3 * x[1] * x[0] + 0.5 * x[1] * x[1];
    if(inputs()>2)
    {
      v[0] += 0.5 * x[2];
      v[1] += x[2];
    }
    if(values()>2)
    {
      v[2] = 3 * x[1] * x[0] * x[0];
    }
    if (inputs()>2 && values()>2)
      v[2] *= x[2];
  }
Example #30
0
 std::unordered_map<Variable, ValuePtr> Evaluator::GetInputs(const std::unordered_map<Variable, MinibatchData>& arguments)
 {
     std::unordered_map<Variable, ValuePtr> inputs(arguments.size());
     for (const auto& kv : arguments)
     {
         inputs[kv.first] = kv.second.data;
     }
     return inputs;
 }