本文整理汇总了C++中MatrixXi::size方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixXi::size方法的具体用法?C++ MatrixXi::size怎么用?C++ MatrixXi::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatrixXi
的用法示例。
在下文中一共展示了MatrixXi::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: configure
void NeighbourJoining::configure(const MatrixXf& D, MatrixXf& currentD, MatrixXi& rowsID, int numOccupiedNodes) {
numObservableNodes = rowsID.rows();
numCurrentNodes = numObservableNodes;
//allocates memory for the latent nodes
rowsID.conservativeResize((2 * numObservableNodes - 2), 1);
//gives latent nodes IDs
for (int i = numObservableNodes; i < 2 * numObservableNodes - 2; ++i) {
rowsID(i) = i + numOccupiedNodes;
}
sort(rowsID.data(), rowsID.data() + rowsID.size());
//cout << "rowsID after sort:" << rowsID.transpose(); cout << endl;
//copies distances of selected Nodes
int offseti = 0; int offsetj = 0;
for (int i = 0; i < numObservableNodes; ++i) {
while (rowsID(i) != i + offseti)
++offseti;
offsetj = 0;
for (int j = 0; j < numObservableNodes; ++j) {
while (rowsID(j) != j + offsetj)
++offsetj;
currentD(i, j) = D(i + offseti, j + offsetj);
currentD(j, i) = currentD(i, j);
}
}
//cout << "copied matrix: " << endl; printMatrix(currentD);
}
示例2: load_mesh_from_file
// Read a surface mesh from a {.obj|.off|.mesh} files
// Inputs:
// mesh_filename path to {.obj|.off|.mesh} file
// Outputs:
// V #V by 3 list of mesh vertex positions
// F #F by 3 list of triangle indices
// Returns true only if successfuly able to read file
bool load_mesh_from_file(
const std::string mesh_filename,
Eigen::MatrixXd & V,
Eigen::MatrixXi & F)
{
using namespace std;
using namespace igl;
using namespace Eigen;
string dirname, basename, extension, filename;
pathinfo(mesh_filename,dirname,basename,extension,filename);
transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
bool success = false;
if(extension == "obj")
{
success = readOBJ(mesh_filename,V,F);
}else if(extension == "off")
{
success = readOFF(mesh_filename,V,F);
}else if(extension == "mesh")
{
// Unused Tets read from .mesh file
MatrixXi Tets;
success = readMESH(mesh_filename,V,Tets,F);
// We're not going to use any input tets. Only the surface
if(Tets.size() > 0 && F.size() == 0)
{
// If Tets read, but no faces then use surface of tet volume
}else
{
// Rearrange vertices so that faces come first
VectorXi IM;
faces_first(V,F,IM);
// Dont' bother reordering Tets, but this is how one would:
//Tets =
// Tets.unaryExpr(bind1st(mem_fun( static_cast<VectorXi::Scalar&
// (VectorXi::*)(VectorXi::Index)>(&VectorXi::operator())),
// &IM)).eval();
// Don't throw away any interior vertices, since user may want weights
// there
}
}else
{
cerr<<"Error: Unknown shape file format extension: ."<<extension<<endl;
return false;
}
return success;
}
示例3: GenerateXapv
MatrixXf CharacterController::GenerateXapv(const std::vector<int> &activeParts)
{
// pvDim without
auto& allClipinfo = m_cpxClipinfo;
auto& pvFacade = allClipinfo.PvFacade;
int pvDim = pvFacade.GetAllPartDimension();
assert(pvDim > 0);
MatrixXf Xabpv(allClipinfo.ClipFrames(), size(activeParts) * pvDim);
ArrayXi incX(pvDim);
incX.setLinSpaced(0, pvDim - 1);
MatrixXi apMask = VectorXi::Map(activeParts.data(), activeParts.size()).replicate(1, pvDim).transpose();
apMask.array() = apMask.array() * pvDim + incX.replicate(1, apMask.cols());
auto maskVec = VectorXi::Map(apMask.data(), apMask.size());
selectCols(pvFacade.GetAllPartsSequence(), maskVec, &Xabpv);
Pca<MatrixXf> pcaXabpv(Xabpv);
int dXabpv = pcaXabpv.reducedRank(g_CharacterPcaCutoff);
Xabpv = pcaXabpv.coordinates(dXabpv);
XabpvT = pcaXabpv.components(dXabpv);
uXabpv = pcaXabpv.mean();
if (g_EnableDebugLogging)
{
ofstream fout(g_CharacterAnalyzeDir / (m_pCharacter->Name + "_Xabpv.pd.csv"));
fout << Xabpv.format(CSVFormat);
fout.close();
}
return Xabpv;
}
示例4: srs
//.........这里部分代码省略.........
}
}
for (auto c = 0; c < m_numCols; ++c)
{
for (auto r = 0; r < m_numRows; r += std::ceil(m_cutNet/m_cellSize))
{
isNetCell(r, c) = 1;
}
}
for (auto c = 0; c < m_numCols; ++c)
{
for (auto r = 0; r < m_numRows; ++r)
{
if (isNetCell(r, c)==1)
ZInet(r, c) = bigOpen(r, c);
}
}
}
// and finally object detection
MatrixXi Obj = progressiveFilter(ZInet, m_cellSize, m_percentSlope, m_maxWindow);
// STEP 3:
// The end result of the iteration process described above is a binary grid
// where each cell is classified as being either bare earth (BE) or object
// (OBJ). The algorithm then applies this mask to the starting minimum
// surface to eliminate nonground cells. These cells are then inpainted
// according to the same process described previously, producing a
// provisional DEM (ZIpro).
// we currently aren't checking for net cells or empty cells (haven't i already marked empty cells as NaNs?)
MatrixXd ZIpro = ZImin;
for (int i = 0; i < Obj.size(); ++i)
{
if (Obj(i) == 1 || Low(i) == 1 || isNetCell(i) == 1)
ZIpro(i) = std::numeric_limits<double>::quiet_NaN();
}
// MatrixXd ZIpro_painted = inpaintKnn(cx, cy, ZIpro);
// MatrixXd ZIpro_painted = TPS(cx, cy, ZIpro);
MatrixXd ZIpro_painted = expandingTPS(cx, cy, ZIpro);
if (!m_outDir.empty())
{
std::string filename = FileUtils::toAbsolutePath("zilow.tif", m_outDir);
eigen::writeMatrix(Low.cast<double>(), filename, "GTiff", m_cellSize, bounds, srs);
filename = FileUtils::toAbsolutePath("zinet.tif", m_outDir);
eigen::writeMatrix(ZInet, filename, "GTiff", m_cellSize, bounds, srs);
filename = FileUtils::toAbsolutePath("ziobj.tif", m_outDir);
eigen::writeMatrix(Obj.cast<double>(), filename, "GTiff", m_cellSize, bounds, srs);
filename = FileUtils::toAbsolutePath("zipro.tif", m_outDir);
eigen::writeMatrix(ZIpro, filename, "GTiff", m_cellSize, bounds, srs);
filename = FileUtils::toAbsolutePath("zipro_painted.tif", m_outDir);
eigen::writeMatrix(ZIpro_painted, filename, "GTiff", m_cellSize, bounds, srs);
}
ZIpro = ZIpro_painted;
// STEP 4:
// The final step of the algorithm is the identification of ground/object
示例5: CreateSimpleMesh
void Mesh::CreateSimpleMesh() {
int c = 0;
MatrixXi g(n_node_x, n_node_y);
for (size_t i=0; i<n_node_x; i++) {
for (size_t j=0; j<n_node_y; j++) {
g(i,j) = c;
c++;
}
}
MatrixXi gg(n_node_p_elem, n_elem);
size_t xi = 0;
size_t xj = 0;
for (size_t i=0; i<n_elem; i++) {
size_t xi_min = xi;
size_t xj_min = xj;
size_t xi_max = xi + n_node_p_dim;
size_t xj_max = xj + n_node_p_dim;
MatrixXi block =
g.block(xi_min, xj_min, n_node_p_dim, n_node_p_dim);
Map<VectorXi> gv(block.data(), block.size());
gg.col(i) = gv;
if (xi_max == n_node_x) {
xi = 0;
xj = xj_max - 1;
} else {
xi = xi_max - 1;
}
}
c = 0;
MatrixXi nf(eqn_p_node, n_node);
for (size_t i=0; i<n_node; i++) {
nf(0,i) = c;
nf(1,i) = c+1;
c += 2;
}
imap.resize(n_dof_p_elem, n_elem);
for (size_t i=0; i<n_elem; i++) {
c = 0;
while (c+eqn_p_node <= n_dof_p_elem) {
imap.block(c, i, eqn_p_node, 1) =
nf.block(
0, gg(c/eqn_p_node, i), eqn_p_node, 1);
c += eqn_p_node;
}
}
valen.resize(n_dof_p_elem, n_elem);
valen.setZero();
for (size_t i=0; i<n_elem; i++) {
for (size_t j=0; j<n_dof_p_elem; j++) {
valen(j, i) += 1;
}
}
size_t k = 0;
size_t e = 0;
size_t n_node_x_vis {n_elem_x + 1};
connec.resize(4*n_elem);
for (size_t j=0; j<n_elem_y; j++) {
for (size_t i=0; i<n_elem_x; i++) {
connec(k+0) = (i+0) + (j+0) * n_node_x_vis;
connec(k+1) = (i+1) + (j+0) * n_node_x_vis;
connec(k+2) = (i+1) + (j+1) * n_node_x_vis;
connec(k+3) = (i+0) + (j+1) * n_node_x_vis;
k+=4;
e++;
}
}
connec = connec.array() + 1;
n_vis_node = connec.maxCoeff();
k = 0;
ex.resize(n_vis_node);
ey.resize(n_vis_node);
m_node_n.resize(n_vis_node);
for (size_t j=0; j<=n_elem_y; j++) {
for (size_t i=0; i<=n_elem_x; i++) {
ex(k) = i * s_elem_x;
ey(k) = j * s_elem_y;
m_node_n(k) = k;
k++;
}
}
m_node_n = m_node_n.array() + 1;
ctr_elem_x.resize(n_elem);
ctr_elem_y.resize(n_elem);
k = 0;
for (size_t j=0; j<n_elem_y; j++) {
for (size_t i=0; i<n_elem_x; i++) {
ctr_elem_x(k) = (1/2.) * (ex(k) + ex(k+1));
ctr_elem_y(k) = (1/2.) * (ey(k) + ey(k+1));
//.........这里部分代码省略.........