Data types

Numbers
Strings
Structs
Cells
Mathnium classes and objects
Java classes and objects

Numbers (including complex numbers), numeric arrays, strings, structs (dictionaries/maps), and cells (arrays of elements which are not necessary of the same type) are the basic data types in Mathnium. Mathnium also has a facility for the definition of derived data types as classes, which are similar to Java classes, except that all fields and methods in a class have public access. The arrays may have arbitrary number of dimensions.

Numeric data types include the following:

Strings may be defined by enclosing the characters in single or double quotes. The main differnce in the two forms is that when the addition (+) operator is used with strings, the double quoted strings are concatenated, whereas the single quoted strings (character arrays) are treated as one dimensional numeric arrays in this context.
>>a="Java "
>>b="Programs"
>>a+b
Java Programs
>>c='Java '
>>d='Programs '
>>c+d
Error Invalid operand sizes for matrix addition/subtraction

 in \Main
>>c='Java     '
>>c+d
Columns 1 through 6
        154        211        229        200        146        129
Columns 7 through 9
        141        147         64
Apart from this distinction, both the forms of strings behave as character (numeric) arrays when used as operands for arithmetic, logical or ralational operators.

Structures are collections of data which can be accessed by string valued keys using the . notation for the keys.
>>a=struct("x",2,"y",'value',"z",rand(2,3)) // construct a struct with 3 fields
>>a
        x:      2
        z:      2X3 Real Matrix
        y:      value

>>a.x                // accesing the fields of a struct
         2
>>a.y
value
>>a.z
       0.1192       0.2547       0.4838
       0.7092       0.5313       0.9464
>>a.w=3    // Another way to define a field of a 'struct'
>>a
        x:      2
        w:      3
        z:      2X3 Real Matrix
        y:      value

Cells are arrays of data elements which are not necessarily all of the same type. Cells may be defined in a similar fashion as numeric arrays, except that braces ( { and }) have to be used instead of square brackets ([ and ]).
>>// A 2 X 3 array of cells.
>>a={2, 3, "Program"; rand(3,2), "Computer", struct("x",2,"y",3)}
>>a
[2]     [3]     [Program]
[3X2 Real Matrix]       [Computer]      [1X1 Struct Array]

>>a{1,1}       //  accessing the elements
         2
>>a[1,2]       // For accessing the elements, square brackets may also be used.
         3
>>a[2,1]
       0.8778       0.7014
       0.0349       0.5651
       0.6343       0.9999

>>a[2,3]
        x:      2
        y:      3

>>a{2,3}
        x:      2
        y:      3
Multi-dimenional cell arrays may also be defined as usual.
>>a{1,2,2}=10
>>a{2,2,2}="Arrays"
>>a
[:, :, 1]
[2]     [3]     [Program]
[3X2 Real Matrix]       [Computer]      [1X1 Struct Array]
[:, :, 2]
[null]  [10]    [null]
[null]  [Arrays]        [null]

>>a{1,1,2}=rand(2,2)+j_rand(2,2)
>>a
[:, :, 1]
[2]     [3]     [Program]
[3X2 Real Matrix]       [Computer]      [1X1 Struct Array]
[:, :, 2]
[2X2 Complex Matrix]    [10]    [null]
[null]  [Arrays]        [null]

>>a[1,1,2]
       0.9743 +     0.8799i          0.3372 +      0.045i
       0.1712 +     0.8715i          0.2501 +      0.134i

Any Java class in the class path may be instantiated and manipulated as in Java, without the need for declaring the type of variable.
>>Vector.class
class java.util.vector
>>Hashtable.class
class java.util.hashtable
>>a=new Vector()
>>a.add(10)
         1
>>a.add("Java Vector")
         1
>>a.add(rand(2,3))
         1
>>a
[10, Java Vector, [[D@1d225a7]
>>a[1]
        10
>>a[2]
Java Vector
>>a[3]
       0.1796       0.2813       0.0273
       0.8685       0.0048       0.2866

>>b=new Hashtable()
>>b.put("x",10)
>>b.put("y",[2 3; 4 5])
>>b.put("z",{1,"A string";10,[3 4]})
>>b
{x=10, z=[2X3 Cell], y=[[D@6ac461}
>>b.x
        10
>>b.y
          2          3
          4          5

>>b.z
[1]     [A string]
[10]    [1X2 Integer Matrix]

>>b.z{1,1}
         1
>>b.z{1,2}
A string
>>b.z{2,2}
          3          4