Is it possible to define arrays in GAP ? If not what is the replacement ?
closed as off topic by Math Gems, Micah, Arkamis, Sasha, Lord_Farin Apr 22 at 16:32
Questions on Mathematics Stack Exchange are expected to relate to math within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.
|
|||||||||||||||
|
Yes it is possible. GAP is rather versitile, so there's probably a number of ways of generating arrays, many of which I won't be able to address here since I'm not yet familiar with them. But I'll give some ways I use frequently. It is important to know that arrays in GAP are indexed starting from 1. This means there is no 0-th element. Method 1: We can input arrays directly by typing them. A simple example:
In the above example, there is a shorthand:
or as a more complicated example:
Here's a 2D example:
and we can generate arrays of arbitrarily high dimensions by taking arrays of arrays of ... of arrays. However, this input method can be time consuming if you have to type in arrays manually. Fortunately, there are other ways. Method 2: Adding an entry to a cell.
In the above example, we have 1D array of length 10 where the 5-th entry is the matrix $B$ and the 10-th entry is $2^{10}$. The other entries are empty. Combining this method with
However, there is an even more succinct method. Method 3: Defining arrays via
This is extremely handy for generating integer sequences for Sloane's OEIS. Or we can combine these to generate 2D arrays:
The $3i+j$ function can be replaced by an internal function, e.g.:
or a user-defined function, e.g.:
Method 4: Defining arrays from arrays. There are several methods for modifying arrays to give other arrays.
In the above example, we start with the array
The above is equivalent to Method 5: Multiplication tables. Since GAP is somewhat groups focused, they should get a mention. We can obtain matrices as the multiplication table of groups. For example:
|
|||
|
tar
but asking how to create a tar file preserving SELinux security contexts here would be off-topic! (and also answerable by reading the fine manual :-) ) – Mariano Suárez-Alvarez♦ Apr 2 at 18:44array
results in many irrelevant hits. A more realistic approach is using GAP's help function, e.g.?Determinant
, to find help, but even then?array
does not produce anything helpful. – Douglas S. Stones Apr 2 at 19:45