 SplitForm - Maple Help

LinearAlgebra

 SplitForm
 compute split form of a sparse rtable Calling Sequence SplitForm(X, opts) Parameters

 X - sparse rtable with hardware data type opts - optional equations controlling the details of the computation Options

 • sort = 0, 1, or 2
 With sort = 1 (the default) or sort = 2, the nonzero entries of $X$ will be sorted by index before computing the split form. With sort = 1, they will be sorted lexicographically by index: that is, sorted by the first index, ties (if any) being broken by the second index, further ties (if any) being broken by the third index, and so on. In other words, in the result, $\mathrm{A1}$ will be sorted, and among entries with equal values for $\mathrm{A1}$, the corresponding entries of $\mathrm{A2}$ will be sorted.
 The option sort = 2 can only be used if $X$ is two-dimensional (a Matrix or a 2-dimensional Array). It sorts the entries by the second index, breaking ties using the first index. This groups entries in the same column together.
 The option sort = 0 does not sort the entries; they are returned in the order in which they are stored in memory. Description

 • The SplitForm function computes the split form of the input rtable $X$, which needs to have one of the hardware data types. It thus performs the opposite function to FromSplitForm.
 • The split form of an $n$-dimensional rtable $X$ with $k$ nonzero entries consists of $n+1$ Vectors, $\mathrm{A1}$, $\mathrm{A2}$, ..., $\mathrm{An}$, and $B$, each with $k$ entries: for every nonzero entry ${X}_{\mathrm{a1},\mathrm{a2},\mathrm{...},\mathrm{an}}=b$, there is an index $i$ such that ${\mathrm{A1}}_{i}=\mathrm{a1}$, ${\mathrm{A2}}_{i}=\mathrm{a2}$, ..., ${\mathrm{An}}_{i}=\mathrm{an}$, and ${B}_{i}=b$. (If $X$ is a Vector, then $n=1$; if $X$ is a Matrix, then $n=2$.)
 • The Vectors $\mathrm{Aj}$ are of word-size integer data type; that is, on 32-bit platforms they will have data type ${\mathrm{integer}}_{4}$ and on 64-bit platforms data type ${\mathrm{integer}}_{8}$. The Vector $B$ has the same data type as $X$.
 • SplitForm returns a sequence of two objects; the first is the list $\left[\mathrm{A1},\mathrm{A2},\mathrm{...},\mathrm{An}\right]$, and the second is $B$.
 • The split form is most useful for sparse rtables. If $X$ does not have sparse storage (as determined by $\mathrm{rtable_option}\left(X,\mathrm{storage}\right)$ being either $\mathrm{sparse}$ or ${\mathrm{sparse}}_{\mathrm{upper}}$ or ${\mathrm{sparse}}_{\mathrm{lower}}$), then a sparse storage copy is made before determining the split form.
 • If $X$ has any indexing functions (as determined by $\mathrm{rtable_indfns}\left(X\right)$), then these are bypassed when determining the split form: since SplitForm is a low level command, Maple returns the split form of the stored entries only. For example, if a Matrix is defined with option $\mathrm{shape}=\mathrm{symmetric}$ and $\mathrm{storage}={\mathrm{sparse}}_{\mathrm{upper}}$, then only one of each pair of off-diagonal entries will be represented in the split form. However, if $X$ has indexing functions but no sparse storage, then the copy made to give it sparse storage, as explained above, typically gets rid of the indexing function and stores all nonzero entries.
 • The code for SplitForm relies on $X$ being a NAG-sparse Matrix (potentially after copying it to give it sparse storage); that is, its datatype as returned by rtable_options needs to be one of these values:
 $\mathrm{sfloat},\mathrm{complex}\left(\mathrm{sfloat}\right),{\mathrm{integer}}_{1},{\mathrm{integer}}_{2},{\mathrm{integer}}_{4},{\mathrm{integer}}_{8},{\mathrm{float}}_{4},{\mathrm{float}}_{8},{\mathrm{complex}}_{8}$ Examples

 > $\mathrm{with}\left(\mathrm{LinearAlgebra}\right):$

