当前位置: 首页>>代码示例>>C++>>正文


C++ sizes函数代码示例

本文整理汇总了C++中sizes函数的典型用法代码示例。如果您正苦于以下问题:C++ sizes函数的具体用法?C++ sizes怎么用?C++ sizes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sizes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_gemm

void test_gemm(const std::string &name, int M, int N, int K, float alpha, float beta)
{
    Halide::Buffer<int32_t> sizes(3);
    Halide::Buffer<float> params(3);
    Halide::Buffer<float> A(K, M);
    Halide::Buffer<float> B(N, K);
    Halide::Buffer<float> C(N, M);
    Halide::Buffer<float> C_ref(N, M);
    sizes(0) = M;
    sizes(1) = N;
    sizes(2) = K;
    params(0) = alpha;
    params(1) = beta;
    for (int i = 0; i < K; i++)
        for (int j = 0; j < M; j++)
            A(i, j) = std::rand() % 10 - 5;
    for (int i = 0; i < N; i++)
        for (int j = 0; j < K; j++)
            B(i, j) = std::rand() % 10 - 5;
    for (int i = 0; i < N; i++)
        for (int j = 0; j < M; j++)
            C(i, j) = std::rand() % 10 - 5;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            C_ref(i, j) = beta * C(i, j);
            for (int k = 0; k < K; k++) {
                C_ref(i, j) += alpha * A(k, j) * B(i, k);
            }
        }
    }

    test_162(sizes.raw_buffer(), params.raw_buffer(),
             A.raw_buffer(), B.raw_buffer(), C.raw_buffer());
    compare_buffers(name, C, C_ref);
}
开发者ID:rbaghdadi,项目名称:ISIR,代码行数:35,代码来源:wrapper_test_162.cpp

示例2: sizes

inline int Blob::xsize(int axis) const
{
    if (axis < -dims() || axis >= dims())
        return 1;

    return sizes()[(axis < 0) ? axis + dims() : axis];
}
开发者ID:2php,项目名称:opencv_contrib,代码行数:7,代码来源:blob.inl.hpp

示例3: QWidget

Splitter::Splitter(QWidget *parent) : QWidget(parent) {
	QHBoxLayout *hbox = new QHBoxLayout(this);

	QFrame *topleft = new QFrame(this);
	topleft->setFrameShape(QFrame::StyledPanel);

	QFrame *topright = new QFrame(this);
	topright->setFrameShape(QFrame::StyledPanel);

	QSplitter *splitter1 = new QSplitter(Qt::Horizontal, this);
	splitter1->addWidget(topleft);
	splitter1->addWidget(topright);

	QFrame *bottom = new QFrame(this);
	bottom->setFrameShape(QFrame::StyledPanel);

	QSplitter *splitter2 = new QSplitter(Qt::Vertical, this);
	splitter2->addWidget(splitter1);
	splitter2->addWidget(bottom);

	QList<int> sizes({50, 100});
	splitter2->setSizes(sizes);

	hbox->addWidget(splitter2);
}
开发者ID:pwarnimo,项目名称:misc_projects,代码行数:25,代码来源:splitter.cpp

示例4: sizes

int
Splitter::getRightChildrenSize() const
{
    QList<int> list = sizes();
    assert(list.size() == 2);
    return list.back();
}
开发者ID:kcotugno,项目名称:Natron,代码行数:7,代码来源:Splitter.cpp

示例5: sf_out

void sf_out(sf_file out        /* output file */, 
	    int axis           /* join axis */,
	    const char *iname  /* name of the input file */)
/*< prepare output >*/
{
    char *oname, cmdline[SF_CMDLEN];
    int ndim;
    off_t n[SF_MAX_DIM];
    sf_file inp;
    FILE *ofile=NULL;

    ofile = sf_tempfile(&oname,"w+b");
    fclose(ofile);

    snprintf(cmdline,SF_CMDLEN,"%s %s --dryrun=y < %s > %s",
	     command,splitcommand,iname,oname);
    sf_system(cmdline);
    
    inp = sf_input(oname);
    ndim = sf_largefiledims (inp,n);
    
    if (axis > ndim) axis=ndim;

    snprintf(nkey,5,"n%d",axis);
    axis--;
    sizes(inp,axis,ndim,n,&size1,&size2);
    
    sf_setformat(out,sf_histstring(inp,"data_format"));
    sf_fileflush(out,inp);
    
    sf_setform(out,SF_NATIVE);
    sf_rm(oname,true,false,false);
}
开发者ID:housian0724,项目名称:src,代码行数:33,代码来源:parallel.c

示例6: sizes

void Desktopwidget::closing (void)
   {
   QList<int> size = sizes ();

   setSettingsSizes ("desktopwidget/", size);
   _page->closing ();
   }
开发者ID:sglass68,项目名称:paperman,代码行数:7,代码来源:desktopwidget.cpp

示例7: qDebug

