Skip to content Skip to navigation Skip to collection information

Connexions

You are here: Home » Content » Introduction to G Programming » Arrays and Clusters

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • NSF Partnership display tagshide tags

    This collection is included inLens: NSF Partnership in Signal Processing
    By: Sidney Burrus

    Click the "NSF Partnership" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

  • Featured Content display tagshide tags

    This collection is included inLens: Connexions Featured Content
    By: Connexions

    Click the "Featured Content" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

Arrays and Clusters

Module by: Eduardo Perez. E-mail the author

Summary: The creation of this content was supported in some part by NSF grant 0538934.

To create an array in G, right click on the Front Panel window and select Array from the Controls >> Modern >> Arrays, Matrix & Cluster menu, and drop the array structure onto the Front Panel window to create an array.

Figure 1: Array Structure
An array structure. The top level listing of the array is labeled Modern and underneath that level is Array, Matrix & Cluster. This level is identified by two icons in a gray shaded rectangle. The icon on the left is labeled Array and the icon on the right is labeled Cluster.

The array structure consists of an index or element offset (highlighted left portion of the array structure) and the array elements (right portion of the structure). When the array structure is placed on the Front Panel window, the data type of the array is undefined as indicated by the grayed out portion of the array.

Figure 2: Index and Elements of an Array
A screen capture showing up and down arrow buttons to the left of field containing the number 0. The arrow buttons and the field containing the number 1 are contained within a red square box labeled index. These elements are the upper left of a square labeled Elements.

To define the array data type, drag and drop any data type, such as numeric, Boolean, string or cluster structure, onto the elements portion of the array structure.

Figure 3: Creating Arrays
An array field screen capture.

At this point, the newly defined array is an Empty or NullArray because no elements of the array have been defined. This is indicated by the grayed out data type within the elements array structure.

Figure 4: Empty Arrays
A form labeled 'Array' with two fields. each field contains the value '0'.

To define elements of an input array, select the element’s index and enter the appropriate value. Figure 5 defines a numeric array with one element at index 0.

Figure 5: Defining Array Elements
A form labeled 'Array' with two fields. The left field contains the value '0' and the right field contains '1.2345'.

G arrays are zero-based. The last element index of an N element array is N-1. Figure 6 and Figure 7 are those of a 10 element array.

Figure 6: Last Array Element
A form labeled 'Array' with two fields. The left field contains the value '9' and the right field contains '9.1011'.
Figure 7: Undefined Nth Element
A form labeled 'Array' with two fields. The left field contains the value '10' and the right field contains '0'.

An output array is created similarly to an input array with the exception that an output data type needs to be dropped into the array structure.

Figure 8: Input and Output Arrays
A form with two sets of two fields. The left form is labeled 'Numeric Input Array' with the values '0' and '0'. The right form is labeled 'Numeric Output Array' with both values being '0'.

Multidimensional Arrays

To create multidimensional arrays, click on the array’s index and select Add Dimension from the menu.

Figure 10 shows a 2-dimensional array.

Figure 9: Creating Multidimensional Arrays
An array form overlaid with a menu. The item 'Add Dimension' is highlighted in blue.
Figure 10: Multidimensional Array
An array form with three fields. The values are '9', '9.1' and '1'.

Array Operators

Figure 11: Array Operators
A 4x7 table of icons contained under the direcotry levels 'Programming' and 'Array'.

Clusters

Clusters allow users to create compound data types by aggregating various and different data types into a single unit.

Figure 12: Empty Cluster
An empty cluster field.

Select the various data types and drag them onto the cluster structure. Figure 13 shows an Error Cluster consisting of a Boolean Error, a numeric ID and a string Message data types.

Figure 13: Cluster Example
An error cluster field with a green circle labeled 'Error'  and a field labeled 'ID' containing '2', and the last field is labeled 'Message' with the value 'Out of range'.

Cluster Operators

Figure 14: Cluster Operators
A 3x6 table of icons contained within the directory levels 'Programming'  and  'Cluster, Class, and Variant'.

Collection Navigation

Content actions

Download:

Collection as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add:

Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks