0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

密行列と疎行列

0
Posted at

1. 見た目上の行列(4x3)

ほとんどの要素が 0(ゼロ)

matrix = [
[5, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 8]
]

2. 保存方法の違い

■ 密行列 (Dense Matrix): すべての値をそのまま保存

メモリ上では全要素分のスペースが必要
dense_storage = [5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8]

=> 合計 12個 の値を保持

■ 疎行列 (Sparse Matrix): 「意味のある値」とその場所だけを保存

例: COO(Coordinate)形式
sparse_data = {
"値": [5, 8],
"行": [0, 2],
"列": [0, 3]
}

=> 合計 6個 の情報だけで済む(データが大きくなるほど節約効果が絶大!)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?