示例#1
0
int Human::playerStatus(int dealerTotal) const
{
	if (total() > dealerTotal)
	{
		cout << name << " wins!\n";
		return 1;
	}
	else if (total() < dealerTotal)
	{
		cout << name << " loses.\n";
		return -1;
	}
	else if (total() == dealerTotal)
	{
		cout << name << "pushes.\n";					
		return 0;
	}
}
示例#2
0
 bool getMemoryShapes(const std::vector<MatShape> &inputs,
                      const int requiredOutputs,
                      std::vector<MatShape> &outputs,
                      std::vector<MatShape> &internals) const
 {
     Layer::getMemoryShapes(inputs, requiredOutputs, outputs, internals);
     internals.assign(1, shape(1, total(inputs[0], 2)));
     return true;
 }
示例#3
0
Object* Array::pop(STATE) {
    size_t cnt = total_->to_native();

    if(cnt == 0) return Qnil;
    Object *obj = get(state, cnt - 1);
    set(state, cnt-1, Qnil);
    total(state, Fixnum::from(cnt - 1));
    return obj;
}
示例#4
0
void Customer::fireTotalsChanged() {
    foodTotalChanged(foodTotal());
    taxTotalChanged(taxTotal());
    barTotalChanged(barTotal());
    totalChanged(total());

    actualTaxChanged(actualTax());
    marginChanged(margin());
}
示例#5
0
void main (void)
{
    struct tipopro proveedor[n];

    cargamatriz (proveedor, n);
    escribirmatriz (proveedor, n);
    printf ("IMPORTE TOTAL= %d\n", total (proveedor, n));
    getch ();
}
示例#6
0
文件: copy.cpp 项目: bigdig/opencv
/* dst = src */
void Mat::copyTo( OutputArray _dst ) const
{
    int dtype = _dst.type();
    if( _dst.fixedType() && dtype != type() )
    {
        CV_Assert( channels() == CV_MAT_CN(dtype) );
        convertTo( _dst, dtype );
        return;
    }

    if( empty() )
    {
        _dst.release();
        return;
    }

    if( dims <= 2 )
    {
        _dst.create( rows, cols, type() );
        Mat dst = _dst.getMat();
        if( data == dst.data )
            return;

        if( rows > 0 && cols > 0 )
        {
            const uchar* sptr = data;
            uchar* dptr = dst.data;

            // to handle the copying 1xn matrix => nx1 std vector.
            Size sz = size() == dst.size() ?
                getContinuousSize(*this, dst) :
                getContinuousSize(*this);
            size_t len = sz.width*elemSize();

            for( ; sz.height--; sptr += step, dptr += dst.step )
                memcpy( dptr, sptr, len );
        }
        return;
    }

    _dst.create( dims, size, type() );
    Mat dst = _dst.getMat();
    if( data == dst.data )
        return;

    if( total() != 0 )
    {
        const Mat* arrays[] = { this, &dst };
        uchar* ptrs[2];
        NAryMatIterator it(arrays, ptrs, 2);
        size_t sz = it.size*elemSize();

        for( size_t i = 0; i < it.nplanes; i++, ++it )
            memcpy(ptrs[1], ptrs[0], sz);
    }
}
示例#7
0
BigInteger BigInteger::operator*(const BigInteger & r) const
{
	BigInteger i(0), total(0), one(1);
	for( ; i < *this; i = i + one )    // runs faster if *this < r   
	{
		total = total + r;
		if ( total.hasOverFlowed() ) return total;      // stop when overflow
	}
	return total;
}
示例#8
0
int UMat::checkVector(int _elemChannels, int _depth, bool _requireContinuous) const
{
    return (depth() == _depth || _depth <= 0) &&
        (isContinuous() || !_requireContinuous) &&
        ((dims == 2 && (((rows == 1 || cols == 1) && channels() == _elemChannels) ||
                        (cols == _elemChannels && channels() == 1))) ||
        (dims == 3 && channels() == 1 && size.p[2] == _elemChannels && (size.p[0] == 1 || size.p[1] == 1) &&
         (isContinuous() || step.p[1] == step.p[2]*size.p[2])))
    ? (int)(total()*channels()/_elemChannels) : -1;
}
示例#9
0
size_t MessageEncoder::getEncodedSize(const Properties& p, const qpid::types::Variant::Map& ap, const std::string& d)
{
    size_t total(getEncodedSize(p));
    //application-properties:
    total += 3/*descriptor*/ + getEncodedSize(ap, true);
    //body:
    if (d.size()) total += 3/*descriptor*/ + 1/*code*/ + encodedSize(d);

    return total;
}
示例#10
0
void WorksheetWidget::finished()
{
	if(WorksheetModel* model = qobject_cast<WorksheetModel*>(ui->tableView->model()))
		model->setWorkLog(m_fetcher->workLog());

	if(!m_fetcher->lastError().isNull())
		setWarning(m_fetcher->lastError());

	ui->totalTimeLabel->setText("Total time spent: " + Entry::formatTimeSpent(total()));
}
示例#11
0
size_t MessageEncoder::getEncodedSize(const Header& h)
{
    //NOTE: this does not take optional optimisation into account,
    //i.e. it is a 'worst case' estimate for required buffer space
    size_t total(3/*descriptor*/ + 1/*code*/ + 1/*size*/ + 1/*count*/ + 5/*codes for each field*/);
    if (h.getPriority() != 4) total += 1;
    if (h.getDeliveryCount()) total += 4;
    if (h.hasTtl()) total += 4;
    return total;
}
示例#12
0
QSize QToolBoxButton::sizeHint() const
{
    QSize iconSize(8, 8);
    if ( !icon.isNull() )
	iconSize += icon.pixmap( QIconSet::Small, QIconSet::Normal ).size() + QSize( 2, 0 );
    QSize textSize = fontMetrics().size( Qt::ShowPrefix, label ) + QSize(0, 8);

    QSize total(iconSize.width() + textSize.width(), QMAX(iconSize.height(), textSize.height()));
    return total.expandedTo(QApplication::globalStrut());
}
示例#13
0
  void Array::unshift(STATE, Object* val) {
    native_int new_size = total_->to_native() + 1;
    native_int lend = start_->to_native();

    if(lend > 0) {
      tuple_->put(state, lend-1, val);
      start(state, Fixnum::from(lend-1));
      total(state, Fixnum::from(new_size));
    } else {
      Tuple* nt = Tuple::create(state, new_size);
      nt->copy_from(state, tuple_, start_, total_,
		    Fixnum::from(1));
      nt->put(state, 0, val);

      total(state, Fixnum::from(new_size));
      start(state, Fixnum::from(0));
      tuple(state, nt);
    }
  }
