[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Entities are the basic objects (constants and variables) in Algae. They contain members and elements. Members contain information about the entity, such as the number of rows in a matrix. An entity's elements, if it has any, contain the data such as the value of a scalar. There are five classes:
Notice that a scalar is not the same as a one-element vector or matrix.
The element labels of a vector are themselves a vector.
The row and column labels of a matrix are vectors. The row label vector has the same number of elements as its matrix has rows, and likewise for the column label.
Several functions return tables. For example, the eig
function
returns a table that contains the matrices values
and
vectors
.
The entities contained in a table are members of it, so they can be
extracted using the . operator. Thus eig(A).values
returns
the eigenvalues of `A'.
"function"
, and `ilk', which is
either "user"
or "builtin"
.
The scalar
, vector
, and matrix
classes are known
collectively as arrays. These are the only classes that contain
elements, and all have the member type
that specifies the data
type. There are four types:
Scalar constants are specified in a manner similar to that used in other programming languages. Numeric constants can be given in decimal form, such as `32' or `32.0', or in scientific notation, such as `3.2E1'. In the latter notation, the letters `e' and `E' may be used interchangeably to prefix the exponent. White space (space, tab, etc.) is significant in that context, of course, so that `1.2e+3' (1200.0) is definitely not the same as `1.2e +3' (4.2).
A `character' constant is a sequence of one or more characters surrounded by matching double-quotes. Within the quotes, the backslash character may be used to introduce "escape sequences" for unusual characters like newline. For example, the string `"\""' is a string containing a single character (the right double-quote). The following escape sequences may be used:
\a
\b
\e
\f
\n
\r
\t
\v
\ooo
\xhh
The escape sequence \ooo
consists of a backslash followed by one,
two, or three octal digits, which are taken to specify the value of the
desired character. For example, \33
is the ASCII "escape"
character (which is also given by \e
). Likewise, the sequence
\xhh
consists of a backslash followed by `x', followed by
one or two hexadecimal digits, which specify the value of the desired
character. For example, \x1b
also specifies the ASCII "escape"
character.
If the character following the backslash is not one of those specified
above, then that character is taken literally. For example, \"
specifies the double-quote character--not the end of the character
constant.
Matrices may be generated by specifying their elements within brackets.
Commas separate elements within rows and semicolons separate the rows.
Thus [1,2;3,4]
specifies the matrix
[ 1 2 ] [ 3 4 ] |
A vector may be generated by using either of the forms `i:j' or
`i:j:k'. It is obtained by starting with the value `i' and
incrementing by `k' (or 1 if the first form is used) while
remaining between `i' and `j', inclusive. (Notice that this
is not the same format used by MATLAB.) For example, [1:8:2]
is
the same as [1,3,5,7]
. All elements within a matrix have the
same type (`integer', `real', etc.); conversion will be
performed automatically if possible.
The terms within the brackets may be constants, variables, or
expressions. For example, [1+2,3]
is the same as [3,3]
.
Matrices may be involved, as long as their dimensions are appropriate.
For example, if the variable `A' is defined to be equal to the
square matrix `[1,2;3,4]', then a new column could be appended to
it with the expression [A,[5;6]]
to yield
[ 1 2 5 ] [ 3 4 6 ] |
Matrices may be partitioned by specifying the desired row and column
numbers within brackets. For example, if `A' is a previously
defined matrix then A[1;1]
specifies a scalar having the value of
the element in the first row and the first column of `A'. The
semicolon within the parentheses separates the row specifiers from the
column specifiers.
Members of data structures are referred to by using the member operator
`.'. For example, the number of rows in a matrix is stored in the
member nr
, so A.nr
returns the number of rows in the
matrix A
. The member operator associates left to right, so that
A.type.type
returns the string "character"
.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |