4.3. Accessing Complex Scalar Values

The technique described here allows you to access the values of complex vectors (*VEC) or dense matrices (*DMAT) and to manipulate either the real part or the imaginary part.

A complex dense matrix is a 2D array of complex scalars. It can also be considered a 3D array of real values as shown in the figure below:

Figure 4.1: 3D Representation of a Complex Dense Matrix

3D Representation of a Complex Dense Matrix

The examples outlined below show several ways to access the complex scalar values.

  • To get the real part of a dense matrix term, you can use the syntax:

    VAL_RE = A(i,j,1)
    VAL_IM = A(i,j,2)
    

  • You can also set a new value directly, using the same logic:

    A(i,j,1) = 3.5
    A(i,j,2) = 0.0
    

  • Similarly, you can access the values of a complex vector:

    VAL_RE = V(i,1)
    VAL_IM = V(i,2)