本文整理汇总了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];
}
示例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;
}
}
}
示例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;
}
示例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);
}
}
示例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() );
}