本文整理汇总了C++中eigen::SparseMatrix::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ SparseMatrix::insert方法的具体用法?C++ SparseMatrix::insert怎么用?C++ SparseMatrix::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eigen::SparseMatrix
的用法示例。
在下文中一共展示了SparseMatrix::insert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeLaplacianOperator
void LaplacianOperator::computeLaplacianOperator( Eigen::SparseMatrix<double>& laplacianOperator )
{
laplacianOperator.resize(mMeshVertexCount,mMeshVertexCount);
laplacianOperator.reserve(Eigen::VectorXi::Constant(mMeshVertexCount,10));
for (int i = 0; i < mMeshVertexCount; i++)
{
/* 如果第i个点没有邻接点,即它是一个孤立的点,那么它的laplacian坐标为0 */
if( adjacentMatrix.innerVector(i).nonZeros() == 0)
{
laplacianOperator.insert(i,i) = 0;
continue;
}
laplacianOperator.insert(i,i) = 1;
#ifdef MY_DEBUG
int adjCount = 0;
#endif
for (Eigen::SparseMatrix<double>::InnerIterator it(adjacentMatrix,i); it; it++)
{
if(i != it.row())
{
laplacianOperator.insert(i,it.row()) = -1/degreeMatrix(i);
#ifdef MY_DEBUG
adjCount++;
if(adjCount >= 10)
printf("InnerVector size should expand! CurrentMax:%d.\n",adjCount);
#endif
}
}
}
}
示例2: Create_spMat_U
void LTransform::Create_spMat_U(Eigen::SparseMatrix<double> &spMat_U){
//*****************************
//2015-06-29 TYPE=Notes
//*****************************
//求解笛卡尔坐标;2.构建控制点矩阵spMat_U;
//*****************************
//spMat_U=spMat_V;
//*****************************
qDebug() <<"START:spMat_U.insert"<< endl;
for(int i=0;i<LMT_point.size();i++){
spMat_U.insert(LMT_point[i].index,0)=LMT_point[i].X;
spMat_U.insert(LMT_point[i].index,1)=LMT_point[i].Y;
spMat_U.insert(LMT_point[i].index,2)=LMT_point[i].Z;
}
for (int k=0; k<spMat_V.outerSize(); ++k)
for (Eigen::SparseMatrix<double>::InnerIterator it(spMat_V,k); it; ++it){
if(!objMesh.is_limitP(LMT_point,it.row())){
spMat_U.insert(it.row(),it.col())=it.value();
}
}
qDebug() <<"END:spMat_U.insert"<< endl;
}//控制点坐标矩阵;
示例3: fill
inline void fill(Eigen::SparseMatrix<T, options> & m,
std::size_t row_index,
std::size_t col_index,
SCALARTYPE value
)
{
m.insert(row_index, col_index) = value;
}
示例4: speye
IGL_INLINE void igl::speye(const int m, const int n, Eigen::SparseMatrix<T> & I)
{
// size of diagonal
int d = (m<n?m:n);
I = Eigen::SparseMatrix<T>(m,n);
I.reserve(d);
for(int i = 0;i<d;i++)
{
I.insert(i,i) = 1.0;
}
I.finalize();
}
示例5: serialization_test
void serialization_test()
{
std::string file("test");
bool tbIn = true,tbOut;
char tcIn = 't',tcOut;
unsigned char tucIn = 'u',tucOut;
short tsIn = 6,tsOut;
int tiIn = -10,tiOut;
unsigned int tuiIn = 10,tuiOut;
float tfIn = 1.0005,tfOut;
double tdIn = 1.000000005,tdOut;
int* tinpIn = NULL,*tinpOut = NULL;
float* tfpIn = new float,*tfpOut = NULL;
*tfpIn = 1.11101;
std::string tstrIn("test12345"),tstrOut;
Test2 tObjIn,tObjOut;
int ti = 2;
tObjIn.ti = &ti;
Test1 test1,test2,test3;
test1.ts = "100";
test2.ts = "200";
test3.ts = "300";
Test1 testA, testC;
testA.tt = &test1;
testA.ts = "test123";
testA.tvt.push_back(&test2);
testA.tvt.push_back(&test3);
Test1 testB = testA;
testB.ts = "400";
testB.tvt.pop_back();
std::pair<int,bool> tPairIn(10,true);
std::pair<int,bool> tPairOut;
std::vector<int> tVector1In ={1,2,3,4,5};
std::vector<int> tVector1Out;
std::pair<int,bool> p1(10,1);
std::pair<int,bool> p2(1,0);
std::pair<int,bool> p3(10000,1);
std::vector<std::pair<int,bool> > tVector2In ={p1,p2,p3};
std::vector<std::pair<int,bool> > tVector2Out;
std::set<std::pair<int,bool> > tSetIn ={p1,p2,p3};
std::set<std::pair<int,bool> > tSetOut;
std::map<int,bool> tMapIn ={p1,p2,p3};
std::map<int,bool> tMapOut;
Eigen::Matrix<float,3,3> tDenseMatrixIn;
tDenseMatrixIn << Eigen::Matrix<float,3,3>::Random();
tDenseMatrixIn.coeffRef(0,0) = 1.00001;
Eigen::Matrix<float,3,3> tDenseMatrixOut;
Eigen::Matrix<float,3,3,Eigen::RowMajor> tDenseRowMatrixIn;
tDenseRowMatrixIn << Eigen::Matrix<float,3,3,Eigen::RowMajor>::Random();
Eigen::Matrix<float,3,3,Eigen::RowMajor> tDenseRowMatrixOut;
Eigen::SparseMatrix<double> tSparseMatrixIn;
tSparseMatrixIn.resize(3,3);
tSparseMatrixIn.insert(0,0) = 1.3;
tSparseMatrixIn.insert(1,1) = 10.2;
tSparseMatrixIn.insert(2,2) = 100.1;
tSparseMatrixIn.finalize();
Eigen::SparseMatrix<double> tSparseMatrixOut;
// binary serialization
igl::serialize(tbIn,file);
igl::deserialize(tbOut,file);
assert(tbIn == tbOut);
igl::serialize(tcIn,file);
igl::deserialize(tcOut,file);
assert(tcIn == tcOut);
igl::serialize(tucIn,file);
igl::deserialize(tucOut,file);
assert(tucIn == tucOut);
igl::serialize(tsIn,file);
igl::deserialize(tsOut,file);
assert(tsIn == tsOut);
igl::serialize(tiIn,file);
igl::deserialize(tiOut,file);
assert(tiIn == tiOut);
igl::serialize(tuiIn,file);
igl::deserialize(tuiOut,file);
assert(tuiIn == tuiOut);
//.........这里部分代码省略.........