将变量号分配给复杂数组 [英] Assigning variable number to complex array

查看:57
本文介绍了将变量号分配给复杂数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将复杂数组分配为变量.我的代码就像

I want to assign complex array as variable. My code is like

        complex indx(3,3)
        integer i,j

        do i=1,3
          do j=1,3
            indx(i,j) = (i,j)                
            write(*,*) indx(i,j)
          end do
        end do

在这种情况下,我会收到类似的错误

and in this case I am getting an error like

 A symbol must be a defined parameter in this context.   [I]
                       indx(i,j) = (i,j)

推荐答案

您必须使用函数 cmplx 建立您要分配的复杂值.

You must use function cmplx to build a complex value you want to assign.

    complex indx(3,3)
    integer i,j

    do i=1,3
      do j=1,3
       indx(i,j) = cmplx(i,j)               
       write(*,*) indx(i,j)
      end do
    end do

您尝试过的语法仅对常量文字有效.

The syntax you tried is only valid for constant literals.

这篇关于将变量号分配给复杂数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