A basic example with a sparse Vector.

 > $V≔\mathrm{Vector}\left(10,\mathrm{datatype}=\mathrm{float}\left[8\right],\mathrm{storage}=\mathrm{sparse}\right)$
 ${V}{≔}\left[\begin{array}{c}{0.}\\ {0.}\\ {0.}\\ {0.}\\ {0.}\\ {0.}\\ {0.}\\ {0.}\\ {0.}\\ {0.}\end{array}\right]$ (1)
 > $V\left[2\right]≔1.;$$V\left[6\right]≔-3.$
 ${{V}}_{{2}}{≔}{1.}$
 ${{V}}_{{6}}{≔}{-3.}$ (2)
 > $\mathrm{SplitForm}\left(V\right)$
 $\left[\left[\begin{array}{c}{2}\\ {6}\end{array}\right]\right]{,}\left[\begin{array}{c}{1.}\\ {-3.}\end{array}\right]$ (3)

Notice below that the symmetric indexing function is ignored when constructing the split form.

 > $M≔\mathrm{Matrix}\left(6,\mathrm{datatype}=\mathrm{integer}\left[4\right],\mathrm{shape}=\mathrm{symmetric},\mathrm{storage}=\mathrm{sparse}\left[\mathrm{upper}\right],\left(i,j\right)↦\mathrm{if}\left(\mathrm{irem}\left(i+j,2\right)=1,\mathrm{abs}\left(i-j\right),0\right)\right)$
 ${M}{≔}\left[\begin{array}{cccccc}{0}& {1}& {0}& {3}& {0}& {5}\\ {1}& {0}& {1}& {0}& {3}& {0}\\ {0}& {1}& {0}& {1}& {0}& {3}\\ {3}& {0}& {1}& {0}& {1}& {0}\\ {0}& {3}& {0}& {1}& {0}& {1}\\ {5}& {0}& {3}& {0}& {1}& {0}\end{array}\right]$ (4)
 > $\mathrm{SplitForm}\left(M\right)$
 $\left[\left[\begin{array}{c}{1}\\ {1}\\ {1}\\ {2}\\ {2}\\ {3}\\ {3}\\ {4}\\ {5}\end{array}\right]{,}\left[\begin{array}{c}{2}\\ {4}\\ {6}\\ {3}\\ {5}\\ {4}\\ {6}\\ {5}\\ {6}\end{array}\right]\right]{,}\left[\begin{array}{c}{1}\\ {3}\\ {5}\\ {1}\\ {3}\\ {1}\\ {3}\\ {1}\\ {1}\end{array}\right]$ (5)

The split form cannot be computed for rtables that don't have a suitable data type.

 > $\mathrm{M2}≔\mathrm{Matrix}\left(3,3,\left(i,j\right)↦i-j\right)$
 ${\mathrm{M2}}{≔}\left[\begin{array}{ccc}{0}& {-1}& {-2}\\ {1}& {0}& {-1}\\ {2}& {1}& {0}\end{array}\right]$ (6)
 > $\mathrm{SplitForm}\left(\mathrm{M2}\right)$

To make this work, we need to recreate $\mathrm{M2}$ with, for example, option $\mathrm{datatype}={\mathrm{integer}}_{8}$.

 > $\mathrm{M2}≔\mathrm{Matrix}\left(\mathrm{M2},'\mathrm{datatype}=\mathrm{integer}\left[8\right]'\right)$
 ${\mathrm{M2}}{≔}\left[\begin{array}{ccc}{0}& {-1}& {-2}\\ {1}& {0}& {-1}\\ {2}& {1}& {0}\end{array}\right]$ (7)
 > $\mathrm{SplitForm}\left(\mathrm{M2},'\mathrm{sort}=2'\right)$
 $\left[\left[\begin{array}{c}{2}\\ {3}\\ {1}\\ {3}\\ {1}\\ {2}\end{array}\right]{,}\left[\begin{array}{c}{1}\\ {1}\\ {2}\\ {2}\\ {3}\\ {3}\end{array}\right]\right]{,}\left[\begin{array}{c}{1}\\ {2}\\ {-1}\\ {1}\\ {-2}\\ {-1}\end{array}\right]$ (8)

