Example #1
1
void ode_evaluate(
	CppAD::vector<Float> &x  , 
	size_t m                 , 
	CppAD::vector<Float> &fm )
{
	typedef CppAD::vector<Float> Vector;

	size_t n = x.size();
	size_t ell;
	CPPAD_ASSERT_KNOWN( m == 0 || m == 1,
		"ode_evaluate: m is not zero or one"
	);
	CPPAD_ASSERT_KNOWN( 
		((m==0) & (fm.size()==n)) || ((m==1) & (fm.size()==n*n)),
		"ode_evaluate: the size of fm is not correct"
	);
	if( m == 0 )
		ell = n;
	else	ell = n + n * n;

	// set up the case we are integrating
	Float  ti   = 0.;
	Float  tf   = 1.;
	Float  smin = 1e-5;
	Float smax  = 1.;
	Float scur  = 1.;
	Float erel  = 0.;
	vector<Float> yi(ell), eabs(ell);
	size_t i, j;
	for(i = 0; i < ell; i++)
	{	eabs[i] = 1e-10;
		if( i < n )
			yi[i] = 1.;
		else	yi[i]  = 0.;
	}

	// return values
	Vector yf(ell), ef(ell), maxabs(ell);
	size_t nstep;

	// construct ode method for taking one step
	ode_evaluate_method<Float> method(m, x);

	// solve differential equation
	yf = OdeErrControl(method, 
		ti, tf, yi, smin, smax, scur, eabs, erel, ef, maxabs, nstep);

	if( m == 0 )
	{	for(i = 0; i < n; i++)
			fm[i] = yf[i];
	}
	else
	{	for(i = 0; i < n; i++)
			for(j = 0; j < n; j++)
				fm[i * n + j] = yf[n + i * n + j];
	}
	return;
}
Example #2
0
static void exi_dir1 (RAnalOp *op, ut8 addr, const char *operation) {
	if (addr < 0x80) {
		ef ("_idata,%d,+,%s=[1],", addr, operation);
	} else {
		ef ("_sfr,0x7f,%d,&,+,%s=[1],", addr, operation);
	}
}
Example #3
0
static void exw_dir2(RAnalOp *op, ut8 addr) {
	if (addr < 0x80) {
		ef ("_idata,%d,+,=[1],", addr);
	} else {
		ef ("_sfr,0x7f,%d,&,+,=[1],", addr);
	}
}
Example #4
0
    ostream &
    ostream::operator<<(const char *str)
    {
        // TODO: At the moment we don't have a good way of specifying the
        // VCPU that a print function comes from. We need to extend iostream
        // so that a print statement can state which VCPU it's coming from
        // so that it can be directed to the proper vcpu here. At the moment
        // everything is broadcast (i.e. all vcpus will get the same output)

        int len = strlen(str);
        int gap = m_width - len;

        if (m_width > 0)
            m_width = 0;

        if (m_justify == std::right)
        {
            for (auto i = 0; i < gap; i++)
                ef()->write(" ", 1);
        }

        ef()->write(str, len);

        if (m_justify == std::left)
        {
            for (auto i = 0; i < gap; i++)
                ef()->write(" ", 1);
        }

        return *this;
    }
