summaryrefslogtreecommitdiffstats
path: root/src/armadillo/include/armadillo_bits/subview_bones.hpp
blob: 95553a10ef3e328ca3bcef5e70f9238867380ef5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
// SPDX-License-Identifier: Apache-2.0
// 
// Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
// Copyright 2008-2016 National ICT Australia (NICTA)
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------------


//! \addtogroup subview
//! @{


//! Class for storing data required to construct or apply operations to a submatrix
//! (ie. where the submatrix starts and ends as well as a reference/pointer to the original matrix),
template<typename eT>
class subview : public Base< eT, subview<eT> >
  {
  public:
  
  typedef eT                                       elem_type;
  typedef typename get_pod_type<elem_type>::result pod_type;
  
  arma_aligned const Mat<eT>& m;
  
  static constexpr bool is_row  = false;
  static constexpr bool is_col  = false;
  static constexpr bool is_xvec = false;
  
  const uword aux_row1;
  const uword aux_col1;
  
  const uword n_rows;
  const uword n_cols;
  const uword n_elem;
  
  protected:
  
  arma_inline subview(const Mat<eT>& in_m, const uword in_row1, const uword in_col1, const uword in_n_rows, const uword in_n_cols);
  
  
  public:
  
  inline ~subview();
  inline  subview() = delete;
  
  inline  subview(const subview&  in);
  inline  subview(      subview&& in);
  
  template<typename op_type             > inline void inplace_op(const eT           val                        );
  template<typename op_type, typename T1> inline void inplace_op(const Base<eT,T1>& x,   const char* identifier);
  template<typename op_type             > inline void inplace_op(const subview<eT>& x,   const char* identifier);
  
  // deliberately returning void
  
  inline void operator=  (const eT val);
  inline void operator+= (const eT val);
  inline void operator-= (const eT val);
  inline void operator*= (const eT val);
  inline void operator/= (const eT val);
  
  inline void operator=  (const subview& x);
  inline void operator+= (const subview& x);
  inline void operator-= (const subview& x);
  inline void operator%= (const subview& x);
  inline void operator/= (const subview& x);
  
  template<typename T1> inline void operator=  (const Base<eT,T1>& x);
  template<typename T1> inline void operator+= (const Base<eT,T1>& x);
  template<typename T1> inline void operator-= (const Base<eT,T1>& x);
  template<typename T1> inline void operator%= (const Base<eT,T1>& x);
  template<typename T1> inline void operator/= (const Base<eT,T1>& x);
  
  template<typename T1> inline void operator=  (const SpBase<eT,T1>& x);
  template<typename T1> inline void operator+= (const SpBase<eT,T1>& x);
  template<typename T1> inline void operator-= (const SpBase<eT,T1>& x);
  template<typename T1> inline void operator%= (const SpBase<eT,T1>& x);
  template<typename T1> inline void operator/= (const SpBase<eT,T1>& x);

  template<typename T1, typename gen_type>
  inline typename enable_if2< is_same_type<typename T1::elem_type, eT>::value, void>::result operator=(const Gen<T1,gen_type>& x);
  
  inline void operator=(const std::initializer_list<eT>& list);
  inline void operator=(const std::initializer_list< std::initializer_list<eT> >& list);
  
  
  inline static void extract(Mat<eT>& out, const subview& in);
  
  inline static void  plus_inplace(Mat<eT>& out, const subview& in);
  inline static void minus_inplace(Mat<eT>& out, const subview& in);
  inline static void schur_inplace(Mat<eT>& out, const subview& in);
  inline static void   div_inplace(Mat<eT>& out, const subview& in);
  
  template<typename functor> inline void  for_each(functor F);
  template<typename functor> inline void  for_each(functor F) const;
  
  template<typename functor> inline void transform(functor F);
  template<typename functor> inline void     imbue(functor F);
  
  inline void replace(const eT old_val, const eT new_val);
  
  inline void clean(const pod_type threshold);
  
  inline void clamp(const eT min_val, const eT max_val);
  
  inline void fill(const eT val);
  inline void zeros();
  inline void ones();
  inline void eye();
  inline void randu();
  inline void randn();
  
  arma_warn_unused inline eT  at_alt    (const uword ii) const;
  
  arma_warn_unused inline eT& operator[](const uword ii);
  arma_warn_unused inline eT  operator[](const uword ii) const;
  
  arma_warn_unused inline eT& operator()(const uword ii);
  arma_warn_unused inline eT  operator()(const uword ii) const;
  
  arma_warn_unused inline eT& operator()(const uword in_row, const uword in_col);
  arma_warn_unused inline eT  operator()(const uword in_row, const uword in_col) const;
  
  arma_warn_unused inline eT&         at(const uword in_row, const uword in_col);
  arma_warn_unused inline eT          at(const uword in_row, const uword in_col) const;
  
  arma_warn_unused inline eT& front();
  arma_warn_unused inline eT  front() const;
  
  arma_warn_unused inline eT& back();
  arma_warn_unused inline eT  back() const;
  
  arma_inline       eT* colptr(const uword in_col);
  arma_inline const eT* colptr(const uword in_col) const;
  
  template<typename eT2>
  inline bool check_overlap(const subview<eT2>& x) const;
  
  arma_warn_unused inline bool is_vec()    const;
  arma_warn_unused inline bool is_finite() const;
  arma_warn_unused inline bool is_zero(const pod_type tol = 0) const;
  
  arma_warn_unused inline bool has_inf()       const;
  arma_warn_unused inline bool has_nan()       const;
  arma_warn_unused inline bool has_nonfinite() const;
  
  inline       subview_row<eT> row(const uword row_num);
  inline const subview_row<eT> row(const uword row_num) const;
  
  inline            subview_row<eT> operator()(const uword row_num, const span& col_span);
  inline      const subview_row<eT> operator()(const uword row_num, const span& col_span) const;
  
  inline       subview_col<eT> col(const uword col_num);
  inline const subview_col<eT> col(const uword col_num) const;
  
  inline            subview_col<eT> operator()(const span& row_span, const uword col_num);
  inline      const subview_col<eT> operator()(const span& row_span, const uword col_num) const;
  
  inline            Col<eT>  unsafe_col(const uword col_num);
  inline      const Col<eT>  unsafe_col(const uword col_num) const;
  
  inline       subview<eT> rows(const uword in_row1, const uword in_row2);
  inline const subview<eT> rows(const uword in_row1, const uword in_row2) const;
  
  inline       subview<eT> cols(const uword in_col1, const uword in_col2);
  inline const subview<eT> cols(const uword in_col1, const uword in_col2) const;
  
  inline       subview<eT> submat(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2);
  inline const subview<eT> submat(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2) const;
  
  inline            subview<eT> submat    (const span& row_span, const span& col_span);
  inline      const subview<eT> submat    (const span& row_span, const span& col_span) const;
  
  inline            subview<eT> operator()(const span& row_span, const span& col_span);
  inline      const subview<eT> operator()(const span& row_span, const span& col_span) const;
  
  inline subview_each1< subview<eT>, 0 > each_col();
  inline subview_each1< subview<eT>, 1 > each_row();
  
  template<typename T1> inline subview_each2< subview<eT>, 0, T1 > each_col(const Base<uword, T1>& indices);
  template<typename T1> inline subview_each2< subview<eT>, 1, T1 > each_row(const Base<uword, T1>& indices);
  
  inline void each_col(const std::function< void(      Col<eT>&) >& F);
  inline void each_col(const std::function< void(const Col<eT>&) >& F) const;
  
  inline void each_row(const std::function< void(      Row<eT>&) >& F);
  inline void each_row(const std::function< void(const Row<eT>&) >& F) const;
  
  inline       diagview<eT> diag(const sword in_id = 0);
  inline const diagview<eT> diag(const sword in_id = 0) const;
  
  inline void swap_rows(const uword in_row1, const uword in_row2);
  inline void swap_cols(const uword in_col1, const uword in_col2);
  
  
  class const_iterator;
  
  class iterator
    {
    public:
    
    inline iterator();
    inline iterator(const iterator& X);
    inline iterator(subview<eT>& in_sv, const uword in_row, const uword in_col);
    
    arma_warn_unused inline eT& operator*();
    
                     inline iterator& operator++();
    arma_warn_unused inline iterator  operator++(int);
    
    arma_warn_unused inline bool operator==(const       iterator& rhs) const;
    arma_warn_unused inline bool operator!=(const       iterator& rhs) const;
    arma_warn_unused inline bool operator==(const const_iterator& rhs) const;
    arma_warn_unused inline bool operator!=(const const_iterator& rhs) const;
    
    typedef std::forward_iterator_tag iterator_category;
    typedef eT                        value_type;
    typedef std::ptrdiff_t            difference_type;  // TODO: not certain on this one
    typedef eT*                       pointer;
    typedef eT&                       reference;
    
    arma_aligned Mat<eT>* M;
    arma_aligned eT*      current_ptr;
    arma_aligned uword    current_row;
    arma_aligned uword    current_col;
    
    arma_aligned const uword aux_row1;
    arma_aligned const uword aux_row2_p1;
    };
  
  
  class const_iterator
    {
    public:
    
    inline const_iterator();
    inline const_iterator(const       iterator& X);
    inline const_iterator(const const_iterator& X);
    inline const_iterator(const subview<eT>& in_sv, const uword in_row, const uword in_col);
    
    arma_warn_unused inline const eT& operator*();
    
                     inline const_iterator& operator++();
    arma_warn_unused inline const_iterator  operator++(int);
    
    arma_warn_unused inline bool operator==(const       iterator& rhs) const;
    arma_warn_unused inline bool operator!=(const       iterator& rhs) const;
    arma_warn_unused inline bool operator==(const const_iterator& rhs) const;
    arma_warn_unused inline bool operator!=(const const_iterator& rhs) const;
    
    // So that we satisfy the STL iterator types.
    typedef std::forward_iterator_tag iterator_category;
    typedef eT                        value_type;
    typedef std::ptrdiff_t            difference_type;  // TODO: not certain on this one
    typedef const eT*                 pointer;
    typedef const eT&                 reference;
    
    arma_aligned const Mat<eT>* M;
    arma_aligned const eT*      current_ptr;
    arma_aligned       uword    current_row;
    arma_aligned       uword    current_col;
    
    arma_aligned const uword aux_row1;
    arma_aligned const uword aux_row2_p1;
    };
  
  
  class const_row_iterator;
  
  class row_iterator
    {
    public:
    
    inline row_iterator();
    inline row_iterator(const row_iterator& X);
    inline row_iterator(subview<eT>& in_sv, const uword in_row, const uword in_col);
    
    arma_warn_unused inline eT& operator* ();
    
                     inline row_iterator& operator++();
    arma_warn_unused inline row_iterator  operator++(int);
    
    arma_warn_unused inline bool operator!=(const       row_iterator& X) const;
    arma_warn_unused inline bool operator==(const       row_iterator& X) const;
    arma_warn_unused inline bool operator!=(const const_row_iterator& X) const;
    arma_warn_unused inline bool operator==(const const_row_iterator& X) const;
    
    typedef std::forward_iterator_tag iterator_category;
    typedef eT                        value_type;
    typedef std::ptrdiff_t            difference_type;  // TODO: not certain on this one
    typedef eT*                       pointer;
    typedef eT&                       reference;
    
    arma_aligned Mat<eT>* M;
    arma_aligned uword    current_row;
    arma_aligned uword    current_col;
    
    arma_aligned const uword aux_col1;
    arma_aligned const uword aux_col2_p1;
    };
  
  
  class const_row_iterator
    {
    public:
    
    inline const_row_iterator();
    inline const_row_iterator(const       row_iterator& X);
    inline const_row_iterator(const const_row_iterator& X);
    inline const_row_iterator(const subview<eT>& in_sv, const uword in_row, const uword in_col);
    
    arma_warn_unused inline const eT& operator*() const;
    
                     inline const_row_iterator& operator++();
    arma_warn_unused inline const_row_iterator  operator++(int);
    
    arma_warn_unused inline bool operator!=(const       row_iterator& X) const;
    arma_warn_unused inline bool operator==(const       row_iterator& X) const;
    arma_warn_unused inline bool operator!=(const const_row_iterator& X) const;
    arma_warn_unused inline bool operator==(const const_row_iterator& X) const;
    
    typedef std::forward_iterator_tag iterator_category;
    typedef eT                        value_type;
    typedef std::ptrdiff_t            difference_type;  // TODO: not certain on this one
    typedef const eT*                 pointer;
    typedef const eT&                 reference;
    
    arma_aligned const Mat<eT>* M;
    arma_aligned       uword    current_row;
    arma_aligned       uword    current_col;
    
    arma_aligned const uword aux_col1;
    arma_aligned const uword aux_col2_p1;
    };
  
  
  
  inline       iterator  begin();
  inline const_iterator  begin() const;
  inline const_iterator cbegin() const;
  
  inline       iterator  end();
  inline const_iterator  end() const;
  inline const_iterator cend() const;
  
  
  friend class Mat<eT>;
  };



template<typename eT>
class subview_col : public subview<eT>
  {
  public:
  
  typedef eT                                       elem_type;
  typedef typename get_pod_type<elem_type>::result pod_type;
  
  static constexpr bool is_row  = false;
  static constexpr bool is_col  = true;
  static constexpr bool is_xvec = false;
  
  const eT* colmem;
  
  inline void operator= (const subview<eT>& x);
  inline void operator= (const subview_col& x);
  inline void operator= (const eT val);
  inline void operator= (const std::initializer_list<eT>& list);
  
  template<typename T1> inline void operator= (const   Base<eT,T1>& x);
  template<typename T1> inline void operator= (const SpBase<eT,T1>& x);
  
  template<typename T1, typename gen_type>
  inline typename enable_if2< is_same_type<typename T1::elem_type, eT>::value, void>::result operator=(const Gen<T1,gen_type>& x);
  
  arma_warn_unused arma_inline const Op<subview_col<eT>,op_htrans>  t() const;
  arma_warn_unused arma_inline const Op<subview_col<eT>,op_htrans> ht() const;
  arma_warn_unused arma_inline const Op<subview_col<eT>,op_strans> st() const;
  
  arma_warn_unused arma_inline const Op<subview_col<eT>,op_strans> as_row() const;
  
  inline void fill(const eT val);
  inline void zeros();
  inline void ones();
  
  arma_inline eT  at_alt    (const uword i) const;
  
  arma_inline eT& operator[](const uword i);
  arma_inline eT  operator[](const uword i) const;
  
  inline eT& operator()(const uword i);
  inline eT  operator()(const uword i) const;
  
  inline eT& operator()(const uword in_row, const uword in_col);
  inline eT  operator()(const uword in_row, const uword in_col) const;
  
  inline eT&         at(const uword in_row, const uword in_col);
  inline eT          at(const uword in_row, const uword in_col) const;
  
  arma_inline       eT* colptr(const uword in_col);
  arma_inline const eT* colptr(const uword in_col) const;
  
  inline       subview_col<eT> rows(const uword in_row1, const uword in_row2);
  inline const subview_col<eT> rows(const uword in_row1, const uword in_row2) const;
  
  inline       subview_col<eT> subvec(const uword in_row1, const uword in_row2);
  inline const subview_col<eT> subvec(const uword in_row1, const uword in_row2) const;
  
  inline       subview_col<eT> subvec(const uword start_row, const SizeMat& s);
  inline const subview_col<eT> subvec(const uword start_row, const SizeMat& s) const;
  
  inline       subview_col<eT> head(const uword N);
  inline const subview_col<eT> head(const uword N) const;
  
  inline       subview_col<eT> tail(const uword N);
  inline const subview_col<eT> tail(const uword N) const;
  
  arma_warn_unused inline eT min() const;
  arma_warn_unused inline eT max() const;
  
  inline eT min(uword& index_of_min_val) const;
  inline eT max(uword& index_of_max_val) const;
  
  arma_warn_unused inline uword index_min() const;
  arma_warn_unused inline uword index_max() const;
  
  inline  subview_col(const subview_col&  in);
  inline  subview_col(      subview_col&& in);
  
  
  protected:
  
  inline subview_col(const Mat<eT>& in_m, const uword in_col);
  inline subview_col(const Mat<eT>& in_m, const uword in_col, const uword in_row1, const uword in_n_rows);
  inline subview_col() = delete;
  
  
  friend class Mat<eT>;
  friend class Col<eT>;
  friend class subview<eT>;
  };



