本文整理汇总了C++中boost::numeric::ublas::vector::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ vector::resize方法的具体用法?C++ vector::resize怎么用?C++ vector::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::numeric::ublas::vector
的用法示例。
在下文中一共展示了vector::resize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeNoInliersFundamental
int computeNoInliersFundamental(mat &data, mat &f, ublas::vector<bool> &inlier_mask, double &dist_std)
{
double T_DIST = 0.5;//dist>0.1 pixels = outlier might want to make it sqrt(5.99)*sigma
int num_inlier = 0;
double m_dist=0;
dist_std=0;
vec dist(data.size1());
inlier_mask.resize(data.size1());
for (int i=0;i<data.size1();i++)
inlier_mask(i)=false;
for (int i=0;i<data.size1();i++)
{
vec x1(3),x2(3);
x1(0)=data(i,0);x1(1)=data(i,1);x1(2)=1;
x2(0)=data(i,2);x2(1)=data(i,3);x2(2)=1;
dist(i) = fabs(inner_prod(prod (x2, f),x1));//x2 F x1
if (dist(i)<T_DIST)
{
num_inlier++;
inlier_mask(i)=true;
m_dist+=dist(i);
}
}
m_dist = m_dist/ num_inlier;
for (int i=0;i<data.size1();i++)
if (inlier_mask(i))
dist_std += pow(dist(i)-m_dist,2);
dist_std = dist_std/(num_inlier-1);
return num_inlier;
}
示例2: readVectorFromBinaryFile
bool readVectorFromBinaryFile(const std::string & filename, boost::numeric::ublas::vector<TYPE> & vec)
{
std::ifstream file(filename.c_str(), std::ios_base::binary);
if (!file) return false;
unsigned int size;
file.read((char*)&size, sizeof(unsigned int));
vec.resize(size);
file.read((char*)&vec[0], sizeof(TYPE)*size);
return true;
}
示例3: readVectorFromFile
bool readVectorFromFile(const std::string & filename, boost::numeric::ublas::vector<TYPE> & vec)
{
std::ifstream file(filename.c_str());
if (!file) return false;
unsigned int size;
file >> size;
vec.resize(size);
for (unsigned int i = 0; i < size; ++i)
{
TYPE element;
file >> element;
vec[i] = element;
}
return true;
}
示例4: read_vector
bool read_vector(FILE* file, boost::numeric::ublas::vector<T>& v) {
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 (count != v.size())
v.resize(count, false);
T* buffer = new T[count];
if (fread(buffer, sizeof(T), count, file) != count)
return false;
std::copy(buffer, buffer + count, v.begin());
return true;
}