首页 > 代码库 > 高效的计算Laplacian 矩阵
高效的计算Laplacian 矩阵
直接上代码,可以直接调用:
function L1 = CP_Laplacian( M )%UNTITLED Summary of this function goes here% Detailed explanation goes here% number of vertices (size of matrix)nverts = size(M.vertices,1);% assume manifold and faces oriented uniformlyedges = [M.faces(:,[1,2]); M.faces(:,[2,3]); M.faces(:,[3,1])];% extract vertices from matrixv1Idxs = edges(:,1);v2Idxs = edges(:,2);v1s = M.vertices(v1Idxs,:);v2s = M.vertices(v2Idxs,:);% compute edge lengths and weightseps = 1e-8;edgel = sqrt( sum( (v1s-v2s).^2, 2 ) );edgew = 1 ./ (eps + edgel );% construct sparse matrixnnzeros = size(edges,1) / 2;L1 = sparse( v1Idxs, v2Idxs, edgew, nverts, nverts );% compute diagonal by summing column-major (faster)D = -full( sum( L1,1 ) )‘;% insert D in 0-diagonal of L1L1 = spdiags(D,0,L1);end
高效的计算Laplacian 矩阵
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。