template<typename eT>
class subview_cols : public subview<eT>
  {
  public:
  
  typedef eT                                       elem_type;
  typedef typename get_pod_type<elem_type>::result pod_type;
  
  static constexpr bool is_row  = false;
  static constexpr bool is_col  = false;
  static constexpr bool is_xvec = false;
  
  inline  subview_cols(const subview_cols&  in);
  inline  subview_cols(      subview_cols&& in);
  
  inline void operator= (const subview<eT>&  x);
  inline void operator= (const subview_cols& x);
  inline void operator= (const eT val);
  inline void operator= (const std::initializer_list<eT>& list);
  inline void operator= (const std::initializer_list< std::initializer_list<eT> >& list);
  
  template<typename T1> inline void operator= (const   Base<eT,T1>& x);
  template<typename T1> inline void operator= (const SpBase<eT,T1>& x);
  
  template<typename T1, typename gen_type>
  inline typename enable_if2< is_same_type<typename T1::elem_type, eT>::value, void>::result operator=(const Gen<T1,gen_type>& x);
  
  arma_warn_unused arma_inline const Op<subview_cols<eT>,op_htrans>  t() const;
  arma_warn_unused arma_inline const Op<subview_cols<eT>,op_htrans> ht() const;
  arma_warn_unused arma_inline const Op<subview_cols<eT>,op_strans> st() const;
  
  arma_warn_unused arma_inline const Op<subview_cols<eT>,op_vectorise_col> as_col() const;
  
  arma_warn_unused inline eT  at_alt    (const uword ii) const;
  
  arma_warn_unused inline eT& operator[](const uword ii);
  arma_warn_unused inline eT  operator[](const uword ii) const;
  
  arma_warn_unused inline eT& operator()(const uword ii);
  arma_warn_unused inline eT  operator()(const uword ii) const;
  
  arma_warn_unused inline eT& operator()(const uword in_row, const uword in_col);
  arma_warn_unused inline eT  operator()(const uword in_row, const uword in_col) const;
  
  arma_warn_unused inline eT&         at(const uword in_row, const uword in_col);
  arma_warn_unused inline eT          at(const uword in_row, const uword in_col) const;
  
  arma_inline       eT* colptr(const uword in_col);
  arma_inline const eT* colptr(const uword in_col) const;
  
  protected:
  
  inline subview_cols(const Mat<eT>& in_m, const uword in_col1, const uword in_n_cols);
  inline subview_cols() = delete;
  
  friend class Mat<eT>;
  friend class subview<eT>;
  };



