Пример #1
0
RealVectorValue
LevelSetOlssonVortex::vectorValue(Real t, const Point & p)
{
  // Compute the velocity field
  _output(0) = std::sin(_pi * p(0)) * std::sin(_pi * p(0)) * std::sin(2 * _pi * p(1));
  _output(1) = -std::sin(_pi * p(1)) * std::sin(_pi * p(1)) * std::sin(2 * _pi * p(0));

  // Compute the coefficient used to reverse the flow
  _reverse_coefficient = 1.0;
  if (_reverse_type == 0 && t > _reverse_time / 2.)
    _reverse_coefficient = -1.0;
  else if (_reverse_type == 1)
    _reverse_coefficient = std::cos(_pi * t / _reverse_time);
  return _reverse_coefficient * _output;
}
Пример #2
0
int vfprintf(FILE *stream, const char *fmt, va_list args) {
  int rc;

  if (stream->flag & _IONBF) {
    char buf[BUFSIZ];

    _stbuf(stream, buf, BUFSIZ);
    rc = _output(stream, fmt, args);
    _ftbuf(stream);
  } else {
    rc = _output(stream, fmt, args);
  }

  return rc;
}
Пример #3
0
  bool _send( T& t, J, const V& value, type2type<B*> )
  {
    typedef B* buffer_type;
    buffer_type buffer = t.get_aspect().template get<_buffer_>();

    return _output( t, J(), value, buffer );
  }
int __cdecl _vsnprintf (
        char *string,
        size_t count,
        const char *format,
        va_list ap
        )
#endif  /* _COUNT_ */

{
        FILE str;
        REG1 FILE *outfile = &str;
        REG2 int retval;

        _ASSERTE(string != NULL);
        _ASSERTE(format != NULL);

        outfile->_flag = _IOWRT|_IOSTRG;
        outfile->_ptr = outfile->_base = string;
#ifndef _COUNT_
        outfile->_cnt = MAXSTR;
#else  /* _COUNT_ */
        outfile->_cnt = count;
#endif  /* _COUNT_ */

        retval = _output(outfile,format,ap );
        _putc_lk('\0',outfile);

        return(retval);
}
int isr_report (ISREPORT *rep)
{   /* --- report the current item set */
    int r = 0;                    /* number of reported item sets */
    int k;                        /* number of perfect extensions */
    int min, max;                 /* min. and max. item set size */

    assert(rep);                  /* check the function argument */
    if (rep->cnt > rep->max)      /* if the item set is too large, */
        return 0;                   /* abort the function */
    k   = (int)(rep->pxpp -rep->pexs);
    max = rep->cnt +k;            /* get number of perfect extensions */
    min = rep->min;               /* and check whether the minimum size */
    if (max < min) return 0;      /* can be reached with perfect exts. */
    if (rep->closed) {            /* if to report only closed item sets */
        if (max > rep->max) max = rep->max;
        if (max > rep->min) rep->min = max;
    }                             /* adapt the minimal item set size */
    if (rep->cnt >= rep->min)     /* if the item set is large enough, */
        r += _output(rep);          /* report and count it */
    if ((k > 0)                   /* if there are perfect extensions */
            &&  (rep->cnt < rep->max))    /* and maximum size not yet reached, */
        r += _report(rep, k);       /* recursively add and report them */
    rep->min  = min;              /* restore the minimum item set size */
    return r;                     /* return number of rep. item sets */
}  /* isr_report() */
Пример #6
0
int __cdecl _snprintf (
	char *string,
	size_t count,
	const char *format,
	...
	)
#endif

{
	FILE str;
	REG1 FILE *outfile = &str;
	va_list arglist;
	REG2 int retval;

	va_start(arglist, format);

	_ASSERTE(string != NULL);
	_ASSERTE(format != NULL);

	outfile->_flag = _IOWRT|_IOSTRG;
	outfile->_ptr = outfile->_base = string;
#ifndef _COUNT_
	outfile->_cnt = MAXSTR;
#else
	outfile->_cnt = count;
#endif

	retval = _output(outfile,format,arglist);

	_putc_lk('\0',outfile); /* no-lock version */

	return(retval);
}
Пример #7
0
int __cdecl printf (
        const char *format,
        ...
        )
/*
 * stdout 'PRINT', 'F'ormatted
 */
{
        va_list arglist;
        int buffing;
        int retval;

        va_start(arglist, format);

        _ASSERTE(format != NULL);

        _lock_str2(1, stdout);

        buffing = _stbuf(stdout);

        retval = _output(stdout,format,arglist);

        _ftbuf(buffing, stdout);

        _unlock_str2(1, stdout);

        return(retval);
}
void place::displayOutput(
    const std::vector<Eigen::SparseMatrix<double>> &rSSparseTrimmed,
    const std::vector<const place::posInfo *> &minima) {

  if (!FLAGS_quietMode) {
    std::cout << "Num minima: " << minima.size() << std::endl;
    std::cout << "Press a key to begin displaying placement options"
              << std::endl;
  }

  cv::rectshow(fpColor);

  int currentCount = 0;
  for (auto &min : minima) {
    const int xOffset = min->x;
    const int yOffset = min->y;
    const Eigen::SparseMatrix<double> &currentScan =
        rSSparseTrimmed[min->rotation];
    cv::Mat output(fpColor.rows, fpColor.cols, CV_8UC3, cv::Scalar::all(255));
    fpColor.copyTo(output);

    cv::Mat_<cv::Vec3b> _output = output;

    for (int i = 0; i < currentScan.outerSize(); ++i) {
      for (Eigen::SparseMatrix<double>::InnerIterator it(currentScan, i); it;
           ++it) {
        if (it.row() + yOffset < 0 || it.row() + yOffset >= output.rows)
          continue;
        if (it.col() + xOffset < 0 || it.col() + xOffset >= output.cols)
          continue;

        _output(it.row() + yOffset, it.col() + xOffset)[0] = 0;
        _output(it.row() + yOffset, it.col() + xOffset)[1] = 0;
        _output(it.row() + yOffset, it.col() + xOffset)[2] = 255;
      }
    }

    if (!FLAGS_quietMode) {
      std::cout << min << std::endl << std::endl;
    }
    const int keyCode = cv::rectshow(output);
    ~output;
    if (keyCode == 27)
      break;
  }
}
Пример #9
0
static void 
_output_plain (rle_out *rle, int c)
{
  rle->just_cleared = false;
  _output (rle, c);
  rle->out_count++;
  if (rle->out_count >= rle->out_bump)
    { 
      rle->out_bits++;
      rle->out_bump += 1 << (rle->out_bits - 1);
    }
  if (rle->out_count >= rle->out_clear)
    { 
      _output (rle, rle->code_clear);
      _did_clear (rle);
    }
}
Пример #10
0
  bool _send( T& t, J, const V& value, type2type<B[N]> )
  {
    typedef random_access_range<B*> range_type;
    typedef B* buffer_type;

    buffer_type buffer = t.get_aspect().template get<_buffer_>();
    return _output( t, J(), value, range_type(buffer, buffer + N) );
  }
Пример #11
0
static void 
_reset_out_clear (rle_out *rle)
{
  rle->out_clear = rle->out_clear_init;
  if (rle->out_count >= rle->out_clear)
    { 
      _output (rle, rle->code_clear);
      _did_clear (rle);
    }
}
Пример #12
0
/* flush out any data remaining in RLE; write EOF and deallocate RLE */
void
_rle_terminate (rle_out *rle)
{
  /* if a run in progress, end it */
  if (rle->rl_count > 0)
    _rl_flush (rle);
  _output (rle, rle->code_eof);
  _output_flush (rle);
  /* deallocate */
  free (rle);
}
Пример #13
0
int vsnprintf(char *buf, size_t count, const char *fmt, va_list args) {
  FILE str;
  int rc;

  str.cnt = (int) count;
  str.flag = _IOWR | _IOSTR;
  str.ptr = str.base = buf;

  rc = _output(&str, fmt, args);
  if (buf != NULL) putc('\0', &str);

  return rc;
}
Пример #14
0
static void 
_rl_flush_clearorrep (rle_out *rle, int count)
{
  int withclr;

  withclr = 1 + _compute_triangle_count ((unsigned int)count, 
					 (unsigned int)(rle->max_ocodes));
  if (withclr < count)
    { 
      _output (rle, rle->code_clear);
      _did_clear (rle);
      _rl_flush_fromclear (rle, count);
    }
  else
    for ( ; count>0; count--)
      _output_plain (rle, rle->rl_pixel);
}
static int _report (ISREPORT *rep, int k)
{   /* --- recursively report item sets */
    int r = 0;                    /* counter for reported item sets */

    assert(rep && (k > 0));       /* check the function arguments */
    while (--k >= 0) {            /* traverse the perfect extensions */
        rep->items[rep->cnt++] = rep->pexs[k];
        if (rep->supps) rep->supps[rep->cnt] = rep->supps[rep->cnt-1];
        else            rep->sdbls[rep->cnt] = rep->sdbls[rep->cnt-1];
        if (rep->cnt >= rep->min)   /* if it has the req. min. size, */
            r += _output(rep);        /* report and count the item set */
        if ((k > 0)                 /* if another item can be added */
                &&  (rep->cnt +k >= rep->min)
                &&  (rep->cnt    <  rep->max))
            r += _report(rep, k);     /* recurse for remaining item sets */
        if (--rep->cnt < rep->pfx)  /* remove the current item again */
            rep->pfx = rep->cnt;      /* and adapt the valid prefix */
    }                             /* if necessary */
    return r;                     /* return number of rep. item sets */
}  /* _report() */
Пример #16
0
static void 
_rl_flush_withtable (rle_out *rle, int count)
{
  int repmax;
  int repleft;
  int leftover;

  repmax = count / rle->rl_table_max;
  leftover = count % rle->rl_table_max;
  repleft = (leftover ? 1 : 0);
  if (rle->out_count + repmax + repleft > rle->max_ocodes)
    { 
      repmax = rle->max_ocodes - rle->out_count;
      leftover = count - (repmax * rle->rl_table_max);
      repleft = 1 + _compute_triangle_count ((unsigned int)leftover,
					     (unsigned int)(rle->max_ocodes));
    }
  if (1 + _compute_triangle_count ((unsigned int)count, 
				   (unsigned int)(rle->max_ocodes)) 
      < repmax + repleft)
    { 
      _output (rle, rle->code_clear);
      _did_clear (rle);
      _rl_flush_fromclear (rle, count);
      return;
    }
  _max_out_clear (rle);
  for ( ; repmax>0; repmax--)
    _output_plain (rle, rle->rl_basecode + rle->rl_table_max - 2);
  if (leftover)
    { 
      if (rle->just_cleared)
	_rl_flush_fromclear (rle, leftover);
      else if (leftover == 1)
	_output_plain (rle, rle->rl_pixel);
      else
	_output_plain (rle, rle->rl_basecode + leftover - 2);
    }
  _reset_out_clear (rle);
}
int __cdecl vprintf (
        const char *format,
        va_list ap
        )
