Debian Codegraph @

doc/ref/chap26.html

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
4 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5
6 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
7 <head>
8 <title>GAP (ref) - Chapter 26: Vector and Matrix Objects</title>
9 <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
10 <meta name="generator" content="GAPDoc2HTML" />
11 <link rel="stylesheet" type="text/css" href="manual.css" />
12 <script src="manual.js" type="text/javascript"></script>
13 <script type="text/javascript">overwriteStyle();</script>
14 </head>
15 <body class="chap26" onload="jscontent()">
16
17
18 <div class="chlinktop"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a> <a href="chap1.html">1</a> <a href="chap2.html">2</a> <a href="chap3.html">3</a> <a href="chap4.html">4</a> <a href="chap5.html">5</a> <a href="chap6.html">6</a> <a href="chap7.html">7</a> <a href="chap8.html">8</a> <a href="chap9.html">9</a> <a href="chap10.html">10</a> <a href="chap11.html">11</a> <a href="chap12.html">12</a> <a href="chap13.html">13</a> <a href="chap14.html">14</a> <a href="chap15.html">15</a> <a href="chap16.html">16</a> <a href="chap17.html">17</a> <a href="chap18.html">18</a> <a href="chap19.html">19</a> <a href="chap20.html">20</a> <a href="chap21.html">21</a> <a href="chap22.html">22</a> <a href="chap23.html">23</a> <a href="chap24.html">24</a> <a href="chap25.html">25</a> <a href="chap26.html">26</a> <a href="chap27.html">27</a> <a href="chap28.html">28</a> <a href="chap29.html">29</a> <a href="chap30.html">30</a> <a href="chap31.html">31</a> <a href="chap32.html">32</a> <a href="chap33.html">33</a> <a href="chap34.html">34</a> <a href="chap35.html">35</a> <a href="chap36.html">36</a> <a href="chap37.html">37</a> <a href="chap38.html">38</a> <a href="chap39.html">39</a> <a href="chap40.html">40</a> <a href="chap41.html">41</a> <a href="chap42.html">42</a> <a href="chap43.html">43</a> <a href="chap44.html">44</a> <a href="chap45.html">45</a> <a href="chap46.html">46</a> <a href="chap47.html">47</a> <a href="chap48.html">48</a> <a href="chap49.html">49</a> <a href="chap50.html">50</a> <a href="chap51.html">51</a> <a href="chap52.html">52</a> <a href="chap53.html">53</a> <a href="chap54.html">54</a> <a href="chap55.html">55</a> <a href="chap56.html">56</a> <a href="chap57.html">57</a> <a href="chap58.html">58</a> <a href="chap59.html">59</a> <a href="chap60.html">60</a> <a href="chap61.html">61</a> <a href="chap62.html">62</a> <a href="chap63.html">63</a> <a href="chap64.html">64</a> <a href="chap65.html">65</a> <a href="chap66.html">66</a> <a href="chap67.html">67</a> <a href="chap68.html">68</a> <a href="chap69.html">69</a> <a href="chap70.html">70</a> <a href="chap71.html">71</a> <a href="chap72.html">72</a> <a href="chap73.html">73</a> <a href="chap74.html">74</a> <a href="chap75.html">75</a> <a href="chap76.html">76</a> <a href="chap77.html">77</a> <a href="chap78.html">78</a> <a href="chap79.html">79</a> <a href="chap80.html">80</a> <a href="chap81.html">81</a> <a href="chap82.html">82</a> <a href="chap83.html">83</a> <a href="chap84.html">84</a> <a href="chap85.html">85</a> <a href="chap86.html">86</a> <a href="chap87.html">87</a> <a href="chapBib.html">Bib</a> <a href="chapInd.html">Ind</a> </div>
19
20 <div class="chlinkprevnexttop">&nbsp;<a href="chap0.html">[Top of Book]</a>&nbsp; <a href="chap0.html#contents">[Contents]</a>&nbsp; &nbsp;<a href="chap25.html">[Previous Chapter]</a>&nbsp; &nbsp;<a href="chap27.html">[Next Chapter]</a>&nbsp; </div>
21
22 <p id="mathjaxlink" class="pcenter"><a href="chap26_mj.html">[MathJax on]</a></p>
23 <p><a id="X856C23B87E50F118" name="X856C23B87E50F118"></a></p>
24 <div class="ChapSects"><a href="chap26.html#X856C23B87E50F118">26 <span class="Heading">Vector and Matrix Objects</span></a>
25 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap26.html#X7A7275C27EC61ACE">26.1 <span class="Heading">Concepts and Rules for Vector and Matrix Objects</span></a>
26 </span>
27 </div>
28 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap26.html#X7C6CDBFE7EB083A5">26.2 <span class="Heading">Categories of Vector and Matrix Objects</span></a>
29 </span>
30 <div class="ContSSBlock">
31 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7D963FCC7E849BE0">26.2-1 IsVectorObj</a></span>
32 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7E7617A0781D1E4B">26.2-2 IsMatrixObj</a></span>
33 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7D1ACCBE7E9CF501">26.2-3 IsMatrixOrMatrixObj</a></span>
34 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X78CD88A283330E72">26.2-4 IsRowListMatrix</a></span>
35 </div></div>
36 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap26.html#X877A706186C89ADB">26.3 <span class="Heading">Defining Attributes of Vector and Matrix Objects</span></a>
37 </span>
38 <div class="ContSSBlock">
39 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X8662026C7CCDB446">26.3-1 <span class="Heading">BaseDomain</span></a>
40 </span>
41 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X85ABF33684865ED5">26.3-2 <span class="Heading">ConstructingFilter</span></a>
42 </span>
43 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X818702FD7A2E9D90">26.3-3 <span class="Heading">CompatibleVectorFilter</span></a>
44 </span>
45 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X828BA5E1849E3D06">26.3-4 Length</a></span>
46 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X820ED34380C10E19">26.3-5 <span class="Heading">NumberRows and NumberColumns</span></a>
47 </span>
48 </div></div>
49 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap26.html#X7BD7D2837BFDE649">26.4 <span class="Heading">Constructing Vector and Matrix Objects</span></a>
50 </span>
51 <div class="ContSSBlock">
52 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X860E84397BD148E9">26.4-1 <span class="Heading">NewVector and NewZeroVector</span></a>
53 </span>
54 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X79A6544D86261E82">26.4-2 <span class="Heading">Vector</span></a>
55 </span>
56 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7DBA8BF5844F3281">26.4-3 <span class="Heading">ZeroVector</span></a>
57 </span>
58 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7AD2210B8047FB01">26.4-4 <span class="Heading">NewMatrix, NewZeroMatrix, NewIdentityMatrix</span></a>
59 </span>
60 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X879384D479EB1D82">26.4-5 <span class="Heading">Matrix</span></a>
61 </span>
62 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X838F5B6C7C87C8E1">26.4-6 <span class="Heading">ZeroMatrix</span></a>
63 </span>
64 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7D807ABC7FCB4E77">26.4-7 <span class="Heading">IdentityMatrix</span></a>
65 </span>
66 </div></div>
67 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap26.html#X7C7F5250855C4371">26.5 <span class="Heading">Operations for Base Domains of Vector and Matrix Objects</span></a>
68 </span>
69 <div class="ContSSBlock">
70 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X85D7A6A782B21E5C">26.5-1 <span class="Heading">OneOfBaseDomain and ZeroOfBaseDomain</span></a>
71 </span>
72 </div></div>
73 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap26.html#X7954E20987E0B260">26.6 <span class="Heading">Operations for Vector and Matrix Objects</span></a>
74 </span>
75 <div class="ContSSBlock">
76 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7FFC60A27FE6FA97">26.6-1 <span class="Heading">Comparison of Vector and Matrix Objects</span></a>
77 </span>
78 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7FBBE79478012648">26.6-2 <span class="Heading">Unpack</span></a>
79 </span>
80 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X85E896F67CE2F925">26.6-3 <span class="Heading">ChangedBaseDomain</span></a>
81 </span>
82 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X83DD8B39864A2C94">26.6-4 <span class="Heading">Randomize</span></a>
83 </span>
84 </div></div>
85 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap26.html#X7FE662477F36A21F">26.7 <span class="Heading">List Like Operations for Vector Objects</span></a>
86 </span>
87 <div class="ContSSBlock">
88 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7D5DF49C7ADB6986">26.7-1 <span class="Heading">Element Access and Assignment for Vector Objects</span></a>
89 </span>
90 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7A21731C83EE3BB0">26.7-2 PositionNonZero</a></span>
91 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7ABDE1B685A78326">26.7-3 PositionLastNonZero</a></span>
92 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X790013817E314B2D">26.7-4 ListOp</a></span>
93 </div></div>
94 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap26.html#X7FDF7655852AEAAE">26.8 <span class="Heading">Arithmetical Operations for Vector Objects</span></a>
95 </span>
96 <div class="ContSSBlock">
97 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7F8CE23F7A250072">26.8-1 <span class="Heading">Unary Arithmetical Operations for Vector Objects</span></a>
98 </span>
99 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X85A815CA790094CC">26.8-2 <span class="Heading">Binary Arithmetical Operations for Vector Objects</span></a>
100 </span>
101 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X876090A684E71C93">26.8-3 AddVector</a></span>
102 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X8039D013817317C3">26.8-4 MultVector</a></span>
103 </div></div>
104 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap26.html#X7BE9D278852C13BC">26.9 <span class="Heading">Operations for Vector Objects</span></a>
105 </span>
106 <div class="ContSSBlock">
107 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7AC470557EC90714">26.9-1 <span class="Heading">ConcatenationOfVectors</span></a>
108 </span>
109 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7DBE956E7F9C700E">26.9-2 ExtractSubVector</a></span>
110 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X80EC354D78D7B5A6">26.9-3 CopySubVector</a></span>
111 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X866366E587991171">26.9-4 WeightOfVector</a></span>
112 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X81ACAE017C00F782">26.9-5 DistanceOfVectors</a></span>
113 </div></div>
114 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap26.html#X81CC13CA7A1FF4AA">26.10 <span class="Heading">Arithmetical Operations for Matrix Objects</span></a>
115 </span>
116 <div class="ContSSBlock">
117 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X819F87A07DA7E2DC">26.10-1 <span class="Heading">Unary Arithmetical Operations for Matrix Objects</span></a>
118 </span>
119 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7BBB70557A7A9591">26.10-2 <span class="Heading">Binary Arithmetical Operations for Matrix Objects</span></a>
120 </span>
121 </div></div>
122 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap26.html#X85FAB7E778A71C19">26.11 <span class="Heading">Operations for Matrix Objects</span></a>
123 </span>
124 <div class="ContSSBlock">
125 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X870FBE817C884AB5">26.11-1 MatElm</a></span>
126 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7C33059984635480">26.11-2 SetMatElm</a></span>
127 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X838B45F7790E9FDF">26.11-3 ExtractSubMatrix</a></span>
128 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X793CD4637F237915">26.11-4 MutableCopyMatrix</a></span>
129 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7ED9E5D4809E3B50">26.11-5 CopySubMatrix</a></span>
130 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X809A6B3F7EA5E7D8">26.11-6 CompatibleVector</a></span>
131 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7EE70D5A81E9ED72">26.11-7 RowsOfMatrix</a></span>
132 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7E06762479A00DF4">26.11-8 <span class="Heading">CompanionMatrix</span></a>
133 </span>
134 </div></div>
135 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap26.html#X7D40EE2084A6C976">26.12 <span class="Heading">Operations for Row List Matrix Objects</span></a>
136 </span>
137 <div class="ContSSBlock">
138 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X82C4FCFA808010F8">26.12-1 <span class="Heading">List Access for a Row List Matrix</span></a>
139 </span>
140 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7F89BB2482D28AAE">26.12-2 <span class="Heading">List Assignment for a Row List Matrix</span></a>
141 </span>
142 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X807518367C96516F">26.12-3 <span class="Heading">Sublist Access for a Row List Matrix</span></a>
143 </span>
144 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X8371789181FA136B">26.12-4 <span class="Heading">Sublist Assignment for a Row List Matrix</span></a>
145 </span>
146 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X872E63867803ED78"><code>26.12-5 IsBound<span>\</span>[<span>\</span>]</code></a></span>
147 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X79328CB280C71DDB"><code>26.12-6 Unbind<span>\</span>[<span>\</span>]</code></a></span>
148 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7BDD838579E4D2D6">26.12-7 Add</a></span>
149 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X86E355D07A41C025">26.12-8 Remove</a></span>
150 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X82D0359B81F8D442">26.12-9 Append</a></span>
151 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7E234F717BE333EA">26.12-10 ShallowCopy</a></span>
152 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7E9F095E85DED480">26.12-11 ListOp</a></span>
153 </div></div>
154 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap26.html#X7B86A8487B12F9BD">26.13 <span class="Heading">Basic operations for row/column reductions</span></a>
155 </span>
156 <div class="ContSSBlock">
157 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7B3997D37CC44FCA">26.13-1 MultMatrixRowLeft</a></span>
158 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X794636447E8C5553">26.13-2 MultMatrixRowRight</a></span>
159 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X80AF7B267E6B9CE0">26.13-3 MultMatrixColumnRight</a></span>
160 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X843DAFE37F347471">26.13-4 MultMatrixColumnLeft</a></span>
161 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X8662EB748629502F">26.13-5 AddMatrixRowsLeft</a></span>
162 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7CD05EE984614AB6">26.13-6 AddMatrixRowsRight</a></span>
163 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7B1E1E417CA267A3">26.13-7 AddMatrixColumnsRight</a></span>
164 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X85ECB8C87DFD8F32">26.13-8 AddMatrixColumnsLeft</a></span>
165 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X86B9C2EC8794BFE0">26.13-9 PositionNonZeroInRow</a></span>
166 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X87CCA3117F6B3F0D">26.13-10 SwapMatrixRows</a></span>
167 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X824C8A347EB9D499">26.13-11 SwapMatrixColumns</a></span>
168 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7E3B10A67BC7F006">26.13-12 AddMatrix</a></span>
169 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X85DAF850790CD476">26.13-13 MultMatrix</a></span>
170 </div></div>
171 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap26.html#X7BEE647484978886">26.14 <span class="Heading">Implementing New Vector and Matrix Objects Types</span></a>
172 </span>
173 </div>
174 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap26.html#X82EEE1D37A94F807">26.15 <span class="Heading">Available Representations of Vector Objects</span></a>
175 </span>
176 <div class="ContSSBlock">
177 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7C8050938691A914">26.15-1 IsGF2VectorRep</a></span>
178 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X82A643007EC6D1CA">26.15-2 Is8BitVectorRep</a></span>
179 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X83262B7085FA94E3">26.15-3 IsPlistVectorRep</a></span>
180 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X8730DB7D7E7DA883">26.15-4 IsZmodnZVectorRep</a></span>
181 </div></div>
182 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap26.html#X7CFD844C7D80D541">26.16 <span class="Heading">Available Representations of Matrix Objects</span></a>
183 </span>
184 <div class="ContSSBlock">
185 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7F6078FF81E912E7">26.16-1 IsGF2MatrixRep</a></span>
186 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X81466B6C7CAC3A7B">26.16-2 Is8BitMatrixRep</a></span>
187 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X80C6031C7DB31A15">26.16-3 IsPlistMatrixRep</a></span>
188 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X8206177679151859">26.16-4 IsGenericMatrixRep</a></span>
189 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X84D0F3117DA86850">26.16-5 IsZmodnZMatrixRep</a></span>
190 </div></div>
191 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap26.html#X82BD536483B78DB9">26.17 <span class="Heading">Groups Consisting of Matrix Objects</span></a>
192 </span>
193 <div class="ContSSBlock">
194 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap26.html#X7F7E8B6F7D008CF2">26.17-1 ConstructingFiltersForMatrixGroupElements</a></span>
195 </div></div>
196 <div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap26.html#X786024B686AFAD91">26.18 <span class="Heading">How to Write Code for Vector and Matrix Objects</span></a>
197 </span>
198 </div>
199 </div>
200
201 <h3>26 <span class="Heading">Vector and Matrix Objects</span></h3>
202
203 <p>This chapter describes an interface to vector and matrix objects which are not represented by plain lists (of plain lists), cf. Chapters <a href="chap23.html#X82C7E6CF7BA03391"><span class="RefLink">23</span></a> and <a href="chap24.html#X812CCAB278643A59"><span class="RefLink">24</span></a>.</p>
204
205 <p><a id="X7A7275C27EC61ACE" name="X7A7275C27EC61ACE"></a></p>
206
207 <h4>26.1 <span class="Heading">Concepts and Rules for Vector and Matrix Objects</span></h4>
208
209 <p>Traditionally, vectors and matrices in <strong class="pkg">GAP</strong> have been represented by (lists of) lists, see the chapters <a href="chap23.html#X82C7E6CF7BA03391"><span class="RefLink">23</span></a> and <a href="chap24.html#X812CCAB278643A59"><span class="RefLink">24</span></a>. More precisely, the term <q>vector</q> (corresponding to the filter <code class="func">IsVector</code> (<a href="chap31.html#X802F34F280B29DF4"><span class="RefLink">31.14-14</span></a>)) is used in the abstract sense of an <q>element of a vector space</q>, the term <q>row vector</q> (corresponding to <code class="func">IsRowVector</code> (<a href="chap23.html#X7DFB22A07836A7A9"><span class="RefLink">23.1-1</span></a>)) is used to denote a <q>coordinate vector</q> which is represented by a <strong class="pkg">GAP</strong> list (see <code class="func">IsList</code> (<a href="chap21.html#X7C4CC4EA8299701E"><span class="RefLink">21.1-1</span></a>)), and the term <q>matrix</q> is used to denote a list of lists, with additional properties (see <code class="func">IsMatrix</code> (<a href="chap24.html#X7E1AE46B862B185F"><span class="RefLink">24.2-1</span></a>)).</p>
210
211 <p>Unfortunately, such lists (objects in <code class="func">IsPlistRep</code> (<a href="chap21.html#X87BA4EBF80F16B72"><span class="RefLink">21.24-2</span></a>)) cannot store their type, and so it is impossible to use the advantages of <strong class="pkg">GAP</strong>'s method selection on them. This situation is unsustainable in the long run since more special representations (compressed, sparse, etc.) have already been and even more will be implemented. Here we describe a programming interface to vectors and matrices, which solves this problem,</p>
212
213 <p>The idea of this interface is that <strong class="pkg">GAP</strong> should be able to represent vectors and matrices by objects that store their type, in order to benefit from method selection. These objects are created by <code class="func">Objectify</code> (<a href="chap79.html#X7CB5C12E813F512B"><span class="RefLink">79.1-1</span></a>), we therefore refer to the them as <q>vector objects</q> and <q>matrix objects</q> respectively.</p>
214
215 <p>(Of course the terminology is somewhat confusing: An <q>abstract matrix</q> in <strong class="pkg">GAP</strong> can be represented either by a list of lists or by a matrix object. It can be detected from the filter <code class="func">IsMatrixOrMatrixObj</code> (<a href="chap26.html#X7D1ACCBE7E9CF501"><span class="RefLink">26.2-3</span></a>); this is the union of the filters <code class="func">IsMatrix</code> (<a href="chap24.html#X7E1AE46B862B185F"><span class="RefLink">24.2-1</span></a>) –which denotes those matrices that are represented by lists of lists– and the filter <code class="func">IsMatrixObj</code> (<a href="chap26.html#X7E7617A0781D1E4B"><span class="RefLink">26.2-2</span></a>) –which defines <q>proper</q> matrix objects in the above sense. In particular, we do <em>not</em> regard the objects in <code class="func">IsMatrix</code> (<a href="chap24.html#X7E1AE46B862B185F"><span class="RefLink">24.2-1</span></a>) as special cases of objects in <code class="func">IsMatrixObj</code> (<a href="chap26.html#X7E7617A0781D1E4B"><span class="RefLink">26.2-2</span></a>), or vice versa. Thus one can install specific methods for all three situations: just for <q>proper</q> matrix objects, just for matrices represented by lists of lists, or for both kinds of matrices. For example, a <strong class="pkg">GAP</strong> package may decide to accept only <q>proper</q> matrix objects as arguments of its functions, or it may try to support also objects in <code class="func">IsMatrix</code> (<a href="chap24.html#X7E1AE46B862B185F"><span class="RefLink">24.2-1</span></a>) as far as this is possible.)</p>
216
217 <p>We want to be able to write (efficient) code that is independent of the actual representation (in the sense of <strong class="pkg">GAP</strong>'s representation filters, see Section <a href="chap13.html#X8698205F8648EB33"><span class="RefLink">13.4</span></a>) and preserves it.</p>
218
219 <p>This latter requirement makes it necessary to distinguish between different representations of matrices: <q>Row list</q> matrices (see <code class="func">IsRowListMatrix</code> (<a href="chap26.html#X78CD88A283330E72"><span class="RefLink">26.2-4</span></a>) behave basically like lists of rows, in particular the rows are individual <strong class="pkg">GAP</strong> objects that can be shared between different matrix objects. One can think of other representations of matrices, such as matrices whose subobjects represent columns, or <q>flat</q> matrices which do not have subobjects like rows or columns at all. The different kinds of matrices have to be distinguished already with respect to the definition of the operations for them.</p>
220
221 <p>In particular vector and matrix objects know their base domain (see <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>)) and their dimensions. The basic condition is that the entries of vector and matrix objects must either lie in the base domain or naturally embed in the sense that addition and multiplication automatically work with elements of the base domain; for example, a matrix object over a polynomial ring may also contain entries from the coefficient ring.</p>
222
223 <p>Vector and matrix objects may be mutable or immutable. Of course all operations changing an object are only allowed/implemented for mutable variants.</p>
224
225 <p>Vector objects are equal with respect to <code class="func">\=</code> (<a href="chap31.html#X7EF67D047F03CA6F"><span class="RefLink">31.11-1</span></a>) if they have the same length and the same entries. It is not necessary that they have the same base domain. Matrices are equal with respect to <code class="func">\=</code> (<a href="chap31.html#X7EF67D047F03CA6F"><span class="RefLink">31.11-1</span></a>) if they have the same dimensions and the same entries.</p>
226
227 <p>For a row list matrix object, it is not guaranteed that all its rows have the same vector type. It is for example thinkable that a matrix object stores some of its rows in a sparse representation and some in a dense one. However, it is guaranteed that the rows of two matrices in the same representation are compatible in the sense that all vector operations defined in this interface can be applied to them and that new matrices in the same representation as the original matrix can be formed out of them.</p>
228
229 <p>Note that there is neither a default mapping from the set of matrix object representations to the set of vector representations nor one in the reverse direction. There is in general no <q>associated</q> vector object representation to a matrix object representation or vice versa. (However, <code class="func">CompatibleVectorFilter</code> (<a href="chap26.html#X818702FD7A2E9D90"><span class="RefLink">26.3-3</span></a>) may describe a vector object representation that is compatible with a given matrix object.)</p>
230
231 <p>The recommended way to write code that preserves the representation basically works by using constructing operations that take template objects to decide about the intended representation for the new object.</p>
232
233 <p>Vector and matrix objects do not have to be <strong class="pkg">GAP</strong> lists in the sense of <code class="func">IsList</code> (<a href="chap21.html#X7C4CC4EA8299701E"><span class="RefLink">21.1-1</span></a>). Note that objects not in the filter <code class="func">IsList</code> (<a href="chap21.html#X7C4CC4EA8299701E"><span class="RefLink">21.1-1</span></a>) need not support all list operations, and their behaviour is not prescribed by the rules for lists, e.g., behaviour w.r.t. arithmetic operations. However, row list matrices behave nearly like lists of row vectors that insist on being dense and containing only vectors of the same length and with the same base domain.</p>
234
235 <p>Vector and matrix objects are not likely to benefit from <strong class="pkg">GAP</strong>'s immediate methods (see section <a href="chap78.html#X87D38D2584D0A8AF"><span class="RefLink">78.7</span></a>). Therefore it may be useful to set the filter <code class="func">IsNoImmediateMethodsObject</code> (<a href="chap78.html#X80C3A19E7B99BB41"><span class="RefLink">78.7-2</span></a>) in the definition of new kinds of vector and matrix objects.</p>
236
237 <p>For information on how to implement new <code class="func">IsMatrixObj</code> (<a href="chap26.html#X7E7617A0781D1E4B"><span class="RefLink">26.2-2</span></a>) and <code class="func">IsVectorObj</code> (<a href="chap26.html#X7D963FCC7E849BE0"><span class="RefLink">26.2-1</span></a>) representations see Section <a href="chap26.html#X7BEE647484978886"><span class="RefLink">26.14</span></a>.</p>
238
239 <p><a id="X7C6CDBFE7EB083A5" name="X7C6CDBFE7EB083A5"></a></p>
240
241 <h4>26.2 <span class="Heading">Categories of Vector and Matrix Objects</span></h4>
242
243 <p>Currently the following categories of vector and matrix objects are supported in <strong class="pkg">GAP</strong>. More can be added as soon as there is need for them.</p>
244
245 <p><a id="X7D963FCC7E849BE0" name="X7D963FCC7E849BE0"></a></p>
246
247 <h5>26.2-1 IsVectorObj</h5>
248
249 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsVectorObj</code>( <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;category&nbsp;)</td></tr></table></div>
250 <p>The idea behind <em>vector objects</em> is that one wants to deal with objects like coefficient lists of fixed length over a given domain <span class="SimpleMath">R</span>, say, which can be added and can be multiplied from the left with elements from <span class="SimpleMath">R</span>. A vector object <span class="SimpleMath">v</span>, say, is always a copyable object (see <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>)) in <code class="func">IsVector</code> (<a href="chap31.html#X802F34F280B29DF4"><span class="RefLink">31.14-14</span></a>), which knows the values of <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) (with value <span class="SimpleMath">R</span>) and <code class="func">Length</code> (<a href="chap21.html#X780769238600AFD1"><span class="RefLink">21.17-5</span></a>), where <span class="SimpleMath">R</span> is a domain (see Chapter <a href="chap12.html#X7BAF69417BB925F6"><span class="RefLink">12.4</span></a>) that has methods for <code class="func">Zero</code> (<a href="chap31.html#X8040AC7A79FFC442"><span class="RefLink">31.10-3</span></a>), <code class="func">One</code> (<a href="chap31.html#X8046262384895B2A"><span class="RefLink">31.10-2</span></a>), <code class="func">\in</code> (<a href="chap30.html#X84B7FA8C7C94400F"><span class="RefLink">30.6-1</span></a>), <code class="func">Characteristic</code> (<a href="chap31.html#X81278E53800BF64D"><span class="RefLink">31.10-1</span></a>), <code class="func">IsFinite</code> (<a href="chap30.html#X808A4061809A6E67"><span class="RefLink">30.4-2</span></a>). We say that <span class="SimpleMath">v</span> is defined over <span class="SimpleMath">R</span>. Typically, <span class="SimpleMath">R</span> will be at least a semiring.</p>
251
252 <p>For creating new vector objects compatible with <span class="SimpleMath">v</span>, <code class="func">NewVector</code> (<a href="chap26.html#X860E84397BD148E9"><span class="RefLink">26.4-1</span></a>) requires that also the value of <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) is known for <span class="SimpleMath">v</span>.</p>
253
254 <p>Further, entry access <span class="SimpleMath">v[i]</span> is expected to return a <strong class="pkg">GAP</strong> object, for <span class="SimpleMath">1 ≤ i ≤</span><code class="code"> Length</code><span class="SimpleMath">( v )</span>, and that these entries of <span class="SimpleMath">v</span> belong to the base domain <span class="SimpleMath">R</span>.</p>
255
256 <p>Note that we do <em>not</em> require that <span class="SimpleMath">v</span> is a list in the sense of <code class="func">IsList</code> (<a href="chap21.html#X7C4CC4EA8299701E"><span class="RefLink">21.1-1</span></a>), in particular the rules of list arithmetic (see the sections <a href="chap21.html#X7E6A1F66781BE923"><span class="RefLink">21.13</span></a> and <a href="chap21.html#X782ED7F27D8C7FC1"><span class="RefLink">21.14</span></a>) need <em>not</em> hold. For example, the sum of two vector objects of different lengths or defined over different base domains is not defined, and a plain list of vector objects is not a matrix. Also unbinding entries of vector objects is not defined.</p>
257
258 <p>Scalar multiplication from the left is defined only with elements from <span class="SimpleMath">R</span>.</p>
259
260 <p>The family of <span class="SimpleMath">v</span> (see <code class="func">FamilyObj</code> (<a href="chap13.html#X7CF70EAC84284919"><span class="RefLink">13.1-1</span></a>)) is the same as the family of its base domain <span class="SimpleMath">R</span>. However, it is <em>not</em> required that the entries lie in <span class="SimpleMath">R</span> in the sense of <code class="func">\in</code> (<a href="chap30.html#X84B7FA8C7C94400F"><span class="RefLink">30.6-1</span></a>), also values may occur that can be naturally embedded into <span class="SimpleMath">R</span>. For example, if <span class="SimpleMath">R</span> is a polynomial ring then some entries in <span class="SimpleMath">v</span> may be elements of the coefficient ring of <span class="SimpleMath">R</span>.</p>
261
262 <p><a id="X7E7617A0781D1E4B" name="X7E7617A0781D1E4B"></a></p>
263
264 <h5>26.2-2 IsMatrixObj</h5>
265
266 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsMatrixObj</code>( <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;category&nbsp;)</td></tr></table></div>
267 <p>The idea behind <em>matrix objects</em> is that one wants to deal with objects like <span class="SimpleMath">m</span> by <span class="SimpleMath">n</span> arrays over a given domain <span class="SimpleMath">R</span>, say, which can be added and multiplied and can be multiplied from the left with elements from <span class="SimpleMath">R</span>. A matrix object <span class="SimpleMath">M</span>, say, is always a copyable object (see <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>)) in <code class="func">IsVector</code> (<a href="chap31.html#X802F34F280B29DF4"><span class="RefLink">31.14-14</span></a>) and <code class="func">IsScalar</code> (<a href="chap31.html#X8113834E84FD0435"><span class="RefLink">31.14-20</span></a>), which knows the values of <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) (with value <span class="SimpleMath">R</span>), <code class="func">NumberRows</code> (<a href="chap26.html#X820ED34380C10E19"><span class="RefLink">26.3-5</span></a>) (with value <span class="SimpleMath">m</span>), <code class="func">NumberColumns</code> (<a href="chap26.html#X820ED34380C10E19"><span class="RefLink">26.3-5</span></a>) (with value <span class="SimpleMath">n</span>), where <span class="SimpleMath">R</span> is a domain (see Chapter <a href="chap12.html#X7BAF69417BB925F6"><span class="RefLink">12.4</span></a>) that has methods for <code class="func">Zero</code> (<a href="chap31.html#X8040AC7A79FFC442"><span class="RefLink">31.10-3</span></a>), <code class="func">One</code> (<a href="chap31.html#X8046262384895B2A"><span class="RefLink">31.10-2</span></a>), <code class="func">\in</code> (<a href="chap30.html#X84B7FA8C7C94400F"><span class="RefLink">30.6-1</span></a>), <code class="func">Characteristic</code> (<a href="chap31.html#X81278E53800BF64D"><span class="RefLink">31.10-1</span></a>), <code class="func">IsFinite</code> (<a href="chap30.html#X808A4061809A6E67"><span class="RefLink">30.4-2</span></a>). We say that <span class="SimpleMath">v</span> is defined over <span class="SimpleMath">R</span>. Typically, <span class="SimpleMath">R</span> will be at least a semiring.</p>
268
269 <p>For creating new matrix objects compatible with <span class="SimpleMath">M</span>, <code class="func">NewMatrix</code> (<a href="chap26.html#X7AD2210B8047FB01"><span class="RefLink">26.4-4</span></a>) requires that also the value of <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) is known for <span class="SimpleMath">M</span>.</p>
270
271 <p>Further, entry access <span class="SimpleMath">M[i,j]</span> is expected to return a <strong class="pkg">GAP</strong> object, for <span class="SimpleMath">1 ≤ i ≤ m</span> and <span class="SimpleMath">1 ≤ j ≤ n</span>, and that these entries of <span class="SimpleMath">M</span> belong to the base domain <span class="SimpleMath">R</span>.</p>
272
273 <p>Note that we do <em>not</em> require that <span class="SimpleMath">M</span> is a list in the sense of <code class="func">IsList</code> (<a href="chap21.html#X7C4CC4EA8299701E"><span class="RefLink">21.1-1</span></a>), in particular the rules of list arithmetic (see the sections <a href="chap21.html#X7E6A1F66781BE923"><span class="RefLink">21.13</span></a> and <a href="chap21.html#X782ED7F27D8C7FC1"><span class="RefLink">21.14</span></a>) need <em>not</em> hold. For example, accessing <q>rows</q> of <span class="SimpleMath">M</span> via <code class="func"><span>\</span>[<span>\</span>]</code> (<a href="chap21.html#X8297BBCD79642BE6"><span class="RefLink">21.2-1</span></a>) is in general not possible, and the sum of two matrix objects with different numbers of rows or columns is not defined. Also unbinding entries of matrix objects is not defined.</p>
274
275 <p>Scalar multiplication from the left is defined only with elements from <span class="SimpleMath">R</span>.</p>
276
277 <p>It is not assumed that the multiplication in <span class="SimpleMath">R</span> is associative, and we do not define what the <span class="SimpleMath">k</span>-th power of a matrix object is in this case, for positive integers <span class="SimpleMath">k</span>. (However, a default powering method is available.)</p>
278
279 <p>The filter <code class="func">IsMatrixObj</code> alone does <em>not</em> imply that the multiplication is the usual matrix multiplication. This multiplication can be defined via the filter <code class="func">IsOrdinaryMatrix</code> (<a href="chap24.html#X7CF42B8A845BC6A9"><span class="RefLink">24.2-2</span></a>); this filter together with the associativity of the base domain also implies the associativity of matrix multiplication. For example, elements of matrix Lie algebras (see <code class="func">LieObject</code> (<a href="chap64.html#X87F121978775AF48"><span class="RefLink">64.1-1</span></a>)) lie in <code class="func">IsMatrixObj</code> but not in <code class="func">IsOrdinaryMatrix</code> (<a href="chap24.html#X7CF42B8A845BC6A9"><span class="RefLink">24.2-2</span></a>).</p>
280
281 <p>The family of <span class="SimpleMath">M</span> (see <code class="func">FamilyObj</code> (<a href="chap13.html#X7CF70EAC84284919"><span class="RefLink">13.1-1</span></a>)) is the collections family (see <code class="func">CollectionsFamily</code> (<a href="chap30.html#X84E5A67E87D8DD66"><span class="RefLink">30.2-1</span></a>)) of its base domain <span class="SimpleMath">R</span>. However, it is <em>not</em> required that the entries lie in <span class="SimpleMath">R</span> in the sense of <code class="func">\in</code> (<a href="chap30.html#X84B7FA8C7C94400F"><span class="RefLink">30.6-1</span></a>), also values may occur that can be naturally embedded into <span class="SimpleMath">R</span>. For example, if <span class="SimpleMath">R</span> is a polynomial ring then some entries in <span class="SimpleMath">M</span> may be elements of the coefficient ring of <span class="SimpleMath">R</span>.</p>
282
283 <p><a id="X7D1ACCBE7E9CF501" name="X7D1ACCBE7E9CF501"></a></p>
284
285 <h5>26.2-3 IsMatrixOrMatrixObj</h5>
286
287 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsMatrixOrMatrixObj</code>( <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;category&nbsp;)</td></tr></table></div>
288 <p>Several functions are defined for objects in <code class="func">IsMatrix</code> (<a href="chap24.html#X7E1AE46B862B185F"><span class="RefLink">24.2-1</span></a>) and objects in <code class="func">IsMatrixObj</code> (<a href="chap26.html#X7E7617A0781D1E4B"><span class="RefLink">26.2-2</span></a>). All these objects lie in the filter <code class="func">IsMatrixOrMatrixObj</code>. It should be used in situations where an object can be either a list of lists in <code class="func">IsMatrix</code> (<a href="chap24.html#X7E1AE46B862B185F"><span class="RefLink">24.2-1</span></a>) or a <q>proper</q> matrix object in <code class="func">IsMatrixObj</code> (<a href="chap26.html#X7E7617A0781D1E4B"><span class="RefLink">26.2-2</span></a>), for example as a requirement in the installation of a method for such an argument.</p>
289
290
291 <div class="example"><pre>
292 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">m:= IdentityMat( 2, GF(2) );;</span>
293 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsMatrix( m ); IsMatrixObj( m ); IsMatrixOrMatrixObj( m );</span>
294 true
295 false
296 true
297 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">m:= NewIdentityMatrix( IsPlistMatrixRep, GF(2), 2 );;</span>
298 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsMatrix( m ); IsMatrixObj( m ); IsMatrixOrMatrixObj( m );</span>
299 false
300 true
301 true
302 </pre></div>
303
304 <p><a id="X78CD88A283330E72" name="X78CD88A283330E72"></a></p>
305
306 <h5>26.2-4 IsRowListMatrix</h5>
307
308 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsRowListMatrix</code>( <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;category&nbsp;)</td></tr></table></div>
309 <p>A <em>row list matrix object</em> is a matrix object (see <code class="func">IsMatrixObj</code> (<a href="chap26.html#X7E7617A0781D1E4B"><span class="RefLink">26.2-2</span></a>)) <span class="SimpleMath">M</span> which admits access to its rows, that is, list access <span class="SimpleMath">M[i]</span> (see <code class="func"><span>\</span>[<span>\</span>]</code> (<a href="chap21.html#X8297BBCD79642BE6"><span class="RefLink">21.2-1</span></a>)) yields the <span class="SimpleMath">i</span>-th row of <span class="SimpleMath">M</span>, for <span class="SimpleMath">1 ≤ i ≤</span> <code class="code">NumberRows( </code><span class="SimpleMath">M</span><code class="code"> )</code>.</p>
310
311 <p>All rows are <code class="func">IsVectorObj</code> (<a href="chap26.html#X7D963FCC7E849BE0"><span class="RefLink">26.2-1</span></a>) objects in the same representation. Several rows of a row list matrix object can be identical objects, and different row list matrices may share rows. Row access just gives a reference to the row object, without copying the row.</p>
312
313 <p>Matrix objects in <code class="func">IsRowListMatrix</code> are <em>not</em> necessarily in <code class="func">IsList</code> (<a href="chap21.html#X7C4CC4EA8299701E"><span class="RefLink">21.1-1</span></a>), and then they need not obey the general rules for lists.</p>
314
315 <p><a id="X877A706186C89ADB" name="X877A706186C89ADB"></a></p>
316
317 <h4>26.3 <span class="Heading">Defining Attributes of Vector and Matrix Objects</span></h4>
318
319 <p><a id="X8662026C7CCDB446" name="X8662026C7CCDB446"></a></p>
320
321 <h5>26.3-1 <span class="Heading">BaseDomain</span></h5>
322
323 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; BaseDomain</code>( <var class="Arg">vector</var> )</td><td class="tdright">(&nbsp;attribute&nbsp;)</td></tr></table></div>
324 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; BaseDomain</code>( <var class="Arg">matrix</var> )</td><td class="tdright">(&nbsp;attribute&nbsp;)</td></tr></table></div>
325 <p>The vector object <var class="Arg">vector</var> or matrix object <var class="Arg">matrix</var>, respectively, is defined over the domain given by its <code class="func">BaseDomain</code> value.</p>
326
327 <p>Note that not all entries of the object necessarily lie in its base domain with respect to <code class="func">\in</code> (<a href="chap30.html#X84B7FA8C7C94400F"><span class="RefLink">30.6-1</span></a>), see Section <a href="chap26.html#X7A7275C27EC61ACE"><span class="RefLink">26.1</span></a>.</p>
328
329 <p><a id="X85ABF33684865ED5" name="X85ABF33684865ED5"></a></p>
330
331 <h5>26.3-2 <span class="Heading">ConstructingFilter</span></h5>
332
333 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConstructingFilter</code>( <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;attribute&nbsp;)</td></tr></table></div>
334 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConstructingFilter</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;attribute&nbsp;)</td></tr></table></div>
335 <p>Returns: a filter</p>
336
337 <p>Called with a vector object <var class="Arg">v</var> or a matrix object <var class="Arg">M</var>, respectively, <code class="func">ConstructingFilter</code> returns a filter <code class="code">f</code> such that when <code class="func">NewVector</code> (<a href="chap26.html#X860E84397BD148E9"><span class="RefLink">26.4-1</span></a>) or <code class="func">NewMatrix</code> (<a href="chap26.html#X7AD2210B8047FB01"><span class="RefLink">26.4-4</span></a>), respectively, is called with <code class="code">f</code> then a vector object or a matrix object, respectively, in the same representation as the argument is produced.</p>
338
339 <p>If the <code class="func">ConstructingFilter</code> value of <var class="Arg">v</var> or <var class="Arg">M</var> implies <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>) then mutable versions of <var class="Arg">v</var> or <var class="Arg">M</var> can be created, otherwise all vector or matrix objects with this filter are immutable.</p>
340
341 <p><a id="X818702FD7A2E9D90" name="X818702FD7A2E9D90"></a></p>
342
343 <h5>26.3-3 <span class="Heading">CompatibleVectorFilter</span></h5>
344
345 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; CompatibleVectorFilter</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;attribute&nbsp;)</td></tr></table></div>
346 <p>Returns: a filter</p>
347
348 <p>Called with a matrix object <var class="Arg">M</var>, <code class="func">CompatibleVectorFilter</code> returns either a filter <code class="code">f</code> such that vector objects with <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value <code class="code">f</code> are compatible in the sense that <var class="Arg">M</var> can be multiplied with these vector objects, of <code class="keyw">fail</code> if no such filter is known.</p>
349
350 <p><a id="X828BA5E1849E3D06" name="X828BA5E1849E3D06"></a></p>
351
352 <h5>26.3-4 Length</h5>
353
354 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Length</code>( <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;attribute&nbsp;)</td></tr></table></div>
355 <p>returns the length of the vector object <var class="Arg">v</var>, which is defined to be the number of entries of <var class="Arg">v</var>.</p>
356
357 <p><a id="X820ED34380C10E19" name="X820ED34380C10E19"></a></p>
358
359 <h5>26.3-5 <span class="Heading">NumberRows and NumberColumns</span></h5>
360
361 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; NumberRows</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;attribute&nbsp;)</td></tr></table></div>
362 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; NrRows</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;attribute&nbsp;)</td></tr></table></div>
363 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; NumberColumns</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;attribute&nbsp;)</td></tr></table></div>
364 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; NrCols</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;attribute&nbsp;)</td></tr></table></div>
365 <p>For a matrix object <var class="Arg">M</var>, <code class="func">NumberRows</code> and <code class="func">NumberColumns</code> store the number of rows and columns of <var class="Arg">M</var>, respectively.</p>
366
367 <p><code class="func">NrRows</code> and <code class="func">NrCols</code> are synonyms of <code class="func">NumberRows</code> and <code class="func">NumberColumns</code>, respectively.</p>
368
369 <p><a id="X7BD7D2837BFDE649" name="X7BD7D2837BFDE649"></a></p>
370
371 <h4>26.4 <span class="Heading">Constructing Vector and Matrix Objects</span></h4>
372
373 <p><a id="X860E84397BD148E9" name="X860E84397BD148E9"></a></p>
374
375 <h5>26.4-1 <span class="Heading">NewVector and NewZeroVector</span></h5>
376
377 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; NewVector</code>( <var class="Arg">filt</var>, <var class="Arg">R</var>, <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
378 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; NewZeroVector</code>( <var class="Arg">filt</var>, <var class="Arg">R</var>, <var class="Arg">n</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
379 <p>For a filter <var class="Arg">filt</var>, a semiring <var class="Arg">R</var>, and a list <var class="Arg">list</var> of elements that belong to <var class="Arg">R</var>, <code class="func">NewVector</code> returns a vector object which has the <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) <var class="Arg">filt</var>, the <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) <var class="Arg">R</var>, and the entries in <var class="Arg">list</var>. The list <var class="Arg">list</var> is guaranteed not to be changed by this operation.</p>
380
381 <p>If the global option <code class="code">check</code> is set to <code class="keyw">false</code> then <code class="func">NewVector</code> need not perform consistency checks.</p>
382
383 <p>Similarly, <code class="func">NewZeroVector</code> returns a vector object of length <var class="Arg">n</var> which has <var class="Arg">filt</var> and <var class="Arg">R</var> as <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) and <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) values, and contains the zero of <var class="Arg">R</var> in each position.</p>
384
385 <p>The returned object is mutable if and only if <var class="Arg">filt</var> implies <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>).</p>
386
387 <p><a id="X79A6544D86261E82" name="X79A6544D86261E82"></a></p>
388
389 <h5>26.4-2 <span class="Heading">Vector</span></h5>
390
391 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Vector</code>( <var class="Arg">filt</var>, <var class="Arg">R</var>, <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
392 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Vector</code>( <var class="Arg">filt</var>, <var class="Arg">R</var>, <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
393 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Vector</code>( <var class="Arg">R</var>, <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
394 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Vector</code>( <var class="Arg">R</var>, <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
395 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Vector</code>( <var class="Arg">list</var>, <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
396 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Vector</code>( <var class="Arg">v1</var>, <var class="Arg">v2</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
397 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Vector</code>( <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
398 <p>Returns: a vector object</p>
399
400 <p>If a filter <var class="Arg">filt</var> is given as the first argument then a vector object is returned that has <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value <var class="Arg">filt</var>, is defined over the base domain <var class="Arg">R</var>, and has the entries given by the list <var class="Arg">list</var> or the vector object <var class="Arg">v</var>, respectively.</p>
401
402 <p>If a semiring <var class="Arg">R</var> is given as the first argument then a vector object is returned whose <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value is guessed from <var class="Arg">R</var>, again with base domain <var class="Arg">R</var> and entries given by the last argument.</p>
403
404 <p>In the remaining cases with two arguments, the first argument is a list or a vector object that defines the entries of the result, and the second argument is a vector object whose <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) and <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) are taken for the result.</p>
405
406 <p>If only a list <var class="Arg">list</var> is given then both the <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) and the <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) are guessed from this list.</p>
407
408 <p>The variant <code class="code">Vector( </code><var class="Arg">v1</var><code class="code">, </code><var class="Arg">v2</var><code class="code"> )</code> is supported also for the case that <var class="Arg">v2</var> is a row vector but not a vector object. In this situation, the result is a row vector that is equal to <var class="Arg">v1</var> and whose internal representation fits to that of <var class="Arg">v2</var>.</p>
409
410 <p>If the global option <code class="code">check</code> is set to <code class="keyw">false</code> then <code class="func">Vector</code> need not perform consistency checks.</p>
411
412 <p>If the <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value of the result implies <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>) then the result is mutable if and only if the argument that determines the entries of the result (<var class="Arg">list</var>, <var class="Arg">v</var>, <var class="Arg">v1</var>) is mutable.</p>
413
414 <p>In the case of a mutable result, it is <em>not</em> guaranteed that the given list of entries is copied.</p>
415
416 <p>Default methods for <code class="func">Vector</code> delegate to <code class="func">NewVector</code> (<a href="chap26.html#X860E84397BD148E9"><span class="RefLink">26.4-1</span></a>).</p>
417
418 <p><a id="X7DBA8BF5844F3281" name="X7DBA8BF5844F3281"></a></p>
419
420 <h5>26.4-3 <span class="Heading">ZeroVector</span></h5>
421
422 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ZeroVector</code>( <var class="Arg">filt</var>, <var class="Arg">R</var>, <var class="Arg">len</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
423 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ZeroVector</code>( <var class="Arg">R</var>, <var class="Arg">len</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
424 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ZeroVector</code>( <var class="Arg">len</var>, <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
425 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ZeroVector</code>( <var class="Arg">len</var>, <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
426 <p>Returns: a vector object</p>
427
428 <p>For a filter <var class="Arg">filt</var>, a semiring <var class="Arg">R</var> and a nonnegative integer <var class="Arg">len</var>, this operation returns a new vector object of length <var class="Arg">len</var> over <var class="Arg">R</var> in the representation <var class="Arg">filt</var> containing only zeros.</p>
429
430 <p>If only <var class="Arg">R</var> and <var class="Arg">len</var> are given, then <strong class="pkg">GAP</strong> guesses a suitable representation.</p>
431
432 <p>For a vector object <var class="Arg">v</var> and a nonnegative integer <var class="Arg">len</var>, this operation returns a new vector object of length <var class="Arg">len</var> in the same representation as <var class="Arg">v</var> containing only zeros.</p>
433
434 <p>For a matrix object <var class="Arg">M</var> and a nonnegative integer <var class="Arg">len</var>, this operation returns a new zero vector object of length <var class="Arg">len</var> in the representation given by the <code class="func">CompatibleVectorFilter</code> (<a href="chap26.html#X818702FD7A2E9D90"><span class="RefLink">26.3-3</span></a>) value of <var class="Arg">M</var>, provided that such a representation exists.</p>
435
436 <p>If the <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value of the result implies <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>) then the result is mutable.</p>
437
438 <p>Default methods for <code class="func">ZeroVector</code> delegate to <code class="func">NewZeroVector</code> (<a href="chap26.html#X860E84397BD148E9"><span class="RefLink">26.4-1</span></a>).</p>
439
440 <p><a id="X7AD2210B8047FB01" name="X7AD2210B8047FB01"></a></p>
441
442 <h5>26.4-4 <span class="Heading">NewMatrix, NewZeroMatrix, NewIdentityMatrix</span></h5>
443
444 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; NewMatrix</code>( <var class="Arg">filt</var>, <var class="Arg">R</var>, <var class="Arg">ncols</var>, <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
445 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; NewZeroMatrix</code>( <var class="Arg">filt</var>, <var class="Arg">R</var>, <var class="Arg">m</var>, <var class="Arg">n</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
446 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; NewIdentityMatrix</code>( <var class="Arg">filt</var>, <var class="Arg">R</var>, <var class="Arg">n</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
447 <p>For a filter <var class="Arg">filt</var>, a semiring <var class="Arg">R</var>, a positive integer <var class="Arg">ncols</var>, and a list <var class="Arg">list</var>, <code class="func">NewMatrix</code> returns a matrix object which has the <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) <var class="Arg">filt</var>, the <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) <var class="Arg">R</var>, <var class="Arg">n</var> columns (see <code class="func">NumberColumns</code> (<a href="chap26.html#X820ED34380C10E19"><span class="RefLink">26.3-5</span></a>)), and the entries described by <var class="Arg">list</var>, which can be either a plain list of vector objects of length <var class="Arg">ncols</var> or a plain list of plain lists of length <var class="Arg">ncols</var> or a plain list of length a multiple of <var class="Arg">ncols</var> containing the entries in row major order. The list <var class="Arg">list</var> is guaranteed not to be changed by this operation.</p>
448
449 <p>The corresponding entries must be in or compatible with <var class="Arg">R</var>. If <var class="Arg">list</var> already contains vector objects, they are copied.</p>
450
451 <p>If the global option <code class="code">check</code> is set to <code class="keyw">false</code> then <code class="func">NewMatrix</code> need not perform consistency checks.</p>
452
453 <p>Similarly, <code class="func">NewZeroMatrix</code> returns a zero matrix object with <var class="Arg">m</var> rows and <var class="Arg">n</var> columns which has <var class="Arg">filt</var> and <var class="Arg">R</var> as <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) and <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) values.</p>
454
455 <p>Similarly, <code class="func">NewIdentityMatrix</code> returns an identity matrix object with <var class="Arg">n</var> rows and columns which has <var class="Arg">filt</var> and <var class="Arg">R</var> as <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) and <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) values, and contains the identity element of <var class="Arg">R</var> in the diagonal and the zero of <var class="Arg">R</var> in each off-diagonal position.</p>
456
457 <p>The returned object is mutable if and only if <var class="Arg">filt</var> implies <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>).</p>
458
459 <p><a id="X879384D479EB1D82" name="X879384D479EB1D82"></a></p>
460
461 <h5>26.4-5 <span class="Heading">Matrix</span></h5>
462
463 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Matrix</code>( [<var class="Arg">filt</var>, ]<var class="Arg">R</var>, <var class="Arg">list</var>[, <var class="Arg">ncols</var>] )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
464 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Matrix</code>( [<var class="Arg">filt</var>, ]<var class="Arg">R</var>, <var class="Arg">matobj</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
465 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Matrix</code>( <var class="Arg">list</var>[, <var class="Arg">ncols</var>], <var class="Arg">example_matobj</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
466 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Matrix</code>( <var class="Arg">matobj</var>, <var class="Arg">example_matobj</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
467 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Matrix</code>( <var class="Arg">list</var>[, <var class="Arg">ncols</var>] )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
468 <p>Returns: a matrix object</p>
469
470 <p>If a filter <var class="Arg">filt</var> is given as the first argument then a matrix object is returned that has <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value <var class="Arg">filt</var>, is defined over the base domain <var class="Arg">R</var>, and has the entries given by the list <var class="Arg">list</var> or the matrix object <var class="Arg">matobj</var>, respectively. Here <var class="Arg">list</var> can be either a list of plain lists that describe the entries of the rows, or a flat list of the entries in row major order, where <var class="Arg">ncols</var> defines the number of columns.</p>
471
472 <p>If a semiring <var class="Arg">R</var> is given as the first argument then a matrix object is returned whose <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value is guessed from <var class="Arg">R</var>, again with base domain <var class="Arg">R</var> and entries given by the last argument.</p>
473
474 <p>In those remaining cases where the last argument is a matrix object, the first argument is a list or a matrix object that defines (together with <var class="Arg">ncols</var> if applicable) the entries of the result, and the <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) and <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) of the last argument are taken for the result.</p>
475
476 <p>Finally, if only a list <var class="Arg">list</var> and perhaps <var class="Arg">ncols</var> is given then both the <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) and the <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) are guessed from the list.</p>
477
478 <p>If the global option <code class="code">check</code> is set to <code class="keyw">false</code> then <code class="func">Matrix</code> need not perform consistency checks.</p>
479
480 <p>If the <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value of the result implies <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>) then the result is mutable if and only if the argument that determines the entries of the result (<var class="Arg">list</var> or <var class="Arg">matobj</var>) is mutable.</p>
481
482 <p>In the case of a mutable result, it is guaranteed that the given list <var class="Arg">list</var> is copied in the sense of <code class="func">ShallowCopy</code> (<a href="chap12.html#X846BC7107C352031"><span class="RefLink">12.7-1</span></a>), and if <var class="Arg">list</var> is a nested list then it is <em>not</em> guaranteed that also the entries of <var class="Arg">list</var> are copied.</p>
483
484 <p>Default methods for <code class="func">Matrix</code> delegate to <code class="func">NewMatrix</code> (<a href="chap26.html#X7AD2210B8047FB01"><span class="RefLink">26.4-4</span></a>).</p>
485
486 <p><a id="X838F5B6C7C87C8E1" name="X838F5B6C7C87C8E1"></a></p>
487
488 <h5>26.4-6 <span class="Heading">ZeroMatrix</span></h5>
489
490 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ZeroMatrix</code>( <var class="Arg">m</var>, <var class="Arg">n</var>, <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
491 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ZeroMatrix</code>( <var class="Arg">R</var>, <var class="Arg">m</var>, <var class="Arg">n</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
492 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ZeroMatrix</code>( <var class="Arg">filt</var>, <var class="Arg">R</var>, <var class="Arg">m</var>, <var class="Arg">n</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
493 <p>Returns: a matrix object</p>
494
495 <p>For a matrix object <var class="Arg">M</var> and two nonnegative integers <var class="Arg">m</var> and <var class="Arg">n</var>, this operation returns a new matrix object with <var class="Arg">m</var> rows and <var class="Arg">n</var> columns in the same representation and over the same base domain as <var class="Arg">M</var> containing only zeros.</p>
496
497 <p>If a semiring <var class="Arg">R</var> and two nonnegative integers <var class="Arg">m</var> and <var class="Arg">n</var> are given, the representation of the result is guessed from <var class="Arg">R</var>.</p>
498
499 <p>If a filter <var class="Arg">filt</var> and a semiring <var class="Arg">R</var> are given as the first and second argument, they are taken as the values of <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) and <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) of the result.</p>
500
501 <p>If the <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value of the result implies <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>) then the result is fully mutable.</p>
502
503 <p>Default methods for <code class="func">ZeroMatrix</code> delegate to <code class="func">NewZeroMatrix</code> (<a href="chap26.html#X7AD2210B8047FB01"><span class="RefLink">26.4-4</span></a>).</p>
504
505 <p><a id="X7D807ABC7FCB4E77" name="X7D807ABC7FCB4E77"></a></p>
506
507 <h5>26.4-7 <span class="Heading">IdentityMatrix</span></h5>
508
509 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IdentityMatrix</code>( <var class="Arg">n</var>, <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
510 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IdentityMatrix</code>( <var class="Arg">R</var>, <var class="Arg">n</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
511 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IdentityMatrix</code>( <var class="Arg">filt</var>, <var class="Arg">R</var>, <var class="Arg">n</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
512 <p>Returns: a matrix object</p>
513
514 <p>For a matrix object <var class="Arg">M</var> and a nonnegative integer <var class="Arg">n</var>, this operation returns a new identity matrix object with <var class="Arg">n</var> rows and columns in the same representation and over the same base domain as <var class="Arg">M</var>.</p>
515
516 <p>If a semiring <var class="Arg">R</var> and a nonnegative integer <var class="Arg">n</var> is given, the representation of the result is guessed from <var class="Arg">R</var>.</p>
517
518 <p>If a filter <var class="Arg">filt</var> and a semiring <var class="Arg">R</var> are given as the first and second argument, they are taken as the values of <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) and <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) of the result.</p>
519
520 <p>If the <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value of the result implies <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>) then the result is fully mutable.</p>
521
522 <p>Default methods for <code class="func">IdentityMatrix</code> delegate to <code class="func">NewIdentityMatrix</code> (<a href="chap26.html#X7AD2210B8047FB01"><span class="RefLink">26.4-4</span></a>).</p>
523
524 <p><a id="X7C7F5250855C4371" name="X7C7F5250855C4371"></a></p>
525
526 <h4>26.5 <span class="Heading">Operations for Base Domains of Vector and Matrix Objects</span></h4>
527
528 <p><a id="X85D7A6A782B21E5C" name="X85D7A6A782B21E5C"></a></p>
529
530 <h5>26.5-1 <span class="Heading">OneOfBaseDomain and ZeroOfBaseDomain</span></h5>
531
532 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; OneOfBaseDomain</code>( <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;attribute&nbsp;)</td></tr></table></div>
533 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; OneOfBaseDomain</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;attribute&nbsp;)</td></tr></table></div>
534 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ZeroOfBaseDomain</code>( <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;attribute&nbsp;)</td></tr></table></div>
535 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ZeroOfBaseDomain</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;attribute&nbsp;)</td></tr></table></div>
536 <p>These attributes return the identity element and the zero element of the <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) value of the vector object <var class="Arg">v</var> or the matrix object <var class="Arg">M</var>, respectively.</p>
537
538 <p>If <var class="Arg">v</var> or <var class="Arg">M</var>, respectively, is a plain list (see <code class="func">IsPlistRep</code> (<a href="chap21.html#X87BA4EBF80F16B72"><span class="RefLink">21.24-2</span></a>)) then computing its <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) value can be regarded as expensive, whereas calling <code class="func">OneOfBaseDomain</code> or <code class="func">ZeroOfBaseDomain</code> can be regarded as cheap. If <var class="Arg">v</var> or <var class="Arg">M</var>, respectively, is not a plain list then one can also call <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) first, without loss of performance.</p>
539
540 <p><a id="X7954E20987E0B260" name="X7954E20987E0B260"></a></p>
541
542 <h4>26.6 <span class="Heading">Operations for Vector and Matrix Objects</span></h4>
543
544 <p><a id="X7FFC60A27FE6FA97" name="X7FFC60A27FE6FA97"></a></p>
545
546 <h5>26.6-1 <span class="Heading">Comparison of Vector and Matrix Objects</span></h5>
547
548 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \=</code>( <var class="Arg">v1</var>, <var class="Arg">v2</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
549 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \=</code>( <var class="Arg">M1</var>, <var class="Arg">M2</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
550 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \&lt;</code>( <var class="Arg">v1</var>, <var class="Arg">v2</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
551 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \&lt;</code>( <var class="Arg">M1</var>, <var class="Arg">M2</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
552 <p>Two vector objects in <code class="func">IsList</code> (<a href="chap21.html#X7C4CC4EA8299701E"><span class="RefLink">21.1-1</span></a>) are equal if they are equal as lists. Two matrix objects in <code class="func">IsList</code> (<a href="chap21.html#X7C4CC4EA8299701E"><span class="RefLink">21.1-1</span></a>) are equal if they are equal as lists.</p>
553
554 <p>Two vector objects of which at least one is not in <code class="func">IsList</code> (<a href="chap21.html#X7C4CC4EA8299701E"><span class="RefLink">21.1-1</span></a>) are equal with respect to <code class="func">\=</code> (<a href="chap31.html#X7EF67D047F03CA6F"><span class="RefLink">31.11-1</span></a>) if they have the same <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value, the same <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) value, the same length, and the same entries.</p>
555
556 <p>Two matrix objects of which at least one is not in <code class="func">IsList</code> (<a href="chap21.html#X7C4CC4EA8299701E"><span class="RefLink">21.1-1</span></a>) are equal with respect to <code class="func">\=</code> (<a href="chap31.html#X7EF67D047F03CA6F"><span class="RefLink">31.11-1</span></a>) if they have the same <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value, the same <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) value, the same dimensions, and the same entries.</p>
557
558 <p>We do <em>not</em> state a general rule how vector and matrix objects shall behave w.r.t. the comparison by <code class="func">\&lt;</code> (<a href="chap31.html#X7EF67D047F03CA6F"><span class="RefLink">31.11-1</span></a>). Note that a <q>row lexicographic order</q> would be quite unnatural for matrices that are internally represented via a list of columns.</p>
559
560 <p>Note that the operations <code class="func">\=</code> (<a href="chap31.html#X7EF67D047F03CA6F"><span class="RefLink">31.11-1</span></a>) and <code class="func">\&lt;</code> (<a href="chap31.html#X7EF67D047F03CA6F"><span class="RefLink">31.11-1</span></a>) are used to form sorted lists and sets of objects, see for example <code class="func">Sort</code> (<a href="chap21.html#X7FE4975F8166884D"><span class="RefLink">21.18-1</span></a>) and <code class="func">Set</code> (<a href="chap30.html#X7E399AC97FD98217"><span class="RefLink">30.3-7</span></a>).</p>
561
562 <p><a id="X7FBBE79478012648" name="X7FBBE79478012648"></a></p>
563
564 <h5>26.6-2 <span class="Heading">Unpack</span></h5>
565
566 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Unpack</code>( <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
567 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Unpack</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
568 <p>Returns: A plain list</p>
569
570 <p>Returns a new mutable plain list (see <code class="func">IsPlistRep</code> (<a href="chap21.html#X87BA4EBF80F16B72"><span class="RefLink">21.24-2</span></a>)) containing the entries of the vector object <var class="Arg">v</var> or the matrix object <var class="Arg">M</var>, respectively. In the case of a matrix object, the result is a plain list of plain lists.</p>
571
572 <p>Changing the result does not change <var class="Arg">v</var> or <var class="Arg">M</var>, respectively. The entries themselves are not copied.</p>
573
574 <p><a id="X85E896F67CE2F925" name="X85E896F67CE2F925"></a></p>
575
576 <h5>26.6-3 <span class="Heading">ChangedBaseDomain</span></h5>
577
578 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ChangedBaseDomain</code>( <var class="Arg">v</var>, <var class="Arg">R</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
579 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ChangedBaseDomain</code>( <var class="Arg">M</var>, <var class="Arg">R</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
580 <p>For a vector object <var class="Arg">v</var> (a matrix object <var class="Arg">M</var>) and a semiring <var class="Arg">R</var>, <code class="func">ChangedBaseDomain</code> returns a new vector object (matrix object) with <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) value <var class="Arg">R</var>, <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value equal to that of <var class="Arg">v</var> (<var class="Arg">M</var>), and the same entries as <var class="Arg">v</var> (<var class="Arg">M</var>).</p>
581
582 <p>The result is mutable if and only if <var class="Arg">v</var> (<var class="Arg">M</var>) is mutable.</p>
583
584 <p>For example, one can create a vector defined over <code class="code">GF(4)</code> from a vector defined over <code class="code">GF(2)</code> with this operation.</p>
585
586 <p><a id="X83DD8B39864A2C94" name="X83DD8B39864A2C94"></a></p>
587
588 <h5>26.6-4 <span class="Heading">Randomize</span></h5>
589
590 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Randomize</code>( [<var class="Arg">Rs</var>, ]<var class="Arg">v</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
591 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Randomize</code>( [<var class="Arg">Rs</var>, ]<var class="Arg">M</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
592 <p>Replaces every entry in the mutable vector object <var class="Arg">v</var> or matrix object <var class="Arg">M</var>, respectively, with a random one from the base domain of <var class="Arg">v</var> or <var class="Arg">M</var>, respectively, and returns the argument.</p>
593
594 <p>If given, the random source <var class="Arg">Rs</var> is used to compute the random elements. Note that in this case, a <code class="func">Random</code> (<a href="chap14.html#X821004F286282D49"><span class="RefLink">14.7-2</span></a>) method must be available that takes a random source as its first argument and the base domain as its second argument.</p>
595
596 <p><a id="X7FE662477F36A21F" name="X7FE662477F36A21F"></a></p>
597
598 <h4>26.7 <span class="Heading">List Like Operations for Vector Objects</span></h4>
599
600 <p>The following operations that are defined for lists are useful also for vector objects. (More such operations can be added if this is appropriate.)</p>
601
602 <p><a id="X7D5DF49C7ADB6986" name="X7D5DF49C7ADB6986"></a></p>
603
604 <h5>26.7-1 <span class="Heading">Element Access and Assignment for Vector Objects</span></h5>
605
606 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; <span>\</span>[<span>\</span>]</code>( <var class="Arg">v</var>, <var class="Arg">i</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
607 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; <span>\</span>[<span>\</span>]\:\=</code>( <var class="Arg">v</var>, <var class="Arg">i</var>, <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
608 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \{\}</code>( <var class="Arg">v</var>, <var class="Arg">list</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
609 <p>For a vector object <var class="Arg">v</var> and a positive integer <var class="Arg">i</var> that is not larger than the length of <var class="Arg">v</var> (see <code class="func">Length</code> (<a href="chap26.html#X828BA5E1849E3D06"><span class="RefLink">26.3-4</span></a>)), <var class="Arg">v</var><code class="code">[</code><var class="Arg">i</var><code class="code">]</code> is the entry at position <var class="Arg">i</var>.</p>
610
611 <p>If <var class="Arg">v</var> is mutable, <var class="Arg">i</var> is as above, and <var class="Arg">obj</var> is an object from the base domain of <var class="Arg">v</var> then <var class="Arg">v</var><code class="code">[</code><var class="Arg">i</var><code class="code">]:= </code><var class="Arg">obj</var> assigns <var class="Arg">obj</var> to the <var class="Arg">i</var>-th position of <var class="Arg">v</var>.</p>
612
613 <p>If <var class="Arg">list</var> is a list of positive integers that are not larger than the length of <var class="Arg">v</var> then <var class="Arg">v</var><code class="code">{</code><var class="Arg">list</var><code class="code">}</code> returns a new mutable vector object in the same representation as <var class="Arg">v</var> (see <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>)) that contains the <var class="Arg">list</var><span class="SimpleMath">[ k ]</span>-th entry of <var class="Arg">v</var> at position <span class="SimpleMath">k</span>.</p>
614
615 <p>If the global option <code class="code">check</code> is set to <code class="keyw">false</code> then <code class="func"><span>\</span>[<span>\</span>]\:\=</code> need not perform consistency checks.</p>
616
617 <p>Note that the sublist assignment operation <code class="func">\{\}\:\=</code> (<a href="chap21.html#X813FF1637F8D2B7F"><span class="RefLink">21.4-1</span></a>) is left out here since it tempts the programmer to use constructions like <code class="code">v{ [ 1 .. 3 ] }:= w{ [ 4 .. 6 ] }</code> which produces an unnecessary intermediate object; one should use <code class="func">CopySubVector</code> (<a href="chap26.html#X80EC354D78D7B5A6"><span class="RefLink">26.9-3</span></a>) instead.</p>
618
619 <p><a id="X7A21731C83EE3BB0" name="X7A21731C83EE3BB0"></a></p>
620
621 <h5>26.7-2 PositionNonZero</h5>
622
623 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; PositionNonZero</code>( <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
624 <p>Returns: An integer</p>
625
626 <p>Returns the index of the first entry in the vector object <var class="Arg">v</var> that is not zero. If all entries are zero, the function returns <code class="code">Length(<var class="Arg">v</var>) + 1</code>.</p>
627
628 <p><a id="X7ABDE1B685A78326" name="X7ABDE1B685A78326"></a></p>
629
630 <h5>26.7-3 PositionLastNonZero</h5>
631
632 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; PositionLastNonZero</code>( <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
633 <p>Returns: An integer</p>
634
635 <p>Returns the index of the last entry in the vector object <var class="Arg">v</var> that is not zero. If all entries are zero, the function returns <span class="SimpleMath">0</span>.</p>
636
637 <p><a id="X790013817E314B2D" name="X790013817E314B2D"></a></p>
638
639 <h5>26.7-4 ListOp</h5>
640
641 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ListOp</code>( <var class="Arg">v</var>[, <var class="Arg">func</var>] )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
642 <p>Returns: A plain list</p>
643
644 <p>Applies the function <var class="Arg">func</var> to each entry of the vector object <var class="Arg">v</var> and returns the results as a mutable plain list. This allows for calling <code class="func">List</code> (<a href="chap30.html#X7F12F40E87F3C3A7"><span class="RefLink">30.3-5</span></a>) on vector objects.</p>
645
646 <p>If the argument <var class="Arg">func</var> is not given, applies <code class="func">IdFunc</code> (<a href="chap5.html#X810325697BDEF899"><span class="RefLink">5.4-6</span></a>) to all entries.</p>
647
648 <p><a id="X7FDF7655852AEAAE" name="X7FDF7655852AEAAE"></a></p>
649
650 <h4>26.8 <span class="Heading">Arithmetical Operations for Vector Objects</span></h4>
651
652 <p><a id="X7F8CE23F7A250072" name="X7F8CE23F7A250072"></a></p>
653
654 <h5>26.8-1 <span class="Heading">Unary Arithmetical Operations for Vector Objects</span></h5>
655
656 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AdditiveInverseMutable</code>( <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
657 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AdditiveInverseSameMutability</code>( <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
658 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ZeroMutable</code>( <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
659 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ZeroSameMutability</code>( <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
660 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsZero</code>( <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;property&nbsp;)</td></tr></table></div>
661 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Characteristic</code>( <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;attribute&nbsp;)</td></tr></table></div>
662 <p>Returns: a vector object</p>
663
664 <p>For a vector object <var class="Arg">v</var>, the operations for computing the additive inverse with prescribed mutability return a vector object with the same <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) and <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) values, such that the sum with <var class="Arg">v</var> is a zero vector. It is not specified what happens if the base domain does not admit the additive inverses of the entries.</p>
665
666 <p>Analogously, the operations for computing a zero vector with prescribed mutability return a vector object compatible with <var class="Arg">v</var>.</p>
667
668 <p><code class="func">IsZero</code> returns <code class="keyw">true</code> if all entries in <var class="Arg">v</var> are zero, and <code class="keyw">false</code> otherwise.</p>
669
670 <p><code class="func">Characteristic</code> returns the corresponding value of the <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) value of <var class="Arg">v</var>.</p>
671
672 <p><a id="X85A815CA790094CC" name="X85A815CA790094CC"></a></p>
673
674 <h5>26.8-2 <span class="Heading">Binary Arithmetical Operations for Vector Objects</span></h5>
675
676 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \+</code>( <var class="Arg">v1</var>, <var class="Arg">v2</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
677 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \-</code>( <var class="Arg">v1</var>, <var class="Arg">v2</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
678 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \*</code>( <var class="Arg">s</var>, <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
679 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \*</code>( <var class="Arg">v</var>, <var class="Arg">s</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
680 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \*</code>( <var class="Arg">v1</var>, <var class="Arg">v2</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
681 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ScalarProduct</code>( <var class="Arg">v1</var>, <var class="Arg">v2</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
682 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \/</code>( <var class="Arg">v</var>, <var class="Arg">s</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
683 <p>The sum and the difference, respectively, of two vector objects <var class="Arg">v1</var> and <var class="Arg">v2</var> is a new mutable vector object whose entries are the sums and the differences of the entries of the arguments.</p>
684
685 <p>The product of a scalar <var class="Arg">s</var> and a vector object <var class="Arg">v</var> (from the left or from the right) is a new mutable vector object whose entries are the corresponding products.</p>
686
687 <p>The quotient of a vector object <var class="Arg">v</var> and a scalar <var class="Arg">s</var> is a new mutable vector object whose entries are the corresponding quotients.</p>
688
689 <p>The product of two vector objects <var class="Arg">v1</var> and <var class="Arg">v2</var> as well as the result of <code class="func">ScalarProduct</code> is the standard scalar product of the two arguments (an element of the base domain of the vector objects).</p>
690
691 <p>All this is defined only if the vector objects have the same length and are defined over the same base domain and have the same representation, and if the products with the given scalar belong to the base domain; otherwise it is not specified what happens. If the result is a vector object then it has the same representation and the same base domain as the given vector object(s).</p>
692
693 <p><a id="X876090A684E71C93" name="X876090A684E71C93"></a></p>
694
695 <h5>26.8-3 AddVector</h5>
696
697 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AddVector</code>( <var class="Arg">dst</var>, <var class="Arg">src</var>[, <var class="Arg">mul</var>[, <var class="Arg">from</var>, <var class="Arg">to</var>]] )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
698 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AddVector</code>( <var class="Arg">dst</var>, <var class="Arg">mul</var>, <var class="Arg">src</var>[, <var class="Arg">from</var>, <var class="Arg">to</var>] )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
699 <p>Returns: nothing</p>
700
701 <p>Called with two vector objects <var class="Arg">dst</var> and <var class="Arg">src</var>, this function replaces the entries of <var class="Arg">dst</var> in-place by the entries of the sum <var class="Arg">dst</var><code class="code"> + </code><var class="Arg">src</var>.</p>
702
703 <p>If a scalar <var class="Arg">mul</var> is given as the third or second argument, respectively, then the entries of <var class="Arg">dst</var> get replaced by those of <var class="Arg">dst</var><code class="code"> + </code><var class="Arg">src</var><code class="code"> * </code><var class="Arg">mul</var> or <var class="Arg">dst</var><code class="code"> + </code><var class="Arg">mul</var><code class="code"> * </code><var class="Arg">src</var>, respectively.</p>
704
705 <p>If the optional parameters <var class="Arg">from</var> and <var class="Arg">to</var> are given then only the index range <code class="code">[<var class="Arg">from</var>..<var class="Arg">to</var>]</code> is guaranteed to be affected. Other indices <em>may</em> be affected, if it is more convenient to do so. This can be helpful if entries of <var class="Arg">src</var> are known to be zero.</p>
706
707 <p>If <var class="Arg">from</var> is bigger than <var class="Arg">to</var>, the operation does nothing.</p>
708
709 <p><a id="X8039D013817317C3" name="X8039D013817317C3"></a></p>
710
711 <h5>26.8-4 MultVector</h5>
712
713 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; MultVector</code>( <var class="Arg">v</var>, <var class="Arg">mul</var>[, <var class="Arg">from</var>, <var class="Arg">to</var>] )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
714 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; MultVectorLeft</code>( <var class="Arg">v</var>, <var class="Arg">mul</var>[, <var class="Arg">from</var>, <var class="Arg">to</var>] )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
715 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; MultVectorRight</code>( <var class="Arg">v</var>, <var class="Arg">mul</var>[, <var class="Arg">from</var>, <var class="Arg">to</var>] )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
716 <p>Returns: nothing</p>
717
718 <p>These operations multiply <var class="Arg">v</var> by <var class="Arg">mul</var> in-place where <code class="func">MultVectorLeft</code> multiplies with <var class="Arg">mul</var> from the left and <code class="func">MultVectorRight</code> does so from the right.</p>
719
720 <p>Note that <code class="func">MultVector</code> is just a synonym for <code class="func">MultVectorLeft</code>. This was chosen because vectors in <strong class="pkg">GAP</strong> are by default row vectors and scalar multiplication is usually written as <span class="SimpleMath">a â‹… v = a â‹… [v_1, ..., v_n] = [a â‹… v_1, ..., a â‹… v_n]</span> with scalars being applied from the left.</p>
721
722 <p>If the optional parameters <var class="Arg">from</var> and <var class="Arg">to</var> are given then only the index range <code class="code">[<var class="Arg">from</var>..<var class="Arg">to</var>]</code> is guaranteed to be affected. Other indices <em>may</em> be affected, if it is more convenient to do so. This can be helpful if entries of <var class="Arg">v</var> are known to be zero. If <var class="Arg">from</var> is bigger than <var class="Arg">to</var>, the operation does nothing.</p>
723
724 <p><a id="X7BE9D278852C13BC" name="X7BE9D278852C13BC"></a></p>
725
726 <h4>26.9 <span class="Heading">Operations for Vector Objects</span></h4>
727
728 <p><a id="X7AC470557EC90714" name="X7AC470557EC90714"></a></p>
729
730 <h5>26.9-1 <span class="Heading">ConcatenationOfVectors</span></h5>
731
732 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConcatenationOfVectors</code>( <var class="Arg">v1</var>, <var class="Arg">v2</var>, <var class="Arg">...</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
733 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConcatenationOfVectors</code>( <var class="Arg">vlist</var> )</td><td class="tdright">(&nbsp;function&nbsp;)</td></tr></table></div>
734 <p>Returns: a vector object</p>
735
736 <p>Returns a new mutable vector object in the representation of <var class="Arg">v1</var> or the first entry of the nonempty list <var class="Arg">vlist</var> of vector objects, respectively, such that the entries are the concatenation of the given vector objects.</p>
737
738 <p>(Note that <code class="func">Concatenation</code> (<a href="chap21.html#X840C55A77D1BB2E1"><span class="RefLink">21.20-1</span></a>) is a function for which no methods can be installed.)</p>
739
740 <p><a id="X7DBE956E7F9C700E" name="X7DBE956E7F9C700E"></a></p>
741
742 <h5>26.9-2 ExtractSubVector</h5>
743
744 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ExtractSubVector</code>( <var class="Arg">v</var>, <var class="Arg">l</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
745 <p>Returns: a vector object</p>
746
747 <p>Returns a new mutable vector object of the same vector representation as <var class="Arg">v</var>, containing the entries of <var class="Arg">v</var> at the positions in the list <var class="Arg">l</var>.</p>
748
749 <p>This is the same as <var class="Arg">v</var><code class="code">{</code><var class="Arg">l</var><code class="code">}</code>, the name <code class="func">ExtractSubVector</code> was introduced in analogy to <code class="func">ExtractSubMatrix</code> (<a href="chap26.html#X838B45F7790E9FDF"><span class="RefLink">26.11-3</span></a>), for which no equivalent syntax using curly brackets is available.</p>
750
751 <p><a id="X80EC354D78D7B5A6" name="X80EC354D78D7B5A6"></a></p>
752
753 <h5>26.9-3 CopySubVector</h5>
754
755 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; CopySubVector</code>( <var class="Arg">src</var>, <var class="Arg">dst</var>, <var class="Arg">scols</var>, <var class="Arg">dcols</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
756 <p>Returns: nothing</p>
757
758 <p>For two row vectors or vector objects <var class="Arg">src</var> and <var class="Arg">dst</var>, such that <var class="Arg">dst</var> is mutable, and two lists <var class="Arg">scols</var> and <var class="Arg">dcols</var> of positions, <code class="func">CopySubVector</code> assigns the entries <var class="Arg">src</var><code class="code">{ </code><var class="Arg">scols</var><code class="code"> }</code> (see <code class="func">ExtractSubVector</code> (<a href="chap26.html#X7DBE956E7F9C700E"><span class="RefLink">26.9-2</span></a>)) to the positions <var class="Arg">dcols</var> in <var class="Arg">dst</var>, but without creating an intermediate object and thus –at least in special cases– much more efficiently.</p>
759
760 <p>For certain objects like compressed vectors this might be significantly more efficient if <var class="Arg">scols</var> and <var class="Arg">dcols</var> are ranges with increment 1.</p>
761
762 <p>If the global option <code class="code">check</code> is set to <code class="keyw">false</code> then <code class="func">CopySubVector</code> need not perform consistency checks.</p>
763
764 <p><a id="X866366E587991171" name="X866366E587991171"></a></p>
765
766 <h5>26.9-4 WeightOfVector</h5>
767
768 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; WeightOfVector</code>( <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
769 <p>Returns: an integer</p>
770
771 <p>returns the Hamming weight of the vector object <var class="Arg">v</var>, i.e., the number of nonzero entries in <var class="Arg">v</var>.</p>
772
773 <p><a id="X81ACAE017C00F782" name="X81ACAE017C00F782"></a></p>
774
775 <h5>26.9-5 DistanceOfVectors</h5>
776
777 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; DistanceOfVectors</code>( <var class="Arg">v1</var>, <var class="Arg">v2</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
778 <p>Returns: an integer</p>
779
780 <p>returns the Hamming distance of the vector objects <var class="Arg">v1</var> and <var class="Arg">v2</var>, i.e., the number of entries in which the vectors differ. The vectors must have equal length.</p>
781
782 <p><a id="X81CC13CA7A1FF4AA" name="X81CC13CA7A1FF4AA"></a></p>
783
784 <h4>26.10 <span class="Heading">Arithmetical Operations for Matrix Objects</span></h4>
785
786 <p><a id="X819F87A07DA7E2DC" name="X819F87A07DA7E2DC"></a></p>
787
788 <h5>26.10-1 <span class="Heading">Unary Arithmetical Operations for Matrix Objects</span></h5>
789
790 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AdditiveInverseMutable</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
791 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AdditiveInverseSameMutability</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
792 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ZeroMutable</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
793 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ZeroSameMutability</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
794 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; OneMutable</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
795 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; OneSameMutability</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
796 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; InverseMutable</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
797 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; InverseSameMutability</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
798 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsZero</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;property&nbsp;)</td></tr></table></div>
799 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsOne</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;property&nbsp;)</td></tr></table></div>
800 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Characteristic</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;attribute&nbsp;)</td></tr></table></div>
801 <p>Returns: a matrix object</p>
802
803 <p>For a vector object <var class="Arg">M</var>, the operations for computing the additive inverse with prescribed mutability return a matrix object with the same <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) and <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) values, such that the sum with <var class="Arg">M</var> is a zero matrix. It is not specified what happens if the base domain does not admit the additive inverses of the entries.</p>
804
805 <p>Analogously, the operations for computing a zero matrix with prescribed mutability return a matrix object compatible with <var class="Arg">M</var>.</p>
806
807 <p>The operations for computing an identity matrix with prescribed mutability return a matrix object compatible with <var class="Arg">M</var>, provided that the base domain admits this and <var class="Arg">M</var> is square and nonempty.</p>
808
809 <p>Analogously, the operations for computing an inverse matrix with prescribed mutability return a matrix object compatible with <var class="Arg">M</var>, provided that <var class="Arg">M</var> is invertible. (If <var class="Arg">M</var> is not invertible then the operations return <code class="keyw">fail</code>.)</p>
810
811 <p><code class="func">IsZero</code> returns <code class="keyw">true</code> if all entries in <var class="Arg">M</var> are zero, and <code class="keyw">false</code> otherwise. <code class="func">IsOne</code> returns <code class="keyw">true</code> if <var class="Arg">M</var> is nonempty and square and contains the identity of the base domain in the diagonal, and zero in all other places.</p>
812
813 <p><code class="func">Characteristic</code> returns the corresponding value of the <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) value of <var class="Arg">M</var>.</p>
814
815 <p><a id="X7BBB70557A7A9591" name="X7BBB70557A7A9591"></a></p>
816
817 <h5>26.10-2 <span class="Heading">Binary Arithmetical Operations for Matrix Objects</span></h5>
818
819 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \+</code>( <var class="Arg">M1</var>, <var class="Arg">M2</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
820 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \-</code>( <var class="Arg">M1</var>, <var class="Arg">M2</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
821 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \*</code>( <var class="Arg">s</var>, <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
822 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \*</code>( <var class="Arg">M</var>, <var class="Arg">s</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
823 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \*</code>( <var class="Arg">M1</var>, <var class="Arg">M2</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
824 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \/</code>( <var class="Arg">M</var>, <var class="Arg">s</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
825 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \^</code>( <var class="Arg">M</var>, <var class="Arg">n</var> )</td><td class="tdright">(&nbsp;method&nbsp;)</td></tr></table></div>
826 <p>The sum and the difference, respectively, of two matrix objects <var class="Arg">M1</var> and <var class="Arg">M2</var> is a new fully mutable matrix object whose entries are the sums and the differences of the entries of the arguments.</p>
827
828 <p>The product of a scalar <var class="Arg">s</var> and a matrix object <var class="Arg">M</var> (from the left or from the right) is a new fully mutable matrix object whose entries are the corresponding products.</p>
829
830 <p>The product of two matrix objects <var class="Arg">M1</var> and <var class="Arg">M2</var> is a new fully mutable matrix object; if both <var class="Arg">M1</var> and <var class="Arg">M2</var> are in the filter <code class="func">IsOrdinaryMatrix</code> (<a href="chap24.html#X7CF42B8A845BC6A9"><span class="RefLink">24.2-2</span></a>) then the entries of the result are those of the ordinary matrix product.</p>
831
832 <p>The quotient of a matrix object <var class="Arg">M</var> and a scalar <var class="Arg">s</var> is a new fully mutable matrix object whose entries are the corresponding quotients.</p>
833
834 <p>For a nonempty square matrix object <var class="Arg">M</var> over an associative base domain, and a positive integer <var class="Arg">n</var>, <var class="Arg">M</var><code class="code">^</code><var class="Arg">n</var> is a fully mutable matrix object whose entries are those of the <var class="Arg">n</var>-th power of <var class="Arg">M</var>. If <var class="Arg">n</var> is zero then <var class="Arg">M</var><code class="code">^</code><var class="Arg">n</var> is an identity matrix, and if <var class="Arg">n</var> is a negative integer and <var class="Arg">M</var> is invertible then <var class="Arg">M</var><code class="code">^</code><var class="Arg">n</var> is the (<code class="code">-</code><var class="Arg">n</var>)-th power of the inverse of <var class="Arg">M</var>.</p>
835
836 <p>All this is defined only if the matrix objects have the same dimensions and are defined over the same base domain and have the same representation, and if the products with the given scalar belong to the base domain; otherwise it is not specified what happens. If the result is a matrix object then it has the same representation and the same base domain as the given matrix object(s).</p>
837
838 <p><a id="X85FAB7E778A71C19" name="X85FAB7E778A71C19"></a></p>
839
840 <h4>26.11 <span class="Heading">Operations for Matrix Objects</span></h4>
841
842 <p><a id="X870FBE817C884AB5" name="X870FBE817C884AB5"></a></p>
843
844 <h5>26.11-1 MatElm</h5>
845
846 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; MatElm</code>( <var class="Arg">M</var>, <var class="Arg">row</var>, <var class="Arg">col</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
847 <p>Returns: an entry of the matrix object</p>
848
849 <p>For a matrix object <var class="Arg">M</var>, this operation returns the entry in row <var class="Arg">row</var> and column <var class="Arg">col</var>.</p>
850
851 <p>Also the syntax <var class="Arg">M</var><code class="code">[ </code><var class="Arg">row</var><code class="code">, </code><var class="Arg">col</var><code class="code"> ]</code> is supported.</p>
852
853 <p>Note that this is <em>not</em> equivalent to <var class="Arg">M</var><code class="code">[ </code><var class="Arg">row</var><code class="code"> ][ </code><var class="Arg">col</var><code class="code"> ]</code>, which would first try to access <var class="Arg">M</var><code class="code">[ </code><var class="Arg">row</var><code class="code"> ]</code>, and this is in general not possible.</p>
854
855 <p><a id="X7C33059984635480" name="X7C33059984635480"></a></p>
856
857 <h5>26.11-2 SetMatElm</h5>
858
859 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; SetMatElm</code>( <var class="Arg">M</var>, <var class="Arg">row</var>, <var class="Arg">col</var>, <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
860 <p>Returns: nothing</p>
861
862 <p>For a mutable matrix object <var class="Arg">M</var>, this operation assigns the object <var class="Arg">obj</var> to the position in row <var class="Arg">row</var> and column <var class="Arg">col</var>, provided that <var class="Arg">obj</var> is compatible with the <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) value of <var class="Arg">M</var>.</p>
863
864 <p>Also the syntax <var class="Arg">M</var><code class="code">[ </code><var class="Arg">row</var><code class="code">, </code><var class="Arg">col</var><code class="code"> ]:= </code><var class="Arg">obj</var> is supported.</p>
865
866 <p>Note that this is <em>not</em> equivalent to <var class="Arg">M</var><code class="code">[ </code><var class="Arg">row</var><code class="code"> ][ </code><var class="Arg">col</var><code class="code"> ]:= </code><var class="Arg">obj</var>, which would first try to access <var class="Arg">M</var><code class="code">[ </code><var class="Arg">row</var><code class="code"> ]</code>, and this is in general not possible.</p>
867
868 <p>If the global option <code class="code">check</code> is set to <code class="keyw">false</code> then <code class="func">SetMatElm</code> need not perform consistency checks.</p>
869
870 <p><a id="X838B45F7790E9FDF" name="X838B45F7790E9FDF"></a></p>
871
872 <h5>26.11-3 ExtractSubMatrix</h5>
873
874 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ExtractSubMatrix</code>( <var class="Arg">M</var>, <var class="Arg">rows</var>, <var class="Arg">cols</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
875 <p>Creates a copy of the submatrix described by the two lists, which mean subsets of row and column positions, respectively. This does <var class="Arg">M</var>{<var class="Arg">rows</var>}{<var class="Arg">cols</var>} and returns the result. It preserves the representation of the matrix.</p>
876
877 <p>If the <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value of the result implies <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>) then the result is fully mutable.</p>
878
879 <p><a id="X793CD4637F237915" name="X793CD4637F237915"></a></p>
880
881 <h5>26.11-4 MutableCopyMatrix</h5>
882
883 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; MutableCopyMatrix</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
884 <p>For a matrix object <var class="Arg">M</var>, this operation returns a fully mutable copy of <var class="Arg">M</var>, with the same <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) and <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) values,</p>
885
886 <p><a id="X7ED9E5D4809E3B50" name="X7ED9E5D4809E3B50"></a></p>
887
888 <h5>26.11-5 CopySubMatrix</h5>
889
890 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; CopySubMatrix</code>( <var class="Arg">src</var>, <var class="Arg">dst</var>, <var class="Arg">srows</var>, <var class="Arg">drows</var>, <var class="Arg">scols</var>, <var class="Arg">dcols</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
891 <p>Returns: nothing</p>
892
893 <p>Does <code class="code"><var class="Arg">dst</var>{<var class="Arg">drows</var>}{<var class="Arg">dcols</var>} := <var class="Arg">src</var>{<var class="Arg">srows</var>}{<var class="Arg">scols</var>}</code> without creating an intermediate object and thus –at least in special cases– much more efficiently. For certain objects like compressed vectors this might be significantly more efficient if <var class="Arg">scols</var> and <var class="Arg">dcols</var> are ranges with increment 1.</p>
894
895 <p>If the global option <code class="code">check</code> is set to <code class="keyw">false</code> then <code class="func">CopySubMatrix</code> need not perform consistency checks.</p>
896
897 <p><a id="X809A6B3F7EA5E7D8" name="X809A6B3F7EA5E7D8"></a></p>
898
899 <h5>26.11-6 CompatibleVector</h5>
900
901 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; CompatibleVector</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
902 <p>Returns: a vector object</p>
903
904 <p>Called with a matrix object <var class="Arg">M</var> with <span class="SimpleMath">m</span> rows, this operation returns a mutable zero vector object <span class="SimpleMath">v</span> of length <span class="SimpleMath">m</span> and in the representation given by the <code class="func">CompatibleVectorFilter</code> (<a href="chap26.html#X818702FD7A2E9D90"><span class="RefLink">26.3-3</span></a>) value of <var class="Arg">M</var> (provided that such a representation exists).</p>
905
906 <p>The idea is that there should be an efficient way to form the product <span class="SimpleMath">v</span><var class="Arg">M</var>.</p>
907
908 <p><a id="X7EE70D5A81E9ED72" name="X7EE70D5A81E9ED72"></a></p>
909
910 <h5>26.11-7 RowsOfMatrix</h5>
911
912 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; RowsOfMatrix</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;attribute&nbsp;)</td></tr></table></div>
913 <p>Returns: a plain list</p>
914
915 <p>Called with a matrix object <var class="Arg">M</var>, this operation returns a plain list of objects in the representation given by the <code class="func">CompatibleVectorFilter</code> (<a href="chap26.html#X818702FD7A2E9D90"><span class="RefLink">26.3-3</span></a>) value of <var class="Arg">M</var> (provided that such a representation exists), where the <span class="SimpleMath">i</span>-th entry describes the <span class="SimpleMath">i</span>-th row of the input.</p>
916
917 <p><a id="X7E06762479A00DF4" name="X7E06762479A00DF4"></a></p>
918
919 <h5>26.11-8 <span class="Heading">CompanionMatrix</span></h5>
920
921 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; CompanionMatrix</code>( <var class="Arg">pol</var>, <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
922 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; CompanionMatrix</code>( <var class="Arg">filt</var>, <var class="Arg">pol</var>, <var class="Arg">R</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
923 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; CompanionMatrix</code>( <var class="Arg">pol</var>, <var class="Arg">R</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
924 <p>Returns: a matrix object</p>
925
926 <p>For a monic, univariate polynomial <var class="Arg">pol</var> whose coefficients lie in the base domain of the matrix object <var class="Arg">M</var>, <code class="func">CompanionMatrix</code> returns the companion matrix of <var class="Arg">pol</var>, as a matrix object with the same <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) and <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) values as <var class="Arg">M</var>.</p>
927
928 <p>We use column convention, that is, the negatives of the coefficients of <var class="Arg">pol</var> appear in the last column of the result.</p>
929
930 <p>If a filter <var class="Arg">filt</var> and a semiring <var class="Arg">R</var> are given then the companion matrix is returned as a matrix object with <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value <var class="Arg">filt</var> and <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) value <var class="Arg">R</var>.</p>
931
932 <p>If only <var class="Arg">pol</var> and a semiring <var class="Arg">R</var> are given, the representation of the result is guessed from <var class="Arg">R</var>.</p>
933
934 <p>If the <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value of the result implies <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>) then the result is fully mutable.</p>
935
936
937 <div class="example"><pre>
938 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">x:= X( GF(5) );; pol:= x^3 + x^2 + 2*x + 3;;</span>
939 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">M:= CompanionMatrix( IsPlistMatrixRep, pol, GF(25) );;</span>
940 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Display( M );</span>
941 &lt;3x3-matrix over GF(5^2):
942 [[ 0*Z(5), 0*Z(5), Z(5) ]
943 [ Z(5)^0, 0*Z(5), Z(5)^3 ]
944 [ 0*Z(5), Z(5)^0, Z(5)^2 ]
945 ]&gt;
946 </pre></div>
947
948 <p><a id="X7D40EE2084A6C976" name="X7D40EE2084A6C976"></a></p>
949
950 <h4>26.12 <span class="Heading">Operations for Row List Matrix Objects</span></h4>
951
952 <p>In general, matrix objects are not lists in the sense of <code class="func">IsList</code> (<a href="chap21.html#X7C4CC4EA8299701E"><span class="RefLink">21.1-1</span></a>), and they need not behave like lists, that is, they need not obey all the rules for lists that are stated in Chapter <a href="chap21.html#X7B256AE5780F140A"><span class="RefLink">21</span></a>. There are situations where one wants to have matrix objects that can on the one hand benefit from <strong class="pkg">GAP</strong>'s method selection, as is explained in Section <a href="chap26.html#X7A7275C27EC61ACE"><span class="RefLink">26.1</span></a>, and do on the other hands support access to <strong class="pkg">GAP</strong> objects that represent their rows (which are suitable vector objects). Matrix objects whose <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value implies <code class="func">IsRowListMatrix</code> (<a href="chap26.html#X78CD88A283330E72"><span class="RefLink">26.2-4</span></a>) support the operations described in this section.</p>
953
954 <p>One implementation of such matrices is given by the <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value <code class="func">IsPlistMatrixRep</code> (<a href="chap26.html#X80C6031C7DB31A15"><span class="RefLink">26.16-3</span></a>), and any row of these matrices is a vector object in <code class="func">IsPlistVectorRep</code> (<a href="chap26.html#X83262B7085FA94E3"><span class="RefLink">26.15-3</span></a>). Note that these objects do <em>not</em> lie in <code class="func">IsList</code> (<a href="chap21.html#X7C4CC4EA8299701E"><span class="RefLink">21.1-1</span></a>) (and in particular not in <code class="func">IsPlistRep</code> (<a href="chap21.html#X87BA4EBF80F16B72"><span class="RefLink">21.24-2</span></a>)), thus we are allowed to define the above operations only restrictively, as follows.</p>
955
956 <p>Unbinding an entry in a row or unbinding a row in a matrix is allowed only in the last position, that is, the vector and matrix objects insist on being dense. All rows of a matrix must have the same length and the same base domain.</p>
957
958 <p><a id="X82C4FCFA808010F8" name="X82C4FCFA808010F8"></a></p>
959
960 <h5>26.12-1 <span class="Heading">List Access for a Row List Matrix</span></h5>
961
962 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; <span>\</span>[<span>\</span>]</code>( <var class="Arg">M</var>, <var class="Arg">pos</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
963 <p>Returns: a vector object</p>
964
965 <p>If <var class="Arg">M</var> is a row list matrix and if <var class="Arg">pos</var> is a positive integer not larger than the number of rows of <var class="Arg">M</var>, this operation returns the <var class="Arg">pos</var>-th row of <var class="Arg">M</var>.</p>
966
967 <p>It is not specified what happens if <var class="Arg">pos</var> is larger.</p>
968
969 <p><a id="X7F89BB2482D28AAE" name="X7F89BB2482D28AAE"></a></p>
970
971 <h5>26.12-2 <span class="Heading">List Assignment for a Row List Matrix</span></h5>
972
973 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; <span>\</span>[<span>\</span>]\:\=</code>( <var class="Arg">M</var>, <var class="Arg">pos</var>, <var class="Arg">v</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
974 <p>Returns: nothing</p>
975
976 <p>If <var class="Arg">M</var> is a row list matrix, <var class="Arg">v</var> is a vector object that can occur as a row in <var class="Arg">M</var> (that is, <var class="Arg">v</var> has the same base domain, the right length, and the right vector representation), and if <var class="Arg">pos</var> is a positive integer not larger than the number of rows of <var class="Arg">M</var> plus 1, this operation sets <var class="Arg">v</var> as the <var class="Arg">pos</var>-th row of <var class="Arg">M</var>.</p>
977
978 <p>In all other situations, it is not specified what happens.</p>
979
980 <p><a id="X807518367C96516F" name="X807518367C96516F"></a></p>
981
982 <h5>26.12-3 <span class="Heading">Sublist Access for a Row List Matrix</span></h5>
983
984 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \{\}</code>( <var class="Arg">M</var>, <var class="Arg">poss</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
985 <p>Returns: a row list matrix</p>
986
987 <p>For a row list matrix <var class="Arg">M</var> and a list <var class="Arg">poss</var> of positions, <var class="Arg">M</var><code class="code">{ </code><var class="Arg">poss</var><code class="code"> }</code> returns a new mutable row list matrix with the same representation as <var class="Arg">M</var>, whose rows are identical to the rows at the positions in the list <var class="Arg">poss</var> in <var class="Arg">M</var>.</p>
988
989 <p><a id="X8371789181FA136B" name="X8371789181FA136B"></a></p>
990
991 <h5>26.12-4 <span class="Heading">Sublist Assignment for a Row List Matrix</span></h5>
992
993 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \{\}\:\=</code>( <var class="Arg">M</var>, <var class="Arg">poss</var>, <var class="Arg">M2</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
994 <p>Returns: nothing</p>
995
996 <p>For a mutable row list matrix <var class="Arg">M</var>, a list <var class="Arg">poss</var> of positions, and a row list matrix <var class="Arg">M2</var> of the same vector type and with the same base domain, <var class="Arg">M</var><code class="code">{ </code><var class="Arg">poss</var><code class="code"> }:= </code><var class="Arg">M2</var> assigns the rows of <var class="Arg">M2</var> to the positions <var class="Arg">poss</var> in the list of rows of <var class="Arg">M</var>.</p>
997
998 <p>It is not specified what happens if the resulting range of row positions is not dense.</p>
999
1000 <p><a id="X872E63867803ED78" name="X872E63867803ED78"></a></p>
1001
1002 <h5><code>26.12-5 IsBound<span>\</span>[<span>\</span>]</code></h5>
1003
1004 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsBound<span>\</span>[<span>\</span>]</code>( <var class="Arg">M</var>, <var class="Arg">pos</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1005 <p>Returns: <code class="keyw">true</code> or <code class="keyw">false</code></p>
1006
1007 <p>For a row list matrix <var class="Arg">M</var> and a positive integer <var class="Arg">pos</var>, <code class="code">IsBound( </code><var class="Arg">M</var><code class="code">[ </code><var class="Arg">pos</var><code class="code"> ] )</code> returns <code class="keyw">true</code> if <var class="Arg">pos</var> is at most the number of rows of <var class="Arg">M</var>, and <code class="keyw">false</code> otherwise.</p>
1008
1009 <p><a id="X79328CB280C71DDB" name="X79328CB280C71DDB"></a></p>
1010
1011 <h5><code>26.12-6 Unbind<span>\</span>[<span>\</span>]</code></h5>
1012
1013 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Unbind<span>\</span>[<span>\</span>]</code>( <var class="Arg">M</var>, <var class="Arg">pos</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1014 <p>Returns: nothing</p>
1015
1016 <p>For a mutable row list matrix <var class="Arg">M</var> with <var class="Arg">pos</var> rows, <code class="code">Unbind( </code><var class="Arg">M</var><code class="code">[ </code><var class="Arg">pos</var><code class="code"> ] )</code> removes the last row. It is not specified what happens if <var class="Arg">pos</var> has another value.</p>
1017
1018 <p><a id="X7BDD838579E4D2D6" name="X7BDD838579E4D2D6"></a></p>
1019
1020 <h5>26.12-7 Add</h5>
1021
1022 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Add</code>( <var class="Arg">M</var>, <var class="Arg">v</var>[, <var class="Arg">pos</var>] )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1023 <p>Returns: nothing</p>
1024
1025 <p>For a mutable row list matrix <var class="Arg">M</var> and a vector object <var class="Arg">v</var> that is compatible with the rows of <var class="Arg">M</var>, the two argument version adds <var class="Arg">v</var> at the end of the list of rows of <var class="Arg">M</var>.</p>
1026
1027 <p>If a positive integer <var class="Arg">pos</var> is given then <var class="Arg">v</var> is added in position <var class="Arg">pos</var>, and all later rows are shifted up by one position.</p>
1028
1029 <p><a id="X86E355D07A41C025" name="X86E355D07A41C025"></a></p>
1030
1031 <h5>26.12-8 Remove</h5>
1032
1033 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Remove</code>( <var class="Arg">M</var>[, <var class="Arg">pos</var>] )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1034 <p>Returns: a vector object if the removed row exists, otherwise nothing</p>
1035
1036 <p>For a mutable row list matrix <var class="Arg">M</var>, this operation removes the <var class="Arg">pos</var>-th row and shifts the later rows down by one position. The default for <var class="Arg">pos</var> is the number of rows of <var class="Arg">M</var>.</p>
1037
1038 <p>If the <var class="Arg">pos</var>-th row existed in <var class="Arg">M</var> then it is returned, otherwise nothing is returned.</p>
1039
1040 <p><a id="X82D0359B81F8D442" name="X82D0359B81F8D442"></a></p>
1041
1042 <h5>26.12-9 Append</h5>
1043
1044 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Append</code>( <var class="Arg">M1</var>, <var class="Arg">M2</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1045 <p>Returns: nothing</p>
1046
1047 <p>For two row list matrices <var class="Arg">M1</var>, <var class="Arg">M2</var> such that <var class="Arg">M1</var> is mutable and such that the <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) and <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) values are equal, this operation appends the rows of <var class="Arg">M2</var> to the rows of <var class="Arg">M1</var>.</p>
1048
1049 <p><a id="X7E234F717BE333EA" name="X7E234F717BE333EA"></a></p>
1050
1051 <h5>26.12-10 ShallowCopy</h5>
1052
1053 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ShallowCopy</code>( <var class="Arg">M</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1054 <p>Returns: a matrix object</p>
1055
1056 <p>For a row list matrix <var class="Arg">M</var>, this operation returns a new mutable matrix with the same <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) and <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) values as <var class="Arg">M</var>, which shares its rows with <var class="Arg">M</var>.</p>
1057
1058 <p><a id="X7E9F095E85DED480" name="X7E9F095E85DED480"></a></p>
1059
1060 <h5>26.12-11 ListOp</h5>
1061
1062 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ListOp</code>( <var class="Arg">M</var>[, <var class="Arg">func</var>] )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1063 <p>Returns: a plain list</p>
1064
1065 <p>For a row list matrix <var class="Arg">M</var>, the variant with one argument returns the plain list (see <code class="func">IsPlistRep</code> (<a href="chap21.html#X87BA4EBF80F16B72"><span class="RefLink">21.24-2</span></a>)) of its rows, and the variant with two arguments returns the plain list of values of these rows under the function <var class="Arg">func</var>.</p>
1066
1067 <p><a id="X7B86A8487B12F9BD" name="X7B86A8487B12F9BD"></a></p>
1068
1069 <h4>26.13 <span class="Heading">Basic operations for row/column reductions</span></h4>
1070
1071 <p><a id="X7B3997D37CC44FCA" name="X7B3997D37CC44FCA"></a></p>
1072
1073 <h5>26.13-1 MultMatrixRowLeft</h5>
1074
1075 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; MultMatrixRowLeft</code>( <var class="Arg">mat</var>, <var class="Arg">i</var>, <var class="Arg">elm</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1076 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; MultMatrixRow</code>( <var class="Arg">mat</var>, <var class="Arg">i</var>, <var class="Arg">elm</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1077 <p>Returns: nothing</p>
1078
1079 <p>Multiplies the <var class="Arg">i</var>-th row of the mutable matrix <var class="Arg">mat</var> with the scalar <var class="Arg">elm</var> from the left in-place.</p>
1080
1081 <p><code class="func">MultMatrixRow</code> is a synonym of <code class="func">MultMatrixRowLeft</code>. This was chosen because linear combinations of rows of matrices are usually written as <span class="SimpleMath">v â‹… A = [v_1, ... ,v_n] â‹… A</span> which multiplies scalars from the left.</p>
1082
1083 <p><a id="X794636447E8C5553" name="X794636447E8C5553"></a></p>
1084
1085 <h5>26.13-2 MultMatrixRowRight</h5>
1086
1087 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; MultMatrixRowRight</code>( <var class="Arg">M</var>, <var class="Arg">i</var>, <var class="Arg">elm</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1088 <p>Returns: nothing</p>
1089
1090 <p>Multiplies the <var class="Arg">i</var>-th row of the mutable matrix <var class="Arg">M</var> with the scalar <var class="Arg">elm</var> from the right in-place.</p>
1091
1092 <p><a id="X80AF7B267E6B9CE0" name="X80AF7B267E6B9CE0"></a></p>
1093
1094 <h5>26.13-3 MultMatrixColumnRight</h5>
1095
1096 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; MultMatrixColumnRight</code>( <var class="Arg">M</var>, <var class="Arg">i</var>, <var class="Arg">elm</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1097 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; MultMatrixColumn</code>( <var class="Arg">M</var>, <var class="Arg">i</var>, <var class="Arg">elm</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1098 <p>Returns: nothing</p>
1099
1100 <p>Multiplies the <var class="Arg">i</var>-th column of the mutable matrix <var class="Arg">M</var> with the scalar <var class="Arg">elm</var> from the right in-place.</p>
1101
1102 <p><code class="func">MultMatrixColumn</code> is a synonym of <code class="func">MultMatrixColumnRight</code>. This was chosen because linear combinations of columns of matrices are usually written as <span class="SimpleMath">A â‹… v^T = A â‹… [v_1, ... ,v_n]^T</span> which multiplies scalars from the right.</p>
1103
1104 <p><a id="X843DAFE37F347471" name="X843DAFE37F347471"></a></p>
1105
1106 <h5>26.13-4 MultMatrixColumnLeft</h5>
1107
1108 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; MultMatrixColumnLeft</code>( <var class="Arg">M</var>, <var class="Arg">i</var>, <var class="Arg">elm</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1109 <p>Returns: nothing</p>
1110
1111 <p>Multiplies the <var class="Arg">i</var>-th column of the mutable matrix <var class="Arg">M</var> with the scalar <var class="Arg">elm</var> from the left in-place.</p>
1112
1113 <p><a id="X8662EB748629502F" name="X8662EB748629502F"></a></p>
1114
1115 <h5>26.13-5 AddMatrixRowsLeft</h5>
1116
1117 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AddMatrixRowsLeft</code>( <var class="Arg">M</var>, <var class="Arg">i</var>, <var class="Arg">j</var>, <var class="Arg">elm</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1118 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AddMatrixRows</code>( <var class="Arg">M</var>, <var class="Arg">i</var>, <var class="Arg">j</var>, <var class="Arg">elm</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1119 <p>Returns: nothing</p>
1120
1121 <p>Adds the product of <var class="Arg">elm</var> with the <var class="Arg">j</var>-th row of the mutable matrix <var class="Arg">M</var> to its <var class="Arg">i</var>-th row in-place. The <var class="Arg">j</var>-th row is multiplied with <var class="Arg">elm</var> from the left.</p>
1122
1123 <p><code class="func">AddMatrixRows</code> is a synonym of <code class="func">AddMatrixRowsLeft</code>. This was chosen because linear combinations of rows of matrices are usually written as <span class="SimpleMath">v â‹… A = [v_1, ... ,v_n] â‹… A</span> which multiplies scalars from the left.</p>
1124
1125 <p><a id="X7CD05EE984614AB6" name="X7CD05EE984614AB6"></a></p>
1126
1127 <h5>26.13-6 AddMatrixRowsRight</h5>
1128
1129 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AddMatrixRowsRight</code>( <var class="Arg">M</var>, <var class="Arg">i</var>, <var class="Arg">j</var>, <var class="Arg">elm</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1130 <p>Returns: nothing</p>
1131
1132 <p>Adds the product of <var class="Arg">elm</var> with the <var class="Arg">j</var>-th row of the mutable matrix <var class="Arg">M</var> to its <var class="Arg">i</var>-th row in-place. The <var class="Arg">j</var>-th row is multiplied with <var class="Arg">elm</var> from the right.</p>
1133
1134 <p><a id="X7B1E1E417CA267A3" name="X7B1E1E417CA267A3"></a></p>
1135
1136 <h5>26.13-7 AddMatrixColumnsRight</h5>
1137
1138 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AddMatrixColumnsRight</code>( <var class="Arg">M</var>, <var class="Arg">i</var>, <var class="Arg">j</var>, <var class="Arg">elm</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1139 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AddMatrixColumns</code>( <var class="Arg">M</var>, <var class="Arg">i</var>, <var class="Arg">j</var>, <var class="Arg">elm</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1140 <p>Returns: nothing</p>
1141
1142 <p>Adds the product of <var class="Arg">elm</var> with the <var class="Arg">j</var>-th column of the mutable matrix <var class="Arg">M</var> to its <var class="Arg">i</var>-th column in-place. The <var class="Arg">j</var>-th column is multiplied with <var class="Arg">elm</var> from the right.</p>
1143
1144 <p><code class="func">AddMatrixColumns</code> is a synonym of <code class="func">AddMatrixColumnsRight</code>. This was chosen because linear combinations of columns of matrices are usually written as <span class="SimpleMath">A â‹… v^T = A â‹… [v_1, ... ,v_n]^T</span> which multiplies scalars from the right.</p>
1145
1146 <p><a id="X85ECB8C87DFD8F32" name="X85ECB8C87DFD8F32"></a></p>
1147
1148 <h5>26.13-8 AddMatrixColumnsLeft</h5>
1149
1150 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AddMatrixColumnsLeft</code>( <var class="Arg">M</var>, <var class="Arg">i</var>, <var class="Arg">j</var>, <var class="Arg">elm</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1151 <p>Returns: nothing</p>
1152
1153 <p>Adds the product of <var class="Arg">elm</var> with the <var class="Arg">j</var>-th column of the mutable matrix <var class="Arg">M</var> to its <var class="Arg">i</var>-th column in-place. The <var class="Arg">j</var>-th column is multiplied with <var class="Arg">elm</var> from the left.</p>
1154
1155 <p><a id="X86B9C2EC8794BFE0" name="X86B9C2EC8794BFE0"></a></p>
1156
1157 <h5>26.13-9 PositionNonZeroInRow</h5>
1158
1159 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; PositionNonZeroInRow</code>( <var class="Arg">M</var>, <var class="Arg">i</var>[, <var class="Arg">from</var>] )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1160 <p>Returns: a positive integer</p>
1161
1162 <p>Returns the position of the first nonzero entry in the <var class="Arg">i</var>-th row of the matrix <var class="Arg">M</var>, or <code class="code">NrCols( M ) + 1</code> if the row is zero. If the optional argument <var class="Arg">from</var> is given, the search starts after position <var class="Arg">from</var>.</p>
1163
1164 <p><a id="X87CCA3117F6B3F0D" name="X87CCA3117F6B3F0D"></a></p>
1165
1166 <h5>26.13-10 SwapMatrixRows</h5>
1167
1168 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; SwapMatrixRows</code>( <var class="Arg">M</var>, <var class="Arg">i</var>, <var class="Arg">j</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1169 <p>Returns: nothing</p>
1170
1171 <p>Swaps the <var class="Arg">i</var>-th row and <var class="Arg">j</var>-th row of a mutable matrix <var class="Arg">M</var>.</p>
1172
1173 <p><a id="X824C8A347EB9D499" name="X824C8A347EB9D499"></a></p>
1174
1175 <h5>26.13-11 SwapMatrixColumns</h5>
1176
1177 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; SwapMatrixColumns</code>( <var class="Arg">M</var>, <var class="Arg">i</var>, <var class="Arg">j</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1178 <p>Returns: nothing</p>
1179
1180 <p>Swaps the <var class="Arg">i</var>-th column and <var class="Arg">j</var>-th column of a mutable matrix <var class="Arg">M</var>.</p>
1181
1182 <p><a id="X7E3B10A67BC7F006" name="X7E3B10A67BC7F006"></a></p>
1183
1184 <h5>26.13-12 AddMatrix</h5>
1185
1186 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AddMatrix</code>( <var class="Arg">M</var>, <var class="Arg">N</var>[, <var class="Arg">c</var>] )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1187 <p>Returns: nothing</p>
1188
1189 <p>Computes the calculation <span class="SimpleMath">M + N â‹… c</span> in-place, storing the result in <var class="Arg">M</var>. If the optional argument <var class="Arg">c</var> is omitted, then <var class="Arg">N</var> is added directly. The matrices must have the same dimensions, otherwise the result is undefined. Specialized methods may be defined only when <var class="Arg">M</var> and <var class="Arg">N</var> have the same representation. If both of the matrices are lists-of-lists, then the operation is delegated row by row to <code class="func">AddRowVector</code> (<a href="chap23.html#X800EC03F7E0A5F23"><span class="RefLink">23.4-1</span></a>).</p>
1190
1191
1192 <div class="example"><pre>
1193 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">mat1 := [ [ 1, 2 ], [ 3, 4 ] ];</span>
1194 [ [ 1, 2 ], [ 3, 4 ] ]
1195 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">mat2 := [ [ 1, 0 ], [ 3, -1 ] ];</span>
1196 [ [ 1, 0 ], [ 3, -1 ] ]
1197 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">AddMatrix( mat1, mat2, 2 );</span>
1198 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">mat1;</span>
1199 [ [ 3, 2 ], [ 9, 2 ] ]
1200 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">mat2;</span>
1201 [ [ 1, 0 ], [ 3, -1 ] ]
1202 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">AddMatrix( mat1, [ [ 1, 0], [ 3, -1] ] );</span>
1203 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">mat1;</span>
1204 [ [ 4, 2 ], [ 12, 1 ] ]
1205 </pre></div>
1206
1207 <p><a id="X85DAF850790CD476" name="X85DAF850790CD476"></a></p>
1208
1209 <h5>26.13-13 MultMatrix</h5>
1210
1211 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; MultMatrix</code>( <var class="Arg">mat</var>, <var class="Arg">c</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1212 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; MultMatrixLeft</code>( <var class="Arg">mat</var>, <var class="Arg">c</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1213 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; MultMatrixRight</code>( <var class="Arg">mat</var>, <var class="Arg">c</var> )</td><td class="tdright">(&nbsp;operation&nbsp;)</td></tr></table></div>
1214 <p>Returns: nothing</p>
1215
1216 <p>These functions multiply the entries of <var class="Arg">mat</var> by <var class="Arg">c</var> in-place. <code class="func">MultMatrixRight</code> performs the operation <var class="Arg">mat</var><code class="code">*</code><var class="Arg">c</var>, whereas <code class="func">MultMatrixLeft</code> performs the operation <var class="Arg">c</var><code class="code">*</code><var class="Arg">mat</var> and <code class="func">MultMatrix</code> is an alias for <code class="func">MultMatrixLeft</code>. In all of these, if the matrix <var class="Arg">mat</var> is a lists-of-lists, then the operation is delegated row by row to <code class="func">MultVectorRight</code> (<a href="chap23.html#X7BEF28C981C42E16"><span class="RefLink">23.4-3</span></a>) and <code class="func">MultVectorLeft</code> (<a href="chap23.html#X7BEF28C981C42E16"><span class="RefLink">23.4-3</span></a>).</p>
1217
1218
1219 <div class="example"><pre>
1220 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">mat1 := [ [ 1, 2 ], [ 3, 4 ] ];</span>
1221 [ [ 1, 2 ], [ 3, 4 ] ]
1222 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">MultMatrixRight(mat1, -2);</span>
1223 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">mat1;</span>
1224 [ [ -2, -4 ], [ -6, -8 ] ]
1225 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">MultMatrix(mat1, -2); # Note that this is the same as calling MultMatrixLeft(mat1, -2)</span>
1226 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">mat1;</span>
1227 [ [ 4, 8 ], [ 12, 16 ] ]
1228 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">A := FreeAssociativeAlgebra(Rationals, 2);</span>
1229 &lt;algebra over Rationals, with 2 generators&gt;
1230 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">mat2 := [ [ A.1, A.2 ], [ A.1 * 2, A.2 * 3 ] ];</span>
1231 [ [ (1)*x.1, (1)*x.2 ], [ (2)*x.1, (3)*x.2 ] ]
1232 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">MultMatrixLeft(mat2, A.1);</span>
1233 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">mat2;</span>
1234 [ [ (1)*x.1^2, (1)*x.1*x.2 ], [ (2)*x.1^2, (3)*x.1*x.2 ] ]
1235 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">mat2 := [ [ A.1, A.2 ], [ A.1 * 2, A.2 * 3 ] ];</span>
1236 [ [ (1)*x.1, (1)*x.2 ], [ (2)*x.1, (3)*x.2 ] ]
1237 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">MultMatrixRight(mat2, A.1);</span>
1238 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">mat2;</span>
1239 [ [ (1)*x.1^2, (1)*x.2*x.1 ], [ (2)*x.1^2, (3)*x.2*x.1 ] ]
1240 </pre></div>
1241
1242 <p><a id="X7BEE647484978886" name="X7BEE647484978886"></a></p>
1243
1244 <h4>26.14 <span class="Heading">Implementing New Vector and Matrix Objects Types</span></h4>
1245
1246 <p>The first step in the design of a new type of vector or matrix objects is to create a new filter that serves as the <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) of the new objects, see the sections <a href="chap26.html#X82EEE1D37A94F807"><span class="RefLink">26.15</span></a> and <a href="chap26.html#X7CFD844C7D80D541"><span class="RefLink">26.16</span></a> for an overview of such filters that are already available.</p>
1247
1248 <p>Here we list those operations for vector and matrix objects for which no default methods can be installed. When one implements a new type of vector or matrix objects then one has to install specific methods at least for these operations, in order to make the objects behave as described in this chapter. It is advisable to install specific methods also for other operations, for performance reasons. The installations of default methods can be found in the file <code class="file">lib/matobj.gi</code> of the <strong class="pkg">GAP</strong> distribution. There one can check for which operations it makes sense to overload them for the new type of vector or matrix objects. Note that the specific methods must be installed with <code class="func">InstallTagBasedMethod</code> (<a href="chap78.html#X799081B4854DC003"><span class="RefLink">78.1-6</span></a>) whenever the default method is installed with this function.</p>
1249
1250 <p><em>Vector objects</em></p>
1251
1252
1253 <ul>
1254 <li><p><code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>),</p>
1255
1256 </li>
1257 <li><p><code class="func">Length</code> (<a href="chap26.html#X828BA5E1849E3D06"><span class="RefLink">26.3-4</span></a>),</p>
1258
1259 </li>
1260 <li><p><code class="func"><span>\</span>[<span>\</span>]</code> (<a href="chap26.html#X7D5DF49C7ADB6986"><span class="RefLink">26.7-1</span></a>),</p>
1261
1262 </li>
1263 <li><p><code class="func"><span>\</span>[<span>\</span>]\:\=</code> (<a href="chap26.html#X7D5DF49C7ADB6986"><span class="RefLink">26.7-1</span></a>) (with consistency checks if the global option <code class="code">check</code> is not set to <code class="keyw">false</code>),</p>
1264
1265 </li>
1266 <li><p><code class="func">\&lt;</code> (<a href="chap31.html#X7EF67D047F03CA6F"><span class="RefLink">31.11-1</span></a>) (see <code class="func">\&lt;</code> (<a href="chap26.html#X7FFC60A27FE6FA97"><span class="RefLink">26.6-1</span></a>)),</p>
1267
1268 </li>
1269 <li><p><code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>),</p>
1270
1271 </li>
1272 <li><p><code class="func">NewVector</code> (<a href="chap26.html#X860E84397BD148E9"><span class="RefLink">26.4-1</span></a>) (with consistency checks if the global option <code class="code">check</code> is not set to <code class="keyw">false</code>, install the method with <code class="func">InstallTagBasedMethod</code> (<a href="chap78.html#X799081B4854DC003"><span class="RefLink">78.1-6</span></a>)).</p>
1273
1274 </li>
1275 </ul>
1276 <p><em>Matrix objects</em></p>
1277
1278
1279 <ul>
1280 <li><p><code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>),</p>
1281
1282 </li>
1283 <li><p><code class="func">NumberRows</code> (<a href="chap26.html#X820ED34380C10E19"><span class="RefLink">26.3-5</span></a>),</p>
1284
1285 </li>
1286 <li><p><code class="func">NumberColumns</code> (<a href="chap26.html#X820ED34380C10E19"><span class="RefLink">26.3-5</span></a>),</p>
1287
1288 </li>
1289 <li><p><code class="func">MatElm</code> (<a href="chap26.html#X870FBE817C884AB5"><span class="RefLink">26.11-1</span></a>),</p>
1290
1291 </li>
1292 <li><p><code class="func">SetMatElm</code> (<a href="chap26.html#X7C33059984635480"><span class="RefLink">26.11-2</span></a>) (with consistency checks if the global option <code class="code">check</code> is not set to <code class="keyw">false</code>),</p>
1293
1294 </li>
1295 <li><p><code class="func">\&lt;</code> (<a href="chap31.html#X7EF67D047F03CA6F"><span class="RefLink">31.11-1</span></a>) (see <code class="func">\&lt;</code> (<a href="chap26.html#X7FFC60A27FE6FA97"><span class="RefLink">26.6-1</span></a>)),</p>
1296
1297 </li>
1298 <li><p><code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>),</p>
1299
1300 </li>
1301 <li><p><code class="func">CompatibleVectorFilter</code> (<a href="chap26.html#X818702FD7A2E9D90"><span class="RefLink">26.3-3</span></a>),</p>
1302
1303 </li>
1304 <li><p><code class="func">NewMatrix</code> (<a href="chap26.html#X7AD2210B8047FB01"><span class="RefLink">26.4-4</span></a>) (with consistency checks if the global option <code class="code">check</code> is not set to <code class="keyw">false</code>, install the method with <code class="func">InstallTagBasedMethod</code> (<a href="chap78.html#X799081B4854DC003"><span class="RefLink">78.1-6</span></a>)).</p>
1305
1306 </li>
1307 </ul>
1308 <p>Methods for <code class="func">NewVector</code> (<a href="chap26.html#X860E84397BD148E9"><span class="RefLink">26.4-1</span></a>) and <code class="func">NewMatrix</code> (<a href="chap26.html#X7AD2210B8047FB01"><span class="RefLink">26.4-4</span></a>) must check their arguments for consistency (do the given filter and base domain fit together, are the entries compatible with the given base domain, is the number of matrix entries a multiple of the given number of columns) except if the global option <code class="code">check</code> is set to <code class="keyw">false</code>. (See Chapter <a href="chap8.html#X7FD84061873F72A2"><span class="RefLink">8</span></a> for information about global options.) The same holds for methods for operations that modify mutable vector or matrix objects, such as <code class="func"><span>\</span>[<span>\</span>]\:\=</code> (<a href="chap26.html#X7D5DF49C7ADB6986"><span class="RefLink">26.7-1</span></a>), <code class="func">SetMatElm</code> (<a href="chap26.html#X7C33059984635480"><span class="RefLink">26.11-2</span></a>), <code class="func">CopySubVector</code> (<a href="chap26.html#X80EC354D78D7B5A6"><span class="RefLink">26.9-3</span></a>), <code class="func">CopySubMatrix</code> (<a href="chap26.html#X7ED9E5D4809E3B50"><span class="RefLink">26.11-5</span></a>), and for those methods of <code class="func">Vector</code> (<a href="chap26.html#X79A6544D86261E82"><span class="RefLink">26.4-2</span></a>) and <code class="func">Matrix</code> (<a href="chap26.html#X879384D479EB1D82"><span class="RefLink">26.4-5</span></a>) that do not delegate to <code class="func">NewVector</code> (<a href="chap26.html#X860E84397BD148E9"><span class="RefLink">26.4-1</span></a>) and <code class="func">NewMatrix</code> (<a href="chap26.html#X7AD2210B8047FB01"><span class="RefLink">26.4-4</span></a>), respectively.</p>
1309
1310 <p><a id="X82EEE1D37A94F807" name="X82EEE1D37A94F807"></a></p>
1311
1312 <h4>26.15 <span class="Heading">Available Representations of Vector Objects</span></h4>
1313
1314 <p>The following filters define vector objects for which the the functionality described in this chapter is supported.</p>
1315
1316 <p><a id="X7C8050938691A914" name="X7C8050938691A914"></a></p>
1317
1318 <h5>26.15-1 IsGF2VectorRep</h5>
1319
1320 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsGF2VectorRep</code>( <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;representation&nbsp;)</td></tr></table></div>
1321 <p>An object <var class="Arg">obj</var> in <code class="func">IsGF2VectorRep</code> describes a vector object (see <code class="func">IsVectorObj</code> (<a href="chap26.html#X7D963FCC7E849BE0"><span class="RefLink">26.2-1</span></a>)) with entries in the finite field with <span class="SimpleMath">2</span> elements.</p>
1322
1323 <p><code class="func">IsGF2VectorRep</code> implies <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>), thus vector objects in this representation can be mutable.</p>
1324
1325 <p><a id="X82A643007EC6D1CA" name="X82A643007EC6D1CA"></a></p>
1326
1327 <h5>26.15-2 Is8BitVectorRep</h5>
1328
1329 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Is8BitVectorRep</code>( <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;representation&nbsp;)</td></tr></table></div>
1330 <p>An object <var class="Arg">obj</var> in <code class="func">Is8BitVectorRep</code> describes a vector object (see <code class="func">IsVectorObj</code> (<a href="chap26.html#X7D963FCC7E849BE0"><span class="RefLink">26.2-1</span></a>)) with entries in a finite field with <span class="SimpleMath">q</span> elements, for <span class="SimpleMath">3 ≤ q ≤ 256</span>. The base domain of <var class="Arg">obj</var> is not necessarily the smallest field that contains all matrix entries.</p>
1331
1332 <p><code class="func">Is8BitVectorRep</code> implies <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>), thus vector objects in this representation can be mutable.</p>
1333
1334 <p><a id="X83262B7085FA94E3" name="X83262B7085FA94E3"></a></p>
1335
1336 <h5>26.15-3 IsPlistVectorRep</h5>
1337
1338 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsPlistVectorRep</code>( <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;representation&nbsp;)</td></tr></table></div>
1339 <p>An object <var class="Arg">obj</var> in <code class="func">IsPlistVectorRep</code> describes a vector object (see <code class="func">IsVectorObj</code> (<a href="chap26.html#X7D963FCC7E849BE0"><span class="RefLink">26.2-1</span></a>)) that can occur as a row in a row list matrix (see Section <a href="chap26.html#X7D40EE2084A6C976"><span class="RefLink">26.12</span></a>).</p>
1340
1341 <p><code class="func">IsPlistVectorRep</code> implies <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>), thus vector objects in this representation can be mutable.</p>
1342
1343 <p><a id="X8730DB7D7E7DA883" name="X8730DB7D7E7DA883"></a></p>
1344
1345 <h5>26.15-4 IsZmodnZVectorRep</h5>
1346
1347 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsZmodnZVectorRep</code>( <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;representation&nbsp;)</td></tr></table></div>
1348 <p>An object <var class="Arg">obj</var> in <code class="func">IsZmodnZVectorRep</code> describes a vector object (see <code class="func">IsVectorObj</code> (<a href="chap26.html#X7D963FCC7E849BE0"><span class="RefLink">26.2-1</span></a>)) with entries in a residue class ring of the ring of integers (see <code class="func">ZmodnZ</code> (<a href="chap14.html#X79CE76AD82B3E2B2"><span class="RefLink">14.5-2</span></a>)). This ring is the base domain (see <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>)) of <var class="Arg">obj</var>.</p>
1349
1350 <p><code class="func">IsZmodnZVectorRep</code> implies <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>), thus matrix objects in this representation can be mutable.</p>
1351
1352 <p><a id="X7CFD844C7D80D541" name="X7CFD844C7D80D541"></a></p>
1353
1354 <h4>26.16 <span class="Heading">Available Representations of Matrix Objects</span></h4>
1355
1356 <p>The following filters define matrix objects for which the the functionality described in this chapter is supported.</p>
1357
1358 <p><a id="X7F6078FF81E912E7" name="X7F6078FF81E912E7"></a></p>
1359
1360 <h5>26.16-1 IsGF2MatrixRep</h5>
1361
1362 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsGF2MatrixRep</code>( <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;representation&nbsp;)</td></tr></table></div>
1363 <p>An object <var class="Arg">obj</var> in <code class="func">IsGF2MatrixRep</code> describes a matrix object (see <code class="func">IsMatrixObj</code> (<a href="chap26.html#X7E7617A0781D1E4B"><span class="RefLink">26.2-2</span></a>)) with entries in the finite field with <span class="SimpleMath">2</span> elements, which behaves like the list of its rows (see <code class="func">IsRowListMatrix</code> (<a href="chap26.html#X78CD88A283330E72"><span class="RefLink">26.2-4</span></a>)). The base domain of <var class="Arg">obj</var> is the field with <span class="SimpleMath">2</span> elements.</p>
1364
1365 <p><code class="func">IsGF2MatrixRep</code> implies <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>), thus vector objects in this representation can be mutable.</p>
1366
1367 <p><a id="X81466B6C7CAC3A7B" name="X81466B6C7CAC3A7B"></a></p>
1368
1369 <h5>26.16-2 Is8BitMatrixRep</h5>
1370
1371 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Is8BitMatrixRep</code>( <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;representation&nbsp;)</td></tr></table></div>
1372 <p>An object <var class="Arg">obj</var> in <code class="func">Is8BitMatrixRep</code> describes a matrix object (see <code class="func">IsMatrixObj</code> (<a href="chap26.html#X7E7617A0781D1E4B"><span class="RefLink">26.2-2</span></a>)) that behaves like the list of its rows (see <code class="func">IsRowListMatrix</code> (<a href="chap26.html#X78CD88A283330E72"><span class="RefLink">26.2-4</span></a>)). The base domain of <var class="Arg">obj</var> is a field that contains all matrix entries (but not necessarily the smallest such field), it must be a finite field with <span class="SimpleMath">q</span> elements, for <span class="SimpleMath">3 ≤ q ≤ 256</span>.</p>
1373
1374 <p><code class="func">Is8BitMatrixRep</code> implies <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>), thus matrix objects in this representation can be mutable.</p>
1375
1376 <p><a id="X80C6031C7DB31A15" name="X80C6031C7DB31A15"></a></p>
1377
1378 <h5>26.16-3 IsPlistMatrixRep</h5>
1379
1380 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsPlistMatrixRep</code>( <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;representation&nbsp;)</td></tr></table></div>
1381 <p>An object <var class="Arg">obj</var> in <code class="func">IsPlistMatrixRep</code> describes a matrix object (see <code class="func">IsMatrixObj</code> (<a href="chap26.html#X7E7617A0781D1E4B"><span class="RefLink">26.2-2</span></a>)) that behaves similar to a list of its rows, in the sense of <code class="func">IsRowListMatrix</code> (<a href="chap26.html#X78CD88A283330E72"><span class="RefLink">26.2-4</span></a>).</p>
1382
1383 <p>In particular, the rows can be accessed via <span class="SimpleMath">M[i]</span>, and they are vector objects in <code class="func">IsPlistVectorRep</code> (<a href="chap26.html#X83262B7085FA94E3"><span class="RefLink">26.15-3</span></a>). This representation is useful if one wants to work explicitly with such row objects.</p>
1384
1385 <p>For most purposes, <code class="func">IsGenericMatrixRep</code> (<a href="chap26.html#X8206177679151859"><span class="RefLink">26.16-4</span></a>) is the better choice. Unlike <code class="func">IsPlistMatrixRep</code>, it does not support direct row access, but it is intended as the general-purpose representation for matrix objects.</p>
1386
1387 <p><code class="func">IsPlistMatrixRep</code> implies <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>), thus matrix objects in this representation can be mutable.</p>
1388
1389 <p><a id="X8206177679151859" name="X8206177679151859"></a></p>
1390
1391 <h5>26.16-4 IsGenericMatrixRep</h5>
1392
1393 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsGenericMatrixRep</code>( <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;representation&nbsp;)</td></tr></table></div>
1394 <p>An object <var class="Arg">obj</var> in <code class="func">IsGenericMatrixRep</code> describes a matrix object (see <code class="func">IsMatrixObj</code> (<a href="chap26.html#X7E7617A0781D1E4B"><span class="RefLink">26.2-2</span></a>)) whose entries are stored as a dense plain list of dense plain row lists.</p>
1395
1396 <p>Unlike <code class="func">IsPlistMatrixRep</code> (<a href="chap26.html#X80C6031C7DB31A15"><span class="RefLink">26.16-3</span></a>), this representation is not a row list matrix, so direct row access via <span class="SimpleMath">M[i]</span> is not supported. Instead, it is intended as the general-purpose representation for matrix objects.</p>
1397
1398 <p>This representation supports the usual matrix operations and is often more efficient than <code class="func">IsPlistMatrixRep</code> (<a href="chap26.html#X80C6031C7DB31A15"><span class="RefLink">26.16-3</span></a>). If existing code uses row access, it is often possible to replace this by the operations from Section <a href="chap26.html#X7B86A8487B12F9BD"><span class="RefLink">26.13</span></a>.</p>
1399
1400 <p>Use <code class="func">IsPlistMatrixRep</code> (<a href="chap26.html#X80C6031C7DB31A15"><span class="RefLink">26.16-3</span></a>) instead if you need the rows to be available as vector objects in <code class="func">IsPlistVectorRep</code> (<a href="chap26.html#X83262B7085FA94E3"><span class="RefLink">26.15-3</span></a>).</p>
1401
1402 <p><a id="X84D0F3117DA86850" name="X84D0F3117DA86850"></a></p>
1403
1404 <h5>26.16-5 IsZmodnZMatrixRep</h5>
1405
1406 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsZmodnZMatrixRep</code>( <var class="Arg">obj</var> )</td><td class="tdright">(&nbsp;representation&nbsp;)</td></tr></table></div>
1407 <p>An object <var class="Arg">obj</var> in <code class="func">IsZmodnZMatrixRep</code> describes a matrix object (see <code class="func">IsMatrixObj</code> (<a href="chap26.html#X7E7617A0781D1E4B"><span class="RefLink">26.2-2</span></a>)) that behaves like the list of its rows (see <code class="func">IsRowListMatrix</code> (<a href="chap26.html#X78CD88A283330E72"><span class="RefLink">26.2-4</span></a>)). The matrix entries lie in a residue class ring of the ring of integers (see <code class="func">ZmodnZ</code> (<a href="chap14.html#X79CE76AD82B3E2B2"><span class="RefLink">14.5-2</span></a>)). This ring is the base domain (see <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>)) of <var class="Arg">obj</var>.</p>
1408
1409 <p><code class="func">IsZmodnZMatrixRep</code> implies <code class="func">IsCopyable</code> (<a href="chap12.html#X811EFD727EBD1ADC"><span class="RefLink">12.6-1</span></a>), thus matrix objects in this representation can be mutable.</p>
1410
1411 <p><a id="X82BD536483B78DB9" name="X82BD536483B78DB9"></a></p>
1412
1413 <h4>26.17 <span class="Heading">Groups Consisting of Matrix Objects</span></h4>
1414
1415 <p>One application of matrix objects is to construct groups whose elements are matrix objects. The following conventions hold for such a group <code class="code">G</code>.</p>
1416
1417
1418 <ul>
1419 <li><p>All elements of <code class="code">G</code> have the same <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) and the same <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>). For a given matrix or matrix object <code class="code">M</code>, a matrix object that can be multiplied with elements of <code class="code">G</code> can be constructed as <code class="code">Matrix( M, Representative( G ) )</code>, and the result can be tested for membership in <code class="code">G</code>.</p>
1420
1421 </li>
1422 </ul>
1423 <p><a id="X7F7E8B6F7D008CF2" name="X7F7E8B6F7D008CF2"></a></p>
1424
1425 <h5>26.17-1 ConstructingFiltersForMatrixGroupElements</h5>
1426
1427 <div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConstructingFiltersForMatrixGroupElements</code></td><td class="tdright">(&nbsp;global variable&nbsp;)</td></tr></table></div>
1428 <p>This is a list of filters <code class="code">f</code> that are supported as the first argument of group constructors such as <code class="func">SymplecticGroup</code> (<a href="chap50.html#X8142A8B07811CA90"><span class="RefLink">50.2-5</span></a>), meaning that one asks for a matrix group whose elements are in <code class="code">f</code>.</p>
1429
1430 <p>If one creates a new representation of matrix objects such that it makes sense to create matrix groups from them then the underlying filter should be added to <code class="func">ConstructingFiltersForMatrixGroupElements</code>.</p>
1431
1432 <p><a id="X786024B686AFAD91" name="X786024B686AFAD91"></a></p>
1433
1434 <h4>26.18 <span class="Heading">How to Write Code for Vector and Matrix Objects</span></h4>
1435
1436 <p>Vector and matrix objects have a number of different representations in <strong class="pkg">GAP</strong> which are optimised for different things; see the list <code class="func">ConstructingFiltersForMatrixGroupElements</code> (<a href="chap26.html#X7F7E8B6F7D008CF2"><span class="RefLink">26.17-1</span></a>) for examples of available <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) values of matrix objects. Most <strong class="pkg">GAP</strong> functions accepting vector or matrix objects as arguments do not depend on any particular representation for these objects. If the output of such a function involves vector and matrix objects, then these are expected to have the same representations as the inputs. For example, a function that computes the Kronecker product of two matrix objects <code class="code">mat1</code>, <code class="code">mat2</code> may take the two inputs, which must have the same <code class="func">ConstructingFilter</code> (<a href="chap26.html#X85ABF33684865ED5"><span class="RefLink">26.3-2</span></a>) value, create a new matrix object which also lies in this filter, for example by calling <code class="code">ZeroMatrix( m, n, mat1 )</code>, and then set the entries in this matrix.</p>
1437
1438 <p>Functions like <code class="func">ZeroMatrix</code> (<a href="chap26.html#X838F5B6C7C87C8E1"><span class="RefLink">26.4-6</span></a>), <code class="func">IdentityMatrix</code> (<a href="chap26.html#X7D807ABC7FCB4E77"><span class="RefLink">26.4-7</span></a>), and <code class="func">Matrix</code> (<a href="chap26.html#X879384D479EB1D82"><span class="RefLink">26.4-5</span></a>) admit different kinds of inputs. <code class="code">ZeroMatrix( R, m, n )</code> can be used, for example, if we want to leave the decision about the representation of the result to <strong class="pkg">GAP</strong>. This might be useful if the result of <code class="code">ZeroMatrix( R, m, n )</code> is the first matrix we create, and then later matrices are created relative to this matrix. If we already have a matrix object <code class="code">M</code> and want <code class="code">ZeroMatrix</code> to return a new matrix object that has the same representation as <code class="code">M</code>, then <code class="code">ZeroMatrix( R, m, n )</code> may not return a matrix with the expected representation. For example, even if we use the same <code class="code">R</code> as before, <strong class="pkg">GAP</strong> might decide to use a sparse representation for large enough <code class="code">m</code> and <code class="code">n</code>. It is possible to create a <code class="code">ZeroMatrix</code> in the same representation as <code class="code">M</code> by fully specifying this representation as follows <code class="code">ZeroMatrix( ConstructingFilter( M ), BaseDomain( M ), m, n )</code>. It is also possible to produce the same result using the more convenient <code class="code">ZeroMatrix( m, n, M )</code>.</p>
1439
1440 <p>This approach works also in many situation where the input involves the <q>list of list</q> matrices in the filter <code class="func">IsMatrix</code> (<a href="chap24.html#X7E1AE46B862B185F"><span class="RefLink">24.2-1</span></a>). In practice, the question is often the other way round: one has old <strong class="pkg">GAP</strong> code that was written for objects in <code class="func">IsMatrix</code> (<a href="chap24.html#X7E1AE46B862B185F"><span class="RefLink">24.2-1</span></a>), and wants to rewrite it such that it works for general matrix objects also. In such cases, the following guidelines may be useful.</p>
1441
1442
1443 <ul>
1444 <li><p>Use <code class="code">M[i, j]</code> not <code class="code">M[i][j]</code> for accessing/assigning matrix entries.</p>
1445
1446 <p><em>Reason:</em> <code class="code">M[i][j]</code> means to fetch or even create <code class="code">M[i]</code> and then take the <code class="code">j</code>-th entry of it.</p>
1447
1448 </li>
1449 <li><p>Use <code class="code">ExtractSubMatrix( M, rows, cols )</code> not <code class="code">M{ rows }{ cols }</code> for accessing submatrices, similarly use <code class="code">CopySubMatrix( src, dst, srows, drows, scols, dcols )</code>.</p>
1450
1451 <p><em>Reason:</em> The <code class="code">M{ rows }</code> syntax is supported only for row-list matrices, see <code class="func">IsRowListMatrix</code> (<a href="chap26.html#X78CD88A283330E72"><span class="RefLink">26.2-4</span></a>).</p>
1452
1453 </li>
1454 <li><p>Use <code class="code">ZeroVector( R, n )</code> not <code class="code">[ 1 .. n ] * Zero( R )</code> for creating a zero vector over a given domain <code class="code">R</code>.</p>
1455
1456 <p><em>Reason:</em> The latter syntax creates an unnecessary new object <code class="code">[ 1 .. n ]</code>, multiplies each of its entries with <code class="code">Zero( R )</code> (not knowing that the result will be <code class="code">Zero( R )</code> in each case), and creates not a vector object but a plain list of the results.</p>
1457
1458 </li>
1459 <li><p>Use <code class="code">ZeroVector( n, M )</code> not <code class="code">0 * M[1]</code> for a given matrix object <code class="code">M</code> with <code class="code">n</code> columns.</p>
1460
1461 <p><em>Reason:</em> Calling <code class="code">M[1]</code> may have to create an unnecessary new object <code class="code">M[1]</code>.</p>
1462
1463 </li>
1464 <li><p>Use <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) not <code class="func">DefaultFieldOfMatrix</code> (<a href="chap24.html#X80AE547B8095A5CB"><span class="RefLink">24.4-2</span></a>).</p>
1465
1466 <p><em>Reason:</em> This is just a conceptual issue, the results should in fact coincide. A matrix object <code class="code">M</code> which is not a list of lists stores its <code class="func">BaseDomain</code> (<a href="chap26.html#X8662026C7CCDB446"><span class="RefLink">26.3-1</span></a>) value. For convenience, <code class="code">DefaultFieldOfMatrix( M )</code> is defined to return this value (although this need not be a field). On the other hand, a list of lists <code class="code">M</code> in <code class="func">IsMatrix</code> (<a href="chap24.html#X7E1AE46B862B185F"><span class="RefLink">24.2-1</span></a>) does not store the two attribute values, <code class="func">DefaultFieldOfMatrix</code> (<a href="chap24.html#X80AE547B8095A5CB"><span class="RefLink">24.4-2</span></a>) value is computed from the entries of <code class="code">M</code>, and for convenience, <code class="code">BaseDomain( M )</code> is defined to return the <code class="func">DefaultFieldOfMatrix</code> (<a href="chap24.html#X80AE547B8095A5CB"><span class="RefLink">24.4-2</span></a>) value.</p>
1467
1468 </li>
1469 <li><p>Do not use the unary versions of <code class="func">ConvertToVectorRep</code> (<a href="chap23.html#X810E46927F9E8F75"><span class="RefLink">23.3-1</span></a>) and <code class="func">ConvertToMatrixRep</code> (<a href="chap24.html#X8587A62F818AA0D6"><span class="RefLink">24.14-2</span></a>).</p>
1470
1471 <p><em>Reason:</em> For example, consider the two matrices <code class="code">M1 = [ [ Z(4) ] ]</code> and <code class="code">M2 = [ [ Z(4)^3 ] ]</code> over the field with four elements. The latter is in fact a matrix over the field with two elements, and <code class="code">ConvertToMatrixRep( M2 )</code> turns it into a matrix in <code class="func">IsGF2MatrixRep</code> (<a href="chap26.html#X7F6078FF81E912E7"><span class="RefLink">26.16-1</span></a>), whereas <code class="code">ConvertToMatrixRep( M1 )</code> yields a matrix in <code class="func">Is8BitMatrixRep</code> (<a href="chap26.html#X81466B6C7CAC3A7B"><span class="RefLink">26.16-2</span></a>). Thus computing products or sums of these matrices is more expensive than computations with two matrices in <code class="func">Is8BitMatrixRep</code> (<a href="chap26.html#X81466B6C7CAC3A7B"><span class="RefLink">26.16-2</span></a>).</p>
1472
1473 </li>
1474 <li><p>Use <code class="func">ImmutableMatrix</code> (<a href="chap24.html#X7DED2522828B6C30"><span class="RefLink">24.14-1</span></a>) and the binary versions of <code class="func">ConvertToVectorRep</code> (<a href="chap23.html#X810E46927F9E8F75"><span class="RefLink">23.3-1</span></a>) and <code class="func">ConvertToMatrixRep</code> (<a href="chap24.html#X8587A62F818AA0D6"><span class="RefLink">24.14-2</span></a>) only when creating initial objects which need not be compatible with given vectors or matrices.</p>
1475
1476 <p><em>Reason:</em> The idea behind these functions is to choose a good representation for initial data (for example for some expensive MeatAxe computations, see Chapter <a href="chap69.html#X7BF9D3CB81A8F8F9"><span class="RefLink">69</span></a>). The results of computations with these data should then automatically be in the same representation. If not then the code in question has problems, and <q>adjusting</q> the representation of intermediate results by calling the abovementioned conversion functions just hides these problems.</p>
1477
1478 </li>
1479 </ul>
1480 <p>Conversely, do <em>not</em> use functions for vector and matrix objects when you want to create an object that shall be used just as a list. For example, use <code class="code">ListWithIdenticalEntries( n, Zero( R ) )</code> not <code class="code">Vector( R, n )</code> in this case. For creating a list with <code class="code">n</code> entries, you can also first call <code class="func">EmptyPlist</code> (<a href="chap21.html#X78BF67A5802E93AD"><span class="RefLink">21.9-1</span></a>) for creating a big enough list, and then enter the values.</p>
1481
1482
1483 <div class="chlinkprevnextbot">&nbsp;<a href="chap0.html">[Top of Book]</a>&nbsp; <a href="chap0.html#contents">[Contents]</a>&nbsp; &nbsp;<a href="chap25.html">[Previous Chapter]</a>&nbsp; &nbsp;<a href="chap27.html">[Next Chapter]</a>&nbsp; </div>
1484
1485
1486 <div class="chlinkbot"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a> <a href="chap1.html">1</a> <a href="chap2.html">2</a> <a href="chap3.html">3</a> <a href="chap4.html">4</a> <a href="chap5.html">5</a> <a href="chap6.html">6</a> <a href="chap7.html">7</a> <a href="chap8.html">8</a> <a href="chap9.html">9</a> <a href="chap10.html">10</a> <a href="chap11.html">11</a> <a href="chap12.html">12</a> <a href="chap13.html">13</a> <a href="chap14.html">14</a> <a href="chap15.html">15</a> <a href="chap16.html">16</a> <a href="chap17.html">17</a> <a href="chap18.html">18</a> <a href="chap19.html">19</a> <a href="chap20.html">20</a> <a href="chap21.html">21</a> <a href="chap22.html">22</a> <a href="chap23.html">23</a> <a href="chap24.html">24</a> <a href="chap25.html">25</a> <a href="chap26.html">26</a> <a href="chap27.html">27</a> <a href="chap28.html">28</a> <a href="chap29.html">29</a> <a href="chap30.html">30</a> <a href="chap31.html">31</a> <a href="chap32.html">32</a> <a href="chap33.html">33</a> <a href="chap34.html">34</a> <a href="chap35.html">35</a> <a href="chap36.html">36</a> <a href="chap37.html">37</a> <a href="chap38.html">38</a> <a href="chap39.html">39</a> <a href="chap40.html">40</a> <a href="chap41.html">41</a> <a href="chap42.html">42</a> <a href="chap43.html">43</a> <a href="chap44.html">44</a> <a href="chap45.html">45</a> <a href="chap46.html">46</a> <a href="chap47.html">47</a> <a href="chap48.html">48</a> <a href="chap49.html">49</a> <a href="chap50.html">50</a> <a href="chap51.html">51</a> <a href="chap52.html">52</a> <a href="chap53.html">53</a> <a href="chap54.html">54</a> <a href="chap55.html">55</a> <a href="chap56.html">56</a> <a href="chap57.html">57</a> <a href="chap58.html">58</a> <a href="chap59.html">59</a> <a href="chap60.html">60</a> <a href="chap61.html">61</a> <a href="chap62.html">62</a> <a href="chap63.html">63</a> <a href="chap64.html">64</a> <a href="chap65.html">65</a> <a href="chap66.html">66</a> <a href="chap67.html">67</a> <a href="chap68.html">68</a> <a href="chap69.html">69</a> <a href="chap70.html">70</a> <a href="chap71.html">71</a> <a href="chap72.html">72</a> <a href="chap73.html">73</a> <a href="chap74.html">74</a> <a href="chap75.html">75</a> <a href="chap76.html">76</a> <a href="chap77.html">77</a> <a href="chap78.html">78</a> <a href="chap79.html">79</a> <a href="chap80.html">80</a> <a href="chap81.html">81</a> <a href="chap82.html">82</a> <a href="chap83.html">83</a> <a href="chap84.html">84</a> <a href="chap85.html">85</a> <a href="chap86.html">86</a> <a href="chap87.html">87</a> <a href="chapBib.html">Bib</a> <a href="chapInd.html">Ind</a> </div>
1487
1488 <hr />
1489 <p class="foot">generated by <a href="https://www.math.rwth-aachen.de/~Frank.Luebeck/GAPDoc">GAPDoc2HTML</a></p>
1490 </body>
1491 </html>