annotate armadillo-2.4.4/docs/index.html @ 36:cc18e9a13fe8 slimline

Fix failure to set hasTimestamp on final part
author Chris Cannam
date Wed, 16 May 2012 11:44:39 +0100
parents 8b6102e2a9b0
children
rev   line source
max@0 1 <!-- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -->
max@0 2 <html>
max@0 3 <head>
max@0 4 <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
max@0 5 <title>Armadillo: C++ linear algebra library</title>
max@0 6 <link type="text/css" rel="stylesheet" href="style.css">
max@0 7 <link rel="icon" href="armadillo_icon.png" type="image/png">
max@0 8 </head>
max@0 9 <body>
max@0 10 <center>
max@0 11 <table style="text-align: left; width: 80%; margin-left: auto; margin-right: auto;" border="0" cellpadding="0" cellspacing="0">
max@0 12 <tbody>
max@0 13 <tr>
max@0 14 <td style="vertical-align: top;">
max@0 15
max@0 16 <table style="text-align: left; width: 100%;" border="0" cellpadding="0" cellspacing="0">
max@0 17 <tbody>
max@0 18 <tr>
max@0 19 <td style="text-align: left; vertical-align: top;">
max@0 20 <font size=+2><b>Reference for Armadillo 2.4.4</b></font>
max@0 21 <br>
max@0 22 <font size=-1><b>(Loco Lounge Lizard)</b></font>
max@0 23 </td>
max@0 24 <td style="text-align: right; vertical-align: top;">
max@0 25 <b><a href="http://arma.sourceforge.net">to Armadillo home page</a></b>
max@0 26 <br>
max@0 27 <b><a href="http://nicta.com.au">to NICTA home page</a></b>
max@0 28 </td>
max@0 29 </tr>
max@0 30 </tbody>
max@0 31 </table>
max@0 32 <hr>
max@0 33 <br>
max@0 34 <br>
max@0 35 <a name="top"></a>
max@0 36 <a style="display:scroll; position:fixed; bottom:5px; right:5px;" href="#top"><font size=-1>[top]</font></a>
max@0 37
max@0 38
max@0 39 <!-- BEGIN CONTENT -->
max@0 40
max@0 41
max@0 42 <b>Preamble</b>
max@0 43 <br>
max@0 44 <br>
max@0 45 <table border="0" cellpadding="0" cellspacing="0">
max@0 46 <tbody>
max@0 47 <tr>
max@0 48 <td style="text-align: left; vertical-align: top; width: 50%;">
max@0 49 <ul>
max@0 50 <li>
max@0 51 To aid the conversion of Matlab/Octave programs,
max@0 52 there is a <a href="#syntax">syntax conversion table</a>
max@0 53 </li>
max@0 54 <br>
max@0 55 <li>
max@0 56 First time users may want to have a look at a short <a href="#example_prog">example program</a>
max@0 57 </li>
max@0 58 <br>
max@0 59 <li>
max@0 60 If you find any bugs or regressions, please <a href="http://arma.sourceforge.net/faq.html">report them</a>
max@0 61 </li>
max@0 62 <br>
max@0 63 <li>
max@0 64 <b>Caveat:</b> the API for version 2.x has <a href="#api_changes">changes &amp; additions</a> compared to version 1.2;
max@0 65 see also the list of <a href="#deprecated">deprecated</a> functionality
max@0 66 </li>
max@0 67 </ul>
max@0 68 </td>
max@0 69 <td>
max@0 70 &nbsp;
max@0 71 </td>
max@0 72 <td class="line" style="vertical-align: top;">
max@0 73 <br>
max@0 74 </td>
max@0 75 <td style="text-align: left; vertical-align: top; width: 45%;">
max@0 76 <ul>
max@0 77 <li>
max@0 78 If you use Armadillo in your research and/or software,
max@0 79 we would appreciate a citation to the following tech report:
max@0 80 <br>
max@0 81 <br>
max@0 82 <font size=-1>
max@0 83 Conrad Sanderson.
max@0 84 <br>
max@0 85 <i><a href="armadillo_nicta_2010.pdf">Armadillo: An Open Source C++ Linear Algebra Library for Fast Prototyping and Computationally Intensive Experiments</a></i>.
max@0 86 <br>
max@0 87 Technical Report, NICTA, 2010.
max@0 88 </font>
max@0 89 </li>
max@0 90 </ul>
max@0 91 </td>
max@0 92 </tr>
max@0 93 </tbody>
max@0 94 </table>
max@0 95
max@0 96 <br>
max@0 97 <br>
max@0 98
max@0 99 <b>Matrix, Vector, Cube and Field Classes</b>
max@0 100 <ul>
max@0 101 <a href="#Mat">Mat&lt;<i>type</i>&gt;, mat and cx_mat</a>&nbsp;&middot;
max@0 102 <a href="#Col">Col&lt;<i>type</i>&gt;, colvec and vec</a>&nbsp;&middot;
max@0 103 <a href="#Row">Row&lt;<i>type</i>&gt;, rowvec</a>&nbsp;&middot;
max@0 104 <a href="#Cube">Cube&lt;<i>type</i>&gt;, cube</a>&nbsp;&middot;
max@0 105 <a href="#field">field&lt;<i>object&nbsp;type</i>&gt;</a>
max@0 106 </ul>
max@0 107 <br>
max@0 108
max@0 109 <b>Member Functions &amp; Variables</b>
max@0 110 <ul>
max@0 111 <a href="#attributes">attributes</a>&nbsp;&middot;
max@0 112 <a href="#colptr">colptr</a>&nbsp;&middot;
max@0 113 <a href="#copy_size">copy_size</a>&nbsp;&middot;
max@0 114 <a href="#diag">diag</a>&nbsp;&middot;
max@0 115 <a href="#element_access">element&nbsp;access</a>&nbsp;&middot;
max@0 116 <a href="#element_initialisation">element&nbsp;initialisation</a>&nbsp;&middot;
max@0 117 <a href="#eye_member">eye</a>&nbsp;&middot;
max@0 118 <a href="#fill">fill</a>&nbsp;&middot;
max@0 119 <a href="#insert">insert rows/cols/slices</a>&nbsp;&middot;
max@0 120 <a href="#in_range">in_range</a>&nbsp;&middot;
max@0 121 <a href="#is_empty">is_empty</a>&nbsp;&middot;
max@0 122 <a href="#is_finite">is_finite</a>&nbsp;&middot;
max@0 123 <a href="#is_square">is_square</a>&nbsp;&middot;
max@0 124 <a href="#is_vec">is_vec</a>&nbsp;&middot;
max@0 125 <a href="#iterators_mat">iterators (matrices)</a>&nbsp;&middot;
max@0 126 <a href="#iterators_cube">iterators (cubes)</a>&nbsp;&middot;
max@0 127 <a href="#memptr">memptr</a>&nbsp;&middot;
max@0 128 <a href="#min_and_max_member">min/max</a>&nbsp;&middot;
max@0 129 <a href="#ones_member">ones</a>&nbsp;&middot;
max@0 130 <a href="#operators">operators</a>&nbsp;&middot;
max@0 131 <a href="#print">print</a>&nbsp;&middot;
max@0 132 <a href="#raw_print">raw_print</a>&nbsp;&middot;
max@0 133 <a href="#randu_randn_member">randu/randn</a>&nbsp;&middot;
max@0 134 <a href="#reset">reset</a>&nbsp;&middot;
max@0 135 <a href="#reshape_member">reshape</a>&nbsp;&middot;
max@0 136 <a href="#resize_member">resize</a>&nbsp;&middot;
max@0 137 <a href="#save_load_mat">save/load (matrices &amp; cubes)</a>&nbsp;&middot;
max@0 138 <a href="#save_load_field">save/load (fields)</a>&nbsp;&middot;
max@0 139 <a href="#set_imag">set_imag/real</a>&nbsp;&middot;
max@0 140 <a href="#set_size">set_size</a>&nbsp;&middot;
max@0 141 <a href="#shed">shed rows/cols/slices</a>&nbsp;&middot;
max@0 142 <a href="#stl_container_fns">STL container functions</a>&nbsp;&middot;
max@0 143 <a href="#submat">submatrix&nbsp;views</a>&nbsp;&middot;
max@0 144 <a href="#subcube">subcube&nbsp;views</a>&nbsp;&middot;
max@0 145 <a href="#subfield">subfield&nbsp;views</a>&nbsp;&middot;
max@0 146 <a href="#swap_rows">swap_rows/cols</a>&nbsp;&middot;
max@0 147 <a href="#t_st_members">t/st (transpose)</a>&nbsp;&middot;
max@0 148 <a href="#zeros_member">zeros</a>
max@0 149 </ul>
max@0 150 <br>
max@0 151
max@0 152 <b>Other Classes</b>
max@0 153 <ul>
max@0 154 <a href="#running_stat">running_stat&lt;<i>type</i>&gt;</a>&nbsp;&middot;
max@0 155 <a href="#running_stat_vec">running_stat_vec&lt;<i>type</i>&gt;</a>&nbsp;&middot;
max@0 156 <a href="#wall_clock">wall_clock</a>
max@0 157 </ul>
max@0 158 <br>
max@0 159
max@0 160 <b>Generated Vectors/Matrices/Cubes</b>
max@0 161 <ul>
max@0 162 <a href="#eye_standalone">eye</a>&nbsp;&middot;
max@0 163 <a href="#linspace">linspace</a>&nbsp;&middot;
max@0 164 <a href="#ones_standalone">ones</a>&nbsp;&middot;
max@0 165 <a href="#randu_randn_standalone">randu/randn</a>&nbsp;&middot;
max@0 166 <a href="#repmat">repmat</a>&nbsp;&middot;
max@0 167 <a href="#toeplitz">toeplitz/toeplitz_circ</a>&nbsp;&middot;
max@0 168 <a href="#zeros_standalone">zeros</a>
max@0 169 </ul>
max@0 170 <br>
max@0 171
max@0 172 <b>Functions Individually Applied to Each Element of a Matrix/Cube</b>
max@0 173 <ul>
max@0 174 <a href="#abs">abs</a>&nbsp;&middot;
max@0 175 <a href="#eps">eps</a>&nbsp;&middot;
max@0 176 <a href="#misc_fns">misc functions (exp, log, pow, sqrt, ...)</a>&nbsp;&middot;
max@0 177 <a href="#trig_fns">trigonometric functions (cos, sin, ...)</a>
max@0 178 </ul>
max@0 179 <br>
max@0 180
max@0 181 <b>Scalar Valued Functions of Vectors/Matrices/Cubes</b>
max@0 182 <ul>
max@0 183 <a href="#accu">accu</a>&nbsp;&middot;
max@0 184 <a href="#as_scalar">as_scalar</a>&nbsp;&middot;
max@0 185 <a href="#det">det</a>&nbsp;&middot;
max@0 186 <a href="#dot">dot/cdot/norm_dot</a>&nbsp;&middot;
max@0 187 <a href="#log_det">log_det</a>&nbsp;&middot;
max@0 188 <a href="#norm">norm</a>&nbsp;&middot;
max@0 189 <a href="#rank">rank</a>&nbsp;&middot;
max@0 190 <a href="#trace">trace</a>
max@0 191 </ul>
max@0 192 <br>
max@0 193
max@0 194 <b>Scalar/Vector Valued Functions of Vectors/Matrices</b>
max@0 195 <ul>
max@0 196 <a href="#diagvec">diagvec</a>&nbsp;&middot;
max@0 197 <a href="#min_and_max">min/max</a>&nbsp;&middot;
max@0 198 <a href="#prod">prod</a>&nbsp;&middot;
max@0 199 <a href="#sum">sum</a>&nbsp;&middot;
max@0 200 <a href="#stats_fns">statistics (mean, stddev, ...)</a>
max@0 201 </ul>
max@0 202 <br>
max@0 203
max@0 204 <b>Vector/Matrix/Cube Valued Functions of Vectors/Matrices/Cubes</b>
max@0 205 <ul>
max@0 206 <a href="#conv">conv</a>&nbsp;&middot;
max@0 207 <a href="#conv_to">conv_to</a>&nbsp;&middot;
max@0 208 <a href="#conj">conj</a>&nbsp;&middot;
max@0 209 <a href="#cor">cor</a>&nbsp;&middot;
max@0 210 <a href="#cov">cov</a>&nbsp;&middot;
max@0 211 <a href="#cross">cross</a>&nbsp;&middot;
max@0 212 <a href="#cumsum">cumsum</a>&nbsp;&middot;
max@0 213 <a href="#diagmat">diagmat</a>&nbsp;&middot;
max@0 214 <a href="#find">find</a>&nbsp;&middot;
max@0 215 <a href="#flip">fliplr/flipud</a>&nbsp;&middot;
max@0 216 <a href="#imag_real">imag/real</a>&nbsp;&middot;
max@0 217 <a href="#join">join&nbsp;rows/cols/slices</a>&nbsp;&middot;
max@0 218 <a href="#kron">kron</a>&nbsp;&middot;
max@0 219 <a href="#reshape">reshape</a>&nbsp;&middot;
max@0 220 <a href="#resize">resize</a>&nbsp;&middot;
max@0 221 <a href="#shuffle">shuffle</a>&nbsp;&middot;
max@0 222 <a href="#sort">sort</a>&nbsp;&middot;
max@0 223 <a href="#sort_index">sort_index</a>&nbsp;&middot;
max@0 224 <a href="#symmat">symmatu/symmatl</a>&nbsp;&middot;
max@0 225 <a href="#strans">strans</a>&nbsp;&middot;
max@0 226 <a href="#trans">trans</a>&nbsp;&middot;
max@0 227 <a href="#trimat">trimatu/trimatl</a>
max@0 228 </ul>
max@0 229 <br>
max@0 230
max@0 231 <b>Decompositions, Inverses and Equation Solvers</b>
max@0 232 <ul>
max@0 233 <a href="#chol">chol</a>&nbsp;&middot;
max@0 234 <a href="#eig_sym">eig_sym</a>&nbsp;&middot;
max@0 235 <a href="#eig_gen">eig_gen</a>&nbsp;&middot;
max@0 236 <a href="#inv">inv</a>&nbsp;&middot;
max@0 237 <a href="#lu">lu</a>&nbsp;&middot;
max@0 238 <a href="#pinv">pinv</a>&nbsp;&middot;
max@0 239 <a href="#princomp">princomp</a>&nbsp;&middot;
max@0 240 <a href="#qr">qr</a>&nbsp;&middot;
max@0 241 <a href="#solve">solve</a>&nbsp;&middot;
max@0 242 <a href="#svd">svd</a>&nbsp;&middot;
max@0 243 <a href="#svd_econ">svd_econ</a>&nbsp;&middot;
max@0 244 <a href="#syl">syl</a>
max@0 245 </ul>
max@0 246 <br>
max@0 247
max@0 248 <b>Miscellaneous</b>
max@0 249 <ul>
max@0 250 <a href="#is_finite_standalone">is_finite()</a>&nbsp;&middot;
max@0 251 <a href="#logging">logging of errors/warnings</a>&nbsp;&middot;
max@0 252 <a href="#math_constants">math constants (pi, ...)</a>&nbsp;&middot;
max@0 253 <a href="#phys_constants">physical constants (speed of light, ...)</a>&nbsp;&middot;
max@0 254 <a href="#log_add">log_add</a>&nbsp;&middot;
max@0 255 <a href="#uword">uword/sword</a>&nbsp;&middot;
max@0 256 <a href="#cx_float_double">cx_float/cx_double</a>&nbsp;&middot;
max@0 257 <a href="#syntax">Matlab/Armadillo syntax differences</a>&nbsp;&middot;
max@0 258 <a href="#example_prog">example program</a>&nbsp;&middot;
max@0 259 <!--<a href="#catching_exceptions">catching exceptions</a>&nbsp;&middot;-->
max@0 260 <a href="#api_changes">API changes</a>
max@0 261 </ul>
max@0 262 <br>
max@0 263
max@0 264 <br>
max@0 265 <br>
max@0 266 <hr class="greyline">
max@0 267 <hr class="greyline">
max@0 268 <br>
max@0 269 <br>
max@0 270 <font size=+1><b>Matrix, Vector, Cube and Field Classes</b></font>
max@0 271 <br>
max@0 272 <br>
max@0 273 <hr class="greyline">
max@0 274 <br>
max@0 275
max@0 276 <a name="Mat"></a><b>Mat&lt;</b><i>type</i><b>&gt;</b>
max@0 277 <br><b>mat</b>
max@0 278 <br><b>cx_mat</b>
max@0 279 <ul>
max@0 280 <li>
max@0 281 The root template matrix class is <b>Mat&lt;</b><i>type</i><b>&gt;</b>, where <i>type</i> can be one of:
max@0 282 <i>char</i>, <i>int</i>, <i>float</i>, <i>double</i>, <i>std::complex&lt;double&gt;</i>, etc.
max@0 283 </li>
max@0 284 <br>
max@0 285 <li>
max@0 286 For convenience the following typedefs have been defined:
max@0 287 <ul>
max@0 288 <table style="text-align: left;" border="0" cellpadding="2" cellspacing="2">
max@0 289 <tbody>
max@0 290 <tr>
max@0 291 <td style="vertical-align: top;">
max@0 292 umat
max@0 293 </td>
max@0 294 <td style="vertical-align: top;">
max@0 295 &nbsp;=&nbsp;
max@0 296 </td>
max@0 297 <td style="vertical-align: top;">
max@0 298 Mat&lt;<a href="#uword">uword</a>&gt;
max@0 299 </td>
max@0 300 </tr>
max@0 301 <tr>
max@0 302 <td style="vertical-align: top;">
max@0 303 imat
max@0 304 </td>
max@0 305 <td style="vertical-align: top;">
max@0 306 &nbsp;=&nbsp;
max@0 307 </td>
max@0 308 <td style="vertical-align: top;">
max@0 309 Mat&lt;<a href="#uword">sword</a>&gt;
max@0 310 </td>
max@0 311 </tr>
max@0 312 <tr>
max@0 313 <td style="vertical-align: top;">
max@0 314 fmat
max@0 315 </td>
max@0 316 <td style="vertical-align: top;">
max@0 317 &nbsp;=&nbsp;
max@0 318 </td>
max@0 319 <td style="vertical-align: top;">
max@0 320 Mat&lt;float&gt;
max@0 321 </td>
max@0 322 </tr>
max@0 323 <tr>
max@0 324 <td style="vertical-align: top;">
max@0 325 mat
max@0 326 </td>
max@0 327 <td style="vertical-align: top;">
max@0 328 &nbsp;=&nbsp;
max@0 329 </td>
max@0 330 <td style="vertical-align: top;">
max@0 331 Mat&lt;double&gt;
max@0 332 </td>
max@0 333 </tr>
max@0 334 <tr>
max@0 335 <td style="vertical-align: top;">
max@0 336 cx_fmat
max@0 337 </td>
max@0 338 <td style="vertical-align: top;">
max@0 339 &nbsp;=&nbsp;
max@0 340 </td>
max@0 341 <td style="vertical-align: top;">
max@0 342 Mat&lt;<a href="#cx_float_double">cx_float</a>&gt;
max@0 343 </td>
max@0 344 </tr>
max@0 345 <tr>
max@0 346 <td style="vertical-align: top;">
max@0 347 cx_mat
max@0 348 </td>
max@0 349 <td style="vertical-align: top;">
max@0 350 &nbsp;=&nbsp;
max@0 351 </td>
max@0 352 <td style="vertical-align: top;">
max@0 353 Mat&lt;<a href="#cx_float_double">cx_double</a>&gt;
max@0 354 </td>
max@0 355 </tr>
max@0 356 </tbody>
max@0 357 </table>
max@0 358 </ul>
max@0 359 </li>
max@0 360 <br>
max@0 361 <li>
max@0 362 In this documentation the <i>mat</i> type is used for convenience;
max@0 363 it is possible to use other types instead, eg. <i>fmat</i>
max@0 364 </li>
max@0 365 <br>
max@0 366 <li>
max@0 367 Functions which are wrappers for LAPACK or ATLAS functions (generally matrix decompositions) are only valid for the following types:
max@0 368 <i>fmat</i>, <i>mat</i>, <i>cx_fmat</i>, <i>cx_mat</i>
max@0 369 </li>
max@0 370 <br>
max@0 371 <li>
max@0 372 Elements are stored with column-major ordering (ie. column by column)
max@0 373 </li>
max@0 374 <br>
max@0 375 <a name="constructors_mat"></a>
max@0 376 <li>
max@0 377 Constructors:
max@0 378 <ul>
max@0 379 <li>mat()</li>
max@0 380 <li>mat(n_rows, n_cols)</li>
max@0 381 <li>mat(mat)</li>
max@0 382 <li>mat(vec)</li>
max@0 383 <li>mat(rowvec)</li>
max@0 384 <li>mat(string)</li>
max@0 385 <li>mat(initialiser_list) &nbsp; (C++11 only)</li>
max@0 386 <li>cx_mat(mat,mat) &nbsp; (for constructing a complex matrix out of two real matrices)</li>
max@0 387 </ul>
max@0 388 </li>
max@0 389 <br>
max@0 390 <li>
max@0 391 The string format for the constructor is elements separated by spaces, and rows denoted by semicolons.
max@0 392 For example, the 2x2 identity matrix can be created using the format string <code>"1 0; 0 1"</code>.
max@0 393 While string based initialisation is compact, directly setting the elements or using <a href="#element_initialisation">element initialisation</a> is considerably faster.
max@0 394 </li>
max@0 395 <br>
max@0 396 <a name="adv_constructors_mat"></a>
max@0 397 <li>
max@0 398 Advanced constructors:
max@0 399 <br>
max@0 400 <br>
max@0 401 <ul>
max@0 402 <li>mat(aux_mem*, n_rows, n_cols, copy_aux_mem = true, strict = true)
max@0 403 <br>
max@0 404 <br>
max@0 405 <ul>
max@0 406 Create a matrix using data from writeable auxiliary memory.
max@0 407 By default the matrix allocates its own memory and copies data from the auxiliary memory (for safety).
max@0 408 However, if <i>copy_aux_mem</i> is set to <i>false</i>,
max@0 409 the matrix will instead directly use the auxiliary memory (ie. no copying).
max@0 410 This is faster, but can be dangerous unless you know what you're doing!
max@0 411 <br>
max@0 412 <br>
max@0 413 The <i>strict</i> variable comes into effect only if <i>copy_aux_mem</i> is set to <i>false</i>
max@0 414 (ie. the matrix is directly using auxiliary memory).
max@0 415 If <i>strict</i> is set to <i>true</i>,
max@0 416 the matrix will be bound to the auxiliary memory for its lifetime;
max@0 417 the number of elements in the matrix can't be changed (directly or indirectly).
max@0 418 If <i>strict</i> is set to <i>false</i>, the matrix will not be bound to the auxiliary memory for its lifetime,
max@0 419 ie., the size of the matrix can be changed.
max@0 420 If the requested number of elements is different to the size of the auxiliary memory,
max@0 421 new memory will be allocated and the auxiliary memory will no longer be used.
max@0 422 </ul>
max@0 423 </li>
max@0 424 <br>
max@0 425 <li>mat(const aux_mem*, n_rows, n_cols)
max@0 426 <br>
max@0 427 <br>
max@0 428 <ul>
max@0 429 Create a matrix by copying data from read-only auxiliary memory.
max@0 430 </ul>
max@0 431 </li>
max@0 432 <a name="adv_constructors_mat_fixed"></a>
max@0 433 <br>
max@0 434 <li>mat::fixed&lt;n_rows, n_cols&gt;
max@0 435 <br>
max@0 436 <br>
max@0 437 <ul>
max@0 438 Create a fixed size matrix, with the size specified via template arguments.
max@0 439 Memory for the matrix is allocated at compile time.
max@0 440 This is generally faster than dynamic memory allocation, but the size of the matrix can't be changed afterwards (directly or indirectly).
max@0 441 <br>
max@0 442 <br>
max@0 443 For convenience, there are several pre-defined typedefs for each matrix type
max@0 444 (where the types are: <i>umat</i>, <i>imat</i>, <i>fmat</i>, <i>mat</i>, <i>cx_fmat</i>, <i>cx_mat</i>).
max@0 445 The typedefs specify a square matrix size, ranging from 2x2 to 9x9.
max@0 446 The typedefs were defined by simply appending a two digit form of the size to the matrix type
max@0 447 -- for example, <i>mat33</i> is equivalent to <i>mat::fixed&lt;3,3&gt;</i>,
max@0 448 while <i>cx_mat44</i> is equivalent to <i>cx_mat::fixed&lt;4,4&gt;</i>.
max@0 449 </ul>
max@0 450 </li>
max@0 451 <br>
max@0 452 <li>mat::fixed&lt;n_rows, n_cols&gt;(const aux_mem*)
max@0 453 <br>
max@0 454 <br>
max@0 455 <ul>
max@0 456 Create a fixed size matrix, with the size specified via template arguments,
max@0 457 and copying data from auxiliary memory.
max@0 458 </ul>
max@0 459 </li>
max@0 460 </ul>
max@0 461 </li>
max@0 462 <br>
max@0 463 <br>
max@0 464 <li>
max@0 465 Examples:
max@0 466 <ul>
max@0 467 <pre>
max@0 468 mat A = randu&lt;mat&gt;(5,5);
max@0 469 double x = A(1,2);
max@0 470
max@0 471 mat B = A + A;
max@0 472 mat C = A * B;
max@0 473 mat D = A % B;
max@0 474
max@0 475 cx_mat X(A,B);
max@0 476
max@0 477 B.zeros();
max@0 478 B.set_size(10,10);
max@0 479 B.zeros(5,6);
max@0 480
max@0 481 //
max@0 482 // fixed size matrices:
max@0 483
max@0 484 mat::fixed&lt;5,6&gt; F;
max@0 485 F.ones();
max@0 486
max@0 487 mat44 G;
max@0 488 G.randn();
max@0 489
max@0 490 cout &lt;&lt; mat22().randu() &lt;&lt; endl;
max@0 491
max@0 492 //
max@0 493 // constructing matrices from
max@0 494 // auxiliary (external) memory:
max@0 495
max@0 496 double aux_mem[24];
max@0 497 mat H(aux_mem, 4, 6, false);
max@0 498 </pre>
max@0 499 </ul>
max@0 500 </li>
max@0 501 <br>
max@0 502 <li><b>Caveat:</b>
max@0 503 For mathematical correctness, scalars are treated as 1x1 matrices during initialisation.
max@0 504 As such, the code below <b>will not</b> generate a 5x5 matrix with every element equal to 123.0:
max@0 505 <ul>
max@0 506 <pre>
max@0 507 mat A(5,5);
max@0 508 A = 123.0;
max@0 509 </pre>
max@0 510 </ul>
max@0 511 Use the following code instead:
max@0 512 <ul>
max@0 513 <pre>
max@0 514 mat A(5,5);
max@0 515 A.fill(123.0);
max@0 516 </pre>
max@0 517 </ul>
max@0 518 Or:
max@0 519 <ul>
max@0 520 <pre>
max@0 521 mat A = 123.0 * ones&lt;mat&gt;(5,5);
max@0 522 </pre>
max@0 523 </ul>
max@0 524 <br>
max@0 525 <li>
max@0 526 See also:
max@0 527 <ul>
max@0 528 <li><a href="#attributes">matrix attributes</a></li>
max@0 529 <li><a href="#element_access">accessing elements</a></li>
max@0 530 <li><a href="#element_initialisation">initialising elements</a></li>
max@0 531 <li><a href="#operators">math &amp; relational operators</a></li>
max@0 532 <li><a href="#submat">submatrix views</a></li>
max@0 533 <li><a href="#save_load_mat">saving &amp; loading matrices</a></li>
max@0 534 <li><a href="#print">printing matrices</a></li>
max@0 535 <li><a href="#iterators_mat">STL-style element iterators</a></li>
max@0 536 <li><a href="http://www.cplusplus.com/doc/tutorial/other_data_types/">explanation of <i>typedef</i></a> (cplusplus.com)
max@0 537 <li><a href="#Col">Col class</a></li>
max@0 538 <li><a href="#Row">Row class</a></li>
max@0 539 <li><a href="#Cube">Cube class</a></li>
max@0 540 </ul>
max@0 541 </li>
max@0 542 <br>
max@0 543 </ul>
max@0 544 <hr class="greyline">
max@0 545 <br>
max@0 546
max@0 547 <a name="Col"></a><b>Col&lt;</b><i>type</i><b>&gt;</b>
max@0 548 <br><b>colvec</b>
max@0 549 <br><b>vec</b>
max@0 550 <ul>
max@0 551 <li>
max@0 552 Classes for column vectors (matrices with one column)
max@0 553 </li>
max@0 554 <br>
max@0 555 <li>The <b>Col&lt;</b><i>type</i><b>&gt;</b> class is derived from the <b>Mat&lt;</b><i>type</i><b>&gt;</b> class
max@0 556 and inherits most of the member functions
max@0 557 </li>
max@0 558 <br>
max@0 559 <li>
max@0 560 For convenience the following typedefs have been defined:
max@0 561 <ul>
max@0 562 <table style="text-align: left;" border="0" cellpadding="2" cellspacing="2">
max@0 563 <tbody>
max@0 564 <tr>
max@0 565 <td style="vertical-align: top;">
max@0 566 uvec, ucolvec
max@0 567 </td>
max@0 568 <td style="vertical-align: top;">
max@0 569 &nbsp;=&nbsp;
max@0 570 </td>
max@0 571 <td style="vertical-align: top;">
max@0 572 Col&lt;<a href="#uword">uword</a>&gt;
max@0 573 </td>
max@0 574 </tr>
max@0 575 <tr>
max@0 576 <td style="vertical-align: top;">
max@0 577 ivec, icolvec
max@0 578 </td>
max@0 579 <td style="vertical-align: top;">
max@0 580 &nbsp;=&nbsp;
max@0 581 </td>
max@0 582 <td style="vertical-align: top;">
max@0 583 Col&lt;<a href="#uword">sword</a>&gt;
max@0 584 </td>
max@0 585 </tr>
max@0 586 <tr>
max@0 587 <td style="vertical-align: top;">
max@0 588 fvec, fcolvec
max@0 589 </td>
max@0 590 <td style="vertical-align: top;">
max@0 591 &nbsp;=&nbsp;
max@0 592 </td>
max@0 593 <td style="vertical-align: top;">
max@0 594 Col&lt;float&gt;
max@0 595 </td>
max@0 596 </tr>
max@0 597 <tr>
max@0 598 <td style="vertical-align: top;">
max@0 599 vec, colvec
max@0 600 </td>
max@0 601 <td style="vertical-align: top;">
max@0 602 &nbsp;=&nbsp;
max@0 603 </td>
max@0 604 <td style="vertical-align: top;">
max@0 605 Col&lt;double&gt;
max@0 606 </td>
max@0 607 </tr>
max@0 608 <tr>
max@0 609 <td style="vertical-align: top;">
max@0 610 cx_fvec, cx_fcolvec
max@0 611 </td>
max@0 612 <td style="vertical-align: top;">
max@0 613 &nbsp;=&nbsp;
max@0 614 </td>
max@0 615 <td style="vertical-align: top;">
max@0 616 Col&lt;<a href="#cx_float_double">cx_float</a>&gt;
max@0 617 </td>
max@0 618 </tr>
max@0 619 <tr>
max@0 620 <td style="vertical-align: top;">
max@0 621 cx_vec, cx_colvec
max@0 622 </td>
max@0 623 <td style="vertical-align: top;">
max@0 624 &nbsp;=&nbsp;
max@0 625 </td>
max@0 626 <td style="vertical-align: top;">
max@0 627 Col&lt;<a href="#cx_float_double">cx_double</a>&gt;
max@0 628 </td>
max@0 629 </tr>
max@0 630 </tbody>
max@0 631 </table>
max@0 632 </ul>
max@0 633 </li>
max@0 634 <br>
max@0 635 <li>
max@0 636 In this documentation, the <b><i>vec</i></b> and <b><i>colvec</i></b> types have the <b>same meaning</b> and are used <b>interchangeably</b>
max@0 637 </li>
max@0 638 <br>
max@0 639 <li>
max@0 640 In this documentation, the types <i>vec</i> or <i>colvec</i> are used for convenience; it is possible to use other types instead, eg.&nbsp;<i>fvec</i>, <i>fcolvec</i>
max@0 641 </li>
max@0 642 <br>
max@0 643 <li>
max@0 644 Functions which take <i>Mat</i> as input can generally also take <i>Col</i> as input.
max@0 645 Main exceptions are functions which require square matrices
max@0 646 </li>
max@0 647 <br>
max@0 648 <li>
max@0 649 Constructors
max@0 650 <ul>
max@0 651 <li>vec(n_elem=0)</li>
max@0 652 <li>vec(vec)</li>
max@0 653 <li>vec(mat) &nbsp; (a <i>std::logic_error</i> exception is thrown if the given matrix has more than one column)</li>
max@0 654 <li>vec(string) &nbsp; (elements separated by spaces)</li>
max@0 655 <li>vec(initialiser_list) &nbsp; (C++11 only)</li>
max@0 656 </ul>
max@0 657 </li>
max@0 658 <br>
max@0 659 <a name="adv_constructors_col"></a>
max@0 660 <li>
max@0 661 Advanced constructors:
max@0 662 <br>
max@0 663 <br>
max@0 664 <ul>
max@0 665 <li>vec(aux_mem*, number_of_elements, copy_aux_mem = true, strict = true)
max@0 666 <br>
max@0 667 <br>
max@0 668 <ul>
max@0 669 Create a column vector using data from writeable auxiliary memory.
max@0 670 By default the vector allocates its own memory and copies data from the auxiliary memory (for safety).
max@0 671 However, if <i>copy_aux_mem</i> is set to <i>false</i>,
max@0 672 the vector will instead directly use the auxiliary memory (ie. no copying).
max@0 673 This is faster, but can be dangerous unless you know what you're doing!
max@0 674 <br>
max@0 675 <br>
max@0 676 The <i>strict</i> variable comes into effect only if <i>copy_aux_mem</i> is set to <i>false</i>
max@0 677 (ie. the vector is directly using auxiliary memory).
max@0 678 If <i>strict</i> is set to <i>true</i>,
max@0 679 the vector will be bound to the auxiliary memory for its lifetime;
max@0 680 the number of elements in the vector can't be changed (directly or indirectly).
max@0 681 If <i>strict</i> is set to <i>false</i>, the vector will not be bound to the auxiliary memory for its lifetime,
max@0 682 ie., the vector's size can be changed.
max@0 683 If the requested number of elements is different to the size of the auxiliary memory,
max@0 684 new memory will be allocated and the auxiliary memory will no longer be used.
max@0 685 </ul>
max@0 686 </li>
max@0 687 <br>
max@0 688 <li>vec(const aux_mem*, number_of_elements)
max@0 689 <br>
max@0 690 <br>
max@0 691 <ul>
max@0 692 Create a column vector by copying data from read-only auxiliary memory.
max@0 693 </ul>
max@0 694 </li>
max@0 695 <br>
max@0 696 <li>vec::fixed&lt;number_of_elements&gt;
max@0 697 <br>
max@0 698 <br>
max@0 699 <ul>
max@0 700 Create a fixed size column vector, with the size specified via the template argument.
max@0 701 Memory for the vector is allocated at compile time.
max@0 702 This is generally faster than dynamic memory allocation, but the size of the vector can't be changed afterwards (directly or indirectly).
max@0 703 <br>
max@0 704 <br>
max@0 705 For convenience, there are several pre-defined typedefs for each vector type
max@0 706 (where the types are: <i>uvec</i>, <i>ivec</i>, <i>fvec</i>, <i>vec</i>, <i>cx_fvec</i>, <i>cx_vec</i> as well as the corresponding <i>colvec</i> versions).
max@0 707 The pre-defined typedefs specify vector sizes ranging from 2 to 9.
max@0 708 The typedefs were defined by simply appending a single digit form of the size to the vector type
max@0 709 -- for example, <i>vec3</i> is equivalent to <i>vec::fixed&lt;3&gt;</i>,
max@0 710 while <i>cx_vec4</i> is equivalent to <i>cx_vec::fixed&lt;4&gt;</i>.
max@0 711 </ul>
max@0 712 </li>
max@0 713 <br>
max@0 714 <li>vec::fixed&lt;number_of_elements&gt;(const aux_mem*)
max@0 715 <br>
max@0 716 <br>
max@0 717 <ul>
max@0 718 Create a fixed size column vector, with the size specified via the template argument,
max@0 719 and copying data from auxiliary memory.
max@0 720 </ul>
max@0 721 </li>
max@0 722 </ul>
max@0 723 </li>
max@0 724 <br>
max@0 725 <br>
max@0 726 <li>
max@0 727 Examples:
max@0 728 <ul>
max@0 729 <pre>
max@0 730 vec x(10);
max@0 731 vec y = zeros&lt;vec&gt;(10,1);
max@0 732
max@0 733 mat A = randu&lt;mat&gt;(10,10);
max@0 734 vec z = A.col(5); // extract a column vector
max@0 735 </pre>
max@0 736 </ul>
max@0 737 </li>
max@0 738 <br>
max@0 739 <li><b>Caveat:</b>
max@0 740 For mathematical correctness, scalars are treated as 1x1 matrices during initialisation.
max@0 741 As such, the code below <b>will not</b> generate a column vector with every element equal to 123.0:
max@0 742 <ul>
max@0 743 <pre>
max@0 744 vec q(5);
max@0 745 q = 123.0;
max@0 746 </pre>
max@0 747 </ul>
max@0 748 Use the following code instead:
max@0 749 <ul>
max@0 750 <pre>
max@0 751 vec q(5);
max@0 752 q.fill(123.0);
max@0 753 </pre>
max@0 754 </ul>
max@0 755 Or:
max@0 756 <ul>
max@0 757 <pre>
max@0 758 vec q = 123.0 * ones&lt;vec&gt;(5,1);
max@0 759 </pre>
max@0 760 </ul>
max@0 761 </li>
max@0 762 <br>
max@0 763 <li>See also:
max@0 764 <ul>
max@0 765 <li><a href="#Mat">Mat class</a></li>
max@0 766 <li><a href="#Row">Row class</a></li>
max@0 767 </ul>
max@0 768 </li>
max@0 769 <br>
max@0 770 </ul>
max@0 771 <hr class="greyline"><br>
max@0 772
max@0 773 <a name="Row"></a>
max@0 774 <b>Row&lt;</b><i>type</i><b>&gt;</b>
max@0 775 <br><b>rowvec</b>
max@0 776 <ul>
max@0 777 <li>
max@0 778 Classes for row vectors (matrices with one row)
max@0 779 </li>
max@0 780 <br>
max@0 781 <li>The template <b>Row&lt;</b><i>type</i><b>&gt;</b> class is derived from the <b>Mat&lt;</b><i>type</i><b>&gt;</b> class
max@0 782 and inherits most of the member functions
max@0 783 </li>
max@0 784 <br>
max@0 785 <li>
max@0 786 For convenience the following typedefs have been defined:
max@0 787 <ul>
max@0 788 <table style="text-align: left;" border="0" cellpadding="2" cellspacing="2">
max@0 789 <tbody>
max@0 790 <tr>
max@0 791 <td style="vertical-align: top;">
max@0 792 urowvec
max@0 793 </td>
max@0 794 <td style="vertical-align: top;">
max@0 795 &nbsp;=&nbsp;
max@0 796 </td>
max@0 797 <td style="vertical-align: top;">
max@0 798 Row&lt;<a href="#uword">uword</a>&gt;
max@0 799 </td>
max@0 800 </tr>
max@0 801 <tr>
max@0 802 <td style="vertical-align: top;">
max@0 803 irowvec
max@0 804 </td>
max@0 805 <td style="vertical-align: top;">
max@0 806 &nbsp;=&nbsp;
max@0 807 </td>
max@0 808 <td style="vertical-align: top;">
max@0 809 Row&lt;<a href="#uword">sword</a>&gt;
max@0 810 </td>
max@0 811 </tr>
max@0 812 <tr>
max@0 813 <td style="vertical-align: top;">
max@0 814 frowvec
max@0 815 </td>
max@0 816 <td style="vertical-align: top;">
max@0 817 &nbsp;=&nbsp;
max@0 818 </td>
max@0 819 <td style="vertical-align: top;">
max@0 820 Row&lt;float&gt;
max@0 821 </td>
max@0 822 </tr>
max@0 823 <tr>
max@0 824 <td style="vertical-align: top;">
max@0 825 rowvec
max@0 826 </td>
max@0 827 <td style="vertical-align: top;">
max@0 828 &nbsp;=&nbsp;
max@0 829 </td>
max@0 830 <td style="vertical-align: top;">
max@0 831 Row&lt;double&gt;
max@0 832 </td>
max@0 833 </tr>
max@0 834 <tr>
max@0 835 <td style="vertical-align: top;">
max@0 836 cx_frowvec
max@0 837 </td>
max@0 838 <td style="vertical-align: top;">
max@0 839 &nbsp;=&nbsp;
max@0 840 </td>
max@0 841 <td style="vertical-align: top;">
max@0 842 Row&lt;<a href="#cx_float_double">cx_float</a>&gt;
max@0 843 </td>
max@0 844 </tr>
max@0 845 <tr>
max@0 846 <td style="vertical-align: top;">
max@0 847 cx_rowvec
max@0 848 </td>
max@0 849 <td style="vertical-align: top;">
max@0 850 &nbsp;=&nbsp;
max@0 851 </td>
max@0 852 <td style="vertical-align: top;">
max@0 853 Row&lt;<a href="#cx_float_double">cx_double</a>&gt;
max@0 854 </td>
max@0 855 </tr>
max@0 856 </tbody>
max@0 857 </table>
max@0 858 </ul>
max@0 859 </li>
max@0 860 <br>
max@0 861 <li>
max@0 862 In this documentation, the <i>rowvec</i> type is used for convenience;
max@0 863 it is possible to use other types instead, eg. <i>frowvec</i>
max@0 864 </li>
max@0 865 <br>
max@0 866 <li>
max@0 867 Functions which take <i>Mat</i> as input can generally also take <i>Row</i> as input.
max@0 868 Main exceptions are functions which require square matrices
max@0 869 </li>
max@0 870 <br>
max@0 871 <li>
max@0 872 Constructors
max@0 873 <ul>
max@0 874 <li>rowvec(n_elem=0)</li>
max@0 875 <li>rowvec(rowvec)</li>
max@0 876 <li>rowvec(mat) &nbsp; (a <i>std::logic_error</i> exception is thrown if the given matrix has more than one row)</li>
max@0 877 <li>rowvec(string) &nbsp; (elements separated by spaces)</li>
max@0 878 <li>rowvec(initialiser_list) &nbsp; (C++11 only)</li>
max@0 879 </ul>
max@0 880 </li>
max@0 881 <br>
max@0 882 <a name="adv_constructors_row"></a>
max@0 883 <li>
max@0 884 Advanced constructors:
max@0 885 <br>
max@0 886 <br>
max@0 887 <ul>
max@0 888 <li>rowvec(aux_mem*, number_of_elements, copy_aux_mem = true, strict = true)
max@0 889 <br>
max@0 890 <br>
max@0 891 <ul>
max@0 892 Create a row vector using data from writeable auxiliary memory.
max@0 893 By default the vector allocates its own memory and copies data from the auxiliary memory (for safety).
max@0 894 However, if <i>copy_aux_mem</i> is set to <i>false</i>,
max@0 895 the vector will instead directly use the auxiliary memory (ie. no copying).
max@0 896 This is faster, but can be dangerous unless you know what you're doing!
max@0 897 <br>
max@0 898 <br>
max@0 899 The <i>strict</i> variable comes into effect only if <i>copy_aux_mem</i> is set to <i>false</i>
max@0 900 (ie. the vector is directly using auxiliary memory).
max@0 901 If <i>strict</i> is set to <i>true</i>,
max@0 902 the vector will be bound to the auxiliary memory for its lifetime;
max@0 903 the number of elements in the vector can't be changed (directly or indirectly).
max@0 904 If <i>strict</i> is set to <i>false</i>, the vector will not be bound to the auxiliary memory for its lifetime,
max@0 905 ie., the vector's size can be changed.
max@0 906 If the requested number of elements is different to the size of the auxiliary memory,
max@0 907 new memory will be allocated and the auxiliary memory will no longer be used.
max@0 908 </ul>
max@0 909 </li>
max@0 910 <br>
max@0 911 <li>rowvec(const aux_mem*, number_of_elements)
max@0 912 <br>
max@0 913 <br>
max@0 914 <ul>
max@0 915 Create a row vector by copying data from read-only auxiliary memory.
max@0 916 </ul>
max@0 917 </li>
max@0 918 <br>
max@0 919 <li>rowvec::fixed&lt;number_of_elements&gt;
max@0 920 <br>
max@0 921 <br>
max@0 922 <ul>
max@0 923 Create a fixed size row vector, with the size specified via the template argument.
max@0 924 Memory for the vector is allocated at compile time.
max@0 925 This is generally faster than dynamic memory allocation, but the size of the vector can't be changed afterwards (directly or indirectly).
max@0 926 <br>
max@0 927 <br>
max@0 928 For convenience, there are several pre-defined typedefs for each vector type
max@0 929 (where the types are: <i>urowvec</i>, <i>irowvec</i>, <i>frowvec</i>, <i>rowvec</i>, <i>cx_frowvec</i>, <i>cx_rowvec</i>).
max@0 930 The pre-defined typedefs specify vector sizes ranging from 2 to 9.
max@0 931 The typedefs were defined by simply appending a single digit form of the size to the vector type
max@0 932 -- for example, <i>rowvec3</i> is equivalent to <i>rowvec::fixed&lt;3&gt;</i>,
max@0 933 while <i>cx_rowvec4</i> is equivalent to <i>cx_rowvec::fixed&lt;4&gt;</i>.
max@0 934 </ul>
max@0 935 </li>
max@0 936 <br>
max@0 937 <li>rowvec::fixed&lt;number_of_elements&gt;(const aux_mem*)
max@0 938 <br>
max@0 939 <br>
max@0 940 <ul>
max@0 941 Create a fixed size row vector, with the size specified via the template argument,
max@0 942 and copying data from auxiliary memory.
max@0 943 </ul>
max@0 944 </li>
max@0 945 </ul>
max@0 946 </li>
max@0 947 <br>
max@0 948 <br>
max@0 949 <li>
max@0 950 Examples:
max@0 951 <ul>
max@0 952 <pre>
max@0 953 rowvec x(10);
max@0 954 rowvec y = zeros&lt;mat&gt;(1,10);
max@0 955
max@0 956 mat A = randu&lt;mat&gt;(10,10);
max@0 957 rowvec z = A.row(5); // extract a row vector
max@0 958 </pre>
max@0 959 </ul>
max@0 960 </li>
max@0 961 <br>
max@0 962 <li>
max@0 963 <b>Caveat:</b>
max@0 964 For mathematical correctness, scalars are treated as 1x1 matrices during initialisation.
max@0 965 As such, the code below <b>will not</b> generate a row vector with every element equal to 123.0:
max@0 966 <ul>
max@0 967 <pre>
max@0 968 rowvec r(5);
max@0 969 r = 123.0;
max@0 970 </pre>
max@0 971 </ul>
max@0 972 Use the following code instead:
max@0 973 <ul>
max@0 974 <pre>
max@0 975 rowvec r(5);
max@0 976 r.fill(123.0);
max@0 977 </pre>
max@0 978 </ul>
max@0 979 Or:
max@0 980 <ul>
max@0 981 <pre>
max@0 982 rowvec r = 123.0 * ones&lt;rowvec&gt;(1,5);
max@0 983 </pre>
max@0 984 </ul>
max@0 985 <br>
max@0 986 <li>See also:
max@0 987 <ul>
max@0 988 <li><a href="#Mat">Mat class</a></li>
max@0 989 <li><a href="#Col">Col class</a></li>
max@0 990 </ul>
max@0 991 </li>
max@0 992 <br>
max@0 993 </ul>
max@0 994 <hr class="greyline">
max@0 995 <br>
max@0 996
max@0 997 <a name="Cube"></a>
max@0 998 <b>Cube&lt;</b><i>type</i><b>&gt;</b>
max@0 999 <br><b>cube</b>
max@0 1000 <br><b>cx_cube</b>
max@0 1001 <ul>
max@0 1002 <li>
max@0 1003 Classes for cubes, also known as "3D matrices"
max@0 1004 </li>
max@0 1005 <br>
max@0 1006 <li>
max@0 1007 The root template cube class is <b>Cube&lt;</b><i>type</i><b>&gt;</b>, where <i>type</i> can be one of:
max@0 1008 <i>char</i>, <i>int</i>, <i>float</i>, <i>double</i>, <i>std::complex&lt;double&gt;</i>, etc
max@0 1009 </li>
max@0 1010 <br>
max@0 1011 <li>
max@0 1012 For convenience the following typedefs have been defined:
max@0 1013 <ul>
max@0 1014 <table style="text-align: left;" border="0" cellpadding="2" cellspacing="2">
max@0 1015 <tbody>
max@0 1016 <tr>
max@0 1017 <td style="vertical-align: top;">
max@0 1018 ucube
max@0 1019 </td>
max@0 1020 <td style="vertical-align: top;">
max@0 1021 &nbsp;=&nbsp;
max@0 1022 </td>
max@0 1023 <td style="vertical-align: top;">
max@0 1024 Cube&lt;<a href="#uword">uword</a>&gt;
max@0 1025 </td>
max@0 1026 </tr>
max@0 1027 <tr>
max@0 1028 <td style="vertical-align: top;">
max@0 1029 icube
max@0 1030 </td>
max@0 1031 <td style="vertical-align: top;">
max@0 1032 &nbsp;=&nbsp;
max@0 1033 </td>
max@0 1034 <td style="vertical-align: top;">
max@0 1035 Cube&lt;<a href="#uword">sword</a>&gt;
max@0 1036 </td>
max@0 1037 </tr>
max@0 1038 <tr>
max@0 1039 <td style="vertical-align: top;">
max@0 1040 fcube
max@0 1041 </td>
max@0 1042 <td style="vertical-align: top;">
max@0 1043 &nbsp;=&nbsp;
max@0 1044 </td>
max@0 1045 <td style="vertical-align: top;">
max@0 1046 Cube&lt;float&gt;
max@0 1047 </td>
max@0 1048 </tr>
max@0 1049 <tr>
max@0 1050 <td style="vertical-align: top;">
max@0 1051 cube
max@0 1052 </td>
max@0 1053 <td style="vertical-align: top;">
max@0 1054 &nbsp;=&nbsp;
max@0 1055 </td>
max@0 1056 <td style="vertical-align: top;">
max@0 1057 Cube&lt;double&gt;
max@0 1058 </td>
max@0 1059 </tr>
max@0 1060 <tr>
max@0 1061 <td style="vertical-align: top;">
max@0 1062 cx_fcube
max@0 1063 </td>
max@0 1064 <td style="vertical-align: top;">
max@0 1065 &nbsp;=&nbsp;
max@0 1066 </td>
max@0 1067 <td style="vertical-align: top;">
max@0 1068 Cube&lt;<a href="#cx_float_double">cx_float</a>&gt;
max@0 1069 </td>
max@0 1070 </tr>
max@0 1071 <tr>
max@0 1072 <td style="vertical-align: top;">
max@0 1073 cx_cube
max@0 1074 </td>
max@0 1075 <td style="vertical-align: top;">
max@0 1076 &nbsp;=&nbsp;
max@0 1077 </td>
max@0 1078 <td style="vertical-align: top;">
max@0 1079 Cube&lt;<a href="#cx_float_double">cx_double</a>&gt;
max@0 1080 </td>
max@0 1081 </tr>
max@0 1082 </tbody>
max@0 1083 </table>
max@0 1084 </ul>
max@0 1085 </li>
max@0 1086 <br>
max@0 1087 <li>
max@0 1088 In this documentation the <i>cube</i> type is used for convenience;
max@0 1089 it is possible to use other types instead, eg. <i>fcube</i>
max@0 1090 </li>
max@0 1091 <br>
max@0 1092 <li>
max@0 1093 Cube data is stored as a set of slices (matrices) stored contiguously within memory.
max@0 1094 Within each slice, elements are stored with column-major ordering (ie. column by column)
max@0 1095 </li>
max@0 1096 <br>
max@0 1097 <li>
max@0 1098 Each slice can be interpreted as a matrix, hence functions which take <i>Mat</i> as input can generally also take cube slices as input
max@0 1099 </li>
max@0 1100 <br>
max@0 1101 <a name="constructors_cube"></a>
max@0 1102 <li>
max@0 1103 Constructors:
max@0 1104 <ul>
max@0 1105 cube()
max@0 1106 <br>cube(cube)
max@0 1107 <br>cube(n_rows, n_cols, n_slices)
max@0 1108 <br>cx_cube(cube, cube) (for constructing a complex cube out of two real cubes)
max@0 1109 </ul>
max@0 1110 </li>
max@0 1111 <br>
max@0 1112
max@0 1113 <a name="adv_constructors_cube"></a>
max@0 1114 <li>
max@0 1115 Advanced constructors:
max@0 1116 <br>
max@0 1117 <br>
max@0 1118 <ul>
max@0 1119 <li>
max@0 1120 cube::fixed&lt;n_rows, n_cols, n_slices&gt;
max@0 1121 <br>
max@0 1122 <br>
max@0 1123 <ul>
max@0 1124 Create a fixed size cube, with the size specified via template arguments.
max@0 1125 Memory for the cube is allocated at compile time.
max@0 1126 This is generally faster than dynamic memory allocation, but the size of the cube can't be changed afterwards (directly or indirectly).
max@0 1127 </ul>
max@0 1128 </li>
max@0 1129 <br>
max@0 1130 <li>cube(aux_mem*, n_rows, n_cols, n_slices, copy_aux_mem = true, strict = true)
max@0 1131 <br>
max@0 1132 <br>
max@0 1133 <ul>
max@0 1134 Create a cube using data from writeable auxiliary memory.
max@0 1135 By default the cube allocates its own memory and copies data from the auxiliary memory (for safety).
max@0 1136 However, if <i>copy_aux_mem</i> is set to <i>false</i>,
max@0 1137 the cube will instead directly use the auxiliary memory (ie. no copying).
max@0 1138 This is faster, but can be dangerous unless you know what you're doing!
max@0 1139 <br>
max@0 1140 <br>
max@0 1141 The <i>strict</i> variable comes into effect only if <i>copy_aux_mem</i> is set to <i>false</i>
max@0 1142 (ie. the cube is directly using auxiliary memory).
max@0 1143 If <i>strict</i> is set to <i>true</i>,
max@0 1144 the cube will be bound to the auxiliary memory for its lifetime;
max@0 1145 the number of elements in the cube can't be changed (directly or indirectly).
max@0 1146 If <i>strict</i> is set to <i>false</i>, the cube will not be bound to the auxiliary memory for its lifetime,
max@0 1147 ie., the size of the cube can be changed.
max@0 1148 If the requested number of elements is different to the size of the auxiliary memory,
max@0 1149 new memory will be allocated and the auxiliary memory will no longer be used.
max@0 1150 </ul>
max@0 1151 </li>
max@0 1152 <br>
max@0 1153 <li>cube(const aux_mem*, n_rows, n_cols, n_slices)
max@0 1154 <br>
max@0 1155 <br>
max@0 1156 <ul>
max@0 1157 Create a cube by copying data from read-only auxiliary memory.
max@0 1158 </ul>
max@0 1159 </li>
max@0 1160 </ul>
max@0 1161 </li>
max@0 1162 <br>
max@0 1163 <br>
max@0 1164 <li>
max@0 1165 Examples:
max@0 1166 <ul>
max@0 1167 <pre>
max@0 1168 cube x(1,2,3);
max@0 1169 cube y = randu&lt;cube&gt;(4,5,6);
max@0 1170
max@0 1171 mat A = y.slice(1); // extract a slice from the cube
max@0 1172 // (each slice is a matrix)
max@0 1173
max@0 1174 mat B = randu&lt;mat&gt;(4,5);
max@0 1175 y.slice(2) = B; // set a slice in the cube
max@0 1176
max@0 1177 cube q = y + y; // cube addition
max@0 1178 cube r = y % y; // element-wise cube multiplication
max@0 1179
max@0 1180 cube::fixed&lt;4,5,6&gt; f;
max@0 1181 f.ones();
max@0 1182 </pre>
max@0 1183 </ul>
max@0 1184 </li>
max@0 1185 <br>
max@0 1186 <li>
max@0 1187 <b>Caveats</b>
max@0 1188 <br>
max@0 1189 <br>
max@0 1190 <ul>
max@0 1191 <li>
max@0 1192 The size of individual slices can't be changed.
max@0 1193 For example, the following <b>will not</b> work:
max@0 1194 <ul>
max@0 1195 <pre>
max@0 1196 cube c(5,6,7);
max@0 1197 c.slice(0) = randu&lt;mat&gt;(10,20); // wrong size
max@0 1198 </pre>
max@0 1199 </ul>
max@0 1200 </li>
max@0 1201 <li>
max@0 1202 For mathematical correctness, scalars are treated as 1x1x1 cubes during initialisation.
max@0 1203 As such, the code below <b>will not</b> generate a cube with every element equal to 123.0:
max@0 1204 <ul>
max@0 1205 <pre>
max@0 1206 cube c(5,6,7);
max@0 1207 c = 123.0;
max@0 1208 </pre>
max@0 1209 </ul>
max@0 1210 Use the following code instead:
max@0 1211 <ul>
max@0 1212 <pre>
max@0 1213 cube c(5,6,7);
max@0 1214 c.fill(123.0);
max@0 1215 </pre>
max@0 1216 </ul>
max@0 1217 Or:
max@0 1218 <ul>
max@0 1219 <pre>
max@0 1220 cube c = 123.0 * ones&lt;cube&gt;(5,6,7);
max@0 1221 </pre>
max@0 1222 </ul>
max@0 1223 </li>
max@0 1224 </ul>
max@0 1225 <br>
max@0 1226 <li>
max@0 1227 See also:
max@0 1228 <ul>
max@0 1229 <li><a href="#attributes">cube attributes</a></li>
max@0 1230 <li><a href="#element_access">accessing elements</a></li>
max@0 1231 <li><a href="#operators">math &amp; relational operators</a></li>
max@0 1232 <li><a href="#subcube">subcube views and slices</a></li>
max@0 1233 <li><a href="#save_load_mat">saving &amp; loading cubes</a></li>
max@0 1234 <li><a href="#iterators_cube">STL-style element iterators</a></li>
max@0 1235 <li><a href="#Mat">Mat class</a></li>
max@0 1236 </ul>
max@0 1237 </li>
max@0 1238 <br>
max@0 1239 </ul>
max@0 1240 <hr class="greyline">
max@0 1241 <br>
max@0 1242
max@0 1243 <a name="field"></a>
max@0 1244 <b>field&lt;</b><i>object type</i><b>&gt;</b>
max@0 1245 <ul>
max@0 1246 <li>
max@0 1247 Class for one and two dimensional fields of arbitrary objects
max@0 1248 </li>
max@0 1249 <br>
max@0 1250 <li>
max@0 1251 Constructors (where <i>object type</i> is another class, eg. <i>std::string</i>, <i>mat</i>, <i>vec</i>, <i>rowvec</i>, etc):
max@0 1252 <ul>
max@0 1253 field&lt;<i>object type</i>&gt;(n_elem=0)
max@0 1254 <br>field&lt;<i>object type</i>&gt;(n_rows, n_cols)
max@0 1255 <br>field&lt;<i>object type</i>&gt;(field&lt;<i>object type</i>&gt;)
max@0 1256 </ul>
max@0 1257 </li>
max@0 1258 <br>
max@0 1259 <li>
max@0 1260 Examples:
max@0 1261 <ul>
max@0 1262 <pre>
max@0 1263 // create a field of strings
max@0 1264 field&lt;std::string&gt; S(3,2);
max@0 1265
max@0 1266 S(0,0) = "hello";
max@0 1267 S(1,0) = "there";
max@0 1268
max@0 1269 // string fields can be saved as plain text files
max@0 1270 S.save("string_field");
max@0 1271
max@0 1272 // create a vec field with 3 rows and 2 columns
max@0 1273 field&lt;vec&gt; F(3,2);
max@0 1274
max@0 1275 // access components of the field
max@0 1276 F(0,0) = vec(5);
max@0 1277 F(1,1) = randu&lt;vec&gt;(6);
max@0 1278 F(2,0).set_size(7);
max@0 1279
max@0 1280 // access element 1 of the vec stored at 2,0
max@0 1281 double x = F(2,0)(1);
max@0 1282
max@0 1283 // copy rows
max@0 1284 F.row(0) = F.row(2);
max@0 1285
max@0 1286 // extract a row of vecs from F
max@0 1287 field&lt;vec&gt; G = F.row(1);
max@0 1288
max@0 1289 // print the field to the standard output
max@0 1290 G.print("G =");
max@0 1291
max@0 1292 // save the field to a binary file
max@0 1293 G.save("vec_field");
max@0 1294 </pre>
max@0 1295 </ul>
max@0 1296 </li>
max@0 1297 <br>
max@0 1298 <li>See also:
max@0 1299 <ul>
max@0 1300 <li><a href="#attributes">field attributes</a></li>
max@0 1301 <li><a href="#subfield">subfield views</a></li>
max@0 1302 <li><a href="#save_load_field">saving/loading fields</a></li>
max@0 1303 <li><a href="http://cplusplus.com/reference/string/string/">string class in the standard C++ library</a> (cplusplus.com)</li>
max@0 1304 </ul>
max@0 1305 </li>
max@0 1306 <br>
max@0 1307 </ul>
max@0 1308 <hr class="greyline">
max@0 1309 <hr class="greyline">
max@0 1310 <br>
max@0 1311 <br>
max@0 1312 <font size=+1><b>Member Functions &amp; Variables</b></font>
max@0 1313 <br>
max@0 1314 <br>
max@0 1315 <hr class="greyline">
max@0 1316 <br>
max@0 1317
max@0 1318 <a name="attributes"></a>
max@0 1319
max@0 1320 <b>attributes</b>
max@0 1321 <ul>
max@0 1322 <table style="text-align: left;" border="0" cellpadding="0" cellspacing="0">
max@0 1323 <tbody>
max@0 1324 <tr>
max@0 1325 <td>
max@0 1326 <b>.n_rows</b>
max@0 1327 </td>
max@0 1328 <td>&nbsp;&nbsp;</td>
max@0 1329 <td>
max@0 1330 (number of rows)
max@0 1331 </td>
max@0 1332 </tr>
max@0 1333 <tr>
max@0 1334 <td>
max@0 1335 <b>.n_cols</b>
max@0 1336 </td>
max@0 1337 <td>&nbsp;&nbsp;</td>
max@0 1338 <td>
max@0 1339 (number of columns)
max@0 1340 </td>
max@0 1341 </tr>
max@0 1342 <tr>
max@0 1343 <td>
max@0 1344 <b>.n_elem</b>
max@0 1345 </td>
max@0 1346 <td>&nbsp;&nbsp;</td>
max@0 1347 <td>
max@0 1348 (total number of elements)
max@0 1349 </td>
max@0 1350 </tr>
max@0 1351 <tr>
max@0 1352 <td>
max@0 1353 <b>.n_slices</b>
max@0 1354 </td>
max@0 1355 <td>&nbsp;&nbsp;</td>
max@0 1356 <td>
max@0 1357 (number of slices)
max@0 1358 </td>
max@0 1359 </tr>
max@0 1360 </tbody>
max@0 1361 </table>
max@0 1362 </ul>
max@0 1363 <br>
max@0 1364 <ul>
max@0 1365 <li>
max@0 1366 Member variables which are read-only;
max@0 1367 to change the size, use
max@0 1368 <a href="#set_size">.set_size()</a>,
max@0 1369 <a href="#copy_size">.copy_size()</a>,
max@0 1370 <a href="#zeros_member">.zeros()</a>,
max@0 1371 <a href="#ones_member">.ones()</a>,
max@0 1372 or
max@0 1373 <a href="#reset">.reset()</a>
max@0 1374 </li>
max@0 1375 <br>
max@0 1376 <li><i>n_rows</i>, <i>n_cols</i> and <i>n_elem</i> are applicable to <i>Mat</i>, <i>Col</i>, <i>Row</i>, <i>Cube</i> and <i>field</i> classes</li>
max@0 1377 <br>
max@0 1378 <li><i>n_slices</i> is applicable only to the <i>Cube</i> class</li>
max@0 1379 <br>
max@0 1380 <li>
max@0 1381 For the <i>Col</i> and <i>Row</i> classes, <i>n_elem</i> also indicates vector length</li>
max@0 1382 <br>
max@0 1383 <li>The variables are of type <a href="#uword">uword</a></li>
max@0 1384 <br>
max@0 1385 <li>
max@0 1386 Examples:
max@0 1387 <ul>
max@0 1388 <pre>
max@0 1389 mat X(4,5);
max@0 1390 cout &lt;&lt; "X has " &lt;&lt; X.n_cols &lt;&lt; " columns" &lt;&lt; endl;
max@0 1391 </pre>
max@0 1392 </ul>
max@0 1393 </li>
max@0 1394 <br>
max@0 1395 <li>
max@0 1396 See also:
max@0 1397 <ul>
max@0 1398 <li><a href="#set_size">.set_size()</a></li>
max@0 1399 <li><a href="#copy_size">.copy_size()</a></li>
max@0 1400 <li><a href="#zeros_member">.zeros()</a></li>
max@0 1401 <li><a href="#ones_member">.ones()</a></li>
max@0 1402 <li><a href="#reset">.reset()</a></li>
max@0 1403 </ul>
max@0 1404 </li>
max@0 1405 <br>
max@0 1406 </ul>
max@0 1407 <hr class="greyline"><br>
max@0 1408
max@0 1409 <a name="colptr"></a>
max@0 1410 <b>.colptr(col_number)</b>
max@0 1411 <ul>
max@0 1412 <li>
max@0 1413 Member function of <i>Mat</i>
max@0 1414 </li>
max@0 1415 <br>
max@0 1416 <li>
max@0 1417 Obtain a raw pointer to the memory used by the specified column
max@0 1418 </li>
max@0 1419 <br>
max@0 1420 <li>
max@0 1421 As soon as the size of the matrix is changed, the pointer is no longer valid
max@0 1422 </li>
max@0 1423 <br>
max@0 1424 <li>This function is not recommended for use unless you know what you're doing
max@0 1425 -- you may wish to use <a href="#submat">submatrix views</a> instead
max@0 1426 </li>
max@0 1427 <br>
max@0 1428 <li>
max@0 1429 Examples:
max@0 1430 <ul>
max@0 1431 <pre>
max@0 1432 mat A = randu&lt;mat&gt;(5,5);
max@0 1433
max@0 1434 double* mem = A.colptr(2);
max@0 1435 </pre>
max@0 1436 </ul>
max@0 1437 </li>
max@0 1438 <br>
max@0 1439 <li>
max@0 1440 See also:
max@0 1441 <ul>
max@0 1442 <li><a href="#memptr">.memptr()</a></li>
max@0 1443 <li><a href="#submat">submatrix access</a></li>
max@0 1444 <li><a href="#iterators_mat">iterators (matrices)</a></li>
max@0 1445 <li><a href="#adv_constructors_mat">advanced constructors (matrices)</a></li>
max@0 1446 </ul>
max@0 1447 </li>
max@0 1448 <br>
max@0 1449 </ul>
max@0 1450 <hr class="greyline"><br>
max@0 1451
max@0 1452 <a name="copy_size"></a>
max@0 1453 <b>.copy_size(A)</b>
max@0 1454 <ul>
max@0 1455 <li>
max@0 1456 Member function of <i>Mat</i>, <i>Col</i>, <i>Row</i>, <i>Cube</i> and <i>field</i>
max@0 1457 </li>
max@0 1458 <br>
max@0 1459 <li>
max@0 1460 Set the size to be the same as object <i>A</i>
max@0 1461 </li>
max@0 1462 <br>
max@0 1463 <li>
max@0 1464 Object <i>A</i> must be of the same root type as the object being modified
max@0 1465 (eg. you can't set the size of a matrix by providing a cube)
max@0 1466 </li>
max@0 1467 <br>
max@0 1468 <li>
max@0 1469 Examples:
max@0 1470 <ul>
max@0 1471 <pre>
max@0 1472 mat A = randu&lt;mat&gt;(5,6);
max@0 1473 mat B;
max@0 1474 B.copy_size(A);
max@0 1475
max@0 1476 cout &lt;&lt; B.n_rows &lt;&lt; endl;
max@0 1477 cout &lt;&lt; B.n_cols &lt;&lt; endl;
max@0 1478 </pre>
max@0 1479 </ul>
max@0 1480 </li>
max@0 1481 </ul>
max@0 1482 <br>
max@0 1483 <hr class="greyline"><br>
max@0 1484
max@0 1485 <a name="diag"></a>
max@0 1486 <b>.diag(k=0)</b>
max@0 1487 <ul>
max@0 1488 <li>
max@0 1489 Member function of <i>Mat</i>.
max@0 1490 </li>
max@0 1491 <br>
max@0 1492 <li>
max@0 1493 Read/write access to the <i>k</i>-th diagonal in a matrix
max@0 1494 </li>
max@0 1495 <br>
max@0 1496 <li>The argument <i>k</i> is optional -- by default the main diagonal is accessed (<i>k=0</i>)</li>
max@0 1497 <br>
max@0 1498 <li>For <i>k &gt; 0</i>, the <i>k</i>-th super-diagonal is accessed (top-right corner)</li>
max@0 1499 <br>
max@0 1500 <li>For <i>k &lt; 0</i>, the <i>k</i>-th sub-diagonal is accessed (bottom-left corner)</li>
max@0 1501 <br>
max@0 1502 <li>
max@0 1503 An extracted diagonal is interpreted as a column vector
max@0 1504 </li>
max@0 1505 <br>
max@0 1506 <li>
max@0 1507 Examples:
max@0 1508 <ul>
max@0 1509 <pre>
max@0 1510 mat X = randu&lt;mat&gt;(5,5);
max@0 1511
max@0 1512 vec a = X.diag();
max@0 1513 vec b = X.diag(1);
max@0 1514 vec c = X.diag(-2);
max@0 1515
max@0 1516 X.diag() = randu&lt;vec&gt;(5);
max@0 1517 X.diag() += 6;
max@0 1518 </pre>
max@0 1519 </ul>
max@0 1520 </li>
max@0 1521 <br>
max@0 1522 <li>
max@0 1523 See also:
max@0 1524 <ul>
max@0 1525 <li><a href="#diagvec">diagvec()</a></li>
max@0 1526 <li><a href="#submat">submatrix views</a></li>
max@0 1527 </ul>
max@0 1528 </li>
max@0 1529 </ul>
max@0 1530 <br>
max@0 1531 <hr class="greyline"><br>
max@0 1532
max@0 1533 <a name="element_access"></a>
max@0 1534 <b>element/object access via (), [] and .at()</b>
max@0 1535 <ul>
max@0 1536 <li>
max@0 1537 Provide access to individual elements or objects stored in a container object
max@0 1538 (ie., <i>Mat</i>, <i>Col</i>, <i>Row</i>, <i>Cube</i>, <i>field</i>)<br>
max@0 1539 <br>
max@0 1540 <ul>
max@0 1541 <table style="text-align: left; width: 100%;"
max@0 1542 border="0" cellpadding="2" cellspacing="2">
max@0 1543 <tbody>
max@0 1544 <tr>
max@0 1545 <td style="vertical-align: top;">
max@0 1546 <pre>(n)</pre>
max@0 1547 </td>
max@0 1548 <td style="vertical-align: top;">&nbsp;<br>
max@0 1549 </td>
max@0 1550 <td style="vertical-align: top;">
max@0 1551 For <i>vec</i> and <i>rowvec</i>, access the <i>n</i>-th element.
max@0 1552 For <i>mat</i>, <i>cube</i> and <i>field</i>, access the <i>n</i>-th element/object under the assumption of a flat layout,
max@0 1553 with column-major ordering of data (ie. column by column).
max@0 1554 A <i>std::logic_error</i> exception is thrown if the requested element is out of bounds.
max@0 1555 The bounds check can be optionally disabled at compile-time (see below).
max@0 1556 </td>
max@0 1557 </tr>
max@0 1558 <tr>
max@0 1559 <td>&nbsp;</td>
max@0 1560 <td>&nbsp;</td>
max@0 1561 <td>&nbsp;</td>
max@0 1562 </tr>
max@0 1563 <tr>
max@0 1564 <td style="vertical-align: top;">
max@0 1565 <pre>.at(n) and [n]</pre>
max@0 1566 </td>
max@0 1567 <td style="vertical-align: top;"><br>
max@0 1568 </td>
max@0 1569 <td style="vertical-align: top;">
max@0 1570 As for <i>(n)</i>, but without a bounds check.
max@0 1571 Not recommended for use unless your code has been thoroughly debugged.
max@0 1572 </td>
max@0 1573 </tr>
max@0 1574 <tr>
max@0 1575 <td>&nbsp;</td>
max@0 1576 <td>&nbsp;</td>
max@0 1577 <td>&nbsp;</td>
max@0 1578 </tr>
max@0 1579 <tr>
max@0 1580 <td style="vertical-align: top;">
max@0 1581 <pre>(i,j)</pre>
max@0 1582 </td>
max@0 1583 <td style="vertical-align: top;"><br>
max@0 1584 </td>
max@0 1585 <td style="vertical-align: top;">
max@0 1586 For <i>mat</i> and <i>field</i> classes, access the element/object stored at the <i>i</i>-th row and <i>j</i>-th column.
max@0 1587 A <i>std::logic_error</i> exception is thrown if the requested element is out of bounds.
max@0 1588 The bounds check can be optionally disabled at compile-time (see below).
max@0 1589 </td>
max@0 1590 </tr>
max@0 1591 <tr>
max@0 1592 <td>&nbsp;</td>
max@0 1593 <td>&nbsp;</td>
max@0 1594 <td>&nbsp;</td>
max@0 1595 </tr>
max@0 1596 <tr>
max@0 1597 <td style="vertical-align: top;">
max@0 1598 <pre>.at(i,j)</pre>
max@0 1599 </td>
max@0 1600 <td style="vertical-align: top;"><br>
max@0 1601 </td>
max@0 1602 <td style="vertical-align: top;">
max@0 1603 As for <i>(i,j)</i>, but without a bounds check.
max@0 1604 Not recommended for use unless your code has been thoroughly debugged.
max@0 1605 </td>
max@0 1606 <td style="vertical-align: top;"><br>
max@0 1607 </td>
max@0 1608 </tr>
max@0 1609 <tr>
max@0 1610 <td>&nbsp;</td>
max@0 1611 <td>&nbsp;</td>
max@0 1612 <td>&nbsp;</td>
max@0 1613 </tr>
max@0 1614 <tr>
max@0 1615 <td style="vertical-align: top;">
max@0 1616 <pre>(i,j,k)</pre>
max@0 1617 </td>
max@0 1618 <td style="vertical-align: top;"><br>
max@0 1619 </td>
max@0 1620 <td style="vertical-align: top;">
max@0 1621 Cube only: access the element stored at the <i>i</i>-th row, <i>j</i>-th column and <i>k</i>-th slice.
max@0 1622 A <i>std::logic_error</i> exception is thrown if the requested element is out of bounds.
max@0 1623 The bounds check can be optionally disabled at compile-time (see below).
max@0 1624 </td>
max@0 1625 </tr>
max@0 1626 <tr>
max@0 1627 <td>&nbsp;</td>
max@0 1628 <td>&nbsp;</td>
max@0 1629 <td>&nbsp;</td>
max@0 1630 </tr>
max@0 1631 <tr>
max@0 1632 <td style="vertical-align: top;">
max@0 1633 <pre>.at(i,j,k)</pre>
max@0 1634 </td>
max@0 1635 <td style="vertical-align: top;"><br>
max@0 1636 </td>
max@0 1637 <td style="vertical-align: top;">
max@0 1638 As for <i>(i,j,k)</i>, but without a bounds check.
max@0 1639 Not recommended for use unless your code has been thoroughly debugged.</td>
max@0 1640 </tr>
max@0 1641 </tbody>
max@0 1642 </table>
max@0 1643 </ul>
max@0 1644 </li>
max@0 1645 <br>
max@0 1646 <li>
max@0 1647 The bounds checks used by the <i>(n)</i>, <i>(i,j)</i> and <i>(i,j,k)</i> access forms
max@0 1648 can be disabled by defining <i>ARMA_NO_DEBUG</i> or <i>NDEBUG</i> macros
max@0 1649 before including the <i>armadillo</i> header file (eg. <i>#define ARMA_NO_DEBUG</i>).
max@0 1650 Disabling the bounds checks is not recommended until your code has been thoroughly debugged
max@0 1651 -- it's better to write correct code first, and then maximise its speed.
max@0 1652 </li>
max@0 1653 <br>
max@0 1654 <li>
max@0 1655 Examples:
max@0 1656 <ul>
max@0 1657 <pre>
max@0 1658 mat A = randu&lt;mat&gt;(10,10);
max@0 1659 A(9,9) = 123.0;
max@0 1660 double x = A.at(9,9);
max@0 1661 double y = A[99];
max@0 1662
max@0 1663 vec p = randu&lt;vec&gt;(10,1);
max@0 1664 p(9) = 123.0;
max@0 1665 double z = p[9];
max@0 1666 </pre>
max@0 1667 </ul>
max@0 1668 </li>
max@0 1669 <br>
max@0 1670 <li>See also:
max@0 1671 <ul>
max@0 1672 <li><a href="#in_range">.in_range()</a></li>
max@0 1673 <li><a href="#iterators_mat">iterators (matrices)</a></li>
max@0 1674 <li><a href="#iterators_cube">iterators (cubes)</a></li>
max@0 1675 </ul>
max@0 1676 </li>
max@0 1677 <br>
max@0 1678 </ul>
max@0 1679 <hr class="greyline"><br>
max@0 1680
max@0 1681 <a name="element_initialisation"></a>
max@0 1682 <b>element initialisation</b>
max@0 1683 <ul>
max@0 1684 <li>
max@0 1685 Instances of <i>Mat</i>, <i>Col</i>, <i>Row</i> and <i>field</i> classes can be initialised via repeated use of the &lt;&lt; operator
max@0 1686 </li>
max@0 1687 <br>
max@0 1688 <li>
max@0 1689 Special element <i>endr</i> indicates "end of row" (conceptually similar to <i>std::endl</i>)
max@0 1690 </li>
max@0 1691 <br>
max@0 1692 <li>
max@0 1693 Setting elements via &lt;&lt; is a bit slower than directly <a href="#element_access">accessing</a> the elements,
max@0 1694 but code using &lt;&lt; is generally more readable as well as being easier to write
max@0 1695 </li>
max@0 1696 <br>
max@0 1697 <li>
max@0 1698 If you have a C++11 compiler, instances of <i>Mat</i>, <i>Col</i> and <i>Row</i> classes can be also initialised via initialiser lists;
max@0 1699 this requires support for the C++11 standard to be <a href="#added_in_24">explicitly enabled</a>
max@0 1700 </li>
max@0 1701 <br>
max@0 1702 <li>
max@0 1703 Examples:
max@0 1704 <ul>
max@0 1705 <pre>
max@0 1706 mat A;
max@0 1707
max@0 1708 A &lt;&lt; 1 &lt;&lt; 2 &lt;&lt; 3 &lt;&lt; endr
max@0 1709 &lt;&lt; 4 &lt;&lt; 5 &lt;&lt; 6 &lt;&lt; endr;
max@0 1710
max@0 1711 mat B = { 1, 2, 3, 4, 5, 6 }; // C++11 only
max@0 1712 B.reshape(2,3);
max@0 1713 </pre>
max@0 1714 </ul>
max@0 1715 </li>
max@0 1716 <br>
max@0 1717 <li>
max@0 1718 See also:
max@0 1719 <ul>
max@0 1720 <li><a href="#element_access">element access</a></li>
max@0 1721 <li><a href="#print">.print()</a></li>
max@0 1722 <li><a href="#save_load_mat">saving &amp; loading matrices</a></li>
max@0 1723 <li><a href="#adv_constructors_mat">advanced constructors (matrices)</a></li>
max@0 1724 </ul>
max@0 1725 </li>
max@0 1726 <br>
max@0 1727 </ul>
max@0 1728 <hr class="greyline"><br>
max@0 1729
max@0 1730 <a name="eye_member"></a>
max@0 1731 <b>.eye()</b>
max@0 1732 <br>
max@0 1733 <b>.eye(n_rows, n_cols)</b>
max@0 1734 <ul>
max@0 1735 <li>
max@0 1736 Set the elements along the main diagonal to one and off-diagonal elements set to zero,
max@0 1737 optionally first resizing to specified dimensions
max@0 1738 </li>
max@0 1739 <br>
max@0 1740 <li>
max@0 1741 An identity matrix is generated when <i>n_rows</i> = <i>n_cols</i>
max@0 1742 </li>
max@0 1743 <br>
max@0 1744 <li>
max@0 1745 Examples:
max@0 1746 <ul>
max@0 1747 <pre>
max@0 1748 mat A(5,5);
max@0 1749 A.eye();
max@0 1750
max@0 1751 mat B;
max@0 1752 B.eye(5,5);
max@0 1753 </pre>
max@0 1754 </ul>
max@0 1755 </li>
max@0 1756 <br>
max@0 1757 <li>See also:
max@0 1758 <ul>
max@0 1759 <li><a href="#eye_standalone">eye()</a> (standalone function)</li>
max@0 1760 <li><a href="#diagmat">diagmat()</a></li>
max@0 1761 <li><a href="#diagvec">diagvec()</a></li>
max@0 1762 <li><a href="#ones_member">.ones()</a></li>
max@0 1763 </ul>
max@0 1764 </li>
max@0 1765 <br>
max@0 1766 </ul>
max@0 1767 <hr class="greyline"><br>
max@0 1768
max@0 1769 <a name="fill"></a>
max@0 1770 <b>.fill(value)</b>
max@0 1771 <ul>
max@0 1772 <li>
max@0 1773 Member function of <i>Mat</i>, <i>Col</i>, <i>Row</i> and <i>Cube</i> classes.
max@0 1774 </li>
max@0 1775 <br>
max@0 1776 <li>Sets the elements to a specified value.
max@0 1777 The type of value must match the type of elements used by the container object
max@0 1778 (eg. for <i>mat</i> the type is double)
max@0 1779 </li>
max@0 1780 <br>
max@0 1781 <li>
max@0 1782 Examples:
max@0 1783 <ul>
max@0 1784 <pre>
max@0 1785 mat A(5,5);
max@0 1786 A.fill(123.0);
max@0 1787 </pre>
max@0 1788 </ul>
max@0 1789 </li>
max@0 1790 <br>
max@0 1791 <li>
max@0 1792 See also:
max@0 1793 <ul>
max@0 1794 <li><a href="#ones_member">.ones()</a></li>
max@0 1795 <li><a href="#zeros_member">.zeros()</a></li>
max@0 1796 <li><a href="#randu_randn_member">.randu() &amp; .randn()</a></li>
max@0 1797 </ul>
max@0 1798 </li>
max@0 1799 <br>
max@0 1800 </ul>
max@0 1801 <hr class="greyline"><br>
max@0 1802
max@0 1803 <a name="in_range"></a>
max@0 1804 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 1805 <tbody>
max@0 1806 <tr>
max@0 1807 <td style="vertical-align: top;"><b>.in_range(</b> i <b>)</b></td>
max@0 1808 <td style="vertical-align: top;"><br>
max@0 1809 </td>
max@0 1810 <td style="vertical-align: top;">(member of <i>Mat</i>, <i>Col</i>, <i>Row</i>, <i>Cube</i> and <i>field</i>)
max@0 1811 </td>
max@0 1812 </tr>
max@0 1813 <tr>
max@0 1814 <td style="vertical-align: top;"><b>.in_range( span(</b>start<b>,</b> end<b>) )</b></td>
max@0 1815 <td style="vertical-align: top;"><br>
max@0 1816 </td>
max@0 1817 <td style="vertical-align: top;">(member of <i>Mat</i>, <i>Col</i>, <i>Row</i>, <i>Cube</i> and <i>field</i>)
max@0 1818 </td>
max@0 1819 </tr>
max@0 1820 <tr>
max@0 1821 <td>
max@0 1822 &nbsp;
max@0 1823 </td>
max@0 1824 </tr>
max@0 1825 <tr>
max@0 1826 <td style="vertical-align: top;"><b>.in_range(</b> row<b>,</b> col <b>)</b></td>
max@0 1827 <td style="vertical-align: top;"><br>
max@0 1828 </td>
max@0 1829 <td style="vertical-align: top;">(member of <i>Mat</i>, <i>Col</i>, <i>Row</i> and <i>field</i>)
max@0 1830 </td>
max@0 1831 </tr>
max@0 1832 <tr>
max@0 1833 <td style="vertical-align: top;"><b>.in_range( <font size=-1>span(</b>start_row<b>,</b> end_row<b>), span(</b>start_col<b>,</b> end_col<b>)</font> )</b></td>
max@0 1834 <td style="vertical-align: top;"><br>
max@0 1835 </td>
max@0 1836 <td style="vertical-align: top;">(member of <i>Mat</i>, <i>Col</i>, <i>Row</i> and <i>field</i>)
max@0 1837 </td>
max@0 1838 </tr>
max@0 1839 <tr>
max@0 1840 <td>
max@0 1841 &nbsp;
max@0 1842 </td>
max@0 1843 </tr>
max@0 1844 <tr>
max@0 1845 <td style="vertical-align: top;"><b>.in_range(</b> row<b>,</b> col<b>,</b> slice <b>)</b></td>
max@0 1846 <td style="vertical-align: top;"><br>
max@0 1847 </td>
max@0 1848 <td style="vertical-align: top;">(member of <i>Cube</i>)
max@0 1849 </td>
max@0 1850 </tr>
max@0 1851 <tr>
max@0 1852 <td style="vertical-align: top;"><b>.in_range( <font size=-1>span(</b>start_row<b>,</b> end_row<b>), span(</b>start_col<b>,</b> end_col<b>), span(</b>start_slice<b>,</b> end_slice<b>)</font> )</b></td>
max@0 1853 <td style="vertical-align: top;"><br>
max@0 1854 </td>
max@0 1855 <td style="vertical-align: top;">(member of <i>Cube</i>)
max@0 1856 </td>
max@0 1857 </tr>
max@0 1858 </tbody>
max@0 1859 </table>
max@0 1860 <br>
max@0 1861 <ul>
max@0 1862 <li>Returns <i>true</i> if the given location or span is currently valid
max@0 1863 </li>
max@0 1864 <br>
max@0 1865 <li>Returns <i>false</i> if the object is empty, the location is out of bounds, or the span is out of bounds
max@0 1866 </li>
max@0 1867 <br>
max@0 1868 <li>
max@0 1869 Instances of <i>span(a,b)</i> can be replaced by:
max@0 1870 <ul>
max@0 1871 <li><i>span()</i> or <i>span::all</i>, to indicate the entire range</li>
max@0 1872 <li><i>span(a)</i>, to indicate a particular row, column or slice</li>
max@0 1873 </ul>
max@0 1874 </li>
max@0 1875 <br>
max@0 1876 <li>
max@0 1877 Examples:
max@0 1878 <ul>
max@0 1879 <pre>
max@0 1880 mat A = randu&lt;mat&gt;(4,5);
max@0 1881
max@0 1882 cout &lt;&lt; A.in_range(0,0) &lt;&lt; endl; // true
max@0 1883 cout &lt;&lt; A.in_range(3,4) &lt;&lt; endl; // true
max@0 1884 cout &lt;&lt; A.in_range(4,5) &lt;&lt; endl; // false
max@0 1885 </pre>
max@0 1886 </ul>
max@0 1887 </li>
max@0 1888 <br>
max@0 1889 <li>
max@0 1890 See also:
max@0 1891 <ul>
max@0 1892 <li><a href="#element_access">element access</a></li>
max@0 1893 <li><a href="#submat">submatrix views</a></li>
max@0 1894 <li><a href="#subcube">subcube views</a></li>
max@0 1895 <li><a href="#subfield">subfield views</a></li>
max@0 1896 <li><a href="#set_size">.set_size()</a></li>
max@0 1897 </ul>
max@0 1898 </li>
max@0 1899 <br>
max@0 1900 </ul>
max@0 1901 <hr class="greyline"><br>
max@0 1902
max@0 1903 <a name="is_empty"></a>
max@0 1904 <b>.is_empty()</b>
max@0 1905 <ul>
max@0 1906 <li>
max@0 1907 Member function of <i>Mat</i>, <i>Col</i>, <i>Row</i>, <i>Cube</i> and <i>field</i> classes
max@0 1908 </li>
max@0 1909 <br>
max@0 1910 <li>Returns true if the object has no elements
max@0 1911 </li>
max@0 1912 <br>
max@0 1913 <li>Returns false if the object has one or more elements
max@0 1914 </li>
max@0 1915 <br>
max@0 1916 <li>
max@0 1917 Examples:
max@0 1918 <ul>
max@0 1919 <pre>
max@0 1920 mat A = randu&lt;mat&gt;(5,5);
max@0 1921 cout &lt;&lt; A.is_empty() &lt;&lt; endl;
max@0 1922
max@0 1923 A.reset();
max@0 1924 cout &lt;&lt; A.is_empty() &lt;&lt; endl;
max@0 1925 </pre>
max@0 1926 </ul>
max@0 1927 </li>
max@0 1928 <br>
max@0 1929 <li>
max@0 1930 See also:
max@0 1931 <ul>
max@0 1932 <li><a href="#is_square">.is_square()</a></li>
max@0 1933 <li><a href="#is_vec">.is_vec()</a></li>
max@0 1934 <li><a href="#reset">.reset()</a></li>
max@0 1935 </ul>
max@0 1936 </li>
max@0 1937 <br>
max@0 1938 </ul>
max@0 1939 <hr class="greyline"><br>
max@0 1940
max@0 1941 <a name="is_finite"></a>
max@0 1942 <b>.is_finite()</b>
max@0 1943 <ul>
max@0 1944 <li>
max@0 1945 Member function of <i>Mat</i>, <i>Col</i>, <i>Row</i> and <i>Cube</i> classes
max@0 1946 </li>
max@0 1947 <br>
max@0 1948 <li>Returns <i>true</i> if all elements of the object are finite
max@0 1949 </li>
max@0 1950 <br>
max@0 1951 <li>Returns <i>false</i> if at least one of the elements of the object is non-finite (&plusmn;infinity or NaN)
max@0 1952 </li>
max@0 1953 <br>
max@0 1954 <li>
max@0 1955 Examples:
max@0 1956 <ul>
max@0 1957 <pre>
max@0 1958 mat A = randu&lt;mat&gt;(5,5);
max@0 1959 mat B = randu&lt;mat&gt;(5,5);
max@0 1960
max@0 1961 B(1,1) = math::nan()
max@0 1962
max@0 1963 cout &lt;&lt; A.is_finite() &lt;&lt; endl;
max@0 1964 cout &lt;&lt; B.is_finite() &lt;&lt; endl;
max@0 1965 </pre>
max@0 1966 </ul>
max@0 1967 </li>
max@0 1968 <br>
max@0 1969 <li>
max@0 1970 See also:
max@0 1971 <ul>
max@0 1972 <li><a href="#math_constants">math::nan()</a></li>
max@0 1973 <li><a href="#math_constants">math::inf()</a></li>
max@0 1974 <li><a href="#is_finite_standalone">is_finite()</a> (standalone function)</li>
max@0 1975 </ul>
max@0 1976 </li>
max@0 1977 <br>
max@0 1978 </ul>
max@0 1979 <hr class="greyline"><br>
max@0 1980
max@0 1981 <a name="is_square"></a>
max@0 1982 <b>.is_square()</b>
max@0 1983 <ul>
max@0 1984 <li>
max@0 1985 Member function of the <i>Mat</i> class
max@0 1986 </li>
max@0 1987 <br>
max@0 1988 <li>Returns <i>true</i> if the matrix is square, ie., number of rows is equal to the number of columns
max@0 1989 </li>
max@0 1990 <br>
max@0 1991 <li>Returns <i>false</i> if the matrix is not square
max@0 1992 </li>
max@0 1993 <br>
max@0 1994 <li>
max@0 1995 Examples:
max@0 1996 <ul>
max@0 1997 <pre>
max@0 1998 mat A = randu&lt;mat&gt;(5,5);
max@0 1999 mat B = randu&lt;mat&gt;(6,7);
max@0 2000
max@0 2001 cout &lt;&lt; A.is_square() &lt;&lt; endl;
max@0 2002 cout &lt;&lt; B.is_square() &lt;&lt; endl;
max@0 2003 </pre>
max@0 2004 </ul>
max@0 2005 </li>
max@0 2006 <br>
max@0 2007 <li>
max@0 2008 See also:
max@0 2009 <ul>
max@0 2010 <li><a href="#is_empty">.is_empty()</a></li>
max@0 2011 <li><a href="#is_vec">.is_vec()</a></li>
max@0 2012 </ul>
max@0 2013 </li>
max@0 2014 </ul>
max@0 2015 <br>
max@0 2016 <hr class="greyline"><br>
max@0 2017
max@0 2018 <a name="is_vec"></a>
max@0 2019 <b>.is_vec()</b>
max@0 2020 <br><b>.is_colvec()</b>
max@0 2021 <br><b>.is_rowvec()</b>
max@0 2022 <ul>
max@0 2023 <li>
max@0 2024 Member functions of the <i>Mat</i> class
max@0 2025 </li>
max@0 2026 <br>
max@0 2027
max@0 2028 <li>.is_vec():
max@0 2029 <ul>
max@0 2030 <li>Returns <i>true</i> if the matrix can be interpreted as a vector (either column or row vector)
max@0 2031 </li>
max@0 2032 <li>Returns <i>false</i> if the matrix does not have exactly one column or one row
max@0 2033 </li>
max@0 2034 </ul>
max@0 2035 </li>
max@0 2036 <br>
max@0 2037
max@0 2038 <li>.is_colvec():
max@0 2039 <ul>
max@0 2040 <li>Returns <i>true</i> if the matrix can be interpreted as a column vector
max@0 2041 </li>
max@0 2042 <li>Returns <i>false</i> if the matrix does not have exactly one column
max@0 2043 </li>
max@0 2044 </ul>
max@0 2045 </li>
max@0 2046 <br>
max@0 2047
max@0 2048 <li>.is_rowvec():
max@0 2049 <ul>
max@0 2050 <li>Returns <i>true</i> if the matrix can be interpreted as a row vector
max@0 2051 </li>
max@0 2052 <li>Returns <i>false</i> if the matrix does not have exactly one row
max@0 2053 </li>
max@0 2054 </ul>
max@0 2055 </li>
max@0 2056 <br>
max@0 2057
max@0 2058 <li><b>Caveat:</b> do not assume that the vector has elements if these functions return <i>true</i> -- it is possible to have an empty vector (eg. 0x1)
max@0 2059 </li>
max@0 2060 <br>
max@0 2061 <li>
max@0 2062 Examples:
max@0 2063 <ul>
max@0 2064 <pre>
max@0 2065 mat A = randu&lt;mat&gt;(1,5);
max@0 2066 mat B = randu&lt;mat&gt;(5,1);
max@0 2067 mat C = randu&lt;mat&gt;(5,5);
max@0 2068
max@0 2069 cout &lt;&lt; A.is_vec() &lt;&lt; endl;
max@0 2070 cout &lt;&lt; B.is_vec() &lt;&lt; endl;
max@0 2071 cout &lt;&lt; C.is_vec() &lt;&lt; endl;
max@0 2072 </pre>
max@0 2073 </ul>
max@0 2074 </li>
max@0 2075 <br>
max@0 2076 <li>
max@0 2077 See also:
max@0 2078 <ul>
max@0 2079 <li><a href="#is_empty">.is_empty()</a></li>
max@0 2080 <li><a href="#is_square">.is_square()</a></li>
max@0 2081 </ul>
max@0 2082 </li>
max@0 2083 </ul>
max@0 2084 <br>
max@0 2085 <hr class="greyline"><br>
max@0 2086
max@0 2087 <a name="insert"></a>
max@0 2088 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 2089 <tbody>
max@0 2090 <tr>
max@0 2091 <td style="vertical-align: top;">
max@0 2092 <b>.insert_rows(&nbsp;</b>row_number, X<b>&nbsp;)</b>
max@0 2093 <br>
max@0 2094 <b>.insert_rows(&nbsp;</b>row_number, number_of_rows, set_to_zero&nbsp;=&nbsp;true<b>&nbsp;)</b>
max@0 2095 </td>
max@0 2096 <td style="vertical-align: top;"><br></td>
max@0 2097 <td style="vertical-align: top;">(member functions of <i>Mat</i> and <i>Col</i>)
max@0 2098 </td>
max@0 2099 </tr>
max@0 2100 <tr>
max@0 2101 <td>&nbsp;</td>
max@0 2102 </tr>
max@0 2103 <tr>
max@0 2104 <td style="vertical-align: top;">
max@0 2105 <b>.insert_cols(&nbsp;</b>col_number, X<b>&nbsp;)</b>
max@0 2106 <br>
max@0 2107 <b>.insert_cols(&nbsp;</b>col_number, number_of_cols, set_to_zero&nbsp;=&nbsp;true<b>&nbsp;)</b>
max@0 2108 </td>
max@0 2109 <td style="vertical-align: top;"><br></td>
max@0 2110 <td style="vertical-align: top;">(member functions of <i>Mat</i> and <i>Row</i>)
max@0 2111 </td>
max@0 2112 </tr>
max@0 2113 <tr>
max@0 2114 <td>&nbsp;</td>
max@0 2115 </tr>
max@0 2116 <tr>
max@0 2117 <td style="vertical-align: top;">
max@0 2118 <b>.insert_slices(&nbsp;</b>slice_number, X<b>&nbsp;)</b>
max@0 2119 <br>
max@0 2120 <b>.insert_slices(&nbsp;</b>slice_number, number_of_slices, set_to_zero&nbsp;=&nbsp;true<b>&nbsp;)</b>
max@0 2121 </td>
max@0 2122 <td style="vertical-align: top;"><br></td>
max@0 2123 <td style="vertical-align: top;">(member functions of <i>Cube</i>)
max@0 2124 </td>
max@0 2125 </tr>
max@0 2126 </tbody>
max@0 2127 </table>
max@0 2128 <br>
max@0 2129 <ul>
max@0 2130 <li>
max@0 2131 Functions with the <i>X</i> argument: insert a copy of X at the specified row/column/slice
max@0 2132 <ul>
max@0 2133 <li>if inserting rows, X must have the same number of columns as the recipient object</li>
max@0 2134 <li>if inserting columns, X must have the same number of rows as the recipient object</li>
max@0 2135 <li>if inserting slices, X must have the same number of rows and columns as the recipient object (ie. all slices must have the same size)</li>
max@0 2136 </ul>
max@0 2137 </li>
max@0 2138 <br>
max@0 2139 <li>
max@0 2140 Functions with the <i>number_of_...</i> argument: expand the object by creating new rows/columns/slices.
max@0 2141 By default, the new rows/columns/slices are set to zero.
max@0 2142 If <i>set_to_zero</i> is <i>false</i>, the memory used by the new rows/columns/slices will not be initialised.
max@0 2143 </li>
max@0 2144 <br>
max@0 2145 <li>
max@0 2146 Examples:
max@0 2147 <ul>
max@0 2148 <pre>
max@0 2149 mat A = randu&lt;mat&gt;(5,10);
max@0 2150 mat B = ones&lt;mat&gt;(5,2);
max@0 2151
max@0 2152 // at column 2, insert a copy of B;
max@0 2153 // A will now have 12 columns
max@0 2154 A.insert_cols(2, B);
max@0 2155
max@0 2156 // at column 1, insert 5 zeroed columns;
max@0 2157 // B will now have 7 columns
max@0 2158 B.insert_cols(1, 5);
max@0 2159 </pre>
max@0 2160 </ul>
max@0 2161 </li>
max@0 2162 <br>
max@0 2163 <li>
max@0 2164 See also:
max@0 2165 <ul>
max@0 2166 <li><a href="#shed">shed rows/columns/slices</a></li>
max@0 2167 <li><a href="#join">join rows/columns/slices</a></li>
max@0 2168 <li><a href="#resize_member">.resize()</a></li>
max@0 2169 <li><a href="#submat">submatrix views</a></li>
max@0 2170 <li><a href="#subcube">subcube views</a></li>
max@0 2171 </ul>
max@0 2172 </li>
max@0 2173 <br>
max@0 2174 </ul>
max@0 2175 <hr class="greyline"><br>
max@0 2176
max@0 2177 <a name="iterators_mat"></a>
max@0 2178 <b>iterators (matrices &amp; vectors)</b>
max@0 2179 <ul>
max@0 2180 <li>
max@0 2181 STL-style iterators and associated member functions of the <i>Mat</i>, <i>Col</i> and <i>Row</i> classes
max@0 2182 </li>
max@0 2183 <br>
max@0 2184 <li>
max@0 2185 iterator types:
max@0 2186 <br>
max@0 2187 <br>
max@0 2188 <ul>
max@0 2189 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 2190 <tbody>
max@0 2191 <tr>
max@0 2192 <td style="vertical-align: top;">
max@0 2193 <b>mat::iterator</b>
max@0 2194 <br>
max@0 2195 <b>vec::iterator</b>
max@0 2196 <br>
max@0 2197 <b>rowvec::iterator</b>
max@0 2198 </td>
max@0 2199 <td style="vertical-align: top;">&nbsp;<br>
max@0 2200 </td>
max@0 2201 <td style="vertical-align: top;">
max@0 2202 random access iterators, for read/write access to elements
max@0 2203 (which are stored column by column)
max@0 2204 </td>
max@0 2205 </tr>
max@0 2206 <tr>
max@0 2207 <td style="vertical-align: top;">
max@0 2208 &nbsp;
max@0 2209 </td>
max@0 2210 <td style="vertical-align: top;">&nbsp;<br>
max@0 2211 </td>
max@0 2212 <td style="vertical-align: top;">
max@0 2213 &nbsp;
max@0 2214 </td>
max@0 2215 </tr>
max@0 2216 <tr>
max@0 2217 <td style="vertical-align: top;">
max@0 2218 <b>mat::const_iterator</b>
max@0 2219 <br>
max@0 2220 <b>vec::const_iterator</b>
max@0 2221 <br>
max@0 2222 <b>rowvec::const_iterator</b>
max@0 2223 </td>
max@0 2224 <td style="vertical-align: top;">&nbsp;<br>
max@0 2225 </td>
max@0 2226 <td style="vertical-align: top;">
max@0 2227 random access iterators, for read-only access to elements
max@0 2228 (which are stored column by column)
max@0 2229 </td>
max@0 2230 </tr>
max@0 2231 <tr>
max@0 2232 <td style="vertical-align: top;">
max@0 2233 &nbsp;
max@0 2234 </td>
max@0 2235 <td style="vertical-align: top;">&nbsp;<br>
max@0 2236 </td>
max@0 2237 <td style="vertical-align: top;">
max@0 2238 &nbsp;
max@0 2239 </td>
max@0 2240 </tr>
max@0 2241 <tr>
max@0 2242 <td style="vertical-align: top;">
max@0 2243 <b>mat::col_iterator</b>
max@0 2244 <br>
max@0 2245 <b>vec::col_iterator</b>
max@0 2246 <br>
max@0 2247 <b>rowvec::col_iterator</b>
max@0 2248 </td>
max@0 2249 <td style="vertical-align: top;">&nbsp;<br>
max@0 2250 </td>
max@0 2251 <td style="vertical-align: top;">
max@0 2252 random access iterators, for read/write access to the elements of a specific column
max@0 2253 </td>
max@0 2254 </tr>
max@0 2255 <tr>
max@0 2256 <td style="vertical-align: top;">
max@0 2257 &nbsp;
max@0 2258 </td>
max@0 2259 <td style="vertical-align: top;">&nbsp;<br>
max@0 2260 </td>
max@0 2261 <td style="vertical-align: top;">
max@0 2262 &nbsp;
max@0 2263 </td>
max@0 2264 </tr>
max@0 2265 <tr>
max@0 2266 <td style="vertical-align: top;">
max@0 2267 <b>mat::const_col_iterator</b>
max@0 2268 <br>
max@0 2269 <b>vec::const_col_iterator</b>
max@0 2270 <br>
max@0 2271 <b>rowvec::const_col_iterator</b>
max@0 2272 </td>
max@0 2273 <td style="vertical-align: top;">&nbsp;<br>
max@0 2274 </td>
max@0 2275 <td style="vertical-align: top;">
max@0 2276 random access iterators, for read-only access to the elements of a specific column
max@0 2277 </td>
max@0 2278 </tr>
max@0 2279 <tr>
max@0 2280 <td style="vertical-align: top;">
max@0 2281 &nbsp;
max@0 2282 </td>
max@0 2283 <td style="vertical-align: top;">&nbsp;<br>
max@0 2284 </td>
max@0 2285 <td style="vertical-align: top;">
max@0 2286 &nbsp;
max@0 2287 </td>
max@0 2288 </tr>
max@0 2289 <tr>
max@0 2290 <td style="vertical-align: top;">
max@0 2291 <b>mat::row_iterator</b>
max@0 2292 </td>
max@0 2293 <td style="vertical-align: top;">&nbsp;<br>
max@0 2294 </td>
max@0 2295 <td style="vertical-align: top;">
max@0 2296 rudimentary forward iterator, for read/write access to the elements of a specific row
max@0 2297 </td>
max@0 2298 </tr>
max@0 2299 <tr>
max@0 2300 <td style="vertical-align: top;">
max@0 2301 &nbsp;
max@0 2302 </td>
max@0 2303 <td style="vertical-align: top;">&nbsp;<br>
max@0 2304 </td>
max@0 2305 <td style="vertical-align: top;">
max@0 2306 &nbsp;
max@0 2307 </td>
max@0 2308 </tr>
max@0 2309 <tr>
max@0 2310 <td style="vertical-align: top;">
max@0 2311 <b>mat::const_row_iterator</b>
max@0 2312 </td>
max@0 2313 <td style="vertical-align: top;">&nbsp;<br>
max@0 2314 </td>
max@0 2315 <td style="vertical-align: top;">
max@0 2316 rudimentary forward iterator, for read-only access to the elements of a specific row
max@0 2317 </td>
max@0 2318 </tr>
max@0 2319 <tr>
max@0 2320 <td style="vertical-align: top;">
max@0 2321 &nbsp;
max@0 2322 </td>
max@0 2323 <td style="vertical-align: top;">&nbsp;<br>
max@0 2324 </td>
max@0 2325 <td style="vertical-align: top;">
max@0 2326 &nbsp;
max@0 2327 </td>
max@0 2328 </tr>
max@0 2329 <tr>
max@0 2330 <td style="vertical-align: top;">
max@0 2331 <b>vec::row_iterator</b>
max@0 2332 <br>
max@0 2333 <b>rowvec::row_iterator</b>
max@0 2334 </td>
max@0 2335 <td style="vertical-align: top;">&nbsp;<br>
max@0 2336 </td>
max@0 2337 <td style="vertical-align: top;">
max@0 2338 random access iterators, for read/write access to the elements of a specific row
max@0 2339 </td>
max@0 2340 </tr>
max@0 2341 <tr>
max@0 2342 <td style="vertical-align: top;">
max@0 2343 &nbsp;
max@0 2344 </td>
max@0 2345 <td style="vertical-align: top;">&nbsp;<br>
max@0 2346 </td>
max@0 2347 <td style="vertical-align: top;">
max@0 2348 &nbsp;
max@0 2349 </td>
max@0 2350 </tr>
max@0 2351 <tr>
max@0 2352 <td style="vertical-align: top;">
max@0 2353 <b>vec::const_row_iterator</b>
max@0 2354 <br>
max@0 2355 <b>rowvec::const_row_iterator</b>
max@0 2356 </td>
max@0 2357 <td style="vertical-align: top;">&nbsp;<br>
max@0 2358 </td>
max@0 2359 <td style="vertical-align: top;">
max@0 2360 random access iterators, for read-only access to the elements of a specific row
max@0 2361 </td>
max@0 2362 </tr>
max@0 2363 </tbody>
max@0 2364 </table>
max@0 2365 </ul>
max@0 2366 </li>
max@0 2367 <br>
max@0 2368 <br>
max@0 2369 <li>
max@0 2370 Member functions:
max@0 2371 <br>
max@0 2372 <br>
max@0 2373 <ul>
max@0 2374 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 2375 <tbody>
max@0 2376 <tr>
max@0 2377 <td style="vertical-align: top;">
max@0 2378 <b>.begin()</b>
max@0 2379 </td>
max@0 2380 <td style="vertical-align: top;">&nbsp;<br>
max@0 2381 </td>
max@0 2382 <td style="vertical-align: top;">
max@0 2383 iterator referring to the first element
max@0 2384 </td>
max@0 2385 </tr>
max@0 2386 <tr>
max@0 2387 <td style="vertical-align: top;">
max@0 2388 <b>.end()</b>
max@0 2389 </td>
max@0 2390 <td style="vertical-align: top;">&nbsp;<br>
max@0 2391 </td>
max@0 2392 <td style="vertical-align: top;">
max@0 2393 iterator referring to the <i>past-the-end</i> element
max@0 2394 </td>
max@0 2395 </tr>
max@0 2396 <tr>
max@0 2397 <td>
max@0 2398 &nbsp;
max@0 2399 </td>
max@0 2400 </tr>
max@0 2401 <tr>
max@0 2402 <td style="vertical-align: top;">
max@0 2403 <b>.begin_row(</b><i>row_number</i><b>)</b>
max@0 2404 </td>
max@0 2405 <td style="vertical-align: top;">&nbsp;<br>
max@0 2406 </td>
max@0 2407 <td style="vertical-align: top;">
max@0 2408 iterator referring to the first element of the specified row
max@0 2409 </td>
max@0 2410 </tr>
max@0 2411 <tr>
max@0 2412 <td style="vertical-align: top;">
max@0 2413 <b>.end_row(</b><i>row_number</i><b>)</b>
max@0 2414 </td>
max@0 2415 <td style="vertical-align: top;">&nbsp;<br>
max@0 2416 </td>
max@0 2417 <td style="vertical-align: top;">
max@0 2418 iterator referring to the <i>past-the-end</i> element of the specified row
max@0 2419 </td>
max@0 2420 </tr>
max@0 2421 <tr>
max@0 2422 <td>
max@0 2423 &nbsp;
max@0 2424 </td>
max@0 2425 </tr>
max@0 2426 <tr>
max@0 2427 <td style="vertical-align: top;">
max@0 2428 <b>.begin_col(</b><i>col_number</i><b>)</b>
max@0 2429 </td>
max@0 2430 <td style="vertical-align: top;">&nbsp;<br>
max@0 2431 </td>
max@0 2432 <td style="vertical-align: top;">
max@0 2433 iterator referring to the first element of the specified column
max@0 2434 </td>
max@0 2435 </tr>
max@0 2436 <tr>
max@0 2437 <td style="vertical-align: top;">
max@0 2438 <b>.end_col(</b><i>col_number</i><b>)</b>
max@0 2439 </td>
max@0 2440 <td style="vertical-align: top;">&nbsp;<br>
max@0 2441 </td>
max@0 2442 <td style="vertical-align: top;">
max@0 2443 iterator referring to the <i>past-the-end</i> element of the specified column
max@0 2444 </td>
max@0 2445 </tr>
max@0 2446 </tbody>
max@0 2447 </table>
max@0 2448 </ul>
max@0 2449 </li>
max@0 2450 <br>
max@0 2451 <br>
max@0 2452 <li>
max@0 2453 Examples:
max@0 2454 <ul>
max@0 2455 <pre>
max@0 2456 mat X = randu&lt;mat&gt;(5,5);
max@0 2457
max@0 2458
max@0 2459 mat::iterator a = X.begin();
max@0 2460 mat::iterator b = X.end();
max@0 2461
max@0 2462 for(mat::iterator i=a; i!=b; ++i)
max@0 2463 {
max@0 2464 cout &lt;&lt; *i &lt;&lt; endl;
max@0 2465 }
max@0 2466
max@0 2467
max@0 2468 mat::col_iterator c = X.begin_col(1); // start of column 1
max@0 2469 mat::col_iterator d = X.end_col(3); // end of column 3
max@0 2470
max@0 2471 for(mat::col_iterator i=c; i!=d; ++i)
max@0 2472 {
max@0 2473 cout &lt;&lt; *i &lt;&lt; endl;
max@0 2474 (*i) = 123.0;
max@0 2475 }
max@0 2476 </pre>
max@0 2477 </ul>
max@0 2478 </li>
max@0 2479 <br>
max@0 2480 <li>
max@0 2481 See also:
max@0 2482 <ul>
max@0 2483 <li><a href="#stl_container_fns">STL container functions</a></li>
max@0 2484 <li><a href="http://cplusplus.com/reference/std/iterator/">iterator at cplusplus.com</a></li>
max@0 2485 <li><a href="#element_access">element access</a></li>
max@0 2486 </ul>
max@0 2487 </li>
max@0 2488 <br>
max@0 2489 </ul>
max@0 2490 <hr class="greyline"><br>
max@0 2491
max@0 2492 <a name="iterators_cube"></a>
max@0 2493 <b>iterators (cubes)</b>
max@0 2494 <ul>
max@0 2495 <li>
max@0 2496 STL-style iterators and associated member functions of the <i>Cube</i> class
max@0 2497 </li>
max@0 2498 <br>
max@0 2499 <li>
max@0 2500 iterator types:
max@0 2501 <br>
max@0 2502 <br>
max@0 2503 <ul>
max@0 2504 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 2505 <tbody>
max@0 2506 <tr>
max@0 2507 <td style="vertical-align: top;">
max@0 2508 <b>cube::iterator</b>
max@0 2509 </td>
max@0 2510 <td style="vertical-align: top;">&nbsp;<br>
max@0 2511 </td>
max@0 2512 <td style="vertical-align: top;">
max@0 2513 random access iterator, for read/write access to elements;
max@0 2514 the elements are ordered slice by slice;
max@0 2515 the elements within each slice are ordered column by column
max@0 2516 </td>
max@0 2517 </tr>
max@0 2518 <tr>
max@0 2519 <td style="vertical-align: top;">
max@0 2520 &nbsp;
max@0 2521 </td>
max@0 2522 <td style="vertical-align: top;">&nbsp;<br>
max@0 2523 </td>
max@0 2524 <td style="vertical-align: top;">
max@0 2525 &nbsp;
max@0 2526 </td>
max@0 2527 </tr>
max@0 2528 <tr>
max@0 2529 <td style="vertical-align: top;">
max@0 2530 <b>cube::const_iterator</b>
max@0 2531 </td>
max@0 2532 <td style="vertical-align: top;">&nbsp;<br>
max@0 2533 </td>
max@0 2534 <td style="vertical-align: top;">
max@0 2535 random access iterators, for read-only access to elements
max@0 2536 </td>
max@0 2537 </tr>
max@0 2538 <tr>
max@0 2539 <td style="vertical-align: top;">
max@0 2540 &nbsp;
max@0 2541 </td>
max@0 2542 <td style="vertical-align: top;">&nbsp;<br>
max@0 2543 </td>
max@0 2544 <td style="vertical-align: top;">
max@0 2545 &nbsp;
max@0 2546 </td>
max@0 2547 </tr>
max@0 2548 <tr>
max@0 2549 <td style="vertical-align: top;">
max@0 2550 <b>cube::slice_iterator</b>
max@0 2551 </td>
max@0 2552 <td style="vertical-align: top;">&nbsp;<br>
max@0 2553 </td>
max@0 2554 <td style="vertical-align: top;">
max@0 2555 random access iterator, for read/write access to the elements of a particular slice;
max@0 2556 the elements are ordered column by column
max@0 2557 </td>
max@0 2558 </tr>
max@0 2559 <tr>
max@0 2560 <td style="vertical-align: top;">
max@0 2561 &nbsp;
max@0 2562 </td>
max@0 2563 <td style="vertical-align: top;">&nbsp;<br>
max@0 2564 </td>
max@0 2565 <td style="vertical-align: top;">
max@0 2566 &nbsp;
max@0 2567 </td>
max@0 2568 </tr>
max@0 2569 <tr>
max@0 2570 <td style="vertical-align: top;">
max@0 2571 <b>cube::const_slice_iterator</b>
max@0 2572 </td>
max@0 2573 <td style="vertical-align: top;">&nbsp;<br>
max@0 2574 </td>
max@0 2575 <td style="vertical-align: top;">
max@0 2576 random access iterators, for read-only access to the elements of a particular slice
max@0 2577 </td>
max@0 2578 </tr>
max@0 2579 </tbody>
max@0 2580 </table>
max@0 2581 </ul>
max@0 2582 </li>
max@0 2583 <br>
max@0 2584 <br>
max@0 2585 <li>
max@0 2586 Member functions:
max@0 2587 <br>
max@0 2588 <br>
max@0 2589 <ul>
max@0 2590 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 2591 <tbody>
max@0 2592 <tr>
max@0 2593 <td style="vertical-align: top;">
max@0 2594 <b>.begin()</b>
max@0 2595 </td>
max@0 2596 <td style="vertical-align: top;">&nbsp;<br>
max@0 2597 </td>
max@0 2598 <td style="vertical-align: top;">
max@0 2599 iterator referring to the first element
max@0 2600 </td>
max@0 2601 </tr>
max@0 2602 <tr>
max@0 2603 <td style="vertical-align: top;">
max@0 2604 <b>.end()</b>
max@0 2605 </td>
max@0 2606 <td style="vertical-align: top;">&nbsp;<br>
max@0 2607 </td>
max@0 2608 <td style="vertical-align: top;">
max@0 2609 iterator referring to the <i>past-the-end</i> element
max@0 2610 </td>
max@0 2611 </tr>
max@0 2612 <tr>
max@0 2613 <td>
max@0 2614 &nbsp;
max@0 2615 </td>
max@0 2616 </tr>
max@0 2617 <tr>
max@0 2618 <td style="vertical-align: top;">
max@0 2619 <b>.begin_slice(</b><i>slice_number</i><b>)</b>
max@0 2620 </td>
max@0 2621 <td style="vertical-align: top;">&nbsp;<br>
max@0 2622 </td>
max@0 2623 <td style="vertical-align: top;">
max@0 2624 iterator referring to the first element of the specified slice
max@0 2625 </td>
max@0 2626 </tr>
max@0 2627 <tr>
max@0 2628 <td style="vertical-align: top;">
max@0 2629 <b>.end_slice(</b><i>slice_number</i><b>)</b>
max@0 2630 </td>
max@0 2631 <td style="vertical-align: top;">&nbsp;<br>
max@0 2632 </td>
max@0 2633 <td style="vertical-align: top;">
max@0 2634 iterator referring to the <i>past-the-end</i> element of the specified slice
max@0 2635 </td>
max@0 2636 </tr>
max@0 2637 </tbody>
max@0 2638 </table>
max@0 2639 </ul>
max@0 2640 </li>
max@0 2641 <br>
max@0 2642 <br>
max@0 2643 <li>
max@0 2644 Examples:
max@0 2645 <ul>
max@0 2646 <pre>
max@0 2647 cube X = randu&lt;cube&gt;(2,3,4);
max@0 2648
max@0 2649
max@0 2650 cube::iterator a = X.begin();
max@0 2651 cube::iterator b = X.end();
max@0 2652
max@0 2653 for(cube::iterator i=a; i!=b; ++i)
max@0 2654 {
max@0 2655 cout &lt;&lt; *i &lt;&lt; endl;
max@0 2656 }
max@0 2657
max@0 2658
max@0 2659 cube::slice_iterator c = X.begin_slice(1); // start of slice 1
max@0 2660 cube::slice_iterator d = X.end_slice(2); // end of slice 2
max@0 2661
max@0 2662 for(cube::slice_iterator i=c; i!=d; ++i)
max@0 2663 {
max@0 2664 cout &lt;&lt; *i &lt;&lt; endl;
max@0 2665 (*i) = 123.0;
max@0 2666 }
max@0 2667 </pre>
max@0 2668 </ul>
max@0 2669 </li>
max@0 2670 <br>
max@0 2671 <li>
max@0 2672 See also:
max@0 2673 <ul>
max@0 2674 <li><a href="http://cplusplus.com/reference/std/iterator/">iterator at cplusplus.com</a></li>
max@0 2675 <li><a href="#element_access">element access</a></li>
max@0 2676 </ul>
max@0 2677 </li>
max@0 2678 <br>
max@0 2679 </ul>
max@0 2680 <hr class="greyline"><br>
max@0 2681
max@0 2682 <a name="memptr"></a>
max@0 2683 <b>.memptr()</b>
max@0 2684 <ul>
max@0 2685 <li>
max@0 2686 Member function of <i>Mat</i>, <i>Col</i>, <i>Row</i> and <i>Cube</i> classes
max@0 2687 </li>
max@0 2688 <br>
max@0 2689 <li>
max@0 2690 Obtain a raw pointer to the memory used for storing elements. Not recommended for use unless you know what you're doing!
max@0 2691 </li>
max@0 2692 <br>
max@0 2693 <li>
max@0 2694 The function can be used for interfacing with libraries such as <a href="http://www.fftw.org/">FFTW</a>
max@0 2695 </li>
max@0 2696 <br>
max@0 2697 <li>
max@0 2698 As soon as the size of the matrix/vector/cube is changed, the pointer is no longer valid
max@0 2699 </li>
max@0 2700 <br>
max@0 2701 <li>
max@0 2702 Data for matrices is stored in a column-by-column order
max@0 2703 </li>
max@0 2704 <br>
max@0 2705 <li>
max@0 2706 Data for cubes is stored in a slice-by-slice (matrix-by-matrix) order
max@0 2707 </li>
max@0 2708 <br>
max@0 2709 <li>
max@0 2710 Examples:
max@0 2711 <ul>
max@0 2712 <pre>
max@0 2713 mat A = randu&lt;mat&gt;(5,5);
max@0 2714 const mat B = randu&lt;mat&gt;(5,5);
max@0 2715
max@0 2716 double* A_mem = A.memptr();
max@0 2717 const double* B_mem = B.memptr();
max@0 2718 </pre>
max@0 2719 </ul>
max@0 2720 </li>
max@0 2721 <br>
max@0 2722 <li>
max@0 2723 See also:
max@0 2724 <ul>
max@0 2725 <li><a href="#colptr">.colptr()</a></li>
max@0 2726 <li><a href="#iterators_mat">iterators (matrices)</a></li>
max@0 2727 <li><a href="#iterators_cube">iterators (cubes)</a></li>
max@0 2728 <li><a href="#adv_constructors_mat">advanced constructors (matrices)</a></li>
max@0 2729 <li><a href="#adv_constructors_cube">advanced constructors (cubes)</a></li>
max@0 2730 </ul>
max@0 2731 </li>
max@0 2732 <br>
max@0 2733 </ul>
max@0 2734 <hr class="greyline"><br>
max@0 2735
max@0 2736 <a name="min_and_max_member"></a>
max@0 2737 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 2738 <tbody>
max@0 2739 <tr>
max@0 2740 <td style="vertical-align: top;"><b>.min()</b></td>
max@0 2741 <td style="vertical-align: top;"><br>
max@0 2742 </td>
max@0 2743 <td style="vertical-align: top;">(member functions of <i>Mat</i>, <i>Col</i>, <i>Row</i>, <i>Cube</i>)
max@0 2744 </td>
max@0 2745 </tr>
max@0 2746 <tr>
max@0 2747 <td style="vertical-align: top;"><b>.max()</b></td>
max@0 2748 <td style="vertical-align: top;"><br>
max@0 2749 </td>
max@0 2750 <td style="vertical-align: top;">&nbsp;
max@0 2751 </td>
max@0 2752 </tr>
max@0 2753 <tr>
max@0 2754 <td style="vertical-align: top;">&nbsp;</td>
max@0 2755 <td style="vertical-align: top;"><br>
max@0 2756 </td>
max@0 2757 <td style="vertical-align: top;">&nbsp;
max@0 2758 </td>
max@0 2759 </tr>
max@0 2760 <tr>
max@0 2761 <td style="vertical-align: top;"><b>.min(</b>&nbsp;index_of_min_val&nbsp;<b>)</b></td>
max@0 2762 <td style="vertical-align: top;"><br>
max@0 2763 </td>
max@0 2764 <td style="vertical-align: top;">(member functions of <i>Mat</i>, <i>Col</i>, <i>Row</i>, <i>Cube</i>)
max@0 2765 </td>
max@0 2766 </tr>
max@0 2767 <tr>
max@0 2768 <td style="vertical-align: top;"><b>.max(</b>&nbsp;index_of_max_val&nbsp;<b>)</b></td>
max@0 2769 <td style="vertical-align: top;"><br>
max@0 2770 </td>
max@0 2771 <td style="vertical-align: top;">&nbsp;
max@0 2772 </td>
max@0 2773 </tr>
max@0 2774 <tr>
max@0 2775 <td style="vertical-align: top;">&nbsp;</td>
max@0 2776 <td style="vertical-align: top;"><br>
max@0 2777 </td>
max@0 2778 <td style="vertical-align: top;">&nbsp;
max@0 2779 </td>
max@0 2780 </tr>
max@0 2781 <tr>
max@0 2782 <td style="vertical-align: top;"><b>.min(</b>&nbsp;row_of_min_val<b>,</b> col_of_min_val&nbsp;<b>)</b></td>
max@0 2783 <td style="vertical-align: top;"><br>
max@0 2784 </td>
max@0 2785 <td style="vertical-align: top;">(member functions of <i>Mat</i>)
max@0 2786 </td>
max@0 2787 </tr>
max@0 2788 <tr>
max@0 2789 <td style="vertical-align: top;"><b>.max(</b>&nbsp;row_of_max_val<b>,</b> col_of_max_val&nbsp;<b>)</b></td>
max@0 2790 <td style="vertical-align: top;"><br>
max@0 2791 </td>
max@0 2792 <td style="vertical-align: top;">&nbsp;
max@0 2793 </td>
max@0 2794 </tr>
max@0 2795 <tr>
max@0 2796 <td style="vertical-align: top;">&nbsp;</td>
max@0 2797 <td style="vertical-align: top;"><br>
max@0 2798 </td>
max@0 2799 <td style="vertical-align: top;">&nbsp;
max@0 2800 </td>
max@0 2801 </tr>
max@0 2802 <tr>
max@0 2803 <td style="vertical-align: top;"><b>.min(</b>&nbsp;row_of_min_val<b>,</b> col_of_min_val<b>,</b> slice_of_min_val&nbsp;<b>)</b></td>
max@0 2804 <td style="vertical-align: top;"><br>
max@0 2805 </td>
max@0 2806 <td style="vertical-align: top;">(member functions of <i>Cube</i>)
max@0 2807 </td>
max@0 2808 </tr>
max@0 2809 <tr>
max@0 2810 <td style="vertical-align: top;"><b>.max(</b>&nbsp;row_of_max_val<b>,</b> col_of_max_val<b>,</b> slice_of_max_val&nbsp;<b>)</b></td>
max@0 2811 <td style="vertical-align: top;"><br>
max@0 2812 </td>
max@0 2813 <td style="vertical-align: top;">&nbsp;
max@0 2814 </td>
max@0 2815 </tr>
max@0 2816 </tbody>
max@0 2817 </table>
max@0 2818 <ul>
max@0 2819 <br>
max@0 2820 <li>
max@0 2821 Without arguments: return the extremum value of an object
max@0 2822 </li>
max@0 2823 <br>
max@0 2824 <li>
max@0 2825 With one or more arguments: return the extremum value of an object and store the location of the extremum value in the provided variable(s)
max@0 2826 </li>
max@0 2827 <br>
max@0 2828 <li>
max@0 2829 The provided variables must be of type <a href="#uword">uword</a>.
max@0 2830 </li>
max@0 2831 <br>
max@0 2832 <li>
max@0 2833 Examples:
max@0 2834 <ul>
max@0 2835 <pre>
max@0 2836 vec v = randu&lt;vec&gt;(10);
max@0 2837
max@0 2838 cout &lt;&lt; "min value is " &lt;&lt; v.min() &lt;&lt; endl;
max@0 2839
max@0 2840
max@0 2841 uword index;
max@0 2842 double min_val = v.min(index);
max@0 2843
max@0 2844 cout &lt;&lt; "index of min value is " &lt;&lt; index &lt;&lt; endl;
max@0 2845
max@0 2846
max@0 2847 mat A = randu&lt;mat&gt;(5,5);
max@0 2848
max@0 2849 uword row;
max@0 2850 uword col;
max@0 2851 double min_val2 = A.max(row,col);
max@0 2852
max@0 2853 cout &lt;&lt; "max value is at " &lt;&lt; row &lt;&lt; ',' &lt;&lt; col &lt;&lt; endl;
max@0 2854 </pre>
max@0 2855 </ul>
max@0 2856 </li>
max@0 2857 <br>
max@0 2858 <li>
max@0 2859 See also:
max@0 2860 <ul>
max@0 2861 <li><a href="#min_and_max">min() &amp; max()</a> (standalone functions)</li>
max@0 2862 <li><a href="#running_stat">running_stat</a></li>
max@0 2863 <li><a href="#running_stat_vec">running_stat_vec</a></li>
max@0 2864 </ul>
max@0 2865 </li>
max@0 2866 <br>
max@0 2867 </ul>
max@0 2868 <hr class="greyline"><br>
max@0 2869
max@0 2870 <a name="ones_member"></a>
max@0 2871 <b>.ones()</b>
max@0 2872 <br><b>.ones(n_elem)</b>
max@0 2873 <br><b>.ones(n_rows, n_cols)</b>
max@0 2874 <br><b>.ones(n_rows, n_cols, n_slices)</b>
max@0 2875 <ul>
max@0 2876 <li>
max@0 2877 Set the elements of an object to one, optionally first resizing to specified dimensions
max@0 2878 </li>
max@0 2879 <br>
max@0 2880 <li>
max@0 2881 <i>.ones()</i> and <i>.ones(n_elem)</i> are member functions of <i>Col</i> and <i>Row</i>
max@0 2882 </li>
max@0 2883 <br>
max@0 2884 <li>
max@0 2885 <i>.ones()</i> and <i>.ones(n_rows, n_cols)</i> are member functions of <i>Mat</i>
max@0 2886 </li>
max@0 2887 <br>
max@0 2888 <li>
max@0 2889 <i>.ones()</i> and <i>.ones(n_rows, n_cols, n_slices)</i> are member functions of <i>Cube</i>
max@0 2890 </li>
max@0 2891 <br>
max@0 2892 <li>
max@0 2893 Examples:
max@0 2894 <ul>
max@0 2895 <pre>
max@0 2896 mat A = randu&lt;mat&gt;(5,10);
max@0 2897 A.ones(); // sets all elements to one
max@0 2898 A.ones(10,20); // sets the size to 10 rows and 20 columns
max@0 2899 // followed by setting all elements to one
max@0 2900 </pre>
max@0 2901 </ul>
max@0 2902 </li>
max@0 2903 <br>
max@0 2904 <li>
max@0 2905 See also:
max@0 2906 <ul>
max@0 2907 <li><a href="#ones_standalone">ones()</a> (standalone function)</li>
max@0 2908 <li><a href="#zeros_member">.zeros()</a></li>
max@0 2909 <li><a href="#fill">.fill()</a></li>
max@0 2910 </ul>
max@0 2911 </li>
max@0 2912 <br>
max@0 2913 </ul>
max@0 2914 <hr class="greyline"><br>
max@0 2915
max@0 2916 <a name="operators"></a>
max@0 2917 <b>operators: &nbsp; + &nbsp; - &nbsp; * &nbsp; / &nbsp; % &nbsp; == &nbsp; != &nbsp; &lt;= &nbsp; &gt;= &nbsp; &lt; &nbsp; &gt;</b>
max@0 2918 <ul>
max@0 2919 <li>
max@0 2920 Overloaded operators for <i>mat</i>, <i>vec</i>, <i>rowvec</i> and <i>cube</i> classes
max@0 2921 </li>
max@0 2922 <br>
max@0 2923 <li>
max@0 2924 Meanings:
max@0 2925 <br>
max@0 2926 <br>
max@0 2927 <ul>
max@0 2928 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 2929 <tbody>
max@0 2930 <tr>
max@0 2931 <td style="vertical-align: top;"><b>+</b></td>
max@0 2932 <td style="vertical-align: top;">&nbsp;&nbsp;&nbsp;<br>
max@0 2933 </td>
max@0 2934 <td style="vertical-align: top;">Addition of two objects</td>
max@0 2935 </tr>
max@0 2936 <tr>
max@0 2937 <td style="vertical-align: top;"><b>-</b></td>
max@0 2938 <td style="vertical-align: top;"><br>
max@0 2939 </td>
max@0 2940 <td style="vertical-align: top;">Subtraction of one object from another or negation of an object</td>
max@0 2941 </tr>
max@0 2942 <tr>
max@0 2943 <td style="vertical-align: top;"><b>/</b></td>
max@0 2944 <td style="vertical-align: top;"><br>
max@0 2945 </td>
max@0 2946 <td style="vertical-align: top;">Element-wise division of an object by another object or a scalar</td>
max@0 2947 </tr>
max@0 2948 <tr>
max@0 2949 <td style="vertical-align: top;"><b>*</b></td>
max@0 2950 <td style="vertical-align: top;"><br>
max@0 2951 </td>
max@0 2952 <td style="vertical-align: top;">Matrix multiplication of two objects; not applicable to the <i>cube</i> class unless multiplying a cube by a scalar</td>
max@0 2953 </tr>
max@0 2954 <tr>
max@0 2955 <td style="vertical-align: top;"><b>%</b></td>
max@0 2956 <td style="vertical-align: top;"><br>
max@0 2957 </td>
max@0 2958 <td style="vertical-align: top;"><a name="schur_product"></a>Schur product: element-wise multiplication of two objects</td>
max@0 2959 </tr>
max@0 2960 <tr>
max@0 2961 <td style="vertical-align: top;"><b>==</b></td>
max@0 2962 <td style="vertical-align: top;"><br>
max@0 2963 </td>
max@0 2964 <td style="vertical-align: top;">Element-wise equality evaluation of two objects; generates a matrix of type <i>umat</i> with entries that indicate whether at a given position the two elements from the two objects are equal (1) or not equal (0)</td>
max@0 2965 </tr>
max@0 2966 <tr>
max@0 2967 <td style="vertical-align: top;"><b>!=</b></td>
max@0 2968 <td style="vertical-align: top;"><br>
max@0 2969 </td>
max@0 2970 <td style="vertical-align: top;">Element-wise non-equality evaluation of two objects</td>
max@0 2971 </tr>
max@0 2972 <tr>
max@0 2973 <td style="vertical-align: top;"><b>&gt;=</b></td>
max@0 2974 <td style="vertical-align: top;"><br>
max@0 2975 </td>
max@0 2976 <td style="vertical-align: top;">As for ==, but the check is for "greater than or equal to"</td>
max@0 2977 </tr>
max@0 2978 <tr>
max@0 2979 <td style="vertical-align: top;"><b>&lt;=</b></td>
max@0 2980 <td style="vertical-align: top;"><br>
max@0 2981 </td>
max@0 2982 <td style="vertical-align: top;">As for ==, but the check is for "less than or equal to"</td>
max@0 2983 </tr>
max@0 2984 <tr>
max@0 2985 <td style="vertical-align: top;"><b>&gt;</b></td>
max@0 2986 <td style="vertical-align: top;"><br>
max@0 2987 </td>
max@0 2988 <td style="vertical-align: top;">As for ==, but the check is for "greater than"</td>
max@0 2989 </tr>
max@0 2990 <tr>
max@0 2991 <td style="vertical-align: top;"><b>&lt;</b></td>
max@0 2992 <td style="vertical-align: top;"><br>
max@0 2993 </td>
max@0 2994 <td style="vertical-align: top;">As for ==, but the check is for "less than"</td>
max@0 2995 </tr>
max@0 2996 </tbody>
max@0 2997 </table>
max@0 2998 </ul>
max@0 2999 </li>
max@0 3000 <br>
max@0 3001 <li>
max@0 3002 A <i>std::logic_error</i> exception is thrown if incompatible object sizes are used
max@0 3003 </li>
max@0 3004 <br>
max@0 3005 <li>
max@0 3006 If the +, - and % operators are chained, Armadillo will try to avoid the generation of temporaries;
max@0 3007 no temporaries are generated if all given objects are of the same type and size
max@0 3008 </li>
max@0 3009 <br>
max@0 3010 <li>
max@0 3011 If the * operator is chained, Armadillo will try to find an efficient ordering of the matrix multiplications
max@0 3012 </li>
max@0 3013 <br>
max@0 3014 <li>
max@0 3015 <b>Caveat:</b> operators involving an equality comparison (ie., ==, !=, &gt;=, &lt;=)
max@0 3016 may not work as expected for floating point element types (ie., <i>float</i>, <i>double</i>)
max@0 3017 due to the necessarily limited precision of these types;
max@0 3018 in other words, these operators are (in general) not recommended for matrices of type <i>mat</i> or <i>fmat</i>
max@0 3019 </li>
max@0 3020 <br>
max@0 3021 <br>
max@0 3022 <li>
max@0 3023 Examples:
max@0 3024 <ul>
max@0 3025 <pre>
max@0 3026 mat A = randu&lt;mat&gt;(5,10);
max@0 3027 mat B = randu&lt;mat&gt;(5,10);
max@0 3028 mat C = randu&lt;mat&gt;(10,5);
max@0 3029
max@0 3030 mat P = A + B;
max@0 3031 mat Q = A - B;
max@0 3032 mat R = -B;
max@0 3033 mat S = A / 123.0;
max@0 3034 mat T = A % B;
max@0 3035 mat U = A * C;
max@0 3036
max@0 3037 // V is constructed without temporaries
max@0 3038 mat V = A + B + A + B;
max@0 3039
max@0 3040 imat AA = "1 2 3; 4 5 6; 7 8 9;";
max@0 3041 imat BB = "3 2 1; 6 5 4; 9 8 7;";
max@0 3042
max@0 3043 // compare elements
max@0 3044 umat ZZ = (AA >= BB);
max@0 3045 </pre>
max@0 3046 </ul>
max@0 3047 </li>
max@0 3048 <br>
max@0 3049 <li>
max@0 3050 See also:
max@0 3051 <ul>
max@0 3052 <li><a href="#accu">accu()</a></li>
max@0 3053 <li><a href="#as_scalar">as_scalar()</a></li>
max@0 3054 <li><a href="#find">find()</a></li>
max@0 3055 </ul>
max@0 3056 </li>
max@0 3057 <br>
max@0 3058 </ul>
max@0 3059 <hr class="greyline"><br>
max@0 3060
max@0 3061 <a name="print"></a>
max@0 3062 <b>.print(header="")</b>
max@0 3063 <br><b>.print(stream, header="")</b>
max@0 3064 <ul>
max@0 3065 <li>
max@0 3066 Member function of <i>Mat</i>, <i>Col</i>, <i>Row</i>, <i>Cube</i> and <i>field</i>
max@0 3067 </li>
max@0 3068 <br>
max@0 3069 <li>
max@0 3070 The first form prints the contents of an object to the <i>std::cout</i> stream, with an optional header line
max@0 3071 </li>
max@0 3072 <br>
max@0 3073 <li>
max@0 3074 The second form prints to a user specified stream
max@0 3075 </li>
max@0 3076 <br>
max@0 3077 <li>
max@0 3078 It's also possible to print objects using the &lt;&lt; stream operator
max@0 3079 </li>
max@0 3080 <br>
max@0 3081 <li>
max@0 3082 Elements of a field can only be printed if there is an associated <i>operator&lt;&lt;</i> function defined
max@0 3083 </li>
max@0 3084 <br>
max@0 3085 <li>
max@0 3086 Examples:
max@0 3087 <ul>
max@0 3088 <pre>
max@0 3089 mat A = randu&lt;mat&gt;(5,5);
max@0 3090 mat B = randu&lt;mat&gt;(6,6);
max@0 3091
max@0 3092 A.print();
max@0 3093
max@0 3094 // print a transposed version of A
max@0 3095 A.t().print();
max@0 3096
max@0 3097 // "B:" is the optional header line
max@0 3098 B.print("B:");
max@0 3099
max@0 3100 cout &lt;&lt; A &lt;&lt; endl;
max@0 3101 cout &lt;&lt; "B:" &lt;&lt; endl &lt;&lt; B &lt;&lt; endl;
max@0 3102 </pre>
max@0 3103 </ul>
max@0 3104 </li>
max@0 3105 <br>
max@0 3106 <li>
max@0 3107 See also:
max@0 3108 <ul>
max@0 3109 <li><a href="#raw_print">.raw_print()</a></li>
max@0 3110 <li><a href="#save_load_mat">saving &amp; loading matrices</a></li>
max@0 3111 <li><a href="#element_initialisation">initialising elements</a></li>
max@0 3112 <li><a href="#logging">logging of errors and warnings</a></li>
max@0 3113 </ul>
max@0 3114 </li>
max@0 3115 <br>
max@0 3116 </ul>
max@0 3117 <hr class="greyline"><br>
max@0 3118
max@0 3119 <a name="raw_print"></a>
max@0 3120 <b>.raw_print(header="")</b>
max@0 3121 <br><b>.raw_print(stream, header="")</b>
max@0 3122 <ul>
max@0 3123 <li>
max@0 3124 Member function of <i>Mat</i>, <i>Col</i>, <i>Row</i> and <i>Cube</i>
max@0 3125 </li>
max@0 3126 <br>
max@0 3127 <li>
max@0 3128 Similar to the <a href="#print">.print()</a> member function,
max@0 3129 with the difference being that no formatting of the output is done -- ie. the user can set the stream's parameters such as precision, cell width, etc.
max@0 3130 </li>
max@0 3131 <br>
max@0 3132 <li>
max@0 3133 If the cell width is set to zero, a space is printed between the elements
max@0 3134 </li>
max@0 3135 <br>
max@0 3136 <li>
max@0 3137 Examples:
max@0 3138 <ul>
max@0 3139 <pre>
max@0 3140 mat A = randu&lt;mat&gt;(5,5);
max@0 3141
max@0 3142 cout.precision(11);
max@0 3143 cout.setf(ios::fixed);
max@0 3144
max@0 3145 A.raw_print(cout, "A =");
max@0 3146 </pre>
max@0 3147 </ul>
max@0 3148 </li>
max@0 3149 </ul>
max@0 3150 <br>
max@0 3151 <hr class="greyline"><br>
max@0 3152
max@0 3153 <a name="randu_randn_member"></a>
max@0 3154 <b>.randu()</b>
max@0 3155 <br><b>.randu(n_elem)</b>
max@0 3156 <br><b>.randu(n_rows, n_cols)</b>
max@0 3157 <br><b>.randu(n_rows, n_cols, n_slices)</b>
max@0 3158 <br>
max@0 3159 <br>
max@0 3160 <b>.randn()</b>
max@0 3161 <br><b>.randn(n_elem)</b>
max@0 3162 <br><b>.randn(n_rows, n_cols)</b>
max@0 3163 <br><b>.randn(n_rows, n_cols, n_slices)</b>
max@0 3164 <ul>
max@0 3165 <li>
max@0 3166 Fill an object with random values, optionally first resizing to specified dimensions
max@0 3167 </li>
max@0 3168 <br>
max@0 3169 <li><i>.randu()</i> uses a uniform distribution in the [0,1] interval
max@0 3170 </li>
max@0 3171 <br>
max@0 3172 <li><i>.randn()</i> uses a normal/Gaussian distribution with zero mean and unit variance
max@0 3173 </li>
max@0 3174 <br>
max@0 3175 <li>
max@0 3176 To change the seed, use the <a href="http://cplusplus.com/reference/clibrary/cstdlib/srand/">std::srand()</a> function
max@0 3177 </li>
max@0 3178 <br>
max@0 3179 <li>
max@0 3180 Examples:
max@0 3181 <ul>
max@0 3182 <pre>
max@0 3183 mat A(4,5);
max@0 3184 A.randu();
max@0 3185
max@0 3186 mat B;
max@0 3187 B.randu(6,7);
max@0 3188 </pre>
max@0 3189 </ul>
max@0 3190 </li>
max@0 3191 <br>
max@0 3192 <li>
max@0 3193 See also:
max@0 3194 <ul>
max@0 3195 <li><a href="#randu_randn_standalone">randu() &amp; randn()</a> (standalone functions)</li>
max@0 3196 <li><a href="#fill">.fill()</a></li>
max@0 3197 <li><a href="#ones_member">.ones()</a></li>
max@0 3198 <li><a href="#zeros_member">.zeros()</a></li>
max@0 3199 <li><a href="http://cplusplus.com/reference/clibrary/cstdlib/srand/">std::srand()</a></li>
max@0 3200 </ul>
max@0 3201 </li>
max@0 3202 <br>
max@0 3203 </ul>
max@0 3204 <hr class="greyline"><br>
max@0 3205
max@0 3206 <a name="reset"></a>
max@0 3207 <b>
max@0 3208 .reset()
max@0 3209 </b>
max@0 3210 <ul>
max@0 3211 <li>
max@0 3212 Member function of <i>Mat</i>, <i>Col</i>, <i>Row</i>, <i>Cube</i> and <i>field</i>
max@0 3213 </li>
max@0 3214 <br>
max@0 3215 <li>
max@0 3216 Causes an object to have no elements
max@0 3217 </li>
max@0 3218 <br>
max@0 3219 <li>
max@0 3220 Examples:
max@0 3221 <ul>
max@0 3222 <pre>
max@0 3223 mat A = randu&lt;mat&gt;(5, 5);
max@0 3224 A.reset();
max@0 3225 </pre>
max@0 3226 </ul>
max@0 3227 </li>
max@0 3228 <br>
max@0 3229 <li>See also:
max@0 3230 <ul>
max@0 3231 <li><a href="#set_size">.set_size()</a></li>
max@0 3232 <li><a href="#is_empty">.is_empty()</a></li>
max@0 3233 <li><a href="#zeros_member">.zeros()</a></li>
max@0 3234 </ul>
max@0 3235 </li>
max@0 3236 </ul>
max@0 3237 <br>
max@0 3238 <hr class="greyline"><br>
max@0 3239
max@0 3240 <a name="reshape_member"></a>
max@0 3241 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 3242 <tbody>
max@0 3243 <tr>
max@0 3244 <td style="vertical-align: top;"><b>.reshape(n_rows, n_cols, dim=0)</b></td>
max@0 3245 <td style="vertical-align: top;"><br>
max@0 3246 </td>
max@0 3247 <td style="vertical-align: top;">(member function of <i>Mat</i>, <i>Col</i>, <i>Row</i>)
max@0 3248 </td>
max@0 3249 </tr>
max@0 3250 <tr>
max@0 3251 <td style="vertical-align: top;"><b>.reshape(n_rows, n_cols, n_slices, dim=0)</b></td>
max@0 3252 <td style="vertical-align: top;"><br>
max@0 3253 </td>
max@0 3254 <td style="vertical-align: top;">(member function of <i>Cube</i>)
max@0 3255 </td>
max@0 3256 </tr>
max@0 3257 </tbody>
max@0 3258 </table>
max@0 3259 <br>
max@0 3260 <ul>
max@0 3261 <li>
max@0 3262 Recreate the object according to given size specifications,
max@0 3263 with the elements taken from the previous version of the object,
max@0 3264 either column-wise (dim=0) or row-wise (dim=1);
max@0 3265 the elements in the generated object are placed column-wise (ie. the first column is filled up before filling the second column)
max@0 3266 </li>
max@0 3267 <br>
max@0 3268 <li>
max@0 3269 The layout of the elements in the recreated object will be different to the layout in the previous version of the object
max@0 3270 </li>
max@0 3271 <br>
max@0 3272 <li>
max@0 3273 This function can be used to vectorise a matrix (ie. concatenate all the columns or rows)
max@0 3274 </li>
max@0 3275 <br>
max@0 3276 <li>
max@0 3277 The new total number of elements (according to the specified size) doesn't have to be the same as the previous total number of elements in the object
max@0 3278 </li>
max@0 3279 <br>
max@0 3280 <li>
max@0 3281 If the total number of elements in the previous version of the object is less than the specified size,
max@0 3282 the extra elements in the recreated object are set to zero
max@0 3283 </li>
max@0 3284 <br>
max@0 3285 <li>
max@0 3286 If the total number of elements in the previous version of the object is greater than the specified size,
max@0 3287 only a subset of the elements is taken
max@0 3288 </li>
max@0 3289 <br>
max@0 3290 <li>
max@0 3291 <b>Caveat:</b>
max@0 3292 .reshape() is slower than <a href="#set_size">.set_size()</a>, which doesn't preserve data
max@0 3293 </li>
max@0 3294 <br>
max@0 3295 <li>
max@0 3296 <b>Caveat:</b>
max@0 3297 if you wish to grow/shrink the object while preserving the elements <b>as well as</b> the layout of the elements,
max@0 3298 use <a href="#resize_member">.resize()</a> instead
max@0 3299 </li>
max@0 3300 <br>
max@0 3301 <li>
max@0 3302 Examples:
max@0 3303 <ul>
max@0 3304 <pre>
max@0 3305 mat A = randu&lt;mat&gt;(4,5);
max@0 3306 A.reshape(5,4);
max@0 3307
max@0 3308 // vectorise A into a column vector:
max@0 3309 A.reshape(A.n_elem, 1);
max@0 3310 </pre>
max@0 3311 </ul>
max@0 3312 </li>
max@0 3313 <br>
max@0 3314 <li>See also:
max@0 3315 <ul>
max@0 3316 <li><a href="#resize_member">.resize()</a></li>
max@0 3317 <li><a href="#set_size">.set_size()</a></li>
max@0 3318 <li><a href="#reset">.reset()</a></li>
max@0 3319 <li><a href="#reshape">reshape()</a> (standalone function)</li>
max@0 3320 </ul>
max@0 3321 </li>
max@0 3322 </ul>
max@0 3323 <br>
max@0 3324 <hr class="greyline"><br>
max@0 3325
max@0 3326 <a name="resize_member"></a>
max@0 3327 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 3328 <tbody>
max@0 3329 <tr>
max@0 3330 <td style="vertical-align: top;"><b>.resize(n_elem)</b></td>
max@0 3331 <td style="vertical-align: top;"><br>
max@0 3332 </td>
max@0 3333 <td style="vertical-align: top;">(member function of <i>Col</i>, <i>Row</i>)
max@0 3334 </td>
max@0 3335 </tr>
max@0 3336 <tr>
max@0 3337 <td style="vertical-align: top;"><b>.resize(n_rows, n_cols)</b></td>
max@0 3338 <td style="vertical-align: top;"><br>
max@0 3339 </td>
max@0 3340 <td style="vertical-align: top;">(member function of <i>Mat</i>)
max@0 3341 </td>
max@0 3342 </tr>
max@0 3343 <tr>
max@0 3344 <td style="vertical-align: top;"><b>.resize(n_rows, n_cols, n_slices)</b></td>
max@0 3345 <td style="vertical-align: top;"><br>
max@0 3346 </td>
max@0 3347 <td style="vertical-align: top;">(member function of <i>Cube</i>)
max@0 3348 </td>
max@0 3349 </tr>
max@0 3350 </tbody>
max@0 3351 </table>
max@0 3352 <br>
max@0 3353 <ul>
max@0 3354 <li>
max@0 3355 Recreate the object according to given size specifications, while preserving the elements as well as the layout of the elements
max@0 3356 </li>
max@0 3357 <br>
max@0 3358 <li>
max@0 3359 Can be used for growing or shrinking an object (ie. adding/removing rows, and/or columns, and/or slices)
max@0 3360 </li>
max@0 3361 <br>
max@0 3362 <li>
max@0 3363 <b>Caveat:</b>
max@0 3364 .resize() is slower than <a href="#set_size">.set_size()</a>, which doesn't preserve data
max@0 3365 </li>
max@0 3366 <br>
max@0 3367 <li>
max@0 3368 Examples:
max@0 3369 <ul>
max@0 3370 <pre>
max@0 3371 mat A = randu&lt;mat&gt;(4,5);
max@0 3372 A.resize(7,6);
max@0 3373 </pre>
max@0 3374 </ul>
max@0 3375 </li>
max@0 3376 <br>
max@0 3377 <li>
max@0 3378 This function was added in version 2.4.1
max@0 3379 </li>
max@0 3380 <br>
max@0 3381 <li>See also:
max@0 3382 <ul>
max@0 3383 <li><a href="#reshape_member">.reshape()</a></li>
max@0 3384 <li><a href="#set_size">.set_size()</a></li>
max@0 3385 <li><a href="#reset">.reset()</a></li>
max@0 3386 <li><a href="#insert">insert rows/cols/slices</a></li>
max@0 3387 <li><a href="#shed">shed rows/cols/slices</a></li>
max@0 3388 <li><a href="#resize">resize()</a> (standalone function)</li>
max@0 3389 </ul>
max@0 3390 </li>
max@0 3391 </ul>
max@0 3392 <br>
max@0 3393 <hr class="greyline"><br>
max@0 3394
max@0 3395 <a name="save_load_mat"></a>
max@0 3396 <b>
max@0 3397 .save(name, file_type = arma_binary)
max@0 3398 <br>
max@0 3399 .save(stream, file_type = arma_binary)
max@0 3400 <br>
max@0 3401 <br>
max@0 3402 .load(name, file_type = auto_detect)
max@0 3403 <br>
max@0 3404 .load(stream, file_type = auto_detect)
max@0 3405 <br>
max@0 3406 <br>
max@0 3407 .quiet_save(name, file_type = arma_binary)
max@0 3408 <br>
max@0 3409 .quiet_save(stream, file_type = arma_binary)
max@0 3410 <br>
max@0 3411 <br>
max@0 3412 .quiet_load(name, file_type = auto_detect)
max@0 3413 <br>
max@0 3414 .quiet_load(stream, file_type = auto_detect)
max@0 3415 </b>
max@0 3416 <ul>
max@0 3417 <li>Member functions of <i>Mat</i>, <i>Col</i>, <i>Row</i> and <i>Cube</i> classes</li>
max@0 3418 <br>
max@0 3419 <li>Store/retrieve data in files or streams</li>
max@0 3420 <br>
max@0 3421 <li>On success, <i>save()</i>, <i>load()</i>, <i>quiet_save()</i>, and <i>quite_load()</i> will return a <i>bool</i> set to <i>true</i></li>
max@0 3422 <br>
max@0 3423 <li><i>save()</i> and <i>quiet_save()</i> will return a <i>bool</i> set to <i>false</i> if the saving process fails</li>
max@0 3424 <br>
max@0 3425 <li>
max@0 3426 <i>load()</i> and <i>quiet_load()</i> will return a <i>bool</i> set to <i>false</i> if the loading process fails;
max@0 3427 additionally, the object will be reset so it has no elements
max@0 3428 </li>
max@0 3429 <br>
max@0 3430 <li><i>load()</i> and <i>save()</i> will print warning messages if any problems are encountered</li>
max@0 3431 <br>
max@0 3432 <li><i>quiet_load()</i> and <i>quiet_save()</i> do not print any error messages</li>
max@0 3433 <br>
max@0 3434 <li>
max@0 3435 The following file formats are supported:
max@0 3436 <br>
max@0 3437 <br>
max@0 3438 <ul>
max@0 3439 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 3440 <tbody>
max@0 3441 <tr>
max@0 3442 <td style="vertical-align: top;"><b>auto_detect</b></td>
max@0 3443 <td style="vertical-align: top;"><br>
max@0 3444 </td>
max@0 3445 <td style="vertical-align: top;">
max@0 3446 for <i>load()</i> and <i>quiet_load()</i>:
max@0 3447 try to automatically detect the file type as one of the formats described below.
max@0 3448 This is the default operation.
max@0 3449 <br>
max@0 3450 <br>
max@0 3451 </td>
max@0 3452 </tr>
max@0 3453 <tr>
max@0 3454 <td style="vertical-align: top;"><b>raw_ascii</b></td>
max@0 3455 <td style="vertical-align: top;"><br>
max@0 3456 </td>
max@0 3457 <td style="vertical-align: top;">
max@0 3458 Numerical data stored in raw ASCII format, without a header.
max@0 3459 The numbers are separated by whitespace.
max@0 3460 The number of columns must be the same in each row.
max@0 3461 Data which was saved in Matlab/Octave using the <i>-ascii</i> option can be read in Armadillo, except for complex numbers.
max@0 3462 Complex numbers are stored in standard C++ notation (a tuple surrounded by brackets: eg. (1.23,4.56) indicates 1.24&nbsp;+&nbsp;4.56i).
max@0 3463 Cubes are loaded as one slice.
max@0 3464 <br>
max@0 3465 <br>
max@0 3466 </td>
max@0 3467 </tr>
max@0 3468 <tr>
max@0 3469 <td style="vertical-align: top;"><b>raw_binary</b></td>
max@0 3470 <td style="vertical-align: top;"><br>
max@0 3471 </td>
max@0 3472 <td style="vertical-align: top;">
max@0 3473 Numerical data stored in machine dependent raw binary format, without a header.
max@0 3474 Matrices are loaded to have one column,
max@0 3475 while cubes are loaded to have one slice with one column.
max@0 3476 The <a href="#reshape_member">.reshape()</a> function can be used to alter the size of the loaded matrix/cube without losing data.
max@0 3477 <br>
max@0 3478 <br>
max@0 3479 </td>
max@0 3480 </tr>
max@0 3481 <tr>
max@0 3482 <td style="vertical-align: top;"><b>arma_ascii</b></td>
max@0 3483 <td style="vertical-align: top;"><br>
max@0 3484 </td>
max@0 3485 <td style="vertical-align: top;">
max@0 3486 Numerical data stored in human readable text format, with a simple header to speed up loading.
max@0 3487 The header indicates the type of matrix as well as the number of rows and columns.
max@0 3488 For cubes, the header additionally specifies the number of slices.
max@0 3489 <br>
max@0 3490 <br>
max@0 3491 </td>
max@0 3492 </tr>
max@0 3493 <tr>
max@0 3494 <td style="vertical-align: top;"><b>arma_binary</b></td>
max@0 3495 <td style="vertical-align: top;"><br>
max@0 3496 </td>
max@0 3497 <td style="vertical-align: top;">
max@0 3498 Numerical data stored in machine dependent binary format, with a simple header to speed up loading.
max@0 3499 The header indicates the type of matrix as well as the number of rows and columns.
max@0 3500 For cubes, the header additionally specifies the number of slices.
max@0 3501 <br>
max@0 3502 <br>
max@0 3503 </td>
max@0 3504 </tr>
max@0 3505 <tr>
max@0 3506 <td style="vertical-align: top;"><b>csv_ascii</b></td>
max@0 3507 <td style="vertical-align: top;"><br>
max@0 3508 </td>
max@0 3509 <td style="vertical-align: top;">
max@0 3510 Numerical data stored in comma separated value (CSV) text format, without a header.
max@0 3511 Applicable to <i>Mat</i> only.
max@0 3512 <br>
max@0 3513 <br>
max@0 3514 </td>
max@0 3515 </tr>
max@0 3516 <tr>
max@0 3517 <td style="vertical-align: top;"><b>pgm_binary</b></td>
max@0 3518 <td style="vertical-align: top;"><br>
max@0 3519 </td>
max@0 3520 <td style="vertical-align: top;">
max@0 3521 Image data stored in Portable Gray Map (PGM) format.
max@0 3522 Applicable to <i>Mat</i> only.
max@0 3523 Saving <i>int</i>, <i>float</i> or <i>double</i> matrices is a lossy operation, as each element is copied and converted to an 8 bit representation.
max@0 3524 As such the matrix should have values in the [0,255] interval, otherwise the resulting image may not display correctly.
max@0 3525 <br>
max@0 3526 <br>
max@0 3527 </td>
max@0 3528 </tr>
max@0 3529 <tr>
max@0 3530 <td style="vertical-align: top;"><b>ppm_binary</b></td>
max@0 3531 <td style="vertical-align: top;"><br>
max@0 3532 </td>
max@0 3533 <td style="vertical-align: top;">
max@0 3534 Image data stored in Portable Pixel Map (PPM) format.
max@0 3535 Applicable to <i>Cube</i> only.
max@0 3536 Saving <i>int</i>, <i>float</i> or <i>double</i> matrices is a lossy operation, as each element is copied and converted to an 8 bit representation.
max@0 3537 As such the cube/field should have values in the [0,255] interval, otherwise the resulting image may not display correctly.
max@0 3538 </td>
max@0 3539 </tr>
max@0 3540 </tbody>
max@0 3541 </table>
max@0 3542 </ul>
max@0 3543 </li>
max@0 3544 <br>
max@0 3545 <br>
max@0 3546 <li>
max@0 3547 Examples:
max@0 3548 <ul>
max@0 3549 <pre>
max@0 3550 mat A = randu&lt;mat&gt;(5,5);
max@0 3551
max@0 3552 A.save("A1.mat"); // default save format is arma_binary
max@0 3553 A.save("A2.mat", arma_ascii);
max@0 3554
max@0 3555 mat B;
max@0 3556 // automatically detect format type
max@0 3557 B.load("A1.mat");
max@0 3558
max@0 3559 mat C;
max@0 3560 // force loading in the arma_ascii format
max@0 3561 C.load("A2.mat", arma_ascii);
max@0 3562
max@0 3563
max@0 3564 // example of saving/loading using a stream
max@0 3565 std::stringstream s;
max@0 3566 A.save(s);
max@0 3567
max@0 3568 mat D;
max@0 3569 D.load(s);
max@0 3570
max@0 3571
max@0 3572 // example of testing for success
max@0 3573 mat E;
max@0 3574 bool status = E.load("A2.mat");
max@0 3575
max@0 3576 if(status == true)
max@0 3577 {
max@0 3578 cout &lt;&lt; "loaded okay" &lt;&lt; endl;
max@0 3579 }
max@0 3580 else
max@0 3581 {
max@0 3582 cout &lt;&lt; "problem with loading" &lt;&lt; endl;
max@0 3583 }
max@0 3584 </pre>
max@0 3585 </ul>
max@0 3586 </li>
max@0 3587 <br>
max@0 3588 <li>See also:
max@0 3589 <ul>
max@0 3590 <li><a href="#save_load_field">saving/loading fields</a></li>
max@0 3591 </ul>
max@0 3592 </li>
max@0 3593 <br>
max@0 3594 </ul>
max@0 3595 <hr class="greyline"><br>
max@0 3596
max@0 3597 <a name="save_load_field"></a>
max@0 3598 <b>
max@0 3599 .save(name, file_type = arma_binary)
max@0 3600 <br>
max@0 3601 .save(stream, file_type = arma_binary)
max@0 3602 <br>
max@0 3603 <br>
max@0 3604 .load(name, file_type = auto_detect)
max@0 3605 <br>
max@0 3606 .load(stream, file_type = auto_detect)
max@0 3607 <br>
max@0 3608 <br>
max@0 3609 .quiet_save(name, file_type = arma_binary)
max@0 3610 <br>
max@0 3611 .quiet_save(stream, file_type = arma_binary)
max@0 3612 <br>
max@0 3613 <br>
max@0 3614 .quiet_load(name, file_type = auto_detect)
max@0 3615 <br>
max@0 3616 .quiet_load(stream, file_type = auto_detect)
max@0 3617 </b>
max@0 3618 <ul>
max@0 3619 <li>Member functions of the <i>field</i> class</li>
max@0 3620 <br>
max@0 3621 <li>Store/retrieve fields in files or stream</li>
max@0 3622 <br>
max@0 3623 <li>On success, save(), load(), quiet_save(), and quite_load() will return a <i>bool</i> set to <i>true</i></li>
max@0 3624 <br>
max@0 3625 <li>save() and quiet_save() will return a <i>bool</i> set to <i>false</i> if the saving process fails</li>
max@0 3626 <br>
max@0 3627 <li>
max@0 3628 load() and quiet_load() will return a <i>bool</i> set to <i>false</i> if the loading process fails;
max@0 3629 additionally, the field will be reset so it has no elements
max@0 3630 </li>
max@0 3631 <br>
max@0 3632 <li>load() and save() will print warning messages if any problems are encountered</li>
max@0 3633 <br>
max@0 3634 <li>quiet_load() and quiet_save() do not print any error messages</li>
max@0 3635 <br>
max@0 3636 <li>
max@0 3637 Fields with objects of type <i>std::string</i> are saved and loaded as raw text files.
max@0 3638 The text files do not have a header.
max@0 3639 Each string is separated by a whitespace.
max@0 3640 load() and quiet_load() will only accept text files that have the same number of strings on each line.
max@0 3641 The strings can have variable lengths.
max@0 3642 </li>
max@0 3643 <br>
max@0 3644 <li>
max@0 3645 Other than storing string fields as text files, the following file formats are supported:
max@0 3646 <br>
max@0 3647 <br>
max@0 3648 <ul>
max@0 3649 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 3650 <tbody>
max@0 3651 <tr>
max@0 3652 <td style="vertical-align: top;"><b>auto_detect</b></td>
max@0 3653 <td style="vertical-align: top;"><br>
max@0 3654 </td>
max@0 3655 <td style="vertical-align: top;">
max@0 3656 <br>
max@0 3657 <li>
max@0 3658 load(): try to automatically detect the field format type as one of the formats described below.
max@0 3659 This is the default operation.
max@0 3660 </li>
max@0 3661 <br>
max@0 3662 </td>
max@0 3663 </tr>
max@0 3664 <tr>
max@0 3665 <td style="vertical-align: top;"><b>arma_binary</b></td>
max@0 3666 <td style="vertical-align: top;"><br>
max@0 3667 </td>
max@0 3668 <td style="vertical-align: top;">
max@0 3669 <br>
max@0 3670 <li>
max@0 3671 Objects are stored in machine dependent binary format.
max@0 3672 <li>
max@0 3673 Default type for fields of type <i>Mat</i>, <i>Col</i> or <i>Row</i>.
max@0 3674 </li>
max@0 3675 <li>
max@0 3676 Only applicable to fields of type <i>Mat</i>, <i>Col</i> or <i>Row</i>.
max@0 3677 </li>
max@0 3678 <br>
max@0 3679 </td>
max@0 3680 </tr>
max@0 3681 <tr>
max@0 3682 <td style="vertical-align: top;"><b>ppm_binary</b></td>
max@0 3683 <td style="vertical-align: top;"><br>
max@0 3684 </td>
max@0 3685 <td style="vertical-align: top;">
max@0 3686 <br>
max@0 3687 <li>
max@0 3688 Image data stored in Portable Pixmap Map (PPM) format.
max@0 3689 </li>
max@0 3690 <li>
max@0 3691 Only applicable to fields of type <i>Mat</i>, <i>Col</i> or <i>Row</i>.
max@0 3692 </li>
max@0 3693 <li>
max@0 3694 .load(): Loads the specified image and stores the red, green and blue components as three separate matrices.
max@0 3695 The resulting field is comprised of the three matrices,
max@0 3696 with the red, green and blue components in the first, second and third matrix, respectively.
max@0 3697 </li>
max@0 3698 <li>
max@0 3699 .save(): Saves a field with exactly three matrices of equal size as an image.
max@0 3700 It is assumed that the red, green and blue components are stored in the first, second and third matrix, respectively.
max@0 3701 Saving <i>int</i>, <i>float</i> or <i>double</i> matrices is a lossy operation,
max@0 3702 as each matrix element is copied and converted to an 8 bit representation.
max@0 3703 </li>
max@0 3704
max@0 3705 </td>
max@0 3706 </tr>
max@0 3707 </tbody>
max@0 3708 </table>
max@0 3709 </ul>
max@0 3710 </li>
max@0 3711 <br>
max@0 3712 <li>See also:
max@0 3713 <ul>
max@0 3714 <li><a href="#save_load_mat">saving/loading matrices and cubes</a></li>
max@0 3715 </ul>
max@0 3716 </li>
max@0 3717 <br>
max@0 3718 </ul>
max@0 3719 <hr class="greyline"><br>
max@0 3720
max@0 3721 <a name="set_imag"></a>
max@0 3722 <b>.set_imag(X)</b>
max@0 3723 <br>
max@0 3724 <b>.set_real(X)</b>
max@0 3725 <br>
max@0 3726 <ul>
max@0 3727 <li>Member functions of Mat, Col, Row and Cube</li>
max@0 3728 <br>
max@0 3729 <li>
max@0 3730 Set the imaginary/real part of an object
max@0 3731 </li>
max@0 3732 <br>
max@0 3733 <li>
max@0 3734 <i>X</i> must have the same size as the recipient object
max@0 3735 </li>
max@0 3736 <br>
max@0 3737 <li>
max@0 3738 Examples:
max@0 3739 <ul>
max@0 3740 <pre>
max@0 3741 mat A = randu&lt;mat&gt;(4,5);
max@0 3742 mat B = randu&lt;mat&gt;(4,5);
max@0 3743
max@0 3744 cx_mat C = zeros&lt;mat&gt;(4,5);
max@0 3745
max@0 3746 C.set_real(A);
max@0 3747 C.set_imag(B);
max@0 3748 </pre>
max@0 3749 </ul>
max@0 3750 </li>
max@0 3751 <br>
max@0 3752 <li>
max@0 3753 <b>Caveat:</b>
max@0 3754 if you want to directly construct a complex matrix out of two real matrices,
max@0 3755 the following code is faster:
max@0 3756 <ul>
max@0 3757 <pre>
max@0 3758 mat A = randu&lt;mat&gt;(4,5);
max@0 3759 mat B = randu&lt;mat&gt;(4,5);
max@0 3760
max@0 3761 cx_mat C = cx_mat(A,B);
max@0 3762 </pre>
max@0 3763 </ul>
max@0 3764 </li>
max@0 3765 <br>
max@0 3766 <li>See also:
max@0 3767 <ul>
max@0 3768 <li><a href="#constructors_mat">matrix constructors</a></li>
max@0 3769 <li><a href="#constructors_cube">cube constructors</a></li>
max@0 3770 <li><a href="#imag_real">imag()&nbsp;/&nbsp;real()</a></li>
max@0 3771 </ul>
max@0 3772 </li>
max@0 3773 <br>
max@0 3774 </ul>
max@0 3775 <hr class="greyline"><br>
max@0 3776
max@0 3777 <a name="set_size"></a>
max@0 3778 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 3779 <tbody>
max@0 3780 <tr>
max@0 3781 <td style="vertical-align: top;"><b>.set_size(n_elem)</b></td>
max@0 3782 <td style="vertical-align: top;"><br>
max@0 3783 </td>
max@0 3784 <td style="vertical-align: top;">(member function of <i>Col</i>, <i>Row</i>, and <i>field</i>)
max@0 3785 </td>
max@0 3786 </tr>
max@0 3787 <tr>
max@0 3788 <td style="vertical-align: top;"><b>.set_size(n_rows, n_cols)</b></td>
max@0 3789 <td style="vertical-align: top;"><br>
max@0 3790 </td>
max@0 3791 <td style="vertical-align: top;">(member function of <i>Mat</i> and <i>field</i>)
max@0 3792 </td>
max@0 3793 </tr>
max@0 3794 <tr>
max@0 3795 <td style="vertical-align: top;"><b>.set_size(n_rows, n_cols, n_slices)</b></td>
max@0 3796 <td style="vertical-align: top;"><br>
max@0 3797 </td>
max@0 3798 <td style="vertical-align: top;">(member function of <i>Cube</i>)
max@0 3799 </td>
max@0 3800 </tr>
max@0 3801 </tbody>
max@0 3802 </table>
max@0 3803 <br>
max@0 3804 <ul>
max@0 3805 <li>Changes the size of an object</li>
max@0 3806 <br>
max@0 3807 <li>
max@0 3808 If the requested number of elements is equal to the old number of elements, existing memory is reused
max@0 3809 </li>
max@0 3810 <br>
max@0 3811 <li>
max@0 3812 If the requested number of elements is not equal to the old number of elements, new memory is used
max@0 3813 </li>
max@0 3814 <br>
max@0 3815 <li>
max@0 3816 If you need to explicitly preserve data, use <a href="#reshape_member">.reshape()</a> or <a href="#resize_member">.resize()</a>
max@0 3817 </li>
max@0 3818 <br>
max@0 3819 <li>
max@0 3820 Examples:
max@0 3821 <ul>
max@0 3822 <pre>
max@0 3823 mat A;
max@0 3824 A.set_size(5,10);
max@0 3825
max@0 3826 vec q;
max@0 3827 q.set_size(100);
max@0 3828 </pre>
max@0 3829 </ul>
max@0 3830 </li>
max@0 3831 <br>
max@0 3832 <li>See also:
max@0 3833 <ul>
max@0 3834 <li><a href="#reset">.reset()</a></li>
max@0 3835 <li><a href="#reshape_member">.reshape()</a></li>
max@0 3836 <li><a href="#resize_member">.resize()</a></li>
max@0 3837 </ul>
max@0 3838 </li>
max@0 3839 </ul>
max@0 3840 <br>
max@0 3841 <hr class="greyline"><br>
max@0 3842
max@0 3843 <a name="shed"></a>
max@0 3844 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 3845 <tbody>
max@0 3846 <tr>
max@0 3847 <td style="vertical-align: top;">
max@0 3848 <b>.shed_row(&nbsp;</b>row_number<b>&nbsp;)</b>
max@0 3849 <br>
max@0 3850 <b>.shed_rows(&nbsp;</b>first_row, last_row<b>&nbsp;)</b>
max@0 3851 </td>
max@0 3852 <td style="vertical-align: top;"><br></td>
max@0 3853 <td style="vertical-align: top;">(member functions of <i>Mat</i> and <i>Col</i>)
max@0 3854 </td>
max@0 3855 </tr>
max@0 3856 <tr>
max@0 3857 <td>&nbsp;</td>
max@0 3858 </tr>
max@0 3859 <tr>
max@0 3860 <td style="vertical-align: top;">
max@0 3861 <b>.shed_col(&nbsp;</b>column_number<b>&nbsp;)</b>
max@0 3862 <br>
max@0 3863 <b>.shed_cols(&nbsp;</b>first_column, last_column<b>&nbsp;)</b>
max@0 3864 </td>
max@0 3865 <td style="vertical-align: top;"><br></td>
max@0 3866 <td style="vertical-align: top;">(member functions of <i>Mat</i> and <i>Row</i>)
max@0 3867 </td>
max@0 3868 </tr>
max@0 3869 <tr>
max@0 3870 <td>&nbsp;</td>
max@0 3871 </tr>
max@0 3872 <tr>
max@0 3873 <td style="vertical-align: top;">
max@0 3874 <b>.shed_slice(&nbsp;</b>slice_number<b>&nbsp;)</b>
max@0 3875 <br>
max@0 3876 <b>.shed_slices(&nbsp;</b>first_slice, last_slice<b>&nbsp;)</b>
max@0 3877 </td>
max@0 3878 <td style="vertical-align: top;"><br></td>
max@0 3879 <td style="vertical-align: top;">(member functions of <i>Cube</i>)
max@0 3880 </td>
max@0 3881 </tr>
max@0 3882 </tbody>
max@0 3883 </table>
max@0 3884 <br>
max@0 3885 <ul>
max@0 3886 <li>
max@0 3887 Single argument functions:
max@0 3888 remove the specified row/column/slice
max@0 3889 </li>
max@0 3890 <br>
max@0 3891 <li>
max@0 3892 Two argument functions:
max@0 3893 remove the specified range of rows/columns/slices
max@0 3894 </li>
max@0 3895 <br>
max@0 3896 <li>
max@0 3897 Examples:
max@0 3898 <ul>
max@0 3899 <pre>
max@0 3900 mat A = randu&lt;mat&gt;(5,10);
max@0 3901
max@0 3902 A.shed_row(2);
max@0 3903 A.shed_cols(2,4);
max@0 3904 </pre>
max@0 3905 </ul>
max@0 3906 </li>
max@0 3907 <br>
max@0 3908 <li>
max@0 3909 See also:
max@0 3910 <ul>
max@0 3911 <li><a href="#insert">insert rows/columns/slices</a></li>
max@0 3912 <li><a href="#join">join rows/columns/slices</a></li>
max@0 3913 <li><a href="#resize_member">.resize()</a></li>
max@0 3914 <li><a href="#submat">submatrix views</a></li>
max@0 3915 <li><a href="#subcube">subcube views</a></li>
max@0 3916 <li><a href="http://thesaurus.com/browse/shed"><i>shed</i> in thesaurus.com</a></li>
max@0 3917 </ul>
max@0 3918 </li>
max@0 3919 <br>
max@0 3920 </ul>
max@0 3921 <hr class="greyline"><br>
max@0 3922
max@0 3923 <a name="stl_container_fns"></a>
max@0 3924 <b>STL container functions</b>
max@0 3925 <ul>
max@0 3926 <li><i>Mat</i>, <i>Col</i> and <i>Row</i> classes provide the following member functions that mimic the containers in the C++ Standard Template Library:<br>
max@0 3927 <br>
max@0 3928
max@0 3929 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 3930 <tbody>
max@0 3931 <tr>
max@0 3932 <td style="vertical-align: top;">
max@0 3933 <b>.clear()</b>
max@0 3934 </td>
max@0 3935 <td style="vertical-align: top;">&nbsp;<br>
max@0 3936 </td>
max@0 3937 <td style="vertical-align: top;">
max@0 3938 causes an object to have no elements
max@0 3939 </td>
max@0 3940 </tr>
max@0 3941 <tr>
max@0 3942 <td style="vertical-align: top;">
max@0 3943 &nbsp;
max@0 3944 </td>
max@0 3945 <td style="vertical-align: top;">&nbsp;<br>
max@0 3946 </td>
max@0 3947 <td style="vertical-align: top;">
max@0 3948 &nbsp;
max@0 3949 </td>
max@0 3950 </tr>
max@0 3951 <tr>
max@0 3952 <td style="vertical-align: top;">
max@0 3953 <b>.empty()</b>
max@0 3954 </td>
max@0 3955 <td style="vertical-align: top;">&nbsp;<br>
max@0 3956 </td>
max@0 3957 <td style="vertical-align: top;">
max@0 3958 returns true if the object has no elements; returns false if the object has one or more elements
max@0 3959 </td>
max@0 3960 </tr>
max@0 3961 <tr>
max@0 3962 <td style="vertical-align: top;">
max@0 3963 &nbsp;
max@0 3964 </td>
max@0 3965 <td style="vertical-align: top;">&nbsp;<br>
max@0 3966 </td>
max@0 3967 <td style="vertical-align: top;">
max@0 3968 &nbsp;
max@0 3969 </td>
max@0 3970 </tr>
max@0 3971 <tr>
max@0 3972 <td style="vertical-align: top;">
max@0 3973 <b>.size()</b>
max@0 3974 </td>
max@0 3975 <td style="vertical-align: top;">&nbsp;<br>
max@0 3976 </td>
max@0 3977 <td style="vertical-align: top;">
max@0 3978 returns the total number of elements
max@0 3979 </td>
max@0 3980 </tr>
max@0 3981 </tbody>
max@0 3982 </table>
max@0 3983 </li>
max@0 3984 <br>
max@0 3985 <li>
max@0 3986 Examples:
max@0 3987 <ul>
max@0 3988 <pre>
max@0 3989 mat A = randu&lt;mat&gt;(5,5);
max@0 3990 cout &lt;&lt; A.size() &lt;&lt; endl;
max@0 3991
max@0 3992 A.clear();
max@0 3993 cout &lt;&lt; A.empty() &lt;&lt; endl;
max@0 3994 </pre>
max@0 3995 </ul>
max@0 3996 </li>
max@0 3997 <br>
max@0 3998 <li>
max@0 3999 See also:
max@0 4000 <ul>
max@0 4001 <li><a href="#iterators_mat">iterators (matrices)</a></li>
max@0 4002 <li><a href="#attributes">matrix and vector attributes</a></li>
max@0 4003 <li><a href="#is_empty">.is_empty()</a></li>
max@0 4004 <li><a href="#reset">.reset()</a></li>
max@0 4005 </ul>
max@0 4006 </li>
max@0 4007 <br>
max@0 4008 </ul>
max@0 4009 <hr class="greyline"><br>
max@0 4010
max@0 4011 <a name="submat"></a>
max@0 4012 <b>submatrix views</b>
max@0 4013 <ul>
max@0 4014 <li>A collection of member functions of <i>Mat</i>, <i>Col</i> and <i>Row</i> classes that provide submatrix views<br>
max@0 4015 <br>
max@0 4016 <li>For a matrix or vector <i>X</i>, the subviews are accessed as:</li>
max@0 4017 <br>
max@0 4018 <ul>
max@0 4019 X.<b>col(&nbsp;</b>col_number<b>&nbsp;)</b><br>
max@0 4020 X<b>(</b>&nbsp;<b>span::all,</b> col_number&nbsp;<b>)</b><br>
max@0 4021 X<b>(</b>&nbsp;<b>span(</b>first_row<b>,</b> last_row<b>),</b> col_number&nbsp;<b>)</b><br>
max@0 4022 <br>
max@0 4023 X.<b>unsafe_col(&nbsp;</b>col_number<b>&nbsp;)</b><br>
max@0 4024 <br>
max@0 4025 X.<b>row(&nbsp;</b>row_number<b>&nbsp;)</b><br>
max@0 4026 X<b>(</b>&nbsp;row_number<b>,</b> <b>span::all</b>&nbsp;<b>)</b><br>
max@0 4027 X<b>(</b>&nbsp;row_number<b>,</b> <b>span(</b>first_col<b>,</b> last_col<b>)&nbsp;)</b><br>
max@0 4028 <br>
max@0 4029 X.<b>cols(&nbsp;</b>first_col<b>,</b> last_col<b>&nbsp;)</b><br>
max@0 4030 X.<b>rows(&nbsp;</b>first_row<b>,</b> last_row<b>&nbsp;)</b><br>
max@0 4031 <br>
max@0 4032 X.<b>submat(&nbsp;</b>first_row<b>,</b> first_col<b>,</b> last_row<b>,</b> last_col<b>&nbsp;)</b><br>
max@0 4033 X.<b>submat(&nbsp;span(</b>first_row<b>,</b> last_row<b>), span(</b>first_col<b>,</b> last_col<b>)&nbsp;)</b><br>
max@0 4034 <br>
max@0 4035 X<b>(&nbsp;span(</b>first_row<b>,</b> last_row<b>), span(</b>first_col<b>,</b> last_col<b>)&nbsp;)</b><br>
max@0 4036 <br>
max@0 4037 X.<b>elem(</b>&nbsp;vector_of_indices&nbsp;<b>)</b>
max@0 4038 </ul>
max@0 4039 </li>
max@0 4040 <br>
max@0 4041 <li>For a vector <i>V</i> (column or row vector), there is an additional method:</li>
max@0 4042 <!-- <li>For a vector <i>V</i> (column or row vector), there are three additional methods:</li> -->
max@0 4043 <br>
max@0 4044 <ul>
max@0 4045 V.<b>subvec(&nbsp;</b>first_index<b>,</b> last_index<b>&nbsp;)</b><br>
max@0 4046 <!--
max@0 4047 V.<b>subvec(&nbsp;span(</b>first_index<b>,</b> last_index<b>)&nbsp;)</b><br>
max@0 4048 <br>
max@0 4049 V<b>(&nbsp;span(</b>first_index<b>,</b> last_index<b>)&nbsp;)</b><br>
max@0 4050 -->
max@0 4051 </ul>
max@0 4052 <br>
max@0 4053 <li>
max@0 4054 Instances of <i>span::all</i>, to indicate an entire range, can be replaced by <i>span()</i>, where no number is specified
max@0 4055 </li>
max@0 4056 <br>
max@0 4057 <li>
max@0 4058 In the function <i>X.elem(vector_of_indices)</i>,
max@0 4059 elements specified in <i>vector_of_indices</i> are accessed.
max@0 4060 <i>X</i> is interpreted as one long vector,
max@0 4061 with column-by-column ordering of the elements of <i>X</i>.
max@0 4062 The <i>vector_of_indices</i> must evaluate to be a vector of type <i><a href="#Col">uvec</a></i>
max@0 4063 (eg., generated by <i><a href="#find">find()</a></i>).
max@0 4064 The aggregate set of the specified elements is treated as a column vector
max@0 4065 (eg., the output of <i>X.elem()</i> is always a column vector).
max@0 4066 </li>
max@0 4067 <br>
max@0 4068 <li>
max@0 4069 The function <i>.unsafe_col()</i> is provided for speed reasons and should be used only if you know what you're doing.
max@0 4070 The function creates a seemingly independent <i>Col</i> vector object (eg. <i>vec</i>),
max@0 4071 but the vector actually uses memory from the existing matrix object.
max@0 4072 As such, the created <i>Col</i> vector is currently not alias safe
max@0 4073 and does not take into account that the parent matrix object could be deleted.
max@0 4074 If deleted memory is accessed through the created <i>Col</i> vector,
max@0 4075 it will cause memory corruption and/or a crash.
max@0 4076 </li>
max@0 4077 <br>
max@0 4078 <li>
max@0 4079 Examples:
max@0 4080 <ul>
max@0 4081 <pre>
max@0 4082 mat A = zeros&lt;mat&gt;(5,10);
max@0 4083
max@0 4084 A.submat(0,1,2,3) = randu&lt;mat&gt;(3,3);
max@0 4085
max@0 4086 // the following three statements
max@0 4087 // access the same part of A
max@0 4088 mat B = A.submat(0,1,2,3);
max@0 4089 mat C = A.submat( span(0,2), span(1,3) );
max@0 4090 mat D = A( span(0,2), span(1,3) );
max@0 4091
max@0 4092 // the following two statements
max@0 4093 // access the same part of A
max@0 4094 A.col(1) = randu&lt;mat&gt;(5,1);
max@0 4095 A(span::all, 1) = randu&lt;mat&gt;(5,1);
max@0 4096
max@0 4097 mat X = randu&lt;mat&gt;(5,5);
max@0 4098
max@0 4099 // get all elements of X that are greater than 0.5
max@0 4100 vec q = X.elem( find(X > 0.5) );
max@0 4101
max@0 4102 // set four specific elements of X to 1
max@0 4103 uvec indices;
max@0 4104 indices &lt;&lt; 2 &lt;&lt; 3 &lt;&lt; 6 &lt;&lt; 8;
max@0 4105
max@0 4106 X.elem(indices) = ones&lt;vec&gt;(4);
max@0 4107 </pre>
max@0 4108 </ul>
max@0 4109 </li>
max@0 4110 <br>
max@0 4111 <li>
max@0 4112 See also:
max@0 4113 <ul>
max@0 4114 <li><a href="#diag">.diag()</a></li>
max@0 4115 <li><a href="#colptr">.colptr()</a></li>
max@0 4116 <li><a href="#in_range">.in_range()</a></li>
max@0 4117 <li><a href="#find">find()</a></li>
max@0 4118 <li><a href="#join">join rows/columns/slices</a></li>
max@0 4119 <li><a href="#shed">shed rows/columns/slices</a></li>
max@0 4120 <li><a href="#insert">insert rows/columns/slices</a></li>
max@0 4121 <li><a href="#subcube">subcube views</a></li>
max@0 4122 </ul>
max@0 4123 </li>
max@0 4124 <br>
max@0 4125 </ul>
max@0 4126 <hr class="greyline"><br>
max@0 4127
max@0 4128 <a name="subcube"></a>
max@0 4129 <b>subcube views and slices</b>
max@0 4130 <ul>
max@0 4131 <li>A collection of member functions of the <i>Cube</i> class that provide subcube views<br>
max@0 4132 <br>
max@0 4133 <li>For a cube <i>Q</i>, the subviews are accessed as:</li>
max@0 4134 <br>
max@0 4135 <ul>
max@0 4136 Q.<b>slice(&nbsp;</b>slice_number&nbsp;<b>)</b><br>
max@0 4137 Q.<b>slices(&nbsp;</b>first_slice<b>,</b> last_slice&nbsp;<b>)</b><br>
max@0 4138 <br>
max@0 4139 Q.<b>subcube(&nbsp;</b>first_row<b>,</b> first_col<b>,</b> first_slice<b>, </b>last_row<b>,</b> last_col<b>, </b>last_slice&nbsp;<b>)</b><br>
max@0 4140 Q.<b>subcube(&nbsp;span(</b>first_row<b>,</b> last_row<b>), span(</b>first_col<b>,</b> last_col<b>), span(</b>first_slice<b>,</b> last_slice<b>)&nbsp;)</b><br>
max@0 4141 <br>
max@0 4142 Q<b>(&nbsp;span(</b>first_row<b>,</b> last_row<b>), span(</b>first_col<b>,</b> last_col<b>), span(</b>first_slice<b>,</b> last_slice<b>)&nbsp;)</b><br>
max@0 4143 </ul>
max@0 4144 </li>
max@0 4145 <br>
max@0 4146 <li>
max@0 4147 Instances of <i>span(a,b)</i> can be replaced by:
max@0 4148 <ul>
max@0 4149 <li><i>span()</i> or <i>span::all</i>, to indicate the entire range</li>
max@0 4150 <li><i>span(a)</i>, to indicate a particular row, column or slice</li>
max@0 4151 </ul>
max@0 4152 </li>
max@0 4153 <br>
max@0 4154 <li>
max@0 4155 An individual slice, accessed via <i>.slice()</i>, is an instance of the <i>Mat</i> class
max@0 4156 (a reference to a matrix is provided)
max@0 4157 </li>
max@0 4158 <br>
max@0 4159 <li>
max@0 4160 Examples:
max@0 4161 <ul>
max@0 4162 <pre>
max@0 4163 cube A = randu&lt;cube&gt;(2,3,4);
max@0 4164 mat B = A.slice(1);
max@0 4165
max@0 4166 A.slice(0) = randu&lt;mat&gt;(2,3);
max@0 4167 A.slice(0)(1,2) = 99.0;
max@0 4168
max@0 4169 A.subcube(0,0,1, 1,1,2) = randu&lt;cube&gt;(2,2,2);
max@0 4170 A( span(0,1), span(0,1), span(1,2) ) = randu&lt;cube&gt;(2,2,2);
max@0 4171
max@0 4172 </pre>
max@0 4173 </ul>
max@0 4174 </li>
max@0 4175 <br>
max@0 4176 <li>
max@0 4177 See also:
max@0 4178 <ul>
max@0 4179 <li><a href="#in_range">.in_range()</a></li>
max@0 4180 <li><a href="#join">join slices</a></li>
max@0 4181 <li><a href="#shed">shed slices</a></li>
max@0 4182 <li><a href="#insert">insert slices</a></li>
max@0 4183 <li><a href="#submat">submatrix views</a></li>
max@0 4184 </ul>
max@0 4185 </li>
max@0 4186 <br>
max@0 4187 </ul>
max@0 4188 <hr class="greyline"><br>
max@0 4189
max@0 4190 <a name="subfield"></a>
max@0 4191 <b>subfield views</b>
max@0 4192 <ul>
max@0 4193 <li>A collection of member functions of the <i>field</i> class that provide subfield views<br>
max@0 4194 <br>
max@0 4195 <li>For a field <i>F</i>, the subfields are accessed as:</li>
max@0 4196 <br>
max@0 4197 <ul>
max@0 4198 F.<b>row(&nbsp;</b>row_number&nbsp;<b>)</b><br>
max@0 4199 F.<b>col(&nbsp;</b>col_number&nbsp;<b>)</b><br>
max@0 4200 <br>
max@0 4201 F.<b>rows(&nbsp;</b>first_row<b>,</b> last_row&nbsp;<b>)</b><br>
max@0 4202 F.<b>cols(&nbsp;</b>first_col<b>,</b> last_col&nbsp;<b>)</b><br>
max@0 4203 <br>
max@0 4204 F.<b>subfield(&nbsp;</b>first_row<b>,</b>&nbsp;first_col<b>,</b> last_row<b>,</b>&nbsp;last_col <b>)</b><br>
max@0 4205 F.<b>subfield(&nbsp;span(</b>first_row<b>,</b>&nbsp;last_row<b>), span(</b>first_col<b>,</b>&nbsp;last_col<b>) )</b><br>
max@0 4206 <br>
max@0 4207 F<b>(&nbsp;span(</b>first_row<b>,</b> last_row<b>), span(</b>first_col<b>,</b>&nbsp;last_col<b>) )</b><br>
max@0 4208 </ul>
max@0 4209 </li>
max@0 4210 <br>
max@0 4211 <li>
max@0 4212 Instances of <i>span(a,b)</i> can be replaced by:
max@0 4213 <ul>
max@0 4214 <li><i>span()</i> or <i>span::all</i>, to indicate the entire range</li>
max@0 4215 <li><i>span(a)</i>, to indicate a particular row or column</li>
max@0 4216 </ul>
max@0 4217 </li>
max@0 4218 <br>
max@0 4219 <li>
max@0 4220 See also:
max@0 4221 <ul>
max@0 4222 <li><a href="#in_range">.in_range()</a></li>
max@0 4223 <li><a href="#submat">submatrix views</a></li>
max@0 4224 <li><a href="#subcube">subcube views</a></li>
max@0 4225 </ul>
max@0 4226 </li>
max@0 4227 <br>
max@0 4228 </ul>
max@0 4229 <hr class="greyline"><br>
max@0 4230
max@0 4231 <a name="swap_rows"></a>
max@0 4232 <b>
max@0 4233 .swap_rows(row1, row2)
max@0 4234 <br>.swap_cols(col1, col2)
max@0 4235 </b>
max@0 4236 <ul>
max@0 4237 <li>
max@0 4238 Member functions of <i>Mat</i>, <i>Col</i> and <i>Row</i> classes
max@0 4239 </li>
max@0 4240 <br>
max@0 4241 <li>
max@0 4242 Swap the contents of specified rows or columns
max@0 4243 </li>
max@0 4244 <br>
max@0 4245 <li>
max@0 4246 Examples:
max@0 4247 <ul>
max@0 4248 <pre>
max@0 4249 mat X = randu&lt;mat&gt;(5,5);
max@0 4250 X.swap_rows(0,4);
max@0 4251 </pre>
max@0 4252 </ul>
max@0 4253 </li>
max@0 4254 <br>
max@0 4255 <li>
max@0 4256 See also:
max@0 4257 <ul>
max@0 4258 <li><a href="#flip">fliplr() &amp; flipud()</a></li>
max@0 4259 </ul>
max@0 4260 </li>
max@0 4261 <br>
max@0 4262 </ul>
max@0 4263 <hr class="greyline"><br>
max@0 4264
max@0 4265 <a name="t_st_members"></a>
max@0 4266 <b>
max@0 4267 .t()
max@0 4268 <br>.st()
max@0 4269 </b>
max@0 4270 <ul>
max@0 4271 <li>
max@0 4272 Member functions of any expression involving matrices or vectors
max@0 4273 </li>
max@0 4274 <br>
max@0 4275 <li>
max@0 4276 <i>.t()</i> provides a transposed copy of the object; if a given object has complex elements, a Hermitian transpose is done (ie. the conjugate of the elements is taken during the transpose operation)
max@0 4277 </li>
max@0 4278 <br>
max@0 4279 <li>
max@0 4280 <i>.st()</i> provides a transposed copy of the object, without taking the conjugate of the elements (complex matrices)
max@0 4281 </li>
max@0 4282 <br>
max@0 4283 <li>
max@0 4284 For non-complex objects, the <i>.t()</i> and <i>.st()</i> functions are equivalent
max@0 4285 </li>
max@0 4286 <br>
max@0 4287 <li>
max@0 4288 Examples:
max@0 4289 <ul>
max@0 4290 <pre>
max@0 4291 mat A = randu&lt;mat&gt;(4,5);
max@0 4292 mat B = A.t();
max@0 4293 </pre>
max@0 4294 </ul>
max@0 4295 </li>
max@0 4296 <br>
max@0 4297 <li>
max@0 4298 The <i>.t()</i> and <i>.st()</i> functions were added in version 2.4
max@0 4299 </li>
max@0 4300 <br>
max@0 4301 <li>
max@0 4302 See also:
max@0 4303 <ul>
max@0 4304 <li><a href="#trans">trans()</a></li>
max@0 4305 <li><a href="#strans">strans()</a></li>
max@0 4306 </ul>
max@0 4307 </li>
max@0 4308 <br>
max@0 4309 </ul>
max@0 4310 <hr class="greyline"><br>
max@0 4311
max@0 4312 <a name="zeros_member"></a>
max@0 4313 <b>.zeros()</b>
max@0 4314 <br><b>.zeros(n_elem)</b>
max@0 4315 <br><b>.zeros(n_rows, n_cols)</b>
max@0 4316 <br><b>.zeros(n_rows, n_cols, n_slices)</b>
max@0 4317 <ul>
max@0 4318 <li>
max@0 4319 Set the elements of an object to zero, optionally first resizing to specified dimensions
max@0 4320 </li>
max@0 4321 <br>
max@0 4322 <li>
max@0 4323 <i>.zeros()</i> and <i>.zeros(n_elem)</i> are member function of <i>Col</i> and <i>Row</i>
max@0 4324 </li>
max@0 4325 <br>
max@0 4326 <li>
max@0 4327 <i>.zeros()</i> and <i>.zeros(n_rows, n_cols)</i> are member functions of <i>Mat</i>
max@0 4328 </li>
max@0 4329 <br>
max@0 4330 <li>
max@0 4331 <i>.zeros()</i> and <i>.zeros(n_rows, n_cols, n_slices)</i> are member functions of <i>Cube</i>
max@0 4332 </li>
max@0 4333 <br>
max@0 4334 <li>
max@0 4335 Examples:
max@0 4336 <ul>
max@0 4337 <pre>
max@0 4338 mat A = randu&lt;mat&gt;(5,10);
max@0 4339 A.zeros(); // sets all elements to zero
max@0 4340 A.zeros(10,20); // sets the size to 10 rows and 20 columns
max@0 4341 // followed by setting all elements to zero
max@0 4342 </pre>
max@0 4343 </ul>
max@0 4344 </li>
max@0 4345 <br>
max@0 4346 <li>
max@0 4347 See also:
max@0 4348 <ul>
max@0 4349 <li><a href="#zeros_standalone">zeros()</a> (standalone function)</li>
max@0 4350 <li><a href="#ones_member">.ones()</a></li>
max@0 4351 <li><a href="#fill">.fill()</a></li>
max@0 4352 <li><a href="#reset">.reset()</a></li>
max@0 4353 </ul>
max@0 4354 </li>
max@0 4355 <br>
max@0 4356 </ul>
max@0 4357 <hr class="greyline">
max@0 4358
max@0 4359
max@0 4360 <hr class="greyline">
max@0 4361 <br>
max@0 4362 <br>
max@0 4363 <font size=+1><b>Other Classes</b></font>
max@0 4364 <br>
max@0 4365 <br>
max@0 4366 <hr class="greyline">
max@0 4367 <br>
max@0 4368
max@0 4369 <a name="running_stat"></a>
max@0 4370 <b>running_stat&lt;</b><i>type</i><b>&gt;</b>
max@0 4371 <ul>
max@0 4372 <li>
max@0 4373 Class for keeping statistics of a continuously sampled one dimensional process/signal.
max@0 4374 Useful if the storage of individual samples (scalars) is not necessary or desired.
max@0 4375 Also useful if the number of samples is not known beforehand or exceeds available memory.
max@0 4376 </li>
max@0 4377 <br>
max@0 4378 <li>
max@0 4379 <i>type</i> should be one of: <i>float</i>, <i>double</i>, <i><a href="#cx_float_double">cx_float</a></i>, <i><a href="#cx_float_double">cx_double</a></i>
max@0 4380 </li>
max@0 4381 <br>
max@0 4382 <li>
max@0 4383 Member functions:
max@0 4384 <ul>
max@0 4385 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 4386 <tbody>
max@0 4387 <tr>
max@0 4388 <td style="vertical-align: top;">
max@0 4389 <b>.operator()(</b>scalar<b>)</b>
max@0 4390 </td>
max@0 4391 <td style="vertical-align: top;">&nbsp;<br>
max@0 4392 </td>
max@0 4393 <td style="vertical-align: top;">
max@0 4394 update the statistics so far using the given scalar
max@0 4395 </td>
max@0 4396 </tr>
max@0 4397 <tr>
max@0 4398 <td style="vertical-align: top;">
max@0 4399 <b>.mean()</b>
max@0 4400 </td>
max@0 4401 <td style="vertical-align: top;">&nbsp;<br>
max@0 4402 </td>
max@0 4403 <td style="vertical-align: top;">
max@0 4404 get the mean or average value so far
max@0 4405 </td>
max@0 4406 </tr>
max@0 4407 <tr>
max@0 4408 <td style="vertical-align: top;">
max@0 4409 <b>.var(</b>norm_type=0<b>)</b>
max@0 4410 </td>
max@0 4411 <td style="vertical-align: top;">&nbsp;<br>
max@0 4412 </td>
max@0 4413 <td style="vertical-align: top;">
max@0 4414 get the variance so far
max@0 4415 </td>
max@0 4416 </tr>
max@0 4417 <tr>
max@0 4418 <td style="vertical-align: top;">
max@0 4419 <b>.stddev(</b>norm_type=0<b>)</b>
max@0 4420 </td>
max@0 4421 <td style="vertical-align: top;">&nbsp;<br>
max@0 4422 </td>
max@0 4423 <td style="vertical-align: top;">
max@0 4424 get the standard deviation so far
max@0 4425 </td>
max@0 4426 </tr>
max@0 4427 <tr>
max@0 4428 <td style="vertical-align: top;">
max@0 4429 <b>.min()</b>
max@0 4430 </td>
max@0 4431 <td style="vertical-align: top;">&nbsp;<br>
max@0 4432 </td>
max@0 4433 <td style="vertical-align: top;">
max@0 4434 get the minimum value so far
max@0 4435 </td>
max@0 4436 </tr>
max@0 4437 <tr>
max@0 4438 <td style="vertical-align: top;">
max@0 4439 <b>.max()</b>
max@0 4440 </td>
max@0 4441 <td style="vertical-align: top;">&nbsp;<br>
max@0 4442 </td>
max@0 4443 <td style="vertical-align: top;">
max@0 4444 get the maximum value so far
max@0 4445 </td>
max@0 4446 </tr>
max@0 4447 <tr>
max@0 4448 <td style="vertical-align: top;">
max@0 4449 <b>.reset()</b>
max@0 4450 </td>
max@0 4451 <td style="vertical-align: top;">&nbsp;<br>
max@0 4452 </td>
max@0 4453 <td style="vertical-align: top;">
max@0 4454 reset all statistics and set the number of samples to zero
max@0 4455 </td>
max@0 4456 </tr>
max@0 4457 <tr>
max@0 4458 <td style="vertical-align: top;">
max@0 4459 <b>.count()</b>
max@0 4460 </td>
max@0 4461 <td style="vertical-align: top;">&nbsp;<br>
max@0 4462 </td>
max@0 4463 <td style="vertical-align: top;">
max@0 4464 get the number of samples so far
max@0 4465 </td>
max@0 4466 </tr>
max@0 4467 </tbody>
max@0 4468 </table>
max@0 4469 </ul>
max@0 4470 </li>
max@0 4471 <br>
max@0 4472 <li>
max@0 4473 For the .var() and .stddev() functions, the default <i>norm_type=0</i> performs normalisation using <i>N-1</i>
max@0 4474 (where <i>N</i> is the number of samples so far),
max@0 4475 providing the best unbiased estimator.
max@0 4476 Using <i>norm_type=1</i> causes normalisation to be done using <i>N</i>, which provides the second moment around the mean.
max@0 4477 </li>
max@0 4478 <br>
max@0 4479 <li>
max@0 4480 The return type of .count() depends on the underlying form of <i>type</i>: it is either <i>float</i> or <i>double</i>.
max@0 4481 </li>
max@0 4482 <br>
max@0 4483 <li>
max@0 4484 Examples:
max@0 4485 <ul>
max@0 4486 <pre>
max@0 4487 running_stat&lt;double&gt; stats;
max@0 4488
max@0 4489 for(uword i=0; i&lt;10000; ++i)
max@0 4490 {
max@0 4491 double sample = double(rand())/RAND_MAX;
max@0 4492 stats(sample);
max@0 4493 }
max@0 4494
max@0 4495 cout &lt;&lt; "mean = " &lt;&lt; stats.mean() &lt;&lt; endl;
max@0 4496 cout &lt;&lt; "var = " &lt;&lt; stats.var() &lt;&lt; endl;
max@0 4497 cout &lt;&lt; "min = " &lt;&lt; stats.min() &lt;&lt; endl;
max@0 4498 cout &lt;&lt; "max = " &lt;&lt; stats.max() &lt;&lt; endl;
max@0 4499 </pre>
max@0 4500 </ul>
max@0 4501 </li>
max@0 4502 <br>
max@0 4503 <li>See also:
max@0 4504 <ul>
max@0 4505 <li><a href="#stats_fns">statistics functions</a></li>
max@0 4506 <li><a href="#running_stat_vec">running_stat_vec</a></li>
max@0 4507 </ul>
max@0 4508 </li>
max@0 4509 </ul>
max@0 4510 <br>
max@0 4511 <hr class="greyline"><br>
max@0 4512
max@0 4513 <a name="running_stat_vec"></a>
max@0 4514 <b>running_stat_vec&lt;</b><i>type</i><b>&gt;(calc_cov = false)</b>
max@0 4515 <ul>
max@0 4516 <li>
max@0 4517 Class for keeping statistics of a continuously sampled multi-dimensional process/signal.
max@0 4518 Useful if the storage of individual samples is not necessary or desired.
max@0 4519 Also useful if the number of samples is not known beforehand or exceeds available memory.
max@0 4520 </li>
max@0 4521 <br>
max@0 4522 <li>
max@0 4523 This class is similar to <i>running_stat</i>, with the difference being that vectors are processed instead of single values.
max@0 4524 </li>
max@0 4525 <br>
max@0 4526 <li>
max@0 4527 <i>type</i> must match the element type used by the sample vectors
max@0 4528 (ie. it must be one of <i>float</i>, <i>double</i>, <i><a href="#cx_float_double">cx_float</a></i>, <i><a href="#cx_float_double">cx_double</a></i>)
max@0 4529 </li>
max@0 4530 <br>
max@0 4531 <li>
max@0 4532 <i>type</i> can be inferred via the use of the <i>elem_type</i> member typedef of a vector class.
max@0 4533 For example, <i>fvec::elem_type</i> will be interpreted as <i>float</i>,
max@0 4534 while <i>cx_vec::elem_type</i> will be interpreted as <i><a href="#cx_float_double">cx_double</a></i>.
max@0 4535 </li>
max@0 4536 <br>
max@0 4537 <li>
max@0 4538 Member functions:
max@0 4539 <ul>
max@0 4540 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 4541 <tbody>
max@0 4542 <tr>
max@0 4543 <td style="vertical-align: top;">
max@0 4544 <b>.operator()(</b>vector<b>)</b>
max@0 4545 </td>
max@0 4546 <td style="vertical-align: top;">&nbsp;<br>
max@0 4547 </td>
max@0 4548 <td style="vertical-align: top;">
max@0 4549 update the statistics so far using the given vector
max@0 4550 </td>
max@0 4551 </tr>
max@0 4552 <tr>
max@0 4553 <td style="vertical-align: top;">
max@0 4554 <b>.mean()</b>
max@0 4555 </td>
max@0 4556 <td style="vertical-align: top;">&nbsp;<br>
max@0 4557 </td>
max@0 4558 <td style="vertical-align: top;">
max@0 4559 get the mean vector so far
max@0 4560 </td>
max@0 4561 </tr>
max@0 4562 <tr>
max@0 4563 <td style="vertical-align: top;">
max@0 4564 <b>.var(</b>norm_type=0<b>)</b>
max@0 4565 </td>
max@0 4566 <td style="vertical-align: top;">&nbsp;<br>
max@0 4567 </td>
max@0 4568 <td style="vertical-align: top;">
max@0 4569 get the vector of variances so far
max@0 4570 </td>
max@0 4571 </tr>
max@0 4572 <tr>
max@0 4573 <td style="vertical-align: top;">
max@0 4574 <b>.stddev(</b>norm_type=0<b>)</b>
max@0 4575 </td>
max@0 4576 <td style="vertical-align: top;">&nbsp;<br>
max@0 4577 </td>
max@0 4578 <td style="vertical-align: top;">
max@0 4579 get the vector of standard deviations so far
max@0 4580 </td>
max@0 4581 </tr>
max@0 4582 <tr>
max@0 4583 <td style="vertical-align: top;">
max@0 4584 <b>.min()</b>
max@0 4585 </td>
max@0 4586 <td style="vertical-align: top;">&nbsp;<br>
max@0 4587 </td>
max@0 4588 <td style="vertical-align: top;">
max@0 4589 get the vector of minimum values so far
max@0 4590 </td>
max@0 4591 </tr>
max@0 4592 <tr>
max@0 4593 <td style="vertical-align: top;">
max@0 4594 <b>.max()</b>
max@0 4595 </td>
max@0 4596 <td style="vertical-align: top;">&nbsp;<br>
max@0 4597 </td>
max@0 4598 <td style="vertical-align: top;">
max@0 4599 get the vector of maximum values so far
max@0 4600 </td>
max@0 4601 </tr>
max@0 4602 <tr>
max@0 4603 <td style="vertical-align: top;">
max@0 4604 <b>.cov(</b>norm_type=0<b>)</b>
max@0 4605 </td>
max@0 4606 <td style="vertical-align: top;">&nbsp;<br>
max@0 4607 </td>
max@0 4608 <td style="vertical-align: top;">
max@0 4609 get the covariance matrix so far
max@0 4610 <br>NOTE: this only works if <i>calc_cov</i> is set to <i>true</i> during the construction of the class
max@0 4611 </td>
max@0 4612 </tr>
max@0 4613 <tr>
max@0 4614 <td style="vertical-align: top;">
max@0 4615 <b>.reset()</b>
max@0 4616 </td>
max@0 4617 <td style="vertical-align: top;">&nbsp;<br>
max@0 4618 </td>
max@0 4619 <td style="vertical-align: top;">
max@0 4620 reset all statistics and set the number of samples to zero
max@0 4621 </td>
max@0 4622 </tr>
max@0 4623 <tr>
max@0 4624 <td style="vertical-align: top;">
max@0 4625 <b>.count()</b>
max@0 4626 </td>
max@0 4627 <td style="vertical-align: top;">&nbsp;<br>
max@0 4628 </td>
max@0 4629 <td style="vertical-align: top;">
max@0 4630 get the number of samples so far
max@0 4631 </td>
max@0 4632 </tr>
max@0 4633 </tbody>
max@0 4634 </table>
max@0 4635 </ul>
max@0 4636 </li>
max@0 4637 <br>
max@0 4638 <li>
max@0 4639 For the .var() and .stddev() functions, the default <i>norm_type=0</i> performs normalisation using <i>N-1</i>
max@0 4640 (where <i>N</i> is the number of samples so far),
max@0 4641 providing the best unbiased estimator.
max@0 4642 Using <i>norm_type=1</i> causes normalisation to be done using <i>N</i>, which provides the second moment around the mean.
max@0 4643 </li>
max@0 4644 <br>
max@0 4645 <li>
max@0 4646 The return type of .count() depends on the underlying form of <i>type</i>: it is either <i>float</i> or <i>double</i>.
max@0 4647 </li>
max@0 4648 <br>
max@0 4649 <li>
max@0 4650 Examples:
max@0 4651 <ul>
max@0 4652 <pre>
max@0 4653 running_stat_vec&lt;rowvec::elem_type&gt; stats;
max@0 4654
max@0 4655 rowvec sample;
max@0 4656
max@0 4657 for(uword i=0; i&lt;10000; ++i)
max@0 4658 {
max@0 4659 sample = randu&lt;rowvec&gt;(5);
max@0 4660 stats(sample);
max@0 4661 }
max@0 4662
max@0 4663 cout &lt;&lt; "mean = " &lt;&lt; stats.mean() &lt;&lt; endl;
max@0 4664 cout &lt;&lt; "var = " &lt;&lt; stats.var() &lt;&lt; endl;
max@0 4665 cout &lt;&lt; "min = " &lt;&lt; stats.min() &lt;&lt; endl;
max@0 4666 cout &lt;&lt; "max = " &lt;&lt; stats.max() &lt;&lt; endl;
max@0 4667
max@0 4668 //
max@0 4669 //
max@0 4670
max@0 4671 running_stat_vec&lt;rowvec::elem_type&gt; more_stats(true);
max@0 4672
max@0 4673 for(uword i=0; i&lt;20; ++i)
max@0 4674 {
max@0 4675 sample = randu&lt;rowvec&gt;(3);
max@0 4676
max@0 4677 sample(1) -= sample(0);
max@0 4678 sample(2) += sample(1);
max@0 4679
max@0 4680 more_stats(sample);
max@0 4681 }
max@0 4682
max@0 4683 cout &lt;&lt; "covariance matrix = " &lt;&lt; endl;
max@0 4684 cout &lt;&lt; more_stats.cov() &lt;&lt; endl;
max@0 4685
max@0 4686 rowvec sd = more_stats.stddev();
max@0 4687
max@0 4688 cout &lt;&lt; "correlations = " &lt;&lt; endl;
max@0 4689 cout &lt;&lt; more_stats.cov() / (trans(sd) * sd);
max@0 4690 </pre>
max@0 4691 </ul>
max@0 4692 </li>
max@0 4693 <br>
max@0 4694 <li>See also:
max@0 4695 <ul>
max@0 4696 <li><a href="#cov">cov()</a></li>
max@0 4697 <li><a href="#cor">cor()</a></li>
max@0 4698 <li><a href="#running_stat">running_stat</a></li>
max@0 4699 <li><a href="#stats_fns">statistics functions</a></li>
max@0 4700 </ul>
max@0 4701 </li>
max@0 4702 </ul>
max@0 4703 <br>
max@0 4704 <hr class="greyline"><br>
max@0 4705
max@0 4706 <a name="wall_clock"></a>
max@0 4707 <b>wall_clock</b>
max@0 4708 <ul>
max@0 4709 <li>
max@0 4710 Simple wall clock timer class, for measuring the number of elapsed seconds between two intervals
max@0 4711 </li>
max@0 4712 <br>
max@0 4713 <li>
max@0 4714 Examples:
max@0 4715 <ul>
max@0 4716 <pre>
max@0 4717 wall_clock timer;
max@0 4718
max@0 4719 mat A = randu&lt;mat&gt;(4,4);
max@0 4720 mat B = randu&lt;mat&gt;(4,4);
max@0 4721 mat C;
max@0 4722
max@0 4723 timer.tic();
max@0 4724 for(uword i=0; i&lt;100000; ++i)
max@0 4725 C = A + B + A + B;
max@0 4726
max@0 4727 double n_secs = timer.toc();
max@0 4728 cout &lt;&lt; "took " &lt;&lt; n_secs &lt;&lt; " seconds" &lt;&lt; endl;
max@0 4729 </pre>
max@0 4730 </ul>
max@0 4731 </li>
max@0 4732 </ul>
max@0 4733 <br>
max@0 4734 <hr class="greyline">
max@0 4735
max@0 4736 <hr class="greyline">
max@0 4737 <br>
max@0 4738 <br>
max@0 4739 <font size=+1><b>Generated Vectors/Matrices</b></font>
max@0 4740 <br>
max@0 4741 <br>
max@0 4742 <hr class="greyline">
max@0 4743 <br>
max@0 4744
max@0 4745 <a name="eye_standalone"></a>
max@0 4746 <b>eye(n_rows, n_cols)</b>
max@0 4747 <ul>
max@0 4748 <li>
max@0 4749 Generate a matrix with the elements along the main diagonal set to one
max@0 4750 and off-diagonal elements set to zero
max@0 4751 </li>
max@0 4752 <br>
max@0 4753 <li>
max@0 4754 An identity matrix is generated when <i>n_rows</i> = <i>n_cols</i>
max@0 4755 </li>
max@0 4756 <br>
max@0 4757 <li>
max@0 4758 Usage:
max@0 4759 <ul>
max@0 4760 <li>
max@0 4761 <i>matrix_type</i> X = eye&lt;<i>matrix_type</i>&gt;(n_rows, n_cols)
max@0 4762 </li>
max@0 4763 </ul>
max@0 4764 </li>
max@0 4765 <br>
max@0 4766 <li>
max@0 4767 Examples:
max@0 4768 <ul>
max@0 4769 <pre>
max@0 4770 mat A = eye&lt;mat&gt;(5,5);
max@0 4771 mat B = 123.0 * eye&lt;mat&gt;(5,5);
max@0 4772 </pre>
max@0 4773 </ul>
max@0 4774 </li>
max@0 4775 <br>
max@0 4776 <li>See also:
max@0 4777 <ul>
max@0 4778 <li><a href="#eye_member">.eye()</a> (member function of Mat)</li>
max@0 4779 <li><a href="#ones_standalone">ones()</a></li>
max@0 4780 <li><a href="#diagmat">diagmat()</a></li>
max@0 4781 <li><a href="#diagvec">diagvec()</a></li>
max@0 4782 </ul>
max@0 4783 </li>
max@0 4784 <br>
max@0 4785 </ul>
max@0 4786 <hr class="greyline"><br>
max@0 4787
max@0 4788 <a name="linspace"></a>
max@0 4789 <b>linspace(start, end, N=100)</b>
max@0 4790 <ul>
max@0 4791 <li>
max@0 4792 Generate a vector with <i>N</i> elements;
max@0 4793 the values of the elements linearly increase from <i>start</i> upto (and including) <i>end</i>
max@0 4794 <br>
max@0 4795 </li>
max@0 4796 <br>
max@0 4797 <li>
max@0 4798 Usage:
max@0 4799 <ul>
max@0 4800 <li><i>vector_type</i> v = linspace&lt;<i>vector_type</i>&gt;(start, end, N)</li>
max@0 4801 <li><i>matrix_type</i> X = linspace&lt;<i>matrix_type</i>&gt;(start, end, N)</li>
max@0 4802 </ul>
max@0 4803 </li>
max@0 4804 <br>
max@0 4805 <li>
max@0 4806 If a <i>matrix_type</i> is specified, the resultant matrix will have one column
max@0 4807 </li>
max@0 4808 <br>
max@0 4809 <li>
max@0 4810 Examples:
max@0 4811 <ul>
max@0 4812 <pre>
max@0 4813 vec v = linspace&lt;vec&gt;(10, 20, 5);
max@0 4814 mat X = linspace&lt;mat&gt;(10, 20, 5);
max@0 4815 </pre>
max@0 4816 </ul>
max@0 4817 </li>
max@0 4818 </ul>
max@0 4819 <br>
max@0 4820 <hr class="greyline"><br>
max@0 4821
max@0 4822 <a name="ones_standalone"></a>
max@0 4823 <b>
max@0 4824 ones(n_elem)
max@0 4825 <br>ones(n_rows, n_cols)
max@0 4826 <br>ones(n_rows, n_cols, n_slices)
max@0 4827 </b>
max@0 4828 <ul>
max@0 4829 <li>
max@0 4830 Generate a vector, matrix or cube with all elements set to one
max@0 4831 </li>
max@0 4832 <br>
max@0 4833 <li>
max@0 4834 Usage:
max@0 4835 <ul>
max@0 4836 <li><i>vector_type</i> v = ones&lt;<i>vector_type</i>&gt;(n_elem)</li>
max@0 4837 <li><i>matrix_type</i> X = ones&lt;<i>matrix_type</i>&gt;(n_rows, n_cols)</li>
max@0 4838 <li><i>cube_type</i> Q = ones&lt;<i>cube_type</i>&gt;(n_rows, n_cols, n_slices)</li>
max@0 4839 </ul>
max@0 4840 </li>
max@0 4841 <br>
max@0 4842 <li>
max@0 4843 Examples:
max@0 4844 <ul>
max@0 4845 <pre>
max@0 4846 vec v = ones&lt;vec&gt;(10);
max@0 4847 mat A = ones&lt;mat&gt;(5,6);
max@0 4848 cube Q = ones&lt;cube&gt;(5,6,7);
max@0 4849
max@0 4850 mat B = 123.0 * ones&lt;mat&gt;(5,6);
max@0 4851 </pre>
max@0 4852 </ul>
max@0 4853 </li>
max@0 4854 <br>
max@0 4855 <li>
max@0 4856 See also:
max@0 4857 <ul>
max@0 4858 <li><a href="#ones_member">.ones()</a> (member function of <i>Mat</i>, <i>Col</i>, <i>Row</i> and <i>Cube</i>)</li>
max@0 4859 <li><a href="#eye_standalone">eye()</a></li>
max@0 4860 </ul>
max@0 4861 </li>
max@0 4862 </ul>
max@0 4863 <br>
max@0 4864 <hr class="greyline"><br>
max@0 4865
max@0 4866 <a name="randu_randn_standalone"></a>
max@0 4867 <b>randu(n_elem)</b>
max@0 4868 <br><b>randu(n_rows, n_cols)</b>
max@0 4869 <br><b>randu(n_rows, n_cols, n_slices)</b>
max@0 4870 <br>
max@0 4871 <br><b>randn(n_elem)</b>
max@0 4872 <br><b>randn(n_rows, n_cols)</b>
max@0 4873 <br><b>randn(n_rows, n_cols, n_slices)</b>
max@0 4874 <ul>
max@0 4875 <li>
max@0 4876 Generate a vector, matrix or cube with the elements set to random values
max@0 4877 </li>
max@0 4878 <br>
max@0 4879 <li><i>randu()</i> uses a uniform distribution in the [0,1] interval
max@0 4880 </li>
max@0 4881 <br>
max@0 4882 <li><i>randn()</i> uses a normal/Gaussian distribution with zero mean and unit variance
max@0 4883 </li>
max@0 4884 <br>
max@0 4885 <li>
max@0 4886 Usage:
max@0 4887 <ul>
max@0 4888 <li><i>vector_type</i> v = randu&lt;<i>vector_type</i>&gt;(n_elem)</li>
max@0 4889 <li><i>matrix_type</i> X = randu&lt;<i>matrix_type</i>&gt;(n_rows, n_cols)</li>
max@0 4890 <li><i>cube_type</i> Q = randu&lt;<i>cube_type</i>&gt;(n_rows, n_cols, n_slices)</li>
max@0 4891 </ul>
max@0 4892 </li>
max@0 4893 <br>
max@0 4894 <li>
max@0 4895 To change the seed, use the <a href="http://cplusplus.com/reference/clibrary/cstdlib/srand/">std::srand()</a> function.
max@0 4896 </li>
max@0 4897 <br>
max@0 4898 <li>
max@0 4899 Examples:
max@0 4900 <ul>
max@0 4901 <pre>
max@0 4902 vec v = randu&lt;vec&gt;(5);
max@0 4903 mat A = randu&lt;mat&gt;(5,6);
max@0 4904 cube Q = randu&lt;cube&gt;(5,6,7);
max@0 4905 </pre>
max@0 4906 </ul>
max@0 4907 </li>
max@0 4908 <li>See also:
max@0 4909 <ul>
max@0 4910 <li><a href="#randu_randn_member">.randu() &amp; .randn()</a> (member functions)</li>
max@0 4911 <li><a href="#ones_standalone">ones()</a></li>
max@0 4912 <li><a href="#zeros_standalone">zeros()</a></li>
max@0 4913 <li><a href="#shuffle">shuffle()</a></li>
max@0 4914 <li><a href="http://cplusplus.com/reference/clibrary/cstdlib/srand/">std::srand()</a></li>
max@0 4915 <li><a href="#api_changes">API changes</a></li>
max@0 4916 </ul>
max@0 4917 </li>
max@0 4918 <br>
max@0 4919 </ul>
max@0 4920 <hr class="greyline"><br>
max@0 4921
max@0 4922 <a name="repmat"></a>
max@0 4923 <b>repmat(A, num_copies_per_row, num_copies_per_col)</b>
max@0 4924 <ul>
max@0 4925 <li>Generate a matrix by replicating matrix A in a block-like fashion</li>
max@0 4926 <br>
max@0 4927 <li>The generated matrix has the following size:
max@0 4928 <ul>
max@0 4929 rows = num_copies_per_row * A.n_rows
max@0 4930 <br>
max@0 4931 cols = num_copies_per_col * A.n_cols
max@0 4932 </ul>
max@0 4933 </li>
max@0 4934 <br>
max@0 4935 <li>
max@0 4936 Examples:
max@0 4937 <ul>
max@0 4938 <pre>
max@0 4939 mat A = randu&lt;mat&gt;(2, 3);
max@0 4940
max@0 4941 mat B = repmat(A, 4, 5);
max@0 4942 </pre>
max@0 4943 </ul>
max@0 4944 </li>
max@0 4945 <br>
max@0 4946 </ul>
max@0 4947 <hr class="greyline">
max@0 4948 <br>
max@0 4949
max@0 4950 <a name="toeplitz"></a>
max@0 4951 <b>toeplitz(A)</b>
max@0 4952 <br><b>toeplitz(A,B)</b>
max@0 4953 <br><b>circ_toeplitz(A)</b>
max@0 4954 <ul>
max@0 4955 <li>
max@0 4956 toeplitz(): generate a Toeplitz matrix, with the first column specified by <i>A</i>, and (optionally) the first row specified by <i>B</i>
max@0 4957 </li>
max@0 4958 <br>
max@0 4959 <li>
max@0 4960 circ_toeplitz(): generate a circulant Toeplitz matrix
max@0 4961 </li>
max@0 4962 <br>
max@0 4963 <li>
max@0 4964 A and B must be vectors
max@0 4965 </li>
max@0 4966 <br>
max@0 4967 <li>
max@0 4968 Examples:
max@0 4969 <ul>
max@0 4970 <pre>
max@0 4971 vec A = randu&lt;vec&gt;(5);
max@0 4972 mat X = toeplitz(A);
max@0 4973 mat Y = circ_toeplitz(A);
max@0 4974 </pre>
max@0 4975 </ul>
max@0 4976 </li>
max@0 4977 <br>
max@0 4978 <li>See also:
max@0 4979 <ul>
max@0 4980 <li><a href="http://mathworld.wolfram.com/ToeplitzMatrix.html">Toeplitz matrix in MathWorld</a></li>
max@0 4981 <li><a href="http://en.wikipedia.org/wiki/Toeplitz_matrix">Toeplitz matrix in Wikipedia</a></li>
max@0 4982 <li><a href="http://en.wikipedia.org/wiki/Circulant_matrix">Circulant matrix in Wikipedia</a></li>
max@0 4983 </ul>
max@0 4984 </li>
max@0 4985 <br>
max@0 4986 </ul>
max@0 4987 <hr class="greyline">
max@0 4988 <br>
max@0 4989
max@0 4990 <a name="zeros_standalone"></a>
max@0 4991 <b>zeros(n_elem)</b>
max@0 4992 <br><b>zeros(n_rows, n_cols)</b>
max@0 4993 <br><b>zeros(n_rows, n_cols, n_slices)</b>
max@0 4994 <ul>
max@0 4995 <li>
max@0 4996 Generate a vector, matrix or cube with the elements set to zero
max@0 4997 </li>
max@0 4998 <br>
max@0 4999 <li>
max@0 5000 Usage:
max@0 5001 <ul>
max@0 5002 <li><i>vector_type</i> v = zeros&lt;<i>vector_type</i>&gt;(n_elem)</li>
max@0 5003 <li><i>matrix_type</i> X = zeros&lt;<i>matrix_type</i>&gt;(n_rows, n_cols)</li>
max@0 5004 <li><i>cube_type</i> X = zeros&lt;<i>cube_type</i>&gt;(n_rows, n_cols, n_slices)</li>
max@0 5005 </ul>
max@0 5006 </li>
max@0 5007 <br>
max@0 5008 <li>
max@0 5009 Examples:
max@0 5010 <ul>
max@0 5011 <pre>
max@0 5012 vec v = zeros&lt;vec&gt;(5);
max@0 5013 mat A = zeros&lt;mat&gt;(5,6);
max@0 5014 cube Q = zeros&lt;cube&gt;(5,6,7);
max@0 5015 </pre>
max@0 5016 </ul>
max@0 5017 </li>
max@0 5018 <br>
max@0 5019 <li>
max@0 5020 See also:
max@0 5021 <ul>
max@0 5022 <li><a href="#zeros_member">.zeros()</a> (member function of <i>Mat</i>, <i>Col</i>, <i>Row</i> and <i>Cube</i>)</li>
max@0 5023 <li><a href="#ones_member">.ones()</a> (member function of <i>Mat</i>, <i>Col</i>, <i>Row</i> and <i>Cube</i>)</li>
max@0 5024 <li><a href="#ones_standalone">ones()</a></li>
max@0 5025 </ul>
max@0 5026 </li>
max@0 5027 </ul>
max@0 5028 <br>
max@0 5029 <hr class="greyline">
max@0 5030
max@0 5031 <hr class="greyline">
max@0 5032 <br>
max@0 5033 <br>
max@0 5034 <font size=+1><b>Functions Individually Applied to Each Element of a Matrix/Cube</b></font>
max@0 5035 <br>
max@0 5036 <br>
max@0 5037 <hr class="greyline">
max@0 5038 <br>
max@0 5039
max@0 5040 <a name="abs"></a>
max@0 5041 <b>abs(mat)</b>
max@0 5042 <br><b>abs(cube)</b>
max@0 5043 <br><b>abs(cx_mat)</b>
max@0 5044 <br><b>abs(cx_cube)</b>
max@0 5045 <ul>
max@0 5046 <li>
max@0 5047 Obtain the magnitude of each element
max@0 5048 </li>
max@0 5049 <br>
max@0 5050 <li>
max@0 5051 Usage for non-complex matrices:
max@0 5052 <ul>
max@0 5053 <li><i>matrix_type</i> Y = abs(X)</li>
max@0 5054 <li>X and Y must have the same <i>matrix_type</i></li>
max@0 5055 </ul>
max@0 5056 </li>
max@0 5057 <br>
max@0 5058 <li>
max@0 5059 Usage for non-complex cubes:
max@0 5060 <ul>
max@0 5061 <li><i>cube_type</i> Y = abs(X)</li>
max@0 5062 <li>X and Y must have the same <i>cube_type</i></li>
max@0 5063 </ul>
max@0 5064 </li>
max@0 5065 <br>
max@0 5066 <li>
max@0 5067 Usage for complex matrices:
max@0 5068 <ul>
max@0 5069 <li><i>non_complex_matrix_type</i> Y = abs(X)</li>
max@0 5070 <li>X must be a have complex matrix type, eg., <i>cx_mat</i> or <i>cx_fmat</i></li>
max@0 5071 <li>The type of Y must be related to the type of X,
max@0 5072 eg., if X has the type <i>cx_mat</i>, then the type of Y must be <i>mat</i>
max@0 5073 </ul>
max@0 5074 </li>
max@0 5075 <br>
max@0 5076 <li>
max@0 5077 Usage for complex cubes:
max@0 5078 <ul>
max@0 5079 <li><i>non_complex_cube_type</i> Y = abs(X)</li>
max@0 5080 <li>X must be a have complex cube type, eg., <i>cx_cube</i> or <i>cx_fcube</i></li>
max@0 5081 <li>The type of Y must be related to the type of X,
max@0 5082 eg., if X has the type <i>cx_cube</i>, then the type of Y must be <i>cube</i>
max@0 5083 </ul>
max@0 5084 </li>
max@0 5085 <br>
max@0 5086 <li>
max@0 5087 Examples:
max@0 5088 <ul>
max@0 5089 <pre>
max@0 5090 mat A = randu&lt;mat&gt;(5,5);
max@0 5091 mat B = abs(A);
max@0 5092
max@0 5093 cx_mat X = randu&lt;cx_mat&gt;(5,5);
max@0 5094 mat Y = abs(X);
max@0 5095 </pre>
max@0 5096 </ul>
max@0 5097 </li>
max@0 5098 </ul>
max@0 5099 <br>
max@0 5100 <hr class="greyline"><br>
max@0 5101
max@0 5102 <a name="eps"></a>
max@0 5103 <b>eps(X)</b>
max@0 5104 <ul>
max@0 5105 <li>
max@0 5106 Obtain the positive distance of the absolute value of each element of <i>X</i> to the next largest representable floating point number
max@0 5107 </li>
max@0 5108 <br>
max@0 5109 <li>
max@0 5110 <i>X</i> can be a scalar (eg. <i>double</i>), vector or matrix
max@0 5111 </li>
max@0 5112 <br>
max@0 5113 <li>
max@0 5114 Examples:
max@0 5115 <ul>
max@0 5116 <pre>
max@0 5117 mat A = randu&lt;mat&gt;(4,5);
max@0 5118 mat B = eps(A);
max@0 5119 </pre>
max@0 5120 </ul>
max@0 5121 </li>
max@0 5122 <br>
max@0 5123 <li>
max@0 5124 See also:
max@0 5125 <ul>
max@0 5126 <li><a href="#math_constants">math::eps()</a></li>
max@0 5127 <li><a href="http://mathworld.wolfram.com/Floating-PointArithmetic.html">Floating-Point Arithmetic in MathWorld</a></li>
max@0 5128 <li><a href="http://en.wikipedia.org/wiki/IEEE_754-2008">IEEE Standard for Floating-Point Arithmetic in Wikipedia</a></li>
max@0 5129
max@0 5130 </ul>
max@0 5131 </li>
max@0 5132 </ul>
max@0 5133 <br>
max@0 5134 <hr class="greyline"><br>
max@0 5135
max@0 5136 <a name="misc_fns"></a>
max@0 5137 <b>
max@0 5138 miscellaneous functions:
max@0 5139 <br>&nbsp; exp, exp2, exp10, trunc_exp,
max@0 5140 <br>&nbsp; log, log2, log10, trunc_log,
max@0 5141 <br>&nbsp; pow, sqrt, square
max@0 5142 <br>&nbsp; floor, ceil
max@0 5143 </b>
max@0 5144 <br>
max@0 5145 <ul>
max@0 5146 <li>
max@0 5147 Apply a function to each element
max@0 5148 </li>
max@0 5149 <br>
max@0 5150 <li>
max@0 5151 Usage:
max@0 5152 <ul>
max@0 5153 <li>
max@0 5154 <i>matrix_type</i> B = misc_fn(A)
max@0 5155 </li>
max@0 5156 <li>
max@0 5157 <i>cube_type</i> B = misc_fn(A)
max@0 5158 </li>
max@0 5159 <li>
max@0 5160 A and B must have the same <i>matrix_type/cube_type</i>
max@0 5161 </li>
max@0 5162 <li>
max@0 5163 misc_fn(A) is one of:
max@0 5164 <ul>
max@0 5165
max@0 5166 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 5167 <tbody>
max@0 5168 <tr>
max@0 5169 <td style="vertical-align: top;">
max@0 5170 exp(A)<sup>&nbsp;</sup>
max@0 5171 </td>
max@0 5172 <td style="vertical-align: top;">
max@0 5173 &nbsp;
max@0 5174 </td>
max@0 5175 <td style="vertical-align: top;">
max@0 5176 base-e exponential, <i>e<sup>x</sup></i>
max@0 5177 </td>
max@0 5178 </tr>
max@0 5179 <tr>
max@0 5180 <td style="vertical-align: top;">
max@0 5181 exp2(A)<sup>&nbsp;</sup>
max@0 5182 </td>
max@0 5183 <td style="vertical-align: top;">
max@0 5184 &nbsp;
max@0 5185 </td>
max@0 5186 <td style="vertical-align: top;">
max@0 5187 base-2 exponential, <i>2<sup>x</sup></i>
max@0 5188 </td>
max@0 5189 </tr>
max@0 5190 <tr>
max@0 5191 <td style="vertical-align: top;">
max@0 5192 exp10(A)<sup>&nbsp;</sup>
max@0 5193 </td>
max@0 5194 <td style="vertical-align: top;">
max@0 5195 &nbsp;
max@0 5196 </td>
max@0 5197 <td style="vertical-align: top;">
max@0 5198 base-10 exponential, <i>10<sup>x</sup></i>
max@0 5199 </td>
max@0 5200 </tr>
max@0 5201 <tr>
max@0 5202 <td style="vertical-align: top;">
max@0 5203 trunc_exp(A)
max@0 5204 </td>
max@0 5205 <td style="vertical-align: top;">
max@0 5206 &nbsp;
max@0 5207 </td>
max@0 5208 <td style="vertical-align: top;">
max@0 5209 base-e exponential,
max@0 5210 truncated to avoid infinity
max@0 5211 <br>
max@0 5212 <font size=-1>(only for elements with type <i>float</i> or <i>double</i>)</font>
max@0 5213 </td>
max@0 5214 </tr>
max@0 5215 <tr>
max@0 5216 <td style="vertical-align: top;">
max@0 5217 log(A)<sub>&nbsp;</sub>
max@0 5218 </td>
max@0 5219 <td style="vertical-align: top;">
max@0 5220 &nbsp;
max@0 5221 </td>
max@0 5222 <td style="vertical-align: top;">
max@0 5223 natural log, <i>log<sub>e</sub>&nbsp;x</i>
max@0 5224 </td>
max@0 5225 </tr>
max@0 5226 <tr>
max@0 5227 <td style="vertical-align: top;">
max@0 5228 log2(A)<sub>&nbsp;</sub>
max@0 5229 </td>
max@0 5230 <td style="vertical-align: top;">
max@0 5231 &nbsp;
max@0 5232 </td>
max@0 5233 <td style="vertical-align: top;">
max@0 5234 base-2 log, <i>log<sub>2</sub>&nbsp;x</i>
max@0 5235 </td>
max@0 5236 </tr>
max@0 5237 <tr>
max@0 5238 <td style="vertical-align: top;">
max@0 5239 log10(A)<sub>&nbsp;</sub>
max@0 5240 </td>
max@0 5241 <td style="vertical-align: top;">
max@0 5242 &nbsp;
max@0 5243 </td>
max@0 5244 <td style="vertical-align: top;">
max@0 5245 base-10 log, <i>log<sub>10</sub>&nbsp;x</i>
max@0 5246 </td>
max@0 5247 </tr>
max@0 5248 <tr>
max@0 5249 <td style="vertical-align: top;">
max@0 5250 trunc_log(A)
max@0 5251 </td>
max@0 5252 <td style="vertical-align: top;">
max@0 5253 &nbsp;
max@0 5254 </td>
max@0 5255 <td style="vertical-align: top;">
max@0 5256 natural log,
max@0 5257 truncated to avoid &plusmn;infinity
max@0 5258 <br>
max@0 5259 <font size=-1>(only for elements with type <i>float</i> or <i>double</i>)</font>
max@0 5260 </td>
max@0 5261 </tr>
max@0 5262 <tr>
max@0 5263 <td style="vertical-align: top;">
max@0 5264 pow(A, p)<sup>&nbsp;</sup>
max@0 5265 </td>
max@0 5266 <td style="vertical-align: top;">
max@0 5267 &nbsp;
max@0 5268 </td>
max@0 5269 <td style="vertical-align: top;">
max@0 5270 raise to the power of p, <i>x<sup>p</sup></i>
max@0 5271 </td>
max@0 5272 </tr>
max@0 5273 <tr>
max@0 5274 <td style="vertical-align: top;">
max@0 5275 sqrt(A)<sup>&nbsp;</sup>
max@0 5276 </td>
max@0 5277 <td style="vertical-align: top;">
max@0 5278 &nbsp;
max@0 5279 </td>
max@0 5280 <td style="vertical-align: top;">
max@0 5281 square root, <i>x<sup>&frac12;</sup></i>
max@0 5282 </td>
max@0 5283 </tr>
max@0 5284 <tr>
max@0 5285 <td style="vertical-align: top;">
max@0 5286 square(A)<sup>&nbsp;</sup>
max@0 5287 </td>
max@0 5288 <td style="vertical-align: top;">
max@0 5289 &nbsp;
max@0 5290 </td>
max@0 5291 <td style="vertical-align: top;">
max@0 5292 square, <i>x<sup>2</sup></i>
max@0 5293 </td>
max@0 5294 </tr>
max@0 5295 <tr>
max@0 5296 <td style="vertical-align: top;">
max@0 5297 floor(A)
max@0 5298 </td>
max@0 5299 <td style="vertical-align: top;">
max@0 5300 &nbsp;
max@0 5301 </td>
max@0 5302 <td style="vertical-align: top;">
max@0 5303 largest integral value that is not greater than the input value
max@0 5304 </td>
max@0 5305 </tr>
max@0 5306 <tr>
max@0 5307 <td style="vertical-align: top;">
max@0 5308 ceil(A)
max@0 5309 </td>
max@0 5310 <td style="vertical-align: top;">
max@0 5311 &nbsp;
max@0 5312 </td>
max@0 5313 <td style="vertical-align: top;">
max@0 5314 smallest integral value that is not less than the input value
max@0 5315 </td>
max@0 5316 </tr>
max@0 5317 </tbody>
max@0 5318 </table>
max@0 5319
max@0 5320
max@0 5321 </ul>
max@0 5322 </li>
max@0 5323
max@0 5324 </ul>
max@0 5325 </li>
max@0 5326 <br>
max@0 5327 <li>
max@0 5328 Examples:
max@0 5329 <ul>
max@0 5330 <pre>
max@0 5331 mat A = randu&lt;mat&gt;(5,5);
max@0 5332 mat B = exp(A);
max@0 5333 </pre>
max@0 5334 </ul>
max@0 5335 </li>
max@0 5336 </ul>
max@0 5337 <br>
max@0 5338 <hr class="greyline"><br>
max@0 5339
max@0 5340 <a name="trig_fns"></a>
max@0 5341 <b>trigonometric functions (cos, sin, tan, ...)</b>
max@0 5342 <ul>
max@0 5343 <li>
max@0 5344 Apply a trigonometric function to each element
max@0 5345 </li>
max@0 5346 <br>
max@0 5347 <li>
max@0 5348 Usage:
max@0 5349 <ul>
max@0 5350 <li>
max@0 5351 <i>matrix_type</i> Y = trig_fn(X)
max@0 5352 </li>
max@0 5353 <li>
max@0 5354 <i>cube_type</i> Y = trig_fn(X)
max@0 5355 </li>
max@0 5356 <li>
max@0 5357 X and Y must have the same <i>matrix_type/cube_type</i>
max@0 5358 </li>
max@0 5359 <li>
max@0 5360 trig_fn is one of:
max@0 5361 <ul>
max@0 5362 <li>
max@0 5363 cos family: <i>cos</i>, <i>acos</i>, <i>cosh</i>, <i>acosh</i>
max@0 5364 </li>
max@0 5365 <li>
max@0 5366 sin family: <i>sin</i>, <i>asin</i>, <i>sinh</i>, <i>asinh</i>
max@0 5367 </li>
max@0 5368 <li>
max@0 5369 tan family: <i>tan</i>, <i>atan</i>, <i>tanh</i>, <i>atanh</i>
max@0 5370 </li>
max@0 5371 </ul>
max@0 5372 </li>
max@0 5373
max@0 5374 </ul>
max@0 5375 </li>
max@0 5376 <br>
max@0 5377 <li>
max@0 5378 Examples:
max@0 5379 <ul>
max@0 5380 <pre>
max@0 5381 mat X = randu&lt;mat&gt;(5,5);
max@0 5382 mat Y = cos(X);
max@0 5383 </pre>
max@0 5384 </ul>
max@0 5385 </li>
max@0 5386 </ul>
max@0 5387 <br>
max@0 5388 <hr class="greyline">
max@0 5389
max@0 5390 <hr class="greyline">
max@0 5391 <br>
max@0 5392 <br>
max@0 5393 <font size=+1><b>Scalar Valued Functions of Vectors/Matrices/Cubes</b></font>
max@0 5394 <br>
max@0 5395 <br>
max@0 5396 <hr class="greyline">
max@0 5397 <br>
max@0 5398
max@0 5399 <a name="accu"></a>
max@0 5400 <b>accu(mat)</b>
max@0 5401 <br><b>accu(cube)</b>
max@0 5402 <ul>
max@0 5403 <li>
max@0 5404 Accumulate (sum) all elements
max@0 5405 </li>
max@0 5406 <br>
max@0 5407 <li>
max@0 5408 Examples:
max@0 5409 <ul>
max@0 5410 <pre>
max@0 5411 mat A = randu&lt;mat&gt;(5,5);
max@0 5412 double x = accu(A);
max@0 5413
max@0 5414 mat B = randu&lt;mat&gt;(5,5);
max@0 5415 double y = accu(A % B);
max@0 5416
max@0 5417 // operator % performs element-wise multiplication,
max@0 5418 // hence accu(A % B) is a "multiply-and-accumulate"
max@0 5419 // operation
max@0 5420 </pre>
max@0 5421 </ul>
max@0 5422 </li>
max@0 5423 <br>
max@0 5424 <li>
max@0 5425 See also:
max@0 5426 <ul>
max@0 5427 <li><a href="#sum">sum()</a></li>
max@0 5428 <li><a href="#cumsum">cumsum()</a></li>
max@0 5429 <li><a href="#as_scalar">as_scalar()</a></li>
max@0 5430 </ul>
max@0 5431 </li>
max@0 5432 <br>
max@0 5433 </ul>
max@0 5434 <hr class="greyline"><br>
max@0 5435
max@0 5436 <a name="as_scalar"></a>
max@0 5437 <b>as_scalar(expression)</b>
max@0 5438 <ul>
max@0 5439 <li>
max@0 5440 Evaluate an expression that results in a 1x1 matrix,
max@0 5441 followed by converting the 1x1 matrix to a pure scalar
max@0 5442 </li>
max@0 5443 <br>
max@0 5444 <li>
max@0 5445 If a binary or trinary expression is given (ie. 2 or 3 terms),
max@0 5446 the function will try to exploit the fact that the result is a 1x1 matrix
max@0 5447 by using optimised expression evaluations
max@0 5448 </li>
max@0 5449 <br>
max@0 5450 <li>
max@0 5451 Examples:
max@0 5452 <ul>
max@0 5453 <pre>
max@0 5454 rowvec r = randu&lt;rowvec&gt;(5);
max@0 5455 colvec q = randu&lt;colvec&gt;(5);
max@0 5456 mat X = randu&lt;mat&gt;(5,5);
max@0 5457
max@0 5458 // examples of some expressions
max@0 5459 // for which optimised implementations exist
max@0 5460
max@0 5461 double a = as_scalar(r*q);
max@0 5462 double b = as_scalar(r*X*q);
max@0 5463 double c = as_scalar(r*diagmat(X)*q);
max@0 5464 double d = as_scalar(r*inv(diagmat(X))*q);
max@0 5465 </pre>
max@0 5466 </ul>
max@0 5467 </li>
max@0 5468 <br>
max@0 5469 <li>
max@0 5470 See also:
max@0 5471 <ul>
max@0 5472 <li><a href="#accu">accu()</a></li>
max@0 5473 <li><a href="#conv_to">conv_to()</a></li>
max@0 5474 <li><a href="#dot">dot()</a></li>
max@0 5475 <li><a href="#norm">norm()</a></li>
max@0 5476 <li><a href="#reshape">reshape()</a></li>
max@0 5477 <li><a href="#resize">resize()</a></li>
max@0 5478 </ul>
max@0 5479 </li>
max@0 5480 <br>
max@0 5481 </ul>
max@0 5482 <hr class="greyline"><br>
max@0 5483
max@0 5484 <a name="det"></a>
max@0 5485 <b>det(A, slow = <i>false</i>)</b>
max@0 5486 <ul>
max@0 5487 <li>
max@0 5488 Determinant of square matrix <i>A</i>
max@0 5489 </li>
max@0 5490 <br>
max@0 5491 <li>
max@0 5492 If <i>A</i> is not square, a <i>std::logic_error</i> exception is thrown
max@0 5493 </li>
max@0 5494 <br>
max@0 5495 <li>
max@0 5496 <b>Caveat</b>: for large matrices you may want to use <a href="#log_det">log_det()</a> instead
max@0 5497 </li>
max@0 5498 <br>
max@0 5499 <li>
max@0 5500 For matrix sizes &le; 4x4, a fast algorithm is used by default.
max@0 5501 In rare instances, the fast algorithm might be less precise than the standard algorithm.
max@0 5502 To force the use of the standard algorithm, set the <i>slow</i> argument to <i>true</i>
max@0 5503 </li>
max@0 5504 <br>
max@0 5505 <li>
max@0 5506 Examples:
max@0 5507 <ul>
max@0 5508 <pre>
max@0 5509 mat A = randu&lt;mat&gt;(5,5);
max@0 5510 double x = det(A);
max@0 5511
max@0 5512 mat44 B = randu&lt;mat&gt;(4,4);
max@0 5513
max@0 5514 double y = det(B); // use fast algorithm by default
max@0 5515 double z = det(B, true); // use slow algorithm
max@0 5516 </pre>
max@0 5517 </ul>
max@0 5518 </li>
max@0 5519 <br>
max@0 5520 <li>
max@0 5521 See also:
max@0 5522 <ul>
max@0 5523 <li><a href="#log_det">log_det()</a></li>
max@0 5524 <li><a href="http://mathworld.wolfram.com/Determinant.html">determinant in MathWorld</a></li>
max@0 5525 <li><a href="http://en.wikipedia.org/wiki/Determinant">determinant in Wikipedia</a></li>
max@0 5526 </ul>
max@0 5527 </li>
max@0 5528 <br>
max@0 5529 </ul>
max@0 5530 <hr class="greyline"><br>
max@0 5531
max@0 5532 <a name="dot"></a>
max@0 5533 <b>dot(A, B)</b>
max@0 5534 <br><b>cdot(A, B)</b>
max@0 5535 <br><b>norm_dot(A, B)</b>
max@0 5536 <ul>
max@0 5537 <li>
max@0 5538 <i>dot(A,B)</i>: dot product of A and B, under the assumption that A and B are vectors with the same number of elements
max@0 5539 </li>
max@0 5540 <br>
max@0 5541 <li>
max@0 5542 <i>cdot(A,B)</i>: as per <i>dot(A,B)</i>, but the complex conjugate of A is used
max@0 5543 </li>
max@0 5544 <br>
max@0 5545 <li>
max@0 5546 <i>norm_dot(A,B)</i>: normalised version of <i>dot(A,B)</i>
max@0 5547 </li>
max@0 5548 <br>
max@0 5549 <li>
max@0 5550 Examples:
max@0 5551 <ul>
max@0 5552 <pre>
max@0 5553 vec a = randu&lt;vec&gt;(10);
max@0 5554 vec b = randu&lt;vec&gt;(10);
max@0 5555
max@0 5556 double x = dot(a,b);
max@0 5557 </pre>
max@0 5558 </ul>
max@0 5559 </li>
max@0 5560 <br>
max@0 5561 <li>See also:
max@0 5562 <ul>
max@0 5563 <li><a href="#as_scalar">as_scalar()</a></li>
max@0 5564 <li><a href="#cross">cross()</a></li>
max@0 5565 <li><a href="#conj">conj()</a></li>
max@0 5566 <li><a href="#norm">norm()</a></li>
max@0 5567 </ul>
max@0 5568 </li>
max@0 5569 <br>
max@0 5570 </ul>
max@0 5571 <hr class="greyline"><br>
max@0 5572
max@0 5573 <a name="log_det"></a>
max@0 5574 <b>log_det(val, sign, A)</b>
max@0 5575 <ul>
max@0 5576 <li>
max@0 5577 Log determinant of square matrix <i>A</i>, such that the determinant is equal to <i>exp(val)*sign</i>
max@0 5578 </li>
max@0 5579 <br>
max@0 5580 <li>
max@0 5581 If <i>A</i> is not square, a <i>std::logic_error</i> exception is thrown
max@0 5582 </li>
max@0 5583 <br>
max@0 5584 <li>
max@0 5585 Examples:
max@0 5586 <ul>
max@0 5587 <pre>
max@0 5588 mat A = randu&lt;mat&gt;(5,5);
max@0 5589
max@0 5590 double val;
max@0 5591 double sign;
max@0 5592
max@0 5593 log_det(val, sign, A);
max@0 5594 </pre>
max@0 5595 </ul>
max@0 5596 </li>
max@0 5597 <br>
max@0 5598 <li>
max@0 5599 See also:
max@0 5600 <ul>
max@0 5601 <li><a href="#det">det()</a></li>
max@0 5602 <li><a href="http://mathworld.wolfram.com/Determinant.html">determinant in MathWorld</a></li>
max@0 5603 <li><a href="http://en.wikipedia.org/wiki/Determinant">determinant in Wikipedia</a></li>
max@0 5604 </ul>
max@0 5605 </li>
max@0 5606 <br>
max@0 5607 </ul>
max@0 5608 <hr class="greyline"><br>
max@0 5609
max@0 5610 <a name="norm"></a>
max@0 5611 <b>
max@0 5612 norm(X, p)
max@0 5613 </b>
max@0 5614 <ul>
max@0 5615 <li>
max@0 5616 Compute the <i>p</i>-norm of <i>X</i>, where <i>X</i> can be a vector or a matrix
max@0 5617 </li>
max@0 5618 <br>
max@0 5619 <li>
max@0 5620 For vectors, <i>p</i> is an integer &ge;1, or one of: "-inf", "inf", "fro"
max@0 5621 </li>
max@0 5622 <br>
max@0 5623 <li>
max@0 5624 For matrices, <i>p</i> is one of: 1, 2, "inf", "fro"
max@0 5625 </li>
max@0 5626 <br>
max@0 5627 <li>
max@0 5628 "-inf" is the minimum norm, "inf" is the maximum norm, while "fro" is the Frobenius norm
max@0 5629 </li>
max@0 5630 <br>
max@0 5631 <li>
max@0 5632 To obtain the zero norm or Hamming norm (ie. the number of non-zero elements),
max@0 5633 you may want to use this expression: <a href="#accu">accu</a>(X&nbsp;!=&nbsp;0).
max@0 5634 </li>
max@0 5635 <br>
max@0 5636 <li>
max@0 5637 Examples:
max@0 5638 <ul>
max@0 5639 <pre>
max@0 5640 vec q = randu&lt;vec&gt;(5);
max@0 5641 double x = norm(q, 2);
max@0 5642 double y = norm(q, "inf");
max@0 5643 </pre>
max@0 5644 </ul>
max@0 5645 </li>
max@0 5646 <br>
max@0 5647 <li>
max@0 5648 See also:
max@0 5649 <ul>
max@0 5650 <li><a href="#dot">dot()</a></li>
max@0 5651 <li><a href="http://en.wikipedia.org/wiki/Norm_(mathematics)">Vector Norm in Wikipedia</a></li>
max@0 5652 <li><a href="http://mathworld.wolfram.com/VectorNorm.html">Vector Norm in MathWorld</a></li>
max@0 5653 <li><a href="http://en.wikipedia.org/wiki/Matrix_norm">Matrix Norm in Wikipedia</a></li>
max@0 5654 <li><a href="http://mathworld.wolfram.com/MatrixNorm.html">Matrix Norm in MathWorld</a></li>
max@0 5655 </ul>
max@0 5656 </li>
max@0 5657 <br>
max@0 5658 </ul>
max@0 5659 <hr class="greyline"><br>
max@0 5660
max@0 5661 <a name="rank"></a>
max@0 5662 <b>rank(X, tolerance = default)</b>
max@0 5663
max@0 5664 <ul>
max@0 5665 <li>Returns the rank of matrix <i>X</i></li><br>
max@0 5666 <li>Any singular values less than default tolerance are treated as zero</li><br>
max@0 5667 <li>The default tolerance is <i>max(X.n_rows, X.n_cols)*eps(sigma)</i>,
max@0 5668 where <i>sigma</i> is the largest singular value of <i>X</i>
max@0 5669 </li><br>
max@0 5670 <li>The computation is based on singular value decomposition;
max@0 5671 if the decomposition fails, a <i>std::runtime_error</i> exception is thrown</li><br>
max@0 5672 <li>
max@0 5673 Examples:
max@0 5674 <ul>
max@0 5675 <pre>
max@0 5676 mat A = randu&lt;mat&gt;(4,5);
max@0 5677 uword r = rank(A);
max@0 5678 </pre>
max@0 5679 </ul>
max@0 5680 </li>
max@0 5681 <br>
max@0 5682 <li>
max@0 5683 See also:
max@0 5684 <ul>
max@0 5685 <li><a href="#eps">eps()</a></li>
max@0 5686 <li><a href="http://mathworld.wolfram.com/MatrixRank.html">Rank in MathWorld</a></li>
max@0 5687 <li><a href="http://en.wikipedia.org/wiki/Rank_(linear_algebra)">Rank in Wikipedia</a></li>
max@0 5688 </ul>
max@0 5689 </li>
max@0 5690 </ul>
max@0 5691 <br>
max@0 5692 <hr class="greyline"><br>
max@0 5693
max@0 5694 <a name="trace"></a>
max@0 5695 <b>trace(mat)</b>
max@0 5696 <ul>
max@0 5697 <li>
max@0 5698 Sum of the diagonal elements of a square matrix
max@0 5699 </li>
max@0 5700 <br>
max@0 5701 <li>
max@0 5702 A <i>std::logic_error</i> exception is thrown if the given matrix is not square
max@0 5703 </li>
max@0 5704 <br>
max@0 5705 <li>
max@0 5706 Examples:
max@0 5707 <ul>
max@0 5708 <pre>
max@0 5709 mat A = randu&lt;mat&gt;(5,5);
max@0 5710 double x = trace(A);
max@0 5711 </pre>
max@0 5712 </ul>
max@0 5713 </li>
max@0 5714 <br>
max@0 5715 <li>
max@0 5716 See also:
max@0 5717 <ul>
max@0 5718 <li><a href="#diag">.diag()</a></li>
max@0 5719 <li><a href="#diagvec">diagvec()</a></li>
max@0 5720 <li><a href="#sum">sum()</a></li>
max@0 5721 </ul>
max@0 5722 </li>
max@0 5723 <br>
max@0 5724 </ul>
max@0 5725 <hr class="greyline">
max@0 5726
max@0 5727 <hr class="greyline">
max@0 5728 <br>
max@0 5729 <br>
max@0 5730 <font size=+1><b>Scalar/Vector Valued Functions of Vectors/Matrices</b></font>
max@0 5731 <br>
max@0 5732 <br>
max@0 5733 <hr class="greyline">
max@0 5734 <br>
max@0 5735
max@0 5736 <a name="diagvec"></a>
max@0 5737 <b>diagvec(A, k=0)</b>
max@0 5738 <ul>
max@0 5739 <li>
max@0 5740 Extract the <i>k</i>-th diagonal from matrix <i>A</i>
max@0 5741 </li>
max@0 5742 <br>
max@0 5743 <li>
max@0 5744 The argument <i>k</i> is optional -- by default the main diagonal is extracted (<i>k=0</i>)
max@0 5745 </li>
max@0 5746 <br>
max@0 5747 <li>For <i>k &gt; 0</i>, the <i>k</i>-th super-diagonal is extracted (top-right corner)</li>
max@0 5748 <br>
max@0 5749 <li>For <i>k &lt; 0</i>, the <i>k</i>-th sub-diagonal is extracted (bottom-left corner)</li>
max@0 5750 <br>
max@0 5751 <li>
max@0 5752 An extracted a diagonal is interpreted as a column vector
max@0 5753 </li>
max@0 5754 <br>
max@0 5755 <li>
max@0 5756 Examples:
max@0 5757 <ul>
max@0 5758 <pre>
max@0 5759 mat A = randu&lt;mat&gt;(5,5);
max@0 5760 vec d = diagvec(A);
max@0 5761 </pre>
max@0 5762 </ul>
max@0 5763 </li>
max@0 5764 <br>
max@0 5765 <li>See also:
max@0 5766 <ul>
max@0 5767 <li><a href="#diag">.diag()</a></li>
max@0 5768 <li><a href="#diagmat">diagmat()</a></li>
max@0 5769 </ul>
max@0 5770 </li>
max@0 5771 <br>
max@0 5772 </ul>
max@0 5773 <hr class="greyline">
max@0 5774 <br>
max@0 5775
max@0 5776 <a name="min_and_max"></a>
max@0 5777 <b>min(mat, dim=0)</b>
max@0 5778 <br><b>min(rowvec)</b>
max@0 5779 <br><b>min(colvec)</b>
max@0 5780 <br>
max@0 5781 <br><b>max(mat, dim=0)</b>
max@0 5782 <br><b>max(rowvec)</b>
max@0 5783 <br><b>max(colvec)</b>
max@0 5784 <ul>
max@0 5785 <li>
max@0 5786 For a matrix argument, return the extremum value for each column (dim=0), or each row (dim=1)
max@0 5787 </li>
max@0 5788 <br>
max@0 5789 <li>
max@0 5790 For a vector argument, return the extremum value
max@0 5791 </li>
max@0 5792 <br>
max@0 5793 <li>
max@0 5794 Examples:
max@0 5795 <ul>
max@0 5796 <pre>
max@0 5797 colvec q = randu&lt;colvec&gt;(10,1);
max@0 5798 double x = max(q);
max@0 5799
max@0 5800 mat A = randu&lt;mat&gt;(10,10);
max@0 5801 rowvec b = max(A);
max@0 5802
max@0 5803 // same result as max(A)
max@0 5804 // the 0 explicitly indicates
max@0 5805 // "traverse across rows"
max@0 5806 rowvec c = max(A,0);
max@0 5807
max@0 5808 // the 1 explicitly indicates
max@0 5809 // "traverse across columns"
max@0 5810 colvec d = max(A,1);
max@0 5811
max@0 5812 // find the overall maximum value
max@0 5813 double y = max(max(A));
max@0 5814 </pre>
max@0 5815 </ul>
max@0 5816 </li>
max@0 5817 <br>
max@0 5818 <li>
max@0 5819 See also:
max@0 5820 <ul>
max@0 5821 <li><a href="#min_and_max_member">.min() &amp; .max()</a> (member functions of Mat and Cube)</li>
max@0 5822 <li><a href="#running_stat">running_stat</a></li>
max@0 5823 <li><a href="#running_stat_vec">running_stat_vec</a></li>
max@0 5824 </ul>
max@0 5825 </li>
max@0 5826 <br>
max@0 5827 </ul>
max@0 5828 <hr class="greyline"><br>
max@0 5829
max@0 5830 <a name="prod"></a>
max@0 5831 <b>prod(mat, dim=0)</b>
max@0 5832 <br><b>prod(rowvec)</b>
max@0 5833 <br><b>prod(colvec)</b>
max@0 5834 <ul>
max@0 5835 <li>
max@0 5836 For a matrix argument, return the product of elements in each column (dim=0), or each row (dim=1)
max@0 5837 </li>
max@0 5838 <br>
max@0 5839 <li>
max@0 5840 For a vector argument, return the product of all elements
max@0 5841 </li>
max@0 5842 <br>
max@0 5843 <li>
max@0 5844 Examples:
max@0 5845 <ul>
max@0 5846 <pre>
max@0 5847 colvec q = randu&lt;colvec&gt;(10,1);
max@0 5848 double x = prod(q);
max@0 5849
max@0 5850 mat A = randu&lt;mat&gt;(10,10);
max@0 5851 rowvec b = prod(A);
max@0 5852
max@0 5853 // same result as prod(A)
max@0 5854 // the 0 explicitly indicates
max@0 5855 // "traverse across rows"
max@0 5856 rowvec c = prod(A,0);
max@0 5857
max@0 5858 // the 1 explicitly indicates
max@0 5859 // "traverse across columns"
max@0 5860 colvec d = prod(A,1);
max@0 5861
max@0 5862 // find the overall product
max@0 5863 double y = prod(prod(A));
max@0 5864 </pre>
max@0 5865 </ul>
max@0 5866 </li>
max@0 5867 <br>
max@0 5868 <li>
max@0 5869 See also:
max@0 5870 <ul>
max@0 5871 <li><a href="#schur_product">Schur product</a></li>
max@0 5872 </ul>
max@0 5873 </li>
max@0 5874 </ul>
max@0 5875 <br>
max@0 5876 <hr class="greyline"><br>
max@0 5877
max@0 5878
max@0 5879 <a name="sum"></a>
max@0 5880 <b>sum(mat, dim=0)</b>
max@0 5881 <br><b>sum(rowvec)</b>
max@0 5882 <br><b>sum(colvec)</b>
max@0 5883 <ul>
max@0 5884 <li>
max@0 5885 For a matrix argument, return the sum of elements in each column (dim=0), or each row (dim=1)
max@0 5886 </li>
max@0 5887 <br>
max@0 5888 <li>
max@0 5889 For a vector argument, return the sum of all elements
max@0 5890 </li>
max@0 5891 <br>
max@0 5892 <li>
max@0 5893 To get a sum of all the elements regardless of the argument type (ie. matrix or vector),
max@0 5894 you may wish to use <a href="#accu">accu()</a> instead
max@0 5895 </li>
max@0 5896 <br>
max@0 5897 <li>
max@0 5898 Examples:
max@0 5899 <ul>
max@0 5900 <pre>
max@0 5901 colvec q = randu&lt;colvec&gt;(10,1);
max@0 5902 double x = sum(q);
max@0 5903
max@0 5904 mat A = randu&lt;mat&gt;(10,10);
max@0 5905 rowvec b = sum(A);
max@0 5906
max@0 5907 // same result as sum(A)
max@0 5908 // the 0 explicitly indicates
max@0 5909 // "traverse across rows"
max@0 5910 rowvec c = sum(A,0);
max@0 5911
max@0 5912 // the 1 explicitly indicates
max@0 5913 // "traverse across columns"
max@0 5914 colvec d = sum(A,1);
max@0 5915
max@0 5916 // find the overall sum
max@0 5917 double y = sum(sum(A));
max@0 5918 </pre>
max@0 5919 </ul>
max@0 5920 </li>
max@0 5921 <br>
max@0 5922 <li>
max@0 5923 See also:
max@0 5924 <ul>
max@0 5925 <li><a href="#accu">accu()</a></li>
max@0 5926 <li><a href="#cumsum">cumsum()</a></li>
max@0 5927 <li><a href="#trace">trace()</a></li>
max@0 5928 <li><a href="#as_scalar">as_scalar()</a></li>
max@0 5929 </ul>
max@0 5930 </li>
max@0 5931 <br>
max@0 5932 </ul>
max@0 5933 <hr class="greyline"><br>
max@0 5934
max@0 5935
max@0 5936 <a name="stats_fns"></a>
max@0 5937 <b>statistics: mean, median, stddev, var</b>
max@0 5938
max@0 5939 <ul>
max@0 5940 <table style="text-align: left;" border="0" cellpadding="2" cellspacing="2">
max@0 5941 <tbody>
max@0 5942 <tr>
max@0 5943 <td style="vertical-align: top;">
max@0 5944 <b>mean(mat, dim=0)</b>
max@0 5945 <br><b>mean(colvec)</b>
max@0 5946 <br><b>mean(rowvec)</b>
max@0 5947 <br>
max@0 5948 <br>
max@0 5949 </td>
max@0 5950 <td style="vertical-align: top;">
max@0 5951 &nbsp;
max@0 5952 </td>
max@0 5953 <td style="vertical-align: top;">
max@0 5954 mean (average value)
max@0 5955 </td>
max@0 5956 </tr>
max@0 5957 <tr>
max@0 5958 <td style="vertical-align: top;">
max@0 5959 <b>median(mat, dim=0)</b>
max@0 5960 <br><b>median(colvec)</b>
max@0 5961 <br><b>median(rowvec)</b>
max@0 5962 <br>
max@0 5963 <br>
max@0 5964 </td>
max@0 5965 <td style="vertical-align: top;">
max@0 5966 &nbsp;
max@0 5967 </td>
max@0 5968 <td style="vertical-align: top;">
max@0 5969 median
max@0 5970 </td>
max@0 5971 </tr>
max@0 5972 <tr>
max@0 5973 <td style="vertical-align: top;">
max@0 5974 <b>stddev(mat, norm_type=0, dim=0)</b>
max@0 5975 <br><b>stddev(colvec, norm_type=0)</b>
max@0 5976 <br><b>stddev(rowvec, norm_type=0)</b>
max@0 5977 <br>
max@0 5978 <br>
max@0 5979 </td>
max@0 5980 <td style="vertical-align: top;">
max@0 5981 &nbsp;
max@0 5982 </td>
max@0 5983 <td style="vertical-align: top;">
max@0 5984 standard deviation
max@0 5985 </td>
max@0 5986 </tr>
max@0 5987 <tr>
max@0 5988 <td style="vertical-align: top;">
max@0 5989 <b>var(mat, norm_type=0, dim=0)</b>
max@0 5990 <br><b>var(colvec, norm_type=0)</b>
max@0 5991 <br><b>var(rowvec, norm_type=0)</b>
max@0 5992 <br>
max@0 5993 <br>
max@0 5994 </td>
max@0 5995 <td style="vertical-align: top;">
max@0 5996 &nbsp;
max@0 5997 </td>
max@0 5998 <td style="vertical-align: top;">
max@0 5999 variance
max@0 6000 </td>
max@0 6001 </tr>
max@0 6002 </tbody>
max@0 6003 </table>
max@0 6004 <br>
max@0 6005 <li>
max@0 6006 For a matrix argument, find a particular statistic for each column (<i>dim=0</i>), or each row (<i>dim=1</i>)
max@0 6007 </li>
max@0 6008 <br>
max@0 6009 <li>
max@0 6010 For a vector argument, return a particular statistic calculated using all the elements of the vector
max@0 6011 </li>
max@0 6012 <br>
max@0 6013 <li>
max@0 6014 For the var() and stddev() functions, the default <i>norm_type=0</i> performs normalisation using <i>N-1</i> (where <i>N</i> is the number of samples),
max@0 6015 providing the best unbiased estimator.
max@0 6016 Using <i>norm_type=1</i> causes normalisation to be done using <i>N</i>, which provides the second moment around the mean
max@0 6017 </li>
max@0 6018 <br>
max@0 6019 <li>
max@0 6020 Examples:
max@0 6021 <ul>
max@0 6022 <pre>
max@0 6023 mat A = randu&lt;mat&gt;(5,5);
max@0 6024 mat B = mean(A);
max@0 6025 mat C = var(A);
max@0 6026 double m = mean(mean(A));
max@0 6027
max@0 6028 vec q = randu&lt;vec&gt;(5);
max@0 6029 double v = var(q);
max@0 6030 </pre>
max@0 6031 </ul>
max@0 6032 </li>
max@0 6033 <br>
max@0 6034 <li>
max@0 6035 See also:
max@0 6036 <ul>
max@0 6037 <li><a href="#cov">cov()</a></li>
max@0 6038 <li><a href="#cor">cor()</a></li>
max@0 6039 <li><a href="#running_stat">running_stat</a></li>
max@0 6040 <li><a href="#running_stat_vec">running_stat_vec</a></li>
max@0 6041 </ul>
max@0 6042 </li>
max@0 6043 </ul>
max@0 6044 <br>
max@0 6045 <hr class="greyline">
max@0 6046
max@0 6047 <hr class="greyline">
max@0 6048 <br>
max@0 6049 <br>
max@0 6050 <font size=+1><b>Vector/Matrix/Cube Valued Functions of Vectors/Matrices/Cubes</b></font>
max@0 6051 <br>
max@0 6052 <br>
max@0 6053 <hr class="greyline">
max@0 6054 <br>
max@0 6055
max@0 6056 <a name="conv"></a>
max@0 6057 <b>
max@0 6058 C = conv(A, B)
max@0 6059 </b>
max@0 6060 <ul>
max@0 6061 <li>
max@0 6062 Convolution of vectors A and B.
max@0 6063 </li>
max@0 6064 <br>
max@0 6065 <li>
max@0 6066 If A and B are polynomial coefficient vectors, convolving them is equivalent to multiplying the two polynomials
max@0 6067 </li>
max@0 6068 <br>
max@0 6069 <li>
max@0 6070 The convolution operation is also equivalent to FIR filtering
max@0 6071 </li>
max@0 6072 <br>
max@0 6073 <li>
max@0 6074 The orientation of the result vector is the same as the orientation of A (ie. column or row vector)
max@0 6075 </li>
max@0 6076 <br>
max@0 6077 <li>
max@0 6078 Examples:
max@0 6079 <ul>
max@0 6080 <pre>
max@0 6081 vec A = randu&lt;vec&gt;(128) - 0.5;
max@0 6082 vec B = randu&lt;vec&gt;(128) - 0.5;
max@0 6083
max@0 6084 vec C = conv(A,B);
max@0 6085 </pre>
max@0 6086 </ul>
max@0 6087 </li>
max@0 6088 <br>
max@0 6089 <li>
max@0 6090 See also:
max@0 6091 <ul>
max@0 6092 <li><a href="http://mathworld.wolfram.com/Convolution.html">Convolution in MathWorld</a></li>
max@0 6093 <li><a href="http://en.wikipedia.org/wiki/Convolution">Convolution in Wikipedia</a></li>
max@0 6094 <li><a href="http://en.wikipedia.org/wiki/Finite_impulse_response">FIR filter in Wikipedia</a></li>
max@0 6095 <li><a href="#cor">cor()</a></li>
max@0 6096 </ul>
max@0 6097 </li>
max@0 6098 </ul>
max@0 6099 <br>
max@0 6100 <hr class="greyline"><br>
max@0 6101
max@0 6102 <a name="conv_to"></a>
max@0 6103 <b>
max@0 6104 conv_to&lt;<i>type</i>&gt;::from(X)
max@0 6105 </b>
max@0 6106 <ul>
max@0 6107 <li>
max@0 6108 A form of casting
max@0 6109 </li>
max@0 6110 <br>
max@0 6111 <li>
max@0 6112 Convert between matrix/vector types (eg. <i>mat</i> to <i>fmat</i>), as well as cube types (eg. <i>cube</i> to <i>fcube</i>)
max@0 6113 </li>
max@0 6114 <br>
max@0 6115 <li>
max@0 6116 Conversion between <i>std::vector</i> and Armadillo matrices/vectors is also possible
max@0 6117 </li>
max@0 6118 <br>
max@0 6119 <li>
max@0 6120 Conversion of a <i>mat</i> object into <i>colvec</i>, <i>rowvec</i> or <i>std::vector</i> is possible if the object can be interpreted as a vector
max@0 6121 </li>
max@0 6122 <br>
max@0 6123 <li>
max@0 6124 Examples:
max@0 6125 <ul>
max@0 6126 <pre>
max@0 6127 mat A = randu&lt;mat&gt;(5,5);
max@0 6128 fmat B = conv_to&lt;fmat&gt;::from(A);
max@0 6129
max@0 6130 typedef std::vector&lt;double&gt; stdvec;
max@0 6131
max@0 6132 stdvec x(3);
max@0 6133 x[0] = 0.0; x[1] = 1.0; x[2] = 2.0;
max@0 6134
max@0 6135 colvec y = conv_to&lt; colvec &gt;::from(x);
max@0 6136 stdvec z = conv_to&lt; stdvec &gt;::from(y);
max@0 6137 </pre>
max@0 6138 </ul>
max@0 6139 </li>
max@0 6140 <br>
max@0 6141 <li>
max@0 6142 See also:
max@0 6143 <ul>
max@0 6144 <li><a href="#as_scalar">as_scalar()</a></li>
max@0 6145 <li><a href="#reshape">reshape()</a></li>
max@0 6146 <li><a href="#resize">resize()</a></li>
max@0 6147 <li><a href="#adv_constructors_mat">advanced constructors (matrices)</a></li>
max@0 6148 <li><a href="#adv_constructors_cube">advanced constructors (cubes)</a></li>
max@0 6149 </ul>
max@0 6150 </li>
max@0 6151 <br>
max@0 6152 </ul>
max@0 6153 <hr class="greyline"><br>
max@0 6154
max@0 6155 <a name="conj"></a>
max@0 6156 <b>conj(cx_mat)</b>
max@0 6157 <br><b>conj(cx_cube)</b>
max@0 6158 <ul>
max@0 6159 <li>
max@0 6160 Obtain the complex conjugate of each element in a complex matrix/cube
max@0 6161 </li>
max@0 6162 <br>
max@0 6163 <li>
max@0 6164 Examples:
max@0 6165 <ul>
max@0 6166 <pre>
max@0 6167 cx_mat X = randu&lt;cx_mat&gt;(5,5);
max@0 6168 cx_mat Y = conj(X);
max@0 6169 </pre>
max@0 6170 </ul>
max@0 6171 </li>
max@0 6172 <br>
max@0 6173 <li>See also:
max@0 6174 <ul>
max@0 6175 <li><a href="#trans">trans()</a></li>
max@0 6176 </ul>
max@0 6177 </li>
max@0 6178 <br>
max@0 6179 </ul>
max@0 6180 <hr class="greyline"><br>
max@0 6181
max@0 6182 <a name="cor"></a>
max@0 6183 <b>cor(X, Y, norm_type=0)</b>
max@0 6184 <br><b>cor(X, norm_type=0)</b>
max@0 6185 <ul>
max@0 6186 <li>
max@0 6187 For two matrix arguments <i>X</i> and <i>Y</i>,
max@0 6188 if each row of <i>X</i> and <i>Y</i> is an observation and each column is a variable,
max@0 6189 the <i>(i,j)</i>-th entry of <i>cor(X,Y)</i> is the correlation coefficient between the <i>i</i>-th variable in <i>X</i> and the <i>j</i>-th variable in <i>Y</i>
max@0 6190 </li>
max@0 6191 <br>
max@0 6192 <li>
max@0 6193 For vector arguments, the type of vector is ignored and each element in the vector is treated as an observation
max@0 6194 </li>
max@0 6195 <br>
max@0 6196 <li>
max@0 6197 For matrices, <i>X</i> and <i>Y</i> must have the same dimensions
max@0 6198 </li>
max@0 6199 <br>
max@0 6200 <li>
max@0 6201 For vectors, <i>X</i> and <i>Y</i> must have the same number of elements
max@0 6202 </li>
max@0 6203 <br>
max@0 6204 <li>
max@0 6205 <i>cor(X)</i> is equivalent to <i>cor(X, X)</i>, also called autocorrelation
max@0 6206 </li>
max@0 6207 <br>
max@0 6208 <li>
max@0 6209 The default <i>norm_type=0</i> performs normalisation of the correlation matrix using <i>N-1</i> (where <i>N</i> is the number of observations).
max@0 6210 Using <i>norm_type=1</i> causes normalisation to be done using <i>N</i>
max@0 6211 </li>
max@0 6212 <br>
max@0 6213 <li>
max@0 6214 Examples:
max@0 6215 <ul>
max@0 6216 <pre>
max@0 6217 mat X = randu&lt;mat&gt;(4,5);
max@0 6218 mat Y = randu&lt;mat&gt;(4,5);
max@0 6219
max@0 6220 mat R = cor(X,Y);
max@0 6221 </pre>
max@0 6222 </ul>
max@0 6223 </li>
max@0 6224 <br>
max@0 6225 <li>
max@0 6226 See also:
max@0 6227 <ul>
max@0 6228 <li><a href="http://mathworld.wolfram.com/Correlation.html">Correlation in MathWorld</a></li>
max@0 6229 <li><a href="http://mathworld.wolfram.com/Autocorrelation.html">Autocorrelation in MathWorld</a></li>
max@0 6230 <li><a href="#cov">cov()</a></li>
max@0 6231 <li><a href="#conv">conv()</a></li>
max@0 6232 </ul>
max@0 6233 </li>
max@0 6234 </ul>
max@0 6235 <br>
max@0 6236 <hr class="greyline"><br>
max@0 6237
max@0 6238 <a name="cov"></a>
max@0 6239 <b>cov(X, Y, norm_type=0)</b>
max@0 6240 <br><b>cov(X, norm_type=0)</b>
max@0 6241 <ul>
max@0 6242 <li>
max@0 6243 For two matrix arguments <i>X</i> and <i>Y</i>,
max@0 6244 if each row of <i>X</i> and <i>Y</i> is an observation and each column is a variable,
max@0 6245 the <i>(i,j)</i>-th entry of <i>cov(X,Y)</i> is the covariance between the <i>i</i>-th variable in <i>X</i> and the <i>j</i>-th variable in <i>Y</i>
max@0 6246 </li>
max@0 6247 <br>
max@0 6248 <li>
max@0 6249 For vector arguments, the type of vector is ignored and each element in the vector is treated as an observation
max@0 6250 </li>
max@0 6251 <br>
max@0 6252 <li>
max@0 6253 For matrices, <i>X</i> and <i>Y</i> must have the same dimensions
max@0 6254 </li>
max@0 6255 <br>
max@0 6256 <li>
max@0 6257 For vectors, <i>X</i> and <i>Y</i> must have the same number of elements
max@0 6258 </li>
max@0 6259 <br>
max@0 6260 <li>
max@0 6261 <i>cov(X)</i> is equivalent to <i>cov(X, X)</i>
max@0 6262 </li>
max@0 6263 <br>
max@0 6264 <li>
max@0 6265 The default <i>norm_type=0</i> performs normalisation using <i>N-1</i> (where <i>N</i> is the number of observations),
max@0 6266 providing the best unbiased estimation of the covariance matrix (if the observations are from a normal distribution).
max@0 6267 Using <i>norm_type=1</i> causes normalisation to be done using <i>N</i>, which provides the second moment matrix of the observations about their mean
max@0 6268 </li>
max@0 6269 <br>
max@0 6270 <li>
max@0 6271 Examples:
max@0 6272 <ul>
max@0 6273 <pre>
max@0 6274 mat X = randu&lt;mat&gt;(4,5);
max@0 6275 mat Y = randu&lt;mat&gt;(4,5);
max@0 6276
max@0 6277 mat C = cov(X,Y);
max@0 6278 </pre>
max@0 6279 </ul>
max@0 6280 </li>
max@0 6281 <br>
max@0 6282 <li>
max@0 6283 See also:
max@0 6284 <ul>
max@0 6285 <li><a href="#running_stat_vec">running_stat_vec</a></li>
max@0 6286 <li><a href="#stats_fns">statistics functions</a></li>
max@0 6287 <li><a href="http://mathworld.wolfram.com/Covariance.html">Covariance in MathWorld</a></li>
max@0 6288 <li><a href="#cor">cor()</a></li>
max@0 6289 </ul>
max@0 6290 </li>
max@0 6291 </ul>
max@0 6292 <br>
max@0 6293 <hr class="greyline"><br>
max@0 6294
max@0 6295 <a name="cross"></a>
max@0 6296 <b>cross(A, B)</b>
max@0 6297 <ul>
max@0 6298 <li>
max@0 6299 Calculate the cross product between A and B, under the assumption that A and B are 3 dimensional vectors
max@0 6300 </li>
max@0 6301 <br>
max@0 6302 <li>
max@0 6303 Examples:
max@0 6304 <ul>
max@0 6305 <pre>
max@0 6306 vec a = randu&lt;vec&gt;(3);
max@0 6307 vec b = randu&lt;vec&gt;(3);
max@0 6308
max@0 6309 vec c = cross(a,b);
max@0 6310 </pre>
max@0 6311 </ul>
max@0 6312 </li>
max@0 6313 <br>
max@0 6314 <li>
max@0 6315 See also:
max@0 6316 <ul>
max@0 6317 <li><a href="#dot">dot()</a></li>
max@0 6318 <li><a href="http://en.wikipedia.org/wiki/Cross_product">Cross product in Wikipedia</a></li>
max@0 6319 <li><a href="http://mathworld.wolfram.com/CrossProduct.html">Cross product in MathWorld</a></li>
max@0 6320 </ul>
max@0 6321 </li>
max@0 6322 </ul>
max@0 6323 <br>
max@0 6324 <hr class="greyline"><br>
max@0 6325
max@0 6326 <a name="cumsum"></a>
max@0 6327 <b>cumsum(mat, dim=0)</b>
max@0 6328 <br><b>cumsum(rowvec)</b>
max@0 6329 <br><b>cumsum(colvec)</b>
max@0 6330 <ul>
max@0 6331 <li>
max@0 6332 For a matrix argument, return a matrix containing the cumulative sum of elements in each column (dim=0, the default), or each row (dim=1)
max@0 6333 </li>
max@0 6334 <br>
max@0 6335 <li>
max@0 6336 For a vector argument, return a vector of the same orientation, containing the cumulative sum of elements
max@0 6337 </li>
max@0 6338 <br>
max@0 6339 <li>
max@0 6340 Examples:
max@0 6341 <ul>
max@0 6342 <pre>
max@0 6343 mat A = randu&lt;mat&gt;(5,5);
max@0 6344 mat B = cumsum(A);
max@0 6345
max@0 6346 vec x = randu&lt;vec&gt;(10);
max@0 6347 vec y = cumsum(x);
max@0 6348 </pre>
max@0 6349 </ul>
max@0 6350 </li>
max@0 6351 <br>
max@0 6352 <li>
max@0 6353 See also:
max@0 6354 <ul>
max@0 6355 <li><a href="#accu">accu()</a></li>
max@0 6356 <li><a href="#sum">sum()</a></li>
max@0 6357 </ul>
max@0 6358 </li>
max@0 6359 <br>
max@0 6360 </ul>
max@0 6361 <hr class="greyline"><br>
max@0 6362
max@0 6363 <a name="diagmat"></a>
max@0 6364 <b>diagmat(mat)</b>
max@0 6365 <br><b>diagmat(rowvec)</b>
max@0 6366 <br><b>diagmat(colvec)</b>
max@0 6367 <ul>
max@0 6368 <li>
max@0 6369 Interpret a matrix or vector as a diagonal matrix
max@0 6370 </li>
max@0 6371 <br>
max@0 6372 <li>
max@0 6373 For <i>mat</i>, given matrix must be square; the main diagonal is copied and all other elements in the generated matrix are set to zero
max@0 6374 </li>
max@0 6375 <br>
max@0 6376 <li>
max@0 6377 For <i>colvec</i> and <i>rowvec</i>, elements of the vector are placed on the main diagonal in the generated matrix and all other elements are set to zero
max@0 6378 </li>
max@0 6379 <br>
max@0 6380 <li>
max@0 6381 Examples:
max@0 6382 <ul>
max@0 6383 <pre>
max@0 6384 mat A = randu&lt;mat&gt;(5,5);
max@0 6385 mat B = diagmat(A);
max@0 6386 mat C = A*diagmat(A);
max@0 6387
max@0 6388 rowvec q = randu&lt;rowvec&gt;(5);
max@0 6389 colvec r = randu&lt;colvec&gt;(5);
max@0 6390 mat X = diagmat(q)*diagmat(r);
max@0 6391 </pre>
max@0 6392 </ul>
max@0 6393 </li>
max@0 6394 <br>
max@0 6395 <li>
max@0 6396 See also:
max@0 6397 <ul>
max@0 6398 <li><a href="#diagvec">diagvec()</a></li>
max@0 6399 <li><a href="#trimat">trimatu() / trimatl()</a></li>
max@0 6400 <li><a href="#symmat">symmatu() / symmatl()</a></li>
max@0 6401 <li><a href="#reshape">reshape()</a></li>
max@0 6402 </ul>
max@0 6403 </li>
max@0 6404 <br>
max@0 6405 </ul>
max@0 6406 <hr class="greyline">
max@0 6407 <br>
max@0 6408
max@0 6409 <a name="find"></a>
max@0 6410 <b>find(X, k=0, s="first")</b>
max@0 6411 <ul>
max@0 6412 <li>Return a column vector of the indices of non-zero elements of <i>X</i></li>
max@0 6413 <br>
max@0 6414 <li>The output vector must have the type <a href="#Col">uvec</a> or <a href="#Mat">umat</a>
max@0 6415 (ie. the indices are stored as unsigned integers of type <a href="#uword">uword</a>)
max@0 6416 </li>
max@0 6417 <br>
max@0 6418 <li>
max@0 6419 The input matrix <i>X</i> is interpreted as a vector, with column-by-column ordering of the elements of <i>X</i>
max@0 6420 </li>
max@0 6421 <br>
max@0 6422 <li>Relational operators can be used instead of <i>X</i>, eg.&nbsp;<i>A&nbsp;&gt;&nbsp;0.5</i>
max@0 6423 </li>
max@0 6424 <br>
max@0 6425 <li>If <i>k=0</i> (default), return the indices of all non-zero elements, otherwise return at most <i>k</i> of their indices</li>
max@0 6426 <br>
max@0 6427 <li>If <i>s="first"</i> (default), return at most the first <i>k</i> indices of the non-zero elements
max@0 6428 </li>
max@0 6429 <br>
max@0 6430 <li>If <i>s="last"</i>, return at most the last <i>k</i> indices of the non-zero elements
max@0 6431 </li>
max@0 6432 <br>
max@0 6433 <li>
max@0 6434 Examples:
max@0 6435 <ul>
max@0 6436 <pre>
max@0 6437 mat A = randu&lt;mat&gt;(5,5);
max@0 6438 mat B = randu&lt;mat&gt;(5,5);
max@0 6439
max@0 6440 uvec q1 = find(A &gt; B);
max@0 6441 uvec q2 = find(A &gt; 0.5);
max@0 6442 uvec q3 = find(A &gt; 0.5, 3, "last");
max@0 6443 </pre>
max@0 6444 </ul>
max@0 6445 </li>
max@0 6446 <br>
max@0 6447 <li>
max@0 6448 See also:
max@0 6449 <ul>
max@0 6450 <li><a href="#conv_to">conv_to()</a> (convert between matrix/vector types)</li>
max@0 6451 <li><a href="#submat">submatrix views</a></li>
max@0 6452 <li><a href="#sort_index">sort_index()</a></li>
max@0 6453 </ul>
max@0 6454 </li>
max@0 6455 <br>
max@0 6456 </ul>
max@0 6457 <hr class="greyline">
max@0 6458 <br>
max@0 6459
max@0 6460 <a name="flip"></a>
max@0 6461 <b>fliplr(mat)</b>
max@0 6462 <br><b>flipud(mat)</b>
max@0 6463 <ul>
max@0 6464 <li>
max@0 6465 fliplr(): generate a copy of the input matrix, with the order of the columns reversed
max@0 6466 </li>
max@0 6467 <br>
max@0 6468 <li>
max@0 6469 flipud(): generate a copy of the input matrix, with the order of the rows reversed
max@0 6470 </li>
max@0 6471 <br>
max@0 6472 <li>
max@0 6473 Examples:
max@0 6474 <ul>
max@0 6475 <pre>
max@0 6476 mat A = randu&lt;mat&gt;(5,5);
max@0 6477
max@0 6478 mat B = fliplr(A);
max@0 6479 mat C = flipud(A);
max@0 6480 </pre>
max@0 6481 </ul>
max@0 6482 </li>
max@0 6483 <br>
max@0 6484 <li>
max@0 6485 See also:
max@0 6486 <ul>
max@0 6487 <li><a href="#swap_rows">.swap_rows() &amp; .swap_cols()</a> (member functions of <i>Mat</i>, <i>Col</i> and <i>Row</i> classes)</li>
max@0 6488 </ul>
max@0 6489 </li>
max@0 6490 <br>
max@0 6491 </ul>
max@0 6492 <hr class="greyline"><br>
max@0 6493
max@0 6494 <a name="imag_real"></a>
max@0 6495 <b>imag(cx_mat)</b>
max@0 6496 <br><b>imag(cx_cube)</b>
max@0 6497 <br>
max@0 6498 <br><b>real(cx_mat)</b>
max@0 6499 <br><b>real(cx_cube)</b>
max@0 6500 <ul>
max@0 6501 <li>
max@0 6502 Extract the imaginary/real part of a complex matrix/cube
max@0 6503 </li>
max@0 6504 <br>
max@0 6505 <li>
max@0 6506 Examples:
max@0 6507 <ul>
max@0 6508 <pre>
max@0 6509 cx_mat C = randu&lt;cx_mat&gt;(5,5);
max@0 6510
max@0 6511 mat A = imag(C);
max@0 6512 mat B = real(C);
max@0 6513 </pre>
max@0 6514 </ul>
max@0 6515 </li>
max@0 6516 <br>
max@0 6517 <li><b>Caveat:</b> versions 4.4, 4.5 and 4.6 of the GCC C++ compiler have a bug when using the <i>-std=c++0x</i> compiler option (ie. experimental support for C++11);
max@0 6518 to work around this bug, preface Armadillo's imag() and real() with the <i>arma</i> namespace qualification, eg. arma::imag(C)
max@0 6519 </li>
max@0 6520 <br>
max@0 6521 <li>See also:
max@0 6522 <ul>
max@0 6523 <li><a href="#set_imag">set_imag()&nbsp;/&nbsp;set_real()</a></li>
max@0 6524 </ul>
max@0 6525 </li>
max@0 6526 <br>
max@0 6527 </ul>
max@0 6528 <hr class="greyline"><br>
max@0 6529
max@0 6530 <a name="join"></a>
max@0 6531 <b>join_rows(mat A, mat B)</b>
max@0 6532 <br><b>join_cols(mat A, mat B)</b>
max@0 6533 <br><b>join_slices(cube A, cube B)</b>
max@0 6534 <ul>
max@0 6535 <li>
max@0 6536 join_rows():
max@0 6537 for two matrices A and B, append each row of B to its respective row of A;
max@0 6538 matrices A and B must have the same number of rows
max@0 6539 </li>
max@0 6540 <br>
max@0 6541 <li>
max@0 6542 join_cols():
max@0 6543 for two matrices A and B, append each column of B to its respective column of A;
max@0 6544 matrices A and B must have the same number of columns
max@0 6545 </li>
max@0 6546 <br>
max@0 6547 <li>
max@0 6548 join_slices():
max@0 6549 for two cubes A and B, append the slices of B to the slices of A;
max@0 6550 cubes A and B have the same number of rows and columns (ie. all slices must have the same size)
max@0 6551 </li>
max@0 6552 <br>
max@0 6553 <li>
max@0 6554 Examples:
max@0 6555 <ul>
max@0 6556 <pre>
max@0 6557 mat A = randu&lt;mat&gt;(4,5);
max@0 6558 mat B = randu&lt;mat&gt;(4,6);
max@0 6559 mat C = randu&lt;mat&gt;(6,5);
max@0 6560
max@0 6561 mat X = join_rows(A,B);
max@0 6562 mat Y = join_cols(A,C);
max@0 6563 </pre>
max@0 6564 </ul>
max@0 6565 </li>
max@0 6566 <br>
max@0 6567 <li>
max@0 6568 See also:
max@0 6569 <ul>
max@0 6570 <li><a href="#shed">shed rows/columns/slices</a></li>
max@0 6571 <li><a href="#insert">insert rows/columns/slices</a></li>
max@0 6572 <li><a href="#submat">submatrix views</a></li>
max@0 6573 <li><a href="#subcube">subcube views</a></li>
max@0 6574 </ul>
max@0 6575 </li>
max@0 6576 <br>
max@0 6577 </ul>
max@0 6578 <hr class="greyline"><br>
max@0 6579
max@0 6580 <a name="kron"></a>
max@0 6581 <b>kron(A,B)</b>
max@0 6582
max@0 6583 <ul>
max@0 6584 <li>Kronecker tensor product.</li>
max@0 6585 <br>
max@0 6586 <li>Using matrix <i>A</i> (with <i>n</i> rows and <i>p</i> columns) and matrix <i>B</i> (with <i>m</i> rows and <i>q</i> columns),
max@0 6587 <i>kron(A,B)</i> returns a matrix (with <i>nm</i> rows and <i>pq</i> columns) which denotes the tensor product of <i>A</i> and <i>B</i>
max@0 6588 </li>
max@0 6589 <br>
max@0 6590 <li>
max@0 6591 Examples:
max@0 6592 <ul>
max@0 6593 <pre>
max@0 6594 mat A = randu&lt;mat&gt;(4,5);
max@0 6595 mat B = randu&lt;mat&gt;(5,4);
max@0 6596
max@0 6597 mat K = kron(A,B);
max@0 6598 </pre>
max@0 6599 </ul>
max@0 6600 </li>
max@0 6601 <br>
max@0 6602 <li>
max@0 6603 See also:
max@0 6604 <ul>
max@0 6605 <li><a href="http://mathworld.wolfram.com/KroneckerProduct.html">Kronecker Product in MathWorld</a></li>
max@0 6606 </ul>
max@0 6607 </li>
max@0 6608 </ul>
max@0 6609 <br>
max@0 6610 <hr class="greyline"><br>
max@0 6611
max@0 6612 <a name="reshape"></a>
max@0 6613 <b>reshape(mat, n_rows, n_cols, dim=0)</b>
max@0 6614 <br><b>reshape(cube, n_rows, n_cols, n_slices, dim=0)</b>
max@0 6615 <ul>
max@0 6616 <li>
max@0 6617 Generate a matrix/cube sized according to given size specifications,
max@0 6618 whose elements are taken from the given matrix/cube, either column-wise (dim=0) or row-wise (dim=1);
max@0 6619 the elements in the generated object are placed column-wise (ie. the first column is filled up before filling the second column)
max@0 6620 </li>
max@0 6621 <br>
max@0 6622 <li>
max@0 6623 The layout of the elements in the generated object will be different to the layout in the given object
max@0 6624 </li>
max@0 6625 <br>
max@0 6626 <li>
max@0 6627 This function can be used to create a vector representation of a matrix (ie. concatenate all the columns or rows)
max@0 6628 </li>
max@0 6629 <br>
max@0 6630 <li>
max@0 6631 The total number of elements in the generated matrix/cube doesn't have to be the same as the total number of elements in the given matrix/cube
max@0 6632 </li>
max@0 6633 <br>
max@0 6634 <li>
max@0 6635 If the total number of elements in the given matrix/cube is less than the specified size,
max@0 6636 the remaining elements in the generated matrix/cube are set to zero
max@0 6637 </li>
max@0 6638 <br>
max@0 6639 <li>
max@0 6640 If the total number of elements in the given matrix/cube is greater than the specified size,
max@0 6641 only a subset of elements is taken from the given matrix/cube
max@0 6642 </li>
max@0 6643 <br>
max@0 6644 <li>
max@0 6645 <b>Caveat:</b>
max@0 6646 reshape() is slower than <a href="#set_size">.set_size()</a>, which doesn't preserve data
max@0 6647 </li>
max@0 6648 <br>
max@0 6649 <li>
max@0 6650 <b>Caveat:</b>
max@0 6651 if you wish to grow/shrink a matrix while preserving the elements <b>as well as</b> the layout of the elements,
max@0 6652 use <a href="#resize">resize()</a> instead
max@0 6653 </li>
max@0 6654 <br>
max@0 6655 <li>
max@0 6656 Examples:
max@0 6657 <ul>
max@0 6658 <pre>
max@0 6659 mat A = randu&lt;mat&gt;(10, 5);
max@0 6660 mat B = reshape(A, 5, 10);
max@0 6661 </pre>
max@0 6662 </ul>
max@0 6663 </li>
max@0 6664 <br>
max@0 6665 <li>
max@0 6666 See also:
max@0 6667 <ul>
max@0 6668 <li><a href="#reshape_member">.reshape()</a> (member function of Mat and Cube)</li>
max@0 6669 <li><a href="#set_size">.set_size()</a> (member function of Mat and Cube)</li>
max@0 6670 <li><a href="#resize">resize()</a></li>
max@0 6671 <li><a href="#as_scalar">as_scalar()</a></li>
max@0 6672 <li><a href="#conv_to">conv_to()</a></li>
max@0 6673 <li><a href="#diagmat">diagmat()</a></li>
max@0 6674 </ul>
max@0 6675 </li>
max@0 6676 <br>
max@0 6677 </ul>
max@0 6678 <hr class="greyline"><br>
max@0 6679
max@0 6680 <a name="resize"></a>
max@0 6681 <b>resize(mat, n_rows, n_cols)</b>
max@0 6682 <br><b>resize(cube, n_rows, n_cols, n_slices)</b>
max@0 6683 <ul>
max@0 6684 <li>
max@0 6685 Generate a matrix/cube sized according to given size specifications,
max@0 6686 whose elements as well as the layout of the elements are taken from the given matrix/cube
max@0 6687 </li>
max@0 6688 <br>
max@0 6689 <li>
max@0 6690 <b>Caveat:</b>
max@0 6691 resize() is slower than <a href="#set_size">.set_size()</a>, which doesn't preserve data
max@0 6692 </li>
max@0 6693 <br>
max@0 6694 <li>
max@0 6695 Examples:
max@0 6696 <ul>
max@0 6697 <pre>
max@0 6698 mat A = randu&lt;mat&gt;(4, 5);
max@0 6699 mat B = resize(A, 7, 6);
max@0 6700 </pre>
max@0 6701 </ul>
max@0 6702 </li>
max@0 6703 <br>
max@0 6704 <li>
max@0 6705 This function was added in version 2.4.1
max@0 6706 </li>
max@0 6707 <br>
max@0 6708 <li>
max@0 6709 See also:
max@0 6710 <ul>
max@0 6711 <li><a href="#resize_member">.resize()</a> (member function of Mat and Cube)</li>
max@0 6712 <li><a href="#set_size">.set_size()</a> (member function of Mat and Cube)</li>
max@0 6713 <li><a href="#reshape">reshape()</a></li>
max@0 6714 <li><a href="#as_scalar">as_scalar()</a></li>
max@0 6715 <li><a href="#conv_to">conv_to()</a></li>
max@0 6716 </ul>
max@0 6717 </li>
max@0 6718 <br>
max@0 6719 </ul>
max@0 6720 <hr class="greyline"><br>
max@0 6721
max@0 6722 <a name="shuffle"></a>
max@0 6723 <b>shuffle(mat, dim=0)</b>
max@0 6724 <br><b>shuffle(rowvec, dim=0)</b>
max@0 6725 <br><b>shuffle(colvec, dim=0)</b>
max@0 6726 <ul>
max@0 6727 <li>
max@0 6728 Shuffle the rows (dim=0) or columns (dim=1) of a matrix or vector
max@0 6729 </li>
max@0 6730 <br>
max@0 6731 <li>
max@0 6732 Examples:
max@0 6733 <ul>
max@0 6734 <pre>
max@0 6735 mat A = randu&lt;mat&gt;(4,5);
max@0 6736 mat B = shuffle(A);
max@0 6737 </pre>
max@0 6738 </ul>
max@0 6739 </li>
max@0 6740 <br>
max@0 6741 <li>
max@0 6742 See also:
max@0 6743 <ul>
max@0 6744 <li><a href="#randu_randn_standalone">randu() / randn()</a></li>
max@0 6745 <li><a href="#sort">sort()</a></li>
max@0 6746 </ul>
max@0 6747 </li>
max@0 6748 <br>
max@0 6749 </ul>
max@0 6750 <hr class="greyline"><br>
max@0 6751
max@0 6752 <a name="sort"></a>
max@0 6753 <b>sort(mat, sort_type=0, dim=0)</b>
max@0 6754 <br><b>sort(rowvec, sort_type=0)</b>
max@0 6755 <br><b>sort(colvec, sort_type=0)</b>
max@0 6756 <ul>
max@0 6757 <li>For a matrix argument, return a matrix with the elements of the input matrix sorted in each column (<i>dim=0</i>), or each row (<i>dim=1</i>)</li>
max@0 6758 <br>
max@0 6759 <li><i>sort_type=0</i> (default) indicates an ascending sort</li>
max@0 6760 <br>
max@0 6761 <li><i>sort_type=1</i> indicates a descending sort</li>
max@0 6762 <br>
max@0 6763 <li>For a vector argument, return a vector which is a sorted version of the input vector</li>
max@0 6764 <br>
max@0 6765 <li>
max@0 6766 Examples:
max@0 6767 <ul>
max@0 6768 <pre>
max@0 6769 mat A = randu&lt;mat&gt;(10,10);
max@0 6770 mat B = sort(A);
max@0 6771 </pre>
max@0 6772 </ul>
max@0 6773 </li>
max@0 6774 <li>
max@0 6775 See also:
max@0 6776 <ul>
max@0 6777 <li><a href="#sort_index">sort_index()</a></li>
max@0 6778 <li><a href="#shuffle">shuffle()</a></li>
max@0 6779 <li><a href="#randu_randn_standalone">randu() / randn()</a></li>
max@0 6780 </ul>
max@0 6781 </li>
max@0 6782 <br>
max@0 6783 </ul>
max@0 6784 <hr class="greyline"><br>
max@0 6785
max@0 6786 <a name="sort_index"></a>
max@0 6787 <b>sort_index(colvec, sort_type=0)</b>
max@0 6788 <br><b>sort_index(rowvec, sort_type=0)</b>
max@0 6789 <ul>
max@0 6790 <li>Return a vector which describes the sorted order of the given vector's elements
max@0 6791 (ie. it contains the indices of the given vector's elements)
max@0 6792 </li>
max@0 6793 <br>
max@0 6794 <li>The output vector must have the type <a href="#Col">uvec</a> or <a href="#Mat">umat</a>
max@0 6795 (ie. the indices are stored as unsigned integers of type <a href="#uword">uword</a>)
max@0 6796 </li>
max@0 6797 <br>
max@0 6798 <li><i>sort_type=0</i> (default) indicates an ascending sort</li>
max@0 6799 <br>
max@0 6800 <li><i>sort_type=1</i> indicates a descending sort</li>
max@0 6801 <br>
max@0 6802 <li>
max@0 6803 Examples:
max@0 6804 <ul>
max@0 6805 <pre>
max@0 6806 vec q = randu&lt;vec&gt;(10);
max@0 6807 uvec indices = sort_index(q);
max@0 6808 </pre>
max@0 6809 </ul>
max@0 6810 </li>
max@0 6811 <br>
max@0 6812 <li>
max@0 6813 See also:
max@0 6814 <ul>
max@0 6815 <li><a href="#find">find()</a></li>
max@0 6816 <li><a href="#sort">sort()</a></li>
max@0 6817 </ul>
max@0 6818 </li>
max@0 6819 <br>
max@0 6820 </ul>
max@0 6821 <hr class="greyline"><br>
max@0 6822
max@0 6823 <a name="symmat"></a>
max@0 6824 <b>symmatu(A)</b>
max@0 6825 <br><b>symmatl(A)</b>
max@0 6826 <ul>
max@0 6827 <li>
max@0 6828 <i>symmatu(A)</i>: interpret square matrix <i>A</i> as symmetric, reflecting the upper triangle to the lower triangle
max@0 6829 </li>
max@0 6830 <br>
max@0 6831 <li>
max@0 6832 <i>symmatl(A)</i>: interpret square matrix <i>A</i> as symmetric, reflecting the lower triangle to the upper triangle
max@0 6833 </li>
max@0 6834 <br>
max@0 6835 <li>
max@0 6836 If <i>A</i> is non-square, a <i>std::logic_error</i> exception is thrown
max@0 6837 </li>
max@0 6838 <br>
max@0 6839 <li>
max@0 6840 Examples:
max@0 6841 <ul>
max@0 6842 <pre>
max@0 6843 mat A = randu&lt;mat&gt;(5,5);
max@0 6844
max@0 6845 mat B = symmatu(A);
max@0 6846 mat C = symmatl(A);
max@0 6847 </pre>
max@0 6848 </ul>
max@0 6849 </li>
max@0 6850 <br>
max@0 6851 <li>See also:
max@0 6852 <ul>
max@0 6853 <li><a href="#diagmat">diagmat()</a></li>
max@0 6854 <li><a href="#trimat">trimatu() / trimatl()</a></li>
max@0 6855 <li><a href="http://en.wikipedia.org/wiki/Symmetric_matrix">Symmetric matrix in Wikipedia</a></li>
max@0 6856 </ul>
max@0 6857 </li>
max@0 6858 </ul>
max@0 6859 <br>
max@0 6860 <hr class="greyline"><br>
max@0 6861
max@0 6862 <a name="strans"></a>
max@0 6863 <b>strans(mat)</b>
max@0 6864 <br><b>strans(colvec)</b>
max@0 6865 <br><b>strans(rowvec)</b>
max@0 6866 <ul>
max@0 6867 <li>
max@0 6868 Simple matrix transpose, without taking the conjugate of the elements (complex matrices)
max@0 6869 </li>
max@0 6870 <br>
max@0 6871 <li>
max@0 6872 Use <a href="#trans">trans()</a> instead, unless you explicitly need to take the transpose of a complex matrix without taking the conjugate of the elements
max@0 6873 </li>
max@0 6874 <br>
max@0 6875 <li>See also:
max@0 6876 <ul>
max@0 6877 <li><a href="#t_st_members">.st()</a></li>
max@0 6878 <li><a href="#trans">trans()</a></li>
max@0 6879 </ul>
max@0 6880 </li>
max@0 6881 </ul>
max@0 6882 <br>
max@0 6883 <hr class="greyline"><br>
max@0 6884
max@0 6885
max@0 6886 <a name="trans"></a>
max@0 6887 <b>trans(mat)</b>
max@0 6888 <br><b>trans(colvec)</b>
max@0 6889 <br><b>trans(rowvec)</b>
max@0 6890 <ul>
max@0 6891 <li>
max@0 6892 Matrix transpose / Hermitian transpose
max@0 6893 </li>
max@0 6894 <br>
max@0 6895 <li>
max@0 6896 If a given object has real elements, a normal transpose is done
max@0 6897 </li>
max@0 6898 <br>
max@0 6899 <li>
max@0 6900 If a given object has complex elements, a Hermitian transpose is done (ie. the conjugate of the elements is taken during the transpose operation)
max@0 6901 </li>
max@0 6902 <br>
max@0 6903 <li>
max@0 6904 <b>Caveat:</b> for complex matrices, the functionality of trans() has changed in version 2.0:
max@0 6905 <ul>
max@0 6906 <li>in version 1.2.x and earlier, trans() does not take the conjugate of complex elements</li>
max@0 6907 <li>in version 1.2.x and earlier, the deprecated htrans() function is used for the Hermitian transpose</li>
max@0 6908 </ul>
max@0 6909 </li>
max@0 6910 <br>
max@0 6911 <li>
max@0 6912 Examples:
max@0 6913 <ul>
max@0 6914 <pre>mat A = randu&lt;mat&gt;(5,10);
max@0 6915 mat B = trans(A);
max@0 6916 </pre>
max@0 6917 </ul>
max@0 6918 </li>
max@0 6919 <br>
max@0 6920 <li>See also:
max@0 6921 <ul>
max@0 6922 <li><a href="#t_st_members">.t()</a></li>
max@0 6923 <li><a href="#strans">strans()</a></li>
max@0 6924 </ul>
max@0 6925 </li>
max@0 6926 </ul>
max@0 6927 <br>
max@0 6928 <hr class="greyline"><br>
max@0 6929
max@0 6930
max@0 6931 <a name="trimat"></a>
max@0 6932 <b>trimatu(A)</b>
max@0 6933 <br><b>trimatl(A)</b>
max@0 6934 <ul>
max@0 6935 <li>
max@0 6936 trimatu(A): interpret square matrix A as upper triangular
max@0 6937 </li>
max@0 6938 <br>
max@0 6939 <li>
max@0 6940 trimatl(A): interpret square matrix A as lower triangular
max@0 6941 </li>
max@0 6942 <br>
max@0 6943 <li>
max@0 6944 A <i>std::logic_error</i> exception is thrown if A is non-square
max@0 6945 </li>
max@0 6946 <br>
max@0 6947 <li>
max@0 6948 Examples:
max@0 6949 <ul>
max@0 6950 <pre>mat A = randu&lt;mat&gt;(5,5);
max@0 6951 mat U = trimatu(A);
max@0 6952 mat L = trimatl(A);
max@0 6953
max@0 6954 // tell the inv() function to look only
max@0 6955 // at the upper triangular part
max@0 6956 mat X = inv( trimatu(U) );
max@0 6957 </pre>
max@0 6958 </ul>
max@0 6959 </li>
max@0 6960 <br>
max@0 6961 <li>See also:
max@0 6962 <ul>
max@0 6963 <li><a href="#symmat">symmatu() / symmatl()</a></li>
max@0 6964 <li><a href="#diagmat">diagmat()</a></li>
max@0 6965 <li><a href="#inv">inv()</a></li>
max@0 6966 <li><a href="#solve">solve()</a></li>
max@0 6967 <li><a href="http://mathworld.wolfram.com/TriangularMatrix.html">Triangular matrix in MathWorld</a></li>
max@0 6968 <li><a href="http://en.wikipedia.org/wiki/Triangular_matrix">Triangular matrix in Wikipedia</a></li>
max@0 6969 </ul>
max@0 6970 </li>
max@0 6971 </ul>
max@0 6972 <br>
max@0 6973 <hr class="greyline">
max@0 6974
max@0 6975
max@0 6976 <hr class="greyline">
max@0 6977 <br>
max@0 6978 <br>
max@0 6979 <font size=+1><b>Decompositions, Inverses and Equation Solvers</b></font>
max@0 6980 <br>
max@0 6981 <br>
max@0 6982 <hr class="greyline">
max@0 6983 <br>
max@0 6984
max@0 6985 <a name="chol"></a>
max@0 6986 <b>R = chol(X)</b>
max@0 6987 <br><b>chol(R, X)</b>
max@0 6988 <ul>
max@0 6989 <li>
max@0 6990 Cholesky decomposition of <i>X</i>, such that <i>trans(R)*R = X</i>
max@0 6991 </li>
max@0 6992 <br>
max@0 6993 <li>
max@0 6994 X must be a symmetric, positive-definite matrix
max@0 6995 </li>
max@0 6996 <br>
max@0 6997 <li>If the decomposition fails, <i>R</i> is reset and:
max@0 6998 <ul>
max@0 6999 <li><i>chol(X)</i> throws a <i>std::runtime_error</i> exception</li>
max@0 7000 <li><i>chol(R,X)</i> returns a bool set to <i>false</i></li>
max@0 7001 </ul>
max@0 7002 </li>
max@0 7003 <br>
max@0 7004 <li>
max@0 7005 Examples:
max@0 7006 <ul>
max@0 7007 <pre>
max@0 7008 mat X = randu&lt;mat&gt;(5,5);
max@0 7009 mat Y = trans(X)*X;
max@0 7010
max@0 7011 mat R = chol(Y);
max@0 7012 </pre>
max@0 7013 </ul>
max@0 7014 </li>
max@0 7015 <br>
max@0 7016 <li>
max@0 7017 See also:
max@0 7018 <ul>
max@0 7019 <li><a href="http://mathworld.wolfram.com/CholeskyDecomposition.html">Cholesky decomposition in MathWorld</a></li>
max@0 7020 </ul>
max@0 7021 </li>
max@0 7022 </ul>
max@0 7023 <br>
max@0 7024 <hr class="greyline"><br>
max@0 7025
max@0 7026 <a name="eig_sym"></a>
max@0 7027 <b>vec eigval = eig_sym(mat X)</b>
max@0 7028 <br><b>vec eigval = eig_sym(cx_mat X)</b>
max@0 7029 <br>
max@0 7030 <br><b>eig_sym(vec eigval, mat X)</b>
max@0 7031 <br><b>eig_sym(vec eigval, cx_mat X)</b>
max@0 7032 <br>
max@0 7033 <br><b>eig_sym(vec eigval, mat eigvec, mat X)</b>
max@0 7034 <br><b>eig_sym(vec eigval, cx_mat eigvec, cx_mat X)</b>
max@0 7035 <ul>
max@0 7036 <li>
max@0 7037 Eigen decomposition of symmetric/hermitian matrix <i>X</i></li>
max@0 7038 <br>
max@0 7039 <li>The eigenvalues and corresponding eigenvectors are stored in <i>eigval</i> and <i>eigvec</i>, respectively</li>
max@0 7040 <br>
max@0 7041 <li>
max@0 7042 The eigenvalues are in ascending order
max@0 7043 </li>
max@0 7044 <br>
max@0 7045 <li>If <i>X</i> is not square, a <i>std::logic_error</i> exception is thrown</li>
max@0 7046 <br>
max@0 7047 <li>If the decomposition fails, the output objects are reset and:
max@0 7048 <ul>
max@0 7049 <li><i>eig_sym(X)</i> throws a <i>std::runtime_error</i> exception</li>
max@0 7050 <li><i>eig_sym(eigval, X)</i> and <i>eig_sym(eigval, eigvec, X)</i> return a bool set to <i>false</i></li>
max@0 7051 </ul>
max@0 7052 </li>
max@0 7053 <br>
max@0 7054 <li>There is currently no check whether <i>X</i> is symmetric</li>
max@0 7055 <br>
max@0 7056 <li>
max@0 7057 Examples:
max@0 7058 <ul>
max@0 7059 <pre>
max@0 7060 mat A = randu&lt;mat&gt;(10,10);
max@0 7061 mat B = trans(A)*A; // generate a symmetric matrix
max@0 7062
max@0 7063 vec eigval;
max@0 7064 mat eigvec;
max@0 7065
max@0 7066 eig_sym(eigval, eigvec, B);
max@0 7067 </pre>
max@0 7068 </ul>
max@0 7069 </li>
max@0 7070 <br>
max@0 7071 <li>
max@0 7072 See also:
max@0 7073 <ul>
max@0 7074 <li><a href="#eig_gen">eig_gen()</a></li>
max@0 7075 <li><a href="#svd">svd()</a></li>
max@0 7076 <li><a href="#svd_econ">svd_econ()</a></li>
max@0 7077 <li><a href="http://mathworld.wolfram.com/EigenDecomposition.html">eigen decomposition in MathWorld</a></li>
max@0 7078 </ul>
max@0 7079 </li>
max@0 7080 <br>
max@0 7081 </ul>
max@0 7082 <hr class="greyline"><br>
max@0 7083
max@0 7084 <a name="eig_gen"></a>
max@0 7085 <b>eig_gen(cx_vec eigval, cx_mat eigvec, mat X, side='r')</b>
max@0 7086 <br>
max@0 7087 <b>eig_gen(cx_vec eigval, cx_mat eigvec, cx_mat X, side='r')</b>
max@0 7088 <br>
max@0 7089 <br>
max@0 7090 <b>eig_gen(cx_vec eigval, mat l_eigvec, mat r_eigvec, mat X)</b>
max@0 7091 <br>
max@0 7092 <b>eig_gen(cx_vec eigval, cx_mat l_eigvec, cx_mat r_eigvec, cx_mat X)</b>
max@0 7093 <ul>
max@0 7094 <li>
max@0 7095 Eigen decomposition of general (non-symmetric/non-hermitian) square matrix <i>X</i></li>
max@0 7096 <br>
max@0 7097 <li>The eigenvalues and corresponding eigenvectors are stored in <i>eigval</i> and <i>eigvec</i>, respectively</li>
max@0 7098 <br>
max@0 7099 <li>
max@0 7100 For the first two forms, <i>side='r'</i> (default) specifies that right eigenvectors are computed,
max@0 7101 while <i>side='l'</i> specifies that left eigenvectors are computed
max@0 7102 </li>
max@0 7103 <br>
max@0 7104 <li>For the last two forms, both left and right eigenvectors are computed</li>
max@0 7105 <br>
max@0 7106 <li>
max@0 7107 The eigenvalues are not guaranteed to be ordered
max@0 7108 </li>
max@0 7109 <br>
max@0 7110 <li>If <i>X</i> is not square, a <i>std::logic_error</i> exception is thrown</li>
max@0 7111 <br>
max@0 7112 <li>If the decomposition fails, the output objects are reset and <i>eig_gen()</i> returns a bool set to <i>false</i></li>
max@0 7113 <br>
max@0 7114 <li>
max@0 7115 Examples:
max@0 7116 <ul>
max@0 7117 <pre>
max@0 7118 mat A = randu&lt;mat&gt;(10,10);
max@0 7119
max@0 7120 cx_vec eigval;
max@0 7121 cx_mat eigvec;
max@0 7122
max@0 7123 eig_gen(eigval, eigvec, A);
max@0 7124 </pre>
max@0 7125 </ul>
max@0 7126 </li>
max@0 7127 <br>
max@0 7128 <li>
max@0 7129 See also:
max@0 7130 <ul>
max@0 7131 <li><a href="#eig_sym">eig_sym()</a></li>
max@0 7132 <li><a href="#svd">svd()</a></li>
max@0 7133 <li><a href="#svd_econ">svd_econ()</a></li>
max@0 7134 <li><a href="http://mathworld.wolfram.com/EigenDecomposition.html">eigen decomposition in MathWorld</a></li>
max@0 7135 </ul>
max@0 7136 </li>
max@0 7137 </ul>
max@0 7138 <br>
max@0 7139 <hr class="greyline"><br>
max@0 7140
max@0 7141 <a name="inv"></a>
max@0 7142 <b>B = inv(A, slow = <i>false</i>)</b>
max@0 7143 <br>
max@0 7144 <b>inv(B, A, slow = <i>false</i>)</b>
max@0 7145 <ul>
max@0 7146 <li>
max@0 7147 Inverse of square matrix <i>A</i>
max@0 7148 </li>
max@0 7149 <br>
max@0 7150 <li>
max@0 7151 If <i>A</i> is known to be a triangular matrix,
max@0 7152 the inverse can be computed faster by explicitly marking the matrix as triangular
max@0 7153 through <a href="#trimat">trimatu()</a> or <a href="#trimat">trimatl()</a>
max@0 7154 </li>
max@0 7155 <br>
max@0 7156 <li>
max@0 7157 If <i>A</i> is known to be a positive-definite symmetric matrix,
max@0 7158 the inverse can be computed faster by explicitly marking the matrix using sympd()
max@0 7159 </li>
max@0 7160 <br>
max@0 7161 <li>
max@0 7162 If <i>A</i> is not square, a <i>std::logic_error</i> exception is thrown
max@0 7163 </li>
max@0 7164 <br>
max@0 7165 <li>If <i>A</i> appears to be singular, <i>B</i> is reset and:
max@0 7166 <ul>
max@0 7167 <li><i>inv(A)</i> throws a <i>std::runtime_error</i> exception</li>
max@0 7168 <li><i>inv(B,A)</i> returns a bool set to <i>false</i></li>
max@0 7169 </ul>
max@0 7170 </li>
max@0 7171 <br>
max@0 7172 <li>
max@0 7173 If you want to solve a system of linear equations, eg., <i>X = inv(A)*B</i>,
max@0 7174 the <a href="#solve">solve()</a> function is generally more efficient
max@0 7175 </li>
max@0 7176 <br>
max@0 7177 <li>
max@0 7178 For matrix sizes &le; 4x4, a fast inverse algorithm is used by default.
max@0 7179 In rare instances, the fast algorithm might be less precise than the standard algorithm.
max@0 7180 To force the use of the standard algorithm, set the <i>slow</i> argument to <i>true</i>
max@0 7181 </li>
max@0 7182 <br>
max@0 7183 <li>
max@0 7184 Examples:
max@0 7185 <ul>
max@0 7186 <pre>
max@0 7187 mat A = randu&lt;mat&gt;(5,5);
max@0 7188 mat B = inv(A);
max@0 7189
max@0 7190
max@0 7191 // Diagonal elements in C are set to the
max@0 7192 // reciprocal of the corresponding elements in A.
max@0 7193 // Off-diagonal elements in C are set to zero.
max@0 7194 mat C = inv( diagmat(A) );
max@0 7195
max@0 7196
max@0 7197 // tell inv() to look only at the upper triangular part of A
max@0 7198 mat D = inv( trimatu(A) );
max@0 7199
max@0 7200
max@0 7201 // tell inv() that AA is a symmetric positive definite matrix
max@0 7202 mat AA = A*trans(A);
max@0 7203 mat E = inv( sympd(AA) );
max@0 7204
max@0 7205
max@0 7206 mat44 F = randu&lt;mat&gt;(4,4);
max@0 7207
max@0 7208 mat G = inv(F); // use fast algorithm by default
max@0 7209 mat H = inv(F, true); // use slow algorithm
max@0 7210 </pre>
max@0 7211 </ul>
max@0 7212 </li>
max@0 7213 <br>
max@0 7214 <li>
max@0 7215 See also:
max@0 7216 <ul>
max@0 7217 <li><a href="#pinv">pinv()</a>
max@0 7218 <li><a href="#solve">solve()</a></li>
max@0 7219 <li><a href="#trimat">trimatu() / trimatl()</a></li>
max@0 7220 <li><a href="http://mathworld.wolfram.com/MatrixInverse.html">matrix inverse in MathWorld</a></li>
max@0 7221 <li><a href="http://en.wikipedia.org/wiki/Invertible_matrix">invertible matrix in Wikipedia</a></li>
max@0 7222 </ul>
max@0 7223 </li>
max@0 7224 </ul>
max@0 7225 <br>
max@0 7226 <hr class="greyline"><br>
max@0 7227
max@0 7228
max@0 7229
max@0 7230 <a name="lu"></a>
max@0 7231 <b>lu(mat L, mat U, mat P, mat X)</b>
max@0 7232 <br>
max@0 7233 <b>lu(mat L, mat U, mat X)</b>
max@0 7234 <ul>
max@0 7235 <li>
max@0 7236 Lower-upper decomposition (with partial pivoting) of matrix <i>X</i>
max@0 7237 </li>
max@0 7238 <br>
max@0 7239 <li>
max@0 7240 The first form provides
max@0 7241 a lower-triangular matrix <i>L</i>,
max@0 7242 an upper-triangular matrix <i>U</i>,
max@0 7243 and a permutation matrix <i>P</i>,
max@0 7244 such that <i>trans(P)*L*U&nbsp;=&nbsp;X</i>
max@0 7245 </li>
max@0 7246 <br>
max@0 7247 <li>
max@0 7248 The second form provides permuted <i>L</i> and <i>U</i>, such that <i>L*U = X</i>.
max@0 7249 Note that in this case <i>L</i> is generally not lower-triangular
max@0 7250 </li>
max@0 7251 <br>
max@0 7252 <li>
max@0 7253 If the decomposition fails, the output objects are reset and <i>lu()</i> returns a bool set to <i>false</i>
max@0 7254 </li>
max@0 7255 <br>
max@0 7256 <li>
max@0 7257 Examples:
max@0 7258 <ul>
max@0 7259 <pre>
max@0 7260 mat A = randu&lt;mat&gt;(5,5);
max@0 7261
max@0 7262 mat L, U, P;
max@0 7263
max@0 7264 lu(L, U, P, A);
max@0 7265
max@0 7266 mat B = trans(P)*L*U;
max@0 7267 </pre>
max@0 7268 </ul>
max@0 7269 </li>
max@0 7270 <br>
max@0 7271 <li>
max@0 7272 See also:
max@0 7273 <ul>
max@0 7274 <li><a href="http://en.wikipedia.org/wiki/LU_decomposition">LU decomposition in Wikipedia</a></li>
max@0 7275 <li><a href="http://mathworld.wolfram.com/LUDecomposition.html">LU decomposition in MathWorld</a></li>
max@0 7276 </ul>
max@0 7277 </li>
max@0 7278 </ul>
max@0 7279 <br>
max@0 7280 <hr class="greyline"><br>
max@0 7281
max@0 7282 <a name="pinv"></a>
max@0 7283 <b>B = pinv(A, tolerance = default)</b>
max@0 7284 <br><b>pinv(B, A, tolerance = default)</b>
max@0 7285 <ul>
max@0 7286 <li>Moore-Penrose pseudo-inverse of matrix <i>A</i></li>
max@0 7287 <br>
max@0 7288 <li>The computation is based on singular value decomposition;
max@0 7289 if the decomposition fails, <i>B</i> is reset and:
max@0 7290 <ul>
max@0 7291 <li><i>pinv(A)</i> throws a <i>std::runtime_error</i> exception</li>
max@0 7292 <li><i>pinv(B,A)</i> returns a bool set to <i>false</i></li>
max@0 7293 </ul>
max@0 7294 <br>
max@0 7295 <li>Any singular values less than <i>tol</i> are treated as zero</li>
max@0 7296 <br>
max@0 7297 <li>For matrix <i>A</i> with <i>m</i> rows and <i>n</i> columns,
max@0 7298 the default tolerance is <i>max(m,n)*norm(A)*math::eps()</i>,
max@0 7299 where <i>math::eps()</i> denotes the difference between 1 and the least value greater than 1 that is representable</li>
max@0 7300 <br>
max@0 7301 <li>
max@0 7302 Examples:
max@0 7303 <ul>
max@0 7304 <pre>
max@0 7305 mat A = randu&lt;mat&gt;(4,5);
max@0 7306 mat B = pinv(A);
max@0 7307 </pre>
max@0 7308 </ul>
max@0 7309 </li>
max@0 7310 <br>
max@0 7311 <li>
max@0 7312 See also:
max@0 7313 <ul>
max@0 7314 <li><a href="#inv">inv()</a></li>
max@0 7315 <li><a href="#math_constants">math::eps()</a></li>
max@0 7316 <li><a href="http://mathworld.wolfram.com/Pseudoinverse.html">Pseudoinverse in MathWorld</a></li>
max@0 7317 <li><a href="http://mathworld.wolfram.com/Moore-PenroseMatrixInverse.html">Moore-Penrose Matrix Inverse in MathWorld</a></li>
max@0 7318 <li><a href="http://en.wikipedia.org/wiki/Moore-Penrose_pseudoinverse">Moore-Penrose pseudoinverse in Wikipedia</a></li>
max@0 7319 </ul>
max@0 7320 </li>
max@0 7321 </ul>
max@0 7322 <br>
max@0 7323 <hr class="greyline"><br>
max@0 7324
max@0 7325 <a name="princomp"></a>
max@0 7326 <b>mat coeff = princomp(mat X)</b>
max@0 7327 <br><b>cx_mat coeff = princomp(cx_mat X)</b><br>
max@0 7328
max@0 7329 <br><b>princomp(mat coeff, mat X)</b>
max@0 7330 <br><b>princomp(cx_mat coeff, cx_mat X)</b><br>
max@0 7331
max@0 7332 <br><b>princomp(mat coeff, mat score, mat X)</b>
max@0 7333 <br><b>princomp(cx_mat coeff, cx_mat score, cx_mat X)</b><br>
max@0 7334
max@0 7335 <br><b>princomp(mat coeff, mat score, vec latent, mat X)</b>
max@0 7336 <br><b>princomp(cx_mat coeff, cx_mat score, vec latent, cx_mat X)</b><br>
max@0 7337
max@0 7338 <br><b>princomp(mat coeff, mat score, vec latent, vec tsquared, mat X)</b>
max@0 7339 <br><b>princomp(cx_mat coeff, cx_mat score, vec latent, cx_vec tsquared, cx_mat X)</b><br>
max@0 7340 <br>
max@0 7341 <ul>
max@0 7342 <li>Principal component analysis of matrix <i>X</i></li><br>
max@0 7343 <li>Each row of <i>X</i> is an observation and each column is a variable</li><br>
max@0 7344 <li>output objects:
max@0 7345 <ul>
max@0 7346 <li><i>coeff</i>: principal component coefficients</li>
max@0 7347 <li><i>score</i>: projected data</li>
max@0 7348 <li><i>latent</i>: eigenvalues of the covariance matrix of <i>X</i></li>
max@0 7349 <li><i>tsquared</i>: Hotteling's statistic for each sample</li>
max@0 7350 </ul>
max@0 7351 </li>
max@0 7352 <br>
max@0 7353 <li>The computation is based on singular value decomposition;
max@0 7354 if the decomposition fails, the output objects are reset and:
max@0 7355 <ul>
max@0 7356 <li><i>princomp(X)</i> throws a <i>std::runtime_error</i> exception</li>
max@0 7357 <li>remaining forms of <i>princomp()</i> return a bool set to <i>false</i></li>
max@0 7358 </ul>
max@0 7359 </li>
max@0 7360 <br>
max@0 7361 <li>
max@0 7362 Examples:
max@0 7363 <ul>
max@0 7364 <pre>
max@0 7365 mat A = randu&lt;mat&gt;(5,4);
max@0 7366
max@0 7367 mat coeff;
max@0 7368 mat score;
max@0 7369 vec latent;
max@0 7370 vec tsquared;
max@0 7371
max@0 7372 princomp(coeff, score, latent, tsquared, A);
max@0 7373 </pre>
max@0 7374 </ul>
max@0 7375 </li>
max@0 7376 <br>
max@0 7377 <li>
max@0 7378 See also:
max@0 7379 <ul>
max@0 7380 <li><a href="http://en.wikipedia.org/wiki/Principal_component_analysis">principal components analysis in Wikipedia</a></li>
max@0 7381 <li><a href="http://mathworld.wolfram.com/PrincipalComponentAnalysis.html">principal components analysis in MathWorld</a></li>
max@0 7382 </ul>
max@0 7383 </li>
max@0 7384 <br>
max@0 7385 </ul>
max@0 7386 <hr class="greyline"><br>
max@0 7387
max@0 7388 <a name="qr"></a>
max@0 7389 <b>qr(Q,R,X)</b>
max@0 7390 <ul>
max@0 7391 <li>
max@0 7392 Decomposition of matrix <i>X</i> into an orthogonal (<i>Q</i>) and a right triangular matrix (<i>R</i>), such that <i>Q*R = X</i>
max@0 7393 </li>
max@0 7394 <br>
max@0 7395 <li>
max@0 7396 If the decomposition fails, <i>Q</i> and <i>R</i> are reset and the function returns a bool set to <i>false</i>
max@0 7397 </li>
max@0 7398 <br>
max@0 7399 <li>
max@0 7400 Examples:
max@0 7401 <ul>
max@0 7402 <pre>
max@0 7403 mat X = randu&lt;mat&gt;(5,5);
max@0 7404 mat Q, R;
max@0 7405
max@0 7406 qr(Q,R,X);
max@0 7407 </pre>
max@0 7408 </ul>
max@0 7409 </li>
max@0 7410 <br>
max@0 7411 <li>
max@0 7412 See also:
max@0 7413 <ul>
max@0 7414 <li><a href="http://mathworld.wolfram.com/QRDecomposition.html">QR decomposition in MathWorld</a></li>
max@0 7415 <li><a href="http://octave.sourceforge.net/octave/function/qr.html">QR decomposition in Octave</a></li>
max@0 7416 </ul>
max@0 7417 </li>
max@0 7418 </ul>
max@0 7419 <br>
max@0 7420 <hr class="greyline"><br>
max@0 7421
max@0 7422 <a name="solve"></a>
max@0 7423 <b>X = solve(A, B, slow = false)</b>
max@0 7424 <br><b>solve(X, A, B, slow = false)</b>
max@0 7425 <ul>
max@0 7426 <li>Solve a system of linear equations, ie., <i>A*X = B</i>, where <i>X</i> is unknown</li>
max@0 7427 <br>
max@0 7428 <li>For a square matrix <i>A</i>, this function is conceptually the same as <i>X = inv(A)*B</i>, but is more efficient</li>
max@0 7429 <br>
max@0 7430 <li>Similar functionality to the "\" (left division operator) operator in Matlab/Octave, ie. <i>X&nbsp;=&nbsp;A&nbsp;\&nbsp;B</i></li>
max@0 7431 <br>
max@0 7432 <li>The number of rows in <i>A</i> and <i>B</i> must be the same</li>
max@0 7433 <br>
max@0 7434 <li>
max@0 7435 If <i>A</i> is known to be a triangular matrix,
max@0 7436 the solution can be computed faster by explicitly marking the matrix as triangular
max@0 7437 through <a href="#trimat">trimatu()</a> or <a href="#trimat">trimatl()</a>
max@0 7438 </li>
max@0 7439 <br>
max@0 7440 <li>
max@0 7441 If <i>A</i> is non-square (and hence also non-triangular),
max@0 7442 solve() will also try to provide approximate solutions to under-determined as well as over-determined systems</li>
max@0 7443 <br>
max@0 7444 <li>
max@0 7445 If no solution is found, <i>X</i> is reset and:
max@0 7446 <ul>
max@0 7447 <li><i>solve(A,B)</i> throws a <i>std::runtime_error</i> exception</li>
max@0 7448 <li><i>solve(X,A,B)</i> returns a bool set to <i>false</i></li>
max@0 7449 </ul>
max@0 7450 </li>
max@0 7451 <br>
max@0 7452 <li>
max@0 7453 For matrix sizes &le; 4x4, a fast algorithm is used by default.
max@0 7454 In rare instances, the fast algorithm might be less precise than the standard algorithm.
max@0 7455 To force the use of the standard algorithm, set the <i>slow</i> argument to <i>true</i>
max@0 7456 </li>
max@0 7457 <br>
max@0 7458 <li>
max@0 7459 <b>NOTE:</b> Old versions of the ATLAS library (eg.&nbsp;3.6) can corrupt memory and crash your program;
max@0 7460 the standard LAPACK library and later versions of ATLAS (eg.&nbsp;3.8) work without problems
max@0 7461 </li>
max@0 7462 <br>
max@0 7463 <li>
max@0 7464 Examples:
max@0 7465 <ul>
max@0 7466 <pre>
max@0 7467 mat A = randu&lt;mat&gt;(5,5);
max@0 7468 vec b = randu&lt;vec&gt;(5);
max@0 7469 mat B = randu&lt;mat&gt;(5,5);
max@0 7470
max@0 7471 vec x = solve(A, b);
max@0 7472 mat X = solve(A, B);
max@0 7473
max@0 7474 vec x2;
max@0 7475 solve(x2, A, b);
max@0 7476
max@0 7477 // tell solve() to look only at the upper triangular part of A
max@0 7478 mat Y = solve( trimatu(A), B );
max@0 7479
max@0 7480
max@0 7481 mat44 C = randu&lt;mat&gt;(4,4);
max@0 7482 mat44 D = randu&lt;mat&gt;(4,4);
max@0 7483
max@0 7484 mat E = solve(C, D); // use fast algorithm by default
max@0 7485 mat F = solve(C, D, true); // use slow algorithm
max@0 7486
max@0 7487 </pre>
max@0 7488 </ul>
max@0 7489 </li>
max@0 7490 <br>
max@0 7491 <li>
max@0 7492 See also:
max@0 7493 <ul>
max@0 7494 <li><a href="#inv">inv()</a></li>
max@0 7495 <li><a href="#syl">syl()</a></li>
max@0 7496 <li><a href="#trimat">trimatu() / trimatl()</a></li>
max@0 7497 <li><a href="http://mathworld.wolfram.com/LinearSystemofEquations.html">linear system of equations in MathWorld</a></li>
max@0 7498 <li><a href="http://en.wikipedia.org/wiki/Linear_system_of_equations">system of linear equations in Wikipedia</a></li>
max@0 7499 </ul>
max@0 7500 </li>
max@0 7501 <br>
max@0 7502 </ul>
max@0 7503 <hr class="greyline"><br>
max@0 7504
max@0 7505
max@0 7506 <a name="svd"></a>
max@0 7507 <b>vec s = svd(mat X)</b>
max@0 7508 <br><b>vec s = svd(cx_mat X)</b>
max@0 7509 <br>
max@0 7510 <br><b>svd(vec s, mat X)</b>,
max@0 7511 <br><b>svd(vec s, cx_mat X)</b>
max@0 7512 <br>
max@0 7513 <br><b>svd(mat U, vec s, mat V, mat X)</b>
max@0 7514 <br><b>svd(cx_mat U, vec s, cx_mat V, cx_mat X)</b>
max@0 7515 <ul>
max@0 7516 <li>
max@0 7517 The single and two argument versions compute the singular values of <i>X</i>
max@0 7518 </li>
max@0 7519 <br>
max@0 7520 <li>
max@0 7521 The four argument version computes the full singular value decomposition of <i>X</i>
max@0 7522 </li>
max@0 7523 <br>
max@0 7524 <li>If <i>X</i> is square, it can be reconstructed using <i>X = U*diagmat(s)*trans(V)</i>
max@0 7525 </li>
max@0 7526 <br>
max@0 7527 <li>
max@0 7528 The singular values are in descending order
max@0 7529 </li>
max@0 7530 <br>
max@0 7531 <li>
max@0 7532 If the decomposition fails, the output objects are reset and:
max@0 7533 <ul>
max@0 7534 <li><i>svd(X)</i> throws a <i>std::runtime_error</i> exception</li>
max@0 7535 <li><i>svd(s,X)</i> and <i>svd(U,s,V,X)</i> return a bool set to <i>false</i></li>
max@0 7536 </ul>
max@0 7537 </li>
max@0 7538 <br>
max@0 7539 <li>
max@0 7540 <b>NOTE:</b> Old versions of the ATLAS library (eg.&nbsp;3.6) can corrupt memory and crash your program;
max@0 7541 the standard LAPACK library and later versions of ATLAS (eg.&nbsp;3.8) work without problems
max@0 7542 </li>
max@0 7543 <br>
max@0 7544 <li>
max@0 7545 Examples:
max@0 7546 <ul>
max@0 7547 <pre>
max@0 7548 mat X = randu&lt;mat&gt;(5,5);
max@0 7549
max@0 7550 mat U;
max@0 7551 vec s;
max@0 7552 mat V;
max@0 7553 svd(U,s,V,X);
max@0 7554 </pre>
max@0 7555 </ul>
max@0 7556 </li>
max@0 7557 <br>
max@0 7558 <li>
max@0 7559 See also:
max@0 7560 <ul>
max@0 7561 <li><a href="#svd_econ">svd_econ()</a></li>
max@0 7562 <li><a href="#eig_gen">eig_gen()</a></li>
max@0 7563 <li><a href="#eig_sym">eig_sym()</a></li>
max@0 7564 <li><a href="http://en.wikipedia.org/wiki/Singular_value_decomposition">singular value decomposition in Wikipedia</a></li>
max@0 7565 <li><a href="http://mathworld.wolfram.com/SingularValueDecomposition.html">singular value decomposition in MathWorld</a></li>
max@0 7566 </ul>
max@0 7567 </li>
max@0 7568 </ul>
max@0 7569 <br>
max@0 7570 <hr class="greyline">
max@0 7571 <br>
max@0 7572
max@0 7573 <a name="svd_econ"></a>
max@0 7574 <b>svd_econ(mat U, vec s, mat V, mat X, mode = 'b')</b>
max@0 7575 <br><b>svd_econ(cx_mat U, vec s, cx_mat V, cx_mat X, mode = 'b')</b>
max@0 7576 <ul>
max@0 7577 <li>
max@0 7578 Economical singular value decomposition of <i>X</i>
max@0 7579 </li>
max@0 7580 <br>
max@0 7581 <li>
max@0 7582 mode is one of:
max@0 7583 <ul>
max@0 7584 <li><i>'l'</i>: compute only left singular vectors</li>
max@0 7585 <li><i>'r'</i>: compute only right singular vectors</li>
max@0 7586 <li><i>'b'</i>: compute both left and right singular vectors (default)</li>
max@0 7587 </ul>
max@0 7588 </li>
max@0 7589 <br>
max@0 7590 <li>
max@0 7591 The singular values are in descending order
max@0 7592 </li>
max@0 7593 <br>
max@0 7594 <li>
max@0 7595 If the decomposition fails, the output objects are reset and bool set to <i>false</i> is returned
max@0 7596 </li>
max@0 7597 <br>
max@0 7598 <li>
max@0 7599 Examples:
max@0 7600 <ul>
max@0 7601 <pre>
max@0 7602 mat X = randu&lt;mat&gt;(4,5);
max@0 7603
max@0 7604 mat U;
max@0 7605 vec s;
max@0 7606 mat V;
max@0 7607 svd_econ(U, s, V, X, 'l');
max@0 7608 </pre>
max@0 7609 </ul>
max@0 7610 </li>
max@0 7611 <br>
max@0 7612 <li>
max@0 7613 See also:
max@0 7614 <ul>
max@0 7615 <li><a href="#svd">svd()</a></li>
max@0 7616 <li><a href="#eig_gen">eig_gen()</a></li>
max@0 7617 <li><a href="#eig_sym">eig_sym()</a></li>
max@0 7618 <li><a href="http://en.wikipedia.org/wiki/Singular_value_decomposition">singular value decomposition in Wikipedia</a></li>
max@0 7619 <li><a href="http://mathworld.wolfram.com/SingularValueDecomposition.html">singular value decomposition in MathWorld</a></li>
max@0 7620 </ul>
max@0 7621 </li>
max@0 7622 </ul>
max@0 7623 <br>
max@0 7624 <hr class="greyline">
max@0 7625 <br>
max@0 7626
max@0 7627 <a name="syl"></a>
max@0 7628 <b>X = syl(A, B, C)</b>
max@0 7629 <br><b>syl(X, A, B, C)</b>
max@0 7630 <ul>
max@0 7631 <li>Solve the Sylvester equation, ie., <i>AX + XB + C = 0</i>, where <i>X</i> is unknown.</li>
max@0 7632 <br>
max@0 7633 <li>Matrices <i>A</i>, <i>B</i> and <i>C</i> must be square sized.</li>
max@0 7634 <br>
max@0 7635 <li>
max@0 7636 If no solution is found, <i>X</i> is reset and:
max@0 7637 <ul>
max@0 7638 <li><i>syl(A,B,C)</i> throws a <i>std::runtime_error</i> exception</li>
max@0 7639 <li><i>svd(X,A,B,C)</i> returns a bool set to <i>false</i></li>
max@0 7640 </ul>
max@0 7641 </li>
max@0 7642 <br>
max@0 7643 <li>
max@0 7644 Examples:
max@0 7645 <ul>
max@0 7646 <pre>
max@0 7647 mat A = randu&lt;mat&gt;(5,5);
max@0 7648 mat B = randu&lt;mat&gt;(5,5);
max@0 7649 mat C = randu&lt;mat&gt;(5,5);
max@0 7650
max@0 7651 mat X1 = syl(A, B, C);
max@0 7652
max@0 7653 mat X2;
max@0 7654 syl(X2, A, B, C);
max@0 7655 </pre>
max@0 7656 </ul>
max@0 7657 </li>
max@0 7658 <br>
max@0 7659 <li>
max@0 7660 See also:
max@0 7661 <ul>
max@0 7662 <li><a href="#solve">solve()</a></li>
max@0 7663 <li><a href="http://en.wikipedia.org/wiki/Sylvester_equation">Sylvester equation in Wikipedia</a></li>
max@0 7664 </ul>
max@0 7665 </li>
max@0 7666 <br>
max@0 7667 </ul>
max@0 7668 <hr class="greyline">
max@0 7669
max@0 7670
max@0 7671 <hr class="greyline">
max@0 7672 <br>
max@0 7673 <br>
max@0 7674 <font size=+1><b>Miscellaneous</b></font>
max@0 7675 <br>
max@0 7676 <br>
max@0 7677 <hr class="greyline">
max@0 7678 <br>
max@0 7679
max@0 7680 <a name="is_finite_standalone"></a>
max@0 7681 <b>is_finite(X)</b>
max@0 7682 <ul>
max@0 7683 <li>
max@0 7684 Returns <i>true</i> if all elements in <i>X</i> are finite
max@0 7685 </li>
max@0 7686 <br>
max@0 7687 <li>
max@0 7688 Returns <i>false</i> if at least one element in <i>X</i> is non-finite (&plusmn;infinity or NaN)
max@0 7689 </li>
max@0 7690 <br>
max@0 7691 <li>
max@0 7692 <i>X</i> can be a scalar (eg. <i>double</i>), vector, matrix or cube
max@0 7693 </li>
max@0 7694 <br>
max@0 7695 <li>
max@0 7696 Examples:
max@0 7697 <ul>
max@0 7698 <pre>
max@0 7699 mat A = randu&lt;mat&gt;(5,5);
max@0 7700 mat B = randu&lt;mat&gt;(5,5);
max@0 7701
max@0 7702 B(1,1) = math::nan();
max@0 7703
max@0 7704 cout &lt;&lt; is_finite(A) &lt;&lt; endl;
max@0 7705 cout &lt;&lt; is_finite(B) &lt;&lt; endl;
max@0 7706
max@0 7707 cout &lt;&lt; is_finite( 0.123456789 ) &lt;&lt; endl;
max@0 7708 cout &lt;&lt; is_finite( math::nan() ) &lt;&lt; endl;
max@0 7709 cout &lt;&lt; is_finite( math::inf() ) &lt;&lt; endl;
max@0 7710 </pre>
max@0 7711 </ul>
max@0 7712 </li>
max@0 7713 <br>
max@0 7714 <li>
max@0 7715 See also:
max@0 7716 <ul>
max@0 7717 <li><a href="#math_constants">math::nan()</a></li>
max@0 7718 <li><a href="#math_constants">math::inf()</a></li>
max@0 7719 <li><a href="#is_finite">.is_finite()</a> (member function of <i>Mat</i> and <i>Cube</i>)</li>
max@0 7720 </ul>
max@0 7721 </li>
max@0 7722 <br>
max@0 7723 </ul>
max@0 7724 <hr class="greyline"><br>
max@0 7725
max@0 7726 <a name="logging"></a>
max@0 7727 <b>logging of warnings and errors</b>
max@0 7728 <br>
max@0 7729 <br>
max@0 7730 <b>set_stream_err1(user_stream)</b><br>
max@0 7731 <b>set_stream_err2(user_stream)</b><br>
max@0 7732 <br>
max@0 7733 <b>std::ostream&amp; x = get_stream_err1()</b>
max@0 7734 <br>
max@0 7735 <b>std::ostream&amp; x = get_stream_err2()</b>
max@0 7736 <br>
max@0 7737 <ul>
max@0 7738 <li>
max@0 7739 By default, Armadillo prints warnings and messages associated with <i>std::logic_error</i> and <i>std::runtime_error</i> exceptions to the <i>std::cout</i> stream
max@0 7740 </li>
max@0 7741 <br>
max@0 7742 <li><b>set_stream_err1()</b>: change the stream for messages associated with <i>std::logic_error</i> exceptions (eg. out of bounds accesses)</li>
max@0 7743 <br>
max@0 7744 <li><b>set_stream_err2()</b>: change the stream for warnings and messages associated with <i>std::runtime_error</i> exceptions (eg. failed decompositions)</li>
max@0 7745 <br>
max@0 7746 <li><b>get_stream_err1()</b>: get a reference to the stream for messages associated with <i>std::logic_error</i> exceptions</li>
max@0 7747 <br>
max@0 7748 <li><b>get_stream_err2()</b>: get a reference to the stream for warnings and messages associated with <i>std::runtime_error</i> exceptions</li>
max@0 7749 <br>
max@0 7750 <li>
max@0 7751 Examples:
max@0 7752 <ul>
max@0 7753 <pre>
max@0 7754 // print "hello" to the current err1 stream
max@0 7755 get_stream_err1() &lt;&lt; "hello" &lt;&lt; endl;
max@0 7756
max@0 7757 // change the err2 stream to be a file
max@0 7758 ofstream f("my_log.txt");
max@0 7759 set_stream_err2(f);
max@0 7760
max@0 7761 // trying to invert a singular matrix
max@0 7762 // will print a message to the err2 stream
max@0 7763 // and throw an exception
max@0 7764 mat X = zeros&lt;mat&gt;(5,5);
max@0 7765 mat Y = inv(X);
max@0 7766
max@0 7767 // disable messages being printed to the err2 stream
max@0 7768 std::ostream nullstream(0);
max@0 7769 set_stream_err2(nullstream);
max@0 7770 </pre>
max@0 7771 </ul>
max@0 7772 </li>
max@0 7773 <br>
max@0 7774 <li>
max@0 7775 <b>Caveat</b>: set_stream_err1() and set_stream_err2() will not change the stream used by .print()
max@0 7776 </li>
max@0 7777 <br>
max@0 7778 <li>
max@0 7779 See also:
max@0 7780 <ul>
max@0 7781 <li><a href="#print">.print()</a></li>
max@0 7782 <li><a href="http://cplusplus.com/reference/iostream/cout/">std::cout</a></li>
max@0 7783 <li><a href="http://cplusplus.com/reference/iostream/ostream/">std::ostream</a></li>
max@0 7784 <li><a href="http://cplusplus.com/reference/std/stdexcept/logic_error/">std::logic_error</a></li>
max@0 7785 <li><a href="http://cplusplus.com/reference/std/stdexcept/runtime_error/">std::runtime_error</a></li>
max@0 7786 <li><a href="http://cplusplus.com/doc/tutorial/exceptions/">tutorial on exceptions</a></li>
max@0 7787 </ul>
max@0 7788 </li>
max@0 7789 <br>
max@0 7790 </ul>
max@0 7791 <hr class="greyline">
max@0 7792
max@0 7793
max@0 7794
max@0 7795 <a name="math_constants"></a>
max@0 7796 <b>math constants (pi, e, euler, gratio, sqrt2, eps, log_min, log_max, nan, inf)</b>
max@0 7797 <br>
max@0 7798 <ul>
max@0 7799 <li>
max@0 7800 Collection of constants, with their precision and/or value dependant on the numerical type and/or machine used.
max@0 7801 </li>
max@0 7802 <br>
max@0 7803 <li>
max@0 7804 The constants are stored as static functions in the <i>Math&lt;type&gt;</i> class,
max@0 7805 where <i>type</i> is either <i>float</i> or <i>double</i>.
max@0 7806 </li>
max@0 7807 <br>
max@0 7808 <li>
max@0 7809 For convenience, <i>Math&lt;float&gt;</i> has been typedefed as <i>fmath</i>,
max@0 7810 while <i>Math&lt;double&gt;</i> has been typedefed as <i>math</i>.
max@0 7811 </li>
max@0 7812 <br>
max@0 7813 <li>
max@0 7814 Meaning of the constants:
max@0 7815 <ul>
max@0 7816 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 7817 <tbody>
max@0 7818 <tr>
max@0 7819 <td style="vertical-align: top;">
max@0 7820 math::pi()
max@0 7821 </td>
max@0 7822 <td style="vertical-align: top;">
max@0 7823 &nbsp;
max@0 7824 </td>
max@0 7825 <td style="vertical-align: top;">
max@0 7826 &pi;, the ratio of any circle's circumference to its diameter
max@0 7827 </td>
max@0 7828 </tr>
max@0 7829 <tr>
max@0 7830 <td style="vertical-align: top;">
max@0 7831 math::e()
max@0 7832 </td>
max@0 7833 <td style="vertical-align: top;">
max@0 7834 &nbsp;
max@0 7835 </td>
max@0 7836 <td style="vertical-align: top;">
max@0 7837 base of the natural logarithm
max@0 7838 </td>
max@0 7839 </tr>
max@0 7840 <tr>
max@0 7841 <td style="vertical-align: top;">
max@0 7842 math::euler()
max@0 7843 </td>
max@0 7844 <td style="vertical-align: top;">
max@0 7845 &nbsp;
max@0 7846 </td>
max@0 7847 <td style="vertical-align: top;">
max@0 7848 Euler's constant, aka Euler-Mascheroni constant
max@0 7849 </td>
max@0 7850 </tr>
max@0 7851 <tr>
max@0 7852 <td style="vertical-align: top;">
max@0 7853 math::gratio()
max@0 7854 </td>
max@0 7855 <td style="vertical-align: top;">
max@0 7856 &nbsp;
max@0 7857 </td>
max@0 7858 <td style="vertical-align: top;">
max@0 7859 golden ratio
max@0 7860 </td>
max@0 7861 </tr>
max@0 7862 <tr>
max@0 7863 <td style="vertical-align: top;">
max@0 7864 math::sqrt2()
max@0 7865 </td>
max@0 7866 <td style="vertical-align: top;">
max@0 7867 &nbsp;
max@0 7868 </td>
max@0 7869 <td style="vertical-align: top;">
max@0 7870 square root of 2
max@0 7871 </td>
max@0 7872 </tr>
max@0 7873 <tr>
max@0 7874 <td style="vertical-align: top;">
max@0 7875 math::eps()
max@0 7876 </td>
max@0 7877 <td style="vertical-align: top;">
max@0 7878 &nbsp;
max@0 7879 </td>
max@0 7880 <td style="vertical-align: top;">
max@0 7881 the difference between 1 and the least value greater than 1 that is representable
max@0 7882 </td>
max@0 7883 </tr>
max@0 7884 <tr>
max@0 7885 <td style="vertical-align: top;">
max@0 7886 math::log_min()
max@0 7887 </td>
max@0 7888 <td style="vertical-align: top;">
max@0 7889 &nbsp;
max@0 7890 </td>
max@0 7891 <td style="vertical-align: top;">
max@0 7892 log of minimum non-zero value
max@0 7893 </td>
max@0 7894 </tr>
max@0 7895 <tr>
max@0 7896 <td style="vertical-align: top;">
max@0 7897 math::log_max()
max@0 7898 </td>
max@0 7899 <td style="vertical-align: top;">
max@0 7900 &nbsp;
max@0 7901 </td>
max@0 7902 <td style="vertical-align: top;">
max@0 7903 log of maximum value
max@0 7904 </td>
max@0 7905 </tr>
max@0 7906 <tr>
max@0 7907 <td style="vertical-align: top;">
max@0 7908 math::nan()
max@0 7909 </td>
max@0 7910 <td style="vertical-align: top;">
max@0 7911 &nbsp;
max@0 7912 </td>
max@0 7913 <td style="vertical-align: top;">
max@0 7914 &ldquo;not a number&rdquo; (NaN)
max@0 7915 </td>
max@0 7916 </tr>
max@0 7917 <tr>
max@0 7918 <td style="vertical-align: top;">
max@0 7919 math::inf()
max@0 7920 </td>
max@0 7921 <td style="vertical-align: top;">
max@0 7922 &nbsp;
max@0 7923 </td>
max@0 7924 <td style="vertical-align: top;">
max@0 7925 infinity
max@0 7926 </td>
max@0 7927 </tr>
max@0 7928 </tbody>
max@0 7929 </table>
max@0 7930 </ul>
max@0 7931 </li>
max@0 7932 <br>
max@0 7933 <li>
max@0 7934 <b>Caveat:</b>
max@0 7935 nan() is not equal to anything, even itself;
max@0 7936 if you wish to check whether a given number <i>x</i> is finite,
max@0 7937 use <a href="#is_finite_standalone">is_finite</a>(<i>x</i>).
max@0 7938 </li>
max@0 7939 <br>
max@0 7940 <li>
max@0 7941 Examples:
max@0 7942 <ul>
max@0 7943 <pre>
max@0 7944 cout &lt;&lt; "2.0 * pi = " &lt;&lt; 2.0 * math::pi() &lt;&lt; endl;
max@0 7945
max@0 7946 cout &lt;&lt; "log_max for floats = ";
max@0 7947 cout &lt;&lt; fmath::log_max() &lt;&lt; endl;
max@0 7948
max@0 7949 cout &lt;&lt; "log_max for doubles = ";
max@0 7950 cout &lt;&lt; math::log_max() &lt;&lt; endl;
max@0 7951 </pre>
max@0 7952 </ul>
max@0 7953 </li>
max@0 7954 <li>
max@0 7955 See also:
max@0 7956 <ul>
max@0 7957 <li><a href="#phys_constants">physical constants</a></li>
max@0 7958 <li><a href="#is_finite_standalone">is_finite()</a></li>
max@0 7959 <li><a href="http://en.wikipedia.org/wiki/NaN">Wikipedia entry for NaN</a></li>
max@0 7960 <li><a href="http://cplusplus.com/reference/std/limits/numeric_limits/">std::numeric_limits</a></li>
max@0 7961 </ul>
max@0 7962 </li>
max@0 7963 </ul>
max@0 7964 <br>
max@0 7965 <hr class="greyline"><br>
max@0 7966
max@0 7967 <a name="phys_constants"></a>
max@0 7968 <b>physical constants (speed of light, etc)</b>
max@0 7969 <br>
max@0 7970 <ul>
max@0 7971 <li>
max@0 7972 Collection of fundamental physical constants,
max@0 7973 mainly taken from
max@0 7974 <a href="http://physics.nist.gov/cuu/Constants">NIST</a>
max@0 7975 and some from
max@0 7976 <a href="http://www.wolframalpha.com">WolframAlpha</a>
max@0 7977 on 2009-06-23.
max@0 7978 </li>
max@0 7979 <br>
max@0 7980 <li>
max@0 7981 Constants from NIST are in turn sourced from the <a href="http://physics.nist.gov/cuu/Constants/papers.html">2006 CODATA values</a>.
max@0 7982 </li>
max@0 7983 <br>
max@0 7984 <li>
max@0 7985 The constants are stored as static functions in the <i>Phy&lt;type&gt;</i> class,
max@0 7986 where <i>type</i> is either <i>float</i> or <i>double</i>.
max@0 7987 </li>
max@0 7988 <br>
max@0 7989 <li>
max@0 7990 For convenience, <i>Phy&lt;float&gt;</i> has been typedefed as <i>fphy</i>,
max@0 7991 while <i>Phy&lt;double&gt;</i> has been typedefed as <i>phy</i>.
max@0 7992 </li>
max@0 7993 <br>
max@0 7994 <li>
max@0 7995 Meaning of the constants:
max@0 7996 <ul>
max@0 7997 <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
max@0 7998 <tbody>
max@0 7999 <tr>
max@0 8000 <td style="vertical-align: top;">
max@0 8001 phy::m_u()
max@0 8002 </td>
max@0 8003 <td style="vertical-align: top;">
max@0 8004 &nbsp;
max@0 8005 </td>
max@0 8006 <td style="vertical-align: top;">
max@0 8007 atomic mass constant (in kg)
max@0 8008 </td>
max@0 8009 </tr>
max@0 8010 <tr>
max@0 8011 <td style="vertical-align: top;">
max@0 8012 phy::N_A()
max@0 8013 </td>
max@0 8014 <td style="vertical-align: top;">
max@0 8015 &nbsp;
max@0 8016 </td>
max@0 8017 <td style="vertical-align: top;">
max@0 8018 Avogadro constant
max@0 8019 </td>
max@0 8020 </tr>
max@0 8021 <tr>
max@0 8022 <td style="vertical-align: top;">
max@0 8023 phy::k()
max@0 8024 </td>
max@0 8025 <td style="vertical-align: top;">
max@0 8026 &nbsp;
max@0 8027 </td>
max@0 8028 <td style="vertical-align: top;">
max@0 8029 Boltzmann constant (in joules per kelvin)
max@0 8030 </td>
max@0 8031 </tr>
max@0 8032 <tr>
max@0 8033 <td style="vertical-align: top;">
max@0 8034 phy::k_evk()
max@0 8035 </td>
max@0 8036 <td style="vertical-align: top;">
max@0 8037 &nbsp;
max@0 8038 </td>
max@0 8039 <td style="vertical-align: top;">
max@0 8040 Boltzmann constant (in eV/K)
max@0 8041 </td>
max@0 8042 </tr>
max@0 8043 <tr>
max@0 8044 <td style="vertical-align: top;">
max@0 8045 phy::a_0()
max@0 8046 </td>
max@0 8047 <td style="vertical-align: top;">
max@0 8048 &nbsp;
max@0 8049 </td>
max@0 8050 <td style="vertical-align: top;">
max@0 8051 Bohr radius (in meters)
max@0 8052 </td>
max@0 8053 </tr>
max@0 8054 <tr>
max@0 8055 <td style="vertical-align: top;">
max@0 8056 phy::mu_B()
max@0 8057 </td>
max@0 8058 <td style="vertical-align: top;">
max@0 8059 &nbsp;
max@0 8060 </td>
max@0 8061 <td style="vertical-align: top;">
max@0 8062 Bohr magneton
max@0 8063 </td>
max@0 8064 </tr>
max@0 8065 <tr>
max@0 8066 <td style="vertical-align: top;">
max@0 8067 phy::Z_0()
max@0 8068 </td>
max@0 8069 <td style="vertical-align: top;">
max@0 8070 &nbsp;
max@0 8071 </td>
max@0 8072 <td style="vertical-align: top;">
max@0 8073 characteristic impedance of vacuum (in ohms)
max@0 8074 </td>
max@0 8075 </tr>
max@0 8076 <tr>
max@0 8077 <td style="vertical-align: top;">
max@0 8078 phy::G_0()
max@0 8079 </td>
max@0 8080 <td style="vertical-align: top;">
max@0 8081 &nbsp;
max@0 8082 </td>
max@0 8083 <td style="vertical-align: top;">
max@0 8084 conductance quantum (in siemens)
max@0 8085 </td>
max@0 8086 </tr>
max@0 8087 <tr>
max@0 8088 <td style="vertical-align: top;">
max@0 8089 phy::k_e()
max@0 8090 </td>
max@0 8091 <td style="vertical-align: top;">
max@0 8092 &nbsp;
max@0 8093 </td>
max@0 8094 <td style="vertical-align: top;">
max@0 8095 Coulomb's constant (in meters per farad)
max@0 8096 </td>
max@0 8097 </tr>
max@0 8098 <tr>
max@0 8099 <td style="vertical-align: top;">
max@0 8100 phy::eps_0()
max@0 8101 </td>
max@0 8102 <td style="vertical-align: top;">
max@0 8103 &nbsp;
max@0 8104 </td>
max@0 8105 <td style="vertical-align: top;">
max@0 8106 electric constant (in farads per meter)
max@0 8107 </td>
max@0 8108 </tr>
max@0 8109 <tr>
max@0 8110 <td style="vertical-align: top;">
max@0 8111 phy::m_e()
max@0 8112 </td>
max@0 8113 <td style="vertical-align: top;">
max@0 8114 &nbsp;
max@0 8115 </td>
max@0 8116 <td style="vertical-align: top;">
max@0 8117 electron mass (in kg)
max@0 8118 </td>
max@0 8119 </tr>
max@0 8120 <tr>
max@0 8121 <td style="vertical-align: top;">
max@0 8122 phy::eV()
max@0 8123 </td>
max@0 8124 <td style="vertical-align: top;">
max@0 8125 &nbsp;
max@0 8126 </td>
max@0 8127 <td style="vertical-align: top;">
max@0 8128 electron volt (in joules)
max@0 8129 </td>
max@0 8130 </tr>
max@0 8131 <tr>
max@0 8132 <td style="vertical-align: top;">
max@0 8133 phy::e()
max@0 8134 </td>
max@0 8135 <td style="vertical-align: top;">
max@0 8136 &nbsp;
max@0 8137 </td>
max@0 8138 <td style="vertical-align: top;">
max@0 8139 elementary charge (in coulombs)
max@0 8140 </td>
max@0 8141 </tr>
max@0 8142 <tr>
max@0 8143 <td style="vertical-align: top;">
max@0 8144 phy::F()
max@0 8145 </td>
max@0 8146 <td style="vertical-align: top;">
max@0 8147 &nbsp;
max@0 8148 </td>
max@0 8149 <td style="vertical-align: top;">
max@0 8150 Faraday constant (in coulombs)
max@0 8151 </td>
max@0 8152 </tr>
max@0 8153 <tr>
max@0 8154 <td style="vertical-align: top;">
max@0 8155 phy::alpha()
max@0 8156 </td>
max@0 8157 <td style="vertical-align: top;">
max@0 8158 &nbsp;
max@0 8159 </td>
max@0 8160 <td style="vertical-align: top;">
max@0 8161 fine-structure constant
max@0 8162 </td>
max@0 8163 </tr>
max@0 8164 <tr>
max@0 8165 <td style="vertical-align: top;">
max@0 8166 phy::alpha_inv()
max@0 8167 </td>
max@0 8168 <td style="vertical-align: top;">
max@0 8169 &nbsp;
max@0 8170 </td>
max@0 8171 <td style="vertical-align: top;">
max@0 8172 inverse fine-structure constant
max@0 8173 </td>
max@0 8174 </tr>
max@0 8175 <tr>
max@0 8176 <td style="vertical-align: top;">
max@0 8177 phy::K_J()
max@0 8178 </td>
max@0 8179 <td style="vertical-align: top;">
max@0 8180 &nbsp;
max@0 8181 </td>
max@0 8182 <td style="vertical-align: top;">
max@0 8183 Josephson constant
max@0 8184 </td>
max@0 8185 </tr>
max@0 8186 <tr>
max@0 8187 <td style="vertical-align: top;">
max@0 8188 phy::mu_0()
max@0 8189 </td>
max@0 8190 <td style="vertical-align: top;">
max@0 8191 &nbsp;
max@0 8192 </td>
max@0 8193 <td style="vertical-align: top;">
max@0 8194 magnetic constant (in henries per meter)
max@0 8195 </td>
max@0 8196 </tr>
max@0 8197 <tr>
max@0 8198 <td style="vertical-align: top;">
max@0 8199 phy::phi_0()
max@0 8200 </td>
max@0 8201 <td style="vertical-align: top;">
max@0 8202 &nbsp;
max@0 8203 </td>
max@0 8204 <td style="vertical-align: top;">
max@0 8205 magnetic flux quantum (in webers)
max@0 8206 </td>
max@0 8207 </tr>
max@0 8208 <tr>
max@0 8209 <td style="vertical-align: top;">
max@0 8210 phy::R()
max@0 8211 </td>
max@0 8212 <td style="vertical-align: top;">
max@0 8213 &nbsp;
max@0 8214 </td>
max@0 8215 <td style="vertical-align: top;">
max@0 8216 molar gas constant (in joules per mole kelvin)
max@0 8217 </td>
max@0 8218 </tr>
max@0 8219 <tr>
max@0 8220 <td style="vertical-align: top;">
max@0 8221 phy::G()
max@0 8222 </td>
max@0 8223 <td style="vertical-align: top;">
max@0 8224 &nbsp;
max@0 8225 </td>
max@0 8226 <td style="vertical-align: top;">
max@0 8227 Newtonian constant of gravitation (in newton square meters per kilogram squared)
max@0 8228 </td>
max@0 8229 </tr>
max@0 8230 <tr>
max@0 8231 <td style="vertical-align: top;">
max@0 8232 phy::h()
max@0 8233 </td>
max@0 8234 <td style="vertical-align: top;">
max@0 8235 &nbsp;
max@0 8236 </td>
max@0 8237 <td style="vertical-align: top;">
max@0 8238 Planck constant (in joule seconds)
max@0 8239 </td>
max@0 8240 </tr>
max@0 8241 <tr>
max@0 8242 <td style="vertical-align: top;">
max@0 8243 phy::h_bar()
max@0 8244 </td>
max@0 8245 <td style="vertical-align: top;">
max@0 8246 &nbsp;
max@0 8247 </td>
max@0 8248 <td style="vertical-align: top;">
max@0 8249 Planck constant over 2 pi, aka reduced Planck constant (in joule seconds)
max@0 8250 </td>
max@0 8251 </tr>
max@0 8252 <tr>
max@0 8253 <td style="vertical-align: top;">
max@0 8254 phy::m_p()
max@0 8255 </td>
max@0 8256 <td style="vertical-align: top;">
max@0 8257 &nbsp;
max@0 8258 </td>
max@0 8259 <td style="vertical-align: top;">
max@0 8260 proton mass (in kg)
max@0 8261 </td>
max@0 8262 </tr>
max@0 8263 <tr>
max@0 8264 <td style="vertical-align: top;">
max@0 8265 phy::R_inf()
max@0 8266 </td>
max@0 8267 <td style="vertical-align: top;">
max@0 8268 &nbsp;
max@0 8269 </td>
max@0 8270 <td style="vertical-align: top;">
max@0 8271 Rydberg constant (in reciprocal meters)
max@0 8272 </td>
max@0 8273 </tr>
max@0 8274 <tr>
max@0 8275 <td style="vertical-align: top;">
max@0 8276 phy::c_0()
max@0 8277 </td>
max@0 8278 <td style="vertical-align: top;">
max@0 8279 &nbsp;
max@0 8280 </td>
max@0 8281 <td style="vertical-align: top;">
max@0 8282 speed of light in vacuum (in meters per second)
max@0 8283 </td>
max@0 8284 </tr>
max@0 8285 <tr>
max@0 8286 <td style="vertical-align: top;">
max@0 8287 phy::sigma()
max@0 8288 </td>
max@0 8289 <td style="vertical-align: top;">
max@0 8290 &nbsp;
max@0 8291 </td>
max@0 8292 <td style="vertical-align: top;">
max@0 8293 Stefan-Boltzmann constant
max@0 8294 </td>
max@0 8295 </tr>
max@0 8296 <tr>
max@0 8297 <td style="vertical-align: top;">
max@0 8298 phy::R_k()
max@0 8299 </td>
max@0 8300 <td style="vertical-align: top;">
max@0 8301 &nbsp;
max@0 8302 </td>
max@0 8303 <td style="vertical-align: top;">
max@0 8304 von Klitzing constant (in ohms)
max@0 8305 </td>
max@0 8306 </tr>
max@0 8307 <tr>
max@0 8308 <td style="vertical-align: top;">
max@0 8309 phy::b()
max@0 8310 </td>
max@0 8311 <td style="vertical-align: top;">
max@0 8312 &nbsp;
max@0 8313 </td>
max@0 8314 <td style="vertical-align: top;">
max@0 8315 Wien wavelength displacement law constant
max@0 8316 </td>
max@0 8317 </tr>
max@0 8318 </tbody>
max@0 8319 </table>
max@0 8320 </ul>
max@0 8321 </li>
max@0 8322 <br>
max@0 8323 <li>
max@0 8324 Examples:
max@0 8325 <ul>
max@0 8326 <pre>
max@0 8327 cout &lt;&lt; "speed of light = " &lt;&lt; phy::c_0() &lt;&lt; endl;
max@0 8328 </pre>
max@0 8329 </ul>
max@0 8330 </li>
max@0 8331 <br>
max@0 8332 <li>
max@0 8333 See also:
max@0 8334 <ul>
max@0 8335 <li><a href="http://en.wikipedia.org/wiki/Physical_constant">physical constant</a> entry in Wikipedia</li>
max@0 8336 <li><a href="#math_constants">math constants</a></li>
max@0 8337 </ul>
max@0 8338 </li>
max@0 8339 </ul>
max@0 8340 <br>
max@0 8341 <hr class="greyline"><br>
max@0 8342
max@0 8343 <a name="log_add"></a>
max@0 8344 <b>log_add(log_a, log_b)</b>
max@0 8345 <ul>
max@0 8346 <li>
max@0 8347 Safe replacement for log(exp(log_a) + exp(log_b))
max@0 8348 </li>
max@0 8349 <br>
max@0 8350 <li>
max@0 8351 Usage:
max@0 8352 <ul>
max@0 8353 <li>
max@0 8354 <i>scalar_type</i> log_c = log_add(log_a, log_b)
max@0 8355 </li>
max@0 8356 <li>
max@0 8357 <i>scalar_type</i> is either <i>float</i> or <i>double</i>
max@0 8358 </li>
max@0 8359 <li>
max@0 8360 log_a, log_b and log_c must have the same type
max@0 8361 </li>
max@0 8362 </ul>
max@0 8363 </li>
max@0 8364 </ul>
max@0 8365 <br>
max@0 8366 <hr class="greyline"><br>
max@0 8367
max@0 8368 <a name="uword"></a>
max@0 8369 <b>uword</b>, <b>sword</b>
max@0 8370 <ul>
max@0 8371 <li>
max@0 8372 <i>uword</i> is a typedef for an unsigned integer with a minimum width of 32 bits; if <i>ARMA_64BIT_WORD</i> is enabled, the minimum width is 64 bits
max@0 8373 </li>
max@0 8374 <br>
max@0 8375 <li>
max@0 8376 <i>sword</i> is a typedef for a signed integer with a minimum width of 32 bits; if <i>ARMA_64BIT_WORD</i> is enabled, the minimum width is 64 bits
max@0 8377 </li>
max@0 8378 <br>
max@0 8379 <li>
max@0 8380 <i>ARMA_64BIT_WORD</i> can be enabled via editing <i>include/armadillo_bits/config.hpp</i>
max@0 8381 </li>
max@0 8382 <br>
max@0 8383 <li>See also:
max@0 8384 <ul>
max@0 8385 <li><a href="http://cplusplus.com/doc/tutorial/variables/">C++ variable types</a></li>
max@0 8386 <li><a href="http://www.cplusplus.com/doc/tutorial/other_data_types/">explanation of <i>typedef</i></a></li>
max@0 8387 <li><a href="#Mat">imat &amp; umat</a> matrix types
max@0 8388 <li><a href="#Col">ivec &amp; uvec</a> vector types
max@0 8389 </ul>
max@0 8390 </li>
max@0 8391 <br>
max@0 8392 </ul>
max@0 8393 <hr class="greyline"><br>
max@0 8394
max@0 8395 <a name="cx_float_double"></a>
max@0 8396 <b>cx_float</b>, <b>cx_double</b>
max@0 8397 <ul>
max@0 8398 <li>
max@0 8399 cx_float is a typedef for <i>std::complex&lt;float&gt;</i>
max@0 8400 </li>
max@0 8401 <br>
max@0 8402 <li>
max@0 8403 cx_double is a typedef for <i>std::complex&lt;double&gt;</i>
max@0 8404 </li>
max@0 8405 <br>
max@0 8406 <li>See also:
max@0 8407 <ul>
max@0 8408 <li><a href="http://cplusplus.com/reference/std/complex/">complex numbers in the standard C++ library</a></li>
max@0 8409 <li><a href="http://www.cplusplus.com/doc/tutorial/other_data_types/">explanation of <i>typedef</i></a></li>
max@0 8410 <li><a href="#Mat">cx_mat</a> matrix type
max@0 8411 <li><a href="#Col">cx_vec</a> vector type
max@0 8412 </ul>
max@0 8413 </li>
max@0 8414 <br>
max@0 8415 </ul>
max@0 8416
max@0 8417 <a name="syntax"></a>
max@0 8418 <hr class="greyline">
max@0 8419 <br>
max@0 8420 <b>
max@0 8421 Examples of Matlab/Octave syntax and conceptually corresponding Armadillo syntax
max@0 8422 </b>
max@0 8423 <br>
max@0 8424 <br>
max@0 8425 <ul>
max@0 8426 <table style="text-align: left;" border="0" cellpadding="2" cellspacing="2">
max@0 8427 <tbody>
max@0 8428 <tr>
max@0 8429 <td style="vertical-align: top;">
max@0 8430 <b>Matlab/Octave</b>
max@0 8431 </td>
max@0 8432 <td style="vertical-align: top;">
max@0 8433 &nbsp;
max@0 8434 </td>
max@0 8435 <td style="vertical-align: top;">
max@0 8436 <b>Armadillo</b>
max@0 8437 </td>
max@0 8438 <td style="vertical-align: top;">
max@0 8439 &nbsp;
max@0 8440 </td>
max@0 8441 <td style="vertical-align: top;">
max@0 8442 <b>Notes</b>
max@0 8443 </td>
max@0 8444 </tr>
max@0 8445 <tr>
max@0 8446 <td style="vertical-align: top;">
max@0 8447 &nbsp;
max@0 8448 </td>
max@0 8449 <td style="vertical-align: top;">
max@0 8450 &nbsp;
max@0 8451 </td>
max@0 8452 <td style="vertical-align: top;">
max@0 8453 &nbsp;
max@0 8454 </td>
max@0 8455 <td style="vertical-align: top;">
max@0 8456 &nbsp;
max@0 8457 </td>
max@0 8458 <td style="vertical-align: top;">
max@0 8459 &nbsp;
max@0 8460 </td>
max@0 8461 </tr>
max@0 8462 <tr>
max@0 8463 <td style="vertical-align: top;">
max@0 8464 A(1, 1)
max@0 8465 </td>
max@0 8466 <td style="vertical-align: top;">
max@0 8467 &nbsp;
max@0 8468 </td>
max@0 8469 <td style="vertical-align: top;">
max@0 8470 A(0, 0)
max@0 8471 </td>
max@0 8472 <td style="vertical-align: top;">
max@0 8473 &nbsp;
max@0 8474 </td>
max@0 8475 <td style="vertical-align: top;">
max@0 8476 indexing in Armadillo starts at 0
max@0 8477 </td>
max@0 8478 </tr>
max@0 8479 <tr>
max@0 8480 <td style="vertical-align: top;">
max@0 8481 A(k, k)
max@0 8482 </td>
max@0 8483 <td style="vertical-align: top;">
max@0 8484 &nbsp;
max@0 8485 </td>
max@0 8486 <td style="vertical-align: top;">
max@0 8487 A(k-1, k-1)
max@0 8488 </td>
max@0 8489 <td style="vertical-align: top;">
max@0 8490 &nbsp;
max@0 8491 </td>
max@0 8492 <td style="vertical-align: top;">
max@0 8493 &nbsp;
max@0 8494 </td>
max@0 8495 </tr>
max@0 8496 <tr>
max@0 8497 <td style="vertical-align: top;">
max@0 8498 &nbsp;
max@0 8499 </td>
max@0 8500 <td style="vertical-align: top;">
max@0 8501 &nbsp;
max@0 8502 </td>
max@0 8503 <td style="vertical-align: top;">
max@0 8504 &nbsp;
max@0 8505 </td>
max@0 8506 <td style="vertical-align: top;">
max@0 8507 &nbsp;
max@0 8508 </td>
max@0 8509 <td style="vertical-align: top;">
max@0 8510 &nbsp;
max@0 8511 </td>
max@0 8512 </tr>
max@0 8513 <tr>
max@0 8514 <td style="vertical-align: top;">
max@0 8515 size(A,1)
max@0 8516 </td>
max@0 8517 <td style="vertical-align: top;">
max@0 8518 &nbsp;
max@0 8519 </td>
max@0 8520 <td style="vertical-align: top;">
max@0 8521 A<a href="#attributes">.n_rows</a>
max@0 8522 </td>
max@0 8523 <td style="vertical-align: top;">
max@0 8524 &nbsp;
max@0 8525 </td>
max@0 8526 <td style="vertical-align: top;">
max@0 8527 read only
max@0 8528 </td>
max@0 8529 </tr>
max@0 8530 <tr>
max@0 8531 <td style="vertical-align: top;">
max@0 8532 size(A,2)
max@0 8533 </td>
max@0 8534 <td style="vertical-align: top;">
max@0 8535 &nbsp;
max@0 8536 </td>
max@0 8537 <td style="vertical-align: top;">
max@0 8538 A<a href="#attributes">.n_cols</a>
max@0 8539 </td>
max@0 8540 <td style="vertical-align: top;">
max@0 8541 &nbsp;
max@0 8542 </td>
max@0 8543 <td style="vertical-align: top;">
max@0 8544 &nbsp;
max@0 8545 </td>
max@0 8546 </tr>
max@0 8547 <tr>
max@0 8548 <td style="vertical-align: top;">
max@0 8549 size(Q,3)
max@0 8550 </td>
max@0 8551 <td style="vertical-align: top;">
max@0 8552 &nbsp;
max@0 8553 </td>
max@0 8554 <td style="vertical-align: top;">
max@0 8555 Q<a href="#attributes">.n_slices</a>
max@0 8556 </td>
max@0 8557 <td style="vertical-align: top;">
max@0 8558 &nbsp;
max@0 8559 </td>
max@0 8560 <td style="vertical-align: top;">
max@0 8561 Q is a <a href="#Cube">cube</a> (3D array)
max@0 8562 </td>
max@0 8563 </tr>
max@0 8564 <tr>
max@0 8565 <td style="vertical-align: top;">
max@0 8566 numel(A)
max@0 8567 </td>
max@0 8568 <td style="vertical-align: top;">
max@0 8569 &nbsp;
max@0 8570 </td>
max@0 8571 <td style="vertical-align: top;">
max@0 8572 A<a href="#attributes">.n_elem</a>
max@0 8573 </td>
max@0 8574 <td style="vertical-align: top;">
max@0 8575 &nbsp;
max@0 8576 </td>
max@0 8577 <td style="vertical-align: top;">
max@0 8578 &nbsp;
max@0 8579 </td>
max@0 8580 </tr>
max@0 8581 <tr>
max@0 8582 <td style="vertical-align: top;">
max@0 8583 &nbsp;
max@0 8584 </td>
max@0 8585 <td style="vertical-align: top;">
max@0 8586 &nbsp;
max@0 8587 </td>
max@0 8588 <td style="vertical-align: top;">
max@0 8589 &nbsp;
max@0 8590 </td>
max@0 8591 <td style="vertical-align: top;">
max@0 8592 &nbsp;
max@0 8593 </td>
max@0 8594 <td style="vertical-align: top;">
max@0 8595 &nbsp;
max@0 8596 </td>
max@0 8597 </tr>
max@0 8598 <tr>
max@0 8599 <td style="vertical-align: top;">
max@0 8600 A(:, k)
max@0 8601 </td>
max@0 8602 <td style="vertical-align: top;">
max@0 8603 &nbsp;
max@0 8604 </td>
max@0 8605 <td style="vertical-align: top;">
max@0 8606 A<a href="#submat">.col</a>(k)
max@0 8607 </td>
max@0 8608 <td style="vertical-align: top;">
max@0 8609 &nbsp;
max@0 8610 </td>
max@0 8611 <td style="vertical-align: top;">
max@0 8612 this is a conceptual example only;
max@0 8613 exact conversion from Matlab/Octave to Armadillo syntax
max@0 8614 will require taking into account that indexing starts at 0
max@0 8615 </td>
max@0 8616 </tr>
max@0 8617 <tr>
max@0 8618 <td style="vertical-align: top;">
max@0 8619 A(k, :)
max@0 8620 </td>
max@0 8621 <td style="vertical-align: top;">
max@0 8622 &nbsp;
max@0 8623 </td>
max@0 8624 <td style="vertical-align: top;">
max@0 8625 A<a href="#submat">.row</a>(k)
max@0 8626 </td>
max@0 8627 <td style="vertical-align: top;">
max@0 8628 &nbsp;
max@0 8629 </td>
max@0 8630 <td style="vertical-align: top;">
max@0 8631 &nbsp;
max@0 8632 </td>
max@0 8633 </tr>
max@0 8634 <tr>
max@0 8635 <td style="vertical-align: top;">
max@0 8636 A(:, p:q)
max@0 8637 </td>
max@0 8638 <td style="vertical-align: top;">
max@0 8639 &nbsp;
max@0 8640 </td>
max@0 8641 <td style="vertical-align: top;">
max@0 8642 A<a href="#submat">.cols</a>(p, q)
max@0 8643 </td>
max@0 8644 <td style="vertical-align: top;">
max@0 8645 &nbsp;
max@0 8646 </td>
max@0 8647 <td style="vertical-align: top;">
max@0 8648 &nbsp;
max@0 8649 </td>
max@0 8650 </tr>
max@0 8651 <tr>
max@0 8652 <td style="vertical-align: top;">
max@0 8653 A(p:q, :)
max@0 8654 </td>
max@0 8655 <td style="vertical-align: top;">
max@0 8656 &nbsp;
max@0 8657 </td>
max@0 8658 <td style="vertical-align: top;">
max@0 8659 A<a href="#submat">.rows</a>(p, q)
max@0 8660 </td>
max@0 8661 <td style="vertical-align: top;">
max@0 8662 &nbsp;
max@0 8663 </td>
max@0 8664 <td style="vertical-align: top;">
max@0 8665 &nbsp;
max@0 8666 </td>
max@0 8667 </tr>
max@0 8668 <tr>
max@0 8669 <td style="vertical-align: top;">
max@0 8670 &nbsp;
max@0 8671 </td>
max@0 8672 <td style="vertical-align: top;">
max@0 8673 &nbsp;
max@0 8674 </td>
max@0 8675 <td style="vertical-align: top;">
max@0 8676 &nbsp;
max@0 8677 </td>
max@0 8678 <td style="vertical-align: top;">
max@0 8679 &nbsp;
max@0 8680 </td>
max@0 8681 <td style="vertical-align: top;">
max@0 8682 &nbsp;
max@0 8683 </td>
max@0 8684 </tr>
max@0 8685 <tr>
max@0 8686 <td style="vertical-align: top;">
max@0 8687 A(p:q, r:s)
max@0 8688 </td>
max@0 8689 <td style="vertical-align: top;">
max@0 8690 &nbsp;
max@0 8691 </td>
max@0 8692 <td style="vertical-align: top;">
max@0 8693 <font size=-1>
max@0 8694 A<a href="#submat">.submat</a>(p, r, q, s)
max@0 8695 </font>
max@0 8696 </td>
max@0 8697 <td style="vertical-align: top;">
max@0 8698 &nbsp;
max@0 8699 </td>
max@0 8700 <td style="vertical-align: top;">
max@0 8701 <font size=-1>
max@0 8702 A.submat(first_row, first_col, last_row, last_col)
max@0 8703 </font>
max@0 8704 </td>
max@0 8705 </tr>
max@0 8706 <tr>
max@0 8707 <td style="vertical-align: top;">
max@0 8708 &nbsp;
max@0 8709 </td>
max@0 8710 <td style="vertical-align: top;">
max@0 8711 &nbsp;
max@0 8712 </td>
max@0 8713 <td style="vertical-align: top;">
max@0 8714 <font size=-1>
max@0 8715 or
max@0 8716 </font>
max@0 8717 </td>
max@0 8718 <td style="vertical-align: top;">
max@0 8719 &nbsp;
max@0 8720 </td>
max@0 8721 <td style="vertical-align: top;">
max@0 8722 &nbsp;
max@0 8723 </td>
max@0 8724 </tr>
max@0 8725 <tr>
max@0 8726 <td style="vertical-align: top;">
max@0 8727 &nbsp;
max@0 8728 </td>
max@0 8729 <td style="vertical-align: top;">
max@0 8730 &nbsp;
max@0 8731 </td>
max@0 8732 <td style="vertical-align: top;">
max@0 8733 <font size=-1>
max@0 8734 A(&nbsp;<a href="#submat">span</a>(p,q),&nbsp;<a href="#submat">span</a>(r,s)&nbsp;)
max@0 8735 </font>
max@0 8736 </td>
max@0 8737 <td style="vertical-align: top;">
max@0 8738 &nbsp;
max@0 8739 </td>
max@0 8740 <td style="vertical-align: top;">
max@0 8741 <font size=-1>
max@0 8742 A(&nbsp;span(first_row,&nbsp;last_row), span(first_col,&nbsp;last_col)&nbsp;)
max@0 8743 </font>
max@0 8744 </td>
max@0 8745 </tr>
max@0 8746 <tr>
max@0 8747 <td style="vertical-align: top;">
max@0 8748 &nbsp;
max@0 8749 </td>
max@0 8750 <td style="vertical-align: top;">
max@0 8751 &nbsp;
max@0 8752 </td>
max@0 8753 <td style="vertical-align: top;">
max@0 8754 &nbsp;
max@0 8755 </td>
max@0 8756 <td style="vertical-align: top;">
max@0 8757 &nbsp;
max@0 8758 </td>
max@0 8759 <td style="vertical-align: top;">
max@0 8760 &nbsp;
max@0 8761 </td>
max@0 8762 </tr>
max@0 8763 <tr>
max@0 8764 <td style="vertical-align: top;">
max@0 8765 Q(:, :, k)
max@0 8766 </td>
max@0 8767 <td style="vertical-align: top;">
max@0 8768 &nbsp;
max@0 8769 </td>
max@0 8770 <td style="vertical-align: top;">
max@0 8771 Q<a href="#subcube">.slice</a>(k)
max@0 8772 </td>
max@0 8773 <td style="vertical-align: top;">
max@0 8774 &nbsp;
max@0 8775 </td>
max@0 8776 <td style="vertical-align: top;">
max@0 8777 Q is a <a href="#Cube">cube</a> (3D array)
max@0 8778 </td>
max@0 8779 </tr>
max@0 8780 <tr>
max@0 8781 <td style="vertical-align: top;">
max@0 8782 Q(:, :, t:u)
max@0 8783 </td>
max@0 8784 <td style="vertical-align: top;">
max@0 8785 &nbsp;
max@0 8786 </td>
max@0 8787 <td style="vertical-align: top;">
max@0 8788 Q<a href="#subcube">.slices</a>(t, u)
max@0 8789 </td>
max@0 8790 <td style="vertical-align: top;">
max@0 8791 &nbsp;
max@0 8792 </td>
max@0 8793 <td style="vertical-align: top;">
max@0 8794 &nbsp;
max@0 8795 </td>
max@0 8796 </tr>
max@0 8797 <tr>
max@0 8798 <td style="vertical-align: top;">
max@0 8799 &nbsp;
max@0 8800 </td>
max@0 8801 <td style="vertical-align: top;">
max@0 8802 &nbsp;
max@0 8803 </td>
max@0 8804 <td style="vertical-align: top;">
max@0 8805 &nbsp;
max@0 8806 </td>
max@0 8807 <td style="vertical-align: top;">
max@0 8808 &nbsp;
max@0 8809 </td>
max@0 8810 <td style="vertical-align: top;">
max@0 8811 &nbsp;
max@0 8812 </td>
max@0 8813 </tr>
max@0 8814 <tr>
max@0 8815 <td style="vertical-align: top;">
max@0 8816 Q(p:q, r:s, t:u)
max@0 8817 </td>
max@0 8818 <td style="vertical-align: top;">
max@0 8819 &nbsp;
max@0 8820 </td>
max@0 8821 <td style="vertical-align: top;">
max@0 8822 <font size=-1>
max@0 8823 Q<a href="#subcube">.subcube</a>(p,&nbsp;r,&nbsp;t,&nbsp;q,&nbsp;s,&nbsp;u)
max@0 8824 </font>
max@0 8825 </td>
max@0 8826 <td style="vertical-align: top;">
max@0 8827 &nbsp;
max@0 8828 </td>
max@0 8829 <td style="vertical-align: top;">
max@0 8830 <font size=-1>
max@0 8831 .subcube(first_row, first_col, first_slice, last_row, last_col, last_slice)
max@0 8832 </font>
max@0 8833 </td>
max@0 8834 </tr>
max@0 8835 <tr>
max@0 8836 <td style="vertical-align: top;">
max@0 8837 &nbsp;
max@0 8838 </td>
max@0 8839 <td style="vertical-align: top;">
max@0 8840 &nbsp;
max@0 8841 </td>
max@0 8842 <td style="vertical-align: top;">
max@0 8843 <font size=-1>
max@0 8844 or
max@0 8845 </font>
max@0 8846 </td>
max@0 8847 <td style="vertical-align: top;">
max@0 8848 &nbsp;
max@0 8849 </td>
max@0 8850 <td style="vertical-align: top;">
max@0 8851 &nbsp;
max@0 8852 </td>
max@0 8853 </tr>
max@0 8854 <tr>
max@0 8855 <td style="vertical-align: top;">
max@0 8856 &nbsp;
max@0 8857 </td>
max@0 8858 <td style="vertical-align: top;">
max@0 8859 &nbsp;
max@0 8860 </td>
max@0 8861 <td style="vertical-align: top;">
max@0 8862 <font size=-1>
max@0 8863 Q(&nbsp;<a href="#subcube">span</a>(p,q),&nbsp;<a href="#subcube">span</a>(r,s),&nbsp;<a href="#subcube">span</a>(t,u)&nbsp;)
max@0 8864 </font>
max@0 8865 </td>
max@0 8866 <td style="vertical-align: top;">
max@0 8867 &nbsp;
max@0 8868 </td>
max@0 8869 <td style="vertical-align: top;">
max@0 8870 &nbsp;
max@0 8871 </td>
max@0 8872 </tr>
max@0 8873 <tr>
max@0 8874 <td style="vertical-align: top;">
max@0 8875 &nbsp;
max@0 8876 </td>
max@0 8877 <td style="vertical-align: top;">
max@0 8878 &nbsp;
max@0 8879 </td>
max@0 8880 <td style="vertical-align: top;">
max@0 8881 &nbsp;
max@0 8882 </td>
max@0 8883 <td style="vertical-align: top;">
max@0 8884 &nbsp;
max@0 8885 </td>
max@0 8886 <td style="vertical-align: top;">
max@0 8887 &nbsp;
max@0 8888 </td>
max@0 8889 </tr>
max@0 8890 <tr>
max@0 8891 <td style="vertical-align: top;">
max@0 8892 A'
max@0 8893 </td>
max@0 8894 <td style="vertical-align: top;">
max@0 8895 &nbsp;
max@0 8896 </td>
max@0 8897 <td style="vertical-align: top;">
max@0 8898 A<a href="#t_st_members">.t()</a> or <a href="#trans">trans</a>(A)
max@0 8899 </td>
max@0 8900 <td style="vertical-align: top;">
max@0 8901 &nbsp;
max@0 8902 </td>
max@0 8903 <td style="vertical-align: top;">
max@0 8904 matrix transpose / Hermitian transpose
max@0 8905 <br>
max@0 8906 (for complex matrices, the conjugate of each element is taken)
max@0 8907 </td>
max@0 8908 </tr>
max@0 8909 <tr>
max@0 8910 <td style="vertical-align: top;">
max@0 8911 A.'
max@0 8912 </td>
max@0 8913 <td style="vertical-align: top;">
max@0 8914 &nbsp;
max@0 8915 </td>
max@0 8916 <td style="vertical-align: top;">
max@0 8917 A<a href="#t_st_members">.st()</a> or <a href="#strans">strans</a>(A)
max@0 8918 </td>
max@0 8919 <td style="vertical-align: top;">
max@0 8920 &nbsp;
max@0 8921 </td>
max@0 8922 <td style="vertical-align: top;">
max@0 8923 simple matrix transpose
max@0 8924 <br>
max@0 8925 (for complex matrices, the conjugate of each element is not taken)
max@0 8926 </td>
max@0 8927 </tr>
max@0 8928 <tr>
max@0 8929 <td style="vertical-align: top;">
max@0 8930 &nbsp;
max@0 8931 </td>
max@0 8932 <td style="vertical-align: top;">
max@0 8933 &nbsp;
max@0 8934 </td>
max@0 8935 <td style="vertical-align: top;">
max@0 8936 &nbsp;
max@0 8937 </td>
max@0 8938 <td style="vertical-align: top;">
max@0 8939 &nbsp;
max@0 8940 </td>
max@0 8941 <td style="vertical-align: top;">
max@0 8942 &nbsp;
max@0 8943 </td>
max@0 8944 </tr>
max@0 8945 <tr>
max@0 8946 <td style="vertical-align: top;">
max@0 8947 A = zeros(size(A))
max@0 8948 </td>
max@0 8949 <td style="vertical-align: top;">
max@0 8950 &nbsp;
max@0 8951 </td>
max@0 8952 <td style="vertical-align: top;">
max@0 8953 A<a href="#zeros_member">.zeros()</a>
max@0 8954 </td>
max@0 8955 <td style="vertical-align: top;">
max@0 8956 &nbsp;
max@0 8957 </td>
max@0 8958 <td style="vertical-align: top;">
max@0 8959 &nbsp;
max@0 8960 </td>
max@0 8961 </tr>
max@0 8962 <tr>
max@0 8963 <td style="vertical-align: top;">
max@0 8964 A = ones(size(A))
max@0 8965 </td>
max@0 8966 <td style="vertical-align: top;">
max@0 8967 &nbsp;
max@0 8968 </td>
max@0 8969 <td style="vertical-align: top;">
max@0 8970 A.<a href="#ones_member">ones()</a>
max@0 8971 </td>
max@0 8972 <td style="vertical-align: top;">
max@0 8973 &nbsp;
max@0 8974 </td>
max@0 8975 <td style="vertical-align: top;">
max@0 8976 &nbsp;
max@0 8977 </td>
max@0 8978 </tr>
max@0 8979 <tr>
max@0 8980 <td style="vertical-align: top;">
max@0 8981 A = zeros(k)
max@0 8982 </td>
max@0 8983 <td style="vertical-align: top;">
max@0 8984 &nbsp;
max@0 8985 </td>
max@0 8986 <td style="vertical-align: top;">
max@0 8987 A = <a href="#zeros_standalone">zeros</a>&lt;mat&gt;(k,k)
max@0 8988 </td>
max@0 8989 <td style="vertical-align: top;">
max@0 8990 &nbsp;
max@0 8991 </td>
max@0 8992 <td style="vertical-align: top;">
max@0 8993 &nbsp;
max@0 8994 </td>
max@0 8995 </tr>
max@0 8996 <tr>
max@0 8997 <td style="vertical-align: top;">
max@0 8998 A = ones(k)
max@0 8999 </td>
max@0 9000 <td style="vertical-align: top;">
max@0 9001 &nbsp;
max@0 9002 </td>
max@0 9003 <td style="vertical-align: top;">
max@0 9004 A = <a href="#ones_standalone">ones</a>&lt;mat&gt;(k,k)
max@0 9005 </td>
max@0 9006 <td style="vertical-align: top;">
max@0 9007 &nbsp;
max@0 9008 </td>
max@0 9009 <td style="vertical-align: top;">
max@0 9010 &nbsp;
max@0 9011 </td>
max@0 9012 </tr>
max@0 9013 <tr>
max@0 9014 <td style="vertical-align: top;">
max@0 9015 &nbsp;
max@0 9016 </td>
max@0 9017 <td style="vertical-align: top;">
max@0 9018 &nbsp;
max@0 9019 </td>
max@0 9020 <td style="vertical-align: top;">
max@0 9021 &nbsp;
max@0 9022 </td>
max@0 9023 <td style="vertical-align: top;">
max@0 9024 &nbsp;
max@0 9025 </td>
max@0 9026 <td style="vertical-align: top;">
max@0 9027 &nbsp;
max@0 9028 </td>
max@0 9029 </tr>
max@0 9030 <tr>
max@0 9031 <td style="vertical-align: top;">
max@0 9032 C = complex(A,B)
max@0 9033 </td>
max@0 9034 <td style="vertical-align: top;">
max@0 9035 &nbsp;
max@0 9036 </td>
max@0 9037 <td style="vertical-align: top;">
max@0 9038 cx_mat C = <a href="#Mat">cx_mat</a>(A,B)
max@0 9039 </td>
max@0 9040 <td style="vertical-align: top;">
max@0 9041 &nbsp;
max@0 9042 </td>
max@0 9043 <td style="vertical-align: top;">
max@0 9044 &nbsp;
max@0 9045 </td>
max@0 9046 </tr>
max@0 9047 <tr>
max@0 9048 <td style="vertical-align: top;">
max@0 9049 &nbsp;
max@0 9050 </td>
max@0 9051 <td style="vertical-align: top;">
max@0 9052 &nbsp;
max@0 9053 </td>
max@0 9054 <td style="vertical-align: top;">
max@0 9055 &nbsp;
max@0 9056 </td>
max@0 9057 <td style="vertical-align: top;">
max@0 9058 &nbsp;
max@0 9059 </td>
max@0 9060 <td style="vertical-align: top;">
max@0 9061 &nbsp;
max@0 9062 </td>
max@0 9063 </tr>
max@0 9064 <tr>
max@0 9065 <td style="vertical-align: top;">
max@0 9066 A .* B
max@0 9067 </td>
max@0 9068 <td style="vertical-align: top;">
max@0 9069 &nbsp;
max@0 9070 </td>
max@0 9071 <td style="vertical-align: top;">
max@0 9072 A % B
max@0 9073 </td>
max@0 9074 <td style="vertical-align: top;">
max@0 9075 &nbsp;
max@0 9076 </td>
max@0 9077 <td style="vertical-align: top;">
max@0 9078 <a href="#operators">element-wise multiplication</a>
max@0 9079 </td>
max@0 9080 </tr>
max@0 9081 <tr>
max@0 9082 <td style="vertical-align: top;">
max@0 9083 A ./ B
max@0 9084 </td>
max@0 9085 <td style="vertical-align: top;">
max@0 9086 &nbsp;
max@0 9087 </td>
max@0 9088 <td style="vertical-align: top;">
max@0 9089 A / B
max@0 9090 </td>
max@0 9091 <td style="vertical-align: top;">
max@0 9092 &nbsp;
max@0 9093 </td>
max@0 9094 <td style="vertical-align: top;">
max@0 9095 <a href="#operators">element-wise division</a>
max@0 9096 </td>
max@0 9097 </tr>
max@0 9098 <tr>
max@0 9099 <td style="vertical-align: top;">
max@0 9100 A \ B
max@0 9101 </td>
max@0 9102 <td style="vertical-align: top;">
max@0 9103 &nbsp;
max@0 9104 </td>
max@0 9105 <td style="vertical-align: top;">
max@0 9106 <a href="#solve">solve</a>(A,B)
max@0 9107 </td>
max@0 9108 <td style="vertical-align: top;">
max@0 9109 &nbsp;
max@0 9110 </td>
max@0 9111 <td style="vertical-align: top;">
max@0 9112 conceptually similar to <a href="#inv">inv</a>(A)*B, but more efficient
max@0 9113 </td>
max@0 9114 </tr>
max@0 9115 <tr>
max@0 9116 <td style="vertical-align: top;">
max@0 9117 A = A + 1;
max@0 9118 </td>
max@0 9119 <td style="vertical-align: top;">
max@0 9120 &nbsp;
max@0 9121 </td>
max@0 9122 <td style="vertical-align: top;">
max@0 9123 A++
max@0 9124 </td>
max@0 9125 <td style="vertical-align: top;">
max@0 9126 &nbsp;
max@0 9127 </td>
max@0 9128 <td style="vertical-align: top;">
max@0 9129 &nbsp;
max@0 9130 </td>
max@0 9131 </tr>
max@0 9132 <tr>
max@0 9133 <td style="vertical-align: top;">
max@0 9134 A = A - 1;
max@0 9135 </td>
max@0 9136 <td style="vertical-align: top;">
max@0 9137 &nbsp;
max@0 9138 </td>
max@0 9139 <td style="vertical-align: top;">
max@0 9140 A--
max@0 9141 </td>
max@0 9142 <td style="vertical-align: top;">
max@0 9143 &nbsp;
max@0 9144 </td>
max@0 9145 <td style="vertical-align: top;">
max@0 9146 &nbsp;
max@0 9147 </td>
max@0 9148 </tr>
max@0 9149 <tr>
max@0 9150 <td style="vertical-align: top;">
max@0 9151 &nbsp;
max@0 9152 </td>
max@0 9153 <td style="vertical-align: top;">
max@0 9154 &nbsp;
max@0 9155 </td>
max@0 9156 <td style="vertical-align: top;">
max@0 9157 &nbsp;
max@0 9158 </td>
max@0 9159 <td style="vertical-align: top;">
max@0 9160 &nbsp;
max@0 9161 </td>
max@0 9162 <td style="vertical-align: top;">
max@0 9163 &nbsp;
max@0 9164 </td>
max@0 9165 </tr>
max@0 9166 <tr>
max@0 9167 <td style="vertical-align: top;">
max@0 9168 A = [ 1 2; 3 4; ]
max@0 9169 </td>
max@0 9170 <td style="vertical-align: top;">
max@0 9171 &nbsp;
max@0 9172 </td>
max@0 9173 <td style="vertical-align: top;">
max@0 9174 A&nbsp;<font size=-1>&lt;&lt;</font> 1 <font size=-1>&lt;&lt;</font> 2 <font size=-1>&lt;&lt;</font> endr<br>
max@0 9175 &nbsp;&nbsp;&nbsp;<font size=-1>&lt;&lt;</font> 3 <font size=-1>&lt;&lt;</font> 4 <font size=-1>&lt;&lt;</font> endr;
max@0 9176 </td>
max@0 9177 <td style="vertical-align: top;">
max@0 9178 &nbsp;
max@0 9179 </td>
max@0 9180 <td style="vertical-align: top;">
max@0 9181 <a href="#element_initialisation">element initialisation</a>,
max@0 9182 with special element <i>endr</i> indicating <i>end of row</i>
max@0 9183 </td>
max@0 9184 </tr>
max@0 9185 <tr>
max@0 9186 <td style="vertical-align: top;">
max@0 9187 &nbsp;
max@0 9188 </td>
max@0 9189 <td style="vertical-align: top;">
max@0 9190 &nbsp;
max@0 9191 </td>
max@0 9192 <td style="vertical-align: top;">
max@0 9193 &nbsp;
max@0 9194 </td>
max@0 9195 <td style="vertical-align: top;">
max@0 9196 &nbsp;
max@0 9197 </td>
max@0 9198 <td style="vertical-align: top;">
max@0 9199 &nbsp;
max@0 9200 </td>
max@0 9201 </tr>
max@0 9202 <tr>
max@0 9203 <td style="vertical-align: top;">
max@0 9204 X = [&nbsp;A&nbsp;&nbsp;B&nbsp;]
max@0 9205 </td>
max@0 9206 <td style="vertical-align: top;">
max@0 9207 &nbsp;
max@0 9208 </td>
max@0 9209 <td style="vertical-align: top;">
max@0 9210 X = <a href="#join">join_rows</a>(A,B)
max@0 9211 </td>
max@0 9212 <td style="vertical-align: top;">
max@0 9213 &nbsp;
max@0 9214 </td>
max@0 9215 <td style="vertical-align: top;">
max@0 9216 &nbsp;
max@0 9217 </td>
max@0 9218 </tr>
max@0 9219 <tr>
max@0 9220 <td style="vertical-align: top;">
max@0 9221 X = [&nbsp;A;&nbsp;B&nbsp;]
max@0 9222 </td>
max@0 9223 <td style="vertical-align: top;">
max@0 9224 &nbsp;
max@0 9225 </td>
max@0 9226 <td style="vertical-align: top;">
max@0 9227 X = <a href="#join">join_cols</a>(A,B)
max@0 9228 </td>
max@0 9229 <td style="vertical-align: top;">
max@0 9230 &nbsp;
max@0 9231 </td>
max@0 9232 <td style="vertical-align: top;">
max@0 9233 &nbsp;
max@0 9234 </td>
max@0 9235 </tr>
max@0 9236 <tr>
max@0 9237 <td style="vertical-align: top;">
max@0 9238 &nbsp;
max@0 9239 </td>
max@0 9240 <td style="vertical-align: top;">
max@0 9241 &nbsp;
max@0 9242 </td>
max@0 9243 <td style="vertical-align: top;">
max@0 9244 &nbsp;
max@0 9245 </td>
max@0 9246 <td style="vertical-align: top;">
max@0 9247 &nbsp;
max@0 9248 </td>
max@0 9249 <td style="vertical-align: top;">
max@0 9250 &nbsp;
max@0 9251 </td>
max@0 9252 </tr>
max@0 9253 <tr>
max@0 9254 <td style="vertical-align: top;">
max@0 9255 A
max@0 9256 </td>
max@0 9257 <td style="vertical-align: top;">
max@0 9258 &nbsp;
max@0 9259 </td>
max@0 9260 <td style="vertical-align: top;">
max@0 9261 cout <font size=-1>&lt;&lt;</font> A <font size=-1>&lt;&lt;</font> endl;
max@0 9262 <br>or
max@0 9263 <br>A<a href="#print">.print</a>("A =");
max@0 9264 </td>
max@0 9265 <td style="vertical-align: top;">
max@0 9266 &nbsp;
max@0 9267 </td>
max@0 9268 <td style="vertical-align: top;">
max@0 9269 &nbsp;
max@0 9270 </td>
max@0 9271 </tr>
max@0 9272 <tr>
max@0 9273 <td style="vertical-align: top;">
max@0 9274 &nbsp;
max@0 9275 </td>
max@0 9276 <td style="vertical-align: top;">
max@0 9277 &nbsp;
max@0 9278 </td>
max@0 9279 <td style="vertical-align: top;">
max@0 9280 &nbsp;
max@0 9281 </td>
max@0 9282 <td style="vertical-align: top;">
max@0 9283 &nbsp;
max@0 9284 </td>
max@0 9285 <td style="vertical-align: top;">
max@0 9286 &nbsp;
max@0 9287 </td>
max@0 9288 </tr>
max@0 9289 <tr>
max@0 9290 <td style="vertical-align: top;">
max@0 9291 save&nbsp;-ascii&nbsp;'A.dat'&nbsp;A
max@0 9292 </td>
max@0 9293 <td style="vertical-align: top;">
max@0 9294 &nbsp;
max@0 9295 </td>
max@0 9296 <td style="vertical-align: top;">
max@0 9297 A<a href="#save_load_mat">.save</a>("A.dat",&nbsp;raw_ascii);
max@0 9298 </td>
max@0 9299 <td style="vertical-align: top;">
max@0 9300 &nbsp;
max@0 9301 </td>
max@0 9302 <td style="vertical-align: top;">
max@0 9303 Matlab/Octave matrices saved as ascii are readable by Armadillo (and vice-versa)
max@0 9304 </td>
max@0 9305 </tr>
max@0 9306 <tr>
max@0 9307 <td style="vertical-align: top;">
max@0 9308 load&nbsp;-ascii&nbsp;'A.dat'
max@0 9309 </td>
max@0 9310 <td style="vertical-align: top;">
max@0 9311 &nbsp;
max@0 9312 </td>
max@0 9313 <td style="vertical-align: top;">
max@0 9314 A<a href="#save_load_mat">.load</a>("A.dat",&nbsp;raw_ascii);
max@0 9315 </td>
max@0 9316 <td style="vertical-align: top;">
max@0 9317 &nbsp;
max@0 9318 </td>
max@0 9319 <td style="vertical-align: top;">
max@0 9320 &nbsp;
max@0 9321 </td>
max@0 9322 </tr>
max@0 9323 <tr>
max@0 9324 <td style="vertical-align: top;">
max@0 9325 &nbsp;
max@0 9326 </td>
max@0 9327 <td style="vertical-align: top;">
max@0 9328 &nbsp;
max@0 9329 </td>
max@0 9330 <td style="vertical-align: top;">
max@0 9331 &nbsp;
max@0 9332 </td>
max@0 9333 <td style="vertical-align: top;">
max@0 9334 &nbsp;
max@0 9335 </td>
max@0 9336 <td style="vertical-align: top;">
max@0 9337 &nbsp;
max@0 9338 </td>
max@0 9339 </tr>
max@0 9340 <tr>
max@0 9341 <td style="vertical-align: top;">
max@0 9342 S&nbsp;=&nbsp;{&nbsp;'abc';&nbsp;'def'&nbsp;}
max@0 9343 </td>
max@0 9344 <td style="vertical-align: top;">
max@0 9345 &nbsp;
max@0 9346 </td>
max@0 9347 <td style="vertical-align: top;">
max@0 9348 <a href="#field">field</a>&lt;std::string&gt; S(2);
max@0 9349 <br>S(0) = "abc";
max@0 9350 <br>S(1) = "def";
max@0 9351 </td>
max@0 9352 <td style="vertical-align: top;">
max@0 9353 &nbsp;
max@0 9354 </td>
max@0 9355 <td style="vertical-align: top;">
max@0 9356 <a href="#field">fields</a> can store arbitrary objects, in a 1D or 2D layout
max@0 9357 </td>
max@0 9358 </tr>
max@0 9359 </tbody>
max@0 9360 </table>
max@0 9361 </ul>
max@0 9362 <br>
max@0 9363
max@0 9364 <a name="example_prog"></a>
max@0 9365 <hr class="greyline">
max@0 9366 <br>
max@0 9367 <b>example program</b>
max@0 9368 <br>
max@0 9369 <br>
max@0 9370 <ul>
max@0 9371 <li>
max@0 9372 If you save the program below as <i>example.cpp</i>,
max@0 9373 under Linux you can compile it using:
max@0 9374 <br>
max@0 9375 g++ example.cpp -o example -O1 -larmadillo
max@0 9376 </li>
max@0 9377 <ul>
max@0 9378 <pre>
max@0 9379 #include &lt;iostream&gt;
max@0 9380 #include &lt;armadillo&gt;
max@0 9381
max@0 9382 using namespace std;
max@0 9383 using namespace arma;
max@0 9384
max@0 9385 int main(int argc, char** argv)
max@0 9386 {
max@0 9387 mat A = randu&lt;mat&gt;(4,5);
max@0 9388 mat B = randu&lt;mat&gt;(4,5);
max@0 9389
max@0 9390 cout &lt;&lt; A*trans(B) &lt;&lt; endl;
max@0 9391
max@0 9392 return 0;
max@0 9393 }
max@0 9394 </pre>
max@0 9395 </ul>
max@0 9396 <li>
max@0 9397 You may also want to have a look at the example programs that come with the Armadillo archive.
max@0 9398 </li>
max@0 9399 <br>
max@0 9400 <li>
max@0 9401 As Armadillo is a template library, we strongly recommended to have optimisation enabled when compiling programs
max@0 9402 (eg. when compiling with GCC, use the -O1 or -O2 options).
max@0 9403 </li>
max@0 9404 </ul>
max@0 9405 <br>
max@0 9406
max@0 9407
max@0 9408 <!--
max@0 9409 <a name="catching_exceptions"></a>
max@0 9410 <hr class="greyline">
max@0 9411 <br>
max@0 9412 <b>how to catch std::runtime_error exceptions</b>
max@0 9413 <br>
max@0 9414 <br>
max@0 9415 <ul>
max@0 9416 <li>
max@0 9417 If a function such as <a href="#inv">inv()</a> fails to find a solution,
max@0 9418 an error message is printed and a <i>std::runtime_error</i> exception is thrown.
max@0 9419 If the exception is not caught, the program typically terminates.
max@0 9420 Below is an example of how to catch exceptions:
max@0 9421 <ul>
max@0 9422 <pre>
max@0 9423 #include &lt;iostream&gt;
max@0 9424 #include &lt;armadillo&gt;
max@0 9425
max@0 9426 using namespace std;
max@0 9427 using namespace arma;
max@0 9428
max@0 9429 int main(int argc, char** argv)
max@0 9430 {
max@0 9431 // create a non-invertible matrix
max@0 9432 mat A = zeros&lt;mat&gt;(5,5);
max@0 9433
max@0 9434 mat B;
max@0 9435
max@0 9436 try
max@0 9437 {
max@0 9438 B = inv(A);
max@0 9439 }
max@0 9440 catch (std::runtime_error&amp; x)
max@0 9441 {
max@0 9442 cout &lt;&lt; "caught an exception" &lt;&lt; endl;
max@0 9443 }
max@0 9444
max@0 9445 return 0;
max@0 9446 }
max@0 9447 </pre>
max@0 9448 </ul>
max@0 9449 <li>
max@0 9450 See also:
max@0 9451 <ul>
max@0 9452 <li><a href="#logging">logging of warnings and errors</a></li>
max@0 9453 <li><a href="http://cplusplus.com/doc/tutorial/exceptions/">tutorial on exceptions</a></li>
max@0 9454 <li><a href="http://cplusplus.com/reference/std/stdexcept/runtime_error/">std::runtime_error</a></li>
max@0 9455 </ul>
max@0 9456 </li>
max@0 9457 <br>
max@0 9458 </ul>
max@0 9459 <br>
max@0 9460 -->
max@0 9461
max@0 9462 <a name="api_changes"></a>
max@0 9463 <hr class="greyline">
max@0 9464 <br>
max@0 9465 <b>API Changes, Additions and Deprecations</b>
max@0 9466 <br>
max@0 9467 <br>
max@0 9468 Armadillo's version number is X.Y.Z, where X is a major version, Y is a minor version, and Z is the patch level (indicating bug fixes).
max@0 9469 <br>
max@0 9470 <br>
max@0 9471 Within each major version (eg. 2.x), minor versions with an even number (eg. 2.2) are backwards compatible with earlier even minor versions (eg. 2.0).
max@0 9472 For example, code written for version 2.0 will work with version 2.2.
max@0 9473 However, as each minor version may have more features (ie. API extensions) than earlier versions,
max@0 9474 code written for version 2.2 doesn't necessarily work with 2.0.
max@0 9475 <br>
max@0 9476 <br>
max@0 9477 An odd minor version number (eg. 2.3) indicates an experimental version.
max@0 9478 Experimental versions are generally faster and have more functionality,
max@0 9479 but their APIs have not been finalised yet.
max@0 9480 <br>
max@0 9481 <br>
max@0 9482 In general, we don't like changes to existing APIs and prefer not to break any user software.
max@0 9483 However, to allow evolution and help code maintenance, we reserve the right to change the APIs in future major versions of Armadillo,
max@0 9484 while remaining backwards compatible wherever possible
max@0 9485 (eg. 3.0 may have slightly different APIs than 2.x).
max@0 9486 Also, in a rare instance the user API may need to be altered if a bug fix absolutely requires it.
max@0 9487 <br>
max@0 9488 <br>
max@0 9489 <br>
max@0 9490 <a name="deprecated"></a>
max@0 9491 Below is a list of deprecated functionality; this functionality will be <b>removed</b> in version 3.0:
max@0 9492 <ul>
max@0 9493 <li>
max@0 9494 <i>.print_trans()</i> and <i>.raw_print_trans()</i> are deprecated;
max@0 9495 <br>instead, you can chain <i>.t()</i> and <i>.print()</i> to achieve a similar result: <i>.t().print()</i>
max@0 9496 <br>&nbsp;
max@0 9497 </li>
max@0 9498 <li>
max@0 9499 support for tying writeable auxiliary (external) memory to fixed size matrices is deprecated;
max@0 9500 <br>instead, you can use standard matrices with <a href="#adv_constructors_mat">writeable auxiliary memory</a>,
max@0 9501 or initialise fixed size matrices by <a href="#adv_constructors_mat">copying the memory</a>.
max@0 9502 Using auxiliary memory with standard matrices is unaffected.
max@0 9503 <br>&nbsp;
max@0 9504 </li>
max@0 9505 </ul>
max@0 9506 <br>
max@0 9507 <br>
max@0 9508 Below is a list of additions and changes since prior versions of Armadillo:
max@0 9509 <ul>
max@0 9510 <a name="added_in_24"></a>
max@0 9511 <li>Added in 2.4:
max@0 9512 <ul>
max@0 9513 <li>shorter forms of transposes: <a href="#t_st_members">.t()</a> and <a href="#t_st_members">.st()</a></li>
max@0 9514 <li><a href="#resize_member">.resize()</a> and <a href="#resize">resize()</a> (added in 2.4.1)</li>
max@0 9515 <li>optional use of 64 bit indices (allowing matrices to have more than 4 billion elements),
max@0 9516 <br>enabled via ARMA_64BIT_WORD in <i>include/armadillo_bits/config.hpp</i></li>
max@0 9517 <li>experimental support for C++11 initialiser lists, enabled via ARMA_USE_CXX11 in <i>include/armadillo_bits/config.hpp</i></li>
max@0 9518 </ul>
max@0 9519 <br>
max@0 9520 <li>Changed in 2.4:
max@0 9521 <ul>
max@0 9522 <li>refactored code to eliminate warnings when using the Clang C++ compiler</li>
max@0 9523 <li><a href="#Mat">umat</a>, <a href="#Col">uvec</a>, <a href="#min_and_max_member">.min()</a> and <a href="#min_and_max_member">.max()</a>
max@0 9524 have been changed to use the <a href="#uword"><i>uword</i></a> type instead of the <i>u32</i> type;
max@0 9525 by default the <i>uword</i> and <i>u32</i> types are equivalent (ie. unsigned integer type with a minimum width 32 bits);
max@0 9526 however, when the use of 64 bit indices is enabled via ARMA_64BIT_WORD in <i>include/armadillo_bits/config.hpp</i>,
max@0 9527 the <i>uword</i> type then has a minimum width of 64 bits
max@0 9528 </ul>
max@0 9529 </li>
max@0 9530 <br>
max@0 9531 <li>Added in 2.2:
max@0 9532 <ul>
max@0 9533 <li><a href="#svd_econ">svd_econ()</a></li>
max@0 9534 <li><a href="#toeplitz">circ_toeplitz()</a></li>
max@0 9535 <li><a href="#is_vec">.is_colvec()</a> and <a href="#is_vec">.is_rowvec()</a></li>
max@0 9536 </ul>
max@0 9537 <br>
max@0 9538 <li>Changed in 2.0:
max@0 9539 <ul>
max@0 9540 <li><a href="#trans">trans()</a> now takes the complex conjugate when transposing a complex matrix</li>
max@0 9541 <li>Forms of
max@0 9542 <a href="#chol">chol()</a>, <a href="#eig_sym">eig_sym()</a>, <a href="#eig_gen">eig_gen()</a>,
max@0 9543 <a href="#inv">inv()</a>, <a href="#lu">lu()</a>, <a href="#pinv">pinv()</a>, <a href="#princomp">princomp()</a>,
max@0 9544 <a href="#qr">qr()</a>, <a href="#solve">solve()</a>, <a href="#svd">svd()</a>, <a href="#syl">syl()</a>
max@0 9545 that do not return a bool indicating success now throw <i>std::runtime_error</i> exceptions when failures are detected</li>
max@0 9546 <li>princomp_cov() has been removed; <a href="#eig_sym">eig_sym()</a> in conjunction with <a href="#cov">cov()</a> can be used instead</li>
max@0 9547 <li><a href="#is_vec">.is_vec()</a> now outputs <i>true</i> for empty vectors (eg. 0x1)</li>
max@0 9548 <li>set_log_stream() &amp; get_log_stream() have been replaced by <a href="#logging">set_stream_err1()</a> &amp; <a href="#logging">get_stream_err1()</a></li>
max@0 9549 </ul>
max@0 9550 <br>
max@0 9551 <li>Added in 2.0:
max@0 9552 <ul>
max@0 9553 <li><a href="#det">det()</a>, <a href="#inv">inv()</a> and <a href="#solve">solve()</a> can be forced to use more precise algorithms for tiny matrices (&le;&nbsp;4x4)</li>
max@0 9554 <li><a href="#syl">syl()</a>, for solving Sylvester's equation</li>
max@0 9555 <li><a href="#strans">strans()</a>, for transposing a complex matrix without taking the complex conjugate</li>
max@0 9556 <li><a href="#symmat">symmatu()</a> and <a href="#symmat">symmatl()</a></li>
max@0 9557 <li>submatrices of <a href="#submat">submatrices</a></li>
max@0 9558 <li>faster <a href="#inv">inverse</a> of symmetric positive definite matrices</li>
max@0 9559 <li>faster element access for <a href="#adv_constructors_mat_fixed">fixed size</a> matrices</li>
max@0 9560 <li>faster multiplication of tiny matrices (eg. 4x4)</li>
max@0 9561 <li>faster compound expressions containing <a href="#submat">submatrices</a></li>
max@0 9562 <li>handling of arbitrarily sized empty matrices (eg. 5x0)</li>
max@0 9563 <li>.count() member function in <a href="#running_stat">running_stat</a> and <a href="#running_stat_vec">running_stat_vec</a></li>
max@0 9564 <li><a href="#save_load_mat">loading &amp; saving</a> of matrices as CSV text files</li>
max@0 9565 </ul>
max@0 9566 <br>
max@0 9567 <li>Added in 1.2:
max@0 9568 <ul>
max@0 9569 <li><a href="#min_and_max_member">.min() &amp; .max()</a> member functions of Mat and Cube</li>
max@0 9570 <li><a href="#misc_fns">floor()</a> and <a href="#misc_fns">ceil()</a></li>
max@0 9571 <li>representation of &ldquo;not a number&rdquo;: <a href="#math_constants">math::nan()</a></li>
max@0 9572 <li>representation of infinity: <a href="#math_constants">math::inf()</a></li>
max@0 9573 <li>standalone <a href="#is_finite_standalone">is_finite()</a></li>
max@0 9574 <li><a href="#in_range">.in_range()</a> can use <b>span()</b> arguments</li>
max@0 9575 <li><a href="#adv_constructors_mat">fixed size</a> matrices and vectors can use auxiliary (external) memory</li>
max@0 9576 <li><a href="#submat">submatrices</a> and <a href="#subfield">subfields</a> can be accessed via <i><b>X(</b>&nbsp;<b>span(</b>a,b<b>)</b>,&nbsp;<b>span(</b>c,d<b>)</b>&nbsp;<b>)</b></i></li>
max@0 9577 <li><a href="#subcube">subcubes</a> can be accessed via <i><b>X(</b>&nbsp;<b>span(</b>a,b<b>)</b>,&nbsp;<b>span(</b>c,d<b>)</b>,&nbsp;<b>span(</b>e,f<b>)</b>&nbsp;<b>)</b></i></li>
max@0 9578 <li>the two argument version of <i><b>span</b></i> can be replaced by
max@0 9579 <i><b>span::all</b></i> or <i><b>span()</b></i>, to indicate an entire range
max@0 9580 </li>
max@0 9581 <li>for cubes, the two argument version of <i><b>span</b></i> can be replaced by
max@0 9582 a single argument version, <i><b>span(</b>a<b>)</b></i>, to indicate a single column, row or slice
max@0 9583 </li>
max@0 9584 <li>arbitrary "flat" subcubes can be interpreted as matrices; for example:
max@0 9585 <ul>
max@0 9586 <pre>
max@0 9587 cube Q = randu&lt;cube&gt;(5,3,4);
max@0 9588 mat A = Q(&nbsp;span(1),&nbsp;span(1,2),&nbsp;span::all&nbsp;);
max@0 9589 // A has a size of 2x4
max@0 9590
max@0 9591 vec v = ones&lt;vec&gt;(4);
max@0 9592 Q(&nbsp;span(1),&nbsp;span(1),&nbsp;span::all&nbsp;)&nbsp;=&nbsp;v;
max@0 9593 </pre>
max@0 9594 </ul>
max@0 9595 </li>
max@0 9596 <li>interpretation of matrices as triangular through <a href="#trimat">trimatu() / trimatl()</a></li>
max@0 9597 <li>explicit handling of triangular matrices by <a href="#solve">solve()</a> and <a href="#inv">inv()</a></li>
max@0 9598 <li>extended syntax for <a href="#submat">submatrices</a>, including access to elements whose indices are specified in a vector</li>
max@0 9599 <li>ability to change the stream used for <a href="#logging">logging</a> of errors and warnings</li>
max@0 9600 <li>ability to <a href="#save_load_mat">save/load matrices</a> in raw binary format</li>
max@0 9601 <li>cumulative sum function: <a href="#cumsum">cumsum()</a></li>
max@0 9602 </ul>
max@0 9603 </li>
max@0 9604 <br>
max@0 9605 <li>
max@0 9606 Changed in 1.0 (compared to earlier 0.x development versions):
max@0 9607 <ul>
max@0 9608 <li>
max@0 9609 the 3 argument version of <a href="#lu">lu()</a>,
max@0 9610 eg. lu(L,U,X),
max@0 9611 provides L and U which should be the same as produced by Octave 3.2
max@0 9612 (this was not the case in versions prior to 0.9.90)
max@0 9613 </li>
max@0 9614 <br>
max@0 9615 <li>
max@0 9616 rand() has been replaced by <a href="#randu_randn_standalone">randu()</a>;
max@0 9617 this has been done to avoid confusion with <a href="http://cplusplus.com/reference/clibrary/cstdlib/rand/">std::rand()</a>,
max@0 9618 which generates random numbers in a different interval
max@0 9619 </li>
max@0 9620 <br>
max@0 9621 <li>
max@0 9622 In versions earlier than 0.9.0,
max@0 9623 some multiplication operations directly converted result matrices with a size of 1x1 into scalars.
max@0 9624 This is no longer the case.
max@0 9625 If you know the result of an expression will be a 1x1 matrix and wish to treat it as a pure scalar,
max@0 9626 use the <a href="#as_scalar">as_scalar()</a> wrapping function
max@0 9627 </li>
max@0 9628 <br>
max@0 9629 <li>
max@0 9630 Almost all functions have been placed in the delayed operations framework (for speed purposes).
max@0 9631 This may affect code which assumed that the output of some functions was a pure matrix.
max@0 9632 The solution is easy, as explained below.
max@0 9633 <br>
max@0 9634 <br>
max@0 9635 In general, Armadillo queues operations before executing them.
max@0 9636 As such, the direct output of an operation or function cannot be assumed to be a directly accessible matrix.
max@0 9637 The queued operations are executed when the output needs to be stored in a matrix,
max@0 9638 eg. <i>mat&nbsp;B&nbsp;=&nbsp;trans(A)</i> or <i>mat&nbsp;B(trans(A))</i>.
max@0 9639 If you need to force the execution of the delayed operations,
max@0 9640 place the operation or function inside the corresponding Mat constructor.
max@0 9641 For example, if your code assumed that the output of some functions was a pure matrix,
max@0 9642 eg. <i>chol(m).diag()</i>, change the code to <i>mat(chol(m)).diag()</i>.
max@0 9643 Similarly, if you need to pass the result of an operation such as <i>A+B</i> to one of your own functions,
max@0 9644 use <i>my_function(&nbsp;mat(A+B)&nbsp;)</i>.
max@0 9645 </li>
max@0 9646 </ul>
max@0 9647 </li>
max@0 9648 <br>
max@0 9649 </ul>
max@0 9650 <br>
max@0 9651 <br>
max@0 9652
max@0 9653
max@0 9654 <!-- END CONTENT -->
max@0 9655
max@0 9656
max@0 9657 <hr>
max@0 9658 <br>
max@0 9659 <br>
max@0 9660
max@0 9661 </td>
max@0 9662 </tr>
max@0 9663 </tbody>
max@0 9664 </table>
max@0 9665 </center>
max@0 9666 </body>
max@0 9667 </html>