📄 writesparse.m
字号:
function writesparse(A,fp)% function writesparse(A,fp)%% Write the binary matrix A into the file fp% in MacKay's sparse format% Todd Moon% Copyright 2004 by Todd K. Moon% Permission is granted to use this program/data% for educational/research only[m,n] = size(A);fprintf(fp,'%d %d\n',n,m); % dimensions of Afprintf(fp,'%d %d\n',max(sum(A,1)),max(sum(A,2))); % max column and row weightsfprintf(fp,'%d ',sum(A,1)); fprintf(fp,'\n'); % column weights (array)fprintf(fp,'%d ',sum(A,2)); fprintf(fp,'\n'); % row weights (array)for i=1:n % write out the nonzero positions in each column fprintf(fp,'%d ',find(A(:,i))); fprintf(fp,'\n');endfor i=1:m % write out the nonzero positions in each row fprintf(fp,'%d ',find(A(i,:))); fprintf(fp,'\n');end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -