annotate armadillo-2.4.4/include/armadillo_bits/Row_meat.hpp @ 18:8d046a9d36aa slimline

Back out rev 13:ac07c60aa798. Like an idiot, I committed a whole pile of unrelated changes in the guise of a single typo fix. Will re-commit in stages
author Chris Cannam
date Thu, 10 May 2012 10:45:44 +0100
parents 8b6102e2a9b0
children
rev   line source
max@0 1 // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
max@0 2 // Copyright (C) 2008-2011 Conrad Sanderson
max@0 3 //
max@0 4 // This file is part of the Armadillo C++ library.
max@0 5 // It is provided without any warranty of fitness
max@0 6 // for any purpose. You can redistribute this file
max@0 7 // and/or modify it under the terms of the GNU
max@0 8 // Lesser General Public License (LGPL) as published
max@0 9 // by the Free Software Foundation, either version 3
max@0 10 // of the License or (at your option) any later version.
max@0 11 // (see http://www.opensource.org/licenses for more info)
max@0 12
max@0 13
max@0 14 //! \addtogroup Row
max@0 15 //! @{
max@0 16
max@0 17
max@0 18 //! construct an empty row vector
max@0 19 template<typename eT>
max@0 20 inline
max@0 21 Row<eT>::Row()
max@0 22 : Mat<eT>(1, 0)
max@0 23 {
max@0 24 arma_extra_debug_sigprint();
max@0 25
max@0 26 access::rw(Mat<eT>::vec_state) = 2;
max@0 27 }
max@0 28
max@0 29
max@0 30
max@0 31 template<typename eT>
max@0 32 inline
max@0 33 Row<eT>::Row(const Row<eT>& X)
max@0 34 : Mat<eT>(1, X.n_elem)
max@0 35 {
max@0 36 arma_extra_debug_sigprint();
max@0 37
max@0 38 access::rw(Mat<eT>::vec_state) = 2;
max@0 39
max@0 40 arrayops::copy((*this).memptr(), X.memptr(), X.n_elem);
max@0 41 }
max@0 42
max@0 43
max@0 44
max@0 45 //! construct a row vector with the specified number of n_elem
max@0 46 template<typename eT>
max@0 47 inline
max@0 48 Row<eT>::Row(const uword in_n_elem)
max@0 49 : Mat<eT>(1, in_n_elem)
max@0 50 {
max@0 51 arma_extra_debug_sigprint();
max@0 52
max@0 53 access::rw(Mat<eT>::vec_state) = 2;
max@0 54 }
max@0 55
max@0 56
max@0 57
max@0 58 template<typename eT>
max@0 59 inline
max@0 60 Row<eT>::Row(const uword in_n_rows, const uword in_n_cols)
max@0 61 {
max@0 62 arma_extra_debug_sigprint();
max@0 63
max@0 64 access::rw(Mat<eT>::vec_state) = 2;
max@0 65
max@0 66 Mat<eT>::init_warm(in_n_rows, in_n_cols);
max@0 67 }
max@0 68
max@0 69
max@0 70
max@0 71 template<typename eT>
max@0 72 inline
max@0 73 Row<eT>::Row(const char* text)
max@0 74 {
max@0 75 arma_extra_debug_sigprint();
max@0 76
max@0 77 access::rw(Mat<eT>::vec_state) = 2;
max@0 78
max@0 79 Mat<eT>::operator=(text);
max@0 80 }
max@0 81
max@0 82
max@0 83
max@0 84 template<typename eT>
max@0 85 inline
max@0 86 const Row<eT>&
max@0 87 Row<eT>::operator=(const char* text)
max@0 88 {
max@0 89 arma_extra_debug_sigprint();
max@0 90
max@0 91 Mat<eT>::operator=(text);
max@0 92
max@0 93 return *this;
max@0 94 }
max@0 95
max@0 96
max@0 97
max@0 98 template<typename eT>
max@0 99 inline
max@0 100 Row<eT>::Row(const std::string& text)
max@0 101 {
max@0 102 arma_extra_debug_sigprint();
max@0 103
max@0 104 access::rw(Mat<eT>::vec_state) = 2;
max@0 105
max@0 106 Mat<eT>::operator=(text);
max@0 107 }
max@0 108
max@0 109
max@0 110
max@0 111 template<typename eT>
max@0 112 inline
max@0 113 const Row<eT>&
max@0 114 Row<eT>::operator=(const std::string& text)
max@0 115 {
max@0 116 arma_extra_debug_sigprint();
max@0 117
max@0 118 Mat<eT>::operator=(text);
max@0 119
max@0 120 return *this;
max@0 121 }
max@0 122
max@0 123
max@0 124
max@0 125 #if defined(ARMA_USE_CXX11)
max@0 126
max@0 127 template<typename eT>
max@0 128 inline
max@0 129 Row<eT>::Row(const std::initializer_list<eT>& list)
max@0 130 {
max@0 131 arma_extra_debug_sigprint();
max@0 132
max@0 133 access::rw(Mat<eT>::vec_state) = 2;
max@0 134
max@0 135 Mat<eT>::operator=(list);
max@0 136 }
max@0 137
max@0 138
max@0 139
max@0 140 template<typename eT>
max@0 141 inline
max@0 142 const Row<eT>&
max@0 143 Row<eT>::operator=(const std::initializer_list<eT>& list)
max@0 144 {
max@0 145 arma_extra_debug_sigprint();
max@0 146
max@0 147 Mat<eT>::operator=(list);
max@0 148
max@0 149 return *this;
max@0 150 }
max@0 151
max@0 152 #endif
max@0 153
max@0 154
max@0 155
max@0 156 template<typename eT>
max@0 157 inline
max@0 158 const Row<eT>&
max@0 159 Row<eT>::operator=(const eT val)
max@0 160 {
max@0 161 arma_extra_debug_sigprint();
max@0 162
max@0 163 Mat<eT>::operator=(val);
max@0 164
max@0 165 return *this;
max@0 166 }
max@0 167
max@0 168
max@0 169
max@0 170 template<typename eT>
max@0 171 template<typename T1>
max@0 172 inline
max@0 173 Row<eT>::Row(const Base<eT,T1>& X)
max@0 174 {
max@0 175 arma_extra_debug_sigprint();
max@0 176
max@0 177 access::rw(Mat<eT>::vec_state) = 2;
max@0 178
max@0 179 Mat<eT>::operator=(X.get_ref());
max@0 180 }
max@0 181
max@0 182
max@0 183
max@0 184 template<typename eT>
max@0 185 template<typename T1>
max@0 186 inline
max@0 187 const Row<eT>&
max@0 188 Row<eT>::operator=(const Base<eT,T1>& X)
max@0 189 {
max@0 190 arma_extra_debug_sigprint();
max@0 191
max@0 192 Mat<eT>::operator=(X.get_ref());
max@0 193
max@0 194 return *this;
max@0 195 }
max@0 196
max@0 197
max@0 198
max@0 199 //! construct a row vector from a given auxiliary array
max@0 200 template<typename eT>
max@0 201 inline
max@0 202 Row<eT>::Row(eT* aux_mem, const uword aux_length, const bool copy_aux_mem, const bool strict)
max@0 203 : Mat<eT>(aux_mem, 1, aux_length, copy_aux_mem, strict)
max@0 204 {
max@0 205 arma_extra_debug_sigprint();
max@0 206
max@0 207 access::rw(Mat<eT>::vec_state) = 2;
max@0 208 }
max@0 209
max@0 210
max@0 211
max@0 212 //! construct a row vector from a given auxiliary array
max@0 213 template<typename eT>
max@0 214 inline
max@0 215 Row<eT>::Row(const eT* aux_mem, const uword aux_length)
max@0 216 : Mat<eT>(aux_mem, 1, aux_length)
max@0 217 {
max@0 218 arma_extra_debug_sigprint();
max@0 219
max@0 220 access::rw(Mat<eT>::vec_state) = 2;
max@0 221 }
max@0 222
max@0 223
max@0 224
max@0 225 template<typename eT>
max@0 226 template<typename T1, typename T2>
max@0 227 inline
max@0 228 Row<eT>::Row
max@0 229 (
max@0 230 const Base<typename Row<eT>::pod_type, T1>& A,
max@0 231 const Base<typename Row<eT>::pod_type, T2>& B
max@0 232 )
max@0 233 {
max@0 234 arma_extra_debug_sigprint();
max@0 235
max@0 236 access::rw(Mat<eT>::vec_state) = 2;
max@0 237
max@0 238 Mat<eT>::init(A,B);
max@0 239 }
max@0 240
max@0 241
max@0 242
max@0 243 template<typename eT>
max@0 244 template<typename T1>
max@0 245 inline
max@0 246 Row<eT>::Row(const BaseCube<eT,T1>& X)
max@0 247 {
max@0 248 arma_extra_debug_sigprint();
max@0 249
max@0 250 access::rw(Mat<eT>::vec_state) = 2;
max@0 251
max@0 252 Mat<eT>::operator=(X);
max@0 253 }
max@0 254
max@0 255
max@0 256
max@0 257 template<typename eT>
max@0 258 template<typename T1>
max@0 259 inline
max@0 260 const Row<eT>&
max@0 261 Row<eT>::operator=(const BaseCube<eT,T1>& X)
max@0 262 {
max@0 263 arma_extra_debug_sigprint();
max@0 264
max@0 265 Mat<eT>::operator=(X);
max@0 266
max@0 267 return *this;
max@0 268 }
max@0 269
max@0 270
max@0 271
max@0 272 template<typename eT>
max@0 273 inline
max@0 274 Row<eT>::Row(const subview_cube<eT>& X)
max@0 275 {
max@0 276 arma_extra_debug_sigprint();
max@0 277
max@0 278 access::rw(Mat<eT>::vec_state) = 2;
max@0 279
max@0 280 Mat<eT>::operator=(X);
max@0 281 }
max@0 282
max@0 283
max@0 284
max@0 285 template<typename eT>
max@0 286 inline
max@0 287 const Row<eT>&
max@0 288 Row<eT>::operator=(const subview_cube<eT>& X)
max@0 289 {
max@0 290 arma_extra_debug_sigprint();
max@0 291
max@0 292 Mat<eT>::operator=(X);
max@0 293
max@0 294 return *this;
max@0 295 }
max@0 296
max@0 297
max@0 298
max@0 299 template<typename eT>
max@0 300 inline
max@0 301 mat_injector< Row<eT> >
max@0 302 Row<eT>::operator<<(const eT val)
max@0 303 {
max@0 304 return mat_injector< Row<eT> >(*this, val);
max@0 305 }
max@0 306
max@0 307
max@0 308
max@0 309 template<typename eT>
max@0 310 arma_inline
max@0 311 eT&
max@0 312 Row<eT>::col(const uword col_num)
max@0 313 {
max@0 314 arma_debug_check( (col_num >= Mat<eT>::n_cols), "Row::col(): out of bounds" );
max@0 315
max@0 316 return access::rw(Mat<eT>::mem[col_num]);
max@0 317 }
max@0 318
max@0 319
max@0 320
max@0 321 template<typename eT>
max@0 322 arma_inline
max@0 323 eT
max@0 324 Row<eT>::col(const uword col_num) const
max@0 325 {
max@0 326 arma_debug_check( (col_num >= Mat<eT>::n_cols), "Row::col(): out of bounds" );
max@0 327
max@0 328 return Mat<eT>::mem[col_num];
max@0 329 }
max@0 330
max@0 331
max@0 332
max@0 333 template<typename eT>
max@0 334 arma_inline
max@0 335 subview_row<eT>
max@0 336 Row<eT>::cols(const uword in_col1, const uword in_col2)
max@0 337 {
max@0 338 arma_extra_debug_sigprint();
max@0 339
max@0 340 arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ), "Row::cols(): indices out of bounds or incorrectly used");
max@0 341
max@0 342 const uword subview_n_cols = in_col2 - in_col1 + 1;
max@0 343
max@0 344 return subview_row<eT>(*this, 0, in_col1, subview_n_cols);
max@0 345 }
max@0 346
max@0 347
max@0 348
max@0 349 template<typename eT>
max@0 350 arma_inline
max@0 351 const subview_row<eT>
max@0 352 Row<eT>::cols(const uword in_col1, const uword in_col2) const
max@0 353 {
max@0 354 arma_extra_debug_sigprint();
max@0 355
max@0 356 arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ), "Row::cols(): indices out of bounds or incorrectly used");
max@0 357
max@0 358 const uword subview_n_cols = in_col2 - in_col1 + 1;
max@0 359
max@0 360 return subview_row<eT>(*this, 0, in_col1, subview_n_cols);
max@0 361 }
max@0 362
max@0 363
max@0 364
max@0 365 template<typename eT>
max@0 366 arma_inline
max@0 367 subview_row<eT>
max@0 368 Row<eT>::subvec(const uword in_col1, const uword in_col2)
max@0 369 {
max@0 370 arma_extra_debug_sigprint();
max@0 371
max@0 372 arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ), "Row::subvec(): indices out of bounds or incorrectly used");
max@0 373
max@0 374 const uword subview_n_cols = in_col2 - in_col1 + 1;
max@0 375
max@0 376 return subview_row<eT>(*this, 0, in_col1, subview_n_cols);
max@0 377 }
max@0 378
max@0 379
max@0 380
max@0 381 template<typename eT>
max@0 382 arma_inline
max@0 383 const subview_row<eT>
max@0 384 Row<eT>::subvec(const uword in_col1, const uword in_col2) const
max@0 385 {
max@0 386 arma_extra_debug_sigprint();
max@0 387
max@0 388 arma_debug_check( ( (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols) ), "Row::subvec(): indices out of bounds or incorrectly used");
max@0 389
max@0 390 const uword subview_n_cols = in_col2 - in_col1 + 1;
max@0 391
max@0 392 return subview_row<eT>(*this, 0, in_col1, subview_n_cols);
max@0 393 }
max@0 394
max@0 395
max@0 396
max@0 397 template<typename eT>
max@0 398 arma_inline
max@0 399 subview_row<eT>
max@0 400 Row<eT>::subvec(const span& col_span)
max@0 401 {
max@0 402 arma_extra_debug_sigprint();
max@0 403
max@0 404 const bool col_all = col_span.whole;
max@0 405
max@0 406 const uword local_n_cols = Mat<eT>::n_cols;
max@0 407
max@0 408 const uword in_col1 = col_all ? 0 : col_span.a;
max@0 409 const uword in_col2 = col_span.b;
max@0 410 const uword subvec_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
max@0 411
max@0 412 arma_debug_check( ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ), "Row::subvec(): indices out of bounds or incorrectly used");
max@0 413
max@0 414 return subview_row<eT>(*this, 0, in_col1, subvec_n_cols);
max@0 415 }
max@0 416
max@0 417
max@0 418
max@0 419 template<typename eT>
max@0 420 arma_inline
max@0 421 const subview_row<eT>
max@0 422 Row<eT>::subvec(const span& col_span) const
max@0 423 {
max@0 424 arma_extra_debug_sigprint();
max@0 425
max@0 426 const bool col_all = col_span.whole;
max@0 427
max@0 428 const uword local_n_cols = Mat<eT>::n_cols;
max@0 429
max@0 430 const uword in_col1 = col_all ? 0 : col_span.a;
max@0 431 const uword in_col2 = col_span.b;
max@0 432 const uword subvec_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
max@0 433
max@0 434 arma_debug_check( ( col_all ? false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) ), "Row::subvec(): indices out of bounds or incorrectly used");
max@0 435
max@0 436 return subview_row<eT>(*this, 0, in_col1, subvec_n_cols);
max@0 437 }
max@0 438
max@0 439
max@0 440
max@0 441 // template<typename eT>
max@0 442 // arma_inline
max@0 443 // subview_row<eT>
max@0 444 // Row<eT>::operator()(const span& col_span)
max@0 445 // {
max@0 446 // arma_extra_debug_sigprint();
max@0 447 //
max@0 448 // return subvec(col_span);
max@0 449 // }
max@0 450 //
max@0 451 //
max@0 452 //
max@0 453 // template<typename eT>
max@0 454 // arma_inline
max@0 455 // const subview_row<eT>
max@0 456 // Row<eT>::operator()(const span& col_span) const
max@0 457 // {
max@0 458 // arma_extra_debug_sigprint();
max@0 459 //
max@0 460 // return subvec(col_span);
max@0 461 // }
max@0 462
max@0 463
max@0 464
max@0 465 //! remove specified columns
max@0 466 template<typename eT>
max@0 467 inline
max@0 468 void
max@0 469 Row<eT>::shed_col(const uword col_num)
max@0 470 {
max@0 471 arma_extra_debug_sigprint();
max@0 472
max@0 473 arma_debug_check( col_num >= Mat<eT>::n_cols, "Row::shed_col(): out of bounds");
max@0 474
max@0 475 shed_cols(col_num, col_num);
max@0 476 }
max@0 477
max@0 478
max@0 479
max@0 480 //! remove specified columns
max@0 481 template<typename eT>
max@0 482 inline
max@0 483 void
max@0 484 Row<eT>::shed_cols(const uword in_col1, const uword in_col2)
max@0 485 {
max@0 486 arma_extra_debug_sigprint();
max@0 487
max@0 488 arma_debug_check
max@0 489 (
max@0 490 (in_col1 > in_col2) || (in_col2 >= Mat<eT>::n_cols),
max@0 491 "Row::shed_cols(): indices out of bounds or incorrectly used"
max@0 492 );
max@0 493
max@0 494 const uword n_keep_front = in_col1;
max@0 495 const uword n_keep_back = Mat<eT>::n_cols - (in_col2 + 1);
max@0 496
max@0 497 Row<eT> X(n_keep_front + n_keep_back);
max@0 498
max@0 499 eT* X_mem = X.memptr();
max@0 500 const eT* t_mem = (*this).memptr();
max@0 501
max@0 502 if(n_keep_front > 0)
max@0 503 {
max@0 504 arrayops::copy( X_mem, t_mem, n_keep_front );
max@0 505 }
max@0 506
max@0 507 if(n_keep_back > 0)
max@0 508 {
max@0 509 arrayops::copy( &(X_mem[n_keep_front]), &(t_mem[in_col2+1]), n_keep_back);
max@0 510 }
max@0 511
max@0 512 Mat<eT>::steal_mem(X);
max@0 513 }
max@0 514
max@0 515
max@0 516
max@0 517 //! insert N cols at the specified col position,
max@0 518 //! optionally setting the elements of the inserted cols to zero
max@0 519 template<typename eT>
max@0 520 inline
max@0 521 void
max@0 522 Row<eT>::insert_cols(const uword col_num, const uword N, const bool set_to_zero)
max@0 523 {
max@0 524 arma_extra_debug_sigprint();
max@0 525
max@0 526 const uword t_n_cols = Mat<eT>::n_cols;
max@0 527
max@0 528 const uword A_n_cols = col_num;
max@0 529 const uword B_n_cols = t_n_cols - col_num;
max@0 530
max@0 531 // insertion at col_num == n_cols is in effect an append operation
max@0 532 arma_debug_check( (col_num > t_n_cols), "Row::insert_cols(): out of bounds");
max@0 533
max@0 534 if(N > 0)
max@0 535 {
max@0 536 Row<eT> out(t_n_cols + N);
max@0 537
max@0 538 eT* out_mem = out.memptr();
max@0 539 const eT* t_mem = (*this).memptr();
max@0 540
max@0 541 if(A_n_cols > 0)
max@0 542 {
max@0 543 arrayops::copy( out_mem, t_mem, A_n_cols );
max@0 544 }
max@0 545
max@0 546 if(B_n_cols > 0)
max@0 547 {
max@0 548 arrayops::copy( &(out_mem[col_num + N]), &(t_mem[col_num]), B_n_cols );
max@0 549 }
max@0 550
max@0 551 if(set_to_zero == true)
max@0 552 {
max@0 553 arrayops::inplace_set( &(out_mem[col_num]), eT(0), N );
max@0 554 }
max@0 555
max@0 556 Mat<eT>::steal_mem(out);
max@0 557 }
max@0 558 }
max@0 559
max@0 560
max@0 561
max@0 562 //! insert the given object at the specified col position;
max@0 563 //! the given object must have one row
max@0 564 template<typename eT>
max@0 565 template<typename T1>
max@0 566 inline
max@0 567 void
max@0 568 Row<eT>::insert_cols(const uword col_num, const Base<eT,T1>& X)
max@0 569 {
max@0 570 arma_extra_debug_sigprint();
max@0 571
max@0 572 Mat<eT>::insert_cols(col_num, X);
max@0 573 }
max@0 574
max@0 575
max@0 576
max@0 577 template<typename eT>
max@0 578 inline
max@0 579 typename Row<eT>::row_iterator
max@0 580 Row<eT>::begin_row(const uword row_num)
max@0 581 {
max@0 582 arma_extra_debug_sigprint();
max@0 583
max@0 584 arma_debug_check( (row_num >= Mat<eT>::n_rows), "begin_row(): index out of bounds");
max@0 585
max@0 586 return Mat<eT>::memptr();
max@0 587 }
max@0 588
max@0 589
max@0 590
max@0 591 template<typename eT>
max@0 592 inline
max@0 593 typename Row<eT>::const_row_iterator
max@0 594 Row<eT>::begin_row(const uword row_num) const
max@0 595 {
max@0 596 arma_extra_debug_sigprint();
max@0 597
max@0 598 arma_debug_check( (row_num >= Mat<eT>::n_rows), "begin_row(): index out of bounds");
max@0 599
max@0 600 return Mat<eT>::memptr();
max@0 601 }
max@0 602
max@0 603
max@0 604
max@0 605 template<typename eT>
max@0 606 inline
max@0 607 typename Row<eT>::row_iterator
max@0 608 Row<eT>::end_row(const uword row_num)
max@0 609 {
max@0 610 arma_extra_debug_sigprint();
max@0 611
max@0 612 arma_debug_check( (row_num >= Mat<eT>::n_rows), "end_row(): index out of bounds");
max@0 613
max@0 614 return Mat<eT>::memptr() + Mat<eT>::n_cols;
max@0 615 }
max@0 616
max@0 617
max@0 618
max@0 619 template<typename eT>
max@0 620 inline
max@0 621 typename Row<eT>::const_row_iterator
max@0 622 Row<eT>::end_row(const uword row_num) const
max@0 623 {
max@0 624 arma_extra_debug_sigprint();
max@0 625
max@0 626 arma_debug_check( (row_num >= Mat<eT>::n_rows), "end_row(): index out of bounds");
max@0 627
max@0 628 return Mat<eT>::memptr() + Mat<eT>::n_cols;
max@0 629 }
max@0 630
max@0 631
max@0 632
max@0 633 template<typename eT>
max@0 634 template<uword fixed_n_elem>
max@0 635 arma_inline
max@0 636 void
max@0 637 Row<eT>::fixed<fixed_n_elem>::mem_setup()
max@0 638 {
max@0 639 arma_extra_debug_sigprint();
max@0 640
max@0 641 access::rw(Mat<eT>::n_rows) = 1;
max@0 642 access::rw(Mat<eT>::n_cols) = fixed_n_elem;
max@0 643 access::rw(Mat<eT>::n_elem) = fixed_n_elem;
max@0 644 access::rw(Mat<eT>::vec_state) = 2;
max@0 645 access::rw(Mat<eT>::mem_state) = 3;
max@0 646 access::rw(Mat<eT>::mem) = (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
max@0 647 }
max@0 648
max@0 649
max@0 650
max@0 651 template<typename eT>
max@0 652 template<uword fixed_n_elem>
max@0 653 inline
max@0 654 Row<eT>::fixed<fixed_n_elem>::fixed()
max@0 655 {
max@0 656 arma_extra_debug_sigprint_this(this);
max@0 657
max@0 658 mem_setup();
max@0 659 }
max@0 660
max@0 661
max@0 662
max@0 663 template<typename eT>
max@0 664 template<uword fixed_n_elem>
max@0 665 arma_inline
max@0 666 Row<eT>::fixed<fixed_n_elem>::fixed(const fixed<fixed_n_elem>& X)
max@0 667 {
max@0 668 arma_extra_debug_sigprint_this(this);
max@0 669
max@0 670 mem_setup();
max@0 671
max@0 672 eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
max@0 673
max@0 674 arrayops::copy( dest, X.mem, fixed_n_elem );
max@0 675 }
max@0 676
max@0 677
max@0 678
max@0 679 template<typename eT>
max@0 680 template<uword fixed_n_elem>
max@0 681 arma_inline
max@0 682 Row<eT>::fixed<fixed_n_elem>::fixed(const subview_cube<eT>& X)
max@0 683 {
max@0 684 arma_extra_debug_sigprint_this(this);
max@0 685
max@0 686 mem_setup();
max@0 687
max@0 688 Row<eT>::operator=(X);
max@0 689 }
max@0 690
max@0 691
max@0 692
max@0 693 template<typename eT>
max@0 694 template<uword fixed_n_elem>
max@0 695 template<typename T1>
max@0 696 arma_inline
max@0 697 Row<eT>::fixed<fixed_n_elem>::fixed(const Base<eT,T1>& A)
max@0 698 {
max@0 699 arma_extra_debug_sigprint_this(this);
max@0 700
max@0 701 mem_setup();
max@0 702
max@0 703 Row<eT>::operator=(A.get_ref());
max@0 704 }
max@0 705
max@0 706
max@0 707
max@0 708 template<typename eT>
max@0 709 template<uword fixed_n_elem>
max@0 710 template<typename T1, typename T2>
max@0 711 arma_inline
max@0 712 Row<eT>::fixed<fixed_n_elem>::fixed(const Base<pod_type,T1>& A, const Base<pod_type,T2>& B)
max@0 713 {
max@0 714 arma_extra_debug_sigprint_this(this);
max@0 715
max@0 716 mem_setup();
max@0 717
max@0 718 Row<eT>::init(A,B);
max@0 719 }
max@0 720
max@0 721
max@0 722
max@0 723 template<typename eT>
max@0 724 template<uword fixed_n_elem>
max@0 725 inline
max@0 726 Row<eT>::fixed<fixed_n_elem>::fixed(eT* aux_mem, const bool copy_aux_mem)
max@0 727 {
max@0 728 arma_extra_debug_sigprint_this(this);
max@0 729
max@0 730 access::rw(Mat<eT>::n_rows) = 1;
max@0 731 access::rw(Mat<eT>::n_cols) = fixed_n_elem;
max@0 732 access::rw(Mat<eT>::n_elem) = fixed_n_elem;
max@0 733 access::rw(Mat<eT>::vec_state) = 2;
max@0 734 access::rw(Mat<eT>::mem_state) = 3;
max@0 735
max@0 736 if(copy_aux_mem == true)
max@0 737 {
max@0 738 eT* dest = (use_extra) ? mem_local_extra : Mat<eT>::mem_local;
max@0 739
max@0 740 access::rw(Mat<eT>::mem) = dest;
max@0 741
max@0 742 arrayops::copy( dest, aux_mem, fixed_n_elem );
max@0 743 }
max@0 744 else
max@0 745 {
max@0 746 access::rw(Mat<eT>::mem) = aux_mem;
max@0 747 }
max@0 748 }
max@0 749
max@0 750
max@0 751
max@0 752 template<typename eT>
max@0 753 template<uword fixed_n_elem>
max@0 754 inline
max@0 755 Row<eT>::fixed<fixed_n_elem>::fixed(const eT* aux_mem)
max@0 756 {
max@0 757 arma_extra_debug_sigprint_this(this);
max@0 758
max@0 759 mem_setup();
max@0 760
max@0 761 arrayops::copy( const_cast<eT*>(Mat<eT>::mem), aux_mem, fixed_n_elem );
max@0 762 }
max@0 763
max@0 764
max@0 765
max@0 766 template<typename eT>
max@0 767 template<uword fixed_n_elem>
max@0 768 inline
max@0 769 Row<eT>::fixed<fixed_n_elem>::fixed(const char* text)
max@0 770 {
max@0 771 arma_extra_debug_sigprint_this(this);
max@0 772
max@0 773 mem_setup();
max@0 774
max@0 775 Row<eT>::operator=(text);
max@0 776 }
max@0 777
max@0 778
max@0 779
max@0 780 template<typename eT>
max@0 781 template<uword fixed_n_elem>
max@0 782 inline
max@0 783 Row<eT>::fixed<fixed_n_elem>::fixed(const std::string& text)
max@0 784 {
max@0 785 arma_extra_debug_sigprint_this(this);
max@0 786
max@0 787 mem_setup();
max@0 788
max@0 789 Row<eT>::operator=(text);
max@0 790 }
max@0 791
max@0 792
max@0 793
max@0 794 template<typename eT>
max@0 795 template<uword fixed_n_elem>
max@0 796 inline
max@0 797 subview_row<eT>
max@0 798 Row<eT>::fixed<fixed_n_elem>::operator()(const uword row_num, const span& col_span)
max@0 799 {
max@0 800 arma_extra_debug_sigprint();
max@0 801
max@0 802 return Mat<eT>::operator()(row_num, col_span);
max@0 803 }
max@0 804
max@0 805
max@0 806
max@0 807 template<typename eT>
max@0 808 template<uword fixed_n_elem>
max@0 809 template<typename T1>
max@0 810 const Row<eT>&
max@0 811 Row<eT>::fixed<fixed_n_elem>::operator=(const Base<eT,T1>& A)
max@0 812 {
max@0 813 arma_extra_debug_sigprint();
max@0 814
max@0 815 Row<eT>::operator=(A.get_ref());
max@0 816
max@0 817 return *this;
max@0 818 }
max@0 819
max@0 820
max@0 821
max@0 822 template<typename eT>
max@0 823 template<uword fixed_n_elem>
max@0 824 const Row<eT>&
max@0 825 Row<eT>::fixed<fixed_n_elem>::operator=(const eT val)
max@0 826 {
max@0 827 arma_extra_debug_sigprint();
max@0 828
max@0 829 Row<eT>::operator=(val);
max@0 830
max@0 831 return *this;
max@0 832 }
max@0 833
max@0 834
max@0 835
max@0 836 template<typename eT>
max@0 837 template<uword fixed_n_elem>
max@0 838 const Row<eT>&
max@0 839 Row<eT>::fixed<fixed_n_elem>::operator=(const char* text)
max@0 840 {
max@0 841 arma_extra_debug_sigprint();
max@0 842
max@0 843 Row<eT>::operator=(text);
max@0 844
max@0 845 return *this;
max@0 846 }
max@0 847
max@0 848
max@0 849
max@0 850 template<typename eT>
max@0 851 template<uword fixed_n_elem>
max@0 852 const Row<eT>&
max@0 853 Row<eT>::fixed<fixed_n_elem>::operator=(const std::string& text)
max@0 854 {
max@0 855 arma_extra_debug_sigprint();
max@0 856
max@0 857 Row<eT>::operator=(text);
max@0 858
max@0 859 return *this;
max@0 860 }
max@0 861
max@0 862
max@0 863
max@0 864 template<typename eT>
max@0 865 template<uword fixed_n_elem>
max@0 866 const Row<eT>&
max@0 867 Row<eT>::fixed<fixed_n_elem>::operator=(const subview_cube<eT>& X)
max@0 868 {
max@0 869 arma_extra_debug_sigprint();
max@0 870
max@0 871 Row<eT>::operator=(X);
max@0 872
max@0 873 return *this;
max@0 874 }
max@0 875
max@0 876
max@0 877
max@0 878 template<typename eT>
max@0 879 template<uword fixed_n_elem>
max@0 880 inline
max@0 881 const subview_row<eT>
max@0 882 Row<eT>::fixed<fixed_n_elem>::operator()(const uword row_num, const span& col_span) const
max@0 883 {
max@0 884 arma_extra_debug_sigprint();
max@0 885
max@0 886 return Mat<eT>::operator()(row_num, col_span);
max@0 887 }
max@0 888
max@0 889
max@0 890
max@0 891 template<typename eT>
max@0 892 template<uword fixed_n_elem>
max@0 893 inline
max@0 894 subview_col<eT>
max@0 895 Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const uword col_num)
max@0 896 {
max@0 897 arma_extra_debug_sigprint();
max@0 898
max@0 899 return Mat<eT>::operator()(row_span, col_num);
max@0 900 }
max@0 901
max@0 902
max@0 903
max@0 904 template<typename eT>
max@0 905 template<uword fixed_n_elem>
max@0 906 inline
max@0 907 const subview_col<eT>
max@0 908 Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const uword col_num) const
max@0 909 {
max@0 910 arma_extra_debug_sigprint();
max@0 911
max@0 912 return Mat<eT>::operator()(row_span, col_num);
max@0 913 }
max@0 914
max@0 915
max@0 916
max@0 917 template<typename eT>
max@0 918 template<uword fixed_n_elem>
max@0 919 inline
max@0 920 subview<eT>
max@0 921 Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const span& col_span)
max@0 922 {
max@0 923 arma_extra_debug_sigprint();
max@0 924
max@0 925 return Mat<eT>::operator()(row_span, col_span);
max@0 926 }
max@0 927
max@0 928
max@0 929
max@0 930 template<typename eT>
max@0 931 template<uword fixed_n_elem>
max@0 932 inline
max@0 933 const subview<eT>
max@0 934 Row<eT>::fixed<fixed_n_elem>::operator()(const span& row_span, const span& col_span) const
max@0 935 {
max@0 936 arma_extra_debug_sigprint();
max@0 937
max@0 938 return Mat<eT>::operator()(row_span, col_span);
max@0 939 }
max@0 940
max@0 941
max@0 942
max@0 943 template<typename eT>
max@0 944 template<uword fixed_n_elem>
max@0 945 arma_inline
max@0 946 arma_warn_unused
max@0 947 eT&
max@0 948 Row<eT>::fixed<fixed_n_elem>::operator[] (const uword i)
max@0 949 {
max@0 950 return access::rw( Mat<eT>::mem[i] );
max@0 951 }
max@0 952
max@0 953
max@0 954
max@0 955 template<typename eT>
max@0 956 template<uword fixed_n_elem>
max@0 957 arma_inline
max@0 958 arma_warn_unused
max@0 959 eT
max@0 960 Row<eT>::fixed<fixed_n_elem>::operator[] (const uword i) const
max@0 961 {
max@0 962 return ( Mat<eT>::mem[i] );
max@0 963 }
max@0 964
max@0 965
max@0 966
max@0 967 template<typename eT>
max@0 968 template<uword fixed_n_elem>
max@0 969 arma_inline
max@0 970 arma_warn_unused
max@0 971 eT&
max@0 972 Row<eT>::fixed<fixed_n_elem>::at(const uword i)
max@0 973 {
max@0 974 return access::rw( Mat<eT>::mem[i] );
max@0 975 }
max@0 976
max@0 977
max@0 978
max@0 979 template<typename eT>
max@0 980 template<uword fixed_n_elem>
max@0 981 arma_inline
max@0 982 arma_warn_unused
max@0 983 eT
max@0 984 Row<eT>::fixed<fixed_n_elem>::at(const uword i) const
max@0 985 {
max@0 986 return ( Mat<eT>::mem[i] );
max@0 987 }
max@0 988
max@0 989
max@0 990
max@0 991 template<typename eT>
max@0 992 template<uword fixed_n_elem>
max@0 993 arma_inline
max@0 994 arma_warn_unused
max@0 995 eT&
max@0 996 Row<eT>::fixed<fixed_n_elem>::operator() (const uword i)
max@0 997 {
max@0 998 arma_debug_check( (i >= fixed_n_elem), "Row::fixed::operator(): out of bounds");
max@0 999
max@0 1000 return access::rw( Mat<eT>::mem[i] );
max@0 1001 }
max@0 1002
max@0 1003
max@0 1004
max@0 1005 template<typename eT>
max@0 1006 template<uword fixed_n_elem>
max@0 1007 arma_inline
max@0 1008 arma_warn_unused
max@0 1009 eT
max@0 1010 Row<eT>::fixed<fixed_n_elem>::operator() (const uword i) const
max@0 1011 {
max@0 1012 arma_debug_check( (i >= fixed_n_elem), "Row::fixed::operator(): out of bounds");
max@0 1013
max@0 1014 return ( Mat<eT>::mem[i] );
max@0 1015 }
max@0 1016
max@0 1017
max@0 1018
max@0 1019 template<typename eT>
max@0 1020 template<uword fixed_n_elem>
max@0 1021 arma_inline
max@0 1022 arma_warn_unused
max@0 1023 eT&
max@0 1024 Row<eT>::fixed<fixed_n_elem>::at(const uword in_row, const uword in_col)
max@0 1025 {
max@0 1026 return access::rw( Mat<eT>::mem[in_col] );
max@0 1027 }
max@0 1028
max@0 1029
max@0 1030
max@0 1031 template<typename eT>
max@0 1032 template<uword fixed_n_elem>
max@0 1033 arma_inline
max@0 1034 arma_warn_unused
max@0 1035 eT
max@0 1036 Row<eT>::fixed<fixed_n_elem>::at(const uword in_row, const uword in_col) const
max@0 1037 {
max@0 1038 return ( Mat<eT>::mem[in_col] );
max@0 1039 }
max@0 1040
max@0 1041
max@0 1042
max@0 1043 template<typename eT>
max@0 1044 template<uword fixed_n_elem>
max@0 1045 arma_inline
max@0 1046 arma_warn_unused
max@0 1047 eT&
max@0 1048 Row<eT>::fixed<fixed_n_elem>::operator() (const uword in_row, const uword in_col)
max@0 1049 {
max@0 1050 arma_debug_check( ((in_row >= 1) || (in_col >= fixed_n_elem)), "Row::fixed::operator(): out of bounds" );
max@0 1051
max@0 1052 return access::rw( Mat<eT>::mem[in_col] );
max@0 1053 }
max@0 1054
max@0 1055
max@0 1056
max@0 1057 template<typename eT>
max@0 1058 template<uword fixed_n_elem>
max@0 1059 arma_inline
max@0 1060 arma_warn_unused
max@0 1061 eT
max@0 1062 Row<eT>::fixed<fixed_n_elem>::operator() (const uword in_row, const uword in_col) const
max@0 1063 {
max@0 1064 arma_debug_check( ((in_row >= 1) || (in_col >= fixed_n_elem)), "Row::fixed::operator(): out of bounds" );
max@0 1065
max@0 1066 return ( Mat<eT>::mem[in_col] );
max@0 1067 }
max@0 1068
max@0 1069
max@0 1070
max@0 1071 template<typename eT>
max@0 1072 template<uword fixed_n_elem>
max@0 1073 arma_hot
max@0 1074 inline
max@0 1075 const Row<eT>&
max@0 1076 Row<eT>::fixed<fixed_n_elem>::fill(const eT val)
max@0 1077 {
max@0 1078 arma_extra_debug_sigprint();
max@0 1079
max@0 1080 arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), val, fixed_n_elem );
max@0 1081
max@0 1082 return *this;
max@0 1083 }
max@0 1084
max@0 1085
max@0 1086
max@0 1087 template<typename eT>
max@0 1088 template<uword fixed_n_elem>
max@0 1089 arma_hot
max@0 1090 inline
max@0 1091 const Row<eT>&
max@0 1092 Row<eT>::fixed<fixed_n_elem>::zeros()
max@0 1093 {
max@0 1094 arma_extra_debug_sigprint();
max@0 1095
max@0 1096 arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(0), fixed_n_elem );
max@0 1097
max@0 1098 return *this;
max@0 1099 }
max@0 1100
max@0 1101
max@0 1102
max@0 1103 template<typename eT>
max@0 1104 template<uword fixed_n_elem>
max@0 1105 arma_hot
max@0 1106 inline
max@0 1107 const Row<eT>&
max@0 1108 Row<eT>::fixed<fixed_n_elem>::ones()
max@0 1109 {
max@0 1110 arma_extra_debug_sigprint();
max@0 1111
max@0 1112 arrayops::inplace_set( const_cast<eT*>(Mat<eT>::mem), eT(1), fixed_n_elem );
max@0 1113
max@0 1114 return *this;
max@0 1115 }
max@0 1116
max@0 1117
max@0 1118
max@0 1119 #ifdef ARMA_EXTRA_ROW_MEAT
max@0 1120 #include ARMA_INCFILE_WRAP(ARMA_EXTRA_ROW_MEAT)
max@0 1121 #endif
max@0 1122
max@0 1123
max@0 1124
max@0 1125 //! @}