示例#14
0
  Object* Array::shift(STATE) {
    native_int cnt = total_->to_native();

    if(cnt == 0) return cNil;
    Object* obj = get(state, 0);
    set(state, 0, cNil);
    start(state, Fixnum::from(start_->to_native() + 1));
    total(state, Fixnum::from(cnt - 1));
    return obj;
  }
示例#15
0
int main() {
	int n;
	res[1]=res[2]=1;
	scanf("%d",&n);
	while(n--) {
		int m;
		scanf("%d",&m);
		printf("%d\n",total(m));
	}
}
ofVec2f ofxCvOpticalFlowLK::flowInRegion(float x, float y, float w, float h){
	ofVec2f topLeft, bottomRight, total(0,0);
	boundsForRect(x, y, w, h, &topLeft, &bottomRight);
	for (int j = topLeft.y; j < bottomRight.y; j++) {
		for(int i = topLeft.x; i < bottomRight.x; i++){
			total += flowAtPoint(i, j);
		}
	}
	return total; 
}
示例#17
0
void Target::SetImage(string filename)
{
    if (filename.size() > 0)
    {
    	// Read the file into a matrix:
        fits2mat(filename.c_str(), this->image);

        // Normalize it, just in case it wasn't normalized to begin with.
        this->image /= total(this->image);
    }
}
示例#18
0
  LookupTable* Timer::to_ruby(VM* state) {
    LookupTable* tbl = LookupTable::create(state);

    tbl->store(state, stats::total(state), Integer::from(state, total()));
    tbl->store(state, stats::timings(state), Integer::from(state, timings()));
    tbl->store(state, stats::max(state), Integer::from(state, max()));
    tbl->store(state, stats::min(state), Integer::from(state, min()));
    tbl->store(state, stats::average(state), Float::create(state, moving_average()));

    return tbl;
  }