void AnimatedSplitter::setActiveWidgetWidth(int width)
{
	if (mActiveIndex >=0 && mActiveIndex < count()) {
		qDebug() << "w" << width;
		// We have to explicitly redistribute the sizes, otherwise
		// any additional/missing space is distributed amongst the widgets
		// according to the relative weight of the sizes. see. setSizes() documentation
		QList<int> sz(sizes());
		int delta = width - sz.at(mActiveIndex);  // < 0 for shrinking
		if (mActiveIndex < count()-1 && sz.at(mActiveIndex+1) > delta) {
			// take place from right
			sz.replace(mActiveIndex, width);
			sz.replace(mActiveIndex+1, sz.at(mActiveIndex+1) - delta);
		} else if (mActiveIndex > 0 && sz.at(mActiveIndex-1) > delta) {
			// take place from left
			sz.replace(mActiveIndex, width);
			sz.replace(mActiveIndex-1, sz.at(mActiveIndex-1) - delta);
		} else {
			// fallback:
			// TODO: the widget likely will not have the final width "width", because of space redistribution
			sz.replace(mActiveIndex, width);
			qDebug() << "AnimatedSplitter fallback: no cannot take space from adjacent widgets";
		}
		setSizes(sz);
	}
}
开发者ID:svn2github,项目名称:texstudio,代码行数:26,代码来源:animatedsplitter.cpp

示例8: sizes

void BarChartWidget::drawBars(QPainter &painter) {
    std::vector<int> sizes(BAR_COUNT, 0);
    fillSizes(sizes);

    QRect baseRectangle = rect();
    int activeWidth = (int) std::floor( baseRectangle.width() * (1 - 2 * PADDING) );
    int singleBarWidth = (int) std::floor((activeWidth - (BAR_COUNT + 1) * SPACING) / BAR_COUNT);

    int baseLineY = (int) std::floor(baseRectangle.bottom() - PADDING_BOTTOM);
    int currX = (int) std::floor(baseRectangle.left() + baseRectangle.width() * PADDING);

    currX += SPACING;
    for (int i = 0; i < BAR_COUNT; i++) {
        QPoint pointTopLeft(currX, baseLineY - sizes.at((unsigned long) i));
        QPoint pointBottomRight(currX + singleBarWidth, baseLineY - 1);
        QRect bar(pointTopLeft, pointBottomRight);
        painter.setPen(mainColor);
        painter.drawRect(bar);
        painter.fillRect(bar, barColor);

        QPoint textTopLeft(currX, baseLineY);
        QPoint textBottomRight(currX + singleBarWidth, baseRectangle.bottom());
        QRect textRect(textTopLeft, textBottomRight);
        painter.setPen(mainColor);
        painter.drawText(textRect, Qt::AlignCenter, labels->at((unsigned long) i));
        
        QPoint valueTopLeft(currX, baseLineY - sizes.at((unsigned long) i) - VALUE_LABEL_HEIGHT);
        QPoint valueBottomRight(currX + singleBarWidth, baseLineY);
        QRect valueLabelRect(valueTopLeft, valueBottomRight);
        QString textValue = QString::number(values->at((unsigned long) i));
        painter.drawText(valueLabelRect, Qt::AlignHCenter | Qt::AlignTop, textValue);
        
        currX += singleBarWidth + SPACING;
    }
}
开发者ID:ivanBobrov,项目名称:LabCodes,代码行数:35,代码来源:BarChartWidget.cpp

示例9: sizes

std::array<uint64_t, 3> nrrd_impl::dimensions() {
  std::istringstream sizes(this->value("sizes"));
  std::array<uint64_t, 3> dims;

  sizes >> dims[0] >> dims[1] >> dims[2];
  return dims;
}
开发者ID:tfogal,项目名称:filtering,代码行数:7,代码来源:f-nrrd.cpp

示例10: main

int main(int argc,char* argv[]){
    // Create some type shortcuts
    typedef Optizelle::Rm <double> X;
    typedef Optizelle::SQL <double> Z;
    typedef X::Vector X_Vector;
    typedef Z::Vector Z_Vector;

    // Read in the name for the input file
    if(argc!=2) {
        std::cerr << "simple_quadratic_cone <parameters>" << std::endl;
        exit(EXIT_FAILURE);
    }
    std::string fname(argv[1]);

    // Generate an initial guess for the primal
    X_Vector x(2);
    x[0]=1.2; x[1]=3.1;

    // Generate an initial guess for the dual
    std::vector <Optizelle::Natural> sizes(1);
        sizes[0]=2;
    std::vector <Optizelle::Cone::t> types(1);
        types[0]=Optizelle::Cone::Quadratic;
    Z_Vector z(types,sizes);

    // Create an optimization state
    Optizelle::InequalityConstrained <double,Optizelle::Rm,Optizelle::SQL>
        ::State::t state(x,z);

    // Read the parameters from file
    Optizelle::json::InequalityConstrained <double,Optizelle::Rm,Optizelle::SQL>
        ::read(Optizelle::Messaging(),fname,state);
    
    // Create a bundle of functions
    Optizelle::InequalityConstrained<double,Optizelle::Rm,Optizelle::SQL>
        ::Functions::t fns;
    fns.f.reset(new MyObj);
    fns.h.reset(new MyIneq);

    // Solve the optimization problem
    Optizelle::InequalityConstrained <double,Optizelle::Rm,Optizelle::SQL>
        ::Algorithms::getMin(Optizelle::Messaging(),fns,state);

    // Print out the reason for convergence
    std::cout << "The algorithm converged due to: " <<
        Optizelle::StoppingCondition::to_string(state.opt_stop) << std::endl;

    // Print out the final answer
    std::cout << std::setprecision(16) << std::scientific 
        << "The optimal point is: (" << state.x[0] << ','
	<< state.x[1] << ')' << std::endl;

    // Write out the final answer to file
    Optizelle::json::InequalityConstrained <double,Optizelle::Rm,Optizelle::SQL>
        ::write_restart(Optizelle::Messaging(),"solution.json",state);

    // Successful termination
    return EXIT_SUCCESS;
}
开发者ID:Dapid,项目名称:Optizelle,代码行数:59,代码来源:simple_quadratic_cone.cpp

