| 1 |
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Manipulação de matrizes</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><link rel="home" href="index.html" title="Manual do Genius"><link rel="up" href="ch11.html" title="Chapter 11. List of GEL functions"><link rel="prev" href="ch11s07.html" title="Teoria dos números"><link rel="next" href="ch11s09.html" title="Álgebra linear"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Manipulação de matrizes</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch11s07.html">Prev</a> </td><th width="60%" align="center">Chapter 11. List of GEL functions</th><td width="20%" align="right"> <a accesskey="n" href="ch11s09.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="genius-gel-function-list-matrix"></a>Manipulação de matrizes</h2></div></div></div><div class="variablelist"><dl class="variablelist"><dt><span lang="en" class="term"><a name="gel-function-AppendElement"></a>AppendElement</span></dt><dd><pre lang="en" class="synopsis">AppendElement (v,elt)</pre><p lang="en">Append an element to a vector and return the vector. No expansion is done. Normally |
| 2 |
a row vector is built if starting from <code class="constant">null</code> or a 1-by-1 matrix, |
| 3 |
but if given a column vector it will properly build a column vector.</p></dd><dt><span lang="en" class="term"><a name="gel-function-ApplyOverMatrix"></a>ApplyOverMatrix</span></dt><dd><pre lang="en" class="synopsis">ApplyOverMatrix (a,func)</pre><p lang="en">Apply a function over all entries of a matrix and return a matrix of the results.</p></dd><dt><span lang="en" class="term"><a name="gel-function-ApplyOverMatrix2"></a>ApplyOverMatrix2</span></dt><dd><pre lang="en" class="synopsis">ApplyOverMatrix2 (a,b,func)</pre><p lang="en">Apply a function over all entries of 2 matrices (or 1 value and 1 matrix) and return a matrix of the results.</p></dd><dt><span lang="en" class="term"><a name="gel-function-ColumnsOf"></a>ColumnsOf</span></dt><dd><pre lang="en" class="synopsis">ColumnsOf (M)</pre><p lang="en">Gets the columns of a matrix as a horizontal vector.</p></dd><dt><span lang="en" class="term"><a name="gel-function-ComplementSubmatrix"></a>ComplementSubmatrix</span></dt><dd><pre lang="en" class="synopsis">ComplementSubmatrix (m,r,c)</pre><p lang="en">Remove column(s) and row(s) from a matrix.</p></dd><dt><span lang="en" class="term"><a name="gel-function-CompoundMatrix"></a>CompoundMatrix</span></dt><dd><pre lang="en" class="synopsis">CompoundMatrix (k,A)</pre><p lang="en">Calculate the kth compound matrix of A.</p></dd><dt><span lang="en" class="term"><a name="gel-function-CountZeroColumns"></a>CountZeroColumns</span></dt><dd><pre lang="en" class="synopsis">CountZeroColumns (M)</pre><p lang="en"> |
| 4 |
Count the number of zero columns in a matrix. For example, |
| 5 |
once you column-reduce a matrix, you can use this to find |
| 6 |
the nullity. See <a class="link" href="ch11s09.html#gel-function-cref"><code class="function">cref</code></a> |
| 7 |
and <a class="link" href="ch11s09.html#gel-function-Nullity"><code class="function">Nullity</code></a>. |
| 8 |
</p></dd><dt><span lang="en" class="term"><a name="gel-function-DeleteColumn"></a>DeleteColumn</span></dt><dd><pre lang="en" class="synopsis">DeleteColumn (M,col)</pre><p lang="en">Delete a column of a matrix.</p></dd><dt><span lang="en" class="term"><a name="gel-function-DeleteRow"></a>DeleteRow</span></dt><dd><pre lang="en" class="synopsis">DeleteRow (M,row)</pre><p lang="en">Delete a row of a matrix.</p></dd><dt><span lang="en" class="term"><a name="gel-function-DiagonalOf"></a>DiagonalOf</span></dt><dd><pre lang="en" class="synopsis">DiagonalOf (M)</pre><p lang="en">Gets the diagonal entries of a matrix as a column vector.</p><p lang="en"> |
| 9 |
See |
| 10 |
<a class="ulink" href="https://en.wikipedia.org/wiki/Diagonal_of_a_matrix#Matrices" target="_top">Wikipedia</a> for more information. |
| 11 |
</p></dd><dt><span lang="en" class="term"><a name="gel-function-DotProduct"></a>DotProduct</span></dt><dd><pre lang="en" class="synopsis">DotProduct (u,v)</pre><p lang="en">Get the dot product of two vectors. The vectors must be of the |
| 12 |
same size. No conjugates are taken so this is a bilinear form even if working over the complex numbers; This is the bilinear scalar product not the sesquilinear scalar product. See <a class="link" href="ch11s08.html#gel-function-HermitianProduct">HermitianProduct</a> for the standard sesquilinear inner product.</p><p lang="en"> |
| 13 |
See |
| 14 |
<a class="ulink" href="https://en.wikipedia.org/wiki/Dot_product" target="_top">Wikipedia</a> or |
| 15 |
<a class="ulink" href="http://planetmath.org/DotProduct" target="_top">Planetmath</a> for more information. |
| 16 |
</p></dd><dt><span lang="en" class="term"><a name="gel-function-ExpandMatrix"></a>ExpandMatrix</span></dt><dd><pre lang="en" class="synopsis">ExpandMatrix (M)</pre><p lang="en"> |
| 17 |
Expands a matrix just like we do on unquoted matrix input. |
| 18 |
That is we expand any internal matrices as blocks. This is |
| 19 |
a way to construct matrices out of smaller ones and this is |
| 20 |
normally done automatically on input unless the matrix is quoted. |
| 21 |
</p></dd><dt><span lang="en" class="term"><a name="gel-function-HermitianProduct"></a>HermitianProduct</span></dt><dd><pre lang="en" class="synopsis">HermitianProduct (u,v)</pre><p lang="en">Aliases: <code class="function">InnerProduct</code></p><p lang="en">Get the Hermitian product of two vectors. The vectors must be of the same size. This is a sesquilinear form using the identity matrix.</p><p lang="en"> |
| 22 |
See |
| 23 |
<a class="ulink" href="https://en.wikipedia.org/wiki/Sesquilinear_form" target="_top">Wikipedia</a> or |
| 24 |
<a class="ulink" href="http://mathworld.wolfram.com/HermitianInnerProduct.html" target="_top">Mathworld</a> for more information. |
| 25 |
</p></dd><dt><span lang="en" class="term"><a name="gel-function-I"></a>I</span></dt><dd><pre lang="en" class="synopsis">I (n)</pre><p lang="en">Aliases: <code class="function">eye</code></p><p lang="en">Return an identity matrix of a given size, that is <code class="varname">n</code> by <code class="varname">n</code>. If <code class="varname">n</code> is zero, returns <code class="constant">null</code>.</p><p lang="en"> |
| 26 |
See |
| 27 |
<a class="ulink" href="https://en.wikipedia.org/wiki/Identity_matrix" target="_top">Wikipedia</a> or |
| 28 |
<a class="ulink" href="http://planetmath.org/IdentityMatrix" target="_top">Planetmath</a> for more information. |
| 29 |
</p></dd><dt><span lang="en" class="term"><a name="gel-function-IndexComplement"></a>IndexComplement</span></dt><dd><pre lang="en" class="synopsis">IndexComplement (vec,msize)</pre><p lang="en">Return the index complement of a vector of indexes. Everything is one based. For example for vector <strong class="userinput"><code>[2,3]</code></strong> and size |
| 30 |
<strong class="userinput"><code>5</code></strong>, we return <strong class="userinput"><code>[1,4,5]</code></strong>. If |
| 31 |
<code class="varname">msize</code> is 0, we always return <code class="constant">null</code>.</p></dd><dt><span lang="en" class="term"><a name="gel-function-IsDiagonal"></a>IsDiagonal</span></dt><dd><pre lang="en" class="synopsis">IsDiagonal (M)</pre><p>É uma matriz diagonal.</p><p lang="en"> |
| 32 |
See |
| 33 |
<a class="ulink" href="https://en.wikipedia.org/wiki/Diagonal_matrix" target="_top">Wikipedia</a> or |
| 34 |
<a class="ulink" href="http://planetmath.org/DiagonalMatrix" target="_top">Planetmath</a> for more information. |
| 35 |
</p></dd><dt><span lang="en" class="term"><a name="gel-function-IsIdentity"></a>IsIdentity</span></dt><dd><pre lang="en" class="synopsis">IsIdentity (x)</pre><p lang="en">Check if a matrix is the identity matrix. Automatically returns <code class="constant">false</code> |
| 36 |
if the matrix is not square. Also works on numbers, in which |
| 37 |
case it is equivalent to <strong class="userinput"><code>x==1</code></strong>. When <code class="varname">x</code> is |
| 38 |
<code class="constant">null</code> (we could think of that as a 0 by 0 matrix), |
| 39 |
no error is generated and <code class="constant">false</code> is returned.</p></dd><dt><span lang="en" class="term"><a name="gel-function-IsLowerTriangular"></a>IsLowerTriangular</span></dt><dd><pre lang="en" class="synopsis">IsLowerTriangular (M)</pre><p lang="en">Is a matrix lower triangular. That is, are all the entries above the diagonal zero.</p></dd><dt><span lang="en" class="term"><a name="gel-function-IsMatrixInteger"></a>IsMatrixInteger</span></dt><dd><pre lang="en" class="synopsis">IsMatrixInteger (M)</pre><p lang="en">Check if a matrix is a matrix of integers (non-complex).</p></dd><dt><span lang="en" class="term"><a name="gel-function-IsMatrixNonnegative"></a>IsMatrixNonnegative</span></dt><dd><pre lang="en" class="synopsis">IsMatrixNonnegative (M)</pre><p lang="en">Check if a matrix is non-negative, that is if each element is non-negative. |
| 40 |
Do not confuse positive matrices with positive semi-definite matrices.</p><p lang="en"> |
| 41 |
See |
| 42 |
<a class="ulink" href="https://en.wikipedia.org/wiki/Positive_matrix" target="_top">Wikipedia</a> for more information. |
| 43 |
</p></dd><dt><span lang="en" class="term"><a name="gel-function-IsMatrixPositive"></a>IsMatrixPositive</span></dt><dd><pre lang="en" class="synopsis">IsMatrixPositive (M)</pre><p lang="en">Check if a matrix is positive, that is if each element is |
| 44 |
positive (and hence real). In particular, no element is 0. Do not confuse |
| 45 |
positive matrices with positive definite matrices.</p><p lang="en"> |
| 46 |
See |
| 47 |
<a class="ulink" href="https://en.wikipedia.org/wiki/Positive_matrix" target="_top">Wikipedia</a> for more information. |
| 48 |
</p></dd><dt><span lang="en" class="term"><a name="gel-function-IsMatrixRational"></a>IsMatrixRational</span></dt><dd><pre lang="en" class="synopsis">IsMatrixRational (M)</pre><p lang="en">Check if a matrix is a matrix of rational (non-complex) |
| 49 |
numbers.</p></dd><dt><span lang="en" class="term"><a name="gel-function-IsMatrixReal"></a>IsMatrixReal</span></dt><dd><pre lang="en" class="synopsis">IsMatrixReal (M)</pre><p lang="en">Check if a matrix is a matrix of real (non-complex) numbers.</p></dd><dt><span lang="en" class="term"><a name="gel-function-IsMatrixSquare"></a>IsMatrixSquare</span></dt><dd><pre lang="en" class="synopsis">IsMatrixSquare (M)</pre><p lang="en"> |
| 50 |
Check if a matrix is square, that is its width is equal to |
| 51 |
its height. |
| 52 |
</p></dd><dt><span lang="en" class="term"><a name="gel-function-IsUpperTriangular"></a>IsUpperTriangular</span></dt><dd><pre lang="en" class="synopsis">IsUpperTriangular (M)</pre><p lang="en">Is a matrix upper triangular? That is, a matrix is upper triangular if all the entries below the diagonal are zero.</p></dd><dt><span lang="en" class="term"><a name="gel-function-IsValueOnly"></a>IsValueOnly</span></dt><dd><pre lang="en" class="synopsis">IsValueOnly (M)</pre><p lang="en">Check if a matrix is a matrix of numbers only. Many internal |
| 53 |
functions make this check. Values can be any number including complex numbers.</p></dd><dt><span lang="en" class="term"><a name="gel-function-IsVector"></a>IsVector</span></dt><dd><pre lang="en" class="synopsis">IsVector (v)</pre><p lang="en"> |
| 54 |
Is argument a horizontal or a vertical vector. Genius does |
| 55 |
not distinguish between a matrix and a vector and a vector |
| 56 |
is just a 1 by <code class="varname">n</code> or <code class="varname">n</code> by 1 matrix. |
| 57 |
</p></dd><dt><span lang="en" class="term"><a name="gel-function-IsZero"></a>IsZero</span></dt><dd><pre lang="en" class="synopsis">IsZero (x)</pre><p lang="en">Check if a matrix is composed of all zeros. Also works on numbers, in which |
| 58 |
case it is equivalent to <strong class="userinput"><code>x==0</code></strong>. When <code class="varname">x</code> is |
| 59 |
<code class="constant">null</code> (we could think of that as a 0 by 0 matrix), |
| 60 |
no error is generated and <code class="constant">true</code> is returned as the condition is |
| 61 |
vacuous. |
| 62 |
</p></dd><dt><span lang="en" class="term"><a name="gel-function-LowerTriangular"></a>LowerTriangular</span></dt><dd><pre lang="en" class="synopsis">LowerTriangular (M)</pre><p lang="en">Returns a copy of the matrix <code class="varname">M</code> with all the entries above the diagonal set to zero.</p></dd><dt><span lang="en" class="term"><a name="gel-function-MakeDiagonal"></a>MakeDiagonal</span></dt><dd><pre lang="en" class="synopsis">MakeDiagonal (v,arg...)</pre><p lang="en">Aliases: <code class="function">diag</code></p><p lang="en">Make diagonal matrix from a vector. Alternatively you can pass |
| 63 |
in the values to put on the diagonal as arguments. So |
| 64 |
<strong class="userinput"><code>MakeDiagonal([1,2,3])</code></strong> is the same as |
| 65 |
<strong class="userinput"><code>MakeDiagonal(1,2,3)</code></strong>.</p><p lang="en"> |
| 66 |
See |
| 67 |
<a class="ulink" href="https://en.wikipedia.org/wiki/Diagonal_matrix" target="_top">Wikipedia</a> or |
| 68 |
<a class="ulink" href="http://planetmath.org/DiagonalMatrix" target="_top">Planetmath</a> for more information. |
| 69 |
</p></dd><dt><span lang="en" class="term"><a name="gel-function-MakeVector"></a>MakeVector</span></dt><dd><pre lang="en" class="synopsis">MakeVector (A)</pre><p lang="en">Alias: <code class="function">MakeColumnVector</code></p><p lang="en">Make column vector out of matrix by putting columns above |
| 70 |
each other. Returns <code class="constant">null</code> when given <code class="constant">null</code>. |
| 71 |
Can be used to ensure a vector is a column vector.</p></dd><dt><span lang="en" class="term"><a name="gel-function-MakeRowVector"></a>MakeRowVector</span></dt><dd><pre lang="en" class="synopsis">MakeRowVector (A)</pre><p lang="en">Make row vector out of matrix by putting rows one after another. |
| 72 |
Returns <code class="constant">null</code> when given <code class="constant">null</code>. |
| 73 |
Can be used to ensure a vector is a row vector.</p></dd><dt><span lang="en" class="term"><a name="gel-function-MatrixProduct"></a>MatrixProduct</span></dt><dd><pre lang="en" class="synopsis">MatrixProduct (A)</pre><p lang="en"> |
| 74 |
Calculate the product of all elements in a matrix or vector. |
| 75 |
That is we multiply all the elements and return a number that |
| 76 |
is the product of all the elements. |
| 77 |
</p></dd><dt><span lang="en" class="term"><a name="gel-function-MatrixSum"></a>MatrixSum</span></dt><dd><pre lang="en" class="synopsis">MatrixSum (A)</pre><p lang="en"> |
| 78 |
Calculate the sum of all elements in a matrix or vector. That is |
| 79 |
we add all the elements and return a number that is the |
| 80 |
sum of all the elements. |
| 81 |
</p></dd><dt><span lang="en" class="term"><a name="gel-function-MatrixSumSquares"></a>MatrixSumSquares</span></dt><dd><pre lang="en" class="synopsis">MatrixSumSquares (A)</pre><p lang="en">Calculate the sum of squares of all elements in a matrix |
| 82 |
or vector.</p></dd><dt><span lang="en" class="term"><a name="gel-function-NonzeroColumns"></a>NonzeroColumns</span></dt><dd><pre lang="en" class="synopsis">NonzeroColumns (M)</pre><p lang="en">Returns a row vector of the indices of nonzero columns in the matrix <code class="varname">M</code>.</p><p lang="en">Version 1.0.18 onwards.</p></dd><dt><span lang="en" class="term"><a name="gel-function-NonzeroElements"></a>NonzeroElements</span></dt><dd><pre lang="en" class="synopsis">NonzeroElements (v)</pre><p lang="en">Returns a row vector of the indices of nonzero elements in the vector <code class="varname">v</code>.</p><p lang="en">Version 1.0.18 onwards.</p></dd><dt><span lang="en" class="term"><a name="gel-function-OuterProduct"></a>OuterProduct</span></dt><dd><pre lang="en" class="synopsis">OuterProduct (u,v)</pre><p lang="en">Get the outer product of two vectors. That is, suppose that |
| 83 |
<code class="varname">u</code> and <code class="varname">v</code> are vertical vectors, then |
| 84 |
the outer product is <strong class="userinput"><code>v * u.'</code></strong>.</p></dd><dt><span lang="en" class="term"><a name="gel-function-ReverseVector"></a>ReverseVector</span></dt><dd><pre lang="en" class="synopsis">ReverseVector (v)</pre><p lang="en">Reverse elements in a vector. Return <code class="constant">null</code> if given <code class="constant">null</code></p></dd><dt><span lang="en" class="term"><a name="gel-function-RowSum"></a>RowSum</span></dt><dd><pre lang="en" class="synopsis">RowSum (m)</pre><p lang="en">Calculate sum of each row in a matrix and return a vertical |
| 85 |
vector with the result.</p></dd><dt><span lang="en" class="term"><a name="gel-function-RowSumSquares"></a>RowSumSquares</span></dt><dd><pre lang="en" class="synopsis">RowSumSquares (m)</pre><p lang="en">Calculate sum of squares of each row in a matrix and return a vertical vector with the results.</p></dd><dt><span lang="en" class="term"><a name="gel-function-RowsOf"></a>RowsOf</span></dt><dd><pre lang="en" class="synopsis">RowsOf (M)</pre><p lang="en">Gets the rows of a matrix as a vertical vector. Each element |
| 86 |
of the vector is a horizontal vector that is the corresponding row of |
| 87 |
<code class="varname">M</code>. This function is useful if you wish to loop over the |
| 88 |
rows of a matrix. For example, as <strong class="userinput"><code>for r in RowsOf(M) do |
| 89 |
something(r)</code></strong>.</p></dd><dt><span lang="en" class="term"><a name="gel-function-SetMatrixSize"></a>SetMatrixSize</span></dt><dd><pre lang="en" class="synopsis">SetMatrixSize (M,rows,columns)</pre><p lang="en">Make new matrix of given size from old one. That is, a new |
| 90 |
matrix will be returned to which the old one is copied. Entries that |
| 91 |
don't fit are clipped and extra space is filled with zeros. |
| 92 |
If <code class="varname">rows</code> or <code class="varname">columns</code> are zero |
| 93 |
then <code class="constant">null</code> is returned. |
| 94 |
</p></dd><dt><span lang="en" class="term"><a name="gel-function-ShuffleVector"></a>ShuffleVector</span></dt><dd><pre lang="en" class="synopsis">ShuffleVector (v)</pre><p lang="en">Shuffle elements in a vector. Return <code class="constant">null</code> if given <code class="constant">null</code>.</p><p lang="en">Version 1.0.13 onwards.</p></dd><dt><span lang="en" class="term"><a name="gel-function-SortVector"></a>SortVector</span></dt><dd><pre lang="en" class="synopsis">SortVector (v)</pre><p lang="en">Sort vector elements in an increasing order.</p></dd><dt><span lang="en" class="term"><a name="gel-function-StripZeroColumns"></a>StripZeroColumns</span></dt><dd><pre lang="en" class="synopsis">StripZeroColumns (M)</pre><p lang="en">Removes any all-zero columns of <code class="varname">M</code>.</p></dd><dt><span lang="en" class="term"><a name="gel-function-StripZeroRows"></a>StripZeroRows</span></dt><dd><pre lang="en" class="synopsis">StripZeroRows (M)</pre><p lang="en">Removes any all-zero rows of <code class="varname">M</code>.</p></dd><dt><span lang="en" class="term"><a name="gel-function-Submatrix"></a>Submatrix</span></dt><dd><pre lang="en" class="synopsis">Submatrix (m,r,c)</pre><p lang="en">Return column(s) and row(s) from a matrix. This is |
| 95 |
just equivalent to <strong class="userinput"><code>m@(r,c)</code></strong>. <code class="varname">r</code> |
| 96 |
and <code class="varname">c</code> should be vectors of rows and columns (or single numbers if only one row or column is needed).</p></dd><dt><span lang="en" class="term"><a name="gel-function-SwapRows"></a>SwapRows</span></dt><dd><pre lang="en" class="synopsis">SwapRows (m,row1,row2)</pre><p lang="en">Swap two rows in a matrix.</p></dd><dt><span lang="en" class="term"><a name="gel-function-UpperTriangular"></a>UpperTriangular</span></dt><dd><pre lang="en" class="synopsis">UpperTriangular (M)</pre><p lang="en">Returns a copy of the matrix <code class="varname">M</code> with all the entries below the diagonal set to zero.</p></dd><dt><span lang="en" class="term"><a name="gel-function-columns"></a>columns</span></dt><dd><pre lang="en" class="synopsis">columns (M)</pre><p lang="en">Get the number of columns of a matrix.</p></dd><dt><span lang="en" class="term"><a name="gel-function-elements"></a>elements</span></dt><dd><pre lang="en" class="synopsis">elements (M)</pre><p lang="en">Get the total number of elements of a matrix. This is the |
| 97 |
number of columns times the number of rows.</p></dd><dt><span lang="en" class="term"><a name="gel-function-ones"></a>ones</span></dt><dd><pre lang="en" class="synopsis">ones (rows,columns...)</pre><p lang="en">Make an matrix of all ones (or a row vector if only one argument is given). Returns <code class="constant">null</code> if either rows or columns are zero.</p></dd><dt><span lang="en" class="term"><a name="gel-function-rows"></a>rows</span></dt><dd><pre lang="en" class="synopsis">rows (M)</pre><p lang="en">Get the number of rows of a matrix.</p></dd><dt><span lang="en" class="term"><a name="gel-function-zeros"></a>zeros</span></dt><dd><pre lang="en" class="synopsis">zeros (rows,columns...)</pre><p lang="en">Make a matrix of all zeros (or a row vector if only one argument is given). Returns <code class="constant">null</code> if either rows or columns are zero.</p></dd></dl></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch11s07.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch11.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch11s09.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Teoria dos números </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Álgebra linear</td></tr></table></div></body></html> |