/
DQuatTransExpr.h
1337 lines (1152 loc) · 59.3 KB
/
DQuatTransExpr.h
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
//=================================================================================================
/*!
// \file blaze_tensor/math/expressions/DQuatTransExpr.h
// \brief Header file for the dense tensor transpose expression
//
// Copyright (C) 2012-2018 Klaus Iglberger - All Rights Reserved
// Copyright (C) 2018-2019 Hartmut Kaiser - All Rights Reserved
// Copyright (C) 2019 Bita Hasheminezhad - All Rights Reserved
//
// This file is part of the Blaze library. You can redistribute it and/or modify it under
// the terms of the New (Revised) BSD License. Redistribution and use in source and binary
// forms, with or without modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
// 3. Neither the names of the Blaze development group nor the names of its contributors
// may be used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
*/
//=================================================================================================
#ifndef _BLAZE_TENSOR_MATH_EXPRESSIONS_DQUATTRANSEXPR_H_
#define _BLAZE_TENSOR_MATH_EXPRESSIONS_DQUATTRANSEXPR_H_
//*************************************************************************************************
// Includes
//*************************************************************************************************
#include <iterator>
#include <blaze/math/Aliases.h>
#include <blaze/math/Exception.h>
#include <blaze/math/constraints/RequiresEvaluation.h>
#include <blaze/math/constraints/StorageOrder.h>
#include <blaze/math/expressions/Computation.h>
#include <blaze/math/expressions/Forward.h>
#include <blaze/math/expressions/Transformation.h>
#include <blaze/math/shims/Serial.h>
#include <blaze/math/simd/SIMDTrait.h>
#include <blaze/math/typetraits/HasConstDataAccess.h>
#include <blaze/math/typetraits/IsAligned.h>
#include <blaze/math/typetraits/IsComputation.h>
#include <blaze/math/typetraits/IsExpression.h>
#include <blaze/math/typetraits/IsHermitian.h>
#include <blaze/math/typetraits/IsLower.h>
#include <blaze/math/typetraits/IsPadded.h>
#include <blaze/math/typetraits/IsStrictlyLower.h>
#include <blaze/math/typetraits/IsStrictlyUpper.h>
#include <blaze/math/typetraits/IsSymmetric.h>
#include <blaze/math/typetraits/IsUniLower.h>
#include <blaze/math/typetraits/IsUniUpper.h>
#include <blaze/math/typetraits/IsUpper.h>
#include <blaze/math/typetraits/RequiresEvaluation.h>
#include <blaze/system/Inline.h>
#include <blaze/util/Assert.h>
#include <blaze/util/EnableIf.h>
#include <blaze/util/FunctionTrace.h>
#include <blaze/util/InvalidType.h>
#include <blaze/util/Types.h>
#include <blaze/util/mpl/If.h>
#include <blaze/util/typetraits/GetMemberType.h>
#include <blaze_tensor/math/constraints/DenseArray.h>
#include <blaze_tensor/math/expressions/DenseArray.h>
#include <blaze_tensor/math/expressions/DQuatTransExprData.h>
#include <blaze_tensor/math/expressions/DQuatTransposer.h>
#include <blaze_tensor/math/expressions/QuatTransExpr.h>
namespace blaze {
//=================================================================================================
//
// CLASS DTENSTRANSEXPR
//
//=================================================================================================
//*************************************************************************************************
/*!\brief Expression object for dense tensor transpositions.
// \ingroup dense_tensor_expression
//
// The DQuatTransExpr class represents the compile time expression for transpositions of
// dense tensors.
*/
template< typename MT, // Type of the dense tensor
size_t... CTAs > // Compile time arguments
class DQuatTransExpr
: public QuatTransExpr< DenseArray< DQuatTransExpr<MT> > >
, public DQuatTransExprData<CTAs...>
, private If< IsComputation_v<MT>, Computation, Transformation >::Type
{
private:
//**Type definitions****************************************************************************
using DataType = DQuatTransExprData<CTAs...>; //!< The type of the DQuatTransExprData base class.
using RT = ResultType_t<MT>; //!< Result type of the dense tensor expression.
using CT = CompositeType_t<MT>; //!< Composite type of the dense tensor expression.
//! Definition of the GetConstIterator type trait.
BLAZE_CREATE_GET_TYPE_MEMBER_TYPE_TRAIT( GetIterator, Iterator, INVALID_TYPE );
BLAZE_CREATE_GET_TYPE_MEMBER_TYPE_TRAIT( GetConstIterator, ConstIterator, INVALID_TYPE );
//**********************************************************************************************
//**Serial evaluation strategy******************************************************************
//! Compilation switch for the serial evaluation strategy of the transposition expression.
/*! The \a useAssign compile time constant expression represents a compilation switch for
the serial evaluation strategy of the transposition expression. In case the given dense
tensor expression of type \a MT requires an intermediate evaluation, \a useAssign will
be set to 1 and the transposition expression will be evaluated via the \a assign function
family. Otherwise \a useAssign will be set to 0 and the expression will be evaluated
via the subscript operator. */
static constexpr bool useAssign = RequiresEvaluation_v<MT>;
/*! \cond BLAZE_INTERNAL */
//! Helper variable template for the explicit application of the SFINAE principle.
template< typename MT2 >
static constexpr bool UseAssign_v = useAssign;
/*! \endcond */
//**********************************************************************************************
//**Parallel evaluation strategy****************************************************************
/*! \cond BLAZE_INTERNAL */
//! Helper variable template for the explicit application of the SFINAE principle.
/*! This variable template is a helper for the selection of the parallel evaluation strategy.
In case the target tensor is SMP assignable and the dense tensor operand requires an
intermediate evaluation, the variable is set to 1 and the expression specific evaluation
strategy is selected. Otherwise the variable is set to 0 and the default strategy is
chosen. */
template< typename MT2 >
static constexpr bool UseSMPAssign_v = ( MT2::smpAssignable && useAssign );
/*! \endcond */
//**********************************************************************************************
public:
//**Type definitions****************************************************************************
using This = DQuatTransExpr<MT>; //!< Type of this DQuatTransExpr instance.
using ResultType = TransposeType_t<MT>; //!< Result type for expression template evaluations.
using OppositeType = OppositeType_t<ResultType>; //!< Result type with opposite storage order for expression template evaluations.
using TransposeType = ResultType_t<MT>; //!< Transpose type for expression template evaluations.
using ElementType = ElementType_t<MT>; //!< Resulting element type.
using ReturnType = ReturnType_t<MT>; //!< Return type for expression template evaluations.
//! Data type for composite expression templates.
using CompositeType = If_t< useAssign, const ResultType, const DQuatTransExpr& >;
//! Reference to a constant transpose value.
using ConstReference = ConstReference_t<MT>;
//! Reference to a non-constant transpose value.
using Reference = If_t< IsConst_v< MT >, ConstReference, Reference_t< MT > >;
//! Pointer to a constant transpose value.
using ConstPointer = ConstPointer_t<MT>;
//! Pointer to a non-constant transpose value.
using Pointer = If_t< IsConst_v<MT> || !HasMutableDataAccess_v<MT>, ConstPointer, Pointer_t<MT> >;
//! Iterator over the elements of the dense tensor.
using ConstIterator = GetConstIterator_t<MT>;
//! Iterator over non-constant elements.
using Iterator = If_t< IsConst_v<MT>, ConstIterator, GetIterator_t<MT> >;
//! Composite data type of the dense tensor expression.
using Operand = If_t< IsExpression_v<MT>, const MT, const MT& >;
//**********************************************************************************************
//**Utility functions***************************************************************************
/*!\name Utility functions */
//@{
using DataType::idces;
using DataType::quat;
using DataType::page;
using DataType::row;
using DataType::column;
using DataType::reverse_quat;
using DataType::reverse_page;
using DataType::reverse_row;
using DataType::reverse_column;
//@}
//**********************************************************************************************
//**Compilation flags***************************************************************************
//! Compilation switch for the expression template evaluation strategy.
static constexpr bool simdEnabled = false;
//! Compilation switch for the expression template assignment strategy.
static constexpr bool smpAssignable = MT::smpAssignable;
//**********************************************************************************************
//**SIMD properties*****************************************************************************
//! The number of elements packed within a single SIMD element.
static constexpr size_t SIMDSIZE = SIMDTrait<ElementType>::size;
//**********************************************************************************************
//**Constructor*********************************************************************************
/*!\brief Constructor for the DQuatTransExpr class.
//
// \param dm The dense tensor operand of the transposition expression.
*/
template< typename... RTAs >
explicit inline DQuatTransExpr( const MT& dm, RTAs... args ) noexcept
: DataType( args... ) // Base class initialization
, dm_( dm ) // Dense tensor of the transposition expression
{}
//**********************************************************************************************
//**Access operator*****************************************************************************
/*!\brief 4D-access to the array elements.
//
// \param i Access index for the row. The index has to be in the range \f$[0..M-1]\f$.
// \param j Access index for the column. The index has to be in the range \f$[0..N-1]\f$.
// \return The resulting value.
*/
inline ReturnType operator()( size_t l, size_t k, size_t i, size_t j ) const {
BLAZE_INTERNAL_ASSERT( l < quats() , "Invalid quat access index" );
BLAZE_INTERNAL_ASSERT( k < pages() , "Invalid page access index" );
BLAZE_INTERNAL_ASSERT( i < rows(), "Invalid row access index" );
BLAZE_INTERNAL_ASSERT( j < columns() , "Invalid column access index" );
return dm_( reverse_quat(l, k, i, j), reverse_page(l, k, i, j), reverse_row(l, k, i, j), reverse_column(l, k, i, j) );
}
//**********************************************************************************************
//**Access operator*****************************************************************************
/*!\brief 4D-access to the array elements.
//
// \param i Access index for the row. The index has to be in the range \f$[0..M-1]\f$.
// \param j Access index for the column. The index has to be in the range \f$[0..N-1]\f$.
// \return The resulting value.
*/
inline ReturnType operator()( std::array< size_t, 4UL > dims ) const
{
size_t j = dims[0];
size_t i = dims[1];
size_t k = dims[2];
size_t l = dims[3];
BLAZE_INTERNAL_ASSERT( l < quats() , "Invalid quat access index" );
BLAZE_INTERNAL_ASSERT( k < pages() , "Invalid page access index" );
BLAZE_INTERNAL_ASSERT( i < rows(), "Invalid row access index" );
BLAZE_INTERNAL_ASSERT( j < columns() , "Invalid column access index" );
return dm_( reverse_quat(l, k, i, j), reverse_page(l, k, i, j), reverse_row(l, k, i, j), reverse_column(l, k, i, j) );
}
//**********************************************************************************************
//**At function*********************************************************************************
/*!\brief Checked access to the quatern elements.
//
// \param i Access index for the row. The index has to be in the range \f$[0..M-1]\f$.
// \param j Access index for the column. The index has to be in the range \f$[0..N-1]\f$.
// \return The resulting value.
// \exception std::out_of_range Invalid tensor access index.
*/
inline ReturnType at( size_t l, size_t k, size_t i, size_t j ) const {
if( l >= quats() ) {
BLAZE_THROW_OUT_OF_RANGE( "Invalid quat access index" );
}
if( k >= pages() ) {
BLAZE_THROW_OUT_OF_RANGE( "Invalid page access index" );
}
if( i >= rows() ) {
BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
}
if( j >= columns() ) {
BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
}
return (*this)(l,k,i,j);
}
//**********************************************************************************************
//**At function*********************************************************************************
/*!\brief Checked access to the tensor elements.
//
// \param i Access index for the row. The index has to be in the range \f$[0..M-1]\f$.
// \param j Access index for the column. The index has to be in the range \f$[0..N-1]\f$.
// \return The resulting value.
// \exception std::out_of_range Invalid tensor access index.
*/
inline ReturnType at( std::array< size_t, 4UL > dims ) const
{
size_t j = dims[0];
size_t i = dims[1];
size_t k = dims[2];
size_t l = dims[3];
if( l >= quats() ) {
BLAZE_THROW_OUT_OF_RANGE( "Invalid quat access index" );
}
if( k >= pages() ) {
BLAZE_THROW_OUT_OF_RANGE( "Invalid page access index" );
}
if( i >= rows() ) {
BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
}
if( j >= columns() ) {
BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
}
return (*this)(l,k,i,j);
}
//**********************************************************************************************
//**Low-level data access***********************************************************************
/*!\brief Low-level data access to the tensor elements.
//
// \return Pointer to the internal element storage.
*/
inline const ElementType* data() const noexcept {
return dm_.data();
}
//**********************************************************************************************
//**Begin function******************************************************************************
/*!\brief Returns an iterator to the first non-zero element of row/column \a i.
//
// \param i The row/column index.
// \return Iterator to the first non-zero element of row/column \a i.
*/
inline ConstIterator begin( size_t i, size_t l, size_t k ) const {
return ConstIterator( dm_.begin( reverse_row(l, k, i, 0), reverse_quat(l, k, i, 0), reverse_page(l, k, i, 0) ) );
}
//**********************************************************************************************
//**End function********************************************************************************
/*!\brief Returns an iterator just past the last non-zero element of row/column \a i.
//
// \param i The row/column index.
// \return Iterator just past the last non-zero element of row/column \a i.
*/
inline ConstIterator end( size_t i, size_t l, size_t k ) const {
return ConstIterator( dm_.end( reverse_row(l, k, i, 0), reverse_quat(l, k, i, 0), reverse_page(l, k, i, 0) ) );
}
//**********************************************************************************************
//**Num_dimensions function*********************************************************************
/*!\brief Returns the current number of dimensions of the array.
//
// \return The number of rows of the array.
*/
static constexpr size_t num_dimensions = 4UL;
//**********************************************************************************************
//**Dimensions function*************************************************************************
/*!\brief Returns the current dimensions of the array.
//
// \return The dimensions of the array.
*/
inline decltype(auto) dimensions() const noexcept {
using array_type =
RemoveCV_t< RemoveReference_t< decltype( dm_.dimensions() ) > >;
return array_type{ columns(), rows(), pages(), quats() };
}
//**********************************************************************************************
//**Dimension function**************************************************************************
/*!\brief Returns the current number of columns of the array.
//
// \return The number of columns of the array.
*/
template< size_t Dim >
size_t dimension() const noexcept {
if(Dim == 0)
return columns();
else if(Dim == 1)
return rows();
else if(Dim == 2)
return pages();
else
return quats();
}
//**********************************************************************************************
//**Rows function*******************************************************************************
/*!\brief Returns the current number of rows of the tensor.
//
// \return The number of rows of the tensor.
*/
inline size_t rows() const noexcept {
return row( dm_.quats(), dm_.pages(), dm_.rows(), dm_.columns() );
}
//**********************************************************************************************
//**Columns function****************************************************************************
/*!\brief Returns the current number of columns of the tensor.
//
// \return The number of columns of the tensor.
*/
inline size_t columns() const noexcept {
return column( dm_.quats(), dm_.pages(), dm_.rows(), dm_.columns() );
}
//**********************************************************************************************
//**Pages function****************************************************************************
/*!\brief Returns the current number of pages of the tensor.
//
// \return The number of pages of the tensor.
*/
inline size_t pages() const noexcept {
return page( dm_.quats(), dm_.pages(), dm_.rows(), dm_.columns() );
}
//**********************************************************************************************
//**Quats function****************************************************************************
/*!\brief Returns the current number of pages of the tensor.
//
// \return The number of pages of the tensor.
*/
inline size_t quats() const noexcept {
return quat( dm_.quats(), dm_.pages(), dm_.rows(), dm_.columns() );
}
//**********************************************************************************************
//**NonZeros function***************************************************************************
/*!\brief Returns the number of non-zero elements in the dense tensor.
//
// \return The number of non-zero elements in the dense tensor.
*/
inline size_t nonZeros() const {
return dm_.nonZeros();
}
//**********************************************************************************************
//**NonZeros function***************************************************************************
/*!\brief Returns the number of non-zero elements in the specified row/column.
//
// \param i The index of the row/column.
// \return The number of non-zero elements of row/column \a i.
*/
inline size_t nonZeros( size_t i, size_t l, size_t k ) const {
return dm_.nonZeros( reverse_row(l, k, i, 0), reverse_quat(l, k, i, 0), reverse_page(l, k, i, 0) );
}
//**********************************************************************************************
//**Operand access******************************************************************************
/*!\brief Returns the dense tensor operand.
//
// \return The dense tensor operand.
*/
inline Operand operand() const noexcept {
return dm_;
}
//**********************************************************************************************
//**********************************************************************************************
/*!\brief Returns whether the expression can alias with the given address \a alias.
//
// \param alias The alias to be checked.
// \return \a true in case the expression can alias, \a false otherwise.
*/
template< typename T >
inline bool canAlias( const T* alias ) const noexcept {
return dm_.isAliased( alias );
}
//**********************************************************************************************
//**********************************************************************************************
/*!\brief Returns whether the expression is aliased with the given address \a alias.
//
// \param alias The alias to be checked.
// \return \a true in case an alias effect is detected, \a false otherwise.
*/
template< typename T >
inline bool isAliased( const T* alias ) const noexcept {
return dm_.isAliased( alias );
}
//**********************************************************************************************
//**********************************************************************************************
/*!\brief Returns whether the operands of the expression are properly aligned in memory.
//
// \return \a true in case the operands are aligned, \a false if not.
*/
inline bool isAligned() const noexcept {
return dm_.isAligned();
}
//**********************************************************************************************
//**********************************************************************************************
/*!\brief Returns whether the expression can be used in SMP assignments.
//
// \return \a true in case the expression can be used in SMP assignments, \a false if not.
*/
inline bool canSMPAssign() const noexcept {
return dm_.canSMPAssign();
}
//**********************************************************************************************
private:
//**Member variables****************************************************************************
Operand dm_; //!< Dense Array of the transposition expression.
//**********************************************************************************************
//**Assignment to dense tensors****************************************************************
/*! \cond BLAZE_INTERNAL */
/*!\brief Assignment of a dense tensor transposition expression to a dense tensor.
// \ingroup dense_tensor
//
// \param lhs The target left-hand side dense tensor.
// \param rhs The right-hand side transposition expression to be assigned.
// \return void
//
// This function implements the performance optimized assignment of a dense tensor
// transposition expression to a dense tensor. Due to the explicit application of
// the SFINAE principle, this function can only be selected by the compiler in case
// the operand requires an intermediate evaluation.
*/
template< typename MT2 > // Type of the target dense quaternion
friend inline EnableIf_t< UseAssign_v<MT2> >
assign( DenseArray<MT2>& lhs, const DQuatTransExpr& rhs )
{
BLAZE_FUNCTION_TRACE;
BLAZE_INTERNAL_ASSERT( (~lhs).quats() == rhs.quats() , "Invalid number of quats" );
BLAZE_INTERNAL_ASSERT( (~lhs).pages() == rhs.pages() , "Invalid number of pages" );
BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
DQuatTransposer<MT2> tmp( ~lhs, rhs.quats(), rhs.pages(), rhs.rows(), rhs.columns() );
assign( tmp, rhs.dm_ );
}
/*! \endcond */
//**********************************************************************************************
//**Assignment to sparse tensors***************************************************************
/*! \cond BLAZE_INTERNAL */
/*!\brief Assignment of a dense tensor transposition expression to a sparse tensor.
// \ingroup dense_tensor
//
// \param lhs The target left-hand side sparse tensor.
// \param rhs The right-hand side transposition expression to be assigned.
// \return void
//
// This function implements the performance optimized assignment of a dense tensor
// transposition expression to a sparse tensor. Due to the explicit application of
// the SFINAE principle, this function can only be selected by the compiler in case
// the operand requires an intermediate evaluation.
*/
// template< typename MT2 > // Type of the target dense tensor
// friend inline EnableIf_t< UseAssign_v<MT2> >
// assign( SparseArray<MT2>& lhs, const DQuatTransExpr& rhs )
// {
// BLAZE_FUNCTION_TRACE;
//
// using TmpType = If_t< SO == SO2, ResultType, OppositeType >;
//
// BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( ResultType );
// BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( OppositeType );
// BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER( ResultType, SO );
// BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER( OppositeType, !SO );
// BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_SAME_STORAGE_ORDER( MT2, TmpType );
// BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION( TmpType );
//
// BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
// BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
//
// const TmpType tmp( serial( rhs ) );
// assign( ~lhs, tmp );
// }
/*! \endcond */
//**********************************************************************************************
//**Addition assignment to dense tensors*******************************************************
/*! \cond BLAZE_INTERNAL */
/*!\brief Addition assignment of a dense tensor transposition expression to a dense tensor.
// \ingroup dense_tensor
//
// \param lhs The target left-hand side dense tensor.
// \param rhs The right-hand side transposition expression to be added.
// \return void
//
// This function implements the performance optimized addition assignment of a dense
// tensor transposition expression to a dense tensor. Due to the explicit application
// of the SFINAE principle, this function can only be selected by the compiler in case
// the operand requires an intermediate evaluation.
*/
template< typename MT2 > // Type of the target dense tensor
friend inline EnableIf_t< UseAssign_v<MT2> >
addAssign( DenseArray<MT2>& lhs, const DQuatTransExpr& rhs )
{
BLAZE_FUNCTION_TRACE;
BLAZE_INTERNAL_ASSERT( (~lhs).quats() == rhs.quats() , "Invalid number of quats" );
BLAZE_INTERNAL_ASSERT( (~lhs).pages() == rhs.pages() , "Invalid number of pages" );
BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
DQuatTransposer<MT2> tmp( ~lhs, rhs.quats(), rhs.pages(), rhs.rows(), rhs.columns() );
addAssign( tmp, rhs.dm_ );
}
/*! \endcond */
//**********************************************************************************************
//**Addition assignment to sparse tensors******************************************************
// No special implementation for the addition assignment to sparse tensors.
//**********************************************************************************************
//**Subtraction assignment to dense tensors****************************************************
/*! \cond BLAZE_INTERNAL */
/*!\brief Subtraction assignment of a dense tensor transposition expression to a dense tensor.
// \ingroup dense_tensor
//
// \param lhs The target left-hand side dense tensor.
// \param rhs The right-hand side transposition expression to be subtracted.
// \return void
//
// This function implements the performance optimized subtraction assignment of a dense
// tensor transposition expression to a dense tensor. Due to the explicit application
// of the SFINAE principle, this function can only be selected by the compiler in case
// the operand requires an intermediate evaluation.
*/
template< typename MT2 > // Type of the target dense tensor
friend inline EnableIf_t< UseAssign_v<MT2> >
subAssign( DenseArray<MT2>& lhs, const DQuatTransExpr& rhs )
{
BLAZE_FUNCTION_TRACE;
BLAZE_INTERNAL_ASSERT( (~lhs).quats() == rhs.quats() , "Invalid number of quats" );
BLAZE_INTERNAL_ASSERT( (~lhs).pages() == rhs.pages() , "Invalid number of pages" );
BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
DQuatTransposer<MT2> tmp( ~lhs, rhs.quats(), rhs.pages(), rhs.rows(), rhs.columns() );
subAssign( tmp, rhs.dm_ );
}
/*! \endcond */
//**********************************************************************************************
//**Subtraction assignment to sparse tensors***************************************************
// No special implementation for the subtraction assignment to sparse tensors.
//**********************************************************************************************
//**Schur product assignment to dense tensors**************************************************
/*! \cond BLAZE_INTERNAL */
/*!\brief Schur product assignment of a dense tensor transposition expression to a dense tensor.
// \ingroup dense_tensor
//
// \param lhs The target left-hand side dense tensor.
// \param rhs The right-hand side transposition expression for the Schur product.
// \return void
//
// This function implements the performance optimized Schur product assignment of a dense
// tensor transposition expression to a dense tensor. Due to the explicit application of
// the SFINAE principle, this function can only be selected by the compiler in case the
// operand requires an intermediate evaluation.
*/
template< typename MT2 > // Type of the target dense tensor
friend inline EnableIf_t< UseAssign_v<MT2> >
schurAssign( DenseArray<MT2>& lhs, const DQuatTransExpr& rhs )
{
BLAZE_FUNCTION_TRACE;
BLAZE_INTERNAL_ASSERT( (~lhs).quats() == rhs.quats() , "Invalid number of quats" );
BLAZE_INTERNAL_ASSERT( (~lhs).pages() == rhs.pages() , "Invalid number of pages" );
BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
DQuatTransposer<MT2> tmp( ~lhs, rhs.quats(), rhs.pages(), rhs.rows(), rhs.columns() );
schurAssign( tmp, rhs.dm_ );
}
/*! \endcond */
//**********************************************************************************************
//**Schur product assignment to sparse tensors*************************************************
// No special implementation for the Schur product assignment to sparse tensors.
//**********************************************************************************************
//**Multiplication assignment to dense tensors*************************************************
// No special implementation for the multiplication assignment to dense tensors.
//**********************************************************************************************
//**Multiplication assignment to sparse tensors************************************************
// No special implementation for the multiplication assignment to sparse tensors.
//**********************************************************************************************
//**SMP assignment to dense tensors************************************************************
/*! \cond BLAZE_INTERNAL */
/*!\brief SMP assignment of a dense tensor transposition expression to a dense tensor.
// \ingroup dense_tensor
//
// \param lhs The target left-hand side dense tensor.
// \param rhs The right-hand side transposition expression to be assigned.
// \return void
//
// This function implements the performance optimized SMP assignment of a dense tensor
// transposition expression to a dense tensor. Due to the explicit application of the
// SFINAE principle, this function can only be selected by the compiler in case the
// expression specific parallel evaluation strategy is selected.
*/
template< typename MT2 > // Type of the target dense tensor
friend inline EnableIf_t< UseSMPAssign_v<MT2> >
smpAssign( DenseArray<MT2>& lhs, const DQuatTransExpr& rhs )
{
BLAZE_FUNCTION_TRACE;
BLAZE_INTERNAL_ASSERT( (~lhs).quats() == rhs.quats() , "Invalid number of quats" );
BLAZE_INTERNAL_ASSERT( (~lhs).pages() == rhs.pages() , "Invalid number of pages" );
BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
DQuatTransposer<MT2> tmp( ~lhs, rhs.quats(), rhs.pages(), rhs.rows(), rhs.columns() );
smpAssign( tmp, rhs.dm_ );
}
/*! \endcond */
//**********************************************************************************************
//**SMP assignment to sparse tensors***********************************************************
/*! \cond BLAZE_INTERNAL */
/*!\brief SMP assignment of a dense tensor transposition expression to a sparse tensor.
// \ingroup dense_tensor
//
// \param lhs The target left-hand side sparse tensor.
// \param rhs The right-hand side transposition expression to be assigned.
// \return void
//
// This function implements the performance optimized SMP assignment of a dense tensor
// transposition expression to a sparse tensor. Due to the explicit application of the
// SFINAE principle, this function can only be selected by the compiler in case the
// expression specific parallel evaluation strategy is selected.
*/
// template< typename MT2 > // Type of the target dense tensor
// friend inline EnableIf_t< UseSMPAssign_v<MT2> >
// smpAssign( SparseArray<MT2>& lhs, const DQuatTransExpr& rhs )
// {
// BLAZE_FUNCTION_TRACE;
//
// using TmpType = If_t< SO == SO2, ResultType, OppositeType >;
//
// BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( ResultType );
// BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE( OppositeType );
// BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER( ResultType, SO );
// BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER( OppositeType, !SO );
// BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_SAME_STORAGE_ORDER( MT2, TmpType );
// BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION( TmpType );
//
// BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
// BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
//
// const TmpType tmp( rhs );
// smpAssign( ~lhs, tmp );
// }
/*! \endcond */
//**********************************************************************************************
//**SMP addition assignment to dense tensors***************************************************
/*! \cond BLAZE_INTERNAL */
/*!\brief SMP addition assignment of a dense tensor transposition expression to a dense tensor.
// \ingroup dense_tensor
//
// \param lhs The target left-hand side dense tensor.
// \param rhs The right-hand side transposition expression to be added.
// \return void
//
// This function implements the performance optimized SMP addition assignment of a dense
// tensor transposition expression to a dense tensor. Due to the explicit application of
// the SFINAE principle, this function can only be selected by the compiler in case the
// expression specific parallel evaluation strategy is selected.
*/
template< typename MT2 > // Type of the target dense tensor
friend inline EnableIf_t< UseSMPAssign_v<MT2> >
smpAddAssign( DenseArray<MT2>& lhs, const DQuatTransExpr& rhs )
{
BLAZE_FUNCTION_TRACE;
BLAZE_INTERNAL_ASSERT( (~lhs).quats() == rhs.quats() , "Invalid number of quats" );
BLAZE_INTERNAL_ASSERT( (~lhs).pages() == rhs.pages() , "Invalid number of pages" );
BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
DQuatTransposer<MT2> tmp( ~lhs, rhs.quats(), rhs.pages(), rhs.rows(), rhs.columns() );
smpAddAssign( tmp, rhs.dm_ );
}
/*! \endcond */
//**********************************************************************************************
//**SMP addition assignment to sparse tensors**************************************************
// No special implementation for the SMP addition assignment to sparse tensors.
//**********************************************************************************************
//**SMP subtraction assignment to dense tensors************************************************
/*! \cond BLAZE_INTERNAL */
/*!\brief SMP subtraction assignment of a dense tensor transposition expression to a dense tensor.
// \ingroup dense_tensor
//
// \param lhs The target left-hand side dense tensor.
// \param rhs The right-hand side transposition expression to be subtracted.
// \return void
//
// This function implements the performance optimized SMP subtraction assignment of a dense
// tensor transposition expression to a dense tensor. Due to the explicit application of
// the SFINAE principle, this function can only be selected by the compiler in case the
// expression specific parallel evaluation strategy is selected.
*/
template< typename MT2 > // Type of the target dense tensor
friend inline EnableIf_t< UseSMPAssign_v<MT2> >
smpSubAssign( DenseArray<MT2>& lhs, const DQuatTransExpr& rhs )
{
BLAZE_FUNCTION_TRACE;
BLAZE_INTERNAL_ASSERT( (~lhs).quats() == rhs.quats() , "Invalid number of quats" );
BLAZE_INTERNAL_ASSERT( (~lhs).pages() == rhs.pages() , "Invalid number of pages" );
BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
DQuatTransposer<MT2> tmp( ~lhs, rhs.quats(), rhs.pages(), rhs.rows(), rhs.columns() );
smpSubAssign( tmp, rhs.dm_ );
}
/*! \endcond */
//**********************************************************************************************
//**SMP subtraction assignment to sparse tensors***********************************************
// No special implementation for the SMP subtraction assignment to sparse tensors.
//**********************************************************************************************
//**SMP Schur product assignment to dense tensors**********************************************
/*! \cond BLAZE_INTERNAL */
/*!\brief SMP Schur product assignment of a dense tensor transposition expression to a dense
// tensor.
// \ingroup dense_tensor
//
// \param lhs The target left-hand side dense tensor.
// \param rhs The right-hand side transposition expression for the Schur product.
// \return void
//
// This function implements the performance optimized SMP Schur product assignment of a dense
// tensor transposition expression to a dense tensor. Due to the explicit application of the
// SFINAE principle, this function can only be selected by the compiler in case the expression
// specific parallel evaluation strategy is selected.
*/
template< typename MT2 > // Type of the target dense tensor
friend inline EnableIf_t< UseSMPAssign_v<MT2> >
smpSchurAssign( DenseArray<MT2>& lhs, const DQuatTransExpr& rhs )
{
BLAZE_FUNCTION_TRACE;
BLAZE_INTERNAL_ASSERT( (~lhs).quats() == rhs.quats() , "Invalid number of quats" );
BLAZE_INTERNAL_ASSERT( (~lhs).pages() == rhs.pages() , "Invalid number of pages" );
BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
DQuatTransposer<MT2> tmp( ~lhs, rhs.quats(), rhs.pages(), rhs.rows(), rhs.columns() );
smpSchurAssign( tmp, rhs.dm_ );
}
/*! \endcond */
//**********************************************************************************************
//**SMP Schur product assignment to sparse tensors*********************************************
// No special implementation for the SMP Schur product assignment to sparse tensors.
//**********************************************************************************************
//**SMP multiplication assignment to dense tensors*********************************************
// No special implementation for the SMP multiplication assignment to dense tensors.
//**********************************************************************************************
//**SMP multiplication assignment to sparse tensors********************************************
// No special implementation for the SMP multiplication assignment to sparse tensors.
//**********************************************************************************************
//**Compile time checks*************************************************************************
/*! \cond BLAZE_INTERNAL */
BLAZE_CONSTRAINT_MUST_BE_DENSE_ARRAY_TYPE( MT );
// BLAZE_CONSTRAINT_MUST_BE_TENSOR_WITH_STORAGE_ORDER( MT, !SO );
/*! \endcond */
//**********************************************************************************************
};
//*************************************************************************************************
//=================================================================================================
//
// GLOBAL OPERATORS
//
//=================================================================================================
//*************************************************************************************************
/*!\brief Calculation of the transpose of the given dense tensor.
// \ingroup dense_tensor
//
// \param dm The dense tensor to be transposed.
// \return The transpose of the tensor.
//
// This function returns an expression representing the transpose of the given dense tensor:
\code
blaze::DynamicArray<double> A;
blaze::DynamicArray<double,> B;
// ... Resizing and initialization
B = trans<2UL, 0UL, 1UL>( A ); // rotate tensor
\endcode
*/
template< size_t P // Mapping index for quat dimension
, size_t O // Mapping index for page dimension
, size_t M // Mapping index for row dimension
, size_t N // Mapping index for column dimension
, typename MT // Type of the target dense tensor
, typename ... RTAs> // Runtime arguments
inline decltype(auto) trans( const DenseArray<MT>& dm, RTAs... args )
{
BLAZE_FUNCTION_TRACE;
using ReturnType = const DQuatTransExpr<MT, P, O, M, N>;
return ReturnType( ~dm, args... );
}
//*************************************************************************************************
//*************************************************************************************************
/*!\brief Calculation of the transpose of the given dense tensor.
// \ingroup dense_tensor
//
// \param dm The dense tensor to be transposed.
// \return The transpose of the tensor.
//
// This function returns an expression representing the transpose of the given dense tensor:
\code
blaze::DynamicArray<double> A;
blaze::DynamicArray<double,> B;
// ... Resizing and initialization
B = trans( A, { 2UL, 0UL, 1UL } ); // rotate tensor
\endcode
*/
template< typename MT // Type of the target dense tensor
, typename ... RTAs> // Runtime arguments
inline decltype(auto) trans( const DenseArray<MT>& dm, RTAs... args )
{
BLAZE_FUNCTION_TRACE;
using ReturnType = const DQuatTransExpr<MT>;
return ReturnType( ~dm, args... );
}
//*************************************************************************************************
//*************************************************************************************************
/*!\brief Calculation of the transpose of the given dense tensor.
// \ingroup dense_tensor
//
// \param dm The dense tensor to be transposed.
// \return The transpose of the tensor.
//
// This function returns an expression representing the transpose of the given dense tensor:
\code
blaze::DynamicArray<double> A;
blaze::DynamicArray<double,> B;
// ... Resizing and initialization
B = trans( A, { 2UL, 0UL, 1UL } ); // rotate tensor
\endcode
*/
template< typename MT // Type of the target dense tensor
, typename T // Type of the element indices
, typename ... RTAs> // Runtime arguments
inline decltype(auto) trans( const DenseArray<MT>& dm, const T* indices, size_t n, RTAs... args )
{
BLAZE_FUNCTION_TRACE;
using ReturnType = const DQuatTransExpr<MT>;
return ReturnType( ~dm, indices, n, args... );
}
//*************************************************************************************************
//*************************************************************************************************
/*!\brief Calculation of the transpose of the given dense tensor.
// \ingroup dense_tensor
//
// \param dm The dense tensor to be transposed.
// \return The transpose of the tensor.
//
// This function returns an expression representing the transpose of the given dense tensor:
\code
blaze::DynamicArray<double> A;
blaze::DynamicArray<double,> B;
// ... Resizing and initialization
B = trans( A, { 2UL, 0UL, 1UL } ); // rotate tensor
\endcode
*/
template< typename MT // Type of the target dense tensor
, size_t... Is // Element indices
, typename ... RTAs> // Runtime arguments
inline decltype(auto) trans( const DenseArray<MT>& dm, std::index_sequence<Is...> indices, RTAs... args )
{