转成matlab: npair = nbk[idx].shape[0] rk = (nbk[idx] == k).nonzero()[0] Lk = sp.sparse.lil_matrix((npair,npair)) Lk.setdiag(lk) Lk[:,rk] = -(lk.reshape(-1,1)) Lk[rk,:] = -(lk.reshape(1,-1)) Lk_tensor.append(sp.sparse.csr_matrix(Lk)) si_map[k] = idx
时间: 2023-12-26 12:06:22 浏览: 76
用于西门子1200/1500的 点到点PPI-TCP通信协议
npair = size(nbk{idx}, 1);
rk = find(nbk{idx} == k);
Lk = sparse(npair, npair);
Lk(1:npair+1:end) = lk;
Lk(:,rk) = -repmat(lk', npair, 1);
Lk(rk,:) = -repmat(lk, 1, npair);
Lk_tensor{end+1} = csr_matrix(Lk);
si_map(k) = idx;
阅读全文