forked from xtensor-stack/xtensor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxscalar.hpp
More file actions
1098 lines (900 loc) · 32.8 KB
/
Copy pathxscalar.hpp
File metadata and controls
1098 lines (900 loc) · 32.8 KB
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
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/***************************************************************************
* Copyright (c) 2016, Johan Mabille, Sylvain Corlay and Wolf Vollprecht *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/
#ifndef XTENSOR_SCALAR_HPP
#define XTENSOR_SCALAR_HPP
#include <array>
#include <cstddef>
#include <utility>
#include <xtl/xtype_traits.hpp>
#include "xexpression.hpp"
#include "xiterable.hpp"
#include "xlayout.hpp"
#include "xtensor_simd.hpp"
namespace xt
{
/***********
* xscalar *
***********/
// xscalar is a cheap wrapper for a scalar value as an xexpression.
template <bool is_const, class CT>
class xscalar_stepper;
template <bool is_const, class CT>
class xdummy_iterator;
template <class CT>
class xscalar;
template <class CT>
struct xiterable_inner_types<xscalar<CT>>
{
using value_type = std::decay_t<CT>;
using inner_shape_type = std::array<std::size_t, 0>;
using shape_type = inner_shape_type;
using const_stepper = xscalar_stepper<true, CT>;
using stepper = xscalar_stepper<false, CT>;
};
#define DL XTENSOR_DEFAULT_LAYOUT
template <class CT>
class xscalar : public xexpression<xscalar<CT>>,
private xiterable<xscalar<CT>>
{
public:
using self_type = xscalar<CT>;
using value_type = std::decay_t<CT>;
using reference = value_type&;
using const_reference = const value_type&;
using pointer = value_type*;
using const_pointer = const value_type*;
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
using simd_value_type = xsimd::simd_type<value_type>;
using iterable_base = xiterable<self_type>;
using inner_shape_type = typename iterable_base::inner_shape_type;
using shape_type = inner_shape_type;
using expression_tag = xscalar_expression_tag;
using stepper = typename iterable_base::stepper;
using const_stepper = typename iterable_base::const_stepper;
template <layout_type L>
using layout_iterator = typename iterable_base::template layout_iterator<L>;
template <layout_type L>
using const_layout_iterator = typename iterable_base::template const_layout_iterator<L>;
template <layout_type L>
using reverse_layout_iterator = typename iterable_base::template reverse_layout_iterator<L>;
template <layout_type L>
using const_reverse_layout_iterator = typename iterable_base::template const_reverse_layout_iterator<L>;
template <class S, layout_type L>
using broadcast_iterator = typename iterable_base::template broadcast_iterator<S, L>;
template <class S, layout_type L>
using const_broadcast_iterator = typename iterable_base::template const_broadcast_iterator<S, L>;
template <class S, layout_type L>
using reverse_broadcast_iterator = typename iterable_base::template reverse_broadcast_iterator<S, L>;
template <class S, layout_type L>
using const_reverse_broadcast_iterator = typename iterable_base::template const_reverse_broadcast_iterator<S, L>;
using iterator = value_type*;
using const_iterator = const value_type*;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using dummy_iterator = xdummy_iterator<false, CT>;
using const_dummy_iterator = xdummy_iterator<true, CT>;
static constexpr layout_type static_layout = layout_type::any;
static constexpr bool contiguous_layout = true;
xscalar() noexcept;
xscalar(CT value) noexcept;
operator value_type&() noexcept;
operator const value_type&() const noexcept;
size_type size() const noexcept;
size_type dimension() const noexcept;
const shape_type& shape() const noexcept;
layout_type layout() const noexcept;
template <class... Args>
reference operator()(Args...) noexcept;
template <class... Args>
reference at(Args...);
template <class... Args>
reference unchecked(Args...) noexcept;
template <class S>
disable_integral_t<S, reference> operator[](const S&) noexcept;
template <class I>
reference operator[](std::initializer_list<I>) noexcept;
reference operator[](size_type) noexcept;
template <class... Args>
const_reference operator()(Args...) const noexcept;
template <class... Args>
const_reference at(Args...) const;
template <class... Args>
const_reference unchecked(Args...) const noexcept;
template <class S>
disable_integral_t<S, const_reference> operator[](const S&) const noexcept;
template <class I>
const_reference operator[](std::initializer_list<I>) const noexcept;
const_reference operator[](size_type) const noexcept;
template <class It>
reference element(It, It) noexcept;
template <class It>
const_reference element(It, It) const noexcept;
template <class S>
bool broadcast_shape(S& shape, bool reuse_cache = false) const noexcept;
template <class S>
bool has_linear_assign(const S& strides) const noexcept;
template <layout_type L = DL>
iterator begin() noexcept;
template <layout_type L = DL>
iterator end() noexcept;
template <layout_type L = DL>
const_iterator begin() const noexcept;
template <layout_type L = DL>
const_iterator end() const noexcept;
template <layout_type L = DL>
const_iterator cbegin() const noexcept;
template <layout_type L = DL>
const_iterator cend() const noexcept;
template <layout_type L = DL>
reverse_iterator rbegin() noexcept;
template <layout_type L = DL>
reverse_iterator rend() noexcept;
template <layout_type L = DL>
const_reverse_iterator rbegin() const noexcept;
template <layout_type L = DL>
const_reverse_iterator rend() const noexcept;
template <layout_type L = DL>
const_reverse_iterator crbegin() const noexcept;
template <layout_type L = DL>
const_reverse_iterator crend() const noexcept;
template <class S, layout_type L = DL>
broadcast_iterator<S, L> begin(const S& shape) noexcept;
template <class S, layout_type L = DL>
broadcast_iterator<S, L> end(const S& shape) noexcept;
template <class S, layout_type L = DL>
const_broadcast_iterator<S, L> begin(const S& shape) const noexcept;
template <class S, layout_type L = DL>
const_broadcast_iterator<S, L> end(const S& shape) const noexcept;
template <class S, layout_type L = DL>
const_broadcast_iterator<S, L> cbegin(const S& shape) const noexcept;
template <class S, layout_type L = DL>
const_broadcast_iterator<S, L> cend(const S& shape) const noexcept;
template <class S, layout_type L = DL>
reverse_broadcast_iterator<S, L> rbegin(const S& shape) noexcept;
template <class S, layout_type L = DL>
reverse_broadcast_iterator<S, L> rend(const S& shape) noexcept;
template <class S, layout_type L = DL>
const_reverse_broadcast_iterator<S, L> rbegin(const S& shape) const noexcept;
template <class S, layout_type L = DL>
const_reverse_broadcast_iterator<S, L> rend(const S& shape) const noexcept;
template <class S, layout_type L = DL>
const_reverse_broadcast_iterator<S, L> crbegin(const S& shape) const noexcept;
template <class S, layout_type L = DL>
const_reverse_broadcast_iterator<S, L> crend(const S& shape) const noexcept;
iterator storage_begin() noexcept;
iterator storage_end() noexcept;
const_iterator storage_begin() const noexcept;
const_iterator storage_end() const noexcept;
const_iterator storage_cbegin() const noexcept;
const_iterator storage_cend() const noexcept;
reverse_iterator storage_rbegin() noexcept;
reverse_iterator storage_rend() noexcept;
const_reverse_iterator storage_rbegin() const noexcept;
const_reverse_iterator storage_rend() const noexcept;
const_reverse_iterator storage_crbegin() const noexcept;
const_reverse_iterator storage_crend() const noexcept;
template <class S>
stepper stepper_begin(const S& shape) noexcept;
template <class S>
stepper stepper_end(const S& shape, layout_type l) noexcept;
template <class S>
const_stepper stepper_begin(const S& shape) const noexcept;
template <class S>
const_stepper stepper_end(const S& shape, layout_type l) const noexcept;
dummy_iterator dummy_begin() noexcept;
dummy_iterator dummy_end() noexcept;
const_dummy_iterator dummy_begin() const noexcept;
const_dummy_iterator dummy_end() const noexcept;
reference data_element(size_type i) noexcept;
const_reference data_element(size_type i) const noexcept;
template <class align, class simd = simd_value_type>
void store_simd(size_type i, const simd& e);
template <class align, class requested_type = value_type,
std::size_t N = xsimd::simd_traits<requested_type>::size>
xsimd::simd_return_type<value_type, requested_type>
load_simd(size_type i) const;
private:
CT m_value;
friend class xconst_iterable<self_type>;
friend class xiterable<self_type>;
};
#undef DL
namespace detail
{
template <class E>
struct is_xscalar_impl : std::false_type
{
};
template <class E>
struct is_xscalar_impl<xscalar<E>> : std::true_type
{
};
}
template <class E>
using is_xscalar = detail::is_xscalar_impl<E>;
namespace detail
{
template <class... E>
struct all_xscalar
{
static constexpr bool value = xtl::conjunction<is_xscalar<std::decay_t<E>>...>::value;
};
}
// Note: MSVC bug workaround. Cannot just define
// template <class... E>
// using all_xscalar = xtl::conjunction<is_xscalar<std::decay_t<E>>...>;
template <class... E>
using all_xscalar = detail::all_xscalar<E...>;
/******************
* xref and xcref *
******************/
template <class T>
xscalar<T&> xref(T& t);
template <class T>
xscalar<const T&> xcref(T& t);
/*******************
* xscalar_stepper *
*******************/
template <bool is_const, class CT>
class xscalar_stepper
{
public:
using self_type = xscalar_stepper<is_const, CT>;
using storage_type = std::conditional_t<is_const,
const xscalar<CT>,
xscalar<CT>>;
using value_type = typename storage_type::value_type;
using reference = std::conditional_t<is_const,
typename storage_type::const_reference,
typename storage_type::reference>;
using pointer = std::conditional_t<is_const,
typename storage_type::const_pointer,
typename storage_type::pointer>;
using size_type = typename storage_type::size_type;
using difference_type = typename storage_type::difference_type;
xscalar_stepper(storage_type* c) noexcept;
reference operator*() const noexcept;
void step(size_type dim, size_type n = 1) noexcept;
void step_back(size_type dim, size_type n = 1) noexcept;
void reset(size_type dim) noexcept;
void reset_back(size_type dim) noexcept;
void to_begin() noexcept;
void to_end(layout_type l) noexcept;
template <class R>
R step_simd();
value_type step_leading();
private:
storage_type* p_c;
};
/*******************
* xdummy_iterator *
*******************/
namespace detail
{
template <bool is_const, class CT>
using dummy_reference_t = std::conditional_t<is_const,
typename xscalar<CT>::const_reference,
typename xscalar<CT>::reference>;
template <bool is_const, class CT>
using dummy_pointer_t = std::conditional_t<is_const,
typename xscalar<CT>::const_pointer,
typename xscalar<CT>::pointer>;
}
template <bool is_const, class CT>
class xdummy_iterator
: public xtl::xrandom_access_iterator_base<xdummy_iterator<is_const, CT>,
typename xscalar<CT>::value_type,
typename xscalar<CT>::difference_type,
detail::dummy_pointer_t<is_const, CT>,
detail::dummy_reference_t<is_const, CT>>
{
public:
using self_type = xdummy_iterator<is_const, CT>;
using storage_type = std::conditional_t<is_const,
const xscalar<CT>,
xscalar<CT>>;
using value_type = typename storage_type::value_type;
using reference = detail::dummy_reference_t<is_const, CT>;
using pointer = detail::dummy_pointer_t<is_const, CT>;
using difference_type = typename storage_type::difference_type;
using iterator_category = std::random_access_iterator_tag;
explicit xdummy_iterator(storage_type* c) noexcept;
self_type& operator++() noexcept;
self_type& operator--() noexcept;
self_type& operator+=(difference_type n) noexcept;
self_type& operator-=(difference_type n) noexcept;
difference_type operator-(const self_type& rhs) const noexcept;
reference operator*() const noexcept;
bool equal(const self_type& rhs) const noexcept;
bool less_than(const self_type& rhs) const noexcept;
private:
storage_type* p_c;
};
template <bool is_const, class CT>
bool operator==(const xdummy_iterator<is_const, CT>& lhs,
const xdummy_iterator<is_const, CT>& rhs) noexcept;
template <bool is_const, class CT>
bool operator<(const xdummy_iterator<is_const, CT>& lhs,
const xdummy_iterator<is_const, CT>& rhs) noexcept;
template <class T>
struct is_xdummy_iterator : std::false_type
{
};
template <bool is_const, class CT>
struct is_xdummy_iterator<xdummy_iterator<is_const, CT>> : std::true_type
{
};
/*****************************
* linear_begin / linear_end *
*****************************/
namespace detail
{
template <class CT>
constexpr auto linear_begin(xscalar<CT>& c) noexcept -> decltype(c.dummy_begin())
{
return c.dummy_begin();
}
template <class CT>
constexpr auto linear_end(xscalar<CT>& c) noexcept -> decltype(c.dummy_end())
{
return c.dummy_end();
}
template <class CT>
constexpr auto linear_begin(const xscalar<CT>& c) noexcept -> decltype(c.dummy_begin())
{
return c.dummy_begin();
}
template <class CT>
constexpr auto linear_end(const xscalar<CT>& c) noexcept -> decltype(c.dummy_end())
{
return c.dummy_end();
}
}
/**************************
* xscalar implementation *
**************************/
// This constructor will not compile when CT is a reference type.
template <class CT>
inline xscalar<CT>::xscalar() noexcept
: m_value()
{
}
template <class CT>
inline xscalar<CT>::xscalar(CT value) noexcept
: m_value(value)
{
}
template <class CT>
inline xscalar<CT>::operator value_type&() noexcept
{
return m_value;
}
template <class CT>
inline xscalar<CT>::operator const value_type&() const noexcept
{
return m_value;
}
template <class CT>
inline auto xscalar<CT>::size() const noexcept -> size_type
{
return 1;
}
template <class CT>
inline auto xscalar<CT>::dimension() const noexcept -> size_type
{
return 0;
}
template <class CT>
inline auto xscalar<CT>::shape() const noexcept -> const shape_type&
{
static std::array<size_type, 0> zero_shape;
return zero_shape;
}
template <class CT>
inline layout_type xscalar<CT>::layout() const noexcept
{
return static_layout;
}
template <class CT>
template <class... Args>
inline auto xscalar<CT>::operator()(Args...) noexcept -> reference
{
XTENSOR_CHECK_DIMENSION((std::array<int, 0>()), Args()...);
return m_value;
}
template <class CT>
template <class... Args>
inline auto xscalar<CT>::at(Args... args) -> reference
{
check_dimension(shape(), args...);
return this->operator()(args...);
}
template <class CT>
template <class... Args>
inline auto xscalar<CT>::unchecked(Args...) noexcept -> reference
{
return m_value;
}
template <class CT>
template <class S>
inline auto xscalar<CT>::operator[](const S&) noexcept
-> disable_integral_t<S, reference>
{
return m_value;
}
template <class CT>
template <class I>
inline auto xscalar<CT>::operator[](std::initializer_list<I>) noexcept
-> reference
{
return m_value;
}
template <class CT>
inline auto xscalar<CT>::operator[](size_type) noexcept -> reference
{
return m_value;
}
template <class CT>
template <class... Args>
inline auto xscalar<CT>::operator()(Args...) const noexcept -> const_reference
{
XTENSOR_CHECK_DIMENSION((std::array<int, 0>()), Args()...);
return m_value;
}
template <class CT>
template <class... Args>
inline auto xscalar<CT>::at(Args... args) const -> const_reference
{
check_dimension(shape(), args...);
return this->operator()(args...);
}
template <class CT>
template <class... Args>
inline auto xscalar<CT>::unchecked(Args...) const noexcept -> const_reference
{
return m_value;
}
template <class CT>
template <class S>
inline auto xscalar<CT>::operator[](const S&) const noexcept
-> disable_integral_t<S, const_reference>
{
return m_value;
}
template <class CT>
template <class I>
inline auto xscalar<CT>::operator[](std::initializer_list<I>) const noexcept
-> const_reference
{
return m_value;
}
template <class CT>
inline auto xscalar<CT>::operator[](size_type) const noexcept -> const_reference
{
return m_value;
}
template <class CT>
template <class It>
inline auto xscalar<CT>::element(It, It) noexcept -> reference
{
return m_value;
}
template <class CT>
template <class It>
inline auto xscalar<CT>::element(It, It) const noexcept -> const_reference
{
return m_value;
}
template <class CT>
template <class S>
inline bool xscalar<CT>::broadcast_shape(S&, bool) const noexcept
{
return true;
}
template <class CT>
template <class S>
inline bool xscalar<CT>::has_linear_assign(const S&) const noexcept
{
return true;
}
template <class CT>
template <layout_type L>
inline auto xscalar<CT>::begin() noexcept -> iterator
{
return &m_value;
}
template <class CT>
template <layout_type L>
inline auto xscalar<CT>::end() noexcept -> iterator
{
return &m_value + 1;
}
template <class CT>
template <layout_type L>
inline auto xscalar<CT>::begin() const noexcept -> const_iterator
{
return &m_value;
}
template <class CT>
template <layout_type L>
inline auto xscalar<CT>::end() const noexcept -> const_iterator
{
return &m_value + 1;
}
template <class CT>
template <layout_type L>
inline auto xscalar<CT>::cbegin() const noexcept -> const_iterator
{
return &m_value;
}
template <class CT>
template <layout_type L>
inline auto xscalar<CT>::cend() const noexcept -> const_iterator
{
return &m_value + 1;
}
template <class CT>
template <layout_type L>
inline auto xscalar<CT>::rbegin() noexcept -> reverse_iterator
{
return reverse_storage_iterator(end());
}
template <class CT>
template <layout_type L>
inline auto xscalar<CT>::rend() noexcept -> reverse_iterator
{
return reverse_storage_iterator(begin());
}
template <class CT>
template <layout_type L>
inline auto xscalar<CT>::rbegin() const noexcept -> const_reverse_iterator
{
return crbegin();
}
template <class CT>
template <layout_type L>
inline auto xscalar<CT>::rend() const noexcept -> const_reverse_iterator
{
return crend();
}
template <class CT>
template <layout_type L>
inline auto xscalar<CT>::crbegin() const noexcept -> const_reverse_iterator
{
return const_reverse_storage_iterator(cend());
}
template <class CT>
template <layout_type L>
inline auto xscalar<CT>::crend() const noexcept -> const_reverse_iterator
{
return const_reverse_storage_iterator(cbegin());
}
/*****************************
* Broadcasting iterator api *
*****************************/
template <class CT>
template <class S, layout_type L>
inline auto xscalar<CT>::begin(const S& shape) noexcept -> broadcast_iterator<S, L>
{
return iterable_base::template begin<S, L>(shape);
}
template <class CT>
template <class S, layout_type L>
inline auto xscalar<CT>::end(const S& shape) noexcept -> broadcast_iterator<S, L>
{
return iterable_base::template end<S, L>(shape);
}
template <class CT>
template <class S, layout_type L>
inline auto xscalar<CT>::begin(const S& shape) const noexcept -> const_broadcast_iterator<S, L>
{
return iterable_base::template begin<S, L>(shape);
}
template <class CT>
template <class S, layout_type L>
inline auto xscalar<CT>::end(const S& shape) const noexcept -> const_broadcast_iterator<S, L>
{
return iterable_base::template end<S, L>(shape);
}
template <class CT>
template <class S, layout_type L>
inline auto xscalar<CT>::cbegin(const S& shape) const noexcept -> const_broadcast_iterator<S, L>
{
return iterable_base::template cbegin<S, L>(shape);
}
template <class CT>
template <class S, layout_type L>
inline auto xscalar<CT>::cend(const S& shape) const noexcept -> const_broadcast_iterator<S, L>
{
return iterable_base::template cend<S, L>(shape);
}
template <class CT>
template <class S, layout_type L>
inline auto xscalar<CT>::rbegin(const S& shape) noexcept -> reverse_broadcast_iterator<S, L>
{
return iterable_base::template rbegin<S, L>(shape);
}
template <class CT>
template <class S, layout_type L>
inline auto xscalar<CT>::rend(const S& shape) noexcept -> reverse_broadcast_iterator<S, L>
{
return iterable_base::template rend<S, L>(shape);
}
template <class CT>
template <class S, layout_type L>
inline auto xscalar<CT>::rbegin(const S& shape) const noexcept -> const_reverse_broadcast_iterator<S, L>
{
return iterable_base::template rbegin<S, L>(shape);
}
template <class CT>
template <class S, layout_type L>
inline auto xscalar<CT>::rend(const S& shape) const noexcept -> const_reverse_broadcast_iterator<S, L>
{
return iterable_base::template rend<S, L>(shape);
}
template <class CT>
template <class S, layout_type L>
inline auto xscalar<CT>::crbegin(const S& shape) const noexcept -> const_reverse_broadcast_iterator<S, L>
{
return iterable_base::template crbegin<S, L>(shape);
}
template <class CT>
template <class S, layout_type L>
inline auto xscalar<CT>::crend(const S& shape) const noexcept -> const_reverse_broadcast_iterator<S, L>
{
return iterable_base::template crend<S, L>(shape);
}
template <class CT>
inline auto xscalar<CT>::storage_begin() noexcept -> iterator
{
return this->template begin<XTENSOR_DEFAULT_LAYOUT>();
}
template <class CT>
inline auto xscalar<CT>::storage_end() noexcept -> iterator
{
return this->template end<XTENSOR_DEFAULT_LAYOUT>();
}
template <class CT>
inline auto xscalar<CT>::storage_begin() const noexcept -> const_iterator
{
return this->template begin<XTENSOR_DEFAULT_LAYOUT>();
}
template <class CT>
inline auto xscalar<CT>::storage_end() const noexcept -> const_iterator
{
return this->template end<XTENSOR_DEFAULT_LAYOUT>();
}
template <class CT>
inline auto xscalar<CT>::storage_cbegin() const noexcept -> const_iterator
{
return this->template cbegin<XTENSOR_DEFAULT_LAYOUT>();
}
template <class CT>
inline auto xscalar<CT>::storage_cend() const noexcept -> const_iterator
{
return this->template cend<XTENSOR_DEFAULT_LAYOUT>();
}
template <class CT>
inline auto xscalar<CT>::storage_rbegin() noexcept -> reverse_iterator
{
return this->template rbegin<XTENSOR_DEFAULT_LAYOUT>();
}
template <class CT>
inline auto xscalar<CT>::storage_rend() noexcept -> reverse_iterator
{
return this->template rend<XTENSOR_DEFAULT_LAYOUT>();
}
template <class CT>
inline auto xscalar<CT>::storage_rbegin() const noexcept -> const_reverse_iterator
{
return this->template rbegin<XTENSOR_DEFAULT_LAYOUT>();
}
template <class CT>
inline auto xscalar<CT>::storage_rend() const noexcept -> const_reverse_iterator
{
return this->template rend<XTENSOR_DEFAULT_LAYOUT>();
}
template <class CT>
inline auto xscalar<CT>::storage_crbegin() const noexcept -> const_reverse_iterator
{
return this->template crbegin<XTENSOR_DEFAULT_LAYOUT>();
}
template <class CT>
inline auto xscalar<CT>::storage_crend() const noexcept -> const_reverse_iterator
{
return this->template crend<XTENSOR_DEFAULT_LAYOUT>();
}
template <class CT>
template <class S>
inline auto xscalar<CT>::stepper_begin(const S&) noexcept -> stepper
{
return stepper(this, false);
}
template <class CT>
template <class S>
inline auto xscalar<CT>::stepper_end(const S&, layout_type) noexcept -> stepper
{
return stepper(this);
}
template <class CT>
template <class S>
inline auto xscalar<CT>::stepper_begin(const S&) const noexcept -> const_stepper
{
return const_stepper(this);
}
template <class CT>
template <class S>
inline auto xscalar<CT>::stepper_end(const S&, layout_type) const noexcept -> const_stepper
{
return const_stepper(this);
}
template <class CT>
inline auto xscalar<CT>::dummy_begin() noexcept -> dummy_iterator
{
return dummy_iterator(this);
}
template <class CT>
inline auto xscalar<CT>::dummy_end() noexcept -> dummy_iterator
{
return dummy_iterator(this);
}
template <class CT>
inline auto xscalar<CT>::dummy_begin() const noexcept -> const_dummy_iterator
{
return const_dummy_iterator(this);
}
template <class CT>
inline auto xscalar<CT>::dummy_end() const noexcept -> const_dummy_iterator
{
return const_dummy_iterator(this);
}
template <class CT>
inline auto xscalar<CT>::data_element(size_type) noexcept -> reference
{
return m_value;
}
template <class CT>
inline auto xscalar<CT>::data_element(size_type) const noexcept -> const_reference
{
return m_value;
}
template <class CT>
template <class align, class simd>
inline void xscalar<CT>::store_simd(size_type, const simd& e)
{
m_value = static_cast<value_type>(e[0]);
}
template <class CT>
template <class align, class requested_type, std::size_t N>
inline auto xscalar<CT>::load_simd(size_type) const
-> xsimd::simd_return_type<value_type, requested_type>
{
return xsimd::set_simd<value_type, requested_type>(m_value);
}
template <class T>
inline xscalar<T&> xref(T& t)
{
return xscalar<T&>(t);
}
template <class T>
inline xscalar<const T&> xcref(T& t)
{
return xscalar<const T&>(t);
}
/**********************************
* xscalar_stepper implementation *
**********************************/
template <bool is_const, class CT>
inline xscalar_stepper<is_const, CT>::xscalar_stepper(storage_type* c) noexcept
: p_c(c)
{
}
template <bool is_const, class CT>
inline auto xscalar_stepper<is_const, CT>::operator*() const noexcept -> reference
{
return p_c->operator()();
}
template <bool is_const, class CT>
inline void xscalar_stepper<is_const, CT>::step(size_type /*dim*/, size_type /*n*/) noexcept
{
}
template <bool is_const, class CT>
inline void xscalar_stepper<is_const, CT>::step_back(size_type /*dim*/, size_type /*n*/) noexcept
{
}
template <bool is_const, class CT>
inline void xscalar_stepper<is_const, CT>::reset(size_type /*dim*/) noexcept
{
}
template <bool is_const, class CT>
inline void xscalar_stepper<is_const, CT>::reset_back(size_type /*dim*/) noexcept
{
}