123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082 |
- \section{Linear Algebra package}
- \begin{Introduction}{Linear Algebra package}
- This section briefly describes what's available in the Linear Algebra
- package.
- Note on examples: In the examples throughout this
- document, the matrix A will be
- \begin{verbatim}
- [1 2 3]
- [4 5 6]
- [7 8 9].
- \end{verbatim}
- The functions can be divided into four categories:
- {\bf Basic matrix handling}
-
- \nameref{add\_columns},
- \nameref{add\_rows},
-
- \nameref{add\_to\_columns},
-
- \nameref{add\_to\_rows},
-
- \nameref{augment\_columns},
-
- \nameref{char\_poly},
-
- \nameref{column\_dim},
-
- \nameref{copy\_into},
-
- \nameref{diagonal},
-
- \nameref{extend},
-
- \nameref{find\_companion},
-
- \nameref{get\_columns},
-
- \nameref{get\_rows},
-
- \nameref{hermitian\_tp},
-
- \nameref{matrix\_augment},
-
- \nameref{matrix\_stack} ,
-
- \nameref{minor},
-
- \nameref{mult\_columns},
-
- \nameref{mult\_rows},
- \nameref{pivot},
-
- \nameref{remove\_columns},
-
- \nameref{remove\_rows},
-
- \nameref{row\_dim},
-
- \nameref{rows\_pivot},
-
- \nameref{stack\_rows},
-
- \nameref{sub\_matrix},
-
- \nameref{swap\_columns},
-
- \nameref{swap\_entries},
-
- \nameref{swap\_rows}.
- {\bf Constructors -- functions that create matrices}
-
- \nameref{band\_matrix},
-
- \nameref{block\_matrix},
-
- \nameref{char\_matrix},
-
- \nameref{coeff\_matrix},
-
- \nameref{companion},
-
- \nameref{hessian},
-
- \nameref{hilbert},
-
- \nameref{jacobian},
-
- \nameref{jordan\_block},
-
- \nameref{make\_identity},
-
- \nameref{random\_matrix},
-
- \nameref{toeplitz},
-
- \nameref{vandermonde}.
- {\bf High level algorithms}
-
- \nameref{char\_poly},
-
- \nameref{cholesky},
-
- \nameref{gram\_schmidt},
-
- \nameref{lu\_decom},
-
- \nameref{pseudo\_inverse},
-
- \nameref{simplex},
-
- \nameref{svd}.
- {\bf Normal Forms}
- There is a separate package, NORMFORM, for computing
- the following matrix normal forms in \REDUCE:
- \nameref{smithex},
- \nameref{smithex\_int},
- \nameref{frobenius},
- \nameref{ratjordan},
- \nameref{jordansymbolic},
- \nameref{jordan}.
- {\bf Predicates}
- \nameref{matrixp},
-
- \nameref{squarep},
-
- \nameref{symmetricp}.
- \end{Introduction}
- \begin{Switch}{fast_la}
- By turning the \name{fast\_la} switch on, the speed of the following
- functions will be increased:
-
- \nameref{add\_columns},
-
- \nameref{add\_rows},
-
- \nameref{augment\_columns},
-
- \nameref{column\_dim},
-
- \nameref{copy\_into},
-
- \nameref{make\_identity},
-
- \nameref{matrix\_augment},
-
- \nameref{matrix\_stack},
-
- \nameref{minor},
-
- \nameref{mult\_columns},
-
- \nameref{mult\_rows},
-
- \nameref{pivot},
-
- \nameref{remove\_columns},
-
- \nameref{remove\_rows},
-
- \nameref{rows\_pivot},
-
- \nameref{squarep},
-
- \nameref{stack\_rows},
-
- \nameref{sub\_matrix},
-
- \nameref{swap\_columns},
-
- \nameref{swap\_entries},
-
- \nameref{swap\_rows},
-
- \nameref{symmetricp}.
-
- The increase in speed will be negligible unless you are making a
- significant number (i.e. thousands) of calls. When using this switch,
- error checking is minimized. This means that illegal input may give
- strange error messages. Beware.
- \end{Switch}
- \begin{Operator}{add_columns}
- Add columns, add rows:
- \begin{Syntax}
- \name{add\_columns}\(\meta{matrix},\meta{c1},\meta{c2},\meta{expr}\)
- \end{Syntax}
- \meta{matrix} :- a \nameref{matrix}.
- \meta{c1},\meta{c2} :- positive integers.
- \meta{expr} :- a scalar expression.
- The Operator \name{add\_columns} replaces column \meta{\meta{c2}} of
- \meta{matrix} by \meta{expr} * column(\meta{matrix},\meta{c1}) +
- column(\meta{matrix},\meta{c2}).
- \name{add\_rows} performs the equivalent task on the rows of
- \meta{matrix}.
- \begin{Examples}
- add_columns(A,1,2,x); &
- \begin{multilineoutput}{6cm}
- [1 x + 2 3]
- [ ]
- [4 4*x + 5 6]
- [ ]
- [7 7*x + 8 9]
- \end{multilineoutput} \\
- add_rows(A,2,3,5); &
- \begin{multilineoutput}{6cm}
- [1 2 3 ]
- [ ]
- [4 5 6 ]
- [ ]
- [27 33 39]
- \end{multilineoutput} \\
- \end{Examples}
- Related functions: \nameref{add\_to\_columns},
- \nameref{add\_to\_rows}, \nameref{mult\_columns},
- \nameref{mult\_rows}.
- \end{Operator}
- \begin{Operator}{add_rows}
- see: \nameref{add\_columns}.
- \end{Operator}
- \begin{Operator}{add_to_columns}
- Add to columns, add to rows:
- \begin{Syntax}
- \name{add\_to\_columns}\(\meta{matrix},\meta{column\_list},\meta{expr}\)
- \end{Syntax}
- \meta{matrix} :- a matrix.
- \meta{column\_list} :- a positive integer or a list of positive
- integers.
- \meta{expr} :- a scalar expression.
- \name{add\_to\_columns} adds \meta{expr} to each column specified in
- \meta{column\_list} of \meta{matrix}.
- \name{add\_to\_rows} performs the equivalent task on the rows of
- \meta{matrix}.
- \begin{Examples}
- add_to_columns(A,\{1,2\},10); &
- \begin{multilineoutput}{6cm}
- [11 12 3]
- [ ]
- [14 15 6]
- [ ]
- [17 18 9]
- \end{multilineoutput}\\
- add_to_rows(A,2,-x) &
- \begin{multilineoutput}{6cm}
- [ 1 2 3 ]
- [ ]
- [ - x + 4 - x + 5 - x + 6]
- [ ]
- [ 7 8 9 ]
- \end{multilineoutput} \\
- \end{Examples}
- Related functions:
- \nameref{add\_columns}, \nameref{add\_rows}, \nameref{mult\_rows},
- \nameref{mult\_columns}.
- \end{Operator}
- \begin{Operator}{add_to_rows}
- see: \nameref{add\_to\_columns}.
- \end{Operator}
- \begin{Operator}{augment_columns}
- Augment columns, stack rows:
- \begin{Syntax}
- \name{augment\_columns}(\meta{matrix},\meta{column\_list})
- \end{Syntax}
- \meta{matrix} :- a matrix.
- \meta{column\_list} :- either a positive integer or a list of positive
- integers.
- \name{augment\_columns} gets hold of the columns of \meta{matrix}
- specified in \name{column\_list} and sticks them together.
- \name{stack\_rows} performs the same task on rows of \meta{matrix}.
- \begin{Examples}
- augment_columns(A,\{1,2\}) &
- \begin{multilineoutput}{6cm}
- [1 2]
- [ ]
- [4 5]
- [ ]
- [7 8]
- \end{multilineoutput} \\
- stack_rows(A,\{1,3\}) &
- \begin{multilineoutput}{6cm}
- [1 2 3]
- [ ]
- [7 8 9]
- \end{multilineoutput} \\
- \end{Examples}
- Related functions:
- \nameref{get\_columns}, \nameref{get\_rows}, \nameref{sub\_matrix}.
- \end{Operator}
- \begin{Operator}{band_matrix}
- \begin{Syntax}
- \name{band\_matrix}(\meta{expr\_list},\meta{square\_size})
- \end{Syntax}
- \meta{expr\_list} :- either a single scalar expression or a list of
- an odd number of scalar expressions.
- \meta{square\_size} :- a positive integer.
- \name{band\_matrix} creates a square matrix of dimension
- \meta{square\_size}. The diagonal consists of the middle expression
- of the \meta{expr\_list}. The expressions to the left of this fill
- the required number of sub\_diagonals and the expressions to the right
- the super\_diagonals.
- \begin{Examples}
- band_matrix(\{x,y,z\},6) &
- \begin{multilineoutput}{6cm}
- [y z 0 0 0 0]
- [ ]
- [x y z 0 0 0]
- [ ]
- [0 x y z 0 0]
- [ ]
- [0 0 x y z 0]
- [ ]
- [0 0 0 x y z]
- [ ]
- [0 0 0 0 x y]
- \end{multilineoutput} \\
- \end{Examples}
- Related functions: \nameref{diagonal}.
- \end{Operator}
- \begin{Operator}{block_matrix}
- \begin{Syntax}
- \name{block\_matrix}(\meta{r},\meta{c},\meta{matrix\_list})
- \end{Syntax}
- \meta{r},\meta{c} :- positive integers.
- \meta{matrix\_list} :- a list of matrices.
- \name{block\_matrix} creates a matrix that consists of \meta{r} by
- \meta{c} matrices filled from the \meta{matrix\_list} row wise.
- \begin{Examples}
- B := make_identity(2); &
- \begin{multilineoutput}{6cm}
- [1 0]
- b := [ ]
- [0 1]
- \end{multilineoutput} \\
- C := mat((5),(5)); &
- \begin{multilineoutput}{6cm}
- [5]
- c := [ ]
- [5]
- \end{multilineoutput} \\
- D := mat((22,33),(44,55)); &
- \begin{multilineoutput}{6cm}
- [22 33]
- d := [ ]
- [44 55]
- \end{multilineoutput} \\
- block_matrix(2,3,\{B,C,D,D,C,B\}); &
- \begin{multilineoutput}{6cm}
- [1 0 5 22 33]
- [ ]
- [0 1 5 44 55]
- [ ]
- [22 33 5 1 0 ]
- [ ]
- [44 55 5 0 1 ]
- \end{multilineoutput} \\
- \end{Examples}
- \end{Operator}
- \begin{Operator}{char_matrix}
- \begin{Syntax}
- \name{char\_matrix}(\meta{matrix},\meta{lambda})
- \end{Syntax}
- \meta{matrix} :- a square matrix.
- \meta{lambda} :- a symbol or algebraic expression.
- \meta{char\_matrix} creates the characteristic matrix C of
- \meta{matrix}.
- This is C = \meta{lambda} * Id - A.
- Id is the identity matrix.
- \begin{Examples}
- char_matrix(A,x); &
- \begin{multilineoutput}{6cm}
- [x - 1 -2 -3 ]
- [ ]
- [ -4 x - 5 -6 ]
- [ ]
- [ -7 -8 x - 9]
- \end{multilineoutput} \\
- \end{Examples}
- Related functions: \nameref{char\_poly}.
- \end{Operator}
- \begin{Operator}{char_poly}
- \begin{Syntax}
- \name{char\_poly}(\meta{matrix},\meta{lambda})
- \end{Syntax}
- \meta{matrix} :- a square matrix.
- \meta{lambda} :- a symbol or algebraic expression.
- \name{char\_poly} finds the characteristic polynomial of \meta{matrix}.
- This is the determinant of \meta{lambda} * Id - A.
- Id is the identity matrix.
- \begin{Examples}
- char_poly(A,x); &
- x^3-15*x^2-18*x
- \end{Examples}
- Related functions: \nameref{char\_matrix}.
- \end{Operator}
- \begin{Operator}{cholesky}
- \begin{Syntax}
- \name{cholesky}(\meta{matrix})
- \end{Syntax}
- \meta{matrix} :- a positive definite matrix containing numeric entries.
- \name{cholesky} computes the cholesky decomposition of \meta{matrix}.
- It returns \{L,U\} where L is a lower matrix, U is an upper matrix,
- A = LU, and U = $L^T$.
- \begin{Examples}
- F := mat((1,1,0),(1,3,1),(0,1,1)); &
- \begin{multilineoutput}{6cm}
- [1 1 0]
- [ ]
- f := [1 3 1]
- [ ]
- [0 1 1]
- \end{multilineoutput} \\
- on rounded; \\
- cholesky(F); &
- \begin{multilineoutput}{6cm}
- \{
- [1 0 0 ]
- [ ]
- [1 1.41421356237 0 ]
- [ ]
- [0 0.707106781187 0.707106781187]
- ,
- [1 1 0 ]
- [ ]
- [0 1.41421356237 0.707106781187]
- [ ]
- [0 0 0.707106781187]
- \}
- \end{multilineoutput} \\
- \end{Examples}
- Related functions: \nameref{lu\_decom}.
- \end{Operator}
- \begin{Operator}{coeff_matrix}
- \begin{Syntax}
- \name{coeff\_matrix}(\{\meta{lineq\_list}\})
- \end{Syntax}
- (If you are feeling lazy then the braces can be omitted.)
- \meta{lineq\_list} :- linear equations. Can be of the form equation = number
- or just equation.
- \name{coeff\_matrix} creates the coefficient matrix C of the linear
- equations.
- It returns \{C,X,B\} such that CX = B.
- \begin{Examples}
- coeff_matrix(\{x+y+4*z=10,y+x-z=20,x+y+4\}); &
- \begin{multilineoutput}{6cm}
- \{
- [4 1 1]
- [ ]
- [-1 1 1]
- [ ]
- [0 1 1]
- ,
- [z]
- [ ]
- [y]
- [ ]
- [x]
- ,
- [10]
- [ ]
- [20]
- [ ]
- [-4]
- \}
- \end{multilineoutput} \\
- \end{Examples}
- \end{Operator}
- \begin{Operator}{column_dim}
- Column dimension, row dimension:
- \begin{Syntax}
- \name{column\_dim}(\meta{matrix})
- \end{Syntax}
- \meta{matrix} :- a matrix.
- \name{column\_dim} finds the column dimension of \meta{matrix}.
- \name{row\_dim} finds the row dimension of \meta{matrix}.
- \begin{Examples}
- column_dim(A); &
- 3 \\
- row_dim(A); &
- 3 \\
- \end{Examples}
- \end{Operator}
- \begin{Operator}{companion}
- \begin{Syntax}
- \name{companion}(\meta{poly},\meta{x})
- \end{Syntax}
- \meta{poly} :- a monic univariate polynomial in \meta{x}.
- \meta{x} :- the variable.
- \name{companion} creates the companion matrix C of \meta{poly}.
- This is the square matrix of dimension n, where n is the degree of
- \meta{poly} w.r.t. \meta{x}.
- The entries of C are:
- C(i,n) = -coeffn(\meta{poly},\meta{x},i-1) for i = 1
- \ldots n, C(i,i-1) = 1 for i = 2 \ldots n and
- the rest are 0.
- \begin{Examples}
- companion(x^4+17*x^3-9*x^2+11,x); &
- \begin{multilineoutput}{6cm}
- [0 0 0 -11]
- [ ]
- [1 0 0 0 ]
- [ ]
- [0 1 0 9 ]
- [ ]
- [0 0 1 -17]
- \end{multilineoutput} \\
- \end{Examples}
- Related functions:
- \nameref{find\_companion}.
- \end{Operator}
- \begin{Operator}{copy_into}
- \begin{Syntax}
- \name{copy\_into}(\meta{A},\meta{B},\meta{r},\meta{c})
- \end{Syntax}
- \meta{A},\meta{B} :- matrices.
- \meta{r},\meta{c} :- positive integers.
- \name{copy\_into} copies matrix \meta{matrix} into \meta{B} with
- \meta{matrix}(1,1) at \meta{B}(\meta{r},\meta{c}).
- \begin{Examples}
- G := mat((0,0,0,0,0),(0,0,0,0,0),(0,0,0,0,0),(0,0,0,0,0),(0,0,0,0,0)); &
- \begin{multilineoutput}{6cm}
- [0 0 0 0 0]
- [ ]
- [0 0 0 0 0]
- [ ]
- g := [0 0 0 0 0]
- [ ]
- [0 0 0 0 0]
- [ ]
- [0 0 0 0 0]
- \end{multilineoutput} \\
- copy_into(A,G,1,2); &
- \begin{multilineoutput}{6cm}
- [0 1 2 3 0]
- [ ]
- [0 4 5 6 0]
- [ ]
- [0 7 8 9 0]
- [ ]
- [0 0 0 0 0]
- [ ]
- [0 0 0 0 0]
- \end{multilineoutput} \\
- \end{Examples}
- Related functions:
- \nameref{augment\_columns}, \nameref{extend}, \nameref{matrix\_augment},
- \nameref{matrix\_stack}, \nameref{stack\_rows}, \nameref{sub\_matrix}.
- \end{Operator}
- \begin{Operator}{diagonal}
- \begin{Syntax}
- \name{diagonal}(\{\meta{mat\_list}\})
- \end{Syntax}
- (If you are feeling lazy then the braces can be omitted.)
- \meta{mat\_list} :- each can be either a scalar expression or a
- square \nameref{matrix}.
- \name{diagonal} creates a matrix that contains the input on the
- diagonal.
- \begin{Examples}
- H := mat((66,77),(88,99)); &
- \begin{multilineoutput}{6cm}
- [66 77]
- h := [ ]
- [88 99]
- \end{multilineoutput} \\
- diagonal(\{A,x,H\}); &
- \begin{multilineoutput}{6cm}
- [1 2 3 0 0 0 ]
- [ ]
- [4 5 6 0 0 0 ]
- [ ]
- [7 8 9 0 0 0 ]
- [ ]
- [0 0 0 x 0 0 ]
- [ ]
- [0 0 0 0 66 77]
- [ ]
- [0 0 0 0 88 99]
- \end{multilineoutput} \\
- \end{Examples}
- Related functions:
- \nameref{jordan\_block}.
- \end{Operator}
- \begin{Operator}{extend}
- \begin{Syntax}
- \name{extend}(\meta{matrix},\meta{r},\meta{c},\meta{expr})
- \end{Syntax}
- \meta{matrix} :- a \nameref{matrix}.
- \meta{r},\meta{c} :- positive integers.
- \meta{expr} :- algebraic expression or symbol.
- \name{extend} returns a copy of \meta{matrix} that has been extended by
- \meta{r} rows and \meta{c} columns. The new entries are made equal to
- \meta{expr}.
- \begin{Examples}
- extend(A,1,2,x); &
- \begin{multilineoutput}{6cm}
- [1 2 3 x x]
- [ ]
- [4 5 6 x x]
- [ ]
- [7 8 9 x x]
- [ ]
- [x x x x x]
- \end{multilineoutput} \\
- \end{Examples}
- Related functions:
- \nameref{copy\_into}, \nameref{matrix\_augment}, \nameref{matrix\_stack},
- \nameref{remove\_columns}, \nameref{remove\_rows}.
- \end{Operator}
- \begin{Operator}{find_companion}
- \begin{Syntax}
- \name{find\_companion}(\meta{matrix},\meta{x})
- \end{Syntax}
- \meta{matrix} :- a \nameref{matrix}.
- \meta{x} :- the variable.
- Given a companion matrix, \name{find\_companion} finds the polynomial
- from which it was made.
- \begin{Examples}
- C := companion(x^4+17*x^3-9*x^2+11,x); &
- \begin{multilineoutput}{6cm}
- [0 0 0 -11]
- [ ]
- [1 0 0 0 ]
- c := [ ]
- [0 1 0 9 ]
- [ ]
- [0 0 1 -17]
- \end{multilineoutput}\\
- find_companion(C,x); &
- x^4+17*x^3-9*x^2+11
- \end{Examples}
- Related functions:
- \nameref{companion}.
- \end{Operator}
- \begin{Operator}{get_columns}
- Get columns, get rows:
- \begin{Syntax}
- \name{get\_columns}(\meta{matrix},\meta{column\_list})
- \end{Syntax}
- \meta{matrix} :- a \nameref{matrix}.
- \meta{c} :- either a positive integer or a list of positive
- integers.
- \name{get\_columns} removes the columns of \meta{matrix} specified in
- \meta{column\_list} and returns them as a list of column matrices.
- \name{get\_rows} performs the same task on the rows of \meta{matrix}.
- \begin{Examples}
- get_columns(A,\{1,3\}); &
- \begin{multilineoutput}{6cm}
- \{
- [1]
- [ ]
- [4]
- [ ]
- [7]
- ,
- [3]
- [ ]
- [6]
- [ ]
- [9]
- \}
- \end{multilineoutput} \\
- get_rows(A,2); &
- \begin{multilineoutput}{6cm}
- \{
- [4 5 6]
- \}
- \end{multilineoutput} \\
- \end{Examples}
- Related functions:
- \nameref{augment\_columns}, \nameref{stack\_rows}, \nameref{sub\_matrix}.
- \end{Operator}
- \begin{Operator}{get_rows}
- see: \nameref{get\_columns}.
- \end{Operator}
- \begin{Operator}{gram_schmidt}
- \begin{Syntax}
- \name{gram\_schmidt}(\{\meta{vec\_list}\})
- \end{Syntax}
- (If you are feeling lazy then the braces can be omitted.)
- \meta{vec\_list} :- linearly independent vectors. Each vector must be
- written as a list, eg:\{1,0,0\}.
- \name{gram\_schmidt} performs the gram\_schmidt orthonormalization on
- the input vectors.
- It returns a list of orthogonal normalized vectors.
- \begin{Examples}
- gram_schmidt(\{\{1,0,0\},\{1,1,0\},\{1,1,1\}\}); &
- \{\{1,0,0\},\{0,1,0\},\{0,0,1\}\} \\
- gram_schmidt(\{\{1,2\},\{3,4\}\}); &
- \{\{ \rfrac{1}{{sqrt(5)}} , \rfrac{2}{sqrt(5)} \},
- \{ \rfrac{2*sqrt(5)}{5} , \rfrac{-sqrt(5)}{5} \}\}
- \end{Examples}
- \end{Operator}
- \begin{Operator}{hermitian_tp}
- \begin{Syntax}
- \name{ hermitian\_tp}(\meta{matrix})
- \end{Syntax}
- \meta{matrix} :- a \nameref{matrix}.
- \name{hermitian\_tp} computes the hermitian transpose of \meta{matrix}.
- This is a \nameref{matrix} in which the (i,j)'th entry is the conjugate
- of the (j,i)'th entry of \meta{matrix}.
- \begin{Examples}
- J := mat((i+1,i+2,i+3),(4,5,2),(1,i,0)); &
- \begin{multilineoutput}{6cm}
- [i + 1 i + 2 i + 3]
- [ ]
- j := [ 4 5 2 ]
- [ ]
- [ 1 i 0 ]
- \end{multilineoutput} \\
- hermitian_tp(j); &
- \begin{multilineoutput}{6cm}
- [ - i + 1 4 1 ]
- [ ]
- [ - i + 2 5 - i]
- [ ]
- [ - i + 3 2 0 ]
- \end{multilineoutput} \\
- \end{Examples}
- Related functions:
- \nameref{tp}.
- \end{Operator}
- \begin{Operator}{hessian}
- \begin{Syntax}
- \name{hessian}(\meta{expr},\meta{variable\_list})
- \end{Syntax}
- \meta{expr} :- a scalar expression.
- \meta{variable\_list} :- either a single variable or a list of
- variables.
- \name{hessian} computes the hessian matrix of \meta{expr} w.r.t. the
- variables in \meta{variable\_list}.
- % Does df exist in the help pages?
- This is an n by n matrix where n is the number of variables and the
- (i,j)'th entry is \nameref{df}(\meta{expr},\meta{variable\_list}(i),
- \meta{variable\_list}(j)).
- \begin{Examples}
- hessian(x*y*z+x^2,\{w,x,y,z\}); &
- \begin{multilineoutput}{6cm}
- [0 0 0 0]
- [ ]
- [0 2 z y]
- [ ]
- [0 z 0 x]
- [ ]
- [0 y x 0]
- \end{multilineoutput}{6cm}
- \end{Examples}
- Related functions: \nameref{df}.
- \end{Operator}
- \begin{Operator}{hilbert}
- \begin{Syntax}
- \name{hilbert}(\meta{square\_size},\meta{expr})
- \end{Syntax}
- \meta{square\_size} :- a positive integer.
- \meta{expr} :- an algebraic expression.
- \name{hilbert} computes the square hilbert matrix of dimension
- \meta{square\_size}.
- This is the symmetric matrix in which the (i,j)'th entry is
- 1/(i+j-\meta{expr}).
- \begin{Examples}
- hilbert(3,y+x); &
- \begin{multilineoutput}{6cm}
- [ - 1 - 1 - 1 ]
- [----------- ----------- -----------]
- [ x + y - 2 x + y - 3 x + y - 4 ]
- [ ]
- [ - 1 - 1 - 1 ]
- [----------- ----------- -----------]
- [ x + y - 3 x + y - 4 x + y - 5 ]
- [ ]
- [ - 1 - 1 - 1 ]
- [----------- ----------- -----------]
- [ x + y - 4 x + y - 5 x + y - 6 ]
- \end{multilineoutput}
- \end{Examples}
- \end{Operator}
- \begin{Operator}{jacobian}
- \begin{Syntax}
- \name{jacobian}(\meta{expr\_list},\meta{variable\_list})
- \end{Syntax}
- \meta{expr\_list} :- either a single algebraic expression or a list
- of algebraic expressions.
- \meta{variable\_list} :- either a single variable or a list of
- variables.
- \name{jacobian} computes the jacobian matrix of \meta{expr\_list}
- w.r.t. \meta{variable\_list}.
- This is a matrix whose (i,j)'th entry is \nameref{df}(\meta{expr\_list}
- (i),\meta{variable\_list}(j)).
- The matrix is n by m where n is the number of variables and m the number
- of expressions.
- \begin{Examples}
-
- jacobian(\{x^4,x*y^2,x*y*z^3\},\{w,x,y,z\}); &
- \begin{multilineoutput}{6cm}
- [ 3 ]
- [0 4*x 0 0 ]
- [ ]
- [ 2 ]
- [0 y 2*x*y 0 ]
- [ ]
- [ 3 3 2]
- [0 y*z x*z 3*x*y*z ]
- \end{multilineoutput}
- \end{Examples}
- Related functions:
- \nameref{hessian}, \nameref{df}.
- \end{Operator}
- \begin{Operator}{jordan_block}
- \begin{Syntax}
- \name{jordan\_block}(\meta{expr},\meta{square\_size})
- \end{Syntax}
- \meta{expr} :- an algebraic expression or symbol.
- \meta{square\_size} :- a positive integer.
- \name{jordan\_block} computes the square jordan block matrix J of
- dimension \meta{square\_size}.
- The entries of J are:
- J(i,i) = \meta{expr} for i=1
- \ldots n, J(i,i+1) = 1 for i=1
- \ldots n-1, and all other entries are 0.
- \begin{Examples}
- jordan\_block(x,5); &
- \begin{multilineoutput}{6cm}
- [x 1 0 0 0]
- [ ]
- [0 x 1 0 0]
- [ ]
- [0 0 x 1 0]
- [ ]
- [0 0 0 x 1]
- [ ]
- [0 0 0 0 x]
- \end{multilineoutput}
- \end{Examples}
- Related functions: \nameref{diagonal}, \nameref{companion}.
- \end{Operator}
- \begin{Operator}{lu_decom}
- \begin{Syntax}
- \name{lu\_decom}(\meta{matrix})
- \end{Syntax}
- \meta{matrix} :- a \nameref{matrix} containing either numeric entries
- or imaginary entries with numeric coefficients.
- \name{lu\_decom} performs LU decomposition on \meta{matrix}, ie: it
- returns \{L,U\} where L is a lower diagonal \nameref{matrix}, U an
- upper diagonal \nameref{matrix} and A = LU.
- Caution:
- The algorithm used can swap the rows of \meta{matrix} during the
- calculation. This means that LU does not equal \meta{matrix} but a row
- equivalent of it. Due to this, \name{lu\_decom} returns \{L,U,vec\}.
- The call \name{convert(\meta{matrix},vec)} will return the matrix that has
- been decomposed, i.e: LU = convert(\meta{matrix},vec).
- \begin{Examples}
- K := mat((1,3,5),(-4,3,7),(8,6,4)); &
- \begin{multilineoutput}{6cm}
- [1 3 5]
- [ ]
- k := [-4 3 7]
- [ ]
- [8 6 4]
- \end{multilineoutput}\\
- on rounded;\\
- lu := lu_decom(K); &
- \begin{multilineoutput}{6cm}
- lu := \{
- [8 0 0 ]
- [ ]
- [-4 6.0 0 ]
- [ ]
- [1 2.25 1.125]
- ,
- [1 0.75 0.5]
- [ ]
- [0 1 1.5]
- [ ]
- [0 0 1 ]
- ,
- [3 2 3]\}
- \end{multilineoutput} \\
- first lu * second lu; &
- \begin{multilineoutput}{6cm}
- [8 6.0 4.0]
- [ ]
- [-4 3.0 7.0]
- [ ]
- [1 3.0 5.0]
- \end{multilineoutput}\\
- convert(K,third lu); &
- \begin{multilineoutput}
- [8 6 4]
- [ ]
- [-4 3 7]
- [ ]
- [1 3 5]
- \end{multilineoutput}\\
- P := mat((i+1,i+2,i+3),(4,5,2),(1,i,0)); &
- \begin{multilineoutput}{6cm}
- [i + 1 i + 2 i + 3]
- [ ]
- p := [ 4 5 2 ]
- [ ]
- [ 1 i 0 ]
- \end{multilineoutput}\\
- lu := lu_decom(P); &
- \begin{multilineoutput}{6cm}
- lu := \{
- [ 1 0 0 ]
- [ ]
- [ 4 - 4*i + 5 0 ]
- [ ]
- [i + 1 3 0.414634146341*i + 2.26829268293]
- ,
- [1 i 0 ]
- [ ]
- [0 1 0.19512195122*i + 0.243902439024]
- [ ]
- [0 0 1 ]
- ,
- [3 2 3]\}
- \end{multilineoutput}\\
- first lu * second lu; &
- \begin{multilineoutput}{6cm}
- [ 1 i 0 ]
- [ ]
- [ 4 5 2.0 ]
- [ ]
- [i + 1 i + 2 i + 3.0]
- \end{multilineoutput}\\
- convert(P,third lu); &
- \begin{multilineoutput}{6cm}
- [ 1 i 0 ]
- [ ]
- [ 4 5 2 ]
- [ ]
- [i + 1 i + 2 i + 3]
- \end{multilineoutput}\\
- \end{Examples}
- Related functions: \nameref{cholesky}.
- \end{Operator}
- \begin{Operator}{make_identity}
- \begin{Syntax}
- \name{make\_identity}(\meta{square\_size})
- \end{Syntax}
- \meta{square\_size} :- a positive integer.
- \name{make\_identity} creates the identity matrix of dimension
- \meta{square\_size}.
- \begin{Examples}
- make_identity(4); &
- \begin{multilineoutput}{6cm}
- [1 0 0 0]
- [ ]
- [0 1 0 0]
- [ ]
- [0 0 1 0]
- [ ]
- [0 0 0 1]
- \end{multilineoutput}
- \end{Examples}
- Related functions: \nameref{diagonal}.
- \end{Operator}
- \begin{Operator}{matrix_augment}
- Matrix augment, matrix stack:
- \begin{Syntax}
- \name{matrix\_augment} \{\meta{matrix\_list}\}
- \end{Syntax}
- (If you are feeling lazy then the braces can be omitted.)
- \meta{matrix\_list} :- matrices.
- \name{matrix\_augment} sticks the matrices in \meta{matrix\_list}
- together horizontally.
- \name{matrix\_stack} sticks the matrices in \meta{matrix\_list}
- together vertically.
- \begin{Examples}
- matrix_augment(\{A,A\}); &
- \begin{multilineoutput}{6cm}
- [1 2 3 1 2 3]
- [ ]
- [4 5 6 4 5 6]
- [ ]
- [7 8 9 7 8 9]
- \end{multilineoutput}\\
- matrix_stack(A,A); &
- \begin{multilineoutput}{6cm}
- [1 2 3]
- [ ]
- [4 5 6]
- [ ]
- [7 8 9]
- [ ]
- [1 2 3]
- [ ]
- [4 5 6]
- [ ]
- [7 8 9]
- \end{multilineoutput} \\
- \end{Examples}
- Related functions:
- \nameref{augment\_columns}, \nameref{stack\_rows}, \nameref{sub\_matrix}.
- \end{Operator}
- \begin{Operator}{matrixp}
- \begin{Syntax}
- \name{matrixp}(\meta{test\_input})
- \end{Syntax}
- \meta{test\_input} :- anything you like.
- \name{matrixp} is a boolean function that returns t if the input is a
- matrix and nil otherwise.
- \begin{Examples}
- matrixp A; &
- t \\
- matrixp(doodlesackbanana);&
- nil
- \end{Examples}
- Related functions: \nameref{squarep}, \nameref{symmetricp}.
- \end{Operator}
- \begin{Operator}{matrix_stack}
- see: \nameref{matrix\_augment}.
- \end{Operator}
- \begin{Operator}{minor}
- \begin{Syntax}
- \name{minor}(\meta{matrix},\meta{r},\meta{c})
- \end{Syntax}
- \meta{matrix} :- a \nameref{matrix}.
- \meta{r},\meta{c} :- positive integers.
- \name{minor} computes the (\meta{r},\meta{c})'th minor of \meta{matrix}.
- This is created by removing the \meta{r}'th row and the \meta{c}'th
- column from \meta{matrix}.
-
- \begin{Examples}
- minor(A,1,3); &
- \begin{multilineoutput}{6cm}
- [4 5]
- [ ]
- [7 8]
- \end{multilineoutput}
- \end{Examples}
- Related functions:
- \nameref{remove\_columns}, \nameref{remove\_rows}.
- \end{Operator}
- \begin{Operator}{mult_columns}
- Mult columns, mult rows:
- \begin{Syntax}
- \name{mult\_columns}(\meta{matrix},\meta{column\_list},\meta{expr})
- \end{Syntax}
- \meta{matrix} :- a \nameref{matrix}.
- \meta{column\_list} :- a positive integer or a list of positive
- integers.
- \meta{expr} :- an algebraic expression.
- \name{mult\_columns} returns a copy of \meta{matrix} in which the
- columns specified in \meta{column\_list} have been multiplied by
- \meta{expr}.
- \name{mult\_rows} performs the same task on the rows of \meta{matrix}.
- \begin{Examples}
- mult_columns(A,\{1,3\},x); &
- \begin{multilineoutput}{6cm}
- [ x 2 3*x]
- [ ]
- [4*x 5 6*x]
- [ ]
- [7*x 8 9*x]
- \end{multilineoutput}\\
- mult_rows(A,2,10); &
- \begin{multilineoutput}{6cm}
- [1 2 3 ]
- [ ]
- [40 50 60]
- [ ]
- [7 8 9 ]
- \end{multilineoutput}
- \end{Examples}
- Related functions: \nameref{add\_to\_columns}, \nameref{add\_to\_rows}.
- \end{Operator}
- \begin{Operator}{mult_rows}
- see: \nameref{mult\_columns}.
- \end{Operator}
- \begin{Operator}{pivot}
- \begin{Syntax}
- \name{pivot}(\meta{matrix},\meta{r},\meta{c})
- \end{Syntax}
-
- \meta{matrix} :- a matrix.
- \meta{r},\meta{c} :- positive integers such that \meta{matrix}(\meta{r},
- \meta{c}) neq 0.
- \name{pivot} pivots \meta{matrix} about it's (\meta{r},\meta{c})'th
- entry.
-
- To do this, multiples of the \meta{r}'th row are added to every other
- row in the matrix.
- This means that the \meta{c}'th column will be 0 except for the
- (\meta{r},\meta{c})'th entry.
- \begin{Examples}
- pivot(A,2,3); &
- \begin{multilineoutput}{6cm}
- [ - 1 ]
- [-1 ------ 0]
- [ 2 ]
- [ ]
- [4 5 6]
- [ ]
- [ 1 ]
- [1 --- 0]
- [ 2 ]
- \end{multilineoutput}
- \end{Examples}
- Related functions:
- \nameref{rows\_pivot}.
- \end{Operator}
- \begin{Operator}{pseudo_inverse}
- \begin{Syntax}
- \name{pseudo\_inverse}(\meta{matrix})
- \end{Syntax}
- \meta{matrix} :- a \nameref{matrix}.
- \name{pseudo\_inverse}, also known as the Moore-Penrose inverse,
- computes the pseudo inverse of \meta{matrix}.
- Given the singular value decomposition of \meta{matrix}, i.e:
- A = $U*P*V^T$, then the pseudo inverse $A^{-1}$ is defined by
- $A^{-1} = V^T*P^{-1}*U$.
- Thus \meta{matrix} * pseudo\_inverse(A) = Id.
- (Id is the identity matrix).
- \begin{Examples}
- R := mat((1,2,3,4),(9,8,7,6)); &
- \begin{multilineoutput}{6cm}
- [1 2 3 4]
- r := [ ]
- [9 8 7 6]
- \end{multilineoutput}\\
- on rounded; \\
- pseudo_inverse(R); &
- \begin{multilineoutput}{6cm}
- [ - 0.199999999996 0.100000000013 ]
- [ ]
- [ - 0.0499999999988 0.0500000000037 ]
- [ ]
- [ 0.0999999999982 - 5.57825497203e-12]
- [ ]
- [ 0.249999999995 - 0.0500000000148 ]
- \end{multilineoutput}
- \end{Examples}
- Related functions: \nameref{svd}.
- \end{Operator}
- \begin{Operator}{random_matrix}
- \begin{Syntax}
- \name{random\_matrix}(\meta{r},\meta{c},\meta{limit})
- \end{Syntax}
-
- \meta{r},\meta{c},\meta{limit} :- positive integers.
- \name{random\_matrix} creates an \meta{r} by \meta{c} matrix with random
- entries in the range -limit < entry < limit.
- Switches:
- \name{imaginary} :- if on then matrix entries are x+i*y where -limit < x,y
- < \meta{limit}.
- \name{not\_negative} :- if on then 0 < entry < \meta{limit}. In the imaginary
- case we have 0 < x,y < \meta{limit}.
- \name{only\_integer} :- if on then each entry is an integer. In the imaginary
- case x and y are integers.
- \name{symmetric} :- if on then the matrix is symmetric.
- \name{upper\_matrix} :- if on then the matrix is upper triangular.
- \name{lower\_matrix} :- if on then the matrix is lower triangular.
- \begin{Examples}
- on rounded; \\
- random_matrix(3,3,10); &
- \begin{multilineoutput}{6cm}
- [ - 8.11911717343 - 5.71677292768 0.620580830035 ]
- [ ]
- [ - 0.032596262422 7.1655452861 5.86742633837 ]
- [ ]
- [ - 9.37155438255 - 7.55636708637 - 8.88618627557]
- \end{multilineoutput}\\
- on only_integer, not_negative, upper_matrix, imaginary; \\
- random_matrix(4,4,10); &
- \begin{multilineoutput}{6cm}
- [70*i + 15 28*i + 8 2*i + 79 27*i + 44]
- [ ]
- [ 0 46*i + 95 9*i + 63 95*i + 50]
- [ ]
- [ 0 0 31*i + 75 14*i + 65]
- [ ]
- [ 0 0 0 5*i + 52 ]
- \end{multilineoutput}\\
- \end{Examples}
- \end{Operator}
- \begin{Operator}{remove_columns}
- Remove columns, remove rows:
- \begin{Syntax}
- \name{remove\_columns}(\meta{matrix},\meta{column\_list})
- \end{Syntax}
- \meta{matrix} :- a \nameref{matrix}.
- \meta{column\_list} :- either a positive integer or a list of positive
- integers.
- \name{remove\_columns} removes the columns specified in
- \meta{column\_list} from \meta{matrix}.
- \name{remove\_rows} performs the same task on the rows of \meta{matrix}.
- \begin{Examples}
- remove_columns(A,2); &
- \begin{multilineoutput}{6cm}
- [1 3]
- [ ]
- [4 6]
- [ ]
- [7 9]
- \end{multilineoutput}\\
- remove_rows(A,\{1,3\}); &
- \begin{multilineoutput}{6cm}
- [4 5 6]
- \end{multilineoutput}\\
- \end{Examples}
- Related functions: \nameref{minor}.
- \end{Operator}
- \begin{Operator}{remove_rows}
- see: \nameref{remove\_columns}.
- \end{Operator}
- \begin{Operator}{row_dim}
- see: \nameref{column\_dim}.
- \end{Operator}
- \begin{Operator}{rows_pivot}
- \begin{Syntax}
- \name{rows\_pivot}(\meta{matrix},\meta{r},\meta{c},\{\meta{row\_list}\})
- \end{Syntax}
- \meta{matrix} :- a nameref{matrix}.
- \meta{r},\meta{c} :- positive integers such that \meta{matrix}(\meta{r},
- \meta{c}) neq 0.
- \meta{row\_list} :- positive integer or a list of positive integers.
- \name{rows\_pivot} performs the same task as \name{pivot} but applies
- the pivot only to the rows specified in \meta{row\_list}.
- \begin{Examples}
- N := mat((1,2,3),(4,5,6),(7,8,9),(1,2,3),(4,5,6)); &
- \begin{multilineoutput}{6cm}
- [1 2 3]
- [ ]
- [4 5 6]
- [ ]
- n := [7 8 9]
- [ ]
- [1 2 3]
- [ ]
- [4 5 6]
- \end{multilineoutput}\\
- rows_pivot(N,2,3,{4,5}); &
- \begin{multilineoutput}{6cm}
- [1 2 3]
- [ ]
- [4 5 6]
- [ ]
- [7 8 9]
- [ ]
- [ - 1 ]
- [-1 ------ 0]
- [ 2 ]
- [ ]
- [0 0 0]
- \end{multilineoutput}\\
- \end{Examples}
- Related functions: \nameref{pivot}.
- \end{Operator}
- \begin{Operator}{simplex}
- \begin{Syntax}
- \name{simplex}(\meta{max/min},\meta{objective function},
- \{\meta{linear inequalities}\})
- \end{Syntax}
- \meta{max/min} :- either max or min (signifying maximize and
- minimize).
- \meta{objective function} :- the function you are maximizing or
- minimizing.
- \meta{linear inequalities} :- the constraint inequalities. Each one must
- be of the form {\it sum of variables (
- <=,=,>=) number}.
- \name{simplex} applies the revised simplex algorithm to find the
- optimal(either maximum or minimum) value of the
- \meta{objective function} under the linear inequality constraints.
- It returns \{optimal value,\{ values of variables at this optimal\}\}.
- The algorithm implies that all the variables are non-negative.
- \begin{Examples}
- simplex(max,x+y,\{x>=10,y>=20,x+y<=25\}); &
- ***** Error in simplex: Problem has no feasible solution\\
- simplex(max,10x+5y+5.5z,\{5x+3z<=200,x+0.1y+0.5z<=12,
- 0.1x+0.2y+0.3z<=9, 30x+10y+50z<=1500\}); &
- \{525.0,\{x=40.0,y=25.0,z=0\}\}\\
- \end{Examples}
- \end{Operator}
- \begin{Operator}{squarep}
- \begin{Syntax}
- \name{squarep}(\meta{matrix})
- \end{Syntax}
-
- \meta{matrix} :- a \nameref{matrix}.
- \name{squarep} is a predicate that returns t if the \meta{matrix} is
- square and nil otherwise.
- \begin{Examples}
- squarep(mat((1,3,5))); &
- nil \\
- squarep(A);
- t\\
- \end{Examples}
- Related functions: \nameref{matrixp}, \nameref{symmetricp}.
- \end{Operator}
- \begin{Operator}{stack_rows}
- see: \nameref{augment\_columns}.
- \end{Operator}
- \begin{Operator}{sub_matrix}
- \begin{Syntax}
- \name{sub\_matrix}(\meta{matrix},\meta{row\_list},\meta{column\_list})
- \end{Syntax}
- \meta{matrix} :- a matrix.
- \meta{row\_list}, \meta{column\_list} :- either a positive integer or a
- list of positive integers.
- name{sub\_matrix} produces the matrix consisting of the intersection of
- the rows specified in \meta{row\_list} and the columns specified in
- \meta{column\_list}.
- \begin{Examples}
- sub_matrix(A,\{1,3\},\{2,3\}); &
- \begin{multilineoutput}{6cm}
- [2 3]
- [ ]
- [8 9]
- \end{multilineoutput}
- \end{Examples}
- Related functions:
- \nameref{augment\_columns}, \nameref{stack\_rows}.
- \end{Operator}
- \begin{Operator}{svd}
- \index{singular value decomposition}
- Singular value decomposition:
- \begin{Syntax}
- \name{svd}(\meta{matrix})
- \end{Syntax}
- \meta{matrix} :- a \nameref{matrix} containing only numeric entries.
- \name{svd} computes the singular value decomposition of \meta{matrix}.
- It returns
- \{U,P,V\}
- where A = $U*P*V^T$
- and P = diag(sigma(1) ... sigma(n)).
- sigma(i) for i= 1 ... n are the singular values of
- \meta{matrix}.
- n is the column dimension of \meta{matrix}.
- The singular values of \meta{matrix} are the non-negative square roots
- of the eigenvalues of $A^T*A$.
- U and V are such that $U*U^T = V*V^T = V^T*V$ = Id.
- Id is the identity matrix.
- \begin{Examples}
- Q := mat((1,3),(-4,3)); &
- \begin{multilineoutput}{6cm}
- [1 3]
- q := [ ]
- [-4 3]
- \end{multilineoutput}\\
- on rounded; \\
- svd(Q); &
- \begin{multilineoutput}{6cm}
- \{
- [ 0.289784137735 0.957092029805]
- [ ]
- [ - 0.957092029805 0.289784137735]
- ,
- [5.1491628629 0 ]
- [ ]
- [ 0 2.9130948854]
- ,
- [ - 0.687215403194 0.726453707825 ]
- [ ]
- [ - 0.726453707825 - 0.687215403194]
- \}
- \end{multilineoutput}\\
- \end{Examples}
- \end{Operator}
- \begin{Operator}{swap_columns}
- Swap columns, swap rows:
- \begin{Syntax}
- \name{swap\_columns} (\meta{matrix},\meta{c1},\meta{c2})
- \end{Syntax}
- \meta{matrix} :- a \nameref{matrix}.
- \meta{c1},\meta{c1} :- positive integers.
-
- \name{swap\_columns} swaps column \meta{c1} of \meta{matrix} with
- column \meta{c2}.
- \name{swap\_rows} performs the same task on two rows of \meta{matrix}.
- \begin{Examples}
- swap_columns(A,2,3); &
- \begin{multilineoutput}{6cm}
- [1 3 2]
- [ ]
- [4 6 5]
- [ ]
- [7 9 8]
- \end{multilineoutput}\\
- swap_rows(A,1,3); &
- \begin{multilineoutput}{6cm}
- [7 8 9]
- [ ]
- [4 5 6]
- [ ]
- [1 2 3]
- \end{multilineoutput}
- \end{Examples}
- Related functions: \nameref{swap\_entries}.
- \end{Operator}
- \begin{Operator}{swap_entries}
- \begin{Syntax}
- \name{swap\_entries}(\meta{matrix},\{\meta{r1},\meta{c1}\},\{\meta{r2},
- \meta{c2}\})
- \end{Syntax}
- \meta{matrix} :- a \nameref{matrix}.
- \meta{r1},\meta{c1},\meta{r2},\meta{c2} :- positive integers.
- \name{swap\_entries} swaps \meta{matrix}(\meta{r1},\meta{c1}) with
- \meta{matrix}(\meta{r2},\meta{c2}).
- \begin{Examples}
- swap_entries(A,\{1,1\},\{3,3\}); &
- \begin{multilineoutput}{6cm}
- [9 2 3]
- [ ]
- [4 5 6]
- [ ]
- [7 8 1]
- \end{multilineoutput}
- \end{Examples}
- Related functions: \nameref{swap\_columns}, \nameref{swap\_rows}.
- \end{Operator}
- \begin{Operator}{swap_rows}
- see: \nameref{swap\_columns}.
- \end{Operator}
- \begin{Operator}{symmetricp}
- \begin{Syntax}
- \name{symmetricp}(\meta{matrix})
- \end{Syntax}
-
- \meta{matrix} :- a \nameref{matrix}.
- \name{symmetricp} is a predicate that returns t if the matrix is symmetric
- and nil otherwise.
- \begin{Examples}
- symmetricp(make_identity(11)); &
- t \\
- symmetricp(A); &
- nil\\
- \end{Examples}
- Related functions: \nameref{matrixp}, \nameref{squarep}.
- \end{Operator}
- \begin{Operator}{toeplitz}
- \begin{Syntax}
- \name{toeplitz}(\meta{expr\_list})
- \end{Syntax}
- (If you are feeling lazy then the braces can be omitted.)
- \meta{expr\_list} :- list of algebraic expressions.
- \name{toeplitz} creates the toeplitz matrix from the \meta{expr\_list}.
- This is a square symmetric matrix in which the first expression is
- placed on the diagonal and the i'th expression is placed on the (i-1)'th
- sub and super diagonals.
- It has dimension n where n is the number of expressions.
- \begin{Examples}
- toeplitz({w,x,y,z}); &
- \begin{multilineoutput}{6cm}
- [w x y z]
- [ ]
- [x w x y]
- [ ]
- [y x w x]
- [ ]
- [z y x w]
- \end{multilineoutput}
- \end{Examples}
- \end{Operator}
- \begin{Operator}{vandermonde}
- \begin{Syntax}
- \name{vandermonde}(\{\meta{expr\_list}\})
- \end{Syntax}
- (If you are feeling lazy then the braces can be omitted.)
- \meta{expr\_list} :- list of algebraic expressions.
- \name{vandermonde} creates the vandermonde matrix from the
- \meta{expr\_list}.
- This is the square matrix in which the (i,j)'th entry is
- \meta{expr\_list}$(i)^(j-1)$.
- It has dimension n where n is the number of expressions.
-
- \begin{Examples}
- vandermonde({x,2*y,3*z}); &
- \begin{multilineoutput}{6cm}
- [ 2 ]
- [1 x x ]
- [ ]
- [ 2]
- [1 2*y 4*y ]
- [ ]
- [ 2]
- [1 3*z 9*z ]
- \end{multilineoutput}
- \end{Examples}
- \end{Operator}
|