作者polomoss (小澤)
看板Grad-ProbAsk
標題Re: [理工] [資結]-一些矩陣的計算問題
時間Wed Dec 16 23:54:14 2009
※ 引述《tryPTT (NULL)》之銘言:
: 一、What is the address for a[5][3] for an array declared as a[7][8]?
: Assume a row major ordering, 10 units of memory per element, and staring
: address is 1000.
a[5][3] = 1000 + [ (5-1) * 8 + (3-1) ] * 10 = 1340
: 二、Given A as an N by N array(N>=2) with A[i,j]=0 if |i-j|>2. Then, determine
: the maximal number of nonzero elements in A.
n + 2(n-1) = 3n-2
: 三、另外想請問一下row/column-major 到底怎麼判斷會比較準?
: ex1: A(0,5)=36 A(1,4)=56 A(2,7)=92 是row-major嗎?
: ex2: B(2,3)=18 B(3,2)=28 A(1,1)=2 是row-major嗎?
ex1 row-major
ex2 row-major
看前兩個就能判斷了
另外,在同一篇加問一題.......
帶狀矩陣,A n,a,b 儲存到B[]一維陣列
給B[k] → A[i,j]
跟給A[i,j] → B[k]
這兩個公式怎麼導~?
--
┌這篇文章讓您覺得?─────────────────────────────┐
│ │
│ 一"一 \ / >\\\< ╯ ╰ ∩ ∩ ▁ ▁ >_< ㄧ ㄧ+ │
│ 皿 ε □ ▽ ▇Δ ▇ ╰╯ ╯ │
│ 北七 亂喔 害羞 莎笅 爽啦 哭爸 XD 科科 │
└──────────────────────────────────────┘
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.116.14.2
推 assassin88:第一題跟我算的一樣..不過第二題我不懂可以解釋一下嗎 12/17 00:00
推 sakuraai:對角線上有n個加上兩旁有n-1個 12/17 01:24
推 assassin88:但不是規定|i-j|>2嗎? 這樣應該會有對角線跟兩旁兩條? 12/17 11:32
→ polomoss:恩,那就是 n + 2(n-1) + 2(n-2) 沒看仔細~ 12/17 18:20