Subject: Re: 提示:有關作業二的第二題

[ Follow Ups ] [ Post Followup ] [ WWW Board ]

Posted by Chong-ming on March 11, 1997 at 22:04:34:

In Reply to: 提示:有關作業二的第二題 posted by Roger Jang on March 11, 1997 at 10:44:42:

同學們如果不熟悉for迴圈和vector運算的寫法,
可以參考下面兩種產生Hilbert矩陣的方法:

每日一字 "Hilbert matrix"

Hilbert matrix is the N by N matrix with elements
which equal to 1/(i+j-1)

for迴圈版本:

FOR I = 1:N,
FOR J = 1:N,
A(I,J) = 1/(I+J-1);
END
END

vector運算版本

J = 1:n;
J = J(ones(n,1),:);
I = J';
E = ones(n,n);
H = E./(I+J-1);

看得用力一點,就會明白vector運算是如何利用
【空間換取時間】了。


Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ WWW Board ] [ FAQ ]