Exemplo n.º 1
0
int main(void)
{
	#pragma STDC FENV_ACCESS ON
	float ysin, ycos;
	float dsin, dcos;
	int e, i, err = 0;
	struct f_ff *p;

	for (i = 0; i < sizeof t/sizeof *t; i++) {
		p = t + i;

		if (p->r < 0)
			continue;
		fesetround(p->r);
		feclearexcept(FE_ALL_EXCEPT);
		sincosf(p->x, &ysin, &ycos);
		e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);

		if (!checkexcept(e, p->e, p->r)) {
			printf("%s:%d: bad fp exception: %s sincosf(%a)=%a,%a, want %s",
				p->file, p->line, rstr(p->r), p->x, p->y, p->y2, estr(p->e));
			printf(" got %s\n", estr(e));
			err++;
		}
		dsin = ulperr(ysin, p->y, p->dy);
		dcos = ulperr(ycos, p->y2, p->dy2);
		if (!checkulp(dsin, p->r) || !checkulp(dcos, p->r)) {
			printf("%s:%d: %s sincosf(%a) want %a,%a got %a,%a, ulperr %.3f = %a + %a, %.3f = %a + %a\n",
				p->file, p->line, rstr(p->r), p->x, p->y, p->y2, ysin, ycos,
				dsin, dsin-p->dy, p->dy, dcos, dcos-p->dy2, p->dy2);
			err++;
		}
	}
	return !!err;
}
Exemplo n.º 2
0
int main(void)
{
	#pragma STDC FENV_ACCESS ON
	int yi;
	long double y;
	float d;
	int e, i, err = 0;
	struct l_li *p;

	for (i = 0; i < sizeof t/sizeof *t; i++) {
		p = t + i;

		if (p->r < 0)
			continue;
		fesetround(p->r);
		feclearexcept(FE_ALL_EXCEPT);
		y = lgammal_r(p->x, &yi);
		e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);

		if (!checkexcept(e, p->e, p->r)) {
			printf("%s:%d: bad fp exception: %s lgammal_r(%La)=%La,%lld, want %s",
				p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e));
			printf(" got %s\n", estr(e));
			err++;
		}
		d = ulperrl(y, p->y, p->dy);
		// TODO: 2 ulp errors allowed
		if ((p->r==RN && fabs(d)>2) || (!isnan(p->x) && p->x!=-inf && !(p->e&DIVBYZERO) && yi != p->i)) {
			printf("%s:%d: %s lgammal_r(%La) want %La,%lld got %La,%d ulperr %.3f = %a + %a\n",
				p->file, p->line, rstr(p->r), p->x, p->y, p->i, y, yi, d, d-p->dy, p->dy);
			err++;
		}
	}
	return !!err;
}
Exemplo n.º 3
0
int main(void)
{
	#pragma STDC FENV_ACCESS ON
	int yi;
	double y;
	float d;
	int e, i, err = 0;
	struct d_di *p;

	for (i = 0; i < sizeof t/sizeof *t; i++) {
		p = t + i;

		if (p->r < 0)
			continue;
		fesetround(p->r);
		feclearexcept(FE_ALL_EXCEPT);
		y = frexp(p->x, &yi);
		e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);

		if (!checkexceptall(e, p->e, p->r)) {
			printf("%s:%d: bad fp exception: %s frexp(%a)=%a,%lld, want %s",
				p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e));
			printf(" got %s\n", estr(e));
			err++;
		}
		d = ulperr(y, p->y, p->dy);
		if (!checkcr(y, p->y, p->r) || (isfinite(p->x) && yi != p->i)) {
			printf("%s:%d: %s frexp(%a) want %a,%lld got %a,%d ulperr %.3f = %a + %a\n",
				p->file, p->line, rstr(p->r), p->x, p->y, p->i, y, yi, d, d-p->dy, p->dy);
			err++;
		}
	}
	return !!err;
}
Exemplo n.º 4
0
int main(void)
{
#pragma STDC FENV_ACCESS ON
    long long yi;
    int e, i, err = 0;
    struct f_i *p;

    for (i = 0; i < sizeof t/sizeof *t; i++) {
        p = t + i;

        if (p->r < 0)
            continue;
        fesetround(p->r);
        feclearexcept(FE_ALL_EXCEPT);
        yi = ___(p->x);
        e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);

        if (!checkexcept(e, p->e, p->r)) {
            printf("%s:%d: bad fp exception: %s ___(%a)=%lld, want %s",
                   p->file, p->line, rstr(p->r), p->x, p->i, estr(p->e));
            printf(" got %s\n", estr(e));
            err++;
        }
        if (yi != p->i) {
            printf("%s:%d: %s ___(%a) want %lld got %lld\n",
                   p->file, p->line, rstr(p->r), p->x, p->i, yi);
            err++;
        }
    }
    return !!err;
}
Exemplo n.º 5
0
int main(void)
{
	#pragma STDC FENV_ACCESS ON
	long double y;
	float d;
	int e, i, err = 0;
	struct l_l *p;

	for (i = 0; i < sizeof t/sizeof *t; i++) {
		p = t + i;

		if (p->r < 0)
			continue;
		fesetround(p->r);
		feclearexcept(FE_ALL_EXCEPT);
		y = erfl(p->x);
		e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);

		if (!checkexcept(e, p->e, p->r)) {
			printf("%s:%d: bad fp exception: %s erfl(%La)=%La, want %s",
				p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
			printf(" got %s\n", estr(e));
			err++;
		}
		d = ulperrl(y, p->y, p->dy);
		if (!checkulp(d, p->r)) {
			printf("%s:%d: %s erfl(%La) want %La got %La ulperr %.3f = %a + %a\n",
				p->file, p->line, rstr(p->r), p->x, p->y, y, d, d-p->dy, p->dy);
			err++;
		}
	}
	return !!err;
}
Exemplo n.º 6
0
int main(void)
{
	#pragma STDC FENV_ACCESS ON
	float y;
	float d;
	int e, i, err = 0;
	struct ff_f *p;

	for (i = 0; i < sizeof t/sizeof *t; i++) {
		p = t + i;

		if (p->r < 0)
			continue;
		fesetround(p->r);
		feclearexcept(FE_ALL_EXCEPT);
		y = fmaxf(p->x, p->x2);
		e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);

		if (!checkexceptall(e, p->e, p->r)) {
			printf("%s:%d: bad fp exception: %s fmaxf(%a,%a)=%a, want %s",
				p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e));
			printf(" got %s\n", estr(e));
			err++;
		}
		d = ulperrf(y, p->y, p->dy);
		if (!checkcr(y, p->y, p->r)) {
			printf("%s:%d: %s fmaxf(%a,%a) want %a got %a ulperr %.3f = %a + %a\n",
				p->file, p->line, rstr(p->r), p->x, p->x2, p->y, y, d, d-p->dy, p->dy);
			err++;
		}
	}
	return !!err;
}
Exemplo n.º 7
0
int CXslTransform::setXmlSource(const char *pszBuffer, unsigned int nSize)
{
    if(m_ParsedSource != NULL)
    {
        m_XalanTransformer.destroyParsedSource(m_ParsedSource);
        m_ParsedSource = NULL;
    }

    int theResult = 0;
    try
    {
        //std::istringstream theXMLStream(pszBuffer, nSize);
        std::istringstream theXMLStream(pszBuffer);
        const XSLTInputSource xmlinput(&theXMLStream);
        theResult = m_XalanTransformer.parseSource(xmlinput, (const XalanParsedSource*&)m_ParsedSource);
    }
    catch(...)
    {
        m_ParsedSource = NULL;
        StringBuffer estr("[Exception compiling xml]");
        estr.appendf("[%s]", m_XalanTransformer.getLastError());
        DBGLOG("%s", estr.str());
        throw MakeStringException(2, "%s", estr.str());
    }

    if (!m_ParsedSource)
    {
        StringBuffer estr("[failed to compile xml]");
        estr.appendf("[%s]", m_XalanTransformer.getLastError());
        DBGLOG("%s", estr.str());
        throw MakeStringException(2, "%s", estr.str());
    }

    return theResult;
}
Exemplo n.º 8
0
void eseqclusteravg::add(const eseqdistCount& sdist){
  if (sdist.count==0) return;
  ldieif(sdist.x<0 || sdist.y<0 || sdist.x>=scluster.size() || sdist.y>=scluster.size(),"out of bounds: sdist.x: "+estr(sdist.x)+" sdist.y: "+estr(sdist.y)+" scluster.size(): "+estr(scluster.size()));

  eseqdistCount tmpdist;
  tmpdist.x=scluster[sdist.x];
  tmpdist.y=scluster[sdist.y];
  tmpdist.dist=sdist.dist;
  tmpdist.count=sdist.count;

  ldieif(tmpdist.x<0 || tmpdist.y<0 || tmpdist.x>=scluster.size() || tmpdist.y>=scluster.size(),"out of bounds: sdist.x: "+estr(tmpdist.x)+" sdist.y: "+estr(tmpdist.y)+" scluster.size(): "+estr(scluster.size()));
  INDTYPE tmp;
  if (tmpdist.x>tmpdist.y) { tmp=tmpdist.x; tmpdist.x=tmpdist.y; tmpdist.y=tmp; }

  long links;
  long i;
//  estr xystr;

//  cout << x << " " << y << " " << sdist.dist << endl;
  ldieif(tmpdist.x==tmpdist.y,"should not happen: "+estr(tmpdist.x)+","+estr(tmpdist.y)+" --- "+estr(sdist.x)+","+estr(sdist.y));

//  xy2estr(x,y,xystr);

  eseqdistavghash::iter it;

  it=smatrix.get(tmpdist);
  if (it==smatrix.end()){
    if (scount[tmpdist.x]*scount[tmpdist.y]==sdist.count){
      merge(tmpdist);
      ofile.write(estr(scluster.size()-mergecount)+" "+tmpdist.dist+" "+tmpdist.x+" "+tmpdist.y+"\n");
      ofile.flush();
//      cout << scluster.size()-mergecount << " " << sdist.dist << " " << sdist.x << " " << sdist.y << endl;
    }else{
      smatrix.add(tmpdist,tmpdist);
      inter[tmpdist.x].push_back(tmpdist.y); inter[tmpdist.y].push_back(tmpdist.x);
    }
    return;
  }

  it->dist=(it->dist*it->count+tmpdist.dist*tmpdist.count)/(it->count+tmpdist.count);
  it->count+=tmpdist.count;
//  ++(*it);

  // complete linkage
  if (it->count==scount[tmpdist.x]*scount[tmpdist.y]){
    merge(tmpdist);
//    update(ind-1,x,y);
    ofile.write(estr(scluster.size()-mergecount)+" "+tmpdist.dist+" "+tmpdist.x+" "+tmpdist.y+"\n");
    ofile.flush();
//    cout << scluster.size()-mergecount << " " << tmpdist.dist << " " << tmpdist.x << " " << tmpdist.y << endl;
//    sleep(1);
//    cout << sdist.dist << " " << x << " " << y << endl;
    smatrix.erase(it);
  }
}
Exemplo n.º 9
0
etype etype::operator/(const etype &var)
{
  switch(type){
    case ET_INT: return(etype( *(int*)value / var.i() ));
    case ET_FLOAT: return(etype( *(float*)value / var.f() ));
    case ET_DOUBLE: return(etype( *(double*)value / var.d() ));
    case ET_CHAR: return(etype( *(char*)value / var.c() ));
    case ET_ESTR: lwarn("division not defined for string type"); return(estr());
    case ET_EARRAY: lwarn("division not defined for array type"); return(estrarray());
  }
  lwarn("undefined value");
  return(estr());
}
Exemplo n.º 10
0
estr etype::s() const
{
  switch(type){
    case ET_INT:    return(estr(*(int*)value));
    case ET_FLOAT:  return(estr(*(float*)value));
    case ET_DOUBLE: return(estr(*(double*)value));
    case ET_CHAR:   return(estr(*(char*)value));
    case ET_ESTR:   return(*(estr*)value);
    case ET_EARRAY:  return( (*(estrarray*)value)[0].s() );
  }

  lwarn("undefined value");
  return(0x00);
}
Exemplo n.º 11
0
void eseqclusteravg::check(ebasicarray<eseqdistCount>& dists)
{
  long i;
  estr xystr;
  bool duplicate=false;
  eseqdisthash checkmatrix;
  for (i=0; i<dists.size(); ++i){
    if (i%(dists.size()/10)==0) { cout << i*10/dists.size(); flush(cout); }
//    xy2estr(dists[i].x,dists[i].y,xystr);

    eseqdisthash::iter it;

//    cout << dists[i].dist << " " << dists[i].x << " " << dists[i].y;
    it=checkmatrix.get(dists[i]);
    if (it != checkmatrix.end()) {
      cout << "duplicate found: "+estr(dists[i].x)+","+dists[i].y << endl;
//      cout << " *";
      duplicate=true;
    }else
      checkmatrix.add(dists[i],1);
//    cout << endl;
  }
  smatrix.clear();

  ldieif(duplicate,"duplicates found");
  cout << "# no duplicates found!" << endl;
}
Exemplo n.º 12
0
void eseqclustersingle::init(INDTYPE count,const estr& ofilename,const estr& seqsfile,const earray<ebasicarray<INDTYPE> >& dupslist) {
  ofile.open(ofilename,"w");
  ofile.write("# seqsfile: "+seqsfile+"\n");
  ofile.write("# OTU_count Merge_distance Merged_OTU_id1 Merged_OTU_id2\n");
  long i,j;
  mergecount=0;
  scount.reserve(count);
  scluster.reserve(count);
  smerge.reserve(count);
  incluster.reserve(count);
  for (i=0; i<count; ++i){
    scount.add(1);
    scluster.add(i);
    smerge.add(-1);
    incluster.add(list<INDTYPE>());
    incluster[i].push_back(i);
  }
  for (i=0; i<dupslist.size(); ++i){
    for (j=1; j<dupslist[i].size(); ++j){
      ++mergecount;
      ofile.write(estr(scluster.size()-mergecount)+" 1.0 "+dupslist[i][0]+" "+dupslist[i][j]+"\n");
      clusterData.mergearr.add(eseqdist(dupslist[i][0],dupslist[i][j],1.0));
    }
  }
  cout << "# initializing cluster with: "<< count<< " seqs" << endl; 
}
Exemplo n.º 13
0
void actionMakeOtusMothur()
{
  estrarray uarr;
  eseqclusterData cdata;
  ldieif(argvc<4,"syntax: "+efile(argv[0]).basename()+" -makeotus_mothur <alignment> <mergelog> <cutoff>");

  cout << "# loading seqs file: " << argv[1] << endl;
  load_seqs(argv[1],uarr);
  cdata.load(argv[2],uarr.size());

  float t=estr(argv[3]).f();
  earray<eintarray> otuarr;
  cdata.getOTU(t,otuarr,uarr.size());

  cout << "label\tnumOtus";
  for (long i=0; i<otuarr.size(); ++i)
    cout << "\tOTU" << i;
  cout << endl;

  cout << (1.0-t) << "\t" << otuarr.size();
  for (long i=0; i<otuarr.size(); ++i){
//    cout << ">OTU" << i << " otu_size="<< otuarr[i].size() << endl;
    cout << "\t" << uarr.keys(otuarr[i][0]);
    for (long j=1; j<otuarr[i].size(); ++j)
      cout << "," << uarr.keys(otuarr[i][j]);
  }
  cout << endl;

  exit(0);
}
Exemplo n.º 14
0
estr args2str(int argvc,char **argv)
{
  estr tmpstr;
  int i;
  for (i=0; i<argvc; ++i)
    tmpstr+=estr(argv[i])+" ";
  tmpstr.del(-1);
  return(tmpstr);
}
Exemplo n.º 15
0
void actionMakePart()
{
  ldieif(argvc<3,"syntax: "+efile(argv[0]).basename()+" -makepart <alignment> <cutoff>");

  cout << "# loading seqs file: " << argv[1] << endl;
  load_seqs_compressed(argv[1],arr,seqlen);

  t=estr(argv[2]).f();

  ebasicarray<INDTYPE> uniqind;
  earray<ebasicarray<INDTYPE> > dupslist;
  finduniq(uniqind,dupslist);
  cout << "# unique seqs: " << uniqind.size() << endl;

  ebasicarray<INDTYPE> otuid;
  otuid.reserve(uniqind.size());
  for (long i=0l; i<uniqind.size(); ++i)
    otuid.add(i);

  cout << "# computing partitions. threshold: " << t << endl;
  if (partsTotal>(arr.size()-1l)*arr.size()/20l) partsTotal=(arr.size()-1l)*arr.size()/20l; // make fewer tasks if to few calculations per task
//  partsTotal=1;
  for (long i=0; i<partsTotal; ++i)
    taskman.addTask(dfuncpart.value().calcfunc,evararray(mutex,uniqind,arr,otuid,(const int&)seqlen,(const long int&)i,(const long int&)partsTotal,(const float&)t,(const int&)winlen));

  taskman.createThread(nthreads);
  taskman.wait();

  cout << endl;

  ebasicarray<INDTYPE> newotuid;
  earray<ebasicarray<INDTYPE> > otus;
  newotuid.init(otuid.size(),-1l);
  long otucount=0;
  for (long i=0; i<otuid.size(); ++i){
    if (newotuid[otuid[i]]==-1l){
      newotuid[otuid[i]]=otucount;
      otus.add(ebasicarray<INDTYPE>());
      ++otucount;
    }
    otuid[i]=newotuid[otuid[i]];
    otus[otuid[i]].add(i);
  }
  cout << "# partitions: " << otus.size() << endl;

  for (long i=0; i<otus.size(); ++i){
    cout << otus[i].size() << ":";
    for (long j=0; j<otus[i].size(); ++j){
//      cout << " " << uniqind[otus[i][j]];
      for (long k=0; k<dupslist[otus[i][j]].size(); ++k)
        cout << " " << dupslist[otus[i][j]][k];
    }
    cout << endl;
  }

  exit(0);
}
Exemplo n.º 16
0
 CommandOutput run(CommandInfo &info, const std::string & initialDirectory) {
     Poco::Pipe outPipe, errPipe;
     Poco::ProcessHandle ph =
         Poco::Process::launch(std::get<0>(info), std::get<1>(info), initialDirectory, 0, &outPipe, &errPipe);
     Poco::PipeInputStream ostr(outPipe);
     Poco::PipeInputStream estr(errPipe);
     auto errCode = Poco::Process::wait(ph);
     
     std::string outStr, errStr;
     Poco::StreamCopier::copyToString(ostr, outStr);
     Poco::StreamCopier::copyToString(estr, errStr);
     return std::make_tuple(outStr, errStr, errCode);
 }