template<typename eT>
class subview_row : public subview<eT>
  {
  public:
  
  typedef eT                                       elem_type;
  typedef typename get_pod_type<elem_type>::result pod_type;
  
  static constexpr bool is_row  = true;
  static constexpr bool is_col  = false;
  static constexpr bool is_xvec = false;
  
  inline void operator= (const subview<eT>& x);
  inline void operator= (const subview_row& x);
  inline void operator= (const eT val);
  inline void operator= (const std::initializer_list<eT>& list);
  
  template<typename T1> inline void operator= (const   Base<eT,T1>& x);
  template<typename T1> inline void operator= (const SpBase<eT,T1>& x);
  
  template<typename T1, typename gen_type>
  inline typename enable_if2< is_same_type<typename T1::elem_type, eT>::value, void>::result operator=(const Gen<T1,gen_type>& x);
  
  arma_warn_unused arma_inline const Op<subview_row<eT>,op_htrans>  t() const;
  arma_warn_unused arma_inline const Op<subview_row<eT>,op_htrans> ht() const;
  arma_warn_unused arma_inline const Op<subview_row<eT>,op_strans> st() const;
  
  arma_warn_unused arma_inline const Op<subview_row<eT>,op_strans> as_col() const;
  
  inline eT  at_alt    (const uword i) const;
  
  inline eT& operator[](const uword i);
  inline eT  operator[](const uword i) const;
  
  inline eT& operator()(const uword i);
  inline eT  operator()(const uword i) const;
  
  inline eT& operator()(const uword in_row, const uword in_col);
  inline eT  operator()(const uword in_row, const uword in_col) const;
  
  inline eT&         at(const uword in_row, const uword in_col);
  inline eT          at(const uword in_row, const uword in_col) const;
  
  inline       subview_row<eT> cols(const uword in_col1, const uword in_col2);
  inline const subview_row<eT> cols(const uword in_col1, const uword in_col2) const;
  
  inline       subview_row<eT> subvec(const uword in_col1, const uword in_col2);
  inline const subview_row<eT> subvec(const uword in_col1, const uword in_col2) const;
  
  inline       subview_row<eT> subvec(const uword start_col, const SizeMat& s);
  inline const subview_row<eT> subvec(const uword start_col, const SizeMat& s) const;
  
  inline       subview_row<eT> head(const uword N);
  inline const subview_row<eT> head(const uword N) const;
  
  inline       subview_row<eT> tail(const uword N);
  inline const subview_row<eT> tail(const uword N) const;
  
  arma_warn_unused inline uword index_min() const;
  arma_warn_unused inline uword index_max() const;
  
  inline typename subview<eT>::row_iterator        begin();
  inline typename subview<eT>::const_row_iterator  begin() const;
  inline typename subview<eT>::const_row_iterator cbegin() const;
  
  inline typename subview<eT>::row_iterator        end();
  inline typename subview<eT>::const_row_iterator  end() const;
  inline typename subview<eT>::const_row_iterator cend() const;
  
  inline  subview_row(const subview_row&  in);
  inline  subview_row(      subview_row&& in);
  
  
  protected:
  
  inline subview_row(const Mat<eT>& in_m, const uword in_row);
  inline subview_row(const Mat<eT>& in_m, const uword in_row, const uword in_col1, const uword in_n_cols);
  inline subview_row() = delete;
  
  
  friend class Mat<eT>;
  friend class Row<eT>;
  friend class subview<eT>;
  };



