Go to the first, previous, next, last section, table of contents.

## Types in Asir

In Asir, various objects described according to the syntax of Asir are translated to intermediate forms and by Asir interpreter further translated into internal forms with the help of basic algebraic engine. Such an object in an internal form has one of the following types listed below. In the list, the number coincides with the value returned by the built-in function `type()`. Each example shows possible forms of inputs for Asir's prompt.

`0 0`
  As a matter of fact, no object exists that has 0 as its identification number. The number 0 is implemented as a null (0) pointer of C language. For convenience's sake, a 0 is returned for the input `type(0)`.
`1 number`

      1 2/3  14.5  3+2*@i

  Numbers have sub-types. See section Types of numbers.
`2 polynomial (but not a number)`

      x  afo  (2.3*x+y)^10

  Every polynomial is maintained internally in its full expanded form, represented as a nested univariate polynomial, according to the current variable ordering, arranged by the descending order of exponents. (See section Distributed polynomial.) In the representation, the indeterminate (or variable), appearing in the polynomial, with maximum ordering is called the main variable. Moreover, we call the coefficient of the maximum degree term of the polynomial with respect to the main variable the leading coefficient.
`3 rational expression (not a polynomial)`

      (x+1)/(y^2-y-x)  x/x

  Note that in Risa/Asir a rational expression is not simplified by reducing the common divisors unless `red()` is called explicitly, even if it is possible. This is because the GCD computation of polynomials is a considerably heavy operation. You have to be careful enough in operating rational expressions.
`4 list`

      []  [1,2,[3,4],[x,y]]

  Lists are all read-only object. A null list is specified by `[]`. There are operations for lists: `car()`, `cdr()`, `cons()` etc. And further more, element referencing by indexing is available. Indexing is done by putting `[index]`'s after a program variable as many as are required. For example,

      [0] L = [[1,2,3],[4,[5,6]],7]$
      [1] L[1][1];
      [5,6]

  Notice that for lists, matrices and vectors, the index begins with number 0. Also notice that referencing list elements is done by following pointers from the first element. Therefore, it sometimes takes much more time to perform referencing operations on a large list than on a vectors or a matrices with the same size.
`5 vector`

      newvect(3)  newvect(2,[a,1])

  Vector objects are created only by explicit execution of `newvect()` command. The first example above creates a null vector object with 3 elements. The other example creates a vector object with 2 elements which is initialized such that its 0-th element is `a` and 1st element is `1`. The second argument for `newvect` is used to initialize elements of the newly created vector. A list with size smaller or equal to the first argument will be accepted. Elements of the initializing list is used from the left to the right. If the list is too short to specify all the vector elements, the unspecified elements are filled with as many 0's as are required. Any vector element is designated by indexing, e.g., `[index]`. `Asir` allows any type, including vector, matrix and list, for each respective element of a vector. As a matter of course, arrays with arbitrary dimensions can be represented by vectors, because each element of a vector can be a vector or matrix itself. An element designator of a vector can be a left value of assignment statement. This implies that an element designator is treated just like a simple program variable. Note that an assignment to the element designator of a vector has effect on the whole value of that vector.

      [0] A3 = newvect(3);
      [ 0 0 0 ]
      [1] for (I=0;I<3;I++)A3[I] = newvect(3);
      [2] for (I=0;I<3;I++)for(J=0;J<3;J++)A3[I][J]=newvect(3);
      [3] A3;
      [ [ [ 0 0 0 ] [ 0 0 0 ] [ 0 0 0 ] ] [ [ 0 0 0 ] [ 0 0 0 ] [ 0 0 0 ] ]
      [ [ 0 0 0 ] [ 0 0 0 ] [ 0 0 0 ] ] ]
      [4] A3[0];
      [ [ 0 0 0 ] [ 0 0 0 ] [ 0 0 0 ] ]
      [5] A3[0][0];
      [ 0 0 0 ]

`6 matrix`

      newmat(2,2)  newmat(2,3,[[x,y],[z]])

  Like vector objects, matrix objects are also created only by explicit execution of `newmat()` command. Initialization of the matrix elements are done in a similar manner with that of the vector elements except that the elements are specified by a list of lists. Each element, again a list, is used to initialize each row; if the list is too short to specify all the row elements, unspecified elements are filled with as many 0's as are required. Like vectors, any matrix element is designated by indexing, e.g., `[index][index]`. `Asir` also allows any type, including vector, matrix and list, for each respective element of a matrix. An element designator of a matrix can also be a left value of assignment statement. This implies that an element designator is treated just like a simple program variable. Note that an assignment to the element designator of a matrix has effect on the whole value of that matrix. Note also that every row, (not column,) of a matrix can be extracted and referred to as a vector.

      [0] M=newmat(2,3);
      [ 0 0 0 ]
      [ 0 0 0 ]
      [1] M[1];
      [ 0 0 0 ]
      [2] type(@@);
      5

`7 string`

      ""  "afo"

  Strings are used mainly for naming files. It is also used for giving comments of the results. Operator symbol `+` denote the concatenation operation of two strings.

      [0] "afo"+"take";
      afotake

`8 structure`

      newstruct(afo)

  The type structure is a simplified version of that in C language. It is defined as a fixed length array and each entry of the array is accessed by its name. A name is associated with each structure.
`9 distributed polynomial`

      2*<<0,1,2,3>>-3*<<1,2,3,4>>

  This is the short for `Distributed representation of polynomials.' This type is specially devised for computation of Groebner bases. Though for ordinary users this type may never be needed, it is provided as a distinguished type that user can operate by `Asir`. This is because the Groebner basis package provided with `Risa/Asir` is written in the `Asir` user language. For details See section Groebner basis computation.
`10 32bit unsigned integer`
`11 error object`
  These are special objects used for OpenXM.
`12 matrix over GF(2)`
  This is used for basis conversion in finite fields of characteristic 2.
`13 MATHCAP object`
  This object is used to express available funcionalities for Open XM.
`14 first order formula`
  This expresses a first order formula used in quantifier elimination.
`15 matrix over GF(p)`
  A matrix over a small finite field.
`16 byte array`
  An array of unsigned bytes.
`-1 VOID object`
  The object with the object identifier -1 indicates that a return value of a function is void.

Go to the first, previous, next, last section, table of contents.