Here is an example with a 4-dimensional Array that has a nonzero entry whenever the indices form a permutation of $\left[1,2,3,4\right]$ that is not a derangement.

 > $A≔\mathrm{Array}\left(1..4,1..4,1..4,1..4,'\mathrm{datatype}=\mathrm{integer}\left[1\right]','\mathrm{storage}=\mathrm{sparse}'\right)$
 ${A}{≔}\begin{array}{c}\left[\begin{array}{cccc}{0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\\ {0}& {0}& {0}& {0}\end{array}\right]\\ \hfill {\text{slice of 4 × 4 × 4 × 4 Array}}\end{array}$ (9)
 > $\mathrm{with}\left(\mathrm{GroupTheory}\right):$
 > $\mathrm{permutations}≔\mathrm{Elements}\left(\mathrm{SymmetricGroup}\left(4\right)\right)$
 ${\mathrm{permutations}}{≔}\left\{\left({2}{,}{4}\right){,}\left({1}{,}{2}\right)\left({3}{,}{4}\right){,}\left({1}{,}{2}{,}{3}\right){,}\left({1}{,}{2}{,}{4}{,}{3}\right){,}\left({1}{,}{2}{,}{4}\right){,}\left({1}{,}{3}{,}{2}\right){,}\left({1}{,}{3}{,}{4}{,}{2}\right){,}\left({1}{,}{3}\right){,}\left({1}{,}{3}{,}{4}\right){,}\left({1}{,}{3}\right)\left({2}{,}{4}\right){,}\left({1}{,}{3}{,}{2}{,}{4}\right){,}\left({1}{,}{4}{,}{3}{,}{2}\right){,}\left({1}{,}{4}{,}{2}\right){,}\left({1}{,}{4}{,}{3}\right){,}\left({1}{,}{4}\right){,}\left({1}{,}{4}{,}{2}{,}{3}\right){,}\left({1}{,}{4}\right)\left({2}{,}{3}\right){,}\left(\right){,}\left({3}{,}{4}\right){,}\left({2}{,}{3}\right){,}\left({2}{,}{3}{,}{4}\right){,}\left({2}{,}{4}{,}{3}\right){,}\left({1}{,}{2}\right){,}\left({1}{,}{2}{,}{3}{,}{4}\right)\right\}$ (10)
 > $\mathbf{for}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathrm{perm}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathrm{permutations}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{lst}≔\mathrm{convert}\left(\mathrm{perm},'\mathrm{permlist}',4\right);\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}A\left[\mathrm{op}\left(\mathrm{lst}\right)\right]≔4-\mathrm{numelems}\left(\mathrm{PermSupport}\left(\mathrm{perm}\right)\right)\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}:$
 > $\mathrm{interface}\left(\mathrm{rtablesize}=15\right)$
 $\left[{10}{,}{10}\right]$ (11)
 > $\mathrm{SplitForm}\left(A\right)$
 $\left[\left[\begin{array}{c}{1}\\ {1}\\ {1}\\ {1}\\ {1}\\ {1}\\ {2}\\ {2}\\ {2}\\ {3}\\ {3}\\ {3}\\ {4}\\ {4}\\ {4}\end{array}\right]{,}\left[\begin{array}{c}{2}\\ {2}\\ {3}\\ {3}\\ {4}\\ {4}\\ {1}\\ {3}\\ {4}\\ {1}\\ {2}\\ {2}\\ {1}\\ {2}\\ {2}\end{array}\right]{,}\left[\begin{array}{c}{3}\\ {4}\\ {2}\\ {4}\\ {2}\\ {3}\\ {3}\\ {1}\\ {3}\\ {2}\\ {1}\\ {4}\\ {3}\\ {1}\\ {3}\end{array}\right]{,}\left[\begin{array}{c}{4}\\ {3}\\ {4}\\ {2}\\ {3}\\ {2}\\ {4}\\ {4}\\ {1}\\ {4}\\ {4}\\ {1}\\ {2}\\ {3}\\ {1}\end{array}\right]\right]{,}\left[\begin{array}{c}{4}\\ {2}\\ {2}\\ {1}\\ {1}\\ {2}\\ {2}\\ {1}\\ {1}\\ {1}\\ {2}\\ {1}\\ {1}\\ {1}\\ {2}\end{array}\right]$ (12) Compatibility

 • The LinearAlgebra[SplitForm] command was introduced in Maple 17.