5-2 ��������������������������?

@ӥu]tƪ}x}A]׬ mnAt nnz ӫDsAMATLAB ʥΤFTӤ}Cxs}x}TG

]Aӵ}x}sŶjp 8*nnz + 8*nnz + 8*n + 8 = 16*nnz + 8*n + 8AhXӪ 8 bytes OΨxsLg`ʸTCH MATLAB west0479.mat ɮ׬ҡAɮץ]t@ 479479 }x}Aڭ̥iHҤWzsŶpUG

Example 1: 05-}x}/memorySize01.mclear all load west0479.mat [m,n]=size(west0479); totalSize=16*nnz(west0479)+8*n+8 whos west0479totalSize = 34032 Name Size Bytes Class Attributes west0479 479x479 34032 double sparse

ѤWҥiAڭ̥ѤWzsŶұo쪺GAM whos Oұo쪺GO@PC~bWҤAnnz(west0479) iǦ^}x} west0479 DsӼơALO٦ nonzeros]Ǧ^@ӥ]tҦDsVq^ nzmax]Ǧ^̤jDsӼơ^C

Hint
  • b@ӵ}x}AN@ӫDs]wsɡAMATLAB ä|۰OŶA]ܻAnnz |H۫Ds֦Ӵ֡A nzmax ä|HۧܡCOzh[@ӫDsɡAY nnz wj nzmax ɡAnzmax |HWj]Y MATLAB |۰ʰtmO^Hxss[C

WzsŶ|H MATLAB ӦҧܡAҥHMwsŶ̦n覡O MATLAB iաAdҦpUG

Example 2: 05-}x}/memorySize02.mcaseNum=100; A=zeros(caseNum, 4); % A in Ax=b b=zeros(caseNum, 1); % b in Ax=b for i=1:caseNum m=max([round(100*rand), 5]); n=max([round(100*rand), 5]); s=sprand(m, n, 0.1); sizeInfo=whos('s'); A(i,1)=nnz(s); A(i,2:3)=sizeInfo.size; A(i,4)=1; b(i)=sizeInfo.bytes; end x=A\b maxDiff=max(abs(A*x-b)) x = 16.0000 0.0000 8.0000 8.0000 maxDiff = 3.6380e-12

bWҤAڭ̨ƹWObѤ@ӽuʤ{ Ax=bA䤤ڭ̨ϥΤF 100 ӵ}x}Ӳ AAA ]t|ӪAC@ӪONo 100 ӵ}x} nnz]DsӼơ^Bm]CӼơ^Bn]Ӽơ^AHα` 1A b hOoXӵ}x}sŶjpCѤWzdҩұo쪺w~t۷pA] x ȴNiHDC@ӯSx]nnzBmBn^ҦΪsŶOO]16B0B8^AӨC@ӵ}x}ٷ|Ψ 8 Ӧ줸ըxsg`ʸTC

Hint
bWzdҤAڭ̨ϥΡuv]x=A\b^Өϥγ̤pkpߤ{AiѤuuʥNơv`C


MATLAB{]pGig