/*
 * stdout 'V'ariable, 'PRINT', 'F'ormatted
 */
{
        REG1 FILE *stream = stdout;
        REG2 int buffing;
        REG3 int retval;

        _ASSERTE(format != NULL);

        _lock_str(stream);
        buffing = _stbuf(stream);
        retval = _output(stream, format, ap );
        _ftbuf(buffing, stream);
        _unlock_str(stream);

        return(retval);
}
Пример #18
0
_rle_init (FILE *fp, int bit_depth)
#endif
{
  int init_bits;
  rle_out *rle;

  /* Initial length for compression codes, one bit longer than the minimum
     number of bits needed to represent the set of pixel values.  The
     IMAX() and the addition of 1 bit are "because of some algorithmic
     constraints". */
  init_bits = IMAX(bit_depth, 2) + 1;

  rle = (rle_out *)_pl_xmalloc(sizeof(rle_out));
  rle->ofile = fp;
#ifdef LIBPLOTTER
  rle->outstream = out;
#endif
  rle->obuf = 0;
  rle->obits = 0;
  rle->oblen = 0;
  rle->code_clear = 1 << (init_bits - 1); 	   /* 100..000 */
  rle->code_eof = rle->code_clear + 1;    	   /* 100..001 */
  rle->rl_basecode = rle->code_eof + 1;   	   /* 100..010 */
  rle->out_bump_init = (1 << (init_bits - 1)) - 1; /* 011..111 */
  /* for images with a lot of runs, making out_clear_init larger will
     give better compression. */ 
						   /* 011..110 */
  rle->out_clear_init = (init_bits <= 3) ? 9 : (rle->out_bump_init - 1);
  rle->out_bits_init = init_bits;
  rle->max_ocodes = (1 << GIFBITS) - ((1 << (rle->out_bits_init - 1)) + 3);

  _did_clear (rle);
  _output (rle, rle->code_clear);
  rle->rl_count = 0;

  return rle;
}
Пример #19
0
void output_debug (const char *format, ...) {
  va_list arglist;
  va_start (arglist, format);
  _output (OUTPUT_DEBUG, format, arglist);
  va_end (arglist);
}
Пример #20
0
void output_info (const char *format, ...) {
  va_list arglist;
  va_start (arglist, format);
  _output (OUTPUT_INFO, format, arglist);
  va_end (arglist);
}
Пример #21
0
	int execute(st step, vt t, int fob, pDomain pd = nullptr) {
		_count_exe++;
		_record_time(step, t);
		_output(step, t);
		return -1;
	}
