 # Matrix

#### Matrix Overview

A Matrix is a one, two, or three dimensional array. An un-typed matrix (also known as a Normal Matrix) is a data structure containing an arbitrary number of heterogeneous data values and with a rank of one, two, or three.

 "Humpty" "Dumpty" "sat" "on" "a" "wall"

The Matrix is a dynamic data type: it can grow to containing new elements or contract as elements are deleted. An element is accessed by an index from 0 to n-1 where n is the number of elements in the Matrix. When an element is added, it is appended to the end.

 "Humpty" "Dumpty" "sat" "on" "a" "wall" "Humpty"

Or we might sort the Matrix

 "a" "Dumpty" "Humpty" "Humpty" "on" "sat" "wall"

Or we might delete a key by specify the index of the item to be deleted (2)

 "a" "Dumpty" "Humpty" "on" "sat" "wall"

#### When to Use

The Matrix object is useful for storing data of the "same" types (homogeneous) or "different" types (heterogeneous) . The Matrix object is very fast and has minimum memory overhead due to the indexed access of its values. If you require a random access strategy or a keyed access strategy see the Dictionary or Structure data types. Within the Matrix object type there are the subtypes that store homogeneous values:

Matrix

NumMatrix

#### Constant Form

The Matrix native data type has a constant form. A Matrix constant is enclosed in brackets and preceded by the sharp symbol (#).

For Example:

#(mat| 0 1 2 3 4 5 6 7 8 9)

The constant form for Matrix allows any Analytic Information Server objects:

#(mat| X: 5 #Jan,1,1996 #{Mike: "father" Sally: "mother"} "Hello")

#(mat| 23 34 "Testing" -.987 #\return)

#(mat| "Hello" 9 34.5)

#(mat| 0 1 2 3 4 5 6 7 8 9 . {a: 10 b: 20})

#### Object Data Types

The Matrix is a Heap Object or an Object Data Type. The Analytic Information Server Object Types are stored in the Heap and are managed by the Heap manager. The Analytic Information Server Heap manager supports object resizing, garbage collection, and anti-fragmentation algorithms so that the user may concentrate on the analysis and modeling of data rather than on memory management. Without exception, all of the Object types are identified by an object id. The object id identifies a block of memory, managed by the Lambda Information Server memory manager, in which the Object's data is stored.

The Analytic Information Server Heap Object and Native Data types can be saved and loaded to and from persistent (disk file) storage at any time. Containers with immediate data are saved on disk in fixed length records equal to the size of the container. Containers with Heap object references are saved in fixed length records, which are automatically expanded to include the contents of the Heap object, and any objects referenced by the Heap object, etc. This feature is called Object Closure Management and is automatic with every Analytic Information Server container database save.

Analytic Information Server containers may be loaded from any database repository record at any time. If the data in the record is immediate, the database load fills the container with the immediate data. If the data in the record is an object closure, the database load fills the container with a Heap object reference, and all of the objects in the record are loaded back into the Heap with the same referential relationships they had when they were saved in the repository.

#### Data Type Examples

The Matrix object can be demonstrated by the following examples.

 Example_Matrix_addMethod_008 Example_Matrix_append_007 Example_Matrix_apply_005 Example_Matrix_apply_006 Example_Matrix_binaryInsert_004 Example_Matrix_binaryInsert_005 Example_Matrix_binarySearch_005 Example_Matrix_binarySearch_006 Example_Matrix_cdr_007 Example_Matrix_cdr_008 Example_Matrix_compareEQ_007 Example_Matrix_compareGE_007 Example_Matrix_compareGT_007 Example_Matrix_compareLE_007 Example_Matrix_compareLT_007 Example_Matrix_compareNE_007 Example_Matrix_compare_007 Example_Matrix_comparison_007 Example_Matrix_copy_006 Example_Matrix_copy_007 Example_Matrix_count_005 Example_Matrix_defmethod_009 Example_Matrix_delete_009 Example_Matrix_insert_005 Example_Matrix_inside_005 Example_Matrix_isAtom_005 Example_Matrix_isEqual_005 Example_Matrix_isIdentical_005 Example_Matrix_isInside_05 Example_Matrix_isMatrix_001 Example_Matrix_isMember_005 Example_Matrix_isNumberMatrix_001 Example_Matrix_isObject_007 Example_Matrix_isType_009 Example_Matrix_length_008 Example_Matrix_makeGaussianMatrix_001 Example_Matrix_makeGramMatrix_001 Example_Matrix_map_006 Example_Matrix_map_007 Example_Matrix_mapc_005 Example_Matrix_matrixGaussianEliminate_001 Example_Matrix_matrixGaussianSubstitute_001 Example_Matrix_member_005 Example_Matrix_methodsOf_010 Example_Matrix_new_009 Example_Matrix_new_010 Example_Matrix_objectToMatrix_001 Example_Matrix_objectToNumMatrix_001 Example_Matrix_rank_001 Example_Matrix_ref_015 Example_Matrix_ref_016 Example_Matrix_remove_005 Example_Matrix_resize_005 Example_Matrix_reverse_002 Example_Matrix_send_008 Example_Matrix_setCdr_005 Example_Matrix_setLastCdr_005 Example_Matrix_setq_014 Example_Matrix_sizeof_007 Example_Matrix_sort_012 Example_Matrix_type_010 Example_Matrix_uniqueInsert_004 Example_Matrix_vectorFill_002