123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta name="generator" content=
- "HTML Tidy for Linux/x86 (vers 1st March 2004), see www.w3.org" />
- <meta http-equiv="Content-Type" content=
- "text/html; charset=us-ascii" />
- <link rel="stylesheet" href="../../../../boost.css" type="text/css"/>
- <link rel="stylesheet" href="ublas.css" type="text/css" />
- <script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
- <script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
- <title>Matrix Expressions</title>
- </head>
- <body>
- <h1><img src="../../../../boost.png" align="middle" />Matrix Expressions</h1>
- <div class="toc" id="toc"></div>
- <h2><a name="matrix_expression"></a>Matrix Expression</h2>
- <h4>Description</h4>
- <p>The templated class <code>matrix_expression<E></code>
- is required to be a public base of all classes which model the Matrix Expression concept.</p>
- <h4>Definition</h4>
- <p>Defined in the header expression_types.hpp.</p>
- <h4>Template parameters</h4>
- <table border="1" summary="parameters">
- <tbody>
- <tr>
- <th>Parameter</th>
- <th>Description</th>
- <th>Default</th>
- </tr>
- <tr>
- <td><code>E</code></td>
- <td>The type of the matrix expression.</td>
- <td> </td>
- </tr>
- </tbody>
- </table>
- <h4>Model of</h4>
- <p>None. <u>Not a Matrix Expression</u>!
- </p>
- <h4>Type requirements</h4>
- <p>None.</p>
- <h4>Public base classes</h4>
- <p>None.</p>
- <h4>Members</h4>
- <table border="1" summary="members">
- <tbody>
- <tr>
- <th>Member</th>
- <th>Description</th>
- </tr>
- <tr>
- <td><code>const expression_type &operator () ()
- const</code></td>
- <td>Returns a <code>const</code> reference of the expression.</td>
- </tr>
- <tr>
- <td><code>expression_type &operator () ()</code></td>
- <td>Returns a reference of the expression.</td>
- </tr>
- </tbody>
- </table>
- <h4>Notes</h4>
- <p>The <code>operator[]</code>, <code>row</code>, <code>column</code>, <code>range</code>, <code>slice</code> and <code>project</code> functions have been removed. Use the free functions defined in <a href="matrix_proxy.html">matrix proxy</a> instead.</p>
- <h2><a name="matrix_container"></a>Matrix Container</h2>
- <h4>Description</h4>
- <p>The templated class <code>matrix_container<C></code>
- is required to be a public base of all classes which model the Matrix concept.
- This includes the class <code>matrix</code> itself.</p>
- <h4>Definition</h4>
- <p>Defined in the header expression_types.hpp.</p>
- <h4>Template parameters</h4>
- <table border="1" summary="parameters">
- <tbody>
- <tr>
- <th>Parameter</th>
- <th>Description</th>
- <th>Default</th>
- </tr>
- <tr>
- <td><code>E</code></td>
- <td>The type of the matrix expression.</td>
- <td> </td>
- </tr>
- </tbody>
- </table>
- <h4>Model of</h4>
- <p>None. <u>Not a Matrix Expression OR Matrix</u>!
- </p>
- <h4>Type requirements</h4>
- <p>None.</p>
- <h4>Public base classes</h4>
- <p><code>matrix_expression<C></code></p>
- <h4>Members</h4>
- <table border="1" summary="members">
- <tbody>
- <tr>
- <th>Member</th>
- <th>Description</th>
- </tr>
- <tr>
- <td><code>const container_type &operator () ()
- const</code></td>
- <td>Returns a <code>const</code> reference of the container.</td>
- </tr>
- <tr>
- <td><code>container_type &operator () ()</code></td>
- <td>Returns a reference of the container.</td>
- </tr>
- </tbody>
- </table>
- <h2><a name="matrix_references"></a>Matrix References</h2>
- <h3>Reference</h3>
- <h4>Description</h4>
- <p>The templated class <code>matrix_reference<E></code>
- contains a reference to a matrix expression.</p>
- <h4>Definition</h4>
- <p>Defined in the header matrix_expression.hpp.</p>
- <h4>Template parameters</h4>
- <table border="1" summary="parameters">
- <tbody>
- <tr>
- <th>Parameter</th>
- <th>Description</th>
- <th>Default</th>
- </tr>
- <tr>
- <td><code>E</code></td>
- <td>The type of the matrix expression.</td>
- <td> </td>
- </tr>
- </tbody>
- </table>
- <h4>Model of</h4>
- <p><a href="expression_concept.html#matrix_expression">Matrix Expression</a>
- .</p>
- <h4>Type requirements</h4>
- <p>None, except for those imposed by the requirements of <a href=
- "expression_concept.html#matrix_expression">Matrix Expression</a> .</p>
- <h4>Public base classes</h4>
- <p><code>matrix_expression<matrix_reference<E>
- ></code></p>
- <h4>Members</h4>
- <table border="1" summary="members">
- <tbody>
- <tr>
- <th>Member</th>
- <th>Description</th>
- </tr>
- <tr>
- <td><code>matrix_reference (expression_type &e)</code></td>
- <td>Constructs a constant reference of the expression.</td>
- </tr>
- <tr>
- <td><code>void resize (size_type size1, size2)</code></td>
- <td>Resizes the expression to hold at most <code>size1</code> rows
- of <code>size2</code> elements.</td>
- </tr>
- <tr>
- <td><code>size_type size1 () const</code></td>
- <td>Returns the number of rows.</td>
- </tr>
- <tr>
- <td><code>size_type size2 () const</code></td>
- <td>Returns the number of columns.</td>
- </tr>
- <tr>
- <td><code>const_reference operator () (size_type i, size_type j)
- const</code></td>
- <td>Returns the value of the <code>j</code>-th element in the
- <code>i</code>-th row.</td>
- </tr>
- <tr>
- <td><code>reference operator () (size_type i, size_type
- j)</code></td>
- <td>Returns a reference of the <code>j</code>-th element in the
- <code>i</code>-th row.</td>
- </tr>
- <tr>
- <td><code>const_iterator1 begin1 () const</code></td>
- <td>Returns a <code>const_iterator1</code> pointing to the
- beginning of the expression.</td>
- </tr>
- <tr>
- <td><code>const_iterator1 end1 () const</code></td>
- <td>Returns a <code>const_iterator1</code> pointing to the end of
- the expression.</td>
- </tr>
- <tr>
- <td><code>iterator1 begin1 ()</code></td>
- <td>Returns a <code>iterator1</code> pointing to the beginning of
- the expression.</td>
- </tr>
- <tr>
- <td><code>iterator1 end1 ()</code></td>
- <td>Returns a <code>iterator1</code> pointing to the end of the
- expression.</td>
- </tr>
- <tr>
- <td><code>const_iterator2 begin2 () const</code></td>
- <td>Returns a <code>const_iterator2</code> pointing to the
- beginning of the expression.</td>
- </tr>
- <tr>
- <td><code>const_iterator2 end2 () const</code></td>
- <td>Returns a <code>const_iterator2</code> pointing to the end of
- the expression.</td>
- </tr>
- <tr>
- <td><code>iterator2 begin2 ()</code></td>
- <td>Returns a <code>iterator2</code> pointing to the beginning of
- the expression.</td>
- </tr>
- <tr>
- <td><code>iterator2 end2 ()</code></td>
- <td>Returns a <code>iterator2</code> pointing to the end of the
- expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator1 rbegin1 () const</code></td>
- <td>Returns a <code>const_reverse_iterator1</code> pointing to the
- beginning of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator1 rend1 () const</code></td>
- <td>Returns a <code>const_reverse_iterator1</code> pointing to the
- end of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>reverse_iterator1 rbegin1 ()</code></td>
- <td>Returns a <code>reverse_iterator1</code> pointing to the
- beginning of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>reverse_iterator1 rend1 ()</code></td>
- <td>Returns a <code>reverse_iterator1</code> pointing to the end of
- the reversed expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator2 rbegin2 () const</code></td>
- <td>Returns a <code>const_reverse_iterator2</code> pointing to the
- beginning of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator2 rend2 () const</code></td>
- <td>Returns a <code>const_reverse_iterator2</code> pointing to the
- end of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>reverse_iterator2 rbegin2 ()</code></td>
- <td>Returns a <code>reverse_iterator2</code> pointing to the
- beginning of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>reverse_iterator2 rend2 ()</code></td>
- <td>Returns a <code>reverse_iterator2</code> pointing to the end of
- the reversed expression.</td>
- </tr>
- </tbody>
- </table>
- <h2><a name="matrix_operations"></a>Matrix Operations</h2>
- <h3>Unary Operation Description</h3>
- <h4>Description</h4>
- <p>The templated classes <code>matrix_unary1<E, F></code> and
- <code>matrix_unary2<E, F></code> describe unary matrix
- operations.</p>
- <h4>Definition</h4>
- <p>Defined in the header matrix_expression.hpp.</p>
- <h4>Template parameters</h4>
- <table border="1" summary="parameters">
- <tbody>
- <tr>
- <th>Parameter</th>
- <th>Description</th>
- <th>Default</th>
- </tr>
- <tr>
- <td><code>E</code></td>
- <td>The type of the matrix expression.</td>
- <td> </td>
- </tr>
- <tr>
- <td><code>F</code></td>
- <td>The type of the operation.</td>
- <td> </td>
- </tr>
- </tbody>
- </table>
- <h4>Model of</h4>
- <p><a href="expression_concept.html#matrix_expression">Matrix Expression</a>
- .</p>
- <h4>Type requirements</h4>
- <p>None, except for those imposed by the requirements of <a href=
- "expression_concept.html#matrix_expression">Matrix Expression</a> .</p>
- <h4>Public base classes</h4>
- <p><code>matrix_expression<matrix_unary1<E, F> ></code>
- and <code>matrix_expression<matrix_unary2<E, F>
- ></code> resp.</p>
- <h4>Members</h4>
- <table border="1" summary="members">
- <tbody>
- <tr>
- <th>Member</th>
- <th>Description</th>
- </tr>
- <tr>
- <td><code>matrix_unary1 (const expression_type &e)</code></td>
- <td>Constructs a description of the expression.</td>
- </tr>
- <tr>
- <td><code>matrix_unary2 (const expression_type &e)</code></td>
- <td>Constructs a description of the expression.</td>
- </tr>
- <tr>
- <td><code>size_type size1 () const</code></td>
- <td>Returns the number of rows.</td>
- </tr>
- <tr>
- <td><code>size_type size2 () const</code></td>
- <td>Returns the number of columns.</td>
- </tr>
- <tr>
- <td><code>const_reference operator () (size_type i, size_type j)
- const</code></td>
- <td>Returns the value of the <code>j</code>-th element in the
- <code>i</code>-th row.</td>
- </tr>
- <tr>
- <td><code>const_iterator1 begin1 () const</code></td>
- <td>Returns a <code>const_iterator1</code> pointing to the
- beginning of the expression.</td>
- </tr>
- <tr>
- <td><code>const_iterator1 end1 () const</code></td>
- <td>Returns a <code>const_iterator1</code> pointing to the end of
- the expression.</td>
- </tr>
- <tr>
- <td><code>const_iterator2 begin2 () const</code></td>
- <td>Returns a <code>const_iterator2</code> pointing to the
- beginning of the expression.</td>
- </tr>
- <tr>
- <td><code>const_iterator2 end2 () const</code></td>
- <td>Returns a <code>const_iterator2</code> pointing to the end of
- the expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator1 rbegin1 () const</code></td>
- <td>Returns a <code>const_reverse_iterator1</code> pointing to the
- beginning of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator1 rend1 () const</code></td>
- <td>Returns a <code>const_reverse_iterator1</code> pointing to the
- end of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator2 rbegin2 () const</code></td>
- <td>Returns a <code>const_reverse_iterator2</code> pointing to the
- beginning of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator2 rend2 () const</code></td>
- <td>Returns a <code>const_reverse_iterator2</code> pointing to the
- end of the reversed expression.</td>
- </tr>
- </tbody>
- </table>
- <h3>Unary Operations</h3>
- <h4>Prototypes</h4>
- <pre>
- <code>template<class E, class F>
- struct matrix_unary1_traits {
- typedef matrix_unary1<typename E::const_closure_type, F> expression_type;
- typedef expression_type result_type;
- };
- // (- m) [i] [j] = - m [i] [j]
- template<class E>
- typename matrix_unary1_traits<E, scalar_negate<typename E::value_type> >::result_type
- operator - (const matrix_expression<E> &e);
- // (conj m) [i] [j] = conj (m [i] [j])
- template<class E>
- typename matrix_unary1_traits<E, scalar_conj<typename E::value_type> >::result_type
- conj (const matrix_expression<E> &e);
- // (real m) [i] [j] = real (m [i] [j])
- template<class E>
- typename matrix_unary1_traits<E, scalar_real<typename E::value_type> >::result_type
- real (const matrix_expression<E> &e);
- // (imag m) [i] [j] = imag (m [i] [j])
- template<class E>
- typename matrix_unary1_traits<E, scalar_imag<typename E::value_type> >::result_type
- imag (const matrix_expression<E> &e);
- template<class E, class F>
- struct matrix_unary2_traits {
- typedef matrix_unary2<typename E::const_closure_type, F> expression_type;
- typedef expression_type result_type;
- };
- // (trans m) [i] [j] = m [j] [i]
- template<class E>
- typename matrix_unary2_traits<E, scalar_identity<typename E::value_type> >::result_type
- trans (const matrix_expression<E> &e);
- // (herm m) [i] [j] = conj (m [j] [i])
- template<class E>
- typename matrix_unary2_traits<E, scalar_conj<typename E::value_type> >::result_type
- herm (const matrix_expression<E> &e);</code>
- </pre>
- <h4>Description</h4>
- <p><code>operator -</code> computes the additive inverse of a
- matrix expression. <code>conj</code> computes the complex conjugate
- of a matrix expression. <code>real</code> and <code>imag</code>
- compute the real and imaginary parts of a matrix expression.
- <code>trans</code> computes the transpose of a matrix expression.
- <code>herm</code> computes the hermitian, i.e. the complex
- conjugate of the transpose of a matrix expression.</p>
- <h4>Definition</h4>
- <p>Defined in the header matrix_expression.hpp.</p>
- <h4>Type requirements</h4>
- <ul>
- <li><code>E</code> is a model of <a href=
- "expression_concept.html#matrix_expression">Matrix Expression</a> .</li>
- </ul>
- <h4>Preconditions</h4>
- <p>None.</p>
- <h4>Complexity</h4>
- <p>Quadratic depending from the size of the matrix expression.</p>
- <h4>Examples</h4>
- <pre>
- #include <boost/numeric/ublas/matrix.hpp>
- #include <boost/numeric/ublas/io.hpp>
- int main () {
- using namespace boost::numeric::ublas;
- matrix<std::complex<double> > m (3, 3);
- for (unsigned i = 0; i < m.size1 (); ++ i)
- for (unsigned j = 0; j < m.size2 (); ++ j)
- m (i, j) = std::complex<double> (3 * i + j, 3 * i + j);
- std::cout << - m << std::endl;
- std::cout << conj (m) << std::endl;
- std::cout << real (m) << std::endl;
- std::cout << imag (m) << std::endl;
- std::cout << trans (m) << std::endl;
- std::cout << herm (m) << std::endl;
- }
- </pre>
- <h3>Binary Operation Description</h3>
- <h4>Description</h4>
- <p>The templated class <code>matrix_binary<E1, E2, F></code>
- describes a binary matrix operation.</p>
- <h4>Definition</h4>
- <p>Defined in the header matrix_expression.hpp.</p>
- <h4>Template parameters</h4>
- <table border="1" summary="parameters">
- <tbody>
- <tr>
- <th>Parameter</th>
- <th>Description</th>
- <th>Default</th>
- </tr>
- <tr>
- <td><code>E1</code></td>
- <td>The type of the first matrix expression.</td>
- <td></td>
- </tr>
- <tr>
- <td><code>E2</code></td>
- <td>The type of the second matrix expression.</td>
- <td></td>
- </tr>
- <tr>
- <td><code>F</code></td>
- <td>The type of the operation.</td>
- <td></td>
- </tr>
- </tbody>
- </table>
- <h4>Model of</h4>
- <p><a href="expression_concept.html#matrix_expression">Matrix Expression</a>
- .</p>
- <h4>Type requirements</h4>
- <p>None, except for those imposed by the requirements of <a href=
- "expression_concept.html#matrix_expression">Matrix Expression</a> .</p>
- <h4>Public base classes</h4>
- <p><code>matrix_expression<matrix_binary<E1, E2, F>
- ></code>.</p>
- <h4>Members</h4>
- <table border="1" summary="members">
- <tbody>
- <tr>
- <th>Member</th>
- <th>Description</th>
- </tr>
- <tr>
- <td><code>matrix_binary (const expression1_type &e1, const
- expression2_type &e2)</code></td>
- <td>Constructs a description of the expression.</td>
- </tr>
- <tr>
- <td><code>size_type size1 () const</code></td>
- <td>Returns the number of rows.</td>
- </tr>
- <tr>
- <td><code>size_type size2 () const</code></td>
- <td>Returns the number of columns.</td>
- </tr>
- <tr>
- <td><code>const_reference operator () (size_type i, size_type j)
- const</code></td>
- <td>Returns the value of the <code>j</code>-th element in the
- <code>i</code>-th row.</td>
- </tr>
- <tr>
- <td><code>const_iterator1 begin1 () const</code></td>
- <td>Returns a <code>const_iterator1</code> pointing to the
- beginning of the expression.</td>
- </tr>
- <tr>
- <td><code>const_iterator1 end1 () const</code></td>
- <td>Returns a <code>const_iterator1</code> pointing to the end of
- the expression.</td>
- </tr>
- <tr>
- <td><code>const_iterator2 begin2 () const</code></td>
- <td>Returns a <code>const_iterator2</code> pointing to the
- beginning of the expression.</td>
- </tr>
- <tr>
- <td><code>const_iterator2 end2 () const</code></td>
- <td>Returns a <code>const_iterator2</code> pointing to the end of
- the expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator1 rbegin1 () const</code></td>
- <td>Returns a <code>const_reverse_iterator1</code> pointing to the
- beginning of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator1 rend1 () const</code></td>
- <td>Returns a <code>const_reverse_iterator1</code> pointing to the
- end of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator2 rbegin2 () const</code></td>
- <td>Returns a <code>const_reverse_iterator2</code> pointing to the
- beginning of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator2 rend2 () const</code></td>
- <td>Returns a <code>const_reverse_iterator2</code> pointing to the
- end of the reversed expression.</td>
- </tr>
- </tbody>
- </table>
- <h3>Binary Operations</h3>
- <h4>Prototypes</h4>
- <pre>
- <code>template<class E1, class E2, class F>
- struct matrix_binary_traits {
- typedef matrix_binary<typename E1::const_closure_type,
- typename E2::const_closure_type, F> expression_type;
- typedef expression_type result_type;
- };
- // (m1 + m2) [i] [j] = m1 [i] [j] + m2 [i] [j]
- template<class E1, class E2>
- typename matrix_binary_traits<E1, E2, scalar_plus<typename E1::value_type,
- typename E2::value_type> >::result_type
- operator + (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2);
- // (m1 - m2) [i] [j] = m1 [i] [j] - m2 [i] [j]
- template<class E1, class E2>
- typename matrix_binary_traits<E1, E2, scalar_minus<typename E1::value_type,
- typename E2::value_type> >::result_type
- operator - (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2);</code>
- </pre>
- <h4>Description</h4>
- <p><code>operator +</code> computes the sum of two matrix
- expressions. <code>operator -</code> computes the difference of two
- matrix expressions.</p>
- <h4>Definition</h4>
- <p>Defined in the header matrix_expression.hpp.</p>
- <h4>Type requirements</h4>
- <ul>
- <li><code>E1</code> is a model of <a href=
- "expression_concept.html#matrix_expression">Matrix Expression</a> .</li>
- <li><code>E2</code> is a model of <a href=
- "expression_concept.html#matrix_expression">Matrix Expression</a> .</li>
- </ul>
- <h4>Preconditions</h4>
- <ul>
- <li><code>e1 ().size1 () == e2 ().size1 ()</code></li>
- <li><code>e1 ().size2 () == e2 ().size2 ()</code></li>
- </ul>
- <h4>Complexity</h4>
- <p>Quadratic depending from the size of the matrix expressions.</p>
- <h4>Examples</h4>
- <pre>
- #include <boost/numeric/ublas/matrix.hpp>
- #include <boost/numeric/ublas/io.hpp>
- int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m1 (3, 3), m2 (3, 3);
- for (unsigned i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i)
- for (unsigned j = 0; j < std::min (m1.size2 (), m2.size2 ()); ++ j)
- m1 (i, j) = m2 (i, j) = 3 * i + j;
- std::cout << m1 + m2 << std::endl;
- std::cout << m1 - m2 << std::endl;
- }
- </pre>
- <h3>Scalar Matrix Operation Description</h3>
- <h4>Description</h4>
- <p>The templated classes <code>matrix_binary_scalar1<E1, E2,
- F></code> and <code>matrix_binary_scalar2<E1, E2,
- F></code> describe binary operations between a scalar and a
- matrix.</p>
- <h4>Definition</h4>
- <p>Defined in the header matrix_expression.hpp.</p>
- <h4>Template parameters</h4>
- <table border="1" summary="parameters">
- <tbody>
- <tr>
- <th>Parameter</th>
- <th>Description</th>
- <th>Default</th>
- </tr>
- <tr>
- <td><code>E1/E2</code></td>
- <td>The type of the scalar expression.</td>
- <td></td>
- </tr>
- <tr>
- <td><code>E2/E1</code></td>
- <td>The type of the matrix expression.</td>
- <td></td>
- </tr>
- <tr>
- <td><code>F</code></td>
- <td>The type of the operation.</td>
- <td></td>
- </tr>
- </tbody>
- </table>
- <h4>Model of</h4>
- <p><a href="expression_concept.html#matrix_expression">Matrix Expression</a>
- .</p>
- <h4>Type requirements</h4>
- <p>None, except for those imposed by the requirements of <a href=
- "expression_concept.html#matrix_expression">Matrix Expression</a> .</p>
- <h4>Public base classes</h4>
- <p><code>matrix_expression<matrix_binary_scalar1<E1, E2,
- F> ></code> and
- <code>matrix_expression<matrix_binary_scalar2<E1, E2, F>
- ></code> resp.</p>
- <h4>Members</h4>
- <table border="1" summary="members">
- <tbody>
- <tr>
- <th>Member</th>
- <th>Description</th>
- </tr>
- <tr>
- <td><code>matrix_binary_scalar1 (const expression1_type &e1,
- const expression2_type &e2)</code></td>
- <td>Constructs a description of the expression.</td>
- </tr>
- <tr>
- <td><code>matrix_binary_scalar1 (const expression1_type &e1,
- const expression2_type &e2)</code></td>
- <td>Constructs a description of the expression.</td>
- </tr>
- <tr>
- <td><code>size_type size1 () const</code></td>
- <td>Returns the number of rows.</td>
- </tr>
- <tr>
- <td><code>size_type size2 () const</code></td>
- <td>Returns the number of columns.</td>
- </tr>
- <tr>
- <td><code>const_reference operator () (size_type i, size_type j)
- const</code></td>
- <td>Returns the value of the <code>j</code>-th element in the
- <code>i</code>-th row.</td>
- </tr>
- <tr>
- <td><code>const_iterator1 begin1 () const</code></td>
- <td>Returns a <code>const_iterator1</code> pointing to the
- beginning of the expression.</td>
- </tr>
- <tr>
- <td><code>const_iterator1 end1 () const</code></td>
- <td>Returns a <code>const_iterator1</code> pointing to the end of
- the expression.</td>
- </tr>
- <tr>
- <td><code>const_iterator2 begin2 () const</code></td>
- <td>Returns a <code>const_iterator2</code> pointing to the
- beginning of the expression.</td>
- </tr>
- <tr>
- <td><code>const_iterator2 end2 () const</code></td>
- <td>Returns a <code>const_iterator2</code> pointing to the end of
- the expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator1 rbegin1 () const</code></td>
- <td>Returns a <code>const_reverse_iterator1</code> pointing to the
- beginning of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator1 rend1 () const</code></td>
- <td>Returns a <code>const_reverse_iterator1</code> pointing to the
- end of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator2 rbegin2 () const</code></td>
- <td>Returns a <code>const_reverse_iterator2</code> pointing to the
- beginning of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator2 rend2 () const</code></td>
- <td>Returns a <code>const_reverse_iterator2</code> pointing to the
- end of the reversed expression.</td>
- </tr>
- </tbody>
- </table>
- <h3>Scalar Matrix Operations</h3>
- <h4>Prototypes</h4>
- <pre>
- <code>template<class T1, class E2, class F>
- struct matrix_binary_scalar1_traits {
- typedef matrix_binary_scalar1<scalar_const_reference<T1>,
- typename E2::const_closure_type, F> expression_type;
- typedef expression_type result_type;
- };
- // (t * m) [i] [j] = t * m [i] [j]
- template<class T1, class E2>
- typename matrix_binary_scalar1_traits<T1, E2, scalar_multiplies<T1, typename E2::value_type> >::result_type
- operator * (const T1 &e1,
- const matrix_expression<E2> &e2);
- template<class E1, class T2, class F>
- struct matrix_binary_scalar2_traits {
- typedef matrix_binary_scalar2<typename E1::const_closure_type,
- scalar_const_reference<T2>, F> expression_type;
- typedef expression_type result_type;
- };
- // (m * t) [i] [j] = m [i] [j] * t
- template<class E1, class T2>
- typename matrix_binary_scalar2_traits<E1, T2, scalar_multiplies<typename E1::value_type, T2> >::result_type
- operator * (const matrix_expression<E1> &e1,
- const T2 &e2);
- // (m / t) [i] [j] = m [i] [j] / t
- template<class E1, class T2>
- typename matrix_binary_scalar2_traits<E1, T2, scalar_divides<typename E1::value_type, T2> >::result_type
- operator / (const matrix_expression<E1> &e1,
- const T2 &e2);</code>
- </pre>
- <h4>Description</h4>
- <p><code>operator *</code> computes the product of a scalar and a
- matrix expression. <code>operator /</code> multiplies the matrix
- with the reciprocal of the scalar.</p>
- <h4>Definition</h4>
- <p>Defined in the header matrix_expression.hpp.</p>
- <h4>Type requirements</h4>
- <ul>
- <li><code>T1/T2</code> is a model of <a href=
- "expression_concept.html#scalar_expression">Scalar Expression</a> .</li>
- <li><code>E2/E1</code> is a model of <a href=
- "expression_concept.html#matrix_expression">Matrix Expression</a> .</li>
- </ul>
- <h4>Preconditions</h4>
- <p>None.</p>
- <h4>Complexity</h4>
- <p>Quadratic depending from the size of the matrix expression.</p>
- <h4>Examples</h4>
- <pre>
- #include <boost/numeric/ublas/matrix.hpp>
- #include <boost/numeric/ublas/io.hpp>
- int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- for (unsigned i = 0; i < m.size1 (); ++ i)
- for (unsigned j = 0; j < m.size2 (); ++ j)
- m (i, j) = 3 * i + j;
- std::cout << 2.0 * m << std::endl;
- std::cout << m * 2.0 << std::endl;
- }
- </pre>
- <h2><a name="matrix_vector_operations"></a>Matrix Vector Operations</h2>
- <h3>Binary Operation Description</h3>
- <h4>Description</h4>
- <p>The templated classes <code>matrix_vector_binary1<E1, E2,
- F></code> and <code>matrix_vector_binary2<E1, E2,
- F></code> describe binary matrix vector operations.</p>
- <h4>Definition</h4>
- <p>Defined in the header matrix_expression.hpp.</p>
- <h4>Template parameters</h4>
- <table border="1" summary="parameters">
- <tbody>
- <tr>
- <th>Parameter</th>
- <th>Description</th>
- <th>Default</th>
- </tr>
- <tr>
- <td><code>E1</code></td>
- <td>The type of the matrix or vector expression.</td>
- <td></td>
- </tr>
- <tr>
- <td><code>E2</code></td>
- <td>The type of the vector or matrix expression.</td>
- <td></td>
- </tr>
- <tr>
- <td><code>F</code></td>
- <td>The type of the operation.</td>
- <td></td>
- </tr>
- </tbody>
- </table>
- <h4>Model of</h4>
- <p><a href="expression_concept.html#vector_expression">Vector Expression</a>
- .</p>
- <h4>Type requirements</h4>
- <p>None, except for those imposed by the requirements of <a href=
- "expression_concept.html#vector_expression">Vector Expression</a> .</p>
- <h4>Public base classes</h4>
- <p><code>vector_expression<matrix_vector_binary1<E1, E2,
- F> ></code> and
- <code>vector_expression<matrix_vector_binary2<E1, E2, F>
- ></code> resp.</p>
- <h4>Members</h4>
- <table border="1" summary="members">
- <tbody>
- <tr>
- <th>Member</th>
- <th>Description</th>
- </tr>
- <tr>
- <td><code>matrix_vector_binary1 (const expression1_type &e1,
- const expression2_type &e2)</code></td>
- <td>Constructs a description of the expression.</td>
- </tr>
- <tr>
- <td><code>matrix_vector_binary2 (const expression1_type &e1,
- const expression2_type &e2)</code></td>
- <td>Constructs a description of the expression.</td>
- </tr>
- <tr>
- <td><code>size_type size () const</code></td>
- <td>Returns the size of the expression.</td>
- </tr>
- <tr>
- <td><code>const_reference operator () (size_type i)
- const</code></td>
- <td>Returns the value of the <code>i</code>-th element.</td>
- </tr>
- <tr>
- <td><code>const_iterator begin () const</code></td>
- <td>Returns a <code>const_iterator</code> pointing to the beginning
- of the expression.</td>
- </tr>
- <tr>
- <td><code>const_iterator end () const</code></td>
- <td>Returns a <code>const_iterator</code> pointing to the end of
- the expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator rbegin () const</code></td>
- <td>Returns a <code>const_reverse_iterator</code> pointing to the
- beginning of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator rend () const</code></td>
- <td>Returns a <code>const_reverse_iterator</code> pointing to the
- end of the reversed expression.</td>
- </tr>
- </tbody>
- </table>
- <h3>Binary Operations</h3>
- <h4>Prototypes</h4>
- <pre>
- <code>template<class T1, class E1, class T2, class E2>
- struct matrix_vector_binary1_traits {
- typedef row_major_tag dispatch_category;
- typedef typename promote_traits<T1, T2>::promote_type promote_type;
- typedef matrix_vector_binary1<typename E1::const_closure_type,
- typename E2::const_closure_type,
- matrix_vector_prod1<T1, T2, promote_type> > expression_type;
- typedef expression_type result_type;
- };
- template<class E1, class E2>
- typename matrix_vector_binary1_traits<typename E1::value_type, E1,
- typename E2::value_type, E2>::result_type
- prod (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2,
- row_major_tag);
- // Dispatcher
- template<class E1, class E2>
- typename matrix_vector_binary1_traits<typename E1::value_type, E1,
- typename E2::value_type, E2>::result_type
- prod (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2);
- template<class E1, class E2>
- typename matrix_vector_binary1_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
- typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
- prec_prod (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2,
- row_major_tag);
- // Dispatcher
- template<class E1, class E2>
- typename matrix_vector_binary1_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
- typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
- prec_prod (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2);
- template<class V, class E1, class E2>
- V
- prod (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2);
- template<class V, class E1, class E2>
- V
- prec_prod (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2);
- template<class T1, class E1, class T2, class E2>
- struct matrix_vector_binary2_traits {
- typedef column_major_tag dispatch_category;
- typedef typename promote_traits<T1, T2>::promote_type promote_type;
- typedef matrix_vector_binary2<typename E1::const_closure_type,
- typename E2::const_closure_type,
- matrix_vector_prod2<T1, T2, promote_type> > expression_type;
- typedef expression_type result_type;
- };
- template<class E1, class E2>
- typename matrix_vector_binary2_traits<typename E1::value_type, E1,
- typename E2::value_type, E2>::result_type
- prod (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2,
- column_major_tag);
- // Dispatcher
- template<class E1, class E2>
- typename matrix_vector_binary2_traits<typename E1::value_type, E1,
- typename E2::value_type, E2>::result_type
- prod (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2);
- template<class E1, class E2>
- typename matrix_vector_binary2_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
- typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
- prec_prod (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2,
- column_major_tag);
- // Dispatcher
- template<class E1, class E2>
- typename matrix_vector_binary2_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
- typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
- prec_prod (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2);
- template<class V, class E1, class E2>
- V
- prod (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2);
- template<class V, class E1, class E2>
- V
- prec_prod (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2);</code>
- </pre>
- <h4>Description</h4>
- <p><code>prod</code> computes the product of the matrix and the
- vector expression. <code>prec_prod</code> computes the double
- precision product of the matrix and the vector expression.</p>
- <h4>Definition</h4>
- <p>Defined in the header matrix_expression.hpp.</p>
- <h4>Type requirements</h4>
- <ul>
- <li><code>E1</code> is a model of <a href=
- "expression_concept.html#matrix_expression">Matrix Expression</a> or
- <a href="expression_concept.html#vector_expression">Vector Expression</a>
- .</li>
- <li><code>E2</code> is a model of <a href=
- "expression_concept.html#vector_expression">Vector Expression</a> or
- <a href="expression_concept.html#matrix_expression">Matrix Expression</a>
- .</li>
- </ul>
- <h4>Preconditions</h4>
- <ul>
- <li><code>e1 ().size2 () == e2 ().size ()</code></li>
- <li><code>e1 ().size () == e2 ().size1 ()</code></li>
- </ul>
- <h4>Complexity</h4>
- <p>Quadratic depending from the size of the matrix expression.</p>
- <h4>Examples</h4>
- <pre>
- #include <boost/numeric/ublas/matrix.hpp>
- #include <boost/numeric/ublas/io.hpp>
- int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- vector<double> v (3);
- for (unsigned i = 0; i < std::min (m.size1 (), v.size ()); ++ i) {
- for (unsigned j = 0; j < m.size2 (); ++ j)
- m (i, j) = 3 * i + j;
- v (i) = i;
- }
- std::cout << prod (m, v) << std::endl;
- std::cout << prod (v, m) << std::endl;
- }
- </pre>
- <h3>Triangular Solver</h3>
- <h4>Prototypes</h4>
- <pre>
- <code>template<class E1, class E2>
- struct matrix_vector_solve_traits {
- typedef typename promote_traits<typename E1::value_type, typename E2::value_type>::promote_type promote_type;
- typedef vector<promote_type> result_type;
- };
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- lower_tag,
- vector_tag);
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- upper_tag,
- vector_tag);
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- unit_lower_tag,
- vector_tag);
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- unit_upper_tag,
- vector_tag);
- template<class E1, class E2, class C>
- typename matrix_vector_solve_traits<E1, E2>::result_type
- solve (const matrix_expression<E1> &e1,
- const vector_expression<E2> &e2,
- C);
- template<class E1, class E2>
- void inplace_solve (E1 &e1,
- const matrix_expression<E2> &e2,
- vector_tag,
- lower_tag);
- template<class E1, class E2>
- void inplace_solve (E1 &e1,
- const matrix_expression<E2> &e2,
- vector_tag,
- upper_tag);
- template<class E1, class E2>
- void inplace_solve (E1 &e1,
- const matrix_expression<E2> &e2,
- vector_tag,
- unit_lower_tag);
- template<class E1, class E2>
- void inplace_solve (E1 &e1,
- const matrix_expression<E2> &e2,
- vector_tag,
- unit_upper_tag);
- template<class E1, class E2, class C>
- typename matrix_vector_solve_traits<E1, E2>::result_type
- solve (const vector_expression<E1> &e1,
- const matrix_expression<E2> &e2,
- C);</code>
- </pre>
- <h4>Description</h4>
- <p><code>solve</code> solves a linear equation for lower or upper
- (unit) triangular matrices.</p>
- <h4>Definition</h4>
- <p>Defined in the header triangular.hpp.</p>
- <h4>Type requirements</h4>
- <ul>
- <li><code>E1</code> is a model of <a href=
- "expression_concept.html#matrix_expression">Matrix Expression</a> or
- <a href="expression_concept.html#vector_expression">Vector Expression</a>
- .</li>
- <li><code>E2</code> is a model of <a href=
- "expression_concept.html#vector_expression">Vector Expression</a> or
- <a href="expression_concept.html#matrix_expression">Matrix Expression</a>
- .</li>
- </ul>
- <h4>Preconditions</h4>
- <ul>
- <li><code>e1 ().size1 () == e1 ().size2 ()</code></li>
- <li><code>e1 ().size2 () == e2 ().size ()</code></li>
- <li><code>e1 ().size () == e2 ().size1 ()</code></li>
- <li><code>e2 ().size1 () == e2 ().size2 ()</code></li>
- </ul>
- <h4>Complexity</h4>
- <p>Quadratic depending from the size of the matrix expression.</p>
- <h4>Examples</h4>
- <pre>
- #include <boost/numeric/ublas/triangular.hpp>
- #include <boost/numeric/ublas/io.hpp>
- int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m (3, 3);
- vector<double> v (3);
- for (unsigned i = 0; i < std::min (m.size1 (), v.size ()); ++ i) {
- for (unsigned j = 0; j <= i; ++ j)
- m (i, j) = 3 * i + j + 1;
- v (i) = i;
- }
- std::cout << solve (m, v, lower_tag ()) << std::endl;
- std::cout << solve (v, m, lower_tag ()) << std::endl;
- }
- </pre>
- <h2><a name="matrix_matrix_operations"></a>Matrix Matrix Operations</h2>
- <h3>Binary Operation Description</h3>
- <h4>Description</h4>
- <p>The templated class <code>matrix_matrix_binary<E1, E2,
- F></code> describes a binary matrix operation.</p>
- <h4>Definition</h4>
- <p>Defined in the header matrix_expression.hpp.</p>
- <h4>Template parameters</h4>
- <table border="1" summary="parameters">
- <tbody>
- <tr>
- <th>Parameter</th>
- <th>Description</th>
- <th>Default</th>
- </tr>
- <tr>
- <td><code>E1</code></td>
- <td>The type of the first matrix expression.</td>
- <td></td>
- </tr>
- <tr>
- <td><code>E2</code></td>
- <td>The type of the second matrix expression.</td>
- <td></td>
- </tr>
- <tr>
- <td><code>F</code></td>
- <td>The type of the operation.</td>
- <td></td>
- </tr>
- </tbody>
- </table>
- <h4>Model of</h4>
- <p><a href="expression_concept.html#matrix_expression">Matrix Expression</a>
- .</p>
- <h4>Type requirements</h4>
- <p>None, except for those imposed by the requirements of <a href=
- "expression_concept.html#matrix_expression">Matrix Expression</a> .</p>
- <h4>Public base classes</h4>
- <p><code>matrix_expression<matrix_matrix_binary<E1, E2, F>
- ></code> .</p>
- <h4>Members</h4>
- <table border="1" summary="members">
- <tbody>
- <tr>
- <th>Member</th>
- <th>Description</th>
- </tr>
- <tr>
- <td><code>matrix_matrix_binary (const expression1_type &e1,
- const expression2_type &e2)</code></td>
- <td>Constructs a description of the expression.</td>
- </tr>
- <tr>
- <td><code>size_type size1 () const</code></td>
- <td>Returns the number of rows.</td>
- </tr>
- <tr>
- <td><code>size_type size2 () const</code></td>
- <td>Returns the number of columns.</td>
- </tr>
- <tr>
- <td><code>const_reference operator () (size_type i, size_type j)
- const</code></td>
- <td>Returns the value of the <code>j</code>-th element in the
- <code>i</code>-th row.</td>
- </tr>
- <tr>
- <td><code>const_iterator1 begin1 () const</code></td>
- <td>Returns a <code>const_iterator1</code> pointing to the
- beginning of the expression.</td>
- </tr>
- <tr>
- <td><code>const_iterator1 end1 () const</code></td>
- <td>Returns a <code>const_iterator1</code> pointing to the end of
- the expression.</td>
- </tr>
- <tr>
- <td><code>const_iterator2 begin2 () const</code></td>
- <td>Returns a <code>const_iterator2</code> pointing to the
- beginning of the expression.</td>
- </tr>
- <tr>
- <td><code>const_iterator2 end2 () const</code></td>
- <td>Returns a <code>const_iterator2</code> pointing to the end of
- the expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator1 rbegin1 () const</code></td>
- <td>Returns a <code>const_reverse_iterator1</code> pointing to the
- beginning of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator1 rend1 () const</code></td>
- <td>Returns a <code>const_reverse_iterator1</code> pointing to the
- end of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator2 rbegin2 () const</code></td>
- <td>Returns a <code>const_reverse_iterator2</code> pointing to the
- beginning of the reversed expression.</td>
- </tr>
- <tr>
- <td><code>const_reverse_iterator2 rend2 () const</code></td>
- <td>Returns a <code>const_reverse_iterator2</code> pointing to the
- end of the reversed expression.</td>
- </tr>
- </tbody>
- </table>
- <h3>Binary Operations</h3>
- <h4>Prototypes</h4>
- <pre>
- <code>template<class T1, class E1, class T2, class E2>
- struct matrix_matrix_binary_traits {
- typedef unknown_orientation_tag dispatch_category;
- typedef typename promote_traits<T1, T2>::promote_type promote_type;
- typedef matrix_matrix_binary<typename E1::const_closure_type,
- typename E2::const_closure_type,
- matrix_matrix_prod<T1, T2, promote_type> > expression_type;
- typedef expression_type result_type;
- };
- template<class E1, class E2>
- typename matrix_matrix_binary_traits<typename E1::value_type, E1,
- typename E2::value_type, E2>::result_type
- prod (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2,
- unknown_orientation_tag);
- // Dispatcher
- template<class E1, class E2>
- typename matrix_matrix_binary_traits<typename E1::value_type, E1,
- typename E2::value_type, E2>::result_type
- prod (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2);
- template<class E1, class E2>
- typename matrix_matrix_binary_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
- typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
- prec_prod (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2,
- unknown_orientation_tag);
- // Dispatcher
- template<class E1, class E2>
- typename matrix_matrix_binary_traits<typename type_traits<typename E1::value_type>::precision_type, E1,
- typename type_traits<typename E2::value_type>::precision_type, E2>::result_type
- prec_prod (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2);
- template<class M, class E1, class E2>
- M
- prod (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2);
- template<class M, class E1, class E2>
- M
- prec_prod (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2);</code>
- </pre>
- <h4>Description</h4>
- <p><code>prod</code> computes the product of the matrix
- expressions. <code>prec_prod</code> computes the double precision
- product of the matrix expressions.</p>
- <h4>Definition</h4>
- <p>Defined in the header matrix_expression.hpp.</p>
- <h4>Type requirements</h4>
- <ul>
- <li><code>E1</code> is a model of <a href=
- "expression_concept.html#matrix_expression">Matrix Expression</a> .</li>
- <li><code>E2</code> is a model of <a href=
- "expression_concept.html#matrix_expression">Matrix Expression</a> .</li>
- </ul>
- <h4>Preconditions</h4>
- <ul>
- <li><code>e1 ().size2 () == e2 ().size1 ()</code></li>
- </ul>
- <h4>Complexity</h4>
- <p>Cubic depending from the size of the matrix expression.</p>
- <h4>Examples</h4>
- <pre>
- #include <boost/numeric/ublas/matrix.hpp>
- #include <boost/numeric/ublas/io.hpp>
- int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m1 (3, 3), m2 (3, 3);
- for (unsigned i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i)
- for (unsigned j = 0; j < std::min (m1.size2 (), m2.size2 ()); ++ j)
- m1 (i, j) = m2 (i, j) = 3 * i + j;
- std::cout << prod (m1, m2) << std::endl;
- }
- </pre>
- <h3>Triangular Solvers</h3>
- <h4>Prototypes</h4>
- <pre>
- <code>template<class E1, class E2>
- struct matrix_matrix_solve_traits {
- typedef typename promote_traits<typename E1::value_type, typename E2::value_type>::promote_type promote_type;
- typedef matrix<promote_type> result_type;
- };
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- lower_tag,
- matrix_tag);
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- upper_tag,
- matrix_tag);
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- unit_lower_tag,
- matrix_tag);
- template<class E1, class E2>
- void inplace_solve (const matrix_expression<E1> &e1,
- E2 &e2,
- unit_upper_tag,
- matrix_tag);
- template<class E1, class E2, class C>
- typename matrix_matrix_solve_traits<E1, E2>::result_type
- solve (const matrix_expression<E1> &e1,
- const matrix_expression<E2> &e2,
- C);</code>
- </pre>
- <h4>Description</h4>
- <p><code>solve</code> solves a linear equation for lower or upper
- (unit) triangular matrices.</p>
- <h4>Definition</h4>
- <p>Defined in the header triangular.hpp.</p>
- <h4>Type requirements</h4>
- <ul>
- <li><code>E1</code> is a model of <a href=
- "expression_concept.html#matrix_expression">Matrix Expression</a> .</li>
- <li><code>E2</code> is a model of <a href=
- "expression_concept.html#matrix_expression">Matrix Expression</a> .</li>
- </ul>
- <h4>Preconditions</h4>
- <ul>
- <li><code>e1 ().size1 () == e1 ().size2 ()</code></li>
- <li><code>e1 ().size2 () == e2 ().size1 ()</code></li>
- </ul>
- <h4>Complexity</h4>
- <p>Cubic depending from the size of the matrix expressions.</p>
- <h4>Examples</h4>
- <pre>
- #include <boost/numeric/ublas/triangular.hpp>
- #include <boost/numeric/ublas/io.hpp>
- int main () {
- using namespace boost::numeric::ublas;
- matrix<double> m1 (3, 3), m2 (3, 3);
- for (unsigned i = 0; i < std::min (m1.size1 (), m2.size1 ()); ++ i)
- for (unsigned j = 0; j <= i; ++ j)
- m1 (i, j) = m2 (i, j) = 3 * i + j + 1;
- std::cout << solve (m1, m2, lower_tag ()) << std::endl;
- }
- </pre>
- <hr />
- <p>Copyright (©) 2000-2002 Joerg Walter, Mathias Koch<br />
- Use, modification and distribution are subject to the
- Boost Software License, Version 1.0.
- (See accompanying file LICENSE_1_0.txt
- or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
- http://www.boost.org/LICENSE_1_0.txt
- </a>).
- </p>
- <script type="text/javascript">
- (function($) {
- $('#toc').toc();
- })(jQuery);
- </script>
- </body>
- </html>
|