欢迎来到天天文库
浏览记录
ID:37710946
大小:19.89 KB
页数:6页
时间:2019-05-29
《Eigen工具查询参考》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、//AsimplequickrefforEigen.Addanythingthat'smissing.//Mainauthor:KeirMierle#includeMatrixA;//Fixedrowsandcols.SameasMatrix3d.MatrixB;//Fixedrows,dynamiccols.MatrixC;//Fulldynamic.SameasMatrixXd.Matrix2、>E;//Rowmajor;defaultiscolumn-major.Matrix3fP,Q,R;//3x3floatmatrix.Vector3fx,y,z;//3x1floatmatrix.RowVector3fa,b,c;//1x3floatmatrix.VectorXdv;//Dynamiccolumnvectorofdoublesdoubles;//Basicusage//Eigen//Matlab//commentsx.size()//length(x)//vectorsizeC.rows()//size(C,1)//numberofrowsC.col3、s()//size(C,2)//numberofcolumnsx(i)//x(i+1)//Matlabis1-basedC(i,j)//C(i+1,j+1)//A.resize(4,4);//Runtimeerrorifassertionsareon.B.resize(4,9);//Runtimeerrorifassertionsareon.A.resize(3,3);//Ok;sizedidn'tchange.B.resize(3,9);//Ok;onlydynamiccolschanged.A<<1,2,3,//InitializeA.Theelementsca4、nalsobe4,5,6,//matrices,whicharestackedalongcols7,8,9;//andthentherowsarestacked.B<5、s(rows,cols)C.setZero(rows,cols)//C=ones(rows,cols)MatrixXd::Ones(rows,cols)//ones(rows,cols)C.setOnes(rows,cols)//C=ones(rows,cols)MatrixXd::Random(rows,cols)//rand(rows,cols)*2-1//MatrixXd::Randomreturnsuniformrandomnumbersin(-1,1).C.setRandom(rows,cols)//C=rand(rows,cols)*2-1VectorX6、d::LinSpaced(size,low,high)//linspace(low,high,size)'v.setLinSpaced(size,low,high)//v=linspace(low,high,size)'//Matrixslicingandblocks.Allexpressionslistedhereareread/write.//Templatedsizeversionsarefaster.NotethatMatlabis1-based(asizeN//vectorisx(1)...x(N)).//Eigen//Matlabx.head(n)//x7、(1:n)x.head()//x(1:n)x.tail(n)//x(end-n+1:end)x.tail()//x(end-n+1:end)x.segment(i,n)//x(i+1:i+n)x.segment(i)//x(i+1:i+n)P.block(i,j,rows,cols)//P(i+1:i+rows,j+1:j+cols)P.block(i,j)//P(i+1:i+rows,j+1:j+cols)P.row(i)//P(i+1,:)P.col(j)//P(:,j+1)P.leftCols()//P(
2、>E;//Rowmajor;defaultiscolumn-major.Matrix3fP,Q,R;//3x3floatmatrix.Vector3fx,y,z;//3x1floatmatrix.RowVector3fa,b,c;//1x3floatmatrix.VectorXdv;//Dynamiccolumnvectorofdoublesdoubles;//Basicusage//Eigen//Matlab//commentsx.size()//length(x)//vectorsizeC.rows()//size(C,1)//numberofrowsC.col
3、s()//size(C,2)//numberofcolumnsx(i)//x(i+1)//Matlabis1-basedC(i,j)//C(i+1,j+1)//A.resize(4,4);//Runtimeerrorifassertionsareon.B.resize(4,9);//Runtimeerrorifassertionsareon.A.resize(3,3);//Ok;sizedidn'tchange.B.resize(3,9);//Ok;onlydynamiccolschanged.A<<1,2,3,//InitializeA.Theelementsca
4、nalsobe4,5,6,//matrices,whicharestackedalongcols7,8,9;//andthentherowsarestacked.B<5、s(rows,cols)C.setZero(rows,cols)//C=ones(rows,cols)MatrixXd::Ones(rows,cols)//ones(rows,cols)C.setOnes(rows,cols)//C=ones(rows,cols)MatrixXd::Random(rows,cols)//rand(rows,cols)*2-1//MatrixXd::Randomreturnsuniformrandomnumbersin(-1,1).C.setRandom(rows,cols)//C=rand(rows,cols)*2-1VectorX6、d::LinSpaced(size,low,high)//linspace(low,high,size)'v.setLinSpaced(size,low,high)//v=linspace(low,high,size)'//Matrixslicingandblocks.Allexpressionslistedhereareread/write.//Templatedsizeversionsarefaster.NotethatMatlabis1-based(asizeN//vectorisx(1)...x(N)).//Eigen//Matlabx.head(n)//x7、(1:n)x.head()//x(1:n)x.tail(n)//x(end-n+1:end)x.tail()//x(end-n+1:end)x.segment(i,n)//x(i+1:i+n)x.segment(i)//x(i+1:i+n)P.block(i,j,rows,cols)//P(i+1:i+rows,j+1:j+cols)P.block(i,j)//P(i+1:i+rows,j+1:j+cols)P.row(i)//P(i+1,:)P.col(j)//P(:,j+1)P.leftCols()//P(
5、s(rows,cols)C.setZero(rows,cols)//C=ones(rows,cols)MatrixXd::Ones(rows,cols)//ones(rows,cols)C.setOnes(rows,cols)//C=ones(rows,cols)MatrixXd::Random(rows,cols)//rand(rows,cols)*2-1//MatrixXd::Randomreturnsuniformrandomnumbersin(-1,1).C.setRandom(rows,cols)//C=rand(rows,cols)*2-1VectorX
6、d::LinSpaced(size,low,high)//linspace(low,high,size)'v.setLinSpaced(size,low,high)//v=linspace(low,high,size)'//Matrixslicingandblocks.Allexpressionslistedhereareread/write.//Templatedsizeversionsarefaster.NotethatMatlabis1-based(asizeN//vectorisx(1)...x(N)).//Eigen//Matlabx.head(n)//x
7、(1:n)x.head()//x(1:n)x.tail(n)//x(end-n+1:end)x.tail()//x(end-n+1:end)x.segment(i,n)//x(i+1:i+n)x.segment(i)//x(i+1:i+n)P.block(i,j,rows,cols)//P(i+1:i+rows,j+1:j+cols)P.block(i,j)//P(i+1:i+rows,j+1:j+cols)P.row(i)//P(i+1,:)P.col(j)//P(:,j+1)P.leftCols()//P(
此文档下载收益归作者所有