Compressed Column Storage (CCS) & Compressed Row Storage (CRS)

英文资料来自http://netlib2.cs.utk.edu/linalg/html_templates/node91.html#sparseA

http://netlib2.cs.utk.edu/linalg/html_templates/node92.html

 

Compressed Column Storage (CCS)

   

Analogous to Compressed Row Storage there is Compressed Column Storage (CCS), which is also called the Harwell-Boeing sparse matrix format [78]. The CCS format is identical to the CRS format except that the columns of  are stored (traversed) instead of the rows. In other words, the CCS format is the CRS format for .

The CCS format is specified by the  arrays {valrow_indcol_ptr}, where row_ind stores the row indices of each nonzero, and col_ptr stores the index of the elements in valwhich start a column of . The CCS format for the matrix  in (gif) is given by

 

.

 

Compressed Row Storage (CRS)

   

The Compressed Row and Column (in the next section) Storage formats are the most general: they make absolutely no assumptions about the sparsity structure of the matrix, and they don't store any unnecessary elements. On the other hand, they are not very efficient, needing an indirect addressing step for every single scalar operation in a matrix-vector product or preconditioner solve.

The Compressed Row Storage (CRS) format puts the subsequent nonzeros of the matrix rows in contiguous memory locations. Assuming we have a nonsymmetric sparse matrix , we create  vectors: one for floating-point numbers (val), and the other two for integers (col_indrow_ptr). The val vector stores the values of the nonzero elements of the matrix , as they are traversed in a row-wise fashion. The col_ind vector stores the column indexes of the elements in the val vector. That is, if  then . The row_ptr vector stores the locations in the val vector that start a row, that is, if  then . By convention, we define , where  is the number of nonzeros in the matrix . The storage savings for this approach is significant. Instead of storing  elements, we need only  storage locations.

As an example, consider the nonsymmetric matrix  defined by

 

 

The CRS format for this matrix is then specified by the arrays {valcol_indrow_ptr} given below

 

.

If the matrix  is symmetric, we need only store the upper (or lower) triangular portion of the matrix. The trade-off is a more complicated algorithm with a somewhat different pattern of data access.  

 

 

 

具体的翻译不做了。写一下自己的理解。

以CRS为模板,CCS即为CRS的转置矩阵。

 

有三个向量,分别为val用于存储矩阵中的值。 col_ind用于存储行坐标,row_ptr这个一时想不到怎么概括。下面简介:

设val[1] = a11这里即为矩阵中的存储方式a11。

所以col[1] = 1,即上面公式val(k) = aij 中的i。

row_ptr[1]=1 <=    k=1    < row_ptr[1+1]=3,

val[2] = a15

所以col[2] = 5

因为还是第一行中的数,所以 row_ptr[1]=1 <=    k=2    < row_ptr[1+1]=3依旧成立。  

 

val[3] = a21

col[3] = 1

row_ptr[2]=3 <=       3          <row[2+1]=6成立。即为第二行中的数。

 

 

 

 

由观察得,row[i+1]-row[i]即为该行中的元素数。再由col向量即可生成该系数矩阵。

 

 

 

CCS为CRS的转置,思路类似。。

 

 

CCS用于TAUCS中sparse matrix的存储。

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值