template<typename eT>
class subview_row_strans : public Base< eT, subview_row_strans<eT> >
  {
  public:
  
  typedef eT                                       elem_type;
  typedef typename get_pod_type<elem_type>::result pod_type;
  
  static constexpr bool is_row  = false;
  static constexpr bool is_col  = true;
  static constexpr bool is_xvec = false;
  
  arma_aligned const subview_row<eT>& sv_row;
  
  const uword n_rows;     // equal to n_elem
  const uword n_elem;
  
  static constexpr uword n_cols = 1;
  
  
  inline explicit subview_row_strans(const subview_row<eT>& in_sv_row);
  
  inline void extract(Mat<eT>& out) const;
  
  inline eT  at_alt    (const uword i) const;
  
  inline eT  operator[](const uword i) const;
  inline eT  operator()(const uword i) const;
  
  inline eT  operator()(const uword in_row, const uword in_col) const;
  inline eT          at(const uword in_row, const uword in_col) const;
  };



template<typename eT>
class subview_row_htrans : public Base< eT, subview_row_htrans<eT> >
  {
  public:
  
  typedef eT                                       elem_type;
  typedef typename get_pod_type<elem_type>::result pod_type;
  
  static constexpr bool is_row  = false;
  static constexpr bool is_col  = true;
  static constexpr bool is_xvec = false;
  
  arma_aligned const subview_row<eT>& sv_row;
  
  const uword n_rows;     // equal to n_elem
  const uword n_elem;
  
  static constexpr uword n_cols = 1;
  
  
  inline explicit subview_row_htrans(const subview_row<eT>& in_sv_row);
  
  inline void extract(Mat<eT>& out) const;
  
  inline eT  at_alt    (const uword i) const;
  
  inline eT  operator[](const uword i) const;
  inline eT  operator()(const uword i) const;
  
  inline eT  operator()(const uword in_row, const uword in_col) const;
  inline eT          at(const uword in_row, const uword in_col) const;
  };



//! @}