Exemplo n.º 17
0
etype etype::operator+(const etype &var)
{
  switch(type){
    case ET_INT: return(etype( *(int*)value + var.i() ));
    case ET_FLOAT: return(etype( *(float*)value + var.f() ));
    case ET_DOUBLE: return(etype( *(double*)value + var.d() ));
    case ET_CHAR: return(etype( *(char*)value + var.c() ));
    case ET_ESTR: return(etype( *(estr*)value + var.s() ));
    case ET_EARRAY: return(etype( *(estrarray*)value + var ));
  }
  lwarn("undefined value");
  return(estr());
}
Exemplo n.º 18
0
emutex::emutex(int type)
{
 
  pthread_mutexattr_t attr;

  pthread_mutexattr_init(&attr);
  if (type!=EMUTEX_RECURSIVE)
    ldie("unknown type: "+estr(type));

  pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);

  pthread_mutex_init(&_mutex, &attr);
  pthread_mutexattr_destroy(&attr);
}
Exemplo n.º 19
0
void eseqclusteravg::save(const estr& filename,const estrarray& arr)
{
  long i;
  estr otustr;
  estrhashof<ebasicarray<INDTYPE> > otus;

  efile f(filename+".clstr");
  for (i=0; i<scluster.size(); ++i)
    f.write(estr(scluster[i])+"     "+arr.keys(i)+"\n");
  f.close();

  list<INDTYPE>::iterator it;
  INDTYPE otucount=0;
  efile f2(filename);
  for (i=0; i<incluster.size(); ++i){
    if (scount[i]==0) continue;
    f2.write(">OTU"+estr(otucount)+"\n");
    for (it=incluster[i].begin(); it!=incluster[i].end(); ++it)
      f2.write(arr.keys(*it)+"\n");
    ++otucount;
  }
  f2.close();
}
Exemplo n.º 20
0
int main(void)
{
	#pragma STDC FENV_ACCESS ON
	float y;
	float d;
	int e, i, err = 0;
	struct f_f *p;

	for (i = 0; i < sizeof t/sizeof *t; i++) {
		p = t + i;

		if (p->r < 0)
			continue;
		fesetround(p->r);
		feclearexcept(FE_ALL_EXCEPT);
		y = j0f(p->x);
		e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);

		if (!checkexcept(e, p->e, p->r)) {
			printf("%s:%d: bad fp exception: %s j0f(%a)=%a, want %s",
				p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
			printf(" got %s\n", estr(e));
			err++;
		}
		d = ulperrf(y, p->y, p->dy);
		if (!checkulp(d, p->r)) {
//			printf("%s:%d: %s j0f(%a) want %a got %a ulperr %.3f = %a + %a\n",
//				p->file, p->line, rstr(p->r), p->x, p->y, y, d, d-p->dy, p->dy);
			err++;
			// TODO: avoid spamming the output
			printf(__FILE__ ": known to be broken near zeros\n");
			break;
		}
	}
	return !!err;
}
Exemplo n.º 21
0
int aestr(char **outp, const char *src)
{
	char *buf;
	int len, serrno;

	buf = calloc(4, strlen(src) + 1);
	if (buf == NULL)
		return -1;
	len = estr(buf, src);
	serrno = errno;
	*outp = realloc(buf, len + 1);
	if (*outp == NULL) {
		*outp = buf;
		errno = serrno;
	}
	return (len);
}
Exemplo n.º 22
0
int CXslTransform::transform(StringBuffer &target)
{
    if(!m_ParsedSource)
        throw MakeStringException(1, "[XML source not set]");
    else if(!m_xslsource)
        throw MakeStringException(2, "[XSL stylesheet not set]");


    XalanCompiledStylesheet* pCompiledStylesheet = NULL;
    pCompiledStylesheet = m_xslsource->getStylesheet();

    if (!pCompiledStylesheet)
    {
        DBGLOG("[failed to compile XSLT stylesheet]");
        throw MakeStringException(2, "[failed to compile XSLT stylesheet]");
    }

    int rc=0;
    m_sMessages.clear();
    try
    {
        XalanStringBufferOutputHandler output(target);
        rc = m_XalanTransformer.transform(*m_ParsedSource, pCompiledStylesheet,
            (void*)&output, (XalanOutputHandlerType)output.callback, (XalanFlushHandlerType)0);
    }
    catch(...)
    {
        StringBuffer estr("[Exception running XSLT stylesheet]");
        estr.appendf("[%s]", m_XalanTransformer.getLastError());
        DBGLOG("%s", estr.str());
        throw MakeStringException(2, "%s", estr.str());
    }

    if (rc < 0)
    {
        StringBuffer estr;
        estr.appendf("[%s]", m_XalanTransformer.getLastError());
        DBGLOG("%s", estr.str());
        throw MakeStringException(2, "%s", estr.str());
    }

    return rc;
}
Exemplo n.º 23
0
int CXslTransform::transform(ISocket* targetSocket)
{
    if(!m_ParsedSource)
        throw MakeStringException(1, "[XML source not set for XSLT[");
    else if(!m_xslsource)
        throw MakeStringException(2, "[XSL stylesheet not set]");

    XalanCompiledStylesheet* pCompiledStylesheet = NULL;
    pCompiledStylesheet = m_xslsource->getStylesheet();

    if (!pCompiledStylesheet)
    {
        DBGLOG("[failed to compile XSLT stylesheet]");
        throw MakeStringException(2, "[failed to compile XSLT stylesheet]");
    }

    int rc=0;
    m_sMessages.clear();
    try
    {
        m_resultTarget = new XSLTResultTarget();
        Owned<ISocketOutputStream> stream = createSocketOutputStream(targetSocket);
        m_resultTarget->setCharacterStream(stream->getWriter());
        rc = m_XalanTransformer.transform(*m_ParsedSource, pCompiledStylesheet, *m_resultTarget);
    }
    catch(...)
    {
        StringBuffer estr("[Exception running XSLT stylesheet]");
        estr.appendf("[%s]", m_XalanTransformer.getLastError());
        DBGLOG("%s", estr.str());
        throw MakeStringException(2, "%s", estr.str());
    }
    if (rc < 0)
    {
        StringBuffer estr;
        estr.appendf("[%s]", m_XalanTransformer.getLastError());
        DBGLOG("%s", estr.str());
        throw MakeStringException(2, "%s", estr.str());
    }

    return rc;
}
Exemplo n.º 24
0
void eseqclusteravg::mergeComplete(float dist)
{
  multiset<eseqdistCount>::iterator it,it_next;
  eseqdistavghash::iter sit;
  for (it=completemerges.begin(); it!=completemerges.end() && incmaxit != smatrix.end() && it->dist>=incmaxdist || incmaxit==smatrix.end() && it->dist>=dist; it=completemerges.begin()){
    sit=smatrix.get(*it);
    if (sit==smatrix.end() || sit->dist!=it->dist || scount[sit->x]==0 || scount[sit->y]==0 || scount[sit->x]*scount[sit->y]!=sit->count) { completemerges.erase(it); continue; }
    if (sit->dist<thres) return; // do not merge past threshold (possible missing links)

    lassert(scluster[sit->x]!=sit->x || scluster[sit->y]!=sit->y);
    cout << "* " << scluster.size()-mergecount << " " << sit->dist << " ("<<sit->dist<<") " << sit->x << " " << scount[sit->x]<< " " << sit->y << " " << scount[sit->y] << " " << smatrix.size() << " " << completemerges.size() << " " << incmaxdist << " " << (completemerges.size()?estr(completemerges.begin()->dist):estr("n/a")) << endl;
    ofile.write(estr(scluster.size()-mergecount)+" "+sit->dist+" "+sit->x+" "+sit->y+"\n");
    merge(*sit);
    smatrix.erase(sit);
    completemerges.erase(it);
    if (incmaxit==smatrix.end())
      getIncompleteMaxDist(dist,incmaxdist,incmaxit);
  }
  ofile.flush();
}
Exemplo n.º 25
0
int CXslTransform::transform()
{
    if(!m_ParsedSource)
        throw MakeStringException(1, "[XML source not set for XSLT[");
    else if(!m_xslsource)
        throw MakeStringException(2, "[XSL stylesheet not set]");
    else if(!m_resultTarget)
        throw MakeStringException(2, "[XSLT target file/buffer not set]");

    XalanCompiledStylesheet* pCompiledStylesheet = NULL;
    pCompiledStylesheet = m_xslsource->getStylesheet();

    if (!pCompiledStylesheet)
    {
        DBGLOG("[failed to compile XSLT stylesheet]");
        throw MakeStringException(2, "[failed to compile XSLT stylesheet]");
    }

    int rc=0;
    m_sMessages.clear();
    try
    {
        rc = m_XalanTransformer.transform(*m_ParsedSource, pCompiledStylesheet, *m_resultTarget);
    }
    catch(...)
    {
        StringBuffer estr("[Exception running XSLT stylesheet]");
        estr.appendf("[%s]", m_XalanTransformer.getLastError());
        DBGLOG("%s", estr.str());
        throw MakeStringException(2, "%s", estr.str());
    }
    if (rc < 0)
    {
        StringBuffer estr;
        estr.appendf("[%s]", m_XalanTransformer.getLastError());
        DBGLOG("%s", estr.str());
        throw MakeStringException(2, "%s", estr.str());
    }

    return rc;
}
Exemplo n.º 26
0
void eseqclusteravg::init(INDTYPE count,const estr& filename,const estr& seqsfile,const earray<ebasicarray<INDTYPE> >& dupslist,float _thres,float (_fdist)(const estr&,const estr&,int),estrarray& _seqarr,int _seqlen)
{
  thres=_thres;
  seqarr=&_seqarr;
  seqlen=_seqlen;
  fdist=_fdist;
  ofile.open(filename,"w");
  ofile.write("# seqsfile: "+seqsfile+"\n");
  ofile.write("# OTU_count Merge_distance Merged_OTU_id1 Merged_OTU_id2\n");
  long i,j;
  incmaxdist=1.0;
  incmaxit=smatrix.end();
  cf=0;
  lastdist=0.0;
  scount.reserve(count);
  scluster.reserve(count);
  smerge.reserve(count);
  inter.reserve(count);
  incluster.reserve(count);
  mergecount=0;
  for (i=0; i<count; ++i){
    scount.add(1);
    scluster.add(i);
    smerge.add(-1);
    incluster.add(list<INDTYPE>());
    incluster[i].push_back(i);
    inter.add(list<INDTYPE>());
  }
  for (i=0; i<dupslist.size(); ++i){
    for (j=1; j<dupslist[i].size(); ++j){
      ++mergecount;
      ofile.write(estr(scluster.size()-mergecount)+" 1.0 "+dupslist[i][0]+" "+dupslist[i][j]+"\n");
      clusterData.mergearr.add(eseqdist(dupslist[i][0],dupslist[i][j],1.0));
    }
  }
  cout << "# initializing cluster with: "<< count<< " seqs" << endl; 
  cout << "# initializing smatrix with: " << (long)(count)*(long)(count)/20000l/2l<< " elements" << endl; 
  smatrix.reserve((long)(count)*(long)(count)/20000l/2l);
//  cout << "# smatrix._hashitems = " << smatrix._hashitems << endl;
}
Exemplo n.º 27
0
void eseqclustersingle::merge(INDTYPE x,INDTYPE y,float dist)
{
  if (x==y) return;
  ldieif(scount[x]==0 || scount[y]==0,"also should not happen");

  clusterData.mergearr.add(eseqdist(x,y,dist));

  smerge[x]=x;
  smerge[y]=x;

  scount[x]+=scount[y];
  scount[y]=0;

  list<INDTYPE>::iterator it;
  for (it=incluster[y].begin(); it!=incluster[y].end(); ++it){
    scluster[*it]=x;
    incluster[x].push_back(*it);
  }
  ++mergecount;
  
//  cout << scluster.size()-mergecount << " " << dist << " " << x << " " << y << endl;
  ofile.write(estr(scluster.size()-mergecount)+" "+dist+" "+x+" "+y+"\n");
}
Exemplo n.º 28
0
void Susi::Syscall::Worker::run() {
	Poco::Pipe outPipe;
	Poco::Pipe errPipe;

	Poco::ProcessHandle ph = Poco::Process::launch(_cmd, _args, 0, &outPipe, &errPipe);

	Poco::PipeInputStream ostr(outPipe);
	Poco::PipeInputStream estr(errPipe);


	if(_bg == true) {
		auto start_payload = Susi::Util::Any::Object{
			{"process_type" , _process_type },
			{"started", true}			
		};
		auto started_event = Susi::Events::createEvent("syscall::startedProcess");
		started_event->payload["result"] = start_payload;

		Susi::Events::publish(std::move(started_event));
	}

	int rc = ph.wait();

	Susi::Util::Any end_payload = Susi::Util::Any::Object{
		{"process_type" , _process_type },
		{"stdout", this->getPipeContent(ostr)},
		{"stderr", this->getPipeContent(estr)},
		{"return", rc}
	};

	//std::cout<<"Payload:"<<end_payload.toString()<<std::endl;

	auto end_event = Susi::Events::createEvent("syscall::endProcess");
	end_event->payload["result"] = end_payload;

	Susi::Events::publish(std::move(end_event));	
}
static inline int error_clblast(error *e, const char *msg,
                                CLBlastStatusCode err) {
  return error_fmt(e, GA_BLAS_ERROR, "%s: %s", msg, estr(err));
}
Exemplo n.º 30
0
    virtual void on_draw()
    {
        pixfmt pixf(rbuf_window());
        renderer_base rb(pixf);
        renderer_solid rs(rb);
        rb.clear(agg::rgba(1, 1, 1));

        // When Gamma changes rebuild the gamma and gradient LUTs 
        //------------------
        if(m_old_gamma != m_gamma.value())
        {
            m_gamma_lut.gamma(m_gamma.value());
            build_gradient_lut();
            m_old_gamma = m_gamma.value();
        }


        // Gradient center. All gradient functions assume the 
        // center being in the origin (0,0) and you can't 
        // change it. But you can apply arbitrary transformations
        // to the gradient (see below).
        //------------------
        double cx = initial_width()  / 2;
        double cy = initial_height() / 2;
        double r = 100;

        // Focal center. Defined in the gradient coordinates, 
        // that is, with respect to the origin (0,0)
        //------------------
        double fx = m_mouse_x - cx;
        double fy = m_mouse_y - cy;

        gradient_func_type    gradient_func(r, fx, fy);
        gradient_adaptor_type gradient_adaptor(gradient_func);
        agg::trans_affine     gradient_mtx;
        
        // Making the affine matrix. Move to (cx,cy), 
        // apply the resizing transformations and invert
        // the matrix. Gradients and images always assume the
        // inverse transformations.
        //------------------
        gradient_mtx.translate(cx, cy);
        gradient_mtx *= trans_affine_resizing();
        gradient_mtx.invert();

        interpolator_type     span_interpolator(gradient_mtx);
        span_gradient_type    span_gradient(span_interpolator, 
                                          gradient_adaptor, 
                                          m_gradient_lut, 
                                          0, r);

        // Form the simple rectangle 
        //------------------
        m_rasterizer.reset();
        m_rasterizer.move_to_d(0,0);
        m_rasterizer.line_to_d(width(), 0);
        m_rasterizer.line_to_d(width(), height());
        m_rasterizer.line_to_d(0, height());

        // Render the gradient to the whole screen and measure the time
        //------------------
        start_timer();
        agg::render_scanlines_aa(m_rasterizer, m_scanline, rb, m_alloc, span_gradient);
        double tm = elapsed_time();

        // Draw the transformed circle that shows the gradient boundary
        //------------------
        agg::ellipse e(cx, cy, r, r);
        agg::conv_stroke<agg::ellipse> estr(e);
        agg::conv_transform<
            agg::conv_stroke<
                agg::ellipse> > etrans(estr, trans_affine_resizing());

        m_rasterizer.add_path(etrans);
        agg::render_scanlines_aa_solid(m_rasterizer, m_scanline, rb, agg::rgba(1,1,1));

        // Show the gradient time
        //------------------
        char buf[64]; 
        agg::gsv_text t;
        t.size(10.0);
        agg::conv_stroke<agg::gsv_text> pt(t);
        pt.width(1.5);
        sprintf(buf, "%3.2f ms", tm);
        t.start_point(10.0, 35.0);
        t.text(buf);
        m_rasterizer.add_path(pt);
        agg::render_scanlines_aa_solid(m_rasterizer, m_scanline, rb, agg::rgba(0,0,0));

#if !LINEAR_RGB
        // Show the controls
        //------------------
        agg::render_ctrl(m_rasterizer, m_scanline, rb, m_gamma);

        // Apply the inverse gamma to the whole buffer 
        // (transform the colors to the perceptually uniform space)
        //------------------
        pixf.apply_gamma_inv(m_gamma_lut);
#endif
    }