当前位置:网站首页>矩 阵 压 缩
矩 阵 压 缩
2022-06-28 23:59:00 【SVIP_Quanw】
1. 对称矩阵压缩
[ a x x x x x b x x x x x c x x x x x d x x x x x e ] \begin{bmatrix} a& x& x& x&x \\ x& b& x& x&x \\ x& x& c& x&x \\ x& x& x& d&x \\ x& x& x& x&e \end{bmatrix} ⎣⎢⎢⎢⎢⎡axxxxxbxxxxxcxxxxxdxxxxxe⎦⎥⎥⎥⎥⎤
[ a x b x x c x x x d x x x x e ] \begin{bmatrix} a& & & & \\ x& b& & & \\ x& x& c& & \\ x& x& x& d& \\ x& x& x& x&e \end{bmatrix} ⎣⎢⎢⎢⎢⎡axxxxbxxxcxxdxe⎦⎥⎥⎥⎥⎤
二维数组中 a i j a_{ij} aij在一维数组中的下标:
k = i ( i − 1 ) / 2 + j − 1 k=i(i-1)/2+j-1 k=i(i−1)/2+j−1
对于对称矩阵我们可以只保存下三角(包括对角线上的元素),或上三角的元素
原来需要的存储单元个数 n × n n \times n n×n 变成了 ( n ( n + 1 ) / 2 ) (n(n+1)/2) (n(n+1)/2)
2. 上下三角矩阵压缩
2.1 下三角对称矩阵压缩
对于
[ a 11 a 21 a 22 a 31 a 32 a 33 a 41 a 42 a 43 a 44 a 51 a 52 a 53 a 54 a 55 ] \begin{bmatrix} a_{11}& & & & \\ a_{21}& a_{22}& & & \\ a_{31}& a_{32}& a_{33}& & \\ a_{41}& a_{42}& a_{43}& a_{44}& \\ a_{51}& a_{52}& a_{53}& a_{54}& a_{55} \end{bmatrix} ⎣⎢⎢⎢⎢⎡a11a21a31a41a51a22a32a42a52a33a43a53a44a54a55⎦⎥⎥⎥⎥⎤
将
[ a 11 . . . a i 1 . . . a i j . . . . . . a n 1 . . . a n j . . . a n n ] \begin{bmatrix} a_{11}& & & & \\ ...\\ a_{i1}& ...& a_{ij}& ...& \\ ... \\ a_{n1}& ...& a_{nj}& ...& a_{nn} \end{bmatrix} \\ ⎣⎢⎢⎢⎢⎡a11...ai1...an1......aijanj......ann⎦⎥⎥⎥⎥⎤
转化为
[ a 11 . . . a i 1 . . . a i j . . . a n 1 . . . a n j . . . a n n ] \begin{bmatrix} a_{11}& ...& a_{i1}& ...& a_{ij}& ...& a_{n1}& ...& a_{nj}& ...& a_{nn}&\\ \end{bmatrix} \\ [a11...ai1...aij...an1...anj...ann]
原矩阵中的下标 i , j i,j i,j,对应于数组中的下标 k k k
2.2 上三角对称矩阵压缩
对于
[ a 11 a 12 a 13 a 14 a 22 a 23 a 24 a 33 a 34 a 44 ] \begin{bmatrix} a_{11}& a_{12}& a_{13}& a_{14}\\ & a_{22}& a_{23}& a_{24}\\ & & a_{33}& a_{34}\\ & & & a_{44}\\ \end{bmatrix} ⎣⎢⎢⎡a11a12a22a13a23a33a14a24a34a44⎦⎥⎥⎤
将
[ a 11 . . . a 1 j . . . a 1 n . . . . . . a i j . . . a i n . . . a n n ] \begin{bmatrix} a_{11}& ...& a_{1j}& ...& a_{1n}\\ & & ...& &...\\ & & a_{ij}& ...& a_{in}\\ & & & &... \\ & & & & a_{nn} \end{bmatrix} \\ ⎣⎢⎢⎢⎢⎡a11...a1j...aij......a1n...ain...ann⎦⎥⎥⎥⎥⎤
转化为
[ a 11 . . . a 1 j . . . a 1 n . . . a i j . . . a i n . . . a n n ] \begin{bmatrix} a_{11}& ...& a_{1j}& ...& a_{1n}& ...& a_{ij}& ...& a_{in}& ...& a_{nn}&\\ \end{bmatrix} \\ [a11...a1j...a1n...aij...ain...ann]
原矩阵中的下标 i , j i,j i,j,对应于数组中的下标 k k k
即:
k = ( i − 1 ) ( 2 n − i + 2 ) / 2 + j − i k=(i-1)(2n-i+2)/2+j-i k=(i−1)(2n−i+2)/2+j−i
2. 对角矩阵压缩
将矩阵
[ a 11 a 12 0 0 0 a 21 a 22 a 23 0 0 0 a 32 a 33 a 34 0 0 0 a 43 a 44 a 45 0 0 0 a 54 a 55 ] \begin{bmatrix} a_{11}& a_{12}& 0& 0&0 \\ a_{21}& a_{22}& a_{23}&0 &0 \\ 0& a_{32}& a_{33}& a_{34}&0 \\ 0& 0& a_{43}& a_{44}& a_{45}\\ 0& 0& 0&a_{54} &a_{55} \end{bmatrix} ⎣⎢⎢⎢⎢⎡a11a21000a12a22a32000a23a33a43000a34a44a54000a45a55⎦⎥⎥⎥⎥⎤
压缩为一维矩阵
[ a 11 a 12 a 21 a 22 a 23 a 32 a 33 a 34 a 43 a 44 a 45 a 54 a 55 ] \begin{bmatrix} a_{11}& a_{12}& a_{21}& a_{22}& a_{23}& a_{32}& a_{33}& a_{34}& a_{43}& a_{44}& a_{45}& a_{54}& a_{55} \end{bmatrix} [a11a12a21a22a23a32a33a34a43a44a45a54a55]
原来 n × n n \times n n×n个存储单元现在只要 3 n − 2 3n-2 3n−2个
原矩阵中的下标 i , j i,j i,j,对应于数组中的下标 k k k
即
k = 2 i + j − 3 k=2i+j-3 k=2i+j−3
已知 k k k:
{ i = ⌊ ( k + 1 ) / 3 ⌋ + 1 j = k − 2 i + 3 \begin{cases} i=\left \lfloor (k+1)/3 \right \rfloor+1 \\ j=k-2i+3 \end{cases} { i=⌊(k+1)/3⌋+1j=k−2i+3
边栏推荐
- Scrapy uses xlwt to implement the exporter that exports data in Excel format
- IO playback function of FIO
- 【LeetCode】21. 合并两个有序链表 - Go 语言题解
- The company has a new Post-00 test paper king. The old oilman said that he could not do it. He has been
- TypeScript -- 第二节:变量声明
- 剑指 Offer 12. 矩阵中的路径
- [Electronic Experiment 2] simple electronic doorbell
- 请问指南针股票软件可靠吗?在上面交易股票安全吗?
- Is the compass stock software reliable? Is it safe to trade stocks on it?
- Is it safe to open an account for buying stocks online?
猜你喜欢

一条update语句到底加了多少锁?带你深入理解底层原理

Stm32f407-------- NVIC interrupt priority management

stm32F407-------LCD

ctfshow XSS

每日一题:消失的数字
![[buuctf.reverse] 131-135](/img/c2/b8b06c8191af2c75bf4ad5c82feaea.png)
[buuctf.reverse] 131-135

12. Détection d'objets Mask rcnn

stm32F407-------RTC实时时钟

PHP 使用endroid/qrcode 二维码生成, GD库生成分享海报

Be on the list again! Know that Chuangyu was selected as one of the top 50 competitive enterprises in China's network security industry in 2022
随机推荐
Test experience: how testers evolve from 0 to 1
mysql 高可用双主同步
【C Primer Plus第二章课后编程题】
Online yaml to JSON tool
每日一练:删除有序数组中的重复项
[machine learning] numerical analysis 02 -- finding roots of arbitrary equations
Yyds dry goods inventory building knowledge map from scratch with neo4j (I)
MapReduce案例
stm32F407-------GPIO输入实验
Huawei's level 22 experts have worked hard for ten years to complete the advanced practical document of cloud native service grid. 6
10、YOLO系列
[SSM] an error is reported that the user name of the access denied for user 'WYF' @ 'localhost' (using password: yes) data becomes the user name of the computer
How to make two objects or arrays equal
PHP uses endroid/qrcode QR code to generate, and Gd library generates sharing posters
Online yaml to JSON tool
The second session of question swiping and clock out activity -- solving the switching problem with recursion as the background (2)
点击劫持:X-Frame-Options未配置
What are some tips to improve your interview success rate?
Technology sharing | software development process that you must understand if you want to get started with testing
stm32F407-------LCD