Example #5
0
bool MagicTower::attack() {
    int opt = thePrefs.GetInt("PlayerSettings", "Tactics");
    bool (*tactics[6])(Enemy*, Enemy*) = { (bool(*)(Enemy*, Enemy*))&Tower::nearest_tower, (bool(*)(Enemy*, Enemy*))&Tower::nearest_castle,
                                           (bool(*)(Enemy*, Enemy*))&Tower::weakest, (bool(*)(Enemy*, Enemy*))&Tower::strongest,
                                           (bool(*)(Enemy*, Enemy*))&Tower::fastest, (bool(*)(Enemy*, Enemy*))&Tower::slowest
                                         };
    Vector2 pos = this->GetPosition();
    ActorSet enemies = theTagList.GetObjectsTagged("enemy");
    ActorSet::iterator it = enemies.begin();
    float min_dist = 1000.0;
    Enemy* for_dmg = NULL;
    while(it != enemies.end()) {
        Vector2 en_pos = (*it)->GetPosition();
        float dist = Vector2::DistanceSquared(en_pos, pos);
        if ((dist <= MathUtil::PixelsToWorldUnits(Level::Radius(level))) && ((for_dmg == NULL) || (tactics[opt]((Enemy*)(*it), for_dmg)))) {
            for_dmg = (Enemy*)(*it);
        }
        it++;
    }
    if(for_dmg) {
        Actor *circle = new Actor();
        circle->SetPosition(this->GetPosition());
        circle->SetColor(0.7f, 0.3f, 0.5f);
        circle->SetDrawShape(ADS_Circle);
        circle->SetSize(0.1);
        theWorld.Add(circle, 3);
        circle->MoveTo(for_dmg->GetPosition(), 0.1);
        std::thread for_del(&MagicTower::delete_circle, this, circle);
        for_del.detach();
        for_dmg->get_damage(thePrefs.GetFloat("TowerSettings", "MagicDmg"));
        int random_effect = MathUtil::RandomIntInRange(1, 3);
        switch(random_effect) {
        case 1: {
            std::shared_ptr<Effect> ef(new Poisoning());
            for_dmg->effect(ef);
            break;
        }
        case 2: {
            std::shared_ptr<Effect> ef(new Deceleration());
            for_dmg->effect(ef);
            break;
        }
        case 3: {
            std::shared_ptr<Effect> ef(new Weakness());
            for_dmg->effect(ef);
            break;
        }
        }
    }
}
Example #6
0
void Cf3Replay::Save(Cf3StageFile *stage, int map)
{
	if (CApp::MakeFileName(m_FileName,"f3r",theSetting->m_RecordNumber,true)) {
		Cf3StageFile data;
		DWORD chunk, size;
		BYTE* ptr;
		// キー入力情報をこーんぽたーじゅ(謎)
		ptr = new BYTE[m_nSize*2];
		Seek();
		while(!Finished()) {
			ptr[m_nProgress*2	] = (*m_iPointer).pressed	[m_nPointer];
			ptr[m_nProgress*2+1	] = (*m_iPointer).pushed	[m_nPointer];
			Progress();
		}
		data.SetStageData(CT_RPLY, m_nSize*2, ptr);
		delete[]ptr;
		// 必要なステージ情報をコピーする
		if (ptr=stage->GetStageData(chunk=CT_TITL,&size))
			data.SetStageData(chunk,size,ptr);
		if (ptr=stage->GetStageData(chunk=CT_HITS,&size))
			data.SetStageData(chunk,size,ptr);
		if (ptr=stage->GetStageData(chunk=Cf3Map::GetChunkType(CT_TL00,map),&size))
			data.SetStageData(chunk,size,ptr);
		if (ptr=stage->GetStageData(chunk=Cf3Map::GetChunkType(CT_M000,map),&size))
			data.SetStageData(chunk,size,ptr);
		if (ptr=stage->GetStageData(chunk=Cf3Map::GetChunkType(CT_M100,map),&size))
			data.SetStageData(chunk,size,ptr);
		if (ptr=stage->GetStageData(chunk=Cf3Map::GetChunkType(CT_M200,map),&size))
			data.SetStageData(chunk,size,ptr);
		if (ptr=stage->GetStageData(chunk=CT_MCD0|(0<<24),&size))
			data.SetStageData(chunk,size,ptr);
		ef (ptr=stage->GetStageData(chunk=CT_MCF0|(0<<24),&size))
			data.SetStageData(chunk,size,ptr);
		if (ptr=stage->GetStageData(chunk=CT_MCD0|(1<<24),&size))
			data.SetStageData(chunk,size,ptr);
		ef (ptr=stage->GetStageData(chunk=CT_MCF0|(1<<24),&size))
			data.SetStageData(chunk,size,ptr);
		if (ptr=stage->GetStageData(chunk=CT_MCD0|(2<<24),&size))
			data.SetStageData(chunk,size,ptr);
		ef (ptr=stage->GetStageData(chunk=CT_MCF0|(2<<24),&size))
			data.SetStageData(chunk,size,ptr);
		// 追加の情報
		data.SetStageData(CT_STGN, 4, &map);
		data.SetStageData(CT_GRVT, 4, &theSetting->m_Gravity);
		data.SetStageData(CT_HYPR, 4, &theSetting->m_Hyper);
		data.Write(m_FileName);
	}
}
Example #7
0
void ef_enumeration_benchmark(uint64_t m, uint8_t bits)
{
    succinct::elias_fano::elias_fano_builder bvb(uint64_t(1) << bits, m);
    monotone_generator mgen(m, bits, 37);
    for (size_t i = 0; i < m; ++i) { 
	bvb.push_back(mgen.next());
    }
    assert(mgen.done());

    succinct::elias_fano ef(&bvb);
    succinct::mapper::size_tree_of(ef)->dump();
    
    
    double elapsed;
    uint64_t foo = 0;
    SUCCINCT_TIMEIT(elapsed) {
	succinct::elias_fano::select_enumerator it(ef, 0);
	for (size_t i = 0; i < m; ++i) {
	    foo ^= it.next();
	}
    }
    volatile uint64_t vfoo = foo;
    (void)vfoo; // silence warning

    std::cerr << "Elapsed: " << elapsed / 1000 << " msec\n"
	      << double(m) / elapsed << " Mcodes/s" << std::endl;
}
Example #8
0
int xdl_diff_modified(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
	     xdemitconf_t const *xecfg, xdemitcb_t *ecb, xdfenv_t *pxe, xdchange_t **pxscr) {
	emit_func_t ef = xecfg->hunk_func ? xdl_call_hunk_func : xdl_emit_diff;

	if (xdl_do_diff(mf1, mf2, xpp, pxe) < 0) {

		return -1;
	}
	if (xdl_change_compact(&pxe->xdf1, &pxe->xdf2, xpp->flags) < 0 ||
	    xdl_change_compact(&pxe->xdf2, &pxe->xdf1, xpp->flags) < 0 ||
	    xdl_build_script(pxe, pxscr) < 0) {

		xdl_free_env(pxe);
		return -1;
	}
	if (*pxscr) {
		if (xpp->flags & XDF_IGNORE_BLANK_LINES)
			xdl_mark_ignorable(*pxscr, pxe, xpp->flags);

		if (ef(pxe, *pxscr, ecb, xecfg) < 0) {

			xdl_free_script(pxscr);
			xdl_free_env(pxe);
			return -1;
		}
	}

	return 0;
}
Example #9
0
void EFXFixture_Test::loadSuccess()
{
    QDomDocument doc;

    QDomElement root = doc.createElement("Fixture");

    QDomElement id = doc.createElement("ID");
    QDomText idText = doc.createTextNode("83");
    id.appendChild(idText);
    root.appendChild(id);

    QDomElement head = doc.createElement("Head");
    QDomText headText = doc.createTextNode("76");
    head.appendChild(headText);
    root.appendChild(head);

    QDomElement dir = doc.createElement("Direction");
    QDomText dirText = doc.createTextNode("Backward");
    dir.appendChild(dirText);
    root.appendChild(dir);

    QDomElement in = doc.createElement("Intensity");
    QDomText inText = doc.createTextNode("91");
    in.appendChild(inText);
    root.appendChild(in);

    EFX e(m_doc);
    EFXFixture ef(&e);
    QVERIFY(ef.loadXML(root) == true);
    QVERIFY(ef.head().fxi == 83);
    QVERIFY(ef.head().head == 76);
    QVERIFY(ef.direction() == EFX::Backward);
    QVERIFY(ef.fadeIntensity() == 91);
}
Example #10
0
void EFXFixture_Test::initial()
{
    EFX e(m_doc);

    EFXFixture ef(&e);
    QVERIFY(ef.fixture() == Fixture::invalidId());
    QVERIFY(ef.direction() == EFX::Forward);
    QVERIFY(ef.serialNumber() == 0);
    QVERIFY(ef.startScene() == NULL);
    QVERIFY(ef.stopScene() == NULL);
    QVERIFY(ef.isValid() == false);
    QVERIFY(ef.isReady() == false);

    QVERIFY(ef.m_fixture == Fixture::invalidId());
    QVERIFY(ef.m_direction == EFX::Forward);
    QVERIFY(ef.m_serialNumber == 0);
    QVERIFY(ef.m_runTimeDirection == EFX::Forward);
    QVERIFY(ef.m_startScene == NULL);
    QVERIFY(ef.m_stopScene == NULL);
    QVERIFY(ef.m_initialized == false);
    QVERIFY(ef.m_ready == false);
    QVERIFY(ef.m_iterator == 0);
    QVERIFY(ef.m_skipIterator == 0);
    QVERIFY(ef.m_skipThreshold == 0);
    QVERIFY(ef.m_panValue == 0);
    QVERIFY(ef.m_tiltValue == 0);
    QVERIFY(ef.m_lsbPanChannel == Fixture::invalidChannel());
    QVERIFY(ef.m_msbPanChannel == Fixture::invalidChannel());
    QVERIFY(ef.m_lsbTiltChannel == Fixture::invalidChannel());
    QVERIFY(ef.m_msbTiltChannel == Fixture::invalidChannel());
}
Example #11
0
void EFXFixture_Test::loadExtraTag()
{
    QDomDocument doc;

    QDomElement root = doc.createElement("Fixture");

    QDomElement id = doc.createElement("ID");
    QDomText idText = doc.createTextNode("108");
    id.appendChild(idText);
    root.appendChild(id);

    QDomElement dir = doc.createElement("Direction");
    QDomText dirText = doc.createTextNode("Forward");
    dir.appendChild(dirText);
    root.appendChild(dir);

    QDomElement foo = doc.createElement("Foobar");
    QDomText fooText = doc.createTextNode("Just testing");
    foo.appendChild(fooText);
    root.appendChild(foo);

    EFX e(m_doc);
    EFXFixture ef(&e);
    QVERIFY(ef.loadXML(&root) == true);
    QVERIFY(ef.fixture() == 108);
    QVERIFY(ef.direction() == EFX::Forward);
}
Example #12
0
void EFXFixture_Test::protectedProperties()
{
    EFX e(m_doc);
    EFXFixture ef(&e);

    ef.setSerialNumber(15);
    QVERIFY(ef.serialNumber() == 15);

    ef.setStartScene(reinterpret_cast<Scene*>(0xDEADBEEF));
    QVERIFY(ef.startScene() == reinterpret_cast<Scene*>(0xDEADBEEF));

    ef.setStopScene(reinterpret_cast<Scene*>(0xDEADBEEF));
    QVERIFY(ef.stopScene() == reinterpret_cast<Scene*>(0xDEADBEEF));

    ef.setLsbPanChannel(56);
    QVERIFY(ef.m_lsbPanChannel == 56);

    ef.setMsbPanChannel(3);
    QVERIFY(ef.m_msbPanChannel == 3);

    ef.setLsbTiltChannel(19);
    QVERIFY(ef.m_lsbTiltChannel == 19);

    ef.setMsbTiltChannel(102);
    QVERIFY(ef.m_msbTiltChannel == 102);
}
Example #13
0
void EFXFixture_Test::save()
{
    EFX e(m_doc);
    EFXFixture ef(&e);
    ef.setHead(GroupHead(56, 7));
    ef.setDirection(EFX::Backward);

    QDomDocument doc;
    QDomElement root = doc.createElement("EFX");

    QVERIFY(ef.saveXML(&doc, &root) == true);

    QDomElement tag = root.firstChild().toElement();
    QVERIFY(tag.tagName() == "Fixture");

    tag = tag.firstChild().toElement();
    QVERIFY(tag.tagName() == "ID");
    QVERIFY(tag.text() == "56");

    tag = tag.nextSibling().toElement();
    QVERIFY(tag.tagName() == "Head");
    QVERIFY(tag.text() == "7");

    tag = tag.nextSibling().toElement();
    QVERIFY(tag.tagName() == "Direction");
    QVERIFY(tag.text() == "Backward");
}
Example #14
0
/*!
    Constructs a QMimeType from a \a fileName.
*/
QMimeType QMimeType::fromFileName( const QString &fileName )
{
    QMimeType type;

    int slashIndex = fileName.lastIndexOf( QLatin1Char( '/' ) );

    int dotIndex = fileName.lastIndexOf( QLatin1Char( '.' ) );

    if( dotIndex > slashIndex )
    {
        if(loadedTimes()->count() == 0)
            loadExtensions();
        QString extension = fileName.mid( dotIndex + 1 ).toLower();

        type.mimeId = typeFor()->value( extension );
    }

    if( type.mimeId.isEmpty() )
    {
        const char elfMagic[] = { '\177', 'E', 'L', 'F', '\0' };

        QFile ef( fileName );

        if ( ef.size() > 5 && ef.open( QIODevice::ReadOnly ) && ef.peek(5) == elfMagic)  // try to find from magic
            type.mimeId = QLatin1String("application/x-executable");  // could be a shared library or an exe
        else
            type.mimeId = QLatin1String("application/octet-stream");
    }

    return type;
}
Example #15
0
void EFXFixture_Test::copyFrom()
{
    EFX e(m_doc);

    EFXFixture ef(&e);
    ef.m_head.fxi = 15;
    ef.m_head.head = 16;
    ef.m_direction = EFX::Backward;
    ef.m_serialNumber = 25;
    ef.m_runTimeDirection = EFX::Backward;
    ef.m_ready = true;
    ef.m_elapsed = 31337;
    ef.m_intensity = 0.314159;
    ef.m_fadeIntensity = 125;

    EFXFixture copy(&e);
    copy.copyFrom(&ef);
    QVERIFY(copy.m_head.fxi == 15);
    QVERIFY(copy.m_head.head == 16);
    QVERIFY(copy.m_direction == EFX::Backward);
    QVERIFY(copy.m_serialNumber == 25);
    QVERIFY(copy.m_runTimeDirection == EFX::Backward);
    QVERIFY(copy.m_ready == true);
    QVERIFY(copy.m_elapsed == 31337);
    QVERIFY(copy.m_intensity == 0.314159);
    QVERIFY(copy.m_fadeIntensity == 125);
}
Example #16
0
File: xdiffi.c Project: Advael/git
int xdl_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
	     xdemitconf_t const *xecfg, xdemitcb_t *ecb) {
	xdchange_t *xscr;
	xdfenv_t xe;
	emit_func_t ef = xecfg->hunk_func ? xdl_call_hunk_func : xdl_emit_diff;

	if (xdl_do_diff(mf1, mf2, xpp, &xe) < 0) {

		return -1;
	}
	if (xdl_change_compact(&xe.xdf1, &xe.xdf2, xpp->flags) < 0 ||
	    xdl_change_compact(&xe.xdf2, &xe.xdf1, xpp->flags) < 0 ||
	    xdl_build_script(&xe, &xscr) < 0) {

		xdl_free_env(&xe);
		return -1;
	}
	if (xscr) {
		if (ef(&xe, xscr, ecb, xecfg) < 0) {

			xdl_free_script(xscr);
			xdl_free_env(&xe);
			return -1;
		}
		xdl_free_script(xscr);
	}
	xdl_free_env(&xe);

	return 0;
}
Example #17
0
void EFXFixture_Test::startStop()
{
    EFX e(m_doc);
    EFXFixture ef(&e);

    SceneStub s1(m_doc);
    s1.setValue(0, 1);
    s1.setValue(1, 2);
    s1.setValue(2, 3);
    ef.setStartScene(&s1);

    SceneStub s2(m_doc);
    s2.setValue(0, 4);
    s2.setValue(1, 5);
    s2.setValue(2, 6);
    ef.setStopScene(&s2);

    QByteArray array;

    ef.start(&array);
    QVERIFY(array[0] == (char) 1);
    QVERIFY(array[1] == (char) 2);
    QVERIFY(array[2] == (char) 3);

    ef.stop(&array);
    QVERIFY(array[0] == (char) 4);
    QVERIFY(array[1] == (char) 5);
    QVERIFY(array[2] == (char) 6);
}
Example #18
0
// Handler for deliverEventQueue.
// This thread decodes frames from events.
void Cluster::deliveredEvent(const Event& e) {
    if (e.isCluster()) {
        EventFrame ef(e, e.getFrame());
        // Stop the deliverEventQueue on update offers.
        // This preserves the connection decoder fragments for an update.
        // Only do this for the two brokers that are directly involved in this
        // offer: the one making the offer, or the one receiving it.
        const ClusterUpdateOfferBody* offer = castUpdateOffer(ef.frame.getBody());
        if (offer && ( e.getMemberId() == self || MemberId(offer->getUpdatee()) == self) ) {
            QPID_LOG(info, *this << " stall for update offer from " << e.getMemberId()
                     << " to " << MemberId(offer->getUpdatee()));
            deliverEventQueue.stop();
        }
        deliverFrame(ef);
    }
    else if(!discarding) {
        if (e.isControl())
            deliverFrame(EventFrame(e, e.getFrame()));
        else {
            try { decoder.decode(e, e.getData()); }
            catch (const Exception& ex) {
                // Close a connection that is sending us invalid data.
                QPID_LOG(error, *this << " aborting connection "
                         << e.getConnectionId() << ": " << ex.what());
                framing::AMQFrame abort((ClusterConnectionAbortBody()));
                deliverFrame(EventFrame(EventHeader(CONTROL, e.getConnectionId()), abort));
            }
        }
    }
}
Example #19
0
void EFXFixture_Test::serialNumber()
{
    EFX e(m_doc);
    EFXFixture ef(&e);

    ef.setSerialNumber(15);
    QVERIFY(ef.serialNumber() == 15);
}
Example #20
0
void EFXFixture_Test::isValid()
{
    EFX e(m_doc);
    EFXFixture ef(&e);

    QVERIFY(ef.isValid() == false);

    ef.setHead(GroupHead(0,0));
    QVERIFY(ef.isValid() == true);
}
Example #21
0
void EFXFixture_Test::isValid()
{
    EFX e(m_doc);
    EFXFixture ef(&e);

    QVERIFY(ef.isValid() == false);

    ef.setFixture(0);
    QVERIFY(ef.isValid() == true);
}
Example #22
0
bool HwndSourceHookMenuPopup::HandleMouseMove(suic::MessageParameter& mp)
{
    bool handled = false;
    MenuPtr hotMenu = HitTestPopup();

    if (IsMouseCapture())
    {
        handled = true;

        if (!hotMenu)
        {
            if (_focusMenu)
            {
                suic::MouseEventArg ef(NULL, mp.point);
                _focusMenu->OnMouseLeave(ef);
            }

            _focusMenu = hotMenu;
        }
        else
        {
            suic::MouseEventArg e(hotMenu.get(), suic::SystemHelper::GetCursorPoint(hotMenu.get()));

            if (_focusMenu && _focusMenu != hotMenu)
            {
                suic::MouseEventArg ef(hotMenu.get(), mp.point);

                _focusMenu->OnMouseLeave(ef);
            }

            hotMenu->OnMouseMove(e);
            _focusMenu = hotMenu;
        }
    }
    else if (!hotMenu)
    {
        handled = true;
        suic::HwndHelper::HandleDefWndMessage(mp);
    }

    return handled;
}
Example #23
0
int main()
{
	EField ef(1000);
	ef.addPointCharge(5,5,-1.0);
	ef.printPointCharges();
	ef.printEField();



	return 0;
}
Example #24
0
 EmpiricalFormula EmpiricalFormula::operator*(const SignedSize & times) const
 {
   EmpiricalFormula ef(*this);
   Map<const Element *, SignedSize>::ConstIterator it = formula_.begin();
   for (; it != formula_.end(); ++it)
   {
     ef.formula_[it->first] *= times;
   }
   ef.charge_ *= times;
   ef.removeZeroedElements_();
   return ef;
 }
Example #25
0
void EFXFixture_Test::setPoint16bit()
{
    EFX e(m_doc);
    EFXFixture ef(&e);
    ef.setFixture(0);

    UniverseArray array(512 * 4);
    ef.setPoint(&array, 5.4, 1.5); // PMSB: 5, PLSB: 0.4, TMSB: 1 (102), TLSB: 0.5(127)
    QVERIFY(array.preGMValues()[0] == (char) 5);
    QVERIFY(array.preGMValues()[1] == (char) 1);
    QVERIFY(array.preGMValues()[2] == (char) 102); /* 255 * 0.4 */
    QVERIFY(array.preGMValues()[3] == (char) 127); /* 255 * 0.5 */
}
Example #26
0
void EFXFixture_Test::startOffset()
{
    EFX e(m_doc);
    EFXFixture ef(&e);
    ef.setHead(GroupHead(0,0));

    QCOMPARE(0, ef.startOffset());
    for(int i = 0; i < 360; i += 90)
    {
        ef.setStartOffset(i);
        QCOMPARE(i, ef.startOffset());
    }
}
Example #27
0
void EFXFixture_Test::setPointLedBar()
{
    EFX e(m_doc);
    EFXFixture ef(&e);
    ef.setHead(GroupHead(m_fixtureLedBar, 0));

    QList<Universe*> ua;
    ua.append(new Universe(0, new GrandMaster()));
    ef.setPoint(ua, 5.4, 1.5); // PMSB: 5, PLSB: 0.4, TMSB: 1 (102), TLSB: 0.5(127)
    QCOMPARE((int)ua[0]->preGMValues()[0], 1); /* Tilt */
    QCOMPARE((int)ua[0]->preGMValues()[1], 0);
    QCOMPARE((int)ua[0]->preGMValues()[2], 0);
    QCOMPARE((int)ua[0]->preGMValues()[3], 0);
}
Example #28
0
bool OdeErrMaxabs(void)
{   bool ok = true;     // initial return value

    CppAD::vector<double> w(2);
    w[0] = 10.;
    w[1] = 1.;
    Method method(w);

    CppAD::vector<double> xi(2);
    xi[0] = 1.;
    xi[1] = 0.;

    CppAD::vector<double> eabs(2);
    eabs[0] = 0.;
    eabs[1] = 0.;

    CppAD::vector<double> ef(2);
    CppAD::vector<double> xf(2);
    CppAD::vector<double> maxabs(2);

    double ti   = 0.;
    double tf   = 1.;
    double smin = .5;
    double smax = 1.;
    double scur = .5;
    double erel = 1e-4;

    bool accurate = false;
    while( ! accurate )
    {   xf = OdeErrControl(method,
                           ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs);
        accurate = true;
        size_t i;
        for(i = 0; i < 2; i++)
            accurate &= ef[i] <= erel * maxabs[i];
        if( ! accurate )
            smin = smin / 2;
    }

    double x0 = exp(-w[0]*tf);
    ok &= CppAD::NearEqual(x0, xf[0], erel, 0.);
    ok &= CppAD::NearEqual(0., ef[0], erel, erel);

    double x1 = w[0] * (exp(-w[0]*tf) - exp(-w[1]*tf))/(w[1] - w[0]);
    ok &= CppAD::NearEqual(x1, xf[1], erel, 0.);
    ok &= CppAD::NearEqual(0., ef[1], erel, erel);

    return ok;
}
Example #29
0
void EFXFixture_Test::isValid()
{
    EFX e(m_doc);
    EFXFixture ef(&e);

    QVERIFY(ef.isValid() == false);

    ef.m_msbPanChannel = 5;
    QVERIFY(ef.isValid() == false);

    ef.m_msbTiltChannel = 9;
    QVERIFY(ef.isValid() == false);

    ef.m_fixture = 72;
    QVERIFY(ef.isValid() == true);
}
Example #30
0
void EFXFixture_Test::setPoint8bit()
{
    EFX e(m_doc);
    EFXFixture ef(&e);

    ef.m_msbPanChannel = 0;
    ef.m_msbTiltChannel = 1;

    ef.m_panValue = 5.4;
    ef.m_tiltValue = 1.5;

    QByteArray array;
    ef.setPoint(&array);
    QVERIFY(array[0] == (char) 5);
    QVERIFY(array[1] == (char) 1);
}