ComplexAsFloat - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


ArrayTools

  

ComplexAsFloat

  

provide real view of a complex Matrix, Vector, or Array

 

Calling Sequence

Parameters

Description

Thread Safety

Examples

Calling Sequence

ComplexAsFloat(A)

Parameters

A

-

rectangular storage Matrix, Vector, or Array of data type complex[8] or complex(sfloat)

Description

• 

The ComplexAsFloat(A) command provides a double-size real view of an existing Matrix, Vector, or Array of complex[8] or complex(sfloat) data type. The input Matrix, Vector, or Array must have rectangular (dense) storage.

• 

ComplexAsFloat does not change the underlying data of the input rtable object. Instead, ComplexAsFloat casts it to an rtable object with the same specifications, the corresponding float datatype, and double the size in one of the dimensions of the input rtable. As such, changes to the contents of the view also affect the contents of the original input rtable, and vice-versa.

• 

If the original Matrix, Vector, or Array has been unassigned, it will still exist in the attributes of the real view, but changing the data will only affect the current view.

  

Important: Use this function with caution. If you remove the table reference from the attributes and unassign the original input object, accessing or changing the data in the view will crash Maple. If a persistent and permanent copy of the data is desired, then this command can be used in combination with copy or ArrayTools:-Copy.

• 

The layout of the output view from ComplexAsFloat is different for C_order and Fortran_order input, as indicated in the following description.

  

If the input rtable is C_order, then the last dimension of the input is doubled on output, and the real and imaginary parts of the input are interleaved (alternating) with respect to the last dimension. For example, calling ComplexAsFloat with a C_order 3 x 4 Matrix results in a 3 x 8 Matrix where the odd columns contain the real parts of the input Matrix, and the even columns contain the imaginary parts (see the Examples section).

  

If the input rtable is Fortran_order, then the first dimension of the input is doubled on output, and the real and imaginary parts of the input are interleaved (alternating) with respect to the first dimension. For example, calling ComplexAsFloat with a Fortran_order 3 x 4 Matrix results in a 6 x 4 Matrix where the odd rows contain the real parts of the input Matrix, and the even rows contain the imaginary parts (see the Examples section).

• 

This command can be used in combination with ArrayTools:-Fill to clear or set the real or imaginary parts of a complex Matrix, or can be used in combination with ArrayTools:-Copy to efficiently extract the real or imaginary parts of a complex Matrix.

• 

This function is part of the ArrayTools package, so it can be used in the short form ComplexAsFloat(..) only after executing the command with(ArrayTools).  However, it can always be accessed through the long form of the command by using ArrayTools[ComplexAsFloat](..).

Thread Safety

• 

The ComplexAsFloat command is thread safe as of Maple 2023, provided that the rtable A is not shared between threads.

• 

For more information on thread safety, see index/threadsafe.

Examples

withArrayTools:

C_order 3 x 4 Matrix

AMatrix3,4,i,ji+10jIi+10j,datatype=complex8,order=C_order

A11.11.I21.21.I31.31.I41.41.I12.12.I22.22.I32.32.I42.42.I13.13.I23.23.I33.33.I43.43.I

(1)

ArComplexAsFloatA

Ar11.−11.21.−21.31.−31.41.−41.12.−12.22.−22.32.−32.42.−42.13.−13.23.−23.33.−33.43.−43.

(2)

Use the Fill command to clear imaginary part only. Note this affects A and Ar.

Fill0,Ar,1,2

Ar

11.0.21.0.31.0.41.0.12.0.22.0.32.0.42.0.13.0.23.0.33.0.43.0.

(3)

A

11.+0.I21.+0.I31.+0.I41.+0.I12.+0.I22.+0.I32.+0.I42.+0.I13.+0.I23.+0.I33.+0.I43.+0.I

(4)

Use the Copy command to extract the real part to an existing Matrix.

BMatrix3,4,datatype=float8,order=C_order:

CopyAr,0,2,B

B

11.21.31.41.12.22.32.42.13.23.33.43.

(5)

Fortran_order 3 x 4 Matrix

AMatrix3,4,i,ji+10jIi+10j,datatype=complex8,order=Fortran_order

A11.11.I21.21.I31.31.I41.41.I12.12.I22.22.I32.32.I42.42.I13.13.I23.23.I33.33.I43.43.I

(6)

ArComplexAsFloatA

Ar11.21.31.41.−11.−21.−31.−41.12.22.32.42.−12.−22.−32.−42.13.23.33.43.−13.−23.−33.−43.

(7)

See Also

ArrayTools

ArrayTools[Copy]

ArrayTools[Fill]

C_order

copy

Fortran_order

Matrix