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


C++ matrix::resize方法代码示例

本文整理汇总了C++中boost::numeric::ublas::matrix::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ matrix::resize方法的具体用法?C++ matrix::resize怎么用?C++ matrix::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost::numeric::ublas::matrix的用法示例。


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

示例1: setTrajectoryKeyPosition

void setTrajectoryKeyPosition(double * trajectoryKeyPositions, int * size1, int * size2)
{
  if (TRAJECTORYKEYPOSITIONS.size1()*TRAJECTORYKEYPOSITIONS.size2() != 0)
  {
    std::cout << "You are reinitializing TrajectoryKeyPositions...\n" ;
    TRAJECTORYKEYPOSITIONS.resize(0, 0);
  }

  TRAJECTORYKEYPOSITIONS.resize(*size1, *size2);
  for (int i = 0; i < *size1 * (*size2); i++)
    TRAJECTORYKEYPOSITIONS(i % (*size1), i / (*size1)) = trajectoryKeyPositions[i];
}
开发者ID:radarsat1,项目名称:siconos,代码行数:12,代码来源:ActuationModelSomeDefinitions.cpp

示例2: similarity

	void similarity(
		const orca::Orca &oa,
		const orca::Orca &ob,
		boost::numeric::ublas::matrix<float> &sim
	) {
		if(oa.graphletSize() != ob.graphletSize()) {
			throw std::invalid_argument("Orca instances now of same size");
		}
		int graphlet_size = oa.graphletSize();
		const size_t orbits = orca::ORBITS[graphlet_size];
		const size_t na = oa.getOrbits().size1();
		const size_t nb = ob.getOrbits().size1();

		std::vector<float> weights(orbits);
		if(orbits > 1) {
			for(size_t k = 0; k < orbits; ++k) {
				weights[k] = 1.0f - log(AFFECTED[k]) / log(orbits);
			}
		} else {
			weights[0] = 1.0f;
		}
		float weights_sum = std::accumulate(weights.begin(), weights.end(), 0.0f);

		sim.resize(na, nb);

		for(size_t i = 0; i < na; ++i) {
			for(size_t j = 0; j < nb; ++j) {
				float D = 0.0f;
				for(size_t k = 0; k < orbits; ++k) {
					int64_t aik = oa.getOrbits()(i, k);
					int64_t bjk = ob.getOrbits()(j, k);

					float num = fabs(log(aik + 1.0f) - log(bjk + 1.0f));
					float denom = log(std::max(aik, bjk) + 2.0f);
					D += weights[k] * num / denom;
				}

				sim(i, j) = 1.0f - D / weights_sum;
			}
		}
	}
开发者ID:SimonLarsen,项目名称:libgraphlet,代码行数:41,代码来源:Similarity.cpp

示例3: read_matrix

bool read_matrix(FILE* file, boost::numeric::ublas::matrix<T, boost::numeric::ublas::column_major>& m) {
  unsigned magic, rowCount, columnCount;
  if (fread(&magic, sizeof(unsigned), 1, file) != 1)
    return false;
  if (!check_magic<T>(magic))
    return false;

  if (fread(&rowCount, sizeof(unsigned), 1, file) != 1)
    return false;
  if (fread(&columnCount, sizeof(unsigned), 1, file) != 1)
    return false;

  const unsigned count = rowCount * columnCount;
  if (rowCount != m.size1() || columnCount != m.size2())
    m.resize(rowCount, columnCount, false);
  T* buffer = new T[count];
  if (fread(buffer, sizeof(T), count, file) != count)
    return false;

  std::copy(buffer, buffer + count, m.data().begin());

  return true;
}
开发者ID:e-thereal,项目名称:gapputils,代码行数:23,代码来源:ublas_io.hpp

示例4: getReactionMatrix

void  getReactionMatrix(std::vector<std::string> vsSimpleReactions,std::map<std::string,int> mSpecies, ublas::matrix<int>& mNmatrix)
{//   std::vector< std::vector<int> > vviMatrix;

// ublas::matrix<int> cN(mSpecies.size(),vsSimpleReactions.size());
    
    mNmatrix.resize(mSpecies.size(),vsSimpleReactions.size());
    
    std::vector<int> viReactionVector;

    std::cout << " Matrix size is " << mNmatrix.size1() << "," << mNmatrix.size2() << std::endl;

    fillVector(viReactionVector,0,mSpecies.size());

    for(int i=0;i<vsSimpleReactions.size();i++)
    {
        
        std::cout << " For reaction " << vsSimpleReactions[i] << std::endl;
        
        function(vsSimpleReactions[i],mSpecies,viReactionVector);
        //     vviMatrix.push_back(viReactionVector);
        insertVectorToMatrix(mNmatrix,i,viReactionVector);
        //     function(vsSimpleReactions,mSpecies,viReactionVector);  
    }
}
开发者ID:Daniel-M,项目名称:cppBioCheN,代码行数:24,代码来源:test.cpp

示例5: resize

 static void resize( boost::numeric::ublas::matrix< T , L , A > &m ,
                     const boost::numeric::ublas::vector< T_V , A_V > &v )
 {
     m.resize( v.size() , v.size() );
 }
开发者ID:imos,项目名称:icfpc2015,代码行数:5,代码来源:ublas_wrapper.hpp


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