Ejemplo n.º 1
0
//----------------------------------------------------------------------------------------------------------------------
// MAKE WIN
//----------------------------------------------------------------------------------------------------------------------
INT_PTR cDlgModal :: make_dlg ( void * pUserDataArg )
{
	this->pUserData = pUserDataArg;
	cWin * pWin = static_cast<cWin *>(this);
	INT_PTR Result = DialogBoxParam ( g_hInstance, MAKEINTRESOURCE (idd()), g_hwnd, dialog_proc(), (LPARAM) pWin );
	return Result;
}
Ejemplo n.º 2
0
//----------------------------------------------------------------------------------------------------------------------
// MAKE DIALOG
//----------------------------------------------------------------------------------------------------------------------
HWND cDlg :: make_dlg ( void * pUserDataArg )
{
	this->pUserData = pUserDataArg;
	cWin * pWin = static_cast<cWin *>(this);
	hwnd = CreateDialogParam ( g_hInstance, MAKEINTRESOURCE ( idd() ), g_hwnd, dialog_proc(), (LPARAM) pWin );
	return hwnd;
}
Ejemplo n.º 3
0
int
main(int argc, char *argv[])
{
	static const int ex_under = FE_UNDERFLOW | FE_INEXACT;	/* shorthand */
	static const int ex_over = FE_OVERFLOW | FE_INEXACT;
	long double ldbl_small, ldbl_eps, ldbl_max;

	printf("1..5\n");

#ifdef	__i386__
	fpsetprec(FP_PE);
#endif
	/*
	 * We can't use a compile-time constant here because gcc on
	 * FreeBSD/i386 assumes long doubles are truncated to the
	 * double format.
	 */
	ldbl_small = ldexpl(1.0, LDBL_MIN_EXP - LDBL_MANT_DIG);
	ldbl_eps = LDBL_EPSILON;
	ldbl_max = ldexpl(1.0 - ldbl_eps / 2, LDBL_MAX_EXP);

	/*
	 * Special cases involving zeroes.
	 */
#define	ztest(prec)							      \
	test##prec(copysign##prec(1.0, nextafter##prec(0.0, -0.0)), -1.0, 0); \
	test##prec(copysign##prec(1.0, nextafter##prec(-0.0, 0.0)), 1.0, 0);  \
	test##prec(copysign##prec(1.0, nexttoward##prec(0.0, -0.0)), -1.0, 0);\
	test##prec(copysign##prec(1.0, nexttoward##prec(-0.0, 0.0)), 1.0, 0)

	ztest();
	ztest(f);
	ztest(l);
#undef	ztest

#define	stest(next, eps, prec)					\
	test##prec(next(-0.0, 42.0), eps, ex_under);		\
	test##prec(next(0.0, -42.0), -eps, ex_under);		\
	test##prec(next(0.0, INFINITY), eps, ex_under);		\
	test##prec(next(-0.0, -INFINITY), -eps, ex_under)

	stest(nextafter, 0x1p-1074, );
	stest(nextafterf, 0x1p-149f, f);
	stest(nextafterl, ldbl_small, l);
	stest(nexttoward, 0x1p-1074, );
	stest(nexttowardf, 0x1p-149f, f);
	stest(nexttowardl, ldbl_small, l);
#undef	stest

	printf("ok 1 - next\n");

	/*
	 * `x == y' and NaN tests
	 */
	testall(42.0, 42.0, 42.0, 0);
	testall(-42.0, -42.0, -42.0, 0);
	testall(INFINITY, INFINITY, INFINITY, 0);
	testall(-INFINITY, -INFINITY, -INFINITY, 0);
	testall(NAN, 42.0, NAN, 0);
	testall(42.0, NAN, NAN, 0);
	testall(NAN, NAN, NAN, 0);

	printf("ok 2 - next\n");

	/*
	 * Tests where x is an ordinary normalized number
	 */
	testboth(1.0, 2.0, 1.0 + DBL_EPSILON, 0, );
	testboth(1.0, -INFINITY, 1.0 - DBL_EPSILON/2, 0, );
	testboth(1.0, 2.0, 1.0 + FLT_EPSILON, 0, f);
	testboth(1.0, -INFINITY, 1.0 - FLT_EPSILON/2, 0, f);
	testboth(1.0, 2.0, 1.0 + ldbl_eps, 0, l);
	testboth(1.0, -INFINITY, 1.0 - ldbl_eps/2, 0, l);

	testboth(-1.0, 2.0, -1.0 + DBL_EPSILON/2, 0, );
	testboth(-1.0, -INFINITY, -1.0 - DBL_EPSILON, 0, );
	testboth(-1.0, 2.0, -1.0 + FLT_EPSILON/2, 0, f);
	testboth(-1.0, -INFINITY, -1.0 - FLT_EPSILON, 0, f);
	testboth(-1.0, 2.0, -1.0 + ldbl_eps/2, 0, l);
	testboth(-1.0, -INFINITY, -1.0 - ldbl_eps, 0, l);

	/* Cases where nextafter(...) != nexttoward(...) */
	test(nexttoward(1.0, 1.0 + ldbl_eps), 1.0 + DBL_EPSILON, 0);
	testf(nexttowardf(1.0, 1.0 + ldbl_eps), 1.0 + FLT_EPSILON, 0);
	testl(nexttowardl(1.0, 1.0 + ldbl_eps), 1.0 + ldbl_eps, 0);

	printf("ok 3 - next\n");

	/*
	 * Tests at word boundaries, normalization boundaries, etc.
	 */
	testboth(0x1.87654ffffffffp+0, INFINITY, 0x1.87655p+0, 0, );
	testboth(0x1.87655p+0, -INFINITY, 0x1.87654ffffffffp+0, 0, );
	testboth(0x1.fffffffffffffp+0, INFINITY, 0x1p1, 0, );
	testboth(0x1p1, -INFINITY, 0x1.fffffffffffffp+0, 0, );
	testboth(0x0.fffffffffffffp-1022, INFINITY, 0x1p-1022, 0, );
	testboth(0x1p-1022, -INFINITY, 0x0.fffffffffffffp-1022, ex_under, );

	testboth(0x1.fffffep0f, INFINITY, 0x1p1, 0, f);
	testboth(0x1p1, -INFINITY, 0x1.fffffep0f, 0, f);
	testboth(0x0.fffffep-126f, INFINITY, 0x1p-126f, 0, f);
	testboth(0x1p-126f, -INFINITY, 0x0.fffffep-126f, ex_under, f);

#if LDBL_MANT_DIG == 53
	testboth(0x1.87654ffffffffp+0L, INFINITY, 0x1.87655p+0L, 0, l);
	testboth(0x1.87655p+0L, -INFINITY, 0x1.87654ffffffffp+0L, 0, l);
	testboth(0x1.fffffffffffffp+0L, INFINITY, 0x1p1L, 0, l);
	testboth(0x1p1L, -INFINITY, 0x1.fffffffffffffp+0L, 0, l);
	testboth(0x0.fffffffffffffp-1022L, INFINITY, 0x1p-1022L, 0, l);
	testboth(0x1p-1022L, -INFINITY, 0x0.fffffffffffffp-1022L, ex_under, l);
#elif LDBL_MANT_DIG == 64 && !defined(__i386)
	testboth(0x1.87654321fffffffep+0L, INFINITY, 0x1.87654322p+0L, 0, l);
	testboth(0x1.87654322p+0L, -INFINITY, 0x1.87654321fffffffep+0L, 0, l);
	testboth(0x1.fffffffffffffffep0L, INFINITY, 0x1p1L, 0, l);
	testboth(0x1p1L, -INFINITY, 0x1.fffffffffffffffep0L, 0, l);
	testboth(0x0.fffffffffffffffep-16382L, INFINITY, 0x1p-16382L, 0, l);
	testboth(0x1p-16382L, -INFINITY,
	    0x0.fffffffffffffffep-16382L, ex_under, l);
#elif LDBL_MANT_DIG == 113
	testboth(0x1.876543210987ffffffffffffffffp+0L, INFINITY,
	    0x1.876543210988p+0, 0, l);
	testboth(0x1.876543210988p+0L, -INFINITY,
	    0x1.876543210987ffffffffffffffffp+0L, 0, l);
	testboth(0x1.ffffffffffffffffffffffffffffp0L, INFINITY, 0x1p1L, 0, l);
	testboth(0x1p1L, -INFINITY, 0x1.ffffffffffffffffffffffffffffp0L, 0, l);
	testboth(0x0.ffffffffffffffffffffffffffffp-16382L, INFINITY,
	    0x1p-16382L, 0, l);
	testboth(0x1p-16382L, -INFINITY,
	    0x0.ffffffffffffffffffffffffffffp-16382L, ex_under, l);
#endif

	printf("ok 4 - next\n");

	/*
	 * Overflow tests
	 */
	test(idd(nextafter(DBL_MAX, INFINITY)), INFINITY, ex_over);
	test(idd(nextafter(INFINITY, 0.0)), DBL_MAX, 0);
	test(idd(nexttoward(DBL_MAX, DBL_MAX * 2.0L)), INFINITY, ex_over);
#if LDBL_MANT_DIG > 53
	test(idd(nexttoward(INFINITY, DBL_MAX * 2.0L)), DBL_MAX, 0);
#endif

	testf(idf(nextafterf(FLT_MAX, INFINITY)), INFINITY, ex_over);
	testf(idf(nextafterf(INFINITY, 0.0)), FLT_MAX, 0);
	testf(idf(nexttowardf(FLT_MAX, FLT_MAX * 2.0)), INFINITY, ex_over);
	testf(idf(nexttowardf(INFINITY, FLT_MAX * 2.0)), FLT_MAX, 0);

	testboth(ldbl_max, INFINITY, INFINITY, ex_over, l);
	testboth(INFINITY, 0.0, ldbl_max, 0, l);

	printf("ok 5 - next\n");

	return (0);
}
Ejemplo n.º 4
0
void RepeatWorkerFactory::init() {
    QList<PortDescriptor*> p; QList<Attribute*> a;

    {
        Descriptor id(BasePorts::IN_SEQ_PORT_ID(), RepeatWorker::tr("Input sequences"),
                        RepeatWorker::tr("A nucleotide sequence to search repeats in."));
        Descriptor od(BasePorts::OUT_ANNOTATIONS_PORT_ID(), RepeatWorker::tr("Repeat annotations"),
                        RepeatWorker::tr("A set of annotations marking repeats found in the sequence."));
        QMap<Descriptor, DataTypePtr> inM;
        inM[BaseSlots::DNA_SEQUENCE_SLOT()] = BaseTypes::DNA_SEQUENCE_TYPE();
        p << new PortDescriptor(id, DataTypePtr(new MapDataType("repeat.seq", inM)), true /*input*/);
        QMap<Descriptor, DataTypePtr> outM;
        outM[BaseSlots::ANNOTATION_TABLE_SLOT()] = BaseTypes::ANNOTATION_TABLE_TYPE();
        p << new PortDescriptor(od, DataTypePtr(new MapDataType("repeat.annotations", outM)), false /*input*/, true /*multi*/);
    }
    {
        Descriptor nd(NAME_ATTR, RepeatWorker::tr("Annotate as"), RepeatWorker::tr("Name of the result annotations marking found repeats."));
        Descriptor idd(IDENTITY_ATTR, RepeatWorker::tr("Identity"), RepeatWorker::tr("Repeats identity."));
        Descriptor ld(LEN_ATTR, RepeatWorker::tr("Min length"), RepeatWorker::tr("Minimum length of repeats."));
        Descriptor mid(MIN_DIST_ATTR, RepeatWorker::tr("Min distance"), RepeatWorker::tr("Minimum distance between repeats."));
        Descriptor mad(MAX_DIST_ATTR, RepeatWorker::tr("Max distance"), RepeatWorker::tr("Maximum distance between repeats."));
        Descriptor ind(INVERT_ATTR, RepeatWorker::tr("Inverted"), RepeatWorker::tr("Search for inverted repeats."));
        Descriptor nsd(NESTED_ATTR, RepeatWorker::tr("Filter algorithm"), RepeatWorker::tr("Filter repeats algorithm."));
        Descriptor ald(ALGO_ATTR, RepeatWorker::tr("Algorithm"), RepeatWorker::tr("Control over variations of algorithm."));
        Descriptor thd(THREADS_ATTR, RepeatWorker::tr("Parallel threads"), RepeatWorker::tr("Number of parallel threads used for the task."));
        Descriptor tan(TANMEDS_ATTR, RepeatWorker::tr("Exclude tandems"), RepeatWorker::tr("Exclude tandems areas before find repeat task is run."));
        Descriptor umaxd(USE_MAX_DISTANCE_ATTR, RepeatWorker::tr("Apply 'Max distance' attribute"), RepeatWorker::tr("Apply 'Max distance' attribute."));
        Descriptor umind(USE_MIN_DISTANCE_ATTR, RepeatWorker::tr("Apply 'Min distance' attribute"), RepeatWorker::tr("Apply 'Max distance' attribute."));

        FindRepeatsTaskSettings cfg = FindRepeatsDialog::defaultSettings();
        Attribute *aa;
        a << new Attribute(nd, BaseTypes::STRING_TYPE(), true, "repeat_unit");
        aa = new Attribute(ld, BaseTypes::NUM_TYPE(), false);
        aa->setAttributeValue(cfg.minLen);
        a << aa;
        aa = new Attribute(idd, BaseTypes::NUM_TYPE(), false);
        aa->setAttributeValue(cfg.getIdentity());
        a << aa;
        a << new Attribute(umind, BaseTypes::BOOL_TYPE(), false, true);
        aa = new Attribute(mid, BaseTypes::NUM_TYPE(), false);
        aa->setAttributeValue(cfg.minDist);
        aa->addRelation(new VisibilityRelation(USE_MIN_DISTANCE_ATTR, true));
        a << aa;
        a << new Attribute(umaxd, BaseTypes::BOOL_TYPE(), false, true);
        aa = new Attribute(mad, BaseTypes::NUM_TYPE(), false);
        aa->setAttributeValue(cfg.maxDist);
        aa->addRelation(new VisibilityRelation(USE_MAX_DISTANCE_ATTR, true));
        a << aa;
        aa = new Attribute(ind, BaseTypes::BOOL_TYPE(), false);
        aa->setAttributeValue(cfg.inverted);
        a << aa;
        aa = new Attribute(nsd, BaseTypes::NUM_TYPE(), false);
        aa->setAttributeValue(cfg.filter);
        a << aa;
        aa = new Attribute(ald, BaseTypes::NUM_TYPE(), false);
        aa->setAttributeValue(cfg.algo);
        a << aa;
        aa = new Attribute(thd, BaseTypes::NUM_TYPE(), false);
        aa->setAttributeValue(cfg.nThreads);
        a << aa;
        aa = new Attribute(tan, BaseTypes::BOOL_TYPE(), false);
        aa->setAttributeValue(cfg.excludeTandems);
        a << aa;
    }

    Descriptor desc(ACTOR_ID, RepeatWorker::tr("Find Repeats"),
        RepeatWorker::tr("Finds repeats in each supplied sequence, stores found regions as annotations.")
       );
    ActorPrototype* proto = new IntegralBusActorPrototype(desc, p, a);
    QMap<QString, PropertyDelegate*> delegates;
    delegates[USE_MIN_DISTANCE_ATTR] = new ComboBoxWithBoolsDelegate();
    delegates[USE_MAX_DISTANCE_ATTR] = new ComboBoxWithBoolsDelegate();
    {
        QVariantMap m; m["minimum"] = 0; m["maximum"] = INT_MAX; m["suffix"] = L10N::suffixBp();
        delegates[MIN_DIST_ATTR] = new SpinBoxDelegate(m);
        m["specialValueText"] = RepeatWorker::tr("Any");
        delegates[MAX_DIST_ATTR] = new SpinBoxDelegate(m);
        m["minimum"] = 2;
        delegates[LEN_ATTR] = new SpinBoxDelegate(m);
    }
    {
        QVariantMap m; m["minimum"] = 50; m["maximum"] = 100; m["suffix"] = "%";
        delegates[IDENTITY_ATTR] = new SpinBoxDelegate(m);
    }
    {
        QVariantMap m; m["specialValueText"] = "Auto";
        delegates[THREADS_ATTR] = new SpinBoxDelegate(m);
    }
    {
        QVariantMap m;
        m["Auto"] = RFAlgorithm_Auto;
        m["Diagonals"] = RFAlgorithm_Diagonal;
        m["Suffix index"] = RFAlgorithm_Suffix;
        delegates[ALGO_ATTR] = new ComboBoxDelegate(m);
    }
    {
        QVariantMap m;
        m["Disjoint repeats"] = DisjointRepeats;
        m["No filtering"] = NoFiltering;
        m["Unique repeats"] = UniqueRepeats;
        delegates[NESTED_ATTR] = new ComboBoxDelegate(m);
    }

    proto->setPrompter(new RepeatPrompter());
    proto->setEditor(new DelegateEditor(delegates));
    proto->setIconPath(":repeat_finder/images/repeats.png");
    WorkflowEnv::getProtoRegistry()->registerProto(BaseActorCategories::CATEGORY_BASIC(), proto);

    DomainFactory* localDomain = WorkflowEnv::getDomainRegistry()->getById(LocalDomainFactory::ID);
    localDomain->registerEntry(new RepeatWorkerFactory());
}
Ejemplo n.º 5
0
void Sp_based::shortest_path()
{
    graph::node_iterator sit, send;
//double nrn = g.number_of_nodes();
//cout << setfill(' ') << right;
    send = g.nodes_end();
    int i=0;
    for (sit = g.nodes_begin(); sit != send; ++sit) {
        i++;
        node s = *sit;
//        cout << "\rsp on " << setw(8) << i << "/" << nrn <<flush;
        queue < node > Q;
        Q.push(s);              /* Dijkstra SP */
        node_map < unsigned int >d(g, 0xffffffff);
        d[s] = 0;
        stack < node > S;       /* betweenness */
        node_map < list < edge > >P(g); /* betweenness */
        node_map < int >N(g, 0);  /* betweenness */
        N[s] = 1;  
        while (Q.empty() == false) {
            node v = Q.front();
            Q.pop();
            S.push(v);          /* betweenness */
            node::adj_edges_iterator eit, eend;
            eend = v.adj_edges_end();
            for (eit = v.adj_edges_begin(); eit != eend; ++eit) {
                node w = eit->target();
                if (w == v) 
                    w = eit->source();
                if (d[w] == 0xffffffff) {
                    Q.push(w);
                    d[w] = d[v] + 1;
                }
                if (d[w] == d[v] + 1) {
                    N[w] += N[v];
                    P[w].push_back(*eit);
                }
            }
        }
	maxd[s]=maxd[s]>d[S.top()]?maxd[s]:d[S.top()];
        nm_t D(g, 0);
	vector<int> idd((int)maxd[s]+1,0);
        while (S.empty() == false) {
            node w = S.top();
            S.pop();
	    // for shrink
	    if(w==s) continue;
            unsigned int l = d[w];
            avgd[s] += l*(1+n_stub[w])+dd[w];
	    if (maxd[s] < (l+d_stub[w].size()-1)) {
                maxd[s] = l+d_stub[w].size()-1;
	        idd.resize((int)maxd[s]+1,0);
	    }
	    for (unsigned int i=1; i<d_stub[w].size(); ++i) {
                if (inQ[s]) idd[l+i]+=d_stub[w][i];
                pairs[l+i]+=d_stub[w][i];
	    }

	    if (inQ[s]) idd[l]++;    
            pairs[l]++;
	    // for shrink
            list < edge >::iterator eit, eend;
            eend = P[w].end();
            for (eit = P[w].begin(); eit != eend; ++eit) {
                node v = eit->source();
                if (w==v) v = eit->target();
                double t = ((double)N[v]/(double)N[w])*(1+D[w]+n_stub[w]);
                ebet[*eit] += t*(n_stub[s]+1);
		if (s!=v) D[v] += t;
            }
            nbet[w] += D[w]*(n_stub[s]+1);
        }
        if (!inQ[s]) continue;
        tree(s);
	for (unsigned int i=1; i<d_stub[s].size(); ++i) {
	    for (unsigned int j=1; j<idd.size(); ++j) {
	        if(idd[j]==0) continue;
			pairs[i+j]+=idd[j]*d_stub[s][i];
	    }
	}
    }
//    cout << endl;
    g.restore_graph();
    for (sit = g.nodes_begin(); sit != send; ++sit) {
        avgd[*sit]/=(coms[*sit]-1);
    }
}