Using ARRAYS and MATRICES

<< Click to Display Table of Contents >>

Navigation:  User Guide >

Using ARRAYS and MATRICES

Previous pageReturn to chapter overviewNext page

FlexPDE includes expanded capabilities for using ARRAYS and MATRICES.

ARRAYS and MATRICES differ from other objects in FlexPDE, such as VARIABLES or VECTORS, in that no assumptions are made about associations between the ARRAY or MATRIX and the geometry or mesh structure of the PDE model. ARRAYS and MATRICES are simply lists of numbers which can be defined, manipulated and accessed independently of any domain definition or coordinate geometry.

Typically, an ARRAY is created and filled with data using one of the available declaration statements, e.g.,

A = array(1,2,3,4,5,6,7,8,9,10)

B = array for x(0 by 0.1 to 10)  : sin(x)+1.1
 

New ARRAYS can be created by performing arithmetic operations on existing arrays:

C = exp(A)        { each element of C is the exponential of the corresponding element of A }

D = C+A        { each element of D is the sum of the corresponding elements of C and A }

E = 100*B        { each element of E is 100 times the corresponding element of B }
 

Elements can be accessed individually by indexing operations:

E[12] = B[3]+9
 

ARRAYS can be used in PLOT statements:

ELEVATION (D) VS A
 

Similarly, MATRICES can be created and filled with data using one of the available declaration statements, e.g.,

M = MATRIX((1,2,3),(4,5,6),(7,8,9))

N = MATRIX FOR x(0 BY 0.1 TO 10)

FOR y(0 BY 0.1 TO 10) : sin(x)*sin(y)+1.1
 

New ARRAYS or MATRICES can be created by performing element-by-element arithmetic operations on existing ARRAYS and MATRICES:

P = 1/M        { each element of matrix P is the reciprocal of the corresponding element of M }
Q = P+M

The special operators ** and // are defined for specifying conventional matrix-array arithmetic:

R = N**B        { R is an ARRAY representing the conventional matrix-array multiplication of B by N }

S = B//N        { S is the solution of the equation N**S=B (i.e., S is the result of multiplying B by the inverse of N) }
 

Elements of MATRICES can be accessed individually by indexing operations:

U = N[3,9]

 

ARRAYS and MATRICES may also be used to define domain boundaries.  See "Boundary Paths" in the Problem Descriptor Reference.

 

All operations on ARRAYS and MATRICES are checked for compatible sizes, and incompatibilities will be reported as errors.

Note: You must remember that the FlexPDE script is not a procedural program.  Objects in the script describe the dependencies of quantities, and are not "current state" records of values that can be explicitly modified by subsequent redefinition or looping.

Examples:

See the example folder "Samples | Usage | Arrays+Matrices"