Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions chunkie/@chunkgraph/edgeids.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function ids = edgeids(cgrph, ichs)
%edgeids return the indices corresponding to points in cgrph.echnks(ichs)
npts = [cgrph.echnks.npt];
% get starting index for each edge
idstart = [1,cumsum(npts)+1];

ids = [];
for i = 1:length(ichs)
ids = [ids, idstart(ichs(i)):(idstart(ichs(i)+1)-1)];
end
end
16 changes: 15 additions & 1 deletion devtools/test/slicegraphTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,18 @@ function slicegraphTest0()
matdiff = norm(sysmat_slc - sysmat(idslce, idslce));
fprintf('error in sliced system matrix is %e\n',matdiff)
assert(matdiff < 1e-10)
end


% test getting ids of edges
ids = edgeids(cgrph,[3,4,2,1]);

% test values are correct
assert(all(sort(ids) == (1:sum([cgrph.echnks(1:4).npt]))));
% test sorted by input list
assert(~all(sort(ids) == ids));

ids = edgeids(cgrph,ichs);
% compare edgeids to manual version
assert(all(ids == idslce));

end
Loading