示例#19
0
void Mat::create(int d, const int* _sizes, int _type)
{
    int i;
    CV_Assert(0 <= d && d <= CV_MAX_DIM && _sizes);
    _type = CV_MAT_TYPE(_type);

    if( data && (d == dims || (d == 1 && dims <= 2)) && _type == type() )
    {
        if( d == 2 && rows == _sizes[0] && cols == _sizes[1] )
            return;
        for( i = 0; i < d; i++ )
            if( size[i] != _sizes[i] )
                break;
        if( i == d && (d > 1 || size[1] == 1))
            return;
    }

    int _sizes_backup[CV_MAX_DIM]; // #5991
    if (_sizes == (this->size.p))
    {
        for(i = 0; i < d; i++ )
            _sizes_backup[i] = _sizes[i];
        _sizes = _sizes_backup;
    }

    release();
    if( d == 0 )
        return;
    flags = (_type & CV_MAT_TYPE_MASK) | MAGIC_VAL;
    setSize(*this, d, _sizes, 0, true);

    if( total() > 0 )
    {
        MatAllocator *a = allocator, *a0 = getDefaultAllocator();
#ifdef HAVE_TGPU
        if( !a || a == tegra::getAllocator() )
            a = tegra::getAllocator(d, _sizes, _type);
#endif
        if(!a)
            a = a0;
        CV_TRY
        {
            u = a->allocate(dims, size, _type, 0, step.p, 0, USAGE_DEFAULT);
            CV_Assert(u != 0);
        }
        CV_CATCH_ALL
        {
            if(a != a0)
                u = a0->allocate(dims, size, _type, 0, step.p, 0, USAGE_DEFAULT);
            CV_Assert(u != 0);
        }
        CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) );
    }
示例#20
0
string Fragment::get()
{
	int ttl = total();
	int choice = rand()%ttl;
	int i = 0;
	for ( ; choice > 0 && i <= m_last; i++)
	{
		choice -= m_data[i].weight;
	}
	if (i == 1) i--;
	return m_data[i].data;
}
示例#21
0
    virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
                           const std::vector<MatShape> &outputs) const
    {
        (void)outputs; // suppress unused variable warning

        int64 flops = 0;
        for(int i = 0; i < inputs.size(); i++)
        {
            flops += 60*total(inputs[i]);
        }
        return flops;
    }
示例#22
0
  vector<int> total_times(const valarray<bool>& v) 
  {
    vector<int> total(v.size()+1);

    total[0] = 0;
    for(int i=0;i<v.size();i++) {
      total[i+1] = total[i];
      if (v[i]) total[i+1]++;
    }
      
    return total;
  }
