annotate armadillo-3.900.4/include/armadillo_bits/Row_meat.hpp @ 84:55a047986812 tip

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