示例11: unsqueezeN

// Unsqueezes src `before` times at the front and `after` times at the end
static Tensor unsqueezeN(const Tensor & src, int64_t before, int64_t after) {
  auto srcSizes = src.sizes();
  auto nDim = src.dim();
  std::vector<int64_t> sizes(nDim + before + after, 1);
  for (int64_t i = 0; i < nDim; i++) {
    sizes[i + before] = srcSizes[i];
  }
  return src.view(sizes);
}
开发者ID:HustlehardInc,项目名称:pytorch,代码行数:10,代码来源:Indexing.cpp

示例12: sizes

/**
 * Returns number of synapses formed.
 * Fills it in transpose form, because we need to count and index the 
 * number of synapses on the target, so we need to iterate over the sources
 * in the inner loop. Once full, does the transpose.
 * Should really have a seed argument for the random number.
 * Later need a way to fast-forward mtrand to just the entries we
 * need to fill.
 */
unsigned int SparseMsg::randomConnect( double probability )
{
	unsigned int nRows = matrix_.nRows(); // Sources
	unsigned int nCols = matrix_.nColumns();	// Destinations
	matrix_.clear();
	unsigned int totalSynapses = 0;
	vector< unsigned int > sizes( nCols, 0 );
	unsigned int totSynNum = 0;
	Element* syn = e2_;
	unsigned int startData = syn->localDataStart();
	unsigned int endData = startData + syn->numLocalData();

	assert( nCols == syn->numData() );

	matrix_.transpose();
	for ( unsigned int i = 0; i < nCols; ++i ) {
		vector< unsigned int > synIndex;
		// This needs to be obtained from current size of syn array.
		// unsigned int synNum = sizes[ i ];
		unsigned int synNum = 0;
		for ( unsigned int j = 0; j < nRows; ++j ) {
			double r = mtrand(); // Want to ensure it is called each time round the loop.
			if ( r < probability ) {
				synIndex.push_back( synNum );
				++synNum;
				++totSynNum;
			} else {
				synIndex.push_back( ~0 );
			}
		}
			
		if ( i >= startData && i < endData ) {
			e2_->resizeField( i - startData, synNum );
		}
			totalSynapses += synNum;
			matrix_.addRow( i, synIndex );
		/*
		 * This is the correct form, but I need to implement something
		 * to check up for target nodes in order to use this.
		if ( i >= startData && i < endData ) {
			e2_->resizeField( i - startData, synNum );
			totalSynapses += synNum;
			matrix_.addRow( i, synIndex );
		} else {
			synIndex.resize( 0 );
			synIndex.assign( nRows, ~0 );
			matrix_.addRow( i, synIndex );
		}
		*/
	}

	matrix_.transpose();
	// cout << Shell::myNode() << ": sizes.size() = " << sizes.size() << ", ncols = " << nCols << ", startSynapse = " << startSynapse << endl;
	e1()->markRewired();
	e2()->markRewired();
	return totalSynapses;
}
开发者ID:subhacom,项目名称:moose-core,代码行数:66,代码来源:SparseMsg.cpp

示例13:

 bool Kernel::NDRange::divisible (NDRange& range) const {
     if (range.dims() != dims())
         return false;
         
     for (int i = 0; i < dims(); i++)
         if (sizes()[i] % range.sizes()[i] != 0)
             return false;
             
     return true;
 }
开发者ID:lochotzke,项目名称:OpenCLWrapper,代码行数:10,代码来源:Kernel.cpp

示例14: main

int main()
{
	sizes();

	{
		A* pB = new B;
		delete pB;
	}
	std::cin.get();
	return 0;
}
开发者ID:Silent77,项目名称:straustrup_solutions,代码行数:11,代码来源:sizes.cpp

示例15: main

int main()
{
  char ch = 'a';
  int i = 100;
  int* p;
  *p = 10;
  bool b = true;
  double d = 10.0;

  sizes(ch, i, p, b, d);
}
开发者ID:fanqo,项目名称:PPPCpp,代码行数:11,代码来源:01.cpp


注:本文中的sizes函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。