Fortran Coder

查看: 22302|回复: 11
打印 上一主题 下一主题

[数学库] 菜鸟求助:IVF中实矩阵求逆用哪个函数啊?

[复制链接]

6

帖子

1

主题

0

精华

入门

F 币
33 元
贡献
15 点
跳转到指定楼层
楼主
发表于 2016-12-31 10:58:15 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
原先CVF还了解一点,现在用IVF有点迷糊了。求逆矩阵不是.i.了吗?
[Fortran] 纯文本查看 复制代码
program main
    use imsl_libraries
    implicit none
    integer,parameter::n=3
    real::a(n,n)=(/1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0/)
    real::b(n,n)=(/5.0,6.0,4.0,8.0,9.0,7.0,2.0,3.0,1.0/)
    real::c(n,n)
    c=.i.a
    write(*,*)c
    end program
求指点
多谢多谢!
分享到:  微信微信
收藏收藏 点赞点赞 点踩点踩

59

帖子

2

主题

0

精华

大师

F 币
810 元
贡献
476 点
12#
发表于 2017-1-6 12:33:06 | 只看该作者
本帖最后由 kerb 于 2017-1-6 12:46 编辑

subroutine dgesv        (        integer         N,
integer         NRHS,
double precision, dimension( lda, * )         A,
integer         LDA,
integer, dimension( * )         IPIV,
double precision, dimension( ldb, * )         B,
integer         LDB,
integer         INFO
)               
DGESV computes the solution to system of linear equations A * X = B for GE matrices

Download DGESV + dependencies [TGZ] [ZIP] [TXT]

Purpose:
DGESV computes the solution to a real system of linear equations
    A * X = B,
where A is an N-by-N matrix and X and B are N-by-NRHS matrices.

The LU decomposition with partial pivoting and row interchanges is
used to factor A as
    A = P * L * U,
where P is a permutation matrix, L is unit lower triangular, and U is
upper triangular.  The factored form of A is then used to solve the
system of equations A * X = B.
Parameters
[in]        N       
          N is INTEGER
          The number of linear equations, i.e., the order of the
          matrix A.  N >= 0.
[in]        NRHS       
          NRHS is INTEGER
          The number of right hand sides, i.e., the number of columns
          of the matrix B.  NRHS >= 0.
[in,out]        A       
          A is DOUBLE PRECISION array, dimension (LDA,N)
          On entry, the N-by-N coefficient matrix A.
          On exit, the factors L and U from the factorization
          A = P*L*U; the unit diagonal elements of L are not stored.
[in]        LDA       
          LDA is INTEGER
          The leading dimension of the array A.  LDA >= max(1,N).
[out]        IPIV       
          IPIV is INTEGER array, dimension (N)
          The pivot indices that define the permutation matrix P;
          row i of the matrix was interchanged with row IPIV(i).
[in,out]        B       
          B is DOUBLE PRECISION array, dimension (LDB,NRHS)
          On entry, the N-by-NRHS matrix of right hand side matrix B.
          On exit, if INFO = 0, the N-by-NRHS solution matrix X.
[in]        LDB       
          LDB is INTEGER
          The leading dimension of the array B.  LDB >= max(1,N).
[out]        INFO       
          INFO is INTEGER
          = 0:  successful exit
          < 0:  if INFO = -i, the i-th argument had an illegal value
          > 0:  if INFO = i, U(i,i) is exactly zero.  The factorization
                has been completed, but the factor U is exactly
                singular, so the solution could not be computed.

6

帖子

1

主题

0

精华

入门

F 币
33 元
贡献
15 点
11#
 楼主| 发表于 2017-1-2 09:42:11 | 只看该作者
vvt 发表于 2017-1-2 08:12
1. 用 matmul 代替 .x. 进行矩阵相乘。
2. 用 IMSL 5.0 代替 6.0和7.0(因为它们有bug)
3. 用 MKL 、Lapac ...

好,我尝试一下imsl5.0。
谢谢了~

954

帖子

0

主题

0

精华

大师

F 币
184 元
贡献
75 点

规矩勋章元老勋章新人勋章水王勋章热心勋章

QQ
10#
发表于 2017-1-2 08:12:06 | 只看该作者
1. 用 matmul 代替 .x. 进行矩阵相乘。
2. 用 IMSL 5.0 代替 6.0和7.0(因为它们有bug)
3. 用 MKL 、Lapack 等代替 IMSL 进行求逆。

选其一

6

帖子

1

主题

0

精华

入门

F 币
33 元
贡献
15 点
9#
 楼主| 发表于 2017-1-2 08:09:22 | 只看该作者


有什么解决的建议吗?
多谢多谢了

954

帖子

0

主题

0

精华

大师

F 币
184 元
贡献
75 点

规矩勋章元老勋章新人勋章水王勋章热心勋章

QQ
8#
发表于 2017-1-1 10:44:28 | 只看该作者
IMSL 的 bug
回复

使用道具 举报

6

帖子

1

主题

0

精华

入门

F 币
33 元
贡献
15 点
7#
 楼主| 发表于 2017-1-1 10:20:56 | 只看该作者
weixing1531 发表于 2016-12-31 21:38
矩阵求逆Excel有现成的函数

嗯嗯 是的,不过求逆这个运算是一个大程序里面的一部分,单独拿出来计算可能会不方便了。
谢谢你

6

帖子

1

主题

0

精华

入门

F 币
33 元
贡献
15 点
6#
 楼主| 发表于 2017-1-1 10:13:59 | 只看该作者
经过提升,程序能运行了,不过只要是加上USE operation_x就报错误
        1        Compilation Aborted (code 1)        
不知道是哪里出了问题?
在工具-选项-IVF-compiles里面的includes和lib已经把相关的
    C:\Program Files (x86)\VNI\imsl\fnl600\Intel64\include\dll
    C:\Program Files (x86)\VNI\imsl\fnl600\Intel64\include\static
和C:\Program Files (x86)\VNI\imsl\fnl600\Intel64\lib
都加上了。
纠结啊,求指教,多谢多谢。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[Fortran] 纯文本查看 复制代码
program main
    include 'link_fnl_shared.h'
    include 'link_fnl_static.h'
use operation_x !//这句
implicit none
    integer,parameter::m=3,n=3
    integer::mi,ni,iaq,jaq
    real,parameter::hoa=7.0,h=0.1
    real::a(m,n)
    real::t(m,n)
    real::e(m,n)
    !
    open(24,file='test12311339.txt')
    do mi=1,m
       do ni=1,n
        t(mi,ni)=hoa*ni+hoa*mi
        a(mi,ni)=hoa*(ni-1)+hoa*mi
        end do
    end do
    e=a.x.t
    write(24,*)e
    end program

127

帖子

35

主题

1

精华

大师

F 币
1153 元
贡献
592 点
5#
发表于 2016-12-31 21:38:29 来自移动端 | 只看该作者
矩阵求逆Excel有现成的函数

127

帖子

35

主题

1

精华

大师

F 币
1153 元
贡献
592 点
地板
发表于 2016-12-31 21:37:54 来自移动端 | 只看该作者
矩阵求逆Excel
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

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

GMT+8, 2024-5-3 18:59

Powered by Tencent X3.4

© 2013-2024 Tencent

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