Пример #22
0
void IntegerRunLengthEncoder::_flush(bool bAll)
{
    do
    {
        if(m_iObjectSize == 0)
        {
            // Decide on the size of the next object
            // Want the object size which gives most object repeats, then for
            // two sizes with the same repeat count, the smaller size.
            size_t iBestRepeats = 0;
            size_t iBestSize = 0;
            size_t iBestOffset = 0;
            for(size_t iNumRecords = 1; iNumRecords <= 8; ++iNumRecords)
            {
                for(size_t iOffset = 0; iOffset < iNumRecords; ++iOffset)
                {
                    size_t iNumRepeats = 0;
                    size_t iObjSize = iNumRecords * m_iRecordSize;
                    while(iObjSize * (iOffset + iNumRepeats + 1) <= m_iBufferSizeUsed
                        && _areRangesEqual(0, iNumRepeats, iOffset, iObjSize))
                    {
                        ++iNumRepeats;
                    }
                    if(iNumRepeats > iBestRepeats
                    ||(iBestRepeats == iBestRepeats && iObjSize < iBestSize))
                    {
                        iBestRepeats = iNumRepeats;
                        iBestSize = iObjSize;
                        iBestOffset = iOffset;
                    }
                }
            }
            if(iBestRepeats == 1)
            {
                // No repeats were found, so the best we can do is output
                // a large non-repeating blob.
                _output(std::min(m_iBufferSizeUsed, 8 * m_iRecordSize), 1);
            }
            else
            {
                if(iBestOffset != 0)
                    _output(iBestOffset * m_iRecordSize, 1);
                // Mark the object as the current one, and remove all but the
                // last instance of it from the buffer. On the next flush, the
                // new data might continue the same object, hence why the
                // object isn't output just yet.
                m_iObjectSize = iBestSize;
                m_iObjectCount = iBestRepeats - 1;
                m_iBufferOffset = (m_iBufferOffset + m_iObjectSize * m_iObjectCount) % m_iBufferSize;
                m_iBufferSizeUsed -= m_iObjectSize * m_iObjectCount;
            }
        }
        else
        {
            // Try to match more of the current object
            while(m_iObjectSize * 2 <= m_iBufferSizeUsed &&
                  _areRangesEqual(0, 1, 0, m_iObjectSize))
            {
                ++m_iObjectCount;
                m_iBufferOffset = (m_iBufferOffset + m_iObjectSize) % m_iBufferSize;
                m_iBufferSizeUsed -= m_iObjectSize;
            }
            // Write data
            if(m_iObjectSize * 2 <= m_iBufferSizeUsed || bAll)
            {
                _output(m_iObjectSize, m_iObjectCount + 1);
                m_iObjectSize = 0;
                m_iObjectCount = 0;
            }
        }
    } while(bAll && m_iBufferSizeUsed != 0);
}
Пример #23
0
void output_error (const char *format, ...) {
  va_list arglist;
  va_start (arglist, format);
  _output (OUTPUT_ERROR, format, arglist);
  va_end (arglist);
}
Пример #24
0
void place::displayOutput(
    const Eigen::SparseMatrix<double> &fp,
    const std::vector<Eigen::SparseMatrix<double>> &rSSparseTrimmed,
    const Eigen::MatrixXb &fpDoors,
    const std::vector<std::vector<place::Door>> &pcDoors,
    const std::vector<const place::posInfo *> &minima) {
  const int num = minima.size() < 20 ? minima.size() : 20;
  if (!FLAGS_quietMode) {
    std::cout << "Num minima: " << num << std::endl;
    std::cout << "Press a key to begin displaying placement options"
              << std::endl;
  }
  cv::Mat fpImg = place::sparseToImage(fp);
  cv::Mat tmpColor(fpImg.rows, fpImg.cols, CV_8UC3, cv::Scalar::all(255));

  for (int i = 0; i < tmpColor.rows; ++i) {
    uchar *dst = tmpColor.ptr<uchar>(i);
    const uchar *src = fpImg.ptr<uchar>(i);
    for (int j = 0; j < tmpColor.cols; ++j) {
      if (src[j] != 255) {
        dst[j * 3] = 128;
        dst[j * 3 + 1] = 128;
        dst[j * 3 + 2] = 128;
      }
    }
  }

  for (int j = 0; j < fpDoors.rows(); ++j) {
    uchar *dst = tmpColor.ptr<uchar>(j);
    for (int i = 0; i < fpDoors.cols(); ++i) {
      if (fpDoors(j, i)) {
        dst[i * 3] = 0;
        dst[i * 3 + 1] = 255;
        dst[i * 3 + 2] = 0;
      }
    }
  }

  cv::rectshow(tmpColor);
  const int cutOff = FLAGS_top > 0 ? FLAGS_top : 20;

  int currentCount = 0;
  for (auto &min : minima) {
    const int xOffset = min->x;
    const int yOffset = min->y;
    const Eigen::SparseMatrix<double> &currentScan =
        rSSparseTrimmed[min->rotation];
    auto &doors = pcDoors[min->rotation];

    cv::Mat output(tmpColor.rows, tmpColor.cols, CV_8UC3, cv::Scalar::all(255));
    tmpColor.copyTo(output);
    cv::Mat_<cv::Vec3b> _output = output;

    for (int i = 0; i < currentScan.outerSize(); ++i) {
      for (Eigen::SparseMatrix<double>::InnerIterator it(currentScan, i); it;
           ++it) {
        if (it.row() + yOffset < 0 || it.row() + yOffset >= output.rows)
          continue;
        if (it.col() + xOffset < 0 || it.col() + xOffset >= output.cols)
          continue;

        _output(it.row() + yOffset, it.col() + xOffset)[0] = 0;
        _output(it.row() + yOffset, it.col() + xOffset)[1] = 0;
        _output(it.row() + yOffset, it.col() + xOffset)[2] = 255;
      }
    }

    for (auto &d : doors) {
      auto color = randomColor();
      for (double x = 0; x < d.w; ++x) {
        Eigen::Vector3i index =
            (d.corner + x * d.xAxis + Eigen::Vector3d(min->x, min->y, 0))
                .unaryExpr([](auto v) { return std::round(v); })
                .cast<int>();

        _output(index[1], index[0]) = color;
      }
    }

    if (!FLAGS_quietMode) {
      std::cout << min << std::endl << std::endl;
    }
    cv::rectshow(output);
    ~output;
    if (++currentCount == cutOff)
      break;
  }
}
Пример #25
0
 bool _send( T& t, J, const V& value, type2type<B> )
 {
   typedef B buffer_type;
   buffer_type& buffer = t.get_aspect().template get<_buffer_>();
   return _output( t, J(), value, orange(buffer, true) );
 }