• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sizes函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: l

QString
Splitter::serializeNatron() const
{
    QMutexLocker l(&_lock);

    QList<int> list = sizes();
    if (list.size() == 2) {
        return QString::fromUtf8("%1 %2").arg(list[0]).arg(list[1]);
    }

    return QString();
}
开发者ID:kcotugno,项目名称:Natron,代码行数:12,代码来源:Splitter.cpp


示例17: SYNC

  void InlineCacheRegistry::print_stats(STATE) {
    SYNC(state);
    int total = 0;
    std::vector<int> sizes(cTrackedICHits + 1);

    int overflow = 0;

    for(CacheHash::iterator hi = caches_.begin();
        hi != caches_.end();
        ++hi) {
      for(CacheVector::iterator vi = hi->second.begin();
          vi != hi->second.end();
          ++vi) {
        InlineCache* ic = *vi;
        int seen = ic->classes_seen();
        if(ic->seen_classes_overflow() > 0) {
          total++;
          overflow++;
        } else if(seen > 0) {
          total++;
          sizes[seen]++;
        }
      }
    }

    std::cerr << "IC Stats:\n";
    for(int i = 1; i < cTrackedICHits + 1; i++) {
      std::cerr << " " << i << ": " << sizes[i] << " "
                << ratio(sizes[i], total) << "%\n";
    }

    std::cerr << cTrackedICHits << "+: " << overflow << " "
              << ratio(overflow, total) << "%\n";

    // print out the mega-morphic ones
    std::cerr << "\nMegamorphic call sites:\n";

    for(CacheHash::iterator hi = caches_.begin();
        hi != caches_.end();
        ++hi) {
      for(CacheVector::iterator vi = hi->second.begin();
          vi != hi->second.end();
          ++vi) {
        InlineCache* ic = *vi;
        if(ic->seen_classes_overflow() > 0) {
          ic->print(state, std::cerr);
          std::cerr << "location: ";
          ic->print_location(state, std::cerr);
          std::cerr << "\n\n";
        }
      }
    }
  }
开发者ID:ConradIrwin,项目名称:rubinius,代码行数:53,代码来源:inline_cache.cpp


示例18: sizes

void AutohidingSplitter::setAutoHideEnabled(bool ah)
{
    if (ah==autoHideEnabled) {
        return;
    }

    autoHideEnabled=ah;
    if (autoHideEnabled) {
        expandedSizes = sizes();
        connect(this, SIGNAL(splitterMoved(int, int)), this, SLOT(updateAfterSplitterMoved(int, int)));
    } else {
        for(int i = 0; i < widgetAutohidden.count() ; ++i) {
开发者ID:padertux,项目名称:cantata,代码行数:12,代码来源:autohidingsplitter.cpp


示例19: resColor

void TraceGfx::DoRender(graph::Engine& engine)
{
	//Отрисовка путей
	for (Trace::Points::const_iterator iter = _trace->GetPoints().begin(); iter != _trace->GetPoints().end(); ++iter)
	{
		_libMat->material.SetDiffuse(*iter == _selPoint ? clrGreen : clrRed);

		_wayPnt->SetPos((*iter)->GetPos());
		_wayPnt->SetScale((*iter)->GetSize());			
		_wayPnt->Render(engine);		
	}

	//Отрисовка связей между путями
	Vec3Range resColor(D3DXVECTOR3(clrWhite / 2.0f), D3DXVECTOR3(clrWhite), Vec3Range::vdVolume);
	D3DXVECTOR3 upVec = engine.GetContext().GetCamera().GetDesc().dir;
	float iPath = 0.0f;
	float pathCnt = static_cast<float>(_trace->GetPathes().size());
	
	for (Trace::Pathes::const_iterator iter = _trace->GetPathes().begin(); iter != _trace->GetPathes().end(); ++iter, ++iPath)
	{
		WayPath* path = *iter;
		D3DXCOLOR pathColor = path == _selPath ? clrGreen : D3DXCOLOR(resColor.GetValue(iPath / (pathCnt - 1.0f)));
		res::VertexData vBuf;
		path->GetTriStripVBuf(vBuf, &upVec);
		if (vBuf.IsInit())
			DrawNodes(engine, vBuf.begin().Pos3(), vBuf.GetVertexCount() - 2, pathColor);
	}

	//Для выделенного узла свой цикл отрисовки
	if (_selNode && _selNode->GetNext())
	{
		D3DXVECTOR3 vBuf[4];
		_selNode->GetTile().GetVBuf(vBuf, 4, &upVec);
		DrawNodes(engine, vBuf, 4 - 2, clrGreen);
	}

	//Отрисовка связи выделения
	if (_pointLink)
	{
		D3DXVECTOR3 pos1 = _pointLink->GetPoint()->GetPos();
		D3DXVECTOR3 pos2 = _pointLink->GetPos();
		D3DXVECTOR3 dir = pos1 - pos2;
		D3DXVECTOR2 sizes(D3DXVec3Length(&dir), _pointLink->GetPoint()->GetSize());
		D3DXVec3Normalize(&dir, &dir);

		_sprite->SetPos((pos1 + pos2) / 2.0f);
		_sprite->SetDir(dir);
		_sprite->sizes = sizes;

		_libMat->material.SetDiffuse(clrGreen);
		_sprite->Render(engine);
	}
}
开发者ID:DimaKirk,项目名称:rrr3d,代码行数:53,代码来源:TraceGfx.cpp


示例20: CORRADE_ASSERT

bool Shader::compile() {
    CORRADE_ASSERT(sources.size() > 1, "Shader::compile(): no files added", false);

    /* Array of source string pointers and their lengths */
    /** @todo Use `Containers::ArrayTuple` to avoid one allocation if it ever
        gets to be implemented (we need properly aligned memory too) */
    Containers::Array<const GLchar*> pointers(sources.size());
    Containers::Array<GLint> sizes(sources.size());
    for(std::size_t i = 0; i != sources.size(); ++i) {
        pointers[i] = static_cast<const GLchar*>(sources[i].data());
        sizes[i] = sources[i].size();
    }

    /* Create shader and set its source */
    glShaderSource(_id, sources.size(), pointers, sizes);

    /* Compile shader */
    glCompileShader(_id);

    /* Check compilation status */
    GLint success, logLength;
    glGetShaderiv(_id, GL_COMPILE_STATUS, &success);
    glGetShaderiv(_id, GL_INFO_LOG_LENGTH, &logLength);

    /* Error or warning message. The string is returned null-terminated, scrap
       the \0 at the end afterwards */
    std::string message(logLength, '\0');
    if(message.size() > 1)
        glGetShaderInfoLog(_id, message.size(), nullptr, &message[0]);
    message.resize(std::max(logLength, 1)-1);

    /* Show error log */
    if(!success) {
        Error out;
        out.setFlag(Debug::NewLineAtTheEnd, false);
        out.setFlag(Debug::SpaceAfterEachValue, false);
        out << "Shader: " << shaderName(_type)
            << " shader failed to compile with the following message:\n"
            << message;

    /* Or just message, if any */
    } else if(!message.empty()) {
        Error out;
        out.setFlag(Debug::NewLineAtTheEnd, false);
        out.setFlag(Debug::SpaceAfterEachValue, false);
        out << "Shader: " << shaderName(_type)
            << " shader was successfully compiled with the following message:\n"
            << message;
    }

    return success;
}
开发者ID:ArEnSc,项目名称:magnum,代码行数:52,代码来源:Shader.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sizeudata函数代码示例发布时间:2022-05-30
下一篇:
C++ sizeof_array函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap