Fortran Coder

如何将压缩储存的稀疏矩阵转化为满秩矩阵

查看数: 6804 | 评论数: 3 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2018-6-25 22:18

正文摘要:

本帖最后由 frankgty 于 2018-6-25 23:46 编辑 现有一个稀疏矩阵以ipodia法压缩储存,数据文件中包含元素值,下标j和ipodia共三列数组。储存方式如图ipodia法所示,ipodia指向每行最后一个非零元素,此矩阵为对称 ...

回复

frankgty 发表于 2018-6-28 04:39:59
fcode 发表于 2018-6-26 08:28
[mw_shl_code=fortran,true]program fcode_cn
  Implicit None
  Real , allocatable    :: rMatrix(:,:) , ...

非常感谢
pasuka 发表于 2018-6-26 09:40:01
lz用ivf的话,直接查阅MKL帮助文档吧
譬如
https://software.intel.com/en-us ... -fortran-mkl-csrcoo
fcode 发表于 2018-6-26 08:28:06
[Fortran] 纯文本查看 复制代码
program fcode_cn
  Implicit None
  Real , allocatable    :: rMatrix(:,:) , value(:)
  Integer , allocatable :: ipodia(:) , indexJ(:)
  Integer :: N , M , i , j
  Open( 12 , File = "Ipodia.txt")
  Open( 13 , File = "Index J.txt")
  Open( 14 , File = "Value.txt")
  N = GetFileN( 12 )
  M = GetFileN( 13 )
  Allocate( rMatrix(N,N) , ipodia(0:N) , indexJ(M) , value(M) )
  rMatrix   = 0
  ipodia(0) = 0
  Read(12,*) ipodia(1:)
  Read(13,*) indexJ
  Read(14,*) value
  Do i = 1 , N
    rMatrix( indexJ( ipodia(i-1)+1 : ipodia(i) ) , i ) = value( ipodia(i-1)+1 : ipodia(i) )
    rMatrix( i , :i-1 ) = rMatrix( :i-1 , i )
  End Do
  Close(12)
  Close(13)
  Close(14)
  
contains

  Integer Function GetFileN( iFileUnit )
    Integer , Intent( IN ) :: iFileUnit
    character( Len = 1 ) :: cDummy
    integer :: ierr
    GetFileN = 0
    Rewind( iFileUnit )
    Do
      Read( iFileUnit , * , ioStat = ierr ) cDummy
      If( ierr /= 0 ) Exit
      GetFileN = GetFileN + 1
    End Do
    Rewind( iFileUnit )
  End Function GetFileN 
  
end program fcode_cn

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-5-7 07:50

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表