Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 7ebd25ac536d248d499a3ce2acda963a > files > 4152

Macaulay2-1.3.1-8.fc15.i686.rpm

<?xml version="1.0" encoding="utf-8" ?>  <!-- for emacs: -*- coding: utf-8 -*- -->
<!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"	 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><title>concatenating matrices</title>
<link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/>
</head>
<body>
<table class="buttons">
  <tr>
    <td><div><a href="_differentiation.html">next</a> | <a href="_basic_sparithmetic_spof_spmatrices.html">previous</a> | <a href="_differentiation.html">forward</a> | <a href="_basic_sparithmetic_spof_spmatrices.html">backward</a> | <a href="_matrices.html">up</a> | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div>

    </td>
  </tr>
</table>
<div><a href="index.html" title="">Macaulay2Doc</a> > <a href="_matrices.html" title="">matrices</a> > <a href="_concatenating_spmatrices.html" title="">concatenating matrices</a></div>
<hr/>
<div><h1>concatenating matrices</h1>
<div>Before Macaulay2 can concatenate matrices, the matrices in question <em>must</em> have entries in the same ring.<h2>concatenate horizontally</h2>
Use <a href="__vb.html" title="a binary operator, often used for horizontal concatenation">|</a> to concatenate two matrices horizontally.<table class="examples"><tr><td><pre>i1 : R = ZZ/32003[a..f];</pre>
</td></tr>
<tr><td><pre>i2 : M = genericMatrix(R,a,3,2)

o2 = | a d |
     | b e |
     | c f |

             3       2
o2 : Matrix R  &lt;--- R</pre>
</td></tr>
<tr><td><pre>i3 : N = matrix{{d^2,a*d},{b*c,b*d},{a,c}}

o3 = | d2 ad |
     | bc bd |
     | a  c  |

             3       2
o3 : Matrix R  &lt;--- R</pre>
</td></tr>
<tr><td><pre>i4 : M|N

o4 = | a d d2 ad |
     | b e bc bd |
     | c f a  c  |

             3       4
o4 : Matrix R  &lt;--- R</pre>
</td></tr>
</table>
<h2>concatenate vertically</h2>
Use <a href="__vb_vb.html" title="a binary operator, often used for vertical concatenation">||</a> to concatenate two matrices vertically.<table class="examples"><tr><td><pre>i5 : P = matrix{{d^2,a*d,e*f},{b*c,b*d,b*e},{a,c,d}}

o5 = | d2 ad ef |
     | bc bd be |
     | a  c  d  |

             3       3
o5 : Matrix R  &lt;--- R</pre>
</td></tr>
<tr><td><pre>i6 : transpose(M)||P

o6 = {-1} | a  b  c  |
     {-1} | d  e  f  |
     {0}  | d2 ad ef |
     {0}  | bc bd be |
     {0}  | a  c  d  |

             5       3
o6 : Matrix R  &lt;--- R</pre>
</td></tr>
</table>
<h2>making block matrices</h2>
The matrix function can take matrices as input as long as the sizes match up.<table class="examples"><tr><td><pre>i7 : matrix{{id_(R^3),M,P},{random(R^1,R^3),random(R^1,R^3),random(R^1,R^2)}}

o7 = | 1      0     0     a     d    d2    ad     ef    |
     | 0      1     0     b     e    bc    bd     be    |
     | 0      0     1     c     f    a     c      d     |
     | -14215 14276 -9343 -2513 9387 -6475 -11220 14456 |

             4       8
o7 : Matrix R  &lt;--- R</pre>
</td></tr>
</table>
Also, the number input entries in each row must be equal.  It might seem like we could form the same matrix with the input <tt>matrix{{id_(R^3),M,P},{random(R^1,R^8)}}</tt> since <tt>random(R^1,R^8)</tt> will construct a 1 by 8 matrix that has the same number of columns as matrix <tt>matrix{{id_(R^3),M,P}}</tt> but as input into the matrix function that row entry must have 3 entries.<h2>direct sum of matrices as maps between modules</h2>
++</div>
</div>
</body>
</html>