Example #1
0
osg::BoundingSphere LightPointNode::computeBound() const
{
    osg::BoundingSphere bsphere;
    bsphere.init();
    _bbox.init();

    if (_lightPointList.empty())
    {
        return bsphere;
    }


    LightPointList::const_iterator itr;
    for(itr=_lightPointList.begin();
        itr!=_lightPointList.end();
        ++itr)
    {
        _bbox.expandBy(itr->_position);
    }


    bsphere.set(_bbox.center(),0.0f);

    for(itr=_lightPointList.begin();
        itr!=_lightPointList.end();
        ++itr)
    {
        osg::Vec3 dv(itr->_position-bsphere.center());
        float radius = dv.length()+itr->_radius;
        if (bsphere.radius()<radius) bsphere.radius()=radius;
    }

    bsphere.radius()+=1.0f;
    return bsphere;
}
Example #2
0
 std::vector<double> getItemsVector(int32_t item) {
     std::vector<float> fv;
     ptr->get_item(item, &fv);
     std::vector<double> dv(fv.size());
     std::copy(fv.begin(), fv.end(), dv.begin());
     return dv;
 }
//_______________________________________________________________________
inline void ReadMLP::Transform_1( std::vector<double>& iv, int cls) const
{
   // Normalization transformation
   if (cls < 0 || cls > 2) {
   if (2 > 1 ) cls = 2;
      else cls = 2;
   }
   const int nVar = 2;

   // get indices of used variables

   // define the indices of the variables which are transformed by this transformation
   std::vector<int> indicesGet;
   std::vector<int> indicesPut;

   indicesGet.push_back( 0);
   indicesGet.push_back( 1);
   indicesPut.push_back( 0);
   indicesPut.push_back( 1);

   std::vector<double> dv(nVar);
   for (int ivar=0; ivar<nVar; ivar++) dv[ivar] = iv[indicesGet.at(ivar)];
   for (int ivar=0;ivar<2;ivar++) {
      double offset = fMin_1[cls][ivar];
      double scale  = 1.0/(fMax_1[cls][ivar]-fMin_1[cls][ivar]);
      iv[indicesPut.at(ivar)] = (dv[ivar]-offset)*scale * 2 - 1;
   }
}
    // Insert a record and try to perform an in-place update on it with a DamageVector
    // containing overlapping DamageEvents.
    TEST( RecordStoreTestHarness, UpdateWithOverlappingDamageEvents ) {
        scoped_ptr<HarnessHelper> harnessHelper( newHarnessHelper() );
        scoped_ptr<RecordStore> rs( harnessHelper->newNonCappedRecordStore() );

        if (!rs->updateWithDamagesSupported())
            return;

        {
            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            ASSERT_EQUALS( 0, rs->numRecords( opCtx.get() ) );
        }

        string data = "00010111";
        RecordId loc;
        const RecordData rec(data.c_str(), data.size() + 1);
        {
            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            {
                WriteUnitOfWork uow( opCtx.get() );
                StatusWith<RecordId> res = rs->insertRecord( opCtx.get(),
                                                            rec.data(),
                                                            rec.size(),
                                                            false );
                ASSERT_OK( res.getStatus() );
                loc = res.getValue();
                uow.commit();
            }
        }

        {
            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            ASSERT_EQUALS( 1, rs->numRecords( opCtx.get() ) );
        }

        {
            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            {
                mutablebson::DamageVector dv( 2 );
                dv[0].sourceOffset = 3;
                dv[0].targetOffset = 0;
                dv[0].size = 5;
                dv[1].sourceOffset = 0;
                dv[1].targetOffset = 3;
                dv[1].size = 5;

                WriteUnitOfWork uow( opCtx.get() );
                ASSERT_OK( rs->updateWithDamages( opCtx.get(), loc, rec, data.c_str(), dv ) );
                uow.commit();
            }
        }

        data = "10100010";
        {
            scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() );
            {
                RecordData record = rs->dataFor( opCtx.get(), loc );
                ASSERT_EQUALS( data, record.data() );
            }
        }
    }
Example #5
0
void
MapWindow::DrawTask(Canvas &canvas)
{
  if (task == NULL)
    return;

  ProtectedTaskManager::Lease task_manager(*task);
  const AbstractTask *task = task_manager->get_active_task();
  if (task == NULL || !task->check_task())
    return;

  /* RLD bearing is invalid if GPS not connected and in non-sim mode,
   but we can still draw targets */
  const bool draw_bearing = Basic().gps.Connected;

  RenderObservationZone ozv;
  RenderTaskPointMap tpv(canvas,
#ifdef ENABLE_OPENGL
                         /* OpenGL doesn't have the BufferCanvas
                            class */
                         NULL,
#else
                         &buffer_canvas,
#endif
                         render_projection,
                         SettingsMap(),
                         /* we're accessing the OrderedTask here,
                            which may be invalid at this point, but it
                            will be used only if active, so it's ok */
                         task_manager->get_ordered_task().get_task_projection(),
                         ozv, draw_bearing,
                         Basic().Location);
  RenderTask dv(tpv, render_projection.GetScreenBounds());
  ((TaskVisitor &)dv).Visit(*task);
}
Example #6
0
void link(CompilerState& state, const LinkDesc& desc)
{
    StackMaps sm;
    DataView dv(state.m_stackMapsSection->data());
    sm.parse(&dv);
    auto rm = sm.computeRecordMap();
    EMASSERT(state.m_codeSectionList.size() == 1);
    uint8_t* prologue = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(state.m_codeSectionList.front().data()));
    uint8_t* body = static_cast<uint8_t*>(state.m_entryPoint);
    desc.m_patchPrologue(desc.m_opaque, prologue);
    for (auto& record : rm) {
        EMASSERT(record.second.size() == 1);
        auto found = state.m_patchMap.find(record.first);
        if (found == state.m_patchMap.end()) {
            // should be the tcg helpers.
            continue;
        }
        PatchDesc& patchDesc = found->second;
        switch (patchDesc.m_type) {
        case PatchType::Assist: {
            desc.m_patchAssist(desc.m_opaque, body + record.second[0].instructionOffset, desc.m_dispAssist);
        } break;
        case PatchType::TcgDirect: {
            auto& recordUnit = record.second[0];
            desc.m_patchTcgDirect(desc.m_opaque, body + recordUnit.instructionOffset, desc.m_dispTcgDirect);
        } break;
        case PatchType::TcgIndirect: {
            auto& recordUnit = record.second[0];
            desc.m_patchTcgIndirect(desc.m_opaque, body + recordUnit.instructionOffset, desc.m_dispTcgIndirect);
        } break;
        default:
            EMUNREACHABLE();
        }
    }
}
Example #7
0
RcppExport SEXP holidayList(SEXP calSexp, SEXP params) {

    try {
        boost::shared_ptr<QuantLib::Calendar> pcal( getCalendar(Rcpp::as<std::string>(calSexp)) );
        Rcpp::List rparam(params);
        int iw = Rcpp::as<int>(rparam["includeWeekends"]);
        std::vector<QuantLib::Date> 
            holidays = QuantLib::Calendar::holidayList(*pcal,
                                                       QuantLib::Date(dateFromR(Rcpp::as<Rcpp::Date>( rparam["from"]))), 
                                                       QuantLib::Date(dateFromR(Rcpp::as<Rcpp::Date>( rparam["to"] ))), 
                                                       iw == 1 ? true : false);                

        if (holidays.size() > 0) {
            Rcpp::DateVector dv( holidays.size() );
            for (unsigned int i = 0; i< holidays.size(); i++){
                dv[i] = Rcpp::Date(holidays[i].month(), holidays[i].dayOfMonth(), holidays[i].year());
            }
            return Rcpp::wrap(dv);
        } else {
            return R_NilValue;
        }

    } catch(std::exception &ex) { 
        forward_exception_to_r(ex); 
    } catch(...) { 
        ::Rf_error("c++ exception (unknown reason)"); 
    }

    return R_NilValue;
}
Example #8
0
TEST_F(test_dvector, is_valid_index)
{
  dvector dv(1, 4);
  ASSERT_EQ(false, dv.is_valid_index(0));
  ASSERT_EQ(true, dv.is_valid_index(1));
  ASSERT_EQ(true, dv.is_valid_index(2));
  ASSERT_EQ(true, dv.is_valid_index(3));
  ASSERT_EQ(true, dv.is_valid_index(4));
  ASSERT_EQ(false, dv.is_valid_index(5));
  ASSERT_EQ(false, false || dv.is_valid_index(0));
  ASSERT_EQ(true, false || dv.is_valid_index(1));
  ASSERT_EQ(true, false || dv.is_valid_index(4));
  ASSERT_EQ(false, false || dv.is_valid_index(5));
  ASSERT_DEATH(dv(0), "Assertion");
  ASSERT_DEATH(dv(5), "Assertion");
}
Example #9
0
void Crossline::Process(const cv::Mat& prevImg, const cv::Mat& nextImg, float** density_feature, float** x_feature, float** y_feature) {
  std::vector<cv::Mat> src1_spl;
  std::vector<cv::Mat> src2_spl;

  split(prevImg, src1_spl);
  split(nextImg, src2_spl);

  std::vector<cv::Mat> channels;
  channels.push_back(src1_spl[0]);
  channels.push_back(src1_spl[1]);
  channels.push_back(src1_spl[2]);
  channels.push_back(src2_spl[0]);
  channels.push_back(src2_spl[1]);
  channels.push_back(src2_spl[2]);
  cv::Mat input_data;
  merge(channels, input_data);

  std::vector<cv::Mat> dv (1, input_data);
  std::vector<int> dv1 (1, 0);

  md_layer_->AddMatVector(dv, dv1);

  feature_extraction_net_->ForwardFromTo(0, feature_extraction_net_->layers().size() - 1);
  const shared_ptr<Blob<float> > feature_blob_density = feature_extraction_net_->blob_by_name("density_out");
  const shared_ptr<Blob<float> > feature_blob_X = feature_extraction_net_->blob_by_name("vx_out");
  const shared_ptr<Blob<float> > feature_blob_Y = feature_extraction_net_->blob_by_name("vy_out");

  *density_feature = feature_blob_density->mutable_cpu_data();
  *x_feature = feature_blob_X->mutable_cpu_data();
  *y_feature = feature_blob_Y->mutable_cpu_data();
}
Example #10
0
// Compute lifetime intervals and use positions of all intervals by walking
// the code bottom-up once. Loops aren't handled yet.
void Vxls::buildIntervals() {
  livein.resize(unit.blocks.size());
  intervals.resize(unit.next_vr);
  for (auto blockIt = blocks.end(); blockIt != blocks.begin();) {
    auto vlabel = *--blockIt;
    auto& block = unit.blocks[vlabel];
    LiveSet live(unit.next_vr);
    for (auto s : succs(block)) {
      if (!livein[s].empty()) live |= livein[s];
    }
    auto& block_range = block_ranges[vlabel];
    forEach(live, [&](Vreg vr) {
      intervals[vr]->add(block_range);
    });
    auto pos = block_range.end;
    for (auto i = block.code.end(); i != block.code.begin();) {
      auto& inst = *--i;
      pos -= 2;
      DefVisitor dv(live, *this, pos);
      visit(inst, dv);
      RegSet implicit_uses, implicit_defs;
      getEffects(abi, inst, implicit_uses, implicit_defs);
      implicit_defs.forEach([&](Vreg r) {
        dv.def(r);
      });
      UseVisitor uv(live, *this, {block_range.start, pos});
      visit(inst, uv);
      implicit_uses.forEach([&](Vreg r) {
        uv.use(r);
      });
    }
    livein[vlabel] = live;
  }
  for (auto& c : unit.cpool) {
    auto ivl = intervals[c.second];
    if (ivl) {
      ivl->ranges.back().start = 0;
      ivl->cns = true;
      ivl->val = c.first;
    }
  }
  // Each interval's range and use list is backwards; reverse them now.
  for (auto ivl : intervals) {
    if (!ivl) continue;
    assert(!ivl->ranges.empty()); // no empty intervals
    std::reverse(ivl->uses.begin(), ivl->uses.end());
    std::reverse(ivl->ranges.begin(), ivl->ranges.end());
  }
  if (dumpIREnabled(kRegAllocLevel)) {
    print("after building intervals");
  }
  // todo: t4764262 this should check each root, not just position 0.
  for (DEBUG_ONLY auto ivl : intervals) {
    // only constants and physical registers can be live at entry.
    assert(!ivl || ivl->cns || ivl->vreg.isPhys() || ivl->start() > 0);
  }
  assert(check(unit));
}
Example #11
0
 void MapGradient::compute_tangent_and_binormal(
     MapVertexProperty<vec3>& tangent,
     MapVertexProperty<vec3>& binormal
 ) {
     vec2 du(1,0) ; vec2 dv(0,1) ;
     FOR_EACH_VERTEX(Map, map_, it) {
         tangent[it] = compute_gradient(it, du) ;
         binormal[it] = compute_gradient(it, dv) ;
     }
		void Manipulator::translate(float dx, float dy, float dz) {
			osg::Matrixd rotation_matrix;
			rotation_matrix.makeRotate(_rotation);
			osg::Vec3d dv(dx, dy, dz);

			dv = dv *rotation_matrix;
			_center += dv;
			_acc_translation += dv;
		}
Example #13
0
void tst_QDoubleValidator::notifySignals()
{
    QDoubleValidator dv(0.1, 0.9, 10, 0);
    QSignalSpy topSpy(&dv, SIGNAL(topChanged(double)));
    QSignalSpy bottomSpy(&dv, SIGNAL(bottomChanged(double)));
    QSignalSpy decSpy(&dv, SIGNAL(decimalsChanged(int)));

    qRegisterMetaType<QDoubleValidator::Notation>("QDoubleValidator::Notation");
    QSignalSpy notSpy(&dv, SIGNAL(notationChanged(QDoubleValidator::Notation)));

    dv.setTop(0.8);
    QCOMPARE(topSpy.count(), 1);
    QVERIFY(dv.top() == 0.8);
    dv.setBottom(0.2);
    QCOMPARE(bottomSpy.count(), 1);
    QVERIFY(dv.bottom() == 0.2);

    dv.setRange(0.2, 0.7);
    QCOMPARE(topSpy.count(), 2);
    QCOMPARE(bottomSpy.count(), 1);
    QCOMPARE(decSpy.count(), 1);
    QVERIFY(dv.bottom() == 0.2);
    QVERIFY(dv.top() == 0.7);
    QVERIFY(dv.decimals() == 0.);

    dv.setRange(0.3, 0.7);
    QCOMPARE(topSpy.count(), 2);
    QCOMPARE(bottomSpy.count(), 2);
    QVERIFY(dv.bottom() == 0.3);
    QVERIFY(dv.top() == 0.7);
    QVERIFY(dv.decimals() == 0.);

    dv.setRange(0.4, 0.6);
    QCOMPARE(topSpy.count(), 3);
    QCOMPARE(bottomSpy.count(), 3);
    QVERIFY(dv.bottom() == 0.4);
    QVERIFY(dv.top() == 0.6);
    QVERIFY(dv.decimals() == 0.);

    dv.setDecimals(10);
    QCOMPARE(decSpy.count(), 2);
    QVERIFY(dv.decimals() == 10.);


    dv.setRange(0.4, 0.6, 100);
    QCOMPARE(topSpy.count(), 3);
    QCOMPARE(bottomSpy.count(), 3);
    QCOMPARE(decSpy.count(), 3);
    QVERIFY(dv.bottom() == 0.4);
    QVERIFY(dv.top() == 0.6);
    QVERIFY(dv.decimals() == 100.);

    dv.setNotation(QDoubleValidator::StandardNotation);
    QCOMPARE(notSpy.count(), 1);
    QVERIFY(dv.notation() == QDoubleValidator::StandardNotation);
}
Example #14
0
static void ParticlesAdvector_RKII()
{
	VFXEpoch::Grid2DfScalarField du(v.getDimY(), v.getDimX(), 1.0f / v.getDimX(), 1.0f / v.getDimY());
	VFXEpoch::Grid2DfScalarField dv(v.getDimY(), v.getDimX(), 1.0f / v.getDimX(), 1.0f / v.getDimY());
	VFXEpoch::ExtractComponents(du, v, VFXEpoch::VECTOR_COMPONENTS::X);
	VFXEpoch::ExtractComponents(dv, v, VFXEpoch::VECTOR_COMPONENTS::Y);
	sl2D_solver._advect_particles_rk2(du, dv, particles);
	du.clear();
	dv.clear();
}
Example #15
0
void tr(int i,int m,int r,int c)
{
	int j,k,o;
	__int64 sa[55],sb[55],pa[55],pb[55];
	s=(s+s+1)%q;
	for(j=r;j<=m;j++)
	{
		if(j>m/2)
		{
			if(!i)break;
			j=m;
		}
		c++;
		if(j>r)c=1;
		e=dv(e,c);
		for(k=2;k<=j;k++)e=dv(e,k);
		memcpy(sa,ta,n*8);
		memcpy(sb,tb,n*8);
		memcpy(pa,ta,n*8);
		memcpy(pb,tb,n*8);
		memset(ta,0,n*8);
		memset(tb,0,n*8);
		for(o=0;o<n-j;o++)
			for(k=0;k<j;k++)
			{
				ta[o+k]=(ta[o+k]+pa[o]*a[j][k])%q;
				tb[o+k]=(tb[o+k]+pb[o]*b[j][k])%q;
			}
		if(j<m)tr(i+1,m-j,j,c);
		else
			for(k=0;k<n;k++)
			{
				a[n][k+i]=(a[n][k+i]+tb[k]*e)%q;
				b[n][k]=(b[n][k]+ta[k]*s%q*e)%q;
			}
		memcpy(ta,sa,n*8);
		memcpy(tb,sb,n*8);
		e=e*c%q;
		for(k=2;k<=j;k++)e=e*k%q;
	}
	s=dv(s+q-1,2);
}
Example #16
0
void dgBody::AddImpulse (const dgVector& pointDeltaVeloc, const dgVector& pointPosit)
{
	dgMatrix invInertia (CalculateInvInertiaMatrix());

	// get contact matrix
	dgMatrix tmp;
	dgVector globalContact (pointPosit - m_globalCentreOfMass);

	tmp[0][0] = dgFloat32 (0.0f);
	tmp[0][1] = + globalContact[2];
	tmp[0][2] = - globalContact[1];
	tmp[0][3] = dgFloat32 (0.0f);

	tmp[1][0] = -globalContact[2];
	tmp[1][1] = dgFloat32 (0.0f);
	tmp[1][2] = +globalContact[0];
	tmp[1][3] = dgFloat32 (0.0f);

	tmp[2][0] = +globalContact[1];
	tmp[2][1] = -globalContact[0];
	tmp[2][2] = dgFloat32 (0.0f);
	tmp[2][3] = dgFloat32 (0.0f);

	tmp[3][0] = dgFloat32 (0.0f);
	tmp[3][1] = dgFloat32 (0.0f);
	tmp[3][2] = dgFloat32 (0.0f);
	tmp[3][3] = dgFloat32 (1.0f);

	dgMatrix contactMatrix (tmp * invInertia * tmp);
	for (dgInt32 i = 0; i < 3; i ++) {
		for (dgInt32 j = 0; j < 3; j ++) {
			contactMatrix[i][j] *= -dgFloat32 (1.0f);
		}
	}
	contactMatrix[0][0] += m_invMass.m_w;	
	contactMatrix[1][1] += m_invMass.m_w;	
	contactMatrix[2][2] += m_invMass.m_w;	

	contactMatrix = contactMatrix.Symetric3by3Inverse ();

	// change of momentum
	dgVector changeOfMomentum (contactMatrix.RotateVector (pointDeltaVeloc));


	dgVector dv (changeOfMomentum.Scale3 (m_invMass.m_w));
	dgVector dw (invInertia.RotateVector (globalContact * changeOfMomentum));

	m_veloc += dv;
	m_omega += dw;

	m_sleeping	= false;
	m_equilibrium = false;
	Unfreeze ();
}
Example #17
0
void
MapWindow::DrawAbortedTask(Canvas &canvas)
{
  if (way_points == NULL || task == NULL)
    return;

  Pen dash_pen(Pen::DASH, IBLSCALE(1), MapGfx.TaskColor);
  canvas.select(dash_pen);
  DrawAbortedTaskVisitor dv(canvas, Orig_Aircraft, *way_points);
  task->scan_point_forward(dv, false); // read lock
}
Example #18
0
void
MapWindow::DrawTask(Canvas &canvas, RECT rc)
{
  if (way_points == NULL || task == NULL)
    return;

  DrawTaskVisitor dv(*this, canvas, Orig_Aircraft, task_screen, task_start_screen,
                     task->getActiveIndex(), *way_points);
  task->scan_leg_forward(dv, false); // read lock
  task->scan_point_forward(dv, false); // read lock
}
Example #19
0
void Mesh::computeDualVertices(void) {
  if (triangles.size() == 0 || vertices.size() == 0) {
    std::cout << "Unitialized mesh\n";
  }

  for (const auto &t : triangles) {
    Vertex dv((vertices[t.v1].x + vertices[t.v2].x + vertices[t.v3].x) / 3,
              (vertices[t.v1].y + vertices[t.v2].y + vertices[t.v3].y) / 3,
              (vertices[t.v1].z + vertices[t.v2].z + vertices[t.v3].z) / 3);
    dvertices.push_back(dv);
  }
}
RcppExport SEXP classicRcppDateExample(SEXP dvsexp, SEXP dtvsexp) {

    SEXP rl = R_NilValue;		 // Use this when there is nothing to be returned.
    char *exceptionMesg = NULL;

    try {

	RcppDateVector dv(dvsexp);
	RcppDatetimeVector dtv(dtvsexp);
	
	Rprintf("\nIn C++, seeing the following date value\n");
	for (int i=0; i<dv.size(); i++) {
	    Rcpp::Rcout << dv(i) << std::endl;
	    dv(i) = dv(i) + 7;		// shift a week
	}
	Rprintf("\nIn C++, seeing the following datetime value\n");
	for (int i=0; i<dtv.size(); i++) {
	    Rcpp::Rcout << dtv(i) << std::endl;
	    dtv(i) = dtv(i) + 0.250;    // shift 250 millisec
	}

	// Build result set to be returned as a list to R.
	RcppResultSet rs;
	rs.add("date",   dv);
	rs.add("datetime", dtv);

	// Get the list to be returned to R.
	rl = rs.getReturnList();
	
    } catch(std::exception& ex) {
	exceptionMesg = copyMessageToR(ex.what());
    } catch(...) {
	exceptionMesg = copyMessageToR("unknown reason");
    }
    
    if(exceptionMesg != NULL)
	Rf_error(exceptionMesg);
	
    return rl;
}
Example #21
0
void
br(void)
{
	if(!isoutput)
		return;
	isoutput = 0;

	nr(L(".dv"), 0);
	dv(0);
	hideihtml();
	if(getnr(L(".paragraph")))
		outhtml(L("</p>"));
}
void tst_QDoubleValidator::validateIntEquiv()
{
    QFETCH(double, minimum);
    QFETCH(double, maximum);
    QFETCH(QString, input);
    QFETCH(QValidator::State, state);

    QLocale::setDefault(QLocale("C"));

    QDoubleValidator dv(minimum, maximum, 0, 0);
    dv.setNotation(QDoubleValidator::StandardNotation);
    int dummy;
    QCOMPARE(dv.validate(input, dummy), state);
}
int main(){

    long k, n1, n2, n3, t1, t2, t3; scanf("%ld %ld %ld %ld %ld %ld %ld", &k, &n1, &n2, &n3, &t1, &t2, &t3);
    std::vector<long> dv(k, 0);
    for(int p = 0; p < k; p++){
        if(p >= n1){dv[p] = (dv[p] > dv[p - n1] + t1) ? dv[p] : (dv[p - n1] + t1);}
        if(p >= n2){dv[p] = (dv[p] > dv[p - n2] + t2) ? dv[p] : (dv[p - n2] + t2);}
        if(p >= n3){dv[p] = (dv[p] > dv[p - n3] + t3) ? dv[p] : (dv[p - n3] + t3);}
    }

    printf("%ld\n", dv.back() + t1 + t2 + t3);

    return 0;
}
Example #24
0
/**
 * Draw the AAT areas to the buffer and copy the buffer to the drawing canvas
 * @param canvas The drawing canvas
 * @param rc The area to draw in
 * @param buffer The drawing buffer
 */
void
MapWindow::DrawTaskAAT(Canvas &canvas, const RECT rc, Canvas &buffer)
{
  if (way_points == NULL || task == NULL)
    return;

  if (task->getSettings().AATEnabled) {
    DrawTaskAATVisitor dv(canvas, rc, buffer, task->getActiveIndex(),
                          task_screen, *this, SettingsMap(), *way_points);
    task->scan_point_forward(dv, false); // read lock
    // TODO, reverse
    canvas.copy_transparent_white(buffer, rc);
  }
}
gboolean WnCourt::on_motion_notify_event_callback(GtkWidget * widget, GdkEventMotion * event , WnCourt *wncourt)
{
	if (event->state & GDK_BUTTON1_MASK) {
		if (wncourt->dragball) {
			vector_t dv((single)(event->x - wncourt->oldX), (single)(event->y - wncourt->oldY), 0);
			wncourt->dragball->getP().getP().add(dv);
			if (wncourt->overball) {
				wncourt->overball->set_highlight(false);
				wncourt->overball = NULL;
			}
		} else if (wncourt->resizing) {
			wncourt->widget_width = (gint)event->x;
			wncourt->widget_height = (gint)event->y;
			if (wncourt->widget_width < 20)
				wncourt->widget_width = 20;
			if (wncourt->widget_height < 20)
				wncourt->widget_height = 20;
			wncourt->CenterScene();
			gtk_widget_set_size_request (wncourt->drawing_area, wncourt->widget_width, wncourt->widget_height);
		} else if (wncourt->panning) {
			wncourt->_court->get_scene().pan(vector_t((single)(event->x - wncourt->oldX), (single)(event->y - wncourt->oldY), 0));
		}
		wncourt->oldX = (int)(event->x);
		wncourt->oldY = (int)(event->y);
	} else {
		wnobj * b;
		if (wncourt->_court->hit((int)event->x, (int)event->y, &b)) {
			if (wncourt->overball != b) {
				wncourt->overball = b;
				wncourt->overball->set_anchor(true);
				wncourt->overball->set_highlight(true);
				gtk_widget_queue_draw(wncourt->drawing_area);
				if (wncourt->overball->getT() & wnobj::et_ball) {
					ball_t *ball = static_cast<ball_t *>(wncourt->overball);
					char *text = g_markup_printf_escaped("<i>%s</i>\n%s", ball->get_type_str(), ball->get_text());
					wncourt->ShowPangoTips(wncourt->CurrentWord.c_str(), text);
					g_free(text);
				}
			}
		} else {
			if (wncourt->overball) {
				wncourt->overball->set_anchor(false);
				wncourt->overball->set_highlight(false);
				wncourt->overball = NULL;
			}
		}
	}
	return TRUE;
}
Example #26
0
/* Function for passing over the network (backward pass) */
void backwardRun() {
    int from[2],to[2]; // declarations of auxiliary arrays
    
    /*      Compute deltas in output layers      */
    for (int i = FO, j = 0; i <= LO; i++, j++) { // from first to last neuron in output layer
        d(i) = (dv(j) - y(i)) * df(x(i));        // using formula to compute deltas on output layer
        //printf("\nd(%d) = (dv(%d) - y(%d)) * df(x(%d))",i,j,i,i);
    }
    //printf("\n---------");
    
    /* Compute deltas in first hidden layer  */
    from[0] = F1H; to[0] = L1H;              // definitions from-to for j (from first to last in first hidden layer)
    from[1] =  FO; to[1] =  LO;              // definitions from-to for i (from first to last in second hidden layer)
    deltaRun(from,to);                       // runs function
}
Example #27
0
/***********************************************************************
 * Compute the forces and energies, given positions, masses,
 * and velocities
 ***********************************************************************/
void compute(int np, int nd, 
	     double *box, 
	     vnd_t pos[nparts], vnd_t vel[nparts], 
	     double mass, vnd_t f[nparts], 
	     double *pot_p, real8 *kin_p) 
{
  double x;
  int i, j, k;
  vnd_t rij;
  double  d;
  double pot, kin;
  
  pot = 0.0;
  kin = 0.0;

 
  /* The computation of forces and energies is fully parallel. */
  {
/*  #pragma omp for reduction(+ : pot, kin) */
  for (i = 0; i < np; i++) {
    /* compute potential energy and forces */
    #pragma omp for
    for (j = 0; j < nd; j++) 
      f[i][j] = 0.0;
     
    #pragma omp for reduction(+ : pot)
    for (j = 0; j < np; j++) { 
      if (i != j) {
   	d = dist(nd,box,pos[i],pos[j],rij);
   	/* attribute half of the potential energy to particle 'j' */
   	pot = pot + 0.5 * v(d);
      	for (k = 0; k < nd; k++) {
   	   	f[i][k] = f[i][k] - rij[k]* dv(d) /d;
         } 
      }
     } 
    /* compute kinetic energy */
    kin = kin + dotr8(nd,vel[i],vel[j]);
  }
  }

  
  kin = kin*0.5*mass;

  *pot_p = pot;
  *kin_p = kin;
}
Example #28
0
TEST_F(test_dvector, cast_ivector)
{
  dvector dv(1, 4);
  dv(1) = INT_MIN;
  dv(2) = INT_MIN/2;
  dv(3) = INT_MAX/2;
  dv(4) = INT_MAX;

  ivector iv(1, 2);
  iv(1) = 3;
  iv(2) = 1;

  dvector ret = dv(iv);
  EXPECT_EQ(iv.indexmin(), ret.indexmin());
  EXPECT_EQ(iv.indexmax(), ret.indexmax());
  EXPECT_DOUBLE_EQ(dv((int)iv(1)), ret(1));
  EXPECT_DOUBLE_EQ(dv((int)iv(2)), ret(2));
}
Example #29
0
TEST_F(test_dvector, cast_lvector)
{
  dvector dv(1, 4);
  dv(1) = LONG_MIN;
  dv(2) = LONG_MIN/2;
  dv(3) = LONG_MAX/2;
  dv(4) = LONG_MAX;

  lvector lv(1, 2);
  lv(1) = 3;
  lv(2) = 1;

  dvector ret = dv(lv);
  EXPECT_EQ(lv.indexmin(), ret.indexmin());
  EXPECT_EQ(lv.indexmax(), ret.indexmax());
  EXPECT_DOUBLE_EQ(dv((int)lv(1)), ret(1));
  EXPECT_DOUBLE_EQ(dv((int)lv(2)), ret(2));
}
TEST(DataView, DataView) {
    char buf[sizeof(uint32_t) * 3];
    uint32_t native = 1234;

    DataView dv(buf);

    dv.writeNative(native);
    dv.writeLE(native, sizeof(uint32_t));
    dv.writeBE(native, sizeof(uint32_t) * 2);

    ASSERT_EQUALS(buf, dv.view());
    ASSERT_EQUALS(buf + 5, dv.view(5));

    ASSERT_EQUALS(native, dv.readNative<uint32_t>());
    ASSERT_EQUALS(native, dv.readLE<uint32_t>(sizeof(uint32_t)));
    ASSERT_EQUALS(native, dv.readBE<uint32_t>(sizeof(uint32_t) * 2));
}