示例#23
0
文件: trieTree.c 项目: ajay/Systems
void total(trieNodePointer root)
{
	for (int i=0; i < 36; i++)
	{
		if (root->children[i] != NULL)
		{
			total(root->children[i]);
			if (root->children[i]->files != NULL)
				totalNodes++;
		}
	}
}
示例#24
0
void newton::run_newton(const complex<double> & start, complex<double>& cur, int & niter){
cur = start;

for (niter = 0; niter < MITER; ++niter)
{
old = cur;
complex<double> total(0.0,0.0);

total = total + 1.0/(cur - std::complex<double>(1,0))+ 1.0/(cur - std::complex<double>(0.309017,0.951057))+ 1.0/(cur - std::complex<double>(-0.809017,0.587785))+ 1.0/(cur - std::complex<double>(-0.809017,-0.587785))+ 1.0/(cur - std::complex<double>(0.309017,-0.951057));
cur = cur - 1.0/total; diff = abs(old-cur); if (diff < .00001) { return;}
} 
}
示例#25
0
文件: trieTree.c 项目: ajay/Systems
void printTree(trieNodePointer root, char *output)
{
	FILE *outputFile = fopen(output, "w");
	totalNodes = 0;
	nodeCount = 0;
	total(ROOT);
	fprintf(outputFile, "{\"list\" : [\n");
	resetVisited(root);
	printTreeRecursive(root, outputFile);
	fprintf(outputFile, "]}\n");
	fclose(outputFile);
}
ofVec2f ofxCvOpticalFlowLK::averageFlowInRegion(float x, float y, float w, float h)
{
	ofVec2f topLeft, bottomRight, total(0,0);
	boundsForRect(x, y, w, h, &topLeft, &bottomRight);
	for (int j = topLeft.y; j < bottomRight.y; j += captureRowsStep) {
		for(int i = topLeft.x; i < bottomRight.x; i += captureColsStep) {
			total += flowAtPoint(i, j);
		}
	}

	return total / ( (bottomRight.x - topLeft.x) * (bottomRight.y - topLeft.y));
}
示例#27
0
nsresult
nsTraceRefcnt::DumpStatistics()
{
  if (!gBloatLog || !gBloatView) {
    return NS_ERROR_FAILURE;
  }

  AutoTraceLogLock lock;

  MOZ_ASSERT(!gDumpedStatistics,
             "Calling DumpStatistics more than once may result in "
             "bogus positive or negative leaks being reported");
  gDumpedStatistics = true;

  // Don't try to log while we hold the lock, we'd deadlock.
  AutoRestore<LoggingType> saveLogging(gLogging);
  gLogging = NoLogging;

  BloatEntry total("TOTAL", 0);
  PL_HashTableEnumerateEntries(gBloatView, BloatEntry::TotalEntries, &total);
  const char* msg;
  if (gLogLeaksOnly) {
    msg = "ALL (cumulative) LEAK STATISTICS";
  } else {
    msg = "ALL (cumulative) LEAK AND BLOAT STATISTICS";
  }
  const bool leaked = total.PrintDumpHeader(gBloatLog, msg);

  nsTArray<BloatEntry*> entries;
  PL_HashTableEnumerateEntries(gBloatView, BloatEntry::DumpEntry, &entries);
  const uint32_t count = entries.Length();

  if (!gLogLeaksOnly || leaked) {
    // Sort the entries alphabetically by classname.
    entries.Sort();

    for (uint32_t i = 0; i < count; ++i) {
      BloatEntry* entry = entries[i];
      entry->Dump(i, gBloatLog);
    }

    fprintf(gBloatLog, "\n");
  }

  fprintf(gBloatLog, "nsTraceRefcnt::DumpStatistics: %d entries\n", count);

  if (gSerialNumbers) {
    fprintf(gBloatLog, "\nSerial Numbers of Leaked Objects:\n");
    PL_HashTableEnumerateEntries(gSerialNumbers, DumpSerialNumbers, gBloatLog);
  }

  return NS_OK;
}
示例#28
0
QSize dtkToolBoxButton::sizeHint(void) const
{
    QSize iconSize(8, 8);
    if (!this->icon().isNull()) {
        int icone = this->style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this->parentWidget() /* QToolBox */);
        iconSize += QSize(icone + 2, icone);
    }
    QSize textSize = fontMetrics().size(Qt::TextShowMnemonic, text()) + QSize(0, 8);

    QSize total(iconSize.width() + textSize.width(), qMax(iconSize.height(), textSize.height()));
    return total.expandedTo(QApplication::globalStrut());
}
示例#29
0
tile_picker::tile_picker(int X, int Y, int ID, int spec_type,
             int Scale, int scroll_h, int Wid, ifield *Next)
     : scroller(X,Y,ID,2,2,1,0,Next)
{
  wid=Wid;
  type=spec_type;
  th=scroll_h;
  scale=Scale;
  set_size(picw()*wid,pich()*th);
  sx=get_current();
  t=total();
}
示例#30
0
static ofPoint getAvgColor(ofImage img) {
    ofPoint total(0,0,0);
    int width = img.getWidth();
    int height = img.getHeight();
    ofPixels pixels = img.getPixels();
    for(int i = 0; i < width; i++) {
        for(int j = 0; j < height; j++) {
            ofColor col = pixels.getColor(i, j);
            total += ofPoint(col.r, col.g, col.b);
        }
    }
    return total / (width*height);
}