1 //=================================================================================================
2 /*!
3 //  \file src/mathtest/views/submatrix/DenseAlignedTest2.cpp
4 //  \brief Source file for the Submatrix dense aligned test (part 2)
5 //
6 //  Copyright (C) 2012-2020 Klaus Iglberger - All Rights Reserved
7 //
8 //  This file is part of the Blaze library. You can redistribute it and/or modify it under
9 //  the terms of the New (Revised) BSD License. Redistribution and use in source and binary
10 //  forms, with or without modification, are permitted provided that the following conditions
11 //  are met:
12 //
13 //  1. Redistributions of source code must retain the above copyright notice, this list of
14 //     conditions and the following disclaimer.
15 //  2. Redistributions in binary form must reproduce the above copyright notice, this list
16 //     of conditions and the following disclaimer in the documentation and/or other materials
17 //     provided with the distribution.
18 //  3. Neither the names of the Blaze development group nor the names of its contributors
19 //     may be used to endorse or promote products derived from this software without specific
20 //     prior written permission.
21 //
22 //  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
23 //  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 //  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25 //  SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 //  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
27 //  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28 //  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 //  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 //  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31 //  DAMAGE.
32 */
33 //=================================================================================================
34 
35 
36 //*************************************************************************************************
37 // Includes
38 //*************************************************************************************************
39 
40 #include <cstdlib>
41 #include <iostream>
42 #include <memory>
43 #include <blaze/math/Views.h>
44 #include <blazetest/mathtest/RandomMaximum.h>
45 #include <blazetest/mathtest/RandomMinimum.h>
46 #include <blazetest/mathtest/views/submatrix/DenseAlignedTest.h>
47 
48 #ifdef BLAZE_USE_HPX_THREADS
49 #  include <hpx/hpx_main.hpp>
50 #endif
51 
52 
53 namespace blazetest {
54 
55 namespace mathtest {
56 
57 namespace views {
58 
59 namespace submatrix {
60 
61 //=================================================================================================
62 //
63 //  CONSTRUCTORS
64 //
65 //=================================================================================================
66 
67 //*************************************************************************************************
68 /*!\brief Constructor for the Submatrix dense aligned test.
69 //
70 // \exception std::runtime_error Operation error detected.
71 */
DenseAlignedTest()72 DenseAlignedTest::DenseAlignedTest()
73    : mat1_ ( 64UL, 64UL )
74    , mat2_ ( 64UL, 64UL )
75    , tmat1_( 64UL, 64UL )
76    , tmat2_( 64UL, 64UL )
77 {
78    testScaling();
79    testFunctionCall();
80    testIterator();
81    testNonZeros();
82    testReset();
83    testClear();
84    testTranspose();
85    testCTranspose();
86    testIsDefault();
87    testIsSame();
88    testSubmatrix();
89    testRow();
90    testRows();
91    testColumn();
92    testColumns();
93    testBand();
94 }
95 //*************************************************************************************************
96 
97 
98 
99 
100 //=================================================================================================
101 //
102 //  TEST FUNCTIONS
103 //
104 //=================================================================================================
105 
106 //*************************************************************************************************
107 /*!\brief Test of all Submatrix (self-)scaling operations.
108 //
109 // \return void
110 // \exception std::runtime_error Error detected.
111 //
112 // This function performs a test of all available ways to scale an instance of the Submatrix
113 // specialization. In case an error is detected, a \a std::runtime_error exception is thrown.
114 */
testScaling()115 void DenseAlignedTest::testScaling()
116 {
117    using blaze::submatrix;
118    using blaze::aligned;
119    using blaze::unaligned;
120 
121 
122    //=====================================================================================
123    // Row-major self-scaling (M*=s)
124    //=====================================================================================
125 
126    {
127       test_ = "Row-major self-scaling (M*=s) (8x16)";
128 
129       initialize();
130 
131       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
132       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
133 
134       sm1 *= 3;
135       sm2 *= 3;
136 
137       checkRows   ( sm1,  8UL );
138       checkColumns( sm1, 16UL );
139       checkRows   ( sm2,  8UL );
140       checkColumns( sm2, 16UL );
141 
142       if( sm1 != sm2 || mat1_ != mat2_ ) {
143          std::ostringstream oss;
144          oss << " Test: " << test_ << "\n"
145              << " Error: Failed self-scaling operation\n"
146              << " Details:\n"
147              << "   Result:\n" << sm1 << "\n"
148              << "   Expected result:\n" << sm2 << "\n";
149          throw std::runtime_error( oss.str() );
150       }
151    }
152 
153    {
154       test_ = "Row-major self-scaling (M*=s) (16x8)";
155 
156       initialize();
157 
158       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 16UL, 8UL );
159       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 16UL, 8UL );
160 
161       sm1 *= 3;
162       sm2 *= 3;
163 
164       checkRows   ( sm1, 16UL );
165       checkColumns( sm1,  8UL );
166       checkRows   ( sm2, 16UL );
167       checkColumns( sm2,  8UL );
168 
169       if( sm1 != sm2 || mat1_ != mat2_ ) {
170          std::ostringstream oss;
171          oss << " Test: " << test_ << "\n"
172              << " Error: Failed self-scaling operation\n"
173              << " Details:\n"
174              << "   Result:\n" << sm1 << "\n"
175              << "   Expected result:\n" << sm2 << "\n";
176          throw std::runtime_error( oss.str() );
177       }
178    }
179 
180 
181    //=====================================================================================
182    // Row-major self-scaling (M=M*s)
183    //=====================================================================================
184 
185    {
186       test_ = "Row-major self-scaling (M=M*s) (8x16)";
187 
188       initialize();
189 
190       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
191       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
192 
193       sm1 = sm1 * 3;
194       sm2 = sm2 * 3;
195 
196       checkRows   ( sm1,  8UL );
197       checkColumns( sm1, 16UL );
198       checkRows   ( sm2,  8UL );
199       checkColumns( sm2, 16UL );
200 
201       if( sm1 != sm2 || mat1_ != mat2_ ) {
202          std::ostringstream oss;
203          oss << " Test: " << test_ << "\n"
204              << " Error: Failed self-scaling operation\n"
205              << " Details:\n"
206              << "   Result:\n" << sm1 << "\n"
207              << "   Expected result:\n" << sm2 << "\n";
208          throw std::runtime_error( oss.str() );
209       }
210    }
211 
212    {
213       test_ = "Row-major self-scaling (M=M*s) (16x8)";
214 
215       initialize();
216 
217       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 16UL, 8UL );
218       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 16UL, 8UL );
219 
220       sm1 = sm1 * 3;
221       sm2 = sm2 * 3;
222 
223       checkRows   ( sm1, 16UL );
224       checkColumns( sm1,  8UL );
225       checkRows   ( sm2, 16UL );
226       checkColumns( sm2,  8UL );
227 
228       if( sm1 != sm2 || mat1_ != mat2_ ) {
229          std::ostringstream oss;
230          oss << " Test: " << test_ << "\n"
231              << " Error: Failed self-scaling operation\n"
232              << " Details:\n"
233              << "   Result:\n" << sm1 << "\n"
234              << "   Expected result:\n" << sm2 << "\n";
235          throw std::runtime_error( oss.str() );
236       }
237    }
238 
239 
240    //=====================================================================================
241    // Row-major self-scaling (M=s*M)
242    //=====================================================================================
243 
244    {
245       test_ = "Row-major self-scaling (M=s*M) (8x16)";
246 
247       initialize();
248 
249       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
250       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
251 
252       sm1 = 3 * sm1;
253       sm2 = 3 * sm2;
254 
255       checkRows   ( sm1,  8UL );
256       checkColumns( sm1, 16UL );
257       checkRows   ( sm2,  8UL );
258       checkColumns( sm2, 16UL );
259 
260       if( sm1 != sm2 || mat1_ != mat2_ ) {
261          std::ostringstream oss;
262          oss << " Test: " << test_ << "\n"
263              << " Error: Failed self-scaling operation\n"
264              << " Details:\n"
265              << "   Result:\n" << sm1 << "\n"
266              << "   Expected result:\n" << sm2 << "\n";
267          throw std::runtime_error( oss.str() );
268       }
269    }
270 
271    {
272       test_ = "Row-major self-scaling (M=s*M) (16x8)";
273 
274       initialize();
275 
276       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 16UL, 8UL );
277       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 16UL, 8UL );
278 
279       sm1 = 3 * sm1;
280       sm2 = 3 * sm2;
281 
282       checkRows   ( sm1, 16UL );
283       checkColumns( sm1,  8UL );
284       checkRows   ( sm2, 16UL );
285       checkColumns( sm2,  8UL );
286 
287       if( sm1 != sm2 || mat1_ != mat2_ ) {
288          std::ostringstream oss;
289          oss << " Test: " << test_ << "\n"
290              << " Error: Failed self-scaling operation\n"
291              << " Details:\n"
292              << "   Result:\n" << sm1 << "\n"
293              << "   Expected result:\n" << sm2 << "\n";
294          throw std::runtime_error( oss.str() );
295       }
296    }
297 
298 
299    //=====================================================================================
300    // Row-major self-scaling (M/=s)
301    //=====================================================================================
302 
303    {
304       test_ = "Row-major self-scaling (M/=s) (8x16)";
305 
306       initialize();
307 
308       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
309       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
310 
311       sm1 /= 0.5;
312       sm2 /= 0.5;
313 
314       checkRows   ( sm1,  8UL );
315       checkColumns( sm1, 16UL );
316       checkRows   ( sm2,  8UL );
317       checkColumns( sm2, 16UL );
318 
319       if( sm1 != sm2 || mat1_ != mat2_ ) {
320          std::ostringstream oss;
321          oss << " Test: " << test_ << "\n"
322              << " Error: Failed self-scaling operation\n"
323              << " Details:\n"
324              << "   Result:\n" << sm1 << "\n"
325              << "   Expected result:\n" << sm2 << "\n";
326          throw std::runtime_error( oss.str() );
327       }
328    }
329 
330    {
331       test_ = "Row-major self-scaling (M/=s) (16x8)";
332 
333       initialize();
334 
335       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 16UL, 8UL );
336       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 16UL, 8UL );
337 
338       sm1 /= 0.5;
339       sm2 /= 0.5;
340 
341       checkRows   ( sm1, 16UL );
342       checkColumns( sm1,  8UL );
343       checkRows   ( sm2, 16UL );
344       checkColumns( sm2,  8UL );
345 
346       if( sm1 != sm2 || mat1_ != mat2_ ) {
347          std::ostringstream oss;
348          oss << " Test: " << test_ << "\n"
349              << " Error: Failed self-scaling operation\n"
350              << " Details:\n"
351              << "   Result:\n" << sm1 << "\n"
352              << "   Expected result:\n" << sm2 << "\n";
353          throw std::runtime_error( oss.str() );
354       }
355    }
356 
357 
358    //=====================================================================================
359    // Row-major self-scaling (M=M/s)
360    //=====================================================================================
361 
362    {
363       test_ = "Row-major self-scaling (M=M/s) (8x16)";
364 
365       initialize();
366 
367       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
368       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
369 
370       sm1 = sm1 / 0.5;
371       sm2 = sm2 / 0.5;
372 
373       checkRows   ( sm1,  8UL );
374       checkColumns( sm1, 16UL );
375       checkRows   ( sm2,  8UL );
376       checkColumns( sm2, 16UL );
377 
378       if( sm1 != sm2 || mat1_ != mat2_ ) {
379          std::ostringstream oss;
380          oss << " Test: " << test_ << "\n"
381              << " Error: Failed self-scaling operation\n"
382              << " Details:\n"
383              << "   Result:\n" << sm1 << "\n"
384              << "   Expected result:\n" << sm2 << "\n";
385          throw std::runtime_error( oss.str() );
386       }
387    }
388 
389    {
390       test_ = "Row-major self-scaling (M=M/s) (16x8)";
391 
392       initialize();
393 
394       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 16UL, 8UL );
395       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 16UL, 8UL );
396 
397       sm1 = sm1 / 0.5;
398       sm2 = sm2 / 0.5;
399 
400       checkRows   ( sm1, 16UL );
401       checkColumns( sm1,  8UL );
402       checkRows   ( sm2, 16UL );
403       checkColumns( sm2,  8UL );
404 
405       if( sm1 != sm2 || mat1_ != mat2_ ) {
406          std::ostringstream oss;
407          oss << " Test: " << test_ << "\n"
408              << " Error: Failed self-scaling operation\n"
409              << " Details:\n"
410              << "   Result:\n" << sm1 << "\n"
411              << "   Expected result:\n" << sm2 << "\n";
412          throw std::runtime_error( oss.str() );
413       }
414    }
415 
416 
417    //=====================================================================================
418    // Row-major Submatrix::scale()
419    //=====================================================================================
420 
421    {
422       test_ = "Row-major Submatrix::scale()";
423 
424       initialize();
425 
426       // Initialization check
427       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
428       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
429 
430       checkRows   ( sm1,  8UL );
431       checkColumns( sm1, 16UL );
432       checkRows   ( sm2,  8UL );
433       checkColumns( sm2, 16UL );
434 
435       // Integral scaling of the matrix
436       sm1.scale( 2 );
437       sm2.scale( 2 );
438 
439       checkRows   ( sm1,  8UL );
440       checkColumns( sm1, 16UL );
441       checkRows   ( sm2,  8UL );
442       checkColumns( sm2, 16UL );
443 
444       if( sm1 != sm2 || mat1_ != mat2_ ) {
445          std::ostringstream oss;
446          oss << " Test: " << test_ << "\n"
447              << " Error: Integral scale operation failed\n"
448              << " Details:\n"
449              << "   Result:\n" << sm1 << "\n"
450              << "   Expected result:\n" << sm2 << "\n";
451          throw std::runtime_error( oss.str() );
452       }
453 
454       // Floating point scaling of the matrix
455       sm1.scale( 0.5 );
456       sm2.scale( 0.5 );
457 
458       checkRows   ( sm1,  8UL );
459       checkColumns( sm1, 16UL );
460       checkRows   ( sm2,  8UL );
461       checkColumns( sm2, 16UL );
462 
463       if( sm1 != sm2 || mat1_ != mat2_ ) {
464          std::ostringstream oss;
465          oss << " Test: " << test_ << "\n"
466              << " Error: Floating point scale operation failed\n"
467              << " Details:\n"
468              << "   Result:\n" << sm1 << "\n"
469              << "   Expected result:\n" << sm2 << "\n";
470          throw std::runtime_error( oss.str() );
471       }
472    }
473 
474 
475    //=====================================================================================
476    // Column-major self-scaling (M*=s)
477    //=====================================================================================
478 
479    {
480       test_ = "Row-major self-scaling (M*=s) (8x16)";
481 
482       initialize();
483 
484       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 8UL, 16UL );
485       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 8UL, 16UL );
486 
487       sm1 *= 3;
488       sm2 *= 3;
489 
490       checkRows   ( sm1,  8UL );
491       checkColumns( sm1, 16UL );
492       checkRows   ( sm2,  8UL );
493       checkColumns( sm2, 16UL );
494 
495       if( sm1 != sm2 || mat1_ != mat2_ ) {
496          std::ostringstream oss;
497          oss << " Test: " << test_ << "\n"
498              << " Error: Failed self-scaling operation\n"
499              << " Details:\n"
500              << "   Result:\n" << sm1 << "\n"
501              << "   Expected result:\n" << sm2 << "\n";
502          throw std::runtime_error( oss.str() );
503       }
504    }
505 
506    {
507       test_ = "Row-major self-scaling (M*=s) (16x8)";
508 
509       initialize();
510 
511       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
512       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
513 
514       sm1 *= 3;
515       sm2 *= 3;
516 
517       checkRows   ( sm1, 16UL );
518       checkColumns( sm1,  8UL );
519       checkRows   ( sm2, 16UL );
520       checkColumns( sm2,  8UL );
521 
522       if( sm1 != sm2 || mat1_ != mat2_ ) {
523          std::ostringstream oss;
524          oss << " Test: " << test_ << "\n"
525              << " Error: Failed self-scaling operation\n"
526              << " Details:\n"
527              << "   Result:\n" << sm1 << "\n"
528              << "   Expected result:\n" << sm2 << "\n";
529          throw std::runtime_error( oss.str() );
530       }
531    }
532 
533 
534    //=====================================================================================
535    // Column-major self-scaling (M=M*s)
536    //=====================================================================================
537 
538    {
539       test_ = "Row-major self-scaling (M=M*s) (8x16)";
540 
541       initialize();
542 
543       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 8UL, 16UL );
544       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 8UL, 16UL );
545 
546       sm1 = sm1 * 3;
547       sm2 = sm2 * 3;
548 
549       checkRows   ( sm1,  8UL );
550       checkColumns( sm1, 16UL );
551       checkRows   ( sm2,  8UL );
552       checkColumns( sm2, 16UL );
553 
554       if( sm1 != sm2 || mat1_ != mat2_ ) {
555          std::ostringstream oss;
556          oss << " Test: " << test_ << "\n"
557              << " Error: Failed self-scaling operation\n"
558              << " Details:\n"
559              << "   Result:\n" << sm1 << "\n"
560              << "   Expected result:\n" << sm2 << "\n";
561          throw std::runtime_error( oss.str() );
562       }
563    }
564 
565    {
566       test_ = "Row-major self-scaling (M=M*s) (16x8)";
567 
568       initialize();
569 
570       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
571       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
572 
573       sm1 = sm1 * 3;
574       sm2 = sm2 * 3;
575 
576       checkRows   ( sm1, 16UL );
577       checkColumns( sm1,  8UL );
578       checkRows   ( sm2, 16UL );
579       checkColumns( sm2,  8UL );
580 
581       if( sm1 != sm2 || mat1_ != mat2_ ) {
582          std::ostringstream oss;
583          oss << " Test: " << test_ << "\n"
584              << " Error: Failed self-scaling operation\n"
585              << " Details:\n"
586              << "   Result:\n" << sm1 << "\n"
587              << "   Expected result:\n" << sm2 << "\n";
588          throw std::runtime_error( oss.str() );
589       }
590    }
591 
592 
593    //=====================================================================================
594    // Column-major self-scaling (M=s*M)
595    //=====================================================================================
596 
597    {
598       test_ = "Row-major self-scaling (M=s*M) (8x16)";
599 
600       initialize();
601 
602       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 8UL, 16UL );
603       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 8UL, 16UL );
604 
605       sm1 = 3 * sm1;
606       sm2 = 3 * sm2;
607 
608       checkRows   ( sm1,  8UL );
609       checkColumns( sm1, 16UL );
610       checkRows   ( sm2,  8UL );
611       checkColumns( sm2, 16UL );
612 
613       if( sm1 != sm2 || mat1_ != mat2_ ) {
614          std::ostringstream oss;
615          oss << " Test: " << test_ << "\n"
616              << " Error: Failed self-scaling operation\n"
617              << " Details:\n"
618              << "   Result:\n" << sm1 << "\n"
619              << "   Expected result:\n" << sm2 << "\n";
620          throw std::runtime_error( oss.str() );
621       }
622    }
623 
624    {
625       test_ = "Row-major self-scaling (M=s*M) (16x8)";
626 
627       initialize();
628 
629       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
630       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
631 
632       sm1 = 3 * sm1;
633       sm2 = 3 * sm2;
634 
635       checkRows   ( sm1, 16UL );
636       checkColumns( sm1,  8UL );
637       checkRows   ( sm2, 16UL );
638       checkColumns( sm2,  8UL );
639 
640       if( sm1 != sm2 || mat1_ != mat2_ ) {
641          std::ostringstream oss;
642          oss << " Test: " << test_ << "\n"
643              << " Error: Failed self-scaling operation\n"
644              << " Details:\n"
645              << "   Result:\n" << sm1 << "\n"
646              << "   Expected result:\n" << sm2 << "\n";
647          throw std::runtime_error( oss.str() );
648       }
649    }
650 
651 
652    //=====================================================================================
653    // Column-major self-scaling (M/=s)
654    //=====================================================================================
655 
656    {
657       test_ = "Column-major self-scaling (M/=s) (8x16)";
658 
659       initialize();
660 
661       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 8UL, 16UL );
662       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 8UL, 16UL );
663 
664       sm1 /= 0.5;
665       sm2 /= 0.5;
666 
667       checkRows   ( sm1,  8UL );
668       checkColumns( sm1, 16UL );
669       checkRows   ( sm2,  8UL );
670       checkColumns( sm2, 16UL );
671 
672       if( sm1 != sm2 || mat1_ != mat2_ ) {
673          std::ostringstream oss;
674          oss << " Test: " << test_ << "\n"
675              << " Error: Failed self-scaling operation\n"
676              << " Details:\n"
677              << "   Result:\n" << sm1 << "\n"
678              << "   Expected result:\n" << sm2 << "\n";
679          throw std::runtime_error( oss.str() );
680       }
681    }
682 
683    {
684       test_ = "Column-major self-scaling (M/=s) (16x8)";
685 
686       initialize();
687 
688       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
689       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
690 
691       sm1 /= 0.5;
692       sm2 /= 0.5;
693 
694       checkRows   ( sm1, 16UL );
695       checkColumns( sm1,  8UL );
696       checkRows   ( sm2, 16UL );
697       checkColumns( sm2,  8UL );
698 
699       if( sm1 != sm2 || mat1_ != mat2_ ) {
700          std::ostringstream oss;
701          oss << " Test: " << test_ << "\n"
702              << " Error: Failed self-scaling operation\n"
703              << " Details:\n"
704              << "   Result:\n" << sm1 << "\n"
705              << "   Expected result:\n" << sm2 << "\n";
706          throw std::runtime_error( oss.str() );
707       }
708    }
709 
710 
711    //=====================================================================================
712    // Column-major self-scaling (M=M/s)
713    //=====================================================================================
714 
715    {
716       test_ = "Column-major self-scaling (M=M/s) (8x16)";
717 
718       initialize();
719 
720       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 8UL, 16UL );
721       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 8UL, 16UL );
722 
723       sm1 = sm1 / 0.5;
724       sm2 = sm2 / 0.5;
725 
726       checkRows   ( sm1,  8UL );
727       checkColumns( sm1, 16UL );
728       checkRows   ( sm2,  8UL );
729       checkColumns( sm2, 16UL );
730 
731       if( sm1 != sm2 || mat1_ != mat2_ ) {
732          std::ostringstream oss;
733          oss << " Test: " << test_ << "\n"
734              << " Error: Failed self-scaling operation\n"
735              << " Details:\n"
736              << "   Result:\n" << sm1 << "\n"
737              << "   Expected result:\n" << sm2 << "\n";
738          throw std::runtime_error( oss.str() );
739       }
740    }
741 
742    {
743       test_ = "Column-major self-scaling (M=M/s) (16x8)";
744 
745       initialize();
746 
747       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
748       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
749 
750       sm1 = sm1 / 0.5;
751       sm2 = sm2 / 0.5;
752 
753       checkRows   ( sm1, 16UL );
754       checkColumns( sm1,  8UL );
755       checkRows   ( sm2, 16UL );
756       checkColumns( sm2,  8UL );
757 
758       if( sm1 != sm2 || mat1_ != mat2_ ) {
759          std::ostringstream oss;
760          oss << " Test: " << test_ << "\n"
761              << " Error: Failed self-scaling operation\n"
762              << " Details:\n"
763              << "   Result:\n" << sm1 << "\n"
764              << "   Expected result:\n" << sm2 << "\n";
765          throw std::runtime_error( oss.str() );
766       }
767    }
768 
769 
770    //=====================================================================================
771    // Column-major Submatrix::scale()
772    //=====================================================================================
773 
774    {
775       test_ = "Column-major Submatrix::scale()";
776 
777       initialize();
778 
779       // Initialization check
780       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
781       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
782 
783       checkRows   ( sm1, 16UL );
784       checkColumns( sm1,  8UL );
785       checkRows   ( sm2, 16UL );
786       checkColumns( sm2,  8UL );
787 
788       // Integral scaling of the matrix
789       sm1.scale( 2 );
790       sm2.scale( 2 );
791 
792       checkRows   ( sm1, 16UL );
793       checkColumns( sm1,  8UL );
794       checkRows   ( sm2, 16UL );
795       checkColumns( sm2,  8UL );
796 
797       if( sm1 != sm2 || mat1_ != mat2_ ) {
798          std::ostringstream oss;
799          oss << " Test: " << test_ << "\n"
800              << " Error: Integral scale operation failed\n"
801              << " Details:\n"
802              << "   Result:\n" << sm1 << "\n"
803              << "   Expected result:\n" << sm2 << "\n";
804          throw std::runtime_error( oss.str() );
805       }
806 
807       // Floating point scaling of the matrix
808       sm1.scale( 0.5 );
809       sm2.scale( 0.5 );
810 
811       checkRows   ( sm1, 16UL );
812       checkColumns( sm1,  8UL );
813       checkRows   ( sm2, 16UL );
814       checkColumns( sm2,  8UL );
815 
816       if( sm1 != sm2 || mat1_ != mat2_ ) {
817          std::ostringstream oss;
818          oss << " Test: " << test_ << "\n"
819              << " Error: Floating point scale operation failed\n"
820              << " Details:\n"
821              << "   Result:\n" << sm1 << "\n"
822              << "   Expected result:\n" << sm2 << "\n";
823          throw std::runtime_error( oss.str() );
824       }
825    }
826 }
827 //*************************************************************************************************
828 
829 
830 //*************************************************************************************************
831 /*!\brief Test of the Submatrix function call operator.
832 //
833 // \return void
834 // \exception std::runtime_error Error detected.
835 //
836 // This function performs a test of adding and accessing elements via the function call operator
837 // of the Submatrix specialization. In case an error is detected, a \a std::runtime_error
838 // exception is thrown.
839 */
testFunctionCall()840 void DenseAlignedTest::testFunctionCall()
841 {
842    using blaze::submatrix;
843    using blaze::aligned;
844    using blaze::unaligned;
845 
846 
847    //=====================================================================================
848    // Row-major submatrix tests
849    //=====================================================================================
850 
851    {
852       test_ = "Row-major Submatrix::operator()";
853 
854       initialize();
855 
856       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
857       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
858 
859       // Assignment to the element (1,4)
860       {
861          sm1(1,4) = 9;
862          sm2(1,4) = 9;
863 
864          checkRows   ( sm1,  8UL );
865          checkColumns( sm1, 16UL );
866          checkRows   ( sm2,  8UL );
867          checkColumns( sm2, 16UL );
868 
869          if( sm1 != sm2 || mat1_ != mat2_ ) {
870             std::ostringstream oss;
871             oss << " Test: " << test_ << "\n"
872                 << " Error: Function call operator failed\n"
873                 << " Details:\n"
874                 << "   Result:\n" << sm1 << "\n"
875                 << "   Expected result:\n" << sm2 << "\n";
876             throw std::runtime_error( oss.str() );
877          }
878       }
879 
880       // Assignment to the element (3,10)
881       {
882          sm1(3,10) = 0;
883          sm2(3,10) = 0;
884 
885          checkRows   ( sm1,  8UL );
886          checkColumns( sm1, 16UL );
887          checkRows   ( sm2,  8UL );
888          checkColumns( sm2, 16UL );
889 
890          if( sm1 != sm2 || mat1_ != mat2_ ) {
891             std::ostringstream oss;
892             oss << " Test: " << test_ << "\n"
893                 << " Error: Function call operator failed\n"
894                 << " Details:\n"
895                 << "   Result:\n" << sm1 << "\n"
896                 << "   Expected result:\n" << sm2 << "\n";
897             throw std::runtime_error( oss.str() );
898          }
899       }
900 
901       // Assignment to the element (6,8)
902       {
903          sm1(6,8) = -7;
904          sm2(6,8) = -7;
905 
906          checkRows   ( sm1,  8UL );
907          checkColumns( sm1, 16UL );
908          checkRows   ( sm2,  8UL );
909          checkColumns( sm2, 16UL );
910 
911          if( sm1 != sm2 || mat1_ != mat2_ ) {
912             std::ostringstream oss;
913             oss << " Test: " << test_ << "\n"
914                 << " Error: Function call operator failed\n"
915                 << " Details:\n"
916                 << "   Result:\n" << sm1 << "\n"
917                 << "   Expected result:\n" << sm2 << "\n";
918             throw std::runtime_error( oss.str() );
919          }
920       }
921 
922       // Addition assignment to the element (5,7)
923       {
924          sm1(5,7) += 3;
925          sm2(5,7) += 3;
926 
927          checkRows   ( sm1,  8UL );
928          checkColumns( sm1, 16UL );
929          checkRows   ( sm2,  8UL );
930          checkColumns( sm2, 16UL );
931 
932          if( sm1 != sm2 || mat1_ != mat2_ ) {
933             std::ostringstream oss;
934             oss << " Test: " << test_ << "\n"
935                 << " Error: Function call operator failed\n"
936                 << " Details:\n"
937                 << "   Result:\n" << sm1 << "\n"
938                 << "   Expected result:\n" << sm2 << "\n";
939             throw std::runtime_error( oss.str() );
940          }
941       }
942 
943       // Subtraction assignment to the element (2,14)
944       {
945          sm1(2,14) -= -8;
946          sm2(2,14) -= -8;
947 
948          checkRows   ( sm1,  8UL );
949          checkColumns( sm1, 16UL );
950          checkRows   ( sm2,  8UL );
951          checkColumns( sm2, 16UL );
952 
953          if( sm1 != sm2 || mat1_ != mat2_ ) {
954             std::ostringstream oss;
955             oss << " Test: " << test_ << "\n"
956                 << " Error: Function call operator failed\n"
957                 << " Details:\n"
958                 << "   Result:\n" << sm1 << "\n"
959                 << "   Expected result:\n" << sm2 << "\n";
960             throw std::runtime_error( oss.str() );
961          }
962       }
963 
964       // Multiplication assignment to the element (1,1)
965       {
966          sm1(1,1) *= 3;
967          sm2(1,1) *= 3;
968 
969          checkRows   ( sm1,  8UL );
970          checkColumns( sm1, 16UL );
971          checkRows   ( sm2,  8UL );
972          checkColumns( sm2, 16UL );
973 
974          if( sm1 != sm2 || mat1_ != mat2_ ) {
975             std::ostringstream oss;
976             oss << " Test: " << test_ << "\n"
977                 << " Error: Function call operator failed\n"
978                 << " Details:\n"
979                 << "   Result:\n" << sm1 << "\n"
980                 << "   Expected result:\n" << sm2 << "\n";
981             throw std::runtime_error( oss.str() );
982          }
983       }
984 
985       // Division assignment to the element (3,4)
986       {
987          sm1(3,4) /= 2;
988          sm2(3,4) /= 2;
989 
990          checkRows   ( sm1,  8UL );
991          checkColumns( sm1, 16UL );
992          checkRows   ( sm2,  8UL );
993          checkColumns( sm2, 16UL );
994 
995          if( sm1 != sm2 || mat1_ != mat2_ ) {
996             std::ostringstream oss;
997             oss << " Test: " << test_ << "\n"
998                 << " Error: Function call operator failed\n"
999                 << " Details:\n"
1000                 << "   Result:\n" << sm1 << "\n"
1001                 << "   Expected result:\n" << sm2 << "\n";
1002             throw std::runtime_error( oss.str() );
1003          }
1004       }
1005    }
1006 
1007 
1008    //=====================================================================================
1009    // Column-major submatrix tests
1010    //=====================================================================================
1011 
1012    {
1013       test_ = "Column-major Submatrix::operator()";
1014 
1015       initialize();
1016 
1017       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
1018       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
1019 
1020       // Assignment to the element (4,1)
1021       {
1022          sm1(4,1) = 9;
1023          sm2(4,1) = 9;
1024 
1025          checkRows   ( sm1, 16UL );
1026          checkColumns( sm1,  8UL );
1027          checkRows   ( sm2, 16UL );
1028          checkColumns( sm2,  8UL );
1029 
1030          if( sm1 != sm2 || mat1_ != mat2_ ) {
1031             std::ostringstream oss;
1032             oss << " Test: " << test_ << "\n"
1033                 << " Error: Function call operator failed\n"
1034                 << " Details:\n"
1035                 << "   Result:\n" << sm1 << "\n"
1036                 << "   Expected result:\n" << sm2 << "\n";
1037             throw std::runtime_error( oss.str() );
1038          }
1039       }
1040 
1041       // Assignment to the element (10,3)
1042       {
1043          sm1(10,3) = 0;
1044          sm2(10,3) = 0;
1045 
1046          checkRows   ( sm1, 16UL );
1047          checkColumns( sm1,  8UL );
1048          checkRows   ( sm2, 16UL );
1049          checkColumns( sm2,  8UL );
1050 
1051          if( sm1 != sm2 || mat1_ != mat2_ ) {
1052             std::ostringstream oss;
1053             oss << " Test: " << test_ << "\n"
1054                 << " Error: Function call operator failed\n"
1055                 << " Details:\n"
1056                 << "   Result:\n" << sm1 << "\n"
1057                 << "   Expected result:\n" << sm2 << "\n";
1058             throw std::runtime_error( oss.str() );
1059          }
1060       }
1061 
1062       // Assignment to the element (8,6)
1063       {
1064          sm1(8,6) = -7;
1065          sm2(8,6) = -7;
1066 
1067          checkRows   ( sm1, 16UL );
1068          checkColumns( sm1,  8UL );
1069          checkRows   ( sm2, 16UL );
1070          checkColumns( sm2,  8UL );
1071 
1072          if( sm1 != sm2 || mat1_ != mat2_ ) {
1073             std::ostringstream oss;
1074             oss << " Test: " << test_ << "\n"
1075                 << " Error: Function call operator failed\n"
1076                 << " Details:\n"
1077                 << "   Result:\n" << sm1 << "\n"
1078                 << "   Expected result:\n" << sm2 << "\n";
1079             throw std::runtime_error( oss.str() );
1080          }
1081       }
1082 
1083       // Addition assignment to the element (7,5)
1084       {
1085          sm1(7,5) += 3;
1086          sm2(7,5) += 3;
1087 
1088          checkRows   ( sm1, 16UL );
1089          checkColumns( sm1,  8UL );
1090          checkRows   ( sm2, 16UL );
1091          checkColumns( sm2,  8UL );
1092 
1093          if( sm1 != sm2 || mat1_ != mat2_ ) {
1094             std::ostringstream oss;
1095             oss << " Test: " << test_ << "\n"
1096                 << " Error: Function call operator failed\n"
1097                 << " Details:\n"
1098                 << "   Result:\n" << sm1 << "\n"
1099                 << "   Expected result:\n" << sm2 << "\n";
1100             throw std::runtime_error( oss.str() );
1101          }
1102       }
1103 
1104       // Subtraction assignment to the element (14,2)
1105       {
1106          sm1(14,2) -= -8;
1107          sm2(14,2) -= -8;
1108 
1109          checkRows   ( sm1, 16UL );
1110          checkColumns( sm1,  8UL );
1111          checkRows   ( sm2, 16UL );
1112          checkColumns( sm2,  8UL );
1113 
1114          if( sm1 != sm2 || mat1_ != mat2_ ) {
1115             std::ostringstream oss;
1116             oss << " Test: " << test_ << "\n"
1117                 << " Error: Function call operator failed\n"
1118                 << " Details:\n"
1119                 << "   Result:\n" << sm1 << "\n"
1120                 << "   Expected result:\n" << sm2 << "\n";
1121             throw std::runtime_error( oss.str() );
1122          }
1123       }
1124 
1125       // Multiplication assignment to the element (1,1)
1126       {
1127          sm1(1,1) *= 3;
1128          sm2(1,1) *= 3;
1129 
1130          checkRows   ( sm1, 16UL );
1131          checkColumns( sm1,  8UL );
1132          checkRows   ( sm2, 16UL );
1133          checkColumns( sm2,  8UL );
1134 
1135          if( sm1 != sm2 || mat1_ != mat2_ ) {
1136             std::ostringstream oss;
1137             oss << " Test: " << test_ << "\n"
1138                 << " Error: Function call operator failed\n"
1139                 << " Details:\n"
1140                 << "   Result:\n" << sm1 << "\n"
1141                 << "   Expected result:\n" << sm2 << "\n";
1142             throw std::runtime_error( oss.str() );
1143          }
1144       }
1145 
1146       // Division assignment to the element (4,3)
1147       {
1148          sm1(4,3) /= 2;
1149          sm2(4,3) /= 2;
1150 
1151          checkRows   ( sm1, 16UL );
1152          checkColumns( sm1,  8UL );
1153          checkRows   ( sm2, 16UL );
1154          checkColumns( sm2,  8UL );
1155 
1156          if( sm1 != sm2 || mat1_ != mat2_ ) {
1157             std::ostringstream oss;
1158             oss << " Test: " << test_ << "\n"
1159                 << " Error: Function call operator failed\n"
1160                 << " Details:\n"
1161                 << "   Result:\n" << sm1 << "\n"
1162                 << "   Expected result:\n" << sm2 << "\n";
1163             throw std::runtime_error( oss.str() );
1164          }
1165       }
1166    }
1167 }
1168 //*************************************************************************************************
1169 
1170 
1171 //*************************************************************************************************
1172 /*!\brief Test of the Submatrix iterator implementation.
1173 //
1174 // \return void
1175 // \exception std::runtime_error Error detected.
1176 //
1177 // This function performs a test of the iterator implementation of the Submatrix class
1178 // template. In case an error is detected, a \a std::runtime_error exception is thrown.
1179 */
testIterator()1180 void DenseAlignedTest::testIterator()
1181 {
1182    using blaze::submatrix;
1183    using blaze::aligned;
1184    using blaze::unaligned;
1185 
1186 
1187    //=====================================================================================
1188    // Row-major submatrix tests
1189    //=====================================================================================
1190 
1191    {
1192       initialize();
1193 
1194       // Testing the Iterator default constructor
1195       {
1196          test_ = "Row-major Iterator default constructor";
1197 
1198          ASMT::Iterator it{};
1199 
1200          if( it != ASMT::Iterator() ) {
1201             std::ostringstream oss;
1202             oss << " Test: " << test_ << "\n"
1203                 << " Error: Failed iterator default constructor\n";
1204             throw std::runtime_error( oss.str() );
1205          }
1206       }
1207 
1208       // Testing the ConstIterator default constructor
1209       {
1210          test_ = "Row-major ConstIterator default constructor";
1211 
1212          ASMT::ConstIterator it{};
1213 
1214          if( it != ASMT::ConstIterator() ) {
1215             std::ostringstream oss;
1216             oss << " Test: " << test_ << "\n"
1217                 << " Error: Failed iterator default constructor\n";
1218             throw std::runtime_error( oss.str() );
1219          }
1220       }
1221 
1222       // Testing conversion from Iterator to ConstIterator
1223       {
1224          test_ = "Row-major Iterator/ConstIterator conversion";
1225 
1226          ASMT sm = submatrix<aligned>( mat1_, 8UL, 16UL, 8UL, 16UL );
1227          ASMT::ConstIterator it( begin( sm, 2UL ) );
1228 
1229          if( it == end( sm, 2UL ) || *it != sm(2,0) ) {
1230             std::ostringstream oss;
1231             oss << " Test: " << test_ << "\n"
1232                 << " Error: Failed iterator conversion detected\n";
1233             throw std::runtime_error( oss.str() );
1234          }
1235       }
1236 
1237       // Counting the number of elements in 0th row of a 8x16 matrix via Iterator (end-begin)
1238       {
1239          test_ = "Row-major Iterator subtraction (end-begin)";
1240 
1241          ASMT sm = submatrix<aligned>( mat1_, 8UL, 16UL, 8UL, 16UL );
1242          const ptrdiff_t number( end( sm, 0UL ) - begin( sm, 0UL ) );
1243 
1244          if( number != 16L ) {
1245             std::ostringstream oss;
1246             oss << " Test: " << test_ << "\n"
1247                 << " Error: Invalid number of elements detected\n"
1248                 << " Details:\n"
1249                 << "   Number of elements         : " << number << "\n"
1250                 << "   Expected number of elements: 16\n";
1251             throw std::runtime_error( oss.str() );
1252          }
1253       }
1254 
1255       // Counting the number of elements in 0th row of a 8x16 matrix via Iterator (begin-end)
1256       {
1257          test_ = "Row-major Iterator subtraction (begin-end)";
1258 
1259          ASMT sm = submatrix<aligned>( mat1_, 8UL, 16UL, 8UL, 16UL );
1260          const ptrdiff_t number( begin( sm, 0UL ) - end( sm, 0UL ) );
1261 
1262          if( number != -16L ) {
1263             std::ostringstream oss;
1264             oss << " Test: " << test_ << "\n"
1265                 << " Error: Invalid number of elements detected\n"
1266                 << " Details:\n"
1267                 << "   Number of elements         : " << number << "\n"
1268                 << "   Expected number of elements: -16\n";
1269             throw std::runtime_error( oss.str() );
1270          }
1271       }
1272 
1273       // Counting the number of elements in 15th row of a 16x8 matrix via ConstIterator (end-begin)
1274       {
1275          test_ = "Row-major ConstIterator subtraction (end-begin)";
1276 
1277          ASMT sm = submatrix<aligned>( mat1_, 8UL, 16UL, 16UL, 8UL );
1278          const ptrdiff_t number( cend( sm, 15UL ) - cbegin( sm, 15UL ) );
1279 
1280          if( number != 8L ) {
1281             std::ostringstream oss;
1282             oss << " Test: " << test_ << "\n"
1283                 << " Error: Invalid number of elements detected\n"
1284                 << " Details:\n"
1285                 << "   Number of elements         : " << number << "\n"
1286                 << "   Expected number of elements: 8\n";
1287             throw std::runtime_error( oss.str() );
1288          }
1289       }
1290 
1291       // Counting the number of elements in 15th row of a 16x8 matrix via ConstIterator (begin-end)
1292       {
1293          test_ = "Row-major ConstIterator subtraction (begin-end)";
1294 
1295          ASMT sm = submatrix<aligned>( mat1_, 8UL, 16UL, 16UL, 8UL );
1296          const ptrdiff_t number( cbegin( sm, 15UL ) - cend( sm, 15UL ) );
1297 
1298          if( number != -8L ) {
1299             std::ostringstream oss;
1300             oss << " Test: " << test_ << "\n"
1301                 << " Error: Invalid number of elements detected\n"
1302                 << " Details:\n"
1303                 << "   Number of elements         : " << number << "\n"
1304                 << "   Expected number of elements: -8\n";
1305             throw std::runtime_error( oss.str() );
1306          }
1307       }
1308 
1309       // Testing read-only access via ConstIterator
1310       {
1311          test_ = "Row-major read-only access via ConstIterator";
1312 
1313          ASMT sm = submatrix<aligned>( mat1_, 8UL, 16UL, 8UL, 16UL );
1314          ASMT::ConstIterator it ( cbegin( sm, 2UL ) );
1315          ASMT::ConstIterator end( cend( sm, 2UL ) );
1316 
1317          if( it == end || *it != sm(2,0) ) {
1318             std::ostringstream oss;
1319             oss << " Test: " << test_ << "\n"
1320                 << " Error: Invalid initial iterator detected\n";
1321             throw std::runtime_error( oss.str() );
1322          }
1323 
1324          ++it;
1325 
1326          if( it == end || *it != sm(2,1) ) {
1327             std::ostringstream oss;
1328             oss << " Test: " << test_ << "\n"
1329                 << " Error: Iterator pre-increment failed\n";
1330             throw std::runtime_error( oss.str() );
1331          }
1332 
1333          --it;
1334 
1335          if( it == end || *it != sm(2,0) ) {
1336             std::ostringstream oss;
1337             oss << " Test: " << test_ << "\n"
1338                 << " Error: Iterator pre-decrement failed\n";
1339             throw std::runtime_error( oss.str() );
1340          }
1341 
1342          it++;
1343 
1344          if( it == end || *it != sm(2,1) ) {
1345             std::ostringstream oss;
1346             oss << " Test: " << test_ << "\n"
1347                 << " Error: Iterator post-increment failed\n";
1348             throw std::runtime_error( oss.str() );
1349          }
1350 
1351          it--;
1352 
1353          if( it == end || *it != sm(2,0) ) {
1354             std::ostringstream oss;
1355             oss << " Test: " << test_ << "\n"
1356                 << " Error: Iterator post-decrement failed\n";
1357             throw std::runtime_error( oss.str() );
1358          }
1359 
1360          it += 2UL;
1361 
1362          if( it == end || *it != sm(2,2) ) {
1363             std::ostringstream oss;
1364             oss << " Test: " << test_ << "\n"
1365                 << " Error: Iterator addition assignment failed\n";
1366             throw std::runtime_error( oss.str() );
1367          }
1368 
1369          it -= 2UL;
1370 
1371          if( it == end || *it != sm(2,0) ) {
1372             std::ostringstream oss;
1373             oss << " Test: " << test_ << "\n"
1374                 << " Error: Iterator subtraction assignment failed\n";
1375             throw std::runtime_error( oss.str() );
1376          }
1377 
1378          it = it + 2UL;
1379 
1380          if( it == end || *it != sm(2,2) ) {
1381             std::ostringstream oss;
1382             oss << " Test: " << test_ << "\n"
1383                 << " Error: Iterator/scalar addition failed\n";
1384             throw std::runtime_error( oss.str() );
1385          }
1386 
1387          it = it - 2UL;
1388 
1389          if( it == end || *it != sm(2,0) ) {
1390             std::ostringstream oss;
1391             oss << " Test: " << test_ << "\n"
1392                 << " Error: Iterator/scalar subtraction failed\n";
1393             throw std::runtime_error( oss.str() );
1394          }
1395 
1396          it = 16UL + it;
1397 
1398          if( it != end ) {
1399             std::ostringstream oss;
1400             oss << " Test: " << test_ << "\n"
1401                 << " Error: Scalar/iterator addition failed\n";
1402             throw std::runtime_error( oss.str() );
1403          }
1404       }
1405 
1406       // Testing assignment via Iterator
1407       {
1408          test_ = "Row-major assignment via Iterator";
1409 
1410          ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
1411          USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
1412          int value = 7;
1413 
1414          ASMT::Iterator it1( begin( sm1, 2UL ) );
1415          USMT::Iterator it2( begin( sm2, 2UL ) );
1416 
1417          for( ; it1!=end( sm1, 2UL ); ++it1, ++it2 ) {
1418             *it1 = value;
1419             *it2 = value;
1420             ++value;
1421          }
1422 
1423          if( sm1 != sm2 || mat1_ != mat2_ ) {
1424             std::ostringstream oss;
1425             oss << " Test: " << test_ << "\n"
1426                 << " Error: Assignment via iterator failed\n"
1427                 << " Details:\n"
1428                 << "   Result:\n" << sm1 << "\n"
1429                 << "   Expected result:\n" << sm2 << "\n";
1430             throw std::runtime_error( oss.str() );
1431          }
1432       }
1433 
1434       // Testing addition assignment via Iterator
1435       {
1436          test_ = "Row-major addition assignment via Iterator";
1437 
1438          ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
1439          USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
1440          int value = 4;
1441 
1442          ASMT::Iterator it1( begin( sm1, 2UL ) );
1443          USMT::Iterator it2( begin( sm2, 2UL ) );
1444 
1445          for( ; it1!=end( sm1, 2UL ); ++it1, ++it2 ) {
1446             *it1 += value;
1447             *it2 += value;
1448             ++value;
1449          }
1450 
1451          if( sm1 != sm2 || mat1_ != mat2_ ) {
1452             std::ostringstream oss;
1453             oss << " Test: " << test_ << "\n"
1454                 << " Error: Addition assignment via iterator failed\n"
1455                 << " Details:\n"
1456                 << "   Result:\n" << sm1 << "\n"
1457                 << "   Expected result:\n" << sm2 << "\n";
1458             throw std::runtime_error( oss.str() );
1459          }
1460       }
1461 
1462       // Testing subtraction assignment via Iterator
1463       {
1464          test_ = "Row-major subtraction assignment via Iterator";
1465 
1466          ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
1467          USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
1468          int value = 4;
1469 
1470          ASMT::Iterator it1( begin( sm1, 2UL ) );
1471          USMT::Iterator it2( begin( sm2, 2UL ) );
1472 
1473          for( ; it1!=end( sm1, 2UL ); ++it1, ++it2 ) {
1474             *it1 -= value;
1475             *it2 -= value;
1476             ++value;
1477          }
1478 
1479          if( sm1 != sm2 || mat1_ != mat2_ ) {
1480             std::ostringstream oss;
1481             oss << " Test: " << test_ << "\n"
1482                 << " Error: Subtraction assignment via iterator failed\n"
1483                 << " Details:\n"
1484                 << "   Result:\n" << sm1 << "\n"
1485                 << "   Expected result:\n" << sm2 << "\n";
1486             throw std::runtime_error( oss.str() );
1487          }
1488       }
1489 
1490       // Testing multiplication assignment via Iterator
1491       {
1492          test_ = "Row-major multiplication assignment via Iterator";
1493 
1494          ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
1495          USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
1496          int value = 2;
1497 
1498          ASMT::Iterator it1( begin( sm1, 2UL ) );
1499          USMT::Iterator it2( begin( sm2, 2UL ) );
1500 
1501          for( ; it1!=end( sm1, 2UL ); ++it1, ++it2 ) {
1502             *it1 *= value;
1503             *it2 *= value;
1504             ++value;
1505          }
1506 
1507          if( sm1 != sm2 || mat1_ != mat2_ ) {
1508             std::ostringstream oss;
1509             oss << " Test: " << test_ << "\n"
1510                 << " Error: Multiplication assignment via iterator failed\n"
1511                 << " Details:\n"
1512                 << "   Result:\n" << sm1 << "\n"
1513                 << "   Expected result:\n" << sm2 << "\n";
1514             throw std::runtime_error( oss.str() );
1515          }
1516       }
1517 
1518       // Testing division assignment via Iterator
1519       {
1520          test_ = "Row-major division assignment via Iterator";
1521 
1522          ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
1523          USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
1524 
1525          ASMT::Iterator it1( begin( sm1, 2UL ) );
1526          USMT::Iterator it2( begin( sm2, 2UL ) );
1527 
1528          for( ; it1!=end( sm1, 2UL ); ++it1, ++it2 ) {
1529             *it1 /= 2;
1530             *it2 /= 2;
1531          }
1532 
1533          if( sm1 != sm2 || mat1_ != mat2_ ) {
1534             std::ostringstream oss;
1535             oss << " Test: " << test_ << "\n"
1536                 << " Error: Division assignment via iterator failed\n"
1537                 << " Details:\n"
1538                 << "   Result:\n" << sm1 << "\n"
1539                 << "   Expected result:\n" << sm2 << "\n";
1540             throw std::runtime_error( oss.str() );
1541          }
1542       }
1543    }
1544 
1545 
1546    //=====================================================================================
1547    // Column-major submatrix tests
1548    //=====================================================================================
1549 
1550    {
1551       initialize();
1552 
1553       // Testing the Iterator default constructor
1554       {
1555          test_ = "Column-major Iterator default constructor";
1556 
1557          AOSMT::Iterator it{};
1558 
1559          if( it != AOSMT::Iterator() ) {
1560             std::ostringstream oss;
1561             oss << " Test: " << test_ << "\n"
1562                 << " Error: Failed iterator default constructor\n";
1563             throw std::runtime_error( oss.str() );
1564          }
1565       }
1566 
1567       // Testing the ConstIterator default constructor
1568       {
1569          test_ = "Column-major ConstIterator default constructor";
1570 
1571          AOSMT::ConstIterator it{};
1572 
1573          if( it != AOSMT::ConstIterator() ) {
1574             std::ostringstream oss;
1575             oss << " Test: " << test_ << "\n"
1576                 << " Error: Failed iterator default constructor\n";
1577             throw std::runtime_error( oss.str() );
1578          }
1579       }
1580 
1581       // Testing conversion from Iterator to ConstIterator
1582       {
1583          test_ = "Column-major Iterator/ConstIterator conversion";
1584 
1585          AOSMT sm = submatrix<aligned>( tmat1_, 16UL, 8UL, 8UL, 16UL );
1586          AOSMT::ConstIterator it( begin( sm, 2UL ) );
1587 
1588          if( it == end( sm, 2UL ) || *it != sm(0,2) ) {
1589             std::ostringstream oss;
1590             oss << " Test: " << test_ << "\n"
1591                 << " Error: Failed iterator conversion detected\n";
1592             throw std::runtime_error( oss.str() );
1593          }
1594       }
1595 
1596       // Counting the number of elements in 0th column of a 16x8 matrix via Iterator (end-begin)
1597       {
1598          test_ = "Column-major Iterator subtraction (end-begin)";
1599 
1600          AOSMT sm = submatrix<aligned>( tmat1_, 16UL, 8UL, 16UL, 8UL );
1601          const ptrdiff_t number( end( sm, 0UL ) - begin( sm, 0UL ) );
1602 
1603          if( number != 16L ) {
1604             std::ostringstream oss;
1605             oss << " Test: " << test_ << "\n"
1606                 << " Error: Invalid number of elements detected\n"
1607                 << " Details:\n"
1608                 << "   Number of elements         : " << number << "\n"
1609                 << "   Expected number of elements: 16\n";
1610             throw std::runtime_error( oss.str() );
1611          }
1612       }
1613 
1614       // Counting the number of elements in 0th column of a 16x8 matrix via Iterator (begin-end)
1615       {
1616          test_ = "Column-major Iterator subtraction (begin-end)";
1617 
1618          AOSMT sm = submatrix<aligned>( tmat1_, 16UL, 8UL, 16UL, 8UL );
1619          const ptrdiff_t number( begin( sm, 0UL ) - end( sm, 0UL ) );
1620 
1621          if( number != -16L ) {
1622             std::ostringstream oss;
1623             oss << " Test: " << test_ << "\n"
1624                 << " Error: Invalid number of elements detected\n"
1625                 << " Details:\n"
1626                 << "   Number of elements         : " << number << "\n"
1627                 << "   Expected number of elements: -16\n";
1628             throw std::runtime_error( oss.str() );
1629          }
1630       }
1631 
1632       // Counting the number of elements in 15th column of a 8x16 matrix via ConstIterator (end-begin)
1633       {
1634          test_ = "Column-major ConstIterator subtraction (end-begin)";
1635 
1636          AOSMT sm = submatrix<aligned>( tmat1_, 16UL, 8UL, 8UL, 16UL );
1637          const ptrdiff_t number( cend( sm, 15UL ) - cbegin( sm, 15UL ) );
1638 
1639          if( number != 8L ) {
1640             std::ostringstream oss;
1641             oss << " Test: " << test_ << "\n"
1642                 << " Error: Invalid number of elements detected\n"
1643                 << " Details:\n"
1644                 << "   Number of elements         : " << number << "\n"
1645                 << "   Expected number of elements: 8\n";
1646             throw std::runtime_error( oss.str() );
1647          }
1648       }
1649 
1650       // Counting the number of elements in 15th column of a 8x16 matrix via ConstIterator (begin-end)
1651       {
1652          test_ = "Column-major ConstIterator subtraction (begin-end)";
1653 
1654          AOSMT sm = submatrix<aligned>( tmat1_, 16UL, 8UL, 8UL, 16UL );
1655          const ptrdiff_t number( cbegin( sm, 15UL ) - cend( sm, 15UL ) );
1656 
1657          if( number != -8L ) {
1658             std::ostringstream oss;
1659             oss << " Test: " << test_ << "\n"
1660                 << " Error: Invalid number of elements detected\n"
1661                 << " Details:\n"
1662                 << "   Number of elements         : " << number << "\n"
1663                 << "   Expected number of elements: -8\n";
1664             throw std::runtime_error( oss.str() );
1665          }
1666       }
1667 
1668       // Testing read-only access via ConstIterator
1669       {
1670          test_ = "Column-major read-only access via ConstIterator";
1671 
1672          AOSMT sm = submatrix<aligned>( tmat1_, 16UL, 8UL, 16UL, 8UL );
1673          AOSMT::ConstIterator it ( cbegin( sm, 2UL ) );
1674          AOSMT::ConstIterator end( cend( sm, 2UL ) );
1675 
1676          if( it == end || *it != sm(0,2) ) {
1677             std::ostringstream oss;
1678             oss << " Test: " << test_ << "\n"
1679                 << " Error: Invalid initial iterator detected\n";
1680             throw std::runtime_error( oss.str() );
1681          }
1682 
1683          ++it;
1684 
1685          if( it == end || *it != sm(1,2) ) {
1686             std::ostringstream oss;
1687             oss << " Test: " << test_ << "\n"
1688                 << " Error: Iterator pre-increment failed\n";
1689             throw std::runtime_error( oss.str() );
1690          }
1691 
1692          --it;
1693 
1694          if( it == end || *it != sm(0,2) ) {
1695             std::ostringstream oss;
1696             oss << " Test: " << test_ << "\n"
1697                 << " Error: Iterator pre-decrement failed\n";
1698             throw std::runtime_error( oss.str() );
1699          }
1700 
1701          it++;
1702 
1703          if( it == end || *it != sm(1,2) ) {
1704             std::ostringstream oss;
1705             oss << " Test: " << test_ << "\n"
1706                 << " Error: Iterator post-increment failed\n";
1707             throw std::runtime_error( oss.str() );
1708          }
1709 
1710          it--;
1711 
1712          if( it == end || *it != sm(0,2) ) {
1713             std::ostringstream oss;
1714             oss << " Test: " << test_ << "\n"
1715                 << " Error: Iterator post-decrement failed\n";
1716             throw std::runtime_error( oss.str() );
1717          }
1718 
1719          it += 2UL;
1720 
1721          if( it == end || *it != sm(2,2) ) {
1722             std::ostringstream oss;
1723             oss << " Test: " << test_ << "\n"
1724                 << " Error: Iterator addition assignment failed\n";
1725             throw std::runtime_error( oss.str() );
1726          }
1727 
1728          it -= 2UL;
1729 
1730          if( it == end || *it != sm(0,2) ) {
1731             std::ostringstream oss;
1732             oss << " Test: " << test_ << "\n"
1733                 << " Error: Iterator subtraction assignment failed\n";
1734             throw std::runtime_error( oss.str() );
1735          }
1736 
1737          it = it + 2UL;
1738 
1739          if( it == end || *it != sm(2,2) ) {
1740             std::ostringstream oss;
1741             oss << " Test: " << test_ << "\n"
1742                 << " Error: Iterator/scalar addition failed\n";
1743             throw std::runtime_error( oss.str() );
1744          }
1745 
1746          it = it - 2UL;
1747 
1748          if( it == end || *it != sm(0,2) ) {
1749             std::ostringstream oss;
1750             oss << " Test: " << test_ << "\n"
1751                 << " Error: Iterator/scalar subtraction failed\n";
1752             throw std::runtime_error( oss.str() );
1753          }
1754 
1755          it = 16UL + it;
1756 
1757          if( it != end ) {
1758             std::ostringstream oss;
1759             oss << " Test: " << test_ << "\n"
1760                 << " Error: Scalar/iterator addition failed\n";
1761             throw std::runtime_error( oss.str() );
1762          }
1763       }
1764 
1765       // Testing assignment via Iterator
1766       {
1767          test_ = "Column-major assignment via Iterator";
1768 
1769          AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
1770          UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
1771          int value = 7;
1772 
1773          AOSMT::Iterator it1( begin( sm1, 2UL ) );
1774          UOSMT::Iterator it2( begin( sm2, 2UL ) );
1775 
1776          for( ; it1!=end( sm1, 2UL ); ++it1, ++it2 ) {
1777             *it1 = value;
1778             *it2 = value;
1779             ++value;
1780          }
1781 
1782          if( sm1 != sm2 || mat1_ != mat2_ ) {
1783             std::ostringstream oss;
1784             oss << " Test: " << test_ << "\n"
1785                 << " Error: Assignment via iterator failed\n"
1786                 << " Details:\n"
1787                 << "   Result:\n" << sm1 << "\n"
1788                 << "   Expected result:\n" << sm2 << "\n";
1789             throw std::runtime_error( oss.str() );
1790          }
1791       }
1792 
1793       // Testing addition assignment via Iterator
1794       {
1795          test_ = "Column-major addition assignment via Iterator";
1796 
1797          AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
1798          UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
1799          int value = 4;
1800 
1801          AOSMT::Iterator it1( begin( sm1, 2UL ) );
1802          UOSMT::Iterator it2( begin( sm2, 2UL ) );
1803 
1804          for( ; it1!=end( sm1, 2UL ); ++it1, ++it2 ) {
1805             *it1 += value;
1806             *it2 += value;
1807             ++value;
1808          }
1809 
1810          if( sm1 != sm2 || mat1_ != mat2_ ) {
1811             std::ostringstream oss;
1812             oss << " Test: " << test_ << "\n"
1813                 << " Error: Addition assignment via iterator failed\n"
1814                 << " Details:\n"
1815                 << "   Result:\n" << sm1 << "\n"
1816                 << "   Expected result:\n" << sm2 << "\n";
1817             throw std::runtime_error( oss.str() );
1818          }
1819       }
1820 
1821       // Testing subtraction assignment via Iterator
1822       {
1823          test_ = "Column-major subtraction assignment via Iterator";
1824 
1825          AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
1826          UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
1827          int value = 4;
1828 
1829          AOSMT::Iterator it1( begin( sm1, 2UL ) );
1830          UOSMT::Iterator it2( begin( sm2, 2UL ) );
1831 
1832          for( ; it1!=end( sm1, 2UL ); ++it1, ++it2 ) {
1833             *it1 -= value;
1834             *it2 -= value;
1835             ++value;
1836          }
1837 
1838          if( sm1 != sm2 || mat1_ != mat2_ ) {
1839             std::ostringstream oss;
1840             oss << " Test: " << test_ << "\n"
1841                 << " Error: Subtraction assignment via iterator failed\n"
1842                 << " Details:\n"
1843                 << "   Result:\n" << sm1 << "\n"
1844                 << "   Expected result:\n" << sm2 << "\n";
1845             throw std::runtime_error( oss.str() );
1846          }
1847       }
1848 
1849       // Testing multiplication assignment via Iterator
1850       {
1851          test_ = "Column-major multiplication assignment via Iterator";
1852 
1853          AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
1854          UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
1855          int value = 2;
1856 
1857          AOSMT::Iterator it1( begin( sm1, 2UL ) );
1858          UOSMT::Iterator it2( begin( sm2, 2UL ) );
1859 
1860          for( ; it1!=end( sm1, 2UL ); ++it1, ++it2 ) {
1861             *it1 *= value;
1862             *it2 *= value;
1863             ++value;
1864          }
1865 
1866          if( sm1 != sm2 || mat1_ != mat2_ ) {
1867             std::ostringstream oss;
1868             oss << " Test: " << test_ << "\n"
1869                 << " Error: Multiplication assignment via iterator failed\n"
1870                 << " Details:\n"
1871                 << "   Result:\n" << sm1 << "\n"
1872                 << "   Expected result:\n" << sm2 << "\n";
1873             throw std::runtime_error( oss.str() );
1874          }
1875       }
1876 
1877       // Testing division assignment via Iterator
1878       {
1879          test_ = "Column-major division assignment via Iterator";
1880 
1881          AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
1882          UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
1883 
1884          AOSMT::Iterator it1( begin( sm1, 2UL ) );
1885          UOSMT::Iterator it2( begin( sm2, 2UL ) );
1886 
1887          for( ; it1!=end( sm1, 2UL ); ++it1, ++it2 ) {
1888             *it1 /= 2;
1889             *it2 /= 2;
1890          }
1891 
1892          if( sm1 != sm2 || mat1_ != mat2_ ) {
1893             std::ostringstream oss;
1894             oss << " Test: " << test_ << "\n"
1895                 << " Error: Division assignment via iterator failed\n"
1896                 << " Details:\n"
1897                 << "   Result:\n" << sm1 << "\n"
1898                 << "   Expected result:\n" << sm2 << "\n";
1899             throw std::runtime_error( oss.str() );
1900          }
1901       }
1902    }
1903 }
1904 //*************************************************************************************************
1905 
1906 
1907 //*************************************************************************************************
1908 /*!\brief Test of the \c nonZeros() member function of the Submatrix class template.
1909 //
1910 // \return void
1911 // \exception std::runtime_error Error detected.
1912 //
1913 // This function performs a test of the \c nonZeros() member function of the Submatrix
1914 // specialization. In case an error is detected, a \a std::runtime_error exception is thrown.
1915 */
testNonZeros()1916 void DenseAlignedTest::testNonZeros()
1917 {
1918    using blaze::submatrix;
1919    using blaze::aligned;
1920    using blaze::unaligned;
1921 
1922 
1923    //=====================================================================================
1924    // Row-major submatrix tests
1925    //=====================================================================================
1926 
1927    {
1928       test_ = "Row-major Submatrix::nonZeros()";
1929 
1930       initialize();
1931 
1932       // Initialization check
1933       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
1934       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
1935 
1936       checkRows   ( sm1,  8UL );
1937       checkColumns( sm1, 16UL );
1938       checkRows   ( sm2,  8UL );
1939       checkColumns( sm2, 16UL );
1940 
1941       if( sm1.nonZeros() != sm2.nonZeros() ) {
1942          std::ostringstream oss;
1943          oss << " Test: " << test_ << "\n"
1944              << " Error: Invalid number of non-zeros\n"
1945              << " Details:\n"
1946              << "   Result:\n" << sm1.nonZeros() << "\n"
1947              << "   Expected result:\n" << sm2.nonZeros() << "\n"
1948              << "   Submatrix:\n" << sm1 << "\n"
1949              << "   Reference:\n" << sm2 << "\n";
1950          throw std::runtime_error( oss.str() );
1951       }
1952 
1953       for( size_t i=0UL; i<sm1.rows(); ++i ) {
1954          if( sm1.nonZeros(i) != sm2.nonZeros(i) ) {
1955             std::ostringstream oss;
1956             oss << " Test: " << test_ << "\n"
1957                 << " Error: Invalid number of non-zeros in row " << i << "\n"
1958                 << " Details:\n"
1959                 << "   Result:\n" << sm1.nonZeros(i) << "\n"
1960                 << "   Expected result:\n" << sm2.nonZeros(i) << "\n"
1961                 << "   Submatrix:\n" << sm1 << "\n"
1962                 << "   Reference:\n" << sm2 << "\n";
1963             throw std::runtime_error( oss.str() );
1964          }
1965       }
1966    }
1967 
1968 
1969    //=====================================================================================
1970    // Column-major submatrix tests
1971    //=====================================================================================
1972 
1973    {
1974       test_ = "Column-major Submatrix::nonZeros()";
1975 
1976       initialize();
1977 
1978       // Initialization check
1979       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
1980       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
1981 
1982       checkRows   ( sm1, 16UL );
1983       checkColumns( sm1,  8UL );
1984       checkRows   ( sm2, 16UL );
1985       checkColumns( sm2,  8UL );
1986 
1987       if( sm1.nonZeros() != sm2.nonZeros() ) {
1988          std::ostringstream oss;
1989          oss << " Test: " << test_ << "\n"
1990              << " Error: Invalid number of non-zeros\n"
1991              << " Details:\n"
1992              << "   Result:\n" << sm1.nonZeros() << "\n"
1993              << "   Expected result:\n" << sm2.nonZeros() << "\n"
1994              << "   Submatrix:\n" << sm1 << "\n"
1995              << "   Reference:\n" << sm2 << "\n";
1996          throw std::runtime_error( oss.str() );
1997       }
1998 
1999       for( size_t j=0UL; j<sm1.columns(); ++j ) {
2000          if( sm1.nonZeros(j) != sm2.nonZeros(j) ) {
2001             std::ostringstream oss;
2002             oss << " Test: " << test_ << "\n"
2003                 << " Error: Invalid number of non-zeros in column " << j << "\n"
2004                 << " Details:\n"
2005                 << "   Result:\n" << sm1.nonZeros(j) << "\n"
2006                 << "   Expected result:\n" << sm2.nonZeros(j) << "\n"
2007                 << "   Submatrix:\n" << sm1 << "\n"
2008                 << "   Reference:\n" << sm2 << "\n";
2009             throw std::runtime_error( oss.str() );
2010          }
2011       }
2012    }
2013 }
2014 //*************************************************************************************************
2015 
2016 
2017 //*************************************************************************************************
2018 /*!\brief Test of the \c reset() member function of the Submatrix class template.
2019 //
2020 // \return void
2021 // \exception std::runtime_error Error detected.
2022 //
2023 // This function performs a test of the \c reset() member function of the Submatrix
2024 // specialization. In case an error is detected, a \a std::runtime_error exception is thrown.
2025 */
testReset()2026 void DenseAlignedTest::testReset()
2027 {
2028    using blaze::submatrix;
2029    using blaze::aligned;
2030    using blaze::unaligned;
2031    using blaze::reset;
2032 
2033 
2034    //=====================================================================================
2035    // Row-major single element reset
2036    //=====================================================================================
2037 
2038    {
2039       test_ = "Row-major reset() function";
2040 
2041       initialize();
2042 
2043       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
2044       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
2045 
2046       reset( sm1(4,4) );
2047       reset( sm2(4,4) );
2048 
2049       checkRows   ( sm1,  8UL );
2050       checkColumns( sm1, 16UL );
2051       checkRows   ( sm2,  8UL );
2052       checkColumns( sm2, 16UL );
2053 
2054       if( sm1 != sm2 || mat1_ != mat2_ ) {
2055          std::ostringstream oss;
2056          oss << " Test: " << test_ << "\n"
2057              << " Error: Reset operation failed\n"
2058              << " Details:\n"
2059              << "   Result:\n" << sm1 << "\n"
2060              << "   Expected result:\n" << sm2 << "\n";
2061          throw std::runtime_error( oss.str() );
2062       }
2063    }
2064 
2065 
2066    //=====================================================================================
2067    // Row-major reset
2068    //=====================================================================================
2069 
2070    {
2071       test_ = "Row-major Submatrix::reset() (lvalue)";
2072 
2073       initialize();
2074 
2075       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
2076       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
2077 
2078       reset( sm1 );
2079       reset( sm2 );
2080 
2081       checkRows   ( sm1,  8UL );
2082       checkColumns( sm1, 16UL );
2083       checkRows   ( sm2,  8UL );
2084       checkColumns( sm2, 16UL );
2085 
2086       if( !isDefault( sm1 ) || !isDefault( sm2 ) || sm1 != sm2 || mat1_ != mat2_ ) {
2087          std::ostringstream oss;
2088          oss << " Test: " << test_ << "\n"
2089              << " Error: Reset operation failed\n"
2090              << " Details:\n"
2091              << "   Result:\n" << sm1 << "\n"
2092              << "   Expected result:\n" << sm2 << "\n";
2093          throw std::runtime_error( oss.str() );
2094       }
2095    }
2096 
2097    {
2098       test_ = "Row-major Submatrix::reset() (rvalue)";
2099 
2100       initialize();
2101 
2102       reset( submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL ) );
2103       reset( submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL ) );
2104 
2105       if( mat1_ != mat2_ ) {
2106          std::ostringstream oss;
2107          oss << " Test: " << test_ << "\n"
2108              << " Error: Reset operation failed\n"
2109              << " Details:\n"
2110              << "   Result:\n" << mat1_ << "\n"
2111              << "   Expected result:\n" << mat2_ << "\n";
2112          throw std::runtime_error( oss.str() );
2113       }
2114    }
2115 
2116 
2117    //=====================================================================================
2118    // Row-major row-wise reset
2119    //=====================================================================================
2120 
2121    {
2122       test_ = "Row-major Submatrix::reset( size_t )";
2123 
2124       initialize();
2125 
2126       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
2127       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
2128 
2129       for( size_t i=0UL; i<sm1.rows(); ++i )
2130       {
2131          reset( sm1, i );
2132          reset( sm2, i );
2133 
2134          if( sm1 != sm2 || mat1_ != mat2_ ) {
2135             std::ostringstream oss;
2136             oss << " Test: " << test_ << "\n"
2137                 << " Error: Reset operation failed\n"
2138                 << " Details:\n"
2139                 << "   Result:\n" << sm1 << "\n"
2140                 << "   Expected result:\n" << sm2 << "\n";
2141             throw std::runtime_error( oss.str() );
2142          }
2143       }
2144    }
2145 
2146 
2147    //=====================================================================================
2148    // Column-major single element reset
2149    //=====================================================================================
2150 
2151    {
2152       test_ = "Column-major reset() function";
2153 
2154       initialize();
2155 
2156       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
2157       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
2158 
2159       reset( sm1(4,4) );
2160       reset( sm2(4,4) );
2161 
2162       checkRows   ( sm1, 16UL );
2163       checkColumns( sm1,  8UL );
2164       checkRows   ( sm2, 16UL );
2165       checkColumns( sm2,  8UL );
2166 
2167       if( sm1 != sm2 || mat1_ != mat2_ ) {
2168          std::ostringstream oss;
2169          oss << " Test: " << test_ << "\n"
2170              << " Error: Reset operation failed\n"
2171              << " Details:\n"
2172              << "   Result:\n" << sm1 << "\n"
2173              << "   Expected result:\n" << sm2 << "\n";
2174          throw std::runtime_error( oss.str() );
2175       }
2176    }
2177 
2178 
2179    //=====================================================================================
2180    // Column-major reset
2181    //=====================================================================================
2182 
2183    {
2184       test_ = "Column-major Submatrix::reset() (lvalue)";
2185 
2186       initialize();
2187 
2188       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
2189       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
2190 
2191       reset( sm1 );
2192       reset( sm2 );
2193 
2194       checkRows   ( sm1, 16UL );
2195       checkColumns( sm1,  8UL );
2196       checkRows   ( sm2, 16UL );
2197       checkColumns( sm2,  8UL );
2198 
2199       if( !isDefault( sm1 ) || !isDefault( sm2 ) || sm1 != sm2 || mat1_ != mat2_ ) {
2200          std::ostringstream oss;
2201          oss << " Test: " << test_ << "\n"
2202              << " Error: Reset operation failed\n"
2203              << " Details:\n"
2204              << "   Result:\n" << sm1 << "\n"
2205              << "   Expected result:\n" << sm2 << "\n";
2206          throw std::runtime_error( oss.str() );
2207       }
2208    }
2209 
2210    {
2211       test_ = "Column-major Submatrix::reset() (rvalue)";
2212 
2213       initialize();
2214 
2215       reset( submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL ) );
2216       reset( submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL ) );
2217 
2218       if( mat1_ != mat2_ ) {
2219          std::ostringstream oss;
2220          oss << " Test: " << test_ << "\n"
2221              << " Error: Reset operation failed\n"
2222              << " Details:\n"
2223              << "   Result:\n" << mat1_ << "\n"
2224              << "   Expected result:\n" << mat2_ << "\n";
2225          throw std::runtime_error( oss.str() );
2226       }
2227    }
2228 
2229 
2230    //=====================================================================================
2231    // Column-major row-wise reset
2232    //=====================================================================================
2233 
2234    {
2235       test_ = "Column-major Submatrix::reset( size_t )";
2236 
2237       initialize();
2238 
2239       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
2240       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
2241 
2242       for( size_t j=0UL; j<sm1.columns(); ++j )
2243       {
2244          reset( sm1, j );
2245          reset( sm2, j );
2246 
2247          if( sm1 != sm2 || mat1_ != mat2_ ) {
2248             std::ostringstream oss;
2249             oss << " Test: " << test_ << "\n"
2250                 << " Error: Reset operation failed\n"
2251                 << " Details:\n"
2252                 << "   Result:\n" << sm1 << "\n"
2253                 << "   Expected result:\n" << sm2 << "\n";
2254             throw std::runtime_error( oss.str() );
2255          }
2256       }
2257    }
2258 }
2259 //*************************************************************************************************
2260 
2261 
2262 //*************************************************************************************************
2263 /*!\brief Test of the \c clear() function with the Submatrix specialization.
2264 //
2265 // \return void
2266 // \exception std::runtime_error Error detected.
2267 //
2268 // This function performs a test of the \c clear() function with the Submatrix specialization.
2269 // In case an error is detected, a \a std::runtime_error exception is thrown.
2270 */
testClear()2271 void DenseAlignedTest::testClear()
2272 {
2273    using blaze::submatrix;
2274    using blaze::aligned;
2275    using blaze::unaligned;
2276    using blaze::clear;
2277 
2278 
2279    //=====================================================================================
2280    // Row-major single element clear
2281    //=====================================================================================
2282 
2283    {
2284       test_ = "Row-major clear() function";
2285 
2286       initialize();
2287 
2288       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
2289       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
2290 
2291       clear( sm1(4,4) );
2292       clear( sm2(4,4) );
2293 
2294       checkRows   ( sm1,  8UL );
2295       checkColumns( sm1, 16UL );
2296       checkRows   ( sm2,  8UL );
2297       checkColumns( sm2, 16UL );
2298 
2299       if( sm1 != sm2 || mat1_ != mat2_ ) {
2300          std::ostringstream oss;
2301          oss << " Test: " << test_ << "\n"
2302              << " Error: Clear operation failed\n"
2303              << " Details:\n"
2304              << "   Result:\n" << sm1 << "\n"
2305              << "   Expected result:\n" << sm2 << "\n";
2306          throw std::runtime_error( oss.str() );
2307       }
2308    }
2309 
2310 
2311    //=====================================================================================
2312    // Row-major clear
2313    //=====================================================================================
2314 
2315    {
2316       test_ = "Row-major clear() function (lvalue)";
2317 
2318       initialize();
2319 
2320       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
2321       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
2322 
2323       clear( sm1 );
2324       clear( sm2 );
2325 
2326       checkRows   ( sm1,  8UL );
2327       checkColumns( sm1, 16UL );
2328       checkRows   ( sm2,  8UL );
2329       checkColumns( sm2, 16UL );
2330 
2331       if( !isDefault( sm1 ) || !isDefault( sm2 ) || sm1 != sm2 || mat1_ != mat2_ ) {
2332          std::ostringstream oss;
2333          oss << " Test: " << test_ << "\n"
2334              << " Error: Clear operation failed\n"
2335              << " Details:\n"
2336              << "   Result:\n" << sm1 << "\n"
2337              << "   Expected result:\n" << sm2 << "\n";
2338          throw std::runtime_error( oss.str() );
2339       }
2340    }
2341 
2342    {
2343       test_ = "Row-major clear() function (rvalue)";
2344 
2345       initialize();
2346 
2347       clear( submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL ) );
2348       clear( submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL ) );
2349 
2350       if( mat1_ != mat2_ ) {
2351          std::ostringstream oss;
2352          oss << " Test: " << test_ << "\n"
2353              << " Error: Clear operation failed\n"
2354              << " Details:\n"
2355              << "   Result:\n" << mat1_ << "\n"
2356              << "   Expected result:\n" << mat2_ << "\n";
2357          throw std::runtime_error( oss.str() );
2358       }
2359    }
2360 
2361 
2362    //=====================================================================================
2363    // Column-major single element clear
2364    //=====================================================================================
2365 
2366    {
2367       test_ = "Column-major clear() function";
2368 
2369       initialize();
2370 
2371       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
2372       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
2373 
2374       clear( sm1(4,4) );
2375       clear( sm2(4,4) );
2376 
2377       checkRows   ( sm1, 16UL );
2378       checkColumns( sm1,  8UL );
2379       checkRows   ( sm2, 16UL );
2380       checkColumns( sm2,  8UL );
2381 
2382       if( sm1 != sm2 || mat1_ != mat2_ ) {
2383          std::ostringstream oss;
2384          oss << " Test: " << test_ << "\n"
2385              << " Error: Clear operation failed\n"
2386              << " Details:\n"
2387              << "   Result:\n" << sm1 << "\n"
2388              << "   Expected result:\n" << sm2 << "\n";
2389          throw std::runtime_error( oss.str() );
2390       }
2391    }
2392 
2393 
2394    //=====================================================================================
2395    // Column-major clear
2396    //=====================================================================================
2397 
2398    {
2399       test_ = "Column-major clear() function (lvalue)";
2400 
2401       initialize();
2402 
2403       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
2404       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
2405 
2406       clear( sm1 );
2407       clear( sm2 );
2408 
2409       checkRows   ( sm1, 16UL );
2410       checkColumns( sm1,  8UL );
2411       checkRows   ( sm2, 16UL );
2412       checkColumns( sm2,  8UL );
2413 
2414       if( !isDefault( sm1 ) || !isDefault( sm2 ) || sm1 != sm2 || mat1_ != mat2_ ) {
2415          std::ostringstream oss;
2416          oss << " Test: " << test_ << "\n"
2417              << " Error: Clear operation failed\n"
2418              << " Details:\n"
2419              << "   Result:\n" << sm1 << "\n"
2420              << "   Expected result:\n" << sm2 << "\n";
2421          throw std::runtime_error( oss.str() );
2422       }
2423    }
2424 
2425    {
2426       test_ = "Column-major clear() function (rvalue)";
2427 
2428       initialize();
2429 
2430       clear( submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL ) );
2431       clear( submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL ) );
2432 
2433       if( mat1_ != mat2_ ) {
2434          std::ostringstream oss;
2435          oss << " Test: " << test_ << "\n"
2436              << " Error: Clear operation failed\n"
2437              << " Details:\n"
2438              << "   Result:\n" << mat1_ << "\n"
2439              << "   Expected result:\n" << mat2_ << "\n";
2440          throw std::runtime_error( oss.str() );
2441       }
2442    }
2443 }
2444 //*************************************************************************************************
2445 
2446 
2447 //*************************************************************************************************
2448 /*!\brief Test of the \c transpose() member function of the Submatrix class template.
2449 //
2450 // \return void
2451 // \exception std::runtime_error Error detected.
2452 //
2453 // This function performs a test of the \c transpose() member function of the Submatrix
2454 // specialization. Additionally, it performs a test of self-transpose via the \c trans()
2455 // function. In case an error is detected, a \a std::runtime_error exception is thrown.
2456 */
testTranspose()2457 void DenseAlignedTest::testTranspose()
2458 {
2459    using blaze::submatrix;
2460    using blaze::aligned;
2461    using blaze::unaligned;
2462 
2463 
2464    //=====================================================================================
2465    // Row-major submatrix tests
2466    //=====================================================================================
2467 
2468    {
2469       test_ = "Row-major self-transpose via transpose()";
2470 
2471       initialize();
2472 
2473       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 8UL );
2474       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 8UL );
2475 
2476       transpose( sm1 );
2477       transpose( sm2 );
2478 
2479       checkRows   ( sm1, 8UL );
2480       checkColumns( sm1, 8UL );
2481       checkRows   ( sm2, 8UL );
2482       checkColumns( sm2, 8UL );
2483 
2484       if( sm1 != sm2 || mat1_ != mat2_ ) {
2485          std::ostringstream oss;
2486          oss << " Test: " << test_ << "\n"
2487              << " Error: Transpose operation failed\n"
2488              << " Details:\n"
2489              << "   Result:\n" << sm1 << "\n"
2490              << "   Expected result:\n" << sm2 << "\n";
2491          throw std::runtime_error( oss.str() );
2492       }
2493    }
2494 
2495    {
2496       test_ = "Row-major self-transpose via trans()";
2497 
2498       initialize();
2499 
2500       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 8UL );
2501       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 8UL );
2502 
2503       sm1 = trans( sm1 );
2504       sm2 = trans( sm2 );
2505 
2506       checkRows   ( sm1, 8UL );
2507       checkColumns( sm1, 8UL );
2508       checkRows   ( sm2, 8UL );
2509       checkColumns( sm2, 8UL );
2510 
2511       if( sm1 != sm2 || mat1_ != mat2_ ) {
2512          std::ostringstream oss;
2513          oss << " Test: " << test_ << "\n"
2514              << " Error: Transpose operation failed\n"
2515              << " Details:\n"
2516              << "   Result:\n" << sm1 << "\n"
2517              << "   Expected result:\n" << sm2 << "\n";
2518          throw std::runtime_error( oss.str() );
2519       }
2520    }
2521 
2522 
2523    //=====================================================================================
2524    // Column-major submatrix tests
2525    //=====================================================================================
2526 
2527    {
2528       test_ = "Column-major self-transpose via transpose()";
2529 
2530       initialize();
2531 
2532       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 8UL, 8UL );
2533       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 8UL, 8UL );
2534 
2535       transpose( sm1 );
2536       transpose( sm2 );
2537 
2538       checkRows   ( sm1, 8UL );
2539       checkColumns( sm1, 8UL );
2540       checkRows   ( sm2, 8UL );
2541       checkColumns( sm2, 8UL );
2542 
2543       if( sm1 != sm2 || mat1_ != mat2_ ) {
2544          std::ostringstream oss;
2545          oss << " Test: " << test_ << "\n"
2546              << " Error: Transpose operation failed\n"
2547              << " Details:\n"
2548              << "   Result:\n" << sm1 << "\n"
2549              << "   Expected result:\n" << sm2 << "\n";
2550          throw std::runtime_error( oss.str() );
2551       }
2552    }
2553 
2554    {
2555       test_ = "Column-major self-transpose via trans()";
2556 
2557       initialize();
2558 
2559       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 8UL, 8UL );
2560       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 8UL, 8UL );
2561 
2562       sm1 = trans( sm1 );
2563       sm2 = trans( sm2 );
2564 
2565       checkRows   ( sm1, 8UL );
2566       checkColumns( sm1, 8UL );
2567       checkRows   ( sm2, 8UL );
2568       checkColumns( sm2, 8UL );
2569 
2570       if( sm1 != sm2 || mat1_ != mat2_ ) {
2571          std::ostringstream oss;
2572          oss << " Test: " << test_ << "\n"
2573              << " Error: Transpose operation failed\n"
2574              << " Details:\n"
2575              << "   Result:\n" << sm1 << "\n"
2576              << "   Expected result:\n" << sm2 << "\n";
2577          throw std::runtime_error( oss.str() );
2578       }
2579    }
2580 }
2581 //*************************************************************************************************
2582 
2583 
2584 //*************************************************************************************************
2585 /*!\brief Test of the \c ctranspose() member function of the Submatrix class template.
2586 //
2587 // \return void
2588 // \exception std::runtime_error Error detected.
2589 //
2590 // This function performs a test of the \c ctranspose() member function of the Submatrix
2591 // class template. Additionally, it performs a test of self-transpose via the \c ctrans()
2592 // function. In case an error is detected, a \a std::runtime_error exception is thrown.
2593 */
testCTranspose()2594 void DenseAlignedTest::testCTranspose()
2595 {
2596    using blaze::submatrix;
2597    using blaze::aligned;
2598    using blaze::unaligned;
2599 
2600 
2601    //=====================================================================================
2602    // Row-major submatrix tests
2603    //=====================================================================================
2604 
2605    {
2606       test_ = "Row-major self-transpose via ctranspose()";
2607 
2608       initialize();
2609 
2610       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 8UL );
2611       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 8UL );
2612 
2613       ctranspose( sm1 );
2614       ctranspose( sm2 );
2615 
2616       checkRows   ( sm1, 8UL );
2617       checkColumns( sm1, 8UL );
2618       checkRows   ( sm2, 8UL );
2619       checkColumns( sm2, 8UL );
2620 
2621       if( sm1 != sm2 || mat1_ != mat2_ ) {
2622          std::ostringstream oss;
2623          oss << " Test: " << test_ << "\n"
2624              << " Error: Transpose operation failed\n"
2625              << " Details:\n"
2626              << "   Result:\n" << sm1 << "\n"
2627              << "   Expected result:\n" << sm2 << "\n";
2628          throw std::runtime_error( oss.str() );
2629       }
2630    }
2631 
2632    {
2633       test_ = "Row-major self-transpose via ctrans()";
2634 
2635       initialize();
2636 
2637       ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 8UL );
2638       USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 8UL );
2639 
2640       sm1 = ctrans( sm1 );
2641       sm2 = ctrans( sm2 );
2642 
2643       checkRows   ( sm1, 8UL );
2644       checkColumns( sm1, 8UL );
2645       checkRows   ( sm2, 8UL );
2646       checkColumns( sm2, 8UL );
2647 
2648       if( sm1 != sm2 || mat1_ != mat2_ ) {
2649          std::ostringstream oss;
2650          oss << " Test: " << test_ << "\n"
2651              << " Error: Transpose operation failed\n"
2652              << " Details:\n"
2653              << "   Result:\n" << sm1 << "\n"
2654              << "   Expected result:\n" << sm2 << "\n";
2655          throw std::runtime_error( oss.str() );
2656       }
2657    }
2658 
2659 
2660    //=====================================================================================
2661    // Column-major submatrix tests
2662    //=====================================================================================
2663 
2664    {
2665       test_ = "Column-major self-transpose via ctranspose()";
2666 
2667       initialize();
2668 
2669       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 8UL, 8UL );
2670       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 8UL, 8UL );
2671 
2672       ctranspose( sm1 );
2673       ctranspose( sm2 );
2674 
2675       checkRows   ( sm1, 8UL );
2676       checkColumns( sm1, 8UL );
2677       checkRows   ( sm2, 8UL );
2678       checkColumns( sm2, 8UL );
2679 
2680       if( sm1 != sm2 || mat1_ != mat2_ ) {
2681          std::ostringstream oss;
2682          oss << " Test: " << test_ << "\n"
2683              << " Error: Transpose operation failed\n"
2684              << " Details:\n"
2685              << "   Result:\n" << sm1 << "\n"
2686              << "   Expected result:\n" << sm2 << "\n";
2687          throw std::runtime_error( oss.str() );
2688       }
2689    }
2690 
2691    {
2692       test_ = "Column-major self-transpose via ctrans()";
2693 
2694       initialize();
2695 
2696       AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 8UL, 8UL );
2697       UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 8UL, 8UL );
2698 
2699       sm1 = ctrans( sm1 );
2700       sm2 = ctrans( sm2 );
2701 
2702       checkRows   ( sm1, 8UL );
2703       checkColumns( sm1, 8UL );
2704       checkRows   ( sm2, 8UL );
2705       checkColumns( sm2, 8UL );
2706 
2707       if( sm1 != sm2 || mat1_ != mat2_ ) {
2708          std::ostringstream oss;
2709          oss << " Test: " << test_ << "\n"
2710              << " Error: Transpose operation failed\n"
2711              << " Details:\n"
2712              << "   Result:\n" << sm1 << "\n"
2713              << "   Expected result:\n" << sm2 << "\n";
2714          throw std::runtime_error( oss.str() );
2715       }
2716    }
2717 }
2718 //*************************************************************************************************
2719 
2720 
2721 //*************************************************************************************************
2722 /*!\brief Test of the \c isDefault() function with the Submatrix class template.
2723 //
2724 // \return void
2725 // \exception std::runtime_error Error detected.
2726 //
2727 // This function performs a test of the \c isDefault() function with the Submatrix
2728 // specialization. In case an error is detected, a \a std::runtime_error exception is thrown.
2729 */
testIsDefault()2730 void DenseAlignedTest::testIsDefault()
2731 {
2732    using blaze::submatrix;
2733    using blaze::aligned;
2734    using blaze::isDefault;
2735 
2736 
2737    //=====================================================================================
2738    // Row-major submatrix tests
2739    //=====================================================================================
2740 
2741    {
2742       test_ = "Row-major isDefault() function";
2743 
2744       initialize();
2745 
2746       // isDefault with default submatrix
2747       {
2748          MT mat( 64UL, 64UL, 0 );
2749          ASMT sm = submatrix<aligned>( mat, 8UL, 16UL, 8UL, 16UL );
2750 
2751          if( isDefault( sm(4,4) ) != true ) {
2752             std::ostringstream oss;
2753             oss << " Test: " << test_ << "\n"
2754                 << " Error: Invalid isDefault evaluation\n"
2755                 << " Details:\n"
2756                 << "   Submatrix element: " << sm(1,1) << "\n";
2757             throw std::runtime_error( oss.str() );
2758          }
2759 
2760          if( isDefault( sm ) != true ) {
2761             std::ostringstream oss;
2762             oss << " Test: " << test_ << "\n"
2763                 << " Error: Invalid isDefault evaluation\n"
2764                 << " Details:\n"
2765                 << "   Submatrix:\n" << sm << "\n";
2766             throw std::runtime_error( oss.str() );
2767          }
2768       }
2769 
2770       // isDefault with non-default submatrix
2771       {
2772          ASMT sm = submatrix<aligned>( mat1_, 8UL, 16UL, 8UL, 16UL );
2773 
2774          if( isDefault( sm ) != false ) {
2775             std::ostringstream oss;
2776             oss << " Test: " << test_ << "\n"
2777                 << " Error: Invalid isDefault evaluation\n"
2778                 << " Details:\n"
2779                 << "   Submatrix:\n" << sm << "\n";
2780             throw std::runtime_error( oss.str() );
2781          }
2782       }
2783    }
2784 
2785 
2786    //=====================================================================================
2787    // Column-major submatrix tests
2788    //=====================================================================================
2789 
2790    {
2791       test_ = "Column-major isDefault() function";
2792 
2793       initialize();
2794 
2795       // isDefault with default submatrix
2796       {
2797          OMT mat( 64UL, 64UL, 0 );
2798          AOSMT sm = submatrix<aligned>( mat, 16UL, 8UL, 16UL, 8UL );
2799 
2800          if( isDefault( sm(4,4) ) != true ) {
2801             std::ostringstream oss;
2802             oss << " Test: " << test_ << "\n"
2803                 << " Error: Invalid isDefault evaluation\n"
2804                 << " Details:\n"
2805                 << "   Submatrix element: " << sm(1,1) << "\n";
2806             throw std::runtime_error( oss.str() );
2807          }
2808 
2809          if( isDefault( sm ) != true ) {
2810             std::ostringstream oss;
2811             oss << " Test: " << test_ << "\n"
2812                 << " Error: Invalid isDefault evaluation\n"
2813                 << " Details:\n"
2814                 << "   Submatrix:\n" << sm << "\n";
2815             throw std::runtime_error( oss.str() );
2816          }
2817       }
2818 
2819       // isDefault with non-default submatrix
2820       {
2821          AOSMT sm = submatrix<aligned>( tmat1_, 16UL, 8UL, 16UL, 8UL );
2822 
2823          if( isDefault( sm ) != false ) {
2824             std::ostringstream oss;
2825             oss << " Test: " << test_ << "\n"
2826                 << " Error: Invalid isDefault evaluation\n"
2827                 << " Details:\n"
2828                 << "   Submatrix:\n" << sm << "\n";
2829             throw std::runtime_error( oss.str() );
2830          }
2831       }
2832    }
2833 }
2834 //*************************************************************************************************
2835 
2836 
2837 //*************************************************************************************************
2838 /*!\brief Test of the \c isSame() function with the Submatrix class template.
2839 //
2840 // \return void
2841 // \exception std::runtime_error Error detected.
2842 //
2843 // This function performs a test of the \c isSame() function with the Submatrix specialization.
2844 // In case an error is detected, a \a std::runtime_error exception is thrown.
2845 */
testIsSame()2846 void DenseAlignedTest::testIsSame()
2847 {
2848    using blaze::submatrix;
2849    using blaze::aligned;
2850 
2851 
2852    //=====================================================================================
2853    // Row-major matrix-based tests
2854    //=====================================================================================
2855 
2856    {
2857       test_ = "Row-major isSame() function (matrix-based)";
2858 
2859       // isSame with matrix and matching submatrix
2860       {
2861          ASMT sm = submatrix<aligned>( mat1_, 0UL, 0UL, 64UL, 64UL );
2862 
2863          if( blaze::isSame( sm, mat1_ ) == false ) {
2864             std::ostringstream oss;
2865             oss << " Test: " << test_ << "\n"
2866                 << " Error: Invalid isSame evaluation\n"
2867                 << " Details:\n"
2868                 << "   Matrix:\n" << mat1_ << "\n"
2869                 << "   Submatrix:\n" << sm << "\n";
2870             throw std::runtime_error( oss.str() );
2871          }
2872 
2873          if( blaze::isSame( mat1_, sm ) == false ) {
2874             std::ostringstream oss;
2875             oss << " Test: " << test_ << "\n"
2876                 << " Error: Invalid isSame evaluation\n"
2877                 << " Details:\n"
2878                 << "   Matrix:\n" << mat1_ << "\n"
2879                 << "   Submatrix:\n" << sm << "\n";
2880             throw std::runtime_error( oss.str() );
2881          }
2882       }
2883 
2884       // isSame with matrix and non-matching submatrix (different number of rows)
2885       {
2886          ASMT sm = submatrix<aligned>( mat1_, 0UL, 0UL, 32UL, 64UL );
2887 
2888          if( blaze::isSame( sm, mat1_ ) == true ) {
2889             std::ostringstream oss;
2890             oss << " Test: " << test_ << "\n"
2891                 << " Error: Invalid isSame evaluation\n"
2892                 << " Details:\n"
2893                 << "   Matrix:\n" << mat1_ << "\n"
2894                 << "   Submatrix:\n" << sm << "\n";
2895             throw std::runtime_error( oss.str() );
2896          }
2897 
2898          if( blaze::isSame( mat1_, sm ) == true ) {
2899             std::ostringstream oss;
2900             oss << " Test: " << test_ << "\n"
2901                 << " Error: Invalid isSame evaluation\n"
2902                 << " Details:\n"
2903                 << "   Matrix:\n" << mat1_ << "\n"
2904                 << "   Submatrix:\n" << sm << "\n";
2905             throw std::runtime_error( oss.str() );
2906          }
2907       }
2908 
2909       // isSame with matrix and non-matching submatrix (different number of columns)
2910       {
2911          ASMT sm = submatrix<aligned>( mat1_, 0UL, 0UL, 64UL, 32UL );
2912 
2913          if( blaze::isSame( sm, mat1_ ) == true ) {
2914             std::ostringstream oss;
2915             oss << " Test: " << test_ << "\n"
2916                 << " Error: Invalid isSame evaluation\n"
2917                 << " Details:\n"
2918                 << "   Matrix:\n" << mat1_ << "\n"
2919                 << "   Submatrix:\n" << sm << "\n";
2920             throw std::runtime_error( oss.str() );
2921          }
2922 
2923          if( blaze::isSame( mat1_, sm ) == true ) {
2924             std::ostringstream oss;
2925             oss << " Test: " << test_ << "\n"
2926                 << " Error: Invalid isSame evaluation\n"
2927                 << " Details:\n"
2928                 << "   Matrix:\n" << mat1_ << "\n"
2929                 << "   Submatrix:\n" << sm << "\n";
2930             throw std::runtime_error( oss.str() );
2931          }
2932       }
2933 
2934       // isSame with matrix and non-matching submatrix (different row index)
2935       {
2936          ASMT sm = submatrix<aligned>( mat1_, 16UL, 0UL, 48UL, 64UL );
2937 
2938          if( blaze::isSame( sm, mat1_ ) == true ) {
2939             std::ostringstream oss;
2940             oss << " Test: " << test_ << "\n"
2941                 << " Error: Invalid isSame evaluation\n"
2942                 << " Details:\n"
2943                 << "   Matrix:\n" << mat1_ << "\n"
2944                 << "   Submatrix:\n" << sm << "\n";
2945             throw std::runtime_error( oss.str() );
2946          }
2947 
2948          if( blaze::isSame( mat1_, sm ) == true ) {
2949             std::ostringstream oss;
2950             oss << " Test: " << test_ << "\n"
2951                 << " Error: Invalid isSame evaluation\n"
2952                 << " Details:\n"
2953                 << "   Matrix:\n" << mat1_ << "\n"
2954                 << "   Submatrix:\n" << sm << "\n";
2955             throw std::runtime_error( oss.str() );
2956          }
2957       }
2958 
2959       // isSame with matrix and non-matching submatrix (different column index)
2960       {
2961          ASMT sm = submatrix<aligned>( mat1_, 0UL, 16UL, 64UL, 48UL );
2962 
2963          if( blaze::isSame( sm, mat1_ ) == true ) {
2964             std::ostringstream oss;
2965             oss << " Test: " << test_ << "\n"
2966                 << " Error: Invalid isSame evaluation\n"
2967                 << " Details:\n"
2968                 << "   Matrix:\n" << mat1_ << "\n"
2969                 << "   Submatrix:\n" << sm << "\n";
2970             throw std::runtime_error( oss.str() );
2971          }
2972 
2973          if( blaze::isSame( mat1_, sm ) == true ) {
2974             std::ostringstream oss;
2975             oss << " Test: " << test_ << "\n"
2976                 << " Error: Invalid isSame evaluation\n"
2977                 << " Details:\n"
2978                 << "   Matrix:\n" << mat1_ << "\n"
2979                 << "   Submatrix:\n" << sm << "\n";
2980             throw std::runtime_error( oss.str() );
2981          }
2982       }
2983 
2984       // isSame with matching submatrices
2985       {
2986          ASMT sm1 = submatrix<aligned>( mat1_, 16UL, 0UL, 32UL, 16UL );
2987          ASMT sm2 = submatrix<aligned>( mat1_, 16UL, 0UL, 32UL, 16UL );
2988 
2989          if( blaze::isSame( sm1, sm2 ) == false ) {
2990             std::ostringstream oss;
2991             oss << " Test: " << test_ << "\n"
2992                 << " Error: Invalid isSame evaluation\n"
2993                 << " Details:\n"
2994                 << "   First submatrix:\n" << sm1 << "\n"
2995                 << "   Second submatrix:\n" << sm2 << "\n";
2996             throw std::runtime_error( oss.str() );
2997          }
2998       }
2999 
3000       // isSame with non-matching submatrices (different number of rows)
3001       {
3002          ASMT sm1 = submatrix<aligned>( mat1_, 16UL, 0UL, 32UL, 16UL );
3003          ASMT sm2 = submatrix<aligned>( mat1_, 16UL, 0UL, 16UL, 16UL );
3004 
3005          if( blaze::isSame( sm1, sm2 ) == true ) {
3006             std::ostringstream oss;
3007             oss << " Test: " << test_ << "\n"
3008                 << " Error: Invalid isSame evaluation\n"
3009                 << " Details:\n"
3010                 << "   First submatrix:\n" << sm1 << "\n"
3011                 << "   Second submatrix:\n" << sm2 << "\n";
3012             throw std::runtime_error( oss.str() );
3013          }
3014       }
3015 
3016       // isSame with non-matching submatrices (different number of columns)
3017       {
3018          ASMT sm1 = submatrix<aligned>( mat1_, 16UL, 0UL, 32UL, 16UL );
3019          ASMT sm2 = submatrix<aligned>( mat1_, 16UL, 0UL, 32UL, 32UL );
3020 
3021          if( blaze::isSame( sm1, sm2 ) == true ) {
3022             std::ostringstream oss;
3023             oss << " Test: " << test_ << "\n"
3024                 << " Error: Invalid isSame evaluation\n"
3025                 << " Details:\n"
3026                 << "   First submatrix:\n" << sm1 << "\n"
3027                 << "   Second submatrix:\n" << sm2 << "\n";
3028             throw std::runtime_error( oss.str() );
3029          }
3030       }
3031 
3032       // isSame with non-matching submatrices (different row index)
3033       {
3034          ASMT sm1 = submatrix<aligned>( mat1_, 16UL, 0UL, 32UL, 16UL );
3035          ASMT sm2 = submatrix<aligned>( mat1_, 32UL, 0UL, 32UL, 16UL );
3036 
3037          if( blaze::isSame( sm1, sm2 ) == true ) {
3038             std::ostringstream oss;
3039             oss << " Test: " << test_ << "\n"
3040                 << " Error: Invalid isSame evaluation\n"
3041                 << " Details:\n"
3042                 << "   First submatrix:\n" << sm1 << "\n"
3043                 << "   Second submatrix:\n" << sm2 << "\n";
3044             throw std::runtime_error( oss.str() );
3045          }
3046       }
3047 
3048       // isSame with non-matching submatrices (different column index)
3049       {
3050          ASMT sm1 = submatrix<aligned>( mat1_, 16UL,  0UL, 32UL, 16UL );
3051          ASMT sm2 = submatrix<aligned>( mat1_, 16UL, 16UL, 32UL, 16UL );
3052 
3053          if( blaze::isSame( sm1, sm2 ) == true ) {
3054             std::ostringstream oss;
3055             oss << " Test: " << test_ << "\n"
3056                 << " Error: Invalid isSame evaluation\n"
3057                 << " Details:\n"
3058                 << "   First submatrix:\n" << sm1 << "\n"
3059                 << "   Second submatrix:\n" << sm2 << "\n";
3060             throw std::runtime_error( oss.str() );
3061          }
3062       }
3063    }
3064 
3065 
3066    //=====================================================================================
3067    // Row-major rows-based tests
3068    //=====================================================================================
3069 
3070    {
3071       test_ = "Row-major isSame() function (rows-based)";
3072 
3073       // isSame with row selection and matching submatrix
3074       {
3075          auto rs = blaze::rows( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3076          auto sm = submatrix<aligned>( rs, 0UL, 0UL, 4UL, 64UL );
3077 
3078          if( blaze::isSame( sm, rs ) == false ) {
3079             std::ostringstream oss;
3080             oss << " Test: " << test_ << "\n"
3081                 << " Error: Invalid isSame evaluation\n"
3082                 << " Details:\n"
3083                 << "   Row selection:\n" << rs << "\n"
3084                 << "   Submatrix:\n" << sm << "\n";
3085             throw std::runtime_error( oss.str() );
3086          }
3087 
3088          if( blaze::isSame( rs, sm ) == false ) {
3089             std::ostringstream oss;
3090             oss << " Test: " << test_ << "\n"
3091                 << " Error: Invalid isSame evaluation\n"
3092                 << " Details:\n"
3093                 << "   Row selection:\n" << rs << "\n"
3094                 << "   Submatrix:\n" << sm << "\n";
3095             throw std::runtime_error( oss.str() );
3096          }
3097       }
3098 
3099       // isSame with row selection and non-matching submatrix (different number of rows)
3100       {
3101          auto rs = blaze::rows( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3102          auto sm = submatrix<aligned>( rs, 0UL, 0UL, 3UL, 64UL );
3103 
3104          if( blaze::isSame( sm, rs ) == true ) {
3105             std::ostringstream oss;
3106             oss << " Test: " << test_ << "\n"
3107                 << " Error: Invalid isSame evaluation\n"
3108                 << " Details:\n"
3109                 << "   Row selection:\n" << rs << "\n"
3110                 << "   Submatrix:\n" << sm << "\n";
3111             throw std::runtime_error( oss.str() );
3112          }
3113 
3114          if( blaze::isSame( rs, sm ) == true ) {
3115             std::ostringstream oss;
3116             oss << " Test: " << test_ << "\n"
3117                 << " Error: Invalid isSame evaluation\n"
3118                 << " Details:\n"
3119                 << "   Row selection:\n" << rs << "\n"
3120                 << "   Submatrix:\n" << sm << "\n";
3121             throw std::runtime_error( oss.str() );
3122          }
3123       }
3124 
3125       // isSame with row selection and non-matching submatrix (different number of columns)
3126       {
3127          auto rs = blaze::rows( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3128          auto sm = submatrix<aligned>( rs, 0UL, 0UL, 4UL, 32UL );
3129 
3130          if( blaze::isSame( sm, rs ) == true ) {
3131             std::ostringstream oss;
3132             oss << " Test: " << test_ << "\n"
3133                 << " Error: Invalid isSame evaluation\n"
3134                 << " Details:\n"
3135                 << "   Row selection:\n" << rs << "\n"
3136                 << "   Submatrix:\n" << sm << "\n";
3137             throw std::runtime_error( oss.str() );
3138          }
3139 
3140          if( blaze::isSame( rs, sm ) == true ) {
3141             std::ostringstream oss;
3142             oss << " Test: " << test_ << "\n"
3143                 << " Error: Invalid isSame evaluation\n"
3144                 << " Details:\n"
3145                 << "   Row selection:\n" << rs << "\n"
3146                 << "   Submatrix:\n" << sm << "\n";
3147             throw std::runtime_error( oss.str() );
3148          }
3149       }
3150 
3151       // isSame with row selection and non-matching submatrix (different row index)
3152       {
3153          auto rs = blaze::rows( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3154          auto sm = submatrix<aligned>( rs, 1UL, 0UL, 3UL, 64UL );
3155 
3156          if( blaze::isSame( sm, rs ) == true ) {
3157             std::ostringstream oss;
3158             oss << " Test: " << test_ << "\n"
3159                 << " Error: Invalid isSame evaluation\n"
3160                 << " Details:\n"
3161                 << "   Row selection:\n" << rs << "\n"
3162                 << "   Submatrix:\n" << sm << "\n";
3163             throw std::runtime_error( oss.str() );
3164          }
3165 
3166          if( blaze::isSame( rs, sm ) == true ) {
3167             std::ostringstream oss;
3168             oss << " Test: " << test_ << "\n"
3169                 << " Error: Invalid isSame evaluation\n"
3170                 << " Details:\n"
3171                 << "   Row selection:\n" << rs << "\n"
3172                 << "   Submatrix:\n" << sm << "\n";
3173             throw std::runtime_error( oss.str() );
3174          }
3175       }
3176 
3177       // isSame with row selection and non-matching submatrix (different column index)
3178       {
3179          auto rs = blaze::rows( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3180          auto sm = submatrix<aligned>( rs, 0UL, 16UL, 4UL, 48UL );
3181 
3182          if( blaze::isSame( sm, rs ) == true ) {
3183             std::ostringstream oss;
3184             oss << " Test: " << test_ << "\n"
3185                 << " Error: Invalid isSame evaluation\n"
3186                 << " Details:\n"
3187                 << "   Row selection:\n" << rs << "\n"
3188                 << "   Submatrix:\n" << sm << "\n";
3189             throw std::runtime_error( oss.str() );
3190          }
3191 
3192          if( blaze::isSame( rs, sm ) == true ) {
3193             std::ostringstream oss;
3194             oss << " Test: " << test_ << "\n"
3195                 << " Error: Invalid isSame evaluation\n"
3196                 << " Details:\n"
3197                 << "   Row selection:\n" << rs << "\n"
3198                 << "   Submatrix:\n" << sm << "\n";
3199             throw std::runtime_error( oss.str() );
3200          }
3201       }
3202 
3203       // isSame with matching submatrices
3204       {
3205          auto rs  = blaze::rows( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3206          auto sm1 = submatrix<aligned>( rs, 0UL, 0UL, 3UL, 32UL );
3207          auto sm2 = submatrix<aligned>( rs, 0UL, 0UL, 3UL, 32UL );
3208 
3209          if( blaze::isSame( sm1, sm2 ) == false ) {
3210             std::ostringstream oss;
3211             oss << " Test: " << test_ << "\n"
3212                 << " Error: Invalid isSame evaluation\n"
3213                 << " Details:\n"
3214                 << "   First submatrix:\n" << sm1 << "\n"
3215                 << "   Second submatrix:\n" << sm2 << "\n";
3216             throw std::runtime_error( oss.str() );
3217          }
3218       }
3219 
3220       // isSame with non-matching submatrices (different number of rows)
3221       {
3222          auto rs  = blaze::rows( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3223          auto sm1 = submatrix<aligned>( rs, 0UL, 0UL, 3UL, 32UL );
3224          auto sm2 = submatrix<aligned>( rs, 0UL, 0UL, 2UL, 32UL );
3225 
3226          if( blaze::isSame( sm1, sm2 ) == true ) {
3227             std::ostringstream oss;
3228             oss << " Test: " << test_ << "\n"
3229                 << " Error: Invalid isSame evaluation\n"
3230                 << " Details:\n"
3231                 << "   First submatrix:\n" << sm1 << "\n"
3232                 << "   Second submatrix:\n" << sm2 << "\n";
3233             throw std::runtime_error( oss.str() );
3234          }
3235       }
3236 
3237       // isSame with non-matching submatrices (different number of columns)
3238       {
3239          auto rs  = blaze::rows( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3240          auto sm1 = submatrix<aligned>( rs, 0UL, 0UL, 3UL, 32UL );
3241          auto sm2 = submatrix<aligned>( rs, 0UL, 0UL, 3UL, 48UL );
3242 
3243          if( blaze::isSame( sm1, sm2 ) == true ) {
3244             std::ostringstream oss;
3245             oss << " Test: " << test_ << "\n"
3246                 << " Error: Invalid isSame evaluation\n"
3247                 << " Details:\n"
3248                 << "   First submatrix:\n" << sm1 << "\n"
3249                 << "   Second submatrix:\n" << sm2 << "\n";
3250             throw std::runtime_error( oss.str() );
3251          }
3252       }
3253 
3254       // isSame with non-matching submatrices (different row index)
3255       {
3256          auto rs  = blaze::rows( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3257          auto sm1 = submatrix<aligned>( rs, 0UL, 0UL, 3UL, 32UL );
3258          auto sm2 = submatrix<aligned>( rs, 1UL, 0UL, 3UL, 32UL );
3259 
3260          if( blaze::isSame( sm1, sm2 ) == true ) {
3261             std::ostringstream oss;
3262             oss << " Test: " << test_ << "\n"
3263                 << " Error: Invalid isSame evaluation\n"
3264                 << " Details:\n"
3265                 << "   First submatrix:\n" << sm1 << "\n"
3266                 << "   Second submatrix:\n" << sm2 << "\n";
3267             throw std::runtime_error( oss.str() );
3268          }
3269       }
3270 
3271       // isSame with non-matching submatrices (different column index)
3272       {
3273          auto rs  = blaze::rows( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3274          auto sm1 = submatrix<aligned>( rs, 0UL,  0UL, 3UL, 32UL );
3275          auto sm2 = submatrix<aligned>( rs, 0UL, 16UL, 3UL, 32UL );
3276 
3277          if( blaze::isSame( sm1, sm2 ) == true ) {
3278             std::ostringstream oss;
3279             oss << " Test: " << test_ << "\n"
3280                 << " Error: Invalid isSame evaluation\n"
3281                 << " Details:\n"
3282                 << "   First submatrix:\n" << sm1 << "\n"
3283                 << "   Second submatrix:\n" << sm2 << "\n";
3284             throw std::runtime_error( oss.str() );
3285          }
3286       }
3287    }
3288 
3289 
3290    //=====================================================================================
3291    // Row-major columns-based tests
3292    //=====================================================================================
3293 
3294    {
3295       test_ = "Row-major isSame() function (columns-based)";
3296 
3297       // isSame with column selection and matching submatrix
3298       {
3299          auto cs = blaze::columns( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3300          auto sm = submatrix<aligned>( cs, 0UL, 0UL, 64UL, 4UL );
3301 
3302          if( blaze::isSame( sm, cs ) == false ) {
3303             std::ostringstream oss;
3304             oss << " Test: " << test_ << "\n"
3305                 << " Error: Invalid isSame evaluation\n"
3306                 << " Details:\n"
3307                 << "   Column selection:\n" << cs << "\n"
3308                 << "   Submatrix:\n" << sm << "\n";
3309             throw std::runtime_error( oss.str() );
3310          }
3311 
3312          if( blaze::isSame( cs, sm ) == false ) {
3313             std::ostringstream oss;
3314             oss << " Test: " << test_ << "\n"
3315                 << " Error: Invalid isSame evaluation\n"
3316                 << " Details:\n"
3317                 << "   Column selection:\n" << cs << "\n"
3318                 << "   Submatrix:\n" << sm << "\n";
3319             throw std::runtime_error( oss.str() );
3320          }
3321       }
3322 
3323       // isSame with column selection and non-matching submatrix (different number of rows)
3324       {
3325          auto cs = blaze::columns( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3326          auto sm = submatrix<aligned>( cs, 0UL, 0UL, 32UL, 4UL );
3327 
3328          if( blaze::isSame( sm, cs ) == true ) {
3329             std::ostringstream oss;
3330             oss << " Test: " << test_ << "\n"
3331                 << " Error: Invalid isSame evaluation\n"
3332                 << " Details:\n"
3333                 << "   Column selection:\n" << cs << "\n"
3334                 << "   Submatrix:\n" << sm << "\n";
3335             throw std::runtime_error( oss.str() );
3336          }
3337 
3338          if( blaze::isSame( cs, sm ) == true ) {
3339             std::ostringstream oss;
3340             oss << " Test: " << test_ << "\n"
3341                 << " Error: Invalid isSame evaluation\n"
3342                 << " Details:\n"
3343                 << "   Column selection:\n" << cs << "\n"
3344                 << "   Submatrix:\n" << sm << "\n";
3345             throw std::runtime_error( oss.str() );
3346          }
3347       }
3348 
3349       // isSame with column selection and non-matching submatrix (different number of columns)
3350       {
3351          auto cs = blaze::columns( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3352          auto sm = submatrix<aligned>( cs, 0UL, 0UL, 64UL, 3UL );
3353 
3354          if( blaze::isSame( sm, cs ) == true ) {
3355             std::ostringstream oss;
3356             oss << " Test: " << test_ << "\n"
3357                 << " Error: Invalid isSame evaluation\n"
3358                 << " Details:\n"
3359                 << "   Column selection:\n" << cs << "\n"
3360                 << "   Submatrix:\n" << sm << "\n";
3361             throw std::runtime_error( oss.str() );
3362          }
3363 
3364          if( blaze::isSame( cs, sm ) == true ) {
3365             std::ostringstream oss;
3366             oss << " Test: " << test_ << "\n"
3367                 << " Error: Invalid isSame evaluation\n"
3368                 << " Details:\n"
3369                 << "   Column selection:\n" << cs << "\n"
3370                 << "   Submatrix:\n" << sm << "\n";
3371             throw std::runtime_error( oss.str() );
3372          }
3373       }
3374 
3375       // isSame with column selection and non-matching submatrix (different row index)
3376       {
3377          auto cs = blaze::columns( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3378          auto sm = submatrix<aligned>( cs, 16UL, 0UL, 48UL, 4UL );
3379 
3380          if( blaze::isSame( sm, cs ) == true ) {
3381             std::ostringstream oss;
3382             oss << " Test: " << test_ << "\n"
3383                 << " Error: Invalid isSame evaluation\n"
3384                 << " Details:\n"
3385                 << "   Column selection:\n" << cs << "\n"
3386                 << "   Submatrix:\n" << sm << "\n";
3387             throw std::runtime_error( oss.str() );
3388          }
3389 
3390          if( blaze::isSame( cs, sm ) == true ) {
3391             std::ostringstream oss;
3392             oss << " Test: " << test_ << "\n"
3393                 << " Error: Invalid isSame evaluation\n"
3394                 << " Details:\n"
3395                 << "   Column selection:\n" << cs << "\n"
3396                 << "   Submatrix:\n" << sm << "\n";
3397             throw std::runtime_error( oss.str() );
3398          }
3399       }
3400 
3401       // isSame with column selection and non-matching submatrix (different column index)
3402       {
3403          auto cs = blaze::columns( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3404          auto sm = submatrix<aligned>( cs, 0UL, 1UL, 64UL, 3UL );
3405 
3406          if( blaze::isSame( sm, cs ) == true ) {
3407             std::ostringstream oss;
3408             oss << " Test: " << test_ << "\n"
3409                 << " Error: Invalid isSame evaluation\n"
3410                 << " Details:\n"
3411                 << "   Column selection:\n" << cs << "\n"
3412                 << "   Submatrix:\n" << sm << "\n";
3413             throw std::runtime_error( oss.str() );
3414          }
3415 
3416          if( blaze::isSame( cs, sm ) == true ) {
3417             std::ostringstream oss;
3418             oss << " Test: " << test_ << "\n"
3419                 << " Error: Invalid isSame evaluation\n"
3420                 << " Details:\n"
3421                 << "   Column selection:\n" << cs << "\n"
3422                 << "   Submatrix:\n" << sm << "\n";
3423             throw std::runtime_error( oss.str() );
3424          }
3425       }
3426 
3427       // isSame with matching submatrices
3428       {
3429          auto cs  = blaze::columns( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3430          auto sm1 = submatrix<aligned>( cs, 0UL, 0UL, 32UL, 3UL );
3431          auto sm2 = submatrix<aligned>( cs, 0UL, 0UL, 32UL, 3UL );
3432 
3433          if( blaze::isSame( sm1, sm2 ) == false ) {
3434             std::ostringstream oss;
3435             oss << " Test: " << test_ << "\n"
3436                 << " Error: Invalid isSame evaluation\n"
3437                 << " Details:\n"
3438                 << "   First submatrix:\n" << sm1 << "\n"
3439                 << "   Second submatrix:\n" << sm2 << "\n";
3440             throw std::runtime_error( oss.str() );
3441          }
3442       }
3443 
3444       // isSame with non-matching submatrices (different number of rows)
3445       {
3446          auto cs  = blaze::columns( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3447          auto sm1 = submatrix<aligned>( cs, 0UL, 0UL, 32UL, 3UL );
3448          auto sm2 = submatrix<aligned>( cs, 0UL, 0UL, 48UL, 3UL );
3449 
3450          if( blaze::isSame( sm1, sm2 ) == true ) {
3451             std::ostringstream oss;
3452             oss << " Test: " << test_ << "\n"
3453                 << " Error: Invalid isSame evaluation\n"
3454                 << " Details:\n"
3455                 << "   First submatrix:\n" << sm1 << "\n"
3456                 << "   Second submatrix:\n" << sm2 << "\n";
3457             throw std::runtime_error( oss.str() );
3458          }
3459       }
3460 
3461       // isSame with non-matching submatrices (different number of columns)
3462       {
3463          auto cs  = blaze::columns( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3464          auto sm1 = submatrix<aligned>( cs, 0UL, 0UL, 32UL, 3UL );
3465          auto sm2 = submatrix<aligned>( cs, 0UL, 0UL, 32UL, 2UL );
3466 
3467          if( blaze::isSame( sm1, sm2 ) == true ) {
3468             std::ostringstream oss;
3469             oss << " Test: " << test_ << "\n"
3470                 << " Error: Invalid isSame evaluation\n"
3471                 << " Details:\n"
3472                 << "   First submatrix:\n" << sm1 << "\n"
3473                 << "   Second submatrix:\n" << sm2 << "\n";
3474             throw std::runtime_error( oss.str() );
3475          }
3476       }
3477 
3478       // isSame with non-matching submatrices (different row index)
3479       {
3480          auto cs  = blaze::columns( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3481          auto sm1 = submatrix<aligned>( cs,  0UL, 0UL, 32UL, 3UL );
3482          auto sm2 = submatrix<aligned>( cs, 16UL, 0UL, 32UL, 3UL );
3483 
3484          if( blaze::isSame( sm1, sm2 ) == true ) {
3485             std::ostringstream oss;
3486             oss << " Test: " << test_ << "\n"
3487                 << " Error: Invalid isSame evaluation\n"
3488                 << " Details:\n"
3489                 << "   First submatrix:\n" << sm1 << "\n"
3490                 << "   Second submatrix:\n" << sm2 << "\n";
3491             throw std::runtime_error( oss.str() );
3492          }
3493       }
3494 
3495       // isSame with non-matching submatrices (different column index)
3496       {
3497          auto cs  = blaze::columns( mat1_, { 0UL, 16UL, 32UL, 48UL } );
3498          auto sm1 = submatrix<aligned>( cs, 0UL, 0UL, 32UL, 3UL );
3499          auto sm2 = submatrix<aligned>( cs, 0UL, 1UL, 32UL, 3UL );
3500 
3501          if( blaze::isSame( sm1, sm2 ) == true ) {
3502             std::ostringstream oss;
3503             oss << " Test: " << test_ << "\n"
3504                 << " Error: Invalid isSame evaluation\n"
3505                 << " Details:\n"
3506                 << "   First submatrix:\n" << sm1 << "\n"
3507                 << "   Second submatrix:\n" << sm2 << "\n";
3508             throw std::runtime_error( oss.str() );
3509          }
3510       }
3511    }
3512 
3513 
3514    //=====================================================================================
3515    // Column-major matrix-based tests
3516    //=====================================================================================
3517 
3518    {
3519       test_ = "Column-major isSame() function (matrix-based)";
3520 
3521       // isSame with matrix and matching submatrix
3522       {
3523          AOSMT sm = submatrix<aligned>( tmat1_, 0UL, 0UL, 64UL, 64UL );
3524 
3525          if( blaze::isSame( sm, tmat1_ ) == false ) {
3526             std::ostringstream oss;
3527             oss << " Test: " << test_ << "\n"
3528                 << " Error: Invalid isSame evaluation\n"
3529                 << " Details:\n"
3530                 << "   Matrix:\n" << tmat1_ << "\n"
3531                 << "   Submatrix:\n" << sm << "\n";
3532             throw std::runtime_error( oss.str() );
3533          }
3534 
3535          if( blaze::isSame( tmat1_, sm ) == false ) {
3536             std::ostringstream oss;
3537             oss << " Test: " << test_ << "\n"
3538                 << " Error: Invalid isSame evaluation\n"
3539                 << " Details:\n"
3540                 << "   Matrix:\n" << tmat1_ << "\n"
3541                 << "   Submatrix:\n" << sm << "\n";
3542             throw std::runtime_error( oss.str() );
3543          }
3544       }
3545 
3546       // isSame with matrix and non-matching submatrix (different number of rows)
3547       {
3548          AOSMT sm = submatrix<aligned>( tmat1_, 0UL, 0UL, 32UL, 64UL );
3549 
3550          if( blaze::isSame( sm, tmat1_ ) == true ) {
3551             std::ostringstream oss;
3552             oss << " Test: " << test_ << "\n"
3553                 << " Error: Invalid isSame evaluation\n"
3554                 << " Details:\n"
3555                 << "   Matrix:\n" << tmat1_ << "\n"
3556                 << "   Submatrix:\n" << sm << "\n";
3557             throw std::runtime_error( oss.str() );
3558          }
3559 
3560          if( blaze::isSame( tmat1_, sm ) == true ) {
3561             std::ostringstream oss;
3562             oss << " Test: " << test_ << "\n"
3563                 << " Error: Invalid isSame evaluation\n"
3564                 << " Details:\n"
3565                 << "   Matrix:\n" << tmat1_ << "\n"
3566                 << "   Submatrix:\n" << sm << "\n";
3567             throw std::runtime_error( oss.str() );
3568          }
3569       }
3570 
3571       // isSame with matrix and non-matching submatrix (different number of columns)
3572       {
3573          AOSMT sm = submatrix<aligned>( tmat1_, 0UL, 0UL, 64UL, 32UL );
3574 
3575          if( blaze::isSame( sm, tmat1_ ) == true ) {
3576             std::ostringstream oss;
3577             oss << " Test: " << test_ << "\n"
3578                 << " Error: Invalid isSame evaluation\n"
3579                 << " Details:\n"
3580                 << "   Matrix:\n" << tmat1_ << "\n"
3581                 << "   Submatrix:\n" << sm << "\n";
3582             throw std::runtime_error( oss.str() );
3583          }
3584 
3585          if( blaze::isSame( tmat1_, sm ) == true ) {
3586             std::ostringstream oss;
3587             oss << " Test: " << test_ << "\n"
3588                 << " Error: Invalid isSame evaluation\n"
3589                 << " Details:\n"
3590                 << "   Matrix:\n" << tmat1_ << "\n"
3591                 << "   Submatrix:\n" << sm << "\n";
3592             throw std::runtime_error( oss.str() );
3593          }
3594       }
3595 
3596       // isSame with matrix and non-matching submatrix (different row index)
3597       {
3598          AOSMT sm = submatrix<aligned>( tmat1_, 16UL, 0UL, 48UL, 64UL );
3599 
3600          if( blaze::isSame( sm, tmat1_ ) == true ) {
3601             std::ostringstream oss;
3602             oss << " Test: " << test_ << "\n"
3603                 << " Error: Invalid isSame evaluation\n"
3604                 << " Details:\n"
3605                 << "   Matrix:\n" << tmat1_ << "\n"
3606                 << "   Submatrix:\n" << sm << "\n";
3607             throw std::runtime_error( oss.str() );
3608          }
3609 
3610          if( blaze::isSame( tmat1_, sm ) == true ) {
3611             std::ostringstream oss;
3612             oss << " Test: " << test_ << "\n"
3613                 << " Error: Invalid isSame evaluation\n"
3614                 << " Details:\n"
3615                 << "   Matrix:\n" << tmat1_ << "\n"
3616                 << "   Submatrix:\n" << sm << "\n";
3617             throw std::runtime_error( oss.str() );
3618          }
3619       }
3620 
3621       // isSame with matrix and non-matching submatrix (different column index)
3622       {
3623          AOSMT sm = submatrix<aligned>( tmat1_, 0UL, 16UL, 64UL, 48UL );
3624 
3625          if( blaze::isSame( sm, tmat1_ ) == true ) {
3626             std::ostringstream oss;
3627             oss << " Test: " << test_ << "\n"
3628                 << " Error: Invalid isSame evaluation\n"
3629                 << " Details:\n"
3630                 << "   Matrix:\n" << tmat1_ << "\n"
3631                 << "   Submatrix:\n" << sm << "\n";
3632             throw std::runtime_error( oss.str() );
3633          }
3634 
3635          if( blaze::isSame( tmat1_, sm ) == true ) {
3636             std::ostringstream oss;
3637             oss << " Test: " << test_ << "\n"
3638                 << " Error: Invalid isSame evaluation\n"
3639                 << " Details:\n"
3640                 << "   Matrix:\n" << tmat1_ << "\n"
3641                 << "   Submatrix:\n" << sm << "\n";
3642             throw std::runtime_error( oss.str() );
3643          }
3644       }
3645 
3646       // isSame with matching submatrices
3647       {
3648          AOSMT sm1 = submatrix<aligned>( tmat1_, 16UL, 0UL, 32UL, 16UL );
3649          AOSMT sm2 = submatrix<aligned>( tmat1_, 16UL, 0UL, 32UL, 16UL );
3650 
3651          if( blaze::isSame( sm1, sm2 ) == false ) {
3652             std::ostringstream oss;
3653             oss << " Test: " << test_ << "\n"
3654                 << " Error: Invalid isSame evaluation\n"
3655                 << " Details:\n"
3656                 << "   First submatrix:\n" << sm1 << "\n"
3657                 << "   Second submatrix:\n" << sm2 << "\n";
3658             throw std::runtime_error( oss.str() );
3659          }
3660       }
3661 
3662       // isSame with non-matching submatrices (different number of rows)
3663       {
3664          AOSMT sm1 = submatrix<aligned>( tmat1_, 16UL, 0UL, 32UL, 16UL );
3665          AOSMT sm2 = submatrix<aligned>( tmat1_, 16UL, 0UL, 16UL, 16UL );
3666 
3667          if( blaze::isSame( sm1, sm2 ) == true ) {
3668             std::ostringstream oss;
3669             oss << " Test: " << test_ << "\n"
3670                 << " Error: Invalid isSame evaluation\n"
3671                 << " Details:\n"
3672                 << "   First submatrix:\n" << sm1 << "\n"
3673                 << "   Second submatrix:\n" << sm2 << "\n";
3674             throw std::runtime_error( oss.str() );
3675          }
3676       }
3677 
3678       // isSame with non-matching submatrices (different number of columns)
3679       {
3680          AOSMT sm1 = submatrix<aligned>( tmat1_, 16UL, 0UL, 32UL, 16UL );
3681          AOSMT sm2 = submatrix<aligned>( tmat1_, 16UL, 0UL, 32UL, 32UL );
3682 
3683          if( blaze::isSame( sm1, sm2 ) == true ) {
3684             std::ostringstream oss;
3685             oss << " Test: " << test_ << "\n"
3686                 << " Error: Invalid isSame evaluation\n"
3687                 << " Details:\n"
3688                 << "   First submatrix:\n" << sm1 << "\n"
3689                 << "   Second submatrix:\n" << sm2 << "\n";
3690             throw std::runtime_error( oss.str() );
3691          }
3692       }
3693 
3694       // isSame with non-matching submatrices (different row index)
3695       {
3696          AOSMT sm1 = submatrix<aligned>( tmat1_, 16UL, 0UL, 32UL, 16UL );
3697          AOSMT sm2 = submatrix<aligned>( tmat1_, 32UL, 0UL, 32UL, 16UL );
3698 
3699          if( blaze::isSame( sm1, sm2 ) == true ) {
3700             std::ostringstream oss;
3701             oss << " Test: " << test_ << "\n"
3702                 << " Error: Invalid isSame evaluation\n"
3703                 << " Details:\n"
3704                 << "   First submatrix:\n" << sm1 << "\n"
3705                 << "   Second submatrix:\n" << sm2 << "\n";
3706             throw std::runtime_error( oss.str() );
3707          }
3708       }
3709 
3710       // isSame with non-matching submatrices (different column index)
3711       {
3712          AOSMT sm1 = submatrix<aligned>( tmat1_, 16UL,  0UL, 32UL, 16UL );
3713          AOSMT sm2 = submatrix<aligned>( tmat1_, 16UL, 16UL, 32UL, 16UL );
3714 
3715          if( blaze::isSame( sm1, sm2 ) == true ) {
3716             std::ostringstream oss;
3717             oss << " Test: " << test_ << "\n"
3718                 << " Error: Invalid isSame evaluation\n"
3719                 << " Details:\n"
3720                 << "   First submatrix:\n" << sm1 << "\n"
3721                 << "   Second submatrix:\n" << sm2 << "\n";
3722             throw std::runtime_error( oss.str() );
3723          }
3724       }
3725    }
3726 
3727 
3728    //=====================================================================================
3729    // Column-major rows-based tests
3730    //=====================================================================================
3731 
3732    {
3733       test_ = "Column-major isSame() function (rows-based)";
3734 
3735       // isSame with row selection and matching submatrix
3736       {
3737          auto rs = blaze::rows( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
3738          auto sm = submatrix<aligned>( rs, 0UL, 0UL, 4UL, 64UL );
3739 
3740          if( blaze::isSame( sm, rs ) == false ) {
3741             std::ostringstream oss;
3742             oss << " Test: " << test_ << "\n"
3743                 << " Error: Invalid isSame evaluation\n"
3744                 << " Details:\n"
3745                 << "   Row selection:\n" << rs << "\n"
3746                 << "   Submatrix:\n" << sm << "\n";
3747             throw std::runtime_error( oss.str() );
3748          }
3749 
3750          if( blaze::isSame( rs, sm ) == false ) {
3751             std::ostringstream oss;
3752             oss << " Test: " << test_ << "\n"
3753                 << " Error: Invalid isSame evaluation\n"
3754                 << " Details:\n"
3755                 << "   Row selection:\n" << rs << "\n"
3756                 << "   Submatrix:\n" << sm << "\n";
3757             throw std::runtime_error( oss.str() );
3758          }
3759       }
3760 
3761       // isSame with row selection and non-matching submatrix (different number of rows)
3762       {
3763          auto rs = blaze::rows( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
3764          auto sm = submatrix<aligned>( rs, 0UL, 0UL, 3UL, 64UL );
3765 
3766          if( blaze::isSame( sm, rs ) == true ) {
3767             std::ostringstream oss;
3768             oss << " Test: " << test_ << "\n"
3769                 << " Error: Invalid isSame evaluation\n"
3770                 << " Details:\n"
3771                 << "   Row selection:\n" << rs << "\n"
3772                 << "   Submatrix:\n" << sm << "\n";
3773             throw std::runtime_error( oss.str() );
3774          }
3775 
3776          if( blaze::isSame( rs, sm ) == true ) {
3777             std::ostringstream oss;
3778             oss << " Test: " << test_ << "\n"
3779                 << " Error: Invalid isSame evaluation\n"
3780                 << " Details:\n"
3781                 << "   Row selection:\n" << rs << "\n"
3782                 << "   Submatrix:\n" << sm << "\n";
3783             throw std::runtime_error( oss.str() );
3784          }
3785       }
3786 
3787       // isSame with row selection and non-matching submatrix (different number of columns)
3788       {
3789          auto rs = blaze::rows( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
3790          auto sm = submatrix<aligned>( rs, 0UL, 0UL, 4UL, 32UL );
3791 
3792          if( blaze::isSame( sm, rs ) == true ) {
3793             std::ostringstream oss;
3794             oss << " Test: " << test_ << "\n"
3795                 << " Error: Invalid isSame evaluation\n"
3796                 << " Details:\n"
3797                 << "   Row selection:\n" << rs << "\n"
3798                 << "   Submatrix:\n" << sm << "\n";
3799             throw std::runtime_error( oss.str() );
3800          }
3801 
3802          if( blaze::isSame( rs, sm ) == true ) {
3803             std::ostringstream oss;
3804             oss << " Test: " << test_ << "\n"
3805                 << " Error: Invalid isSame evaluation\n"
3806                 << " Details:\n"
3807                 << "   Row selection:\n" << rs << "\n"
3808                 << "   Submatrix:\n" << sm << "\n";
3809             throw std::runtime_error( oss.str() );
3810          }
3811       }
3812 
3813       // isSame with row selection and non-matching submatrix (different row index)
3814       {
3815          auto rs = blaze::rows( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
3816          auto sm = submatrix<aligned>( rs, 1UL, 0UL, 3UL, 64UL );
3817 
3818          if( blaze::isSame( sm, rs ) == true ) {
3819             std::ostringstream oss;
3820             oss << " Test: " << test_ << "\n"
3821                 << " Error: Invalid isSame evaluation\n"
3822                 << " Details:\n"
3823                 << "   Row selection:\n" << rs << "\n"
3824                 << "   Submatrix:\n" << sm << "\n";
3825             throw std::runtime_error( oss.str() );
3826          }
3827 
3828          if( blaze::isSame( rs, sm ) == true ) {
3829             std::ostringstream oss;
3830             oss << " Test: " << test_ << "\n"
3831                 << " Error: Invalid isSame evaluation\n"
3832                 << " Details:\n"
3833                 << "   Row selection:\n" << rs << "\n"
3834                 << "   Submatrix:\n" << sm << "\n";
3835             throw std::runtime_error( oss.str() );
3836          }
3837       }
3838 
3839       // isSame with row selection and non-matching submatrix (different column index)
3840       {
3841          auto rs = blaze::rows( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
3842          auto sm = submatrix<aligned>( rs, 0UL, 16UL, 4UL, 48UL );
3843 
3844          if( blaze::isSame( sm, rs ) == true ) {
3845             std::ostringstream oss;
3846             oss << " Test: " << test_ << "\n"
3847                 << " Error: Invalid isSame evaluation\n"
3848                 << " Details:\n"
3849                 << "   Row selection:\n" << rs << "\n"
3850                 << "   Submatrix:\n" << sm << "\n";
3851             throw std::runtime_error( oss.str() );
3852          }
3853 
3854          if( blaze::isSame( rs, sm ) == true ) {
3855             std::ostringstream oss;
3856             oss << " Test: " << test_ << "\n"
3857                 << " Error: Invalid isSame evaluation\n"
3858                 << " Details:\n"
3859                 << "   Row selection:\n" << rs << "\n"
3860                 << "   Submatrix:\n" << sm << "\n";
3861             throw std::runtime_error( oss.str() );
3862          }
3863       }
3864 
3865       // isSame with matching submatrices
3866       {
3867          auto rs  = blaze::rows( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
3868          auto sm1 = submatrix<aligned>( rs, 0UL, 0UL, 3UL, 32UL );
3869          auto sm2 = submatrix<aligned>( rs, 0UL, 0UL, 3UL, 32UL );
3870 
3871          if( blaze::isSame( sm1, sm2 ) == false ) {
3872             std::ostringstream oss;
3873             oss << " Test: " << test_ << "\n"
3874                 << " Error: Invalid isSame evaluation\n"
3875                 << " Details:\n"
3876                 << "   First submatrix:\n" << sm1 << "\n"
3877                 << "   Second submatrix:\n" << sm2 << "\n";
3878             throw std::runtime_error( oss.str() );
3879          }
3880       }
3881 
3882       // isSame with non-matching submatrices (different number of rows)
3883       {
3884          auto rs  = blaze::rows( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
3885          auto sm1 = submatrix<aligned>( rs, 0UL, 0UL, 3UL, 32UL );
3886          auto sm2 = submatrix<aligned>( rs, 0UL, 0UL, 2UL, 32UL );
3887 
3888          if( blaze::isSame( sm1, sm2 ) == true ) {
3889             std::ostringstream oss;
3890             oss << " Test: " << test_ << "\n"
3891                 << " Error: Invalid isSame evaluation\n"
3892                 << " Details:\n"
3893                 << "   First submatrix:\n" << sm1 << "\n"
3894                 << "   Second submatrix:\n" << sm2 << "\n";
3895             throw std::runtime_error( oss.str() );
3896          }
3897       }
3898 
3899       // isSame with non-matching submatrices (different number of columns)
3900       {
3901          auto rs  = blaze::rows( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
3902          auto sm1 = submatrix<aligned>( rs, 0UL, 0UL, 3UL, 32UL );
3903          auto sm2 = submatrix<aligned>( rs, 0UL, 0UL, 3UL, 48UL );
3904 
3905          if( blaze::isSame( sm1, sm2 ) == true ) {
3906             std::ostringstream oss;
3907             oss << " Test: " << test_ << "\n"
3908                 << " Error: Invalid isSame evaluation\n"
3909                 << " Details:\n"
3910                 << "   First submatrix:\n" << sm1 << "\n"
3911                 << "   Second submatrix:\n" << sm2 << "\n";
3912             throw std::runtime_error( oss.str() );
3913          }
3914       }
3915 
3916       // isSame with non-matching submatrices (different row index)
3917       {
3918          auto rs  = blaze::rows( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
3919          auto sm1 = submatrix<aligned>( rs, 0UL, 0UL, 3UL, 32UL );
3920          auto sm2 = submatrix<aligned>( rs, 1UL, 0UL, 3UL, 32UL );
3921 
3922          if( blaze::isSame( sm1, sm2 ) == true ) {
3923             std::ostringstream oss;
3924             oss << " Test: " << test_ << "\n"
3925                 << " Error: Invalid isSame evaluation\n"
3926                 << " Details:\n"
3927                 << "   First submatrix:\n" << sm1 << "\n"
3928                 << "   Second submatrix:\n" << sm2 << "\n";
3929             throw std::runtime_error( oss.str() );
3930          }
3931       }
3932 
3933       // isSame with non-matching submatrices (different column index)
3934       {
3935          auto rs  = blaze::rows( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
3936          auto sm1 = submatrix<aligned>( rs, 0UL,  0UL, 3UL, 32UL );
3937          auto sm2 = submatrix<aligned>( rs, 0UL, 16UL, 3UL, 48UL );
3938 
3939          if( blaze::isSame( sm1, sm2 ) == true ) {
3940             std::ostringstream oss;
3941             oss << " Test: " << test_ << "\n"
3942                 << " Error: Invalid isSame evaluation\n"
3943                 << " Details:\n"
3944                 << "   First submatrix:\n" << sm1 << "\n"
3945                 << "   Second submatrix:\n" << sm2 << "\n";
3946             throw std::runtime_error( oss.str() );
3947          }
3948       }
3949    }
3950 
3951 
3952    //=====================================================================================
3953    // Column-major columns-based tests
3954    //=====================================================================================
3955 
3956    {
3957       test_ = "Column-major isSame() function (columns-based)";
3958 
3959       // isSame with column selection and matching submatrix
3960       {
3961          auto cs = blaze::columns( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
3962          auto sm = submatrix<aligned>( cs, 0UL, 0UL, 64UL, 4UL );
3963 
3964          if( blaze::isSame( sm, cs ) == false ) {
3965             std::ostringstream oss;
3966             oss << " Test: " << test_ << "\n"
3967                 << " Error: Invalid isSame evaluation\n"
3968                 << " Details:\n"
3969                 << "   Column selection:\n" << cs << "\n"
3970                 << "   Submatrix:\n" << sm << "\n";
3971             throw std::runtime_error( oss.str() );
3972          }
3973 
3974          if( blaze::isSame( cs, sm ) == false ) {
3975             std::ostringstream oss;
3976             oss << " Test: " << test_ << "\n"
3977                 << " Error: Invalid isSame evaluation\n"
3978                 << " Details:\n"
3979                 << "   Column selection:\n" << cs << "\n"
3980                 << "   Submatrix:\n" << sm << "\n";
3981             throw std::runtime_error( oss.str() );
3982          }
3983       }
3984 
3985       // isSame with column selection and non-matching submatrix (different number of rows)
3986       {
3987          auto cs = blaze::columns( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
3988          auto sm = submatrix<aligned>( cs, 0UL, 0UL, 32UL, 4UL );
3989 
3990          if( blaze::isSame( sm, cs ) == true ) {
3991             std::ostringstream oss;
3992             oss << " Test: " << test_ << "\n"
3993                 << " Error: Invalid isSame evaluation\n"
3994                 << " Details:\n"
3995                 << "   Column selection:\n" << cs << "\n"
3996                 << "   Submatrix:\n" << sm << "\n";
3997             throw std::runtime_error( oss.str() );
3998          }
3999 
4000          if( blaze::isSame( cs, sm ) == true ) {
4001             std::ostringstream oss;
4002             oss << " Test: " << test_ << "\n"
4003                 << " Error: Invalid isSame evaluation\n"
4004                 << " Details:\n"
4005                 << "   Column selection:\n" << cs << "\n"
4006                 << "   Submatrix:\n" << sm << "\n";
4007             throw std::runtime_error( oss.str() );
4008          }
4009       }
4010 
4011       // isSame with column selection and non-matching submatrix (different number of columns)
4012       {
4013          auto cs = blaze::columns( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
4014          auto sm = submatrix<aligned>( cs, 0UL, 0UL, 64UL, 3UL );
4015 
4016          if( blaze::isSame( sm, cs ) == true ) {
4017             std::ostringstream oss;
4018             oss << " Test: " << test_ << "\n"
4019                 << " Error: Invalid isSame evaluation\n"
4020                 << " Details:\n"
4021                 << "   Column selection:\n" << cs << "\n"
4022                 << "   Submatrix:\n" << sm << "\n";
4023             throw std::runtime_error( oss.str() );
4024          }
4025 
4026          if( blaze::isSame( cs, sm ) == true ) {
4027             std::ostringstream oss;
4028             oss << " Test: " << test_ << "\n"
4029                 << " Error: Invalid isSame evaluation\n"
4030                 << " Details:\n"
4031                 << "   Column selection:\n" << cs << "\n"
4032                 << "   Submatrix:\n" << sm << "\n";
4033             throw std::runtime_error( oss.str() );
4034          }
4035       }
4036 
4037       // isSame with column selection and non-matching submatrix (different row index)
4038       {
4039          auto cs = blaze::columns( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
4040          auto sm = submatrix<aligned>( cs, 16UL, 0UL, 48UL, 4UL );
4041 
4042          if( blaze::isSame( sm, cs ) == true ) {
4043             std::ostringstream oss;
4044             oss << " Test: " << test_ << "\n"
4045                 << " Error: Invalid isSame evaluation\n"
4046                 << " Details:\n"
4047                 << "   Column selection:\n" << cs << "\n"
4048                 << "   Submatrix:\n" << sm << "\n";
4049             throw std::runtime_error( oss.str() );
4050          }
4051 
4052          if( blaze::isSame( cs, sm ) == true ) {
4053             std::ostringstream oss;
4054             oss << " Test: " << test_ << "\n"
4055                 << " Error: Invalid isSame evaluation\n"
4056                 << " Details:\n"
4057                 << "   Column selection:\n" << cs << "\n"
4058                 << "   Submatrix:\n" << sm << "\n";
4059             throw std::runtime_error( oss.str() );
4060          }
4061       }
4062 
4063       // isSame with column selection and non-matching submatrix (different column index)
4064       {
4065          auto cs = blaze::columns( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
4066          auto sm = submatrix<aligned>( cs, 0UL, 1UL, 64UL, 3UL );
4067 
4068          if( blaze::isSame( sm, cs ) == true ) {
4069             std::ostringstream oss;
4070             oss << " Test: " << test_ << "\n"
4071                 << " Error: Invalid isSame evaluation\n"
4072                 << " Details:\n"
4073                 << "   Column selection:\n" << cs << "\n"
4074                 << "   Submatrix:\n" << sm << "\n";
4075             throw std::runtime_error( oss.str() );
4076          }
4077 
4078          if( blaze::isSame( cs, sm ) == true ) {
4079             std::ostringstream oss;
4080             oss << " Test: " << test_ << "\n"
4081                 << " Error: Invalid isSame evaluation\n"
4082                 << " Details:\n"
4083                 << "   Column selection:\n" << cs << "\n"
4084                 << "   Submatrix:\n" << sm << "\n";
4085             throw std::runtime_error( oss.str() );
4086          }
4087       }
4088 
4089       // isSame with matching submatrices
4090       {
4091          auto cs  = blaze::columns( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
4092          auto sm1 = submatrix<aligned>( cs, 0UL, 0UL, 32UL, 3UL );
4093          auto sm2 = submatrix<aligned>( cs, 0UL, 0UL, 32UL, 3UL );
4094 
4095          if( blaze::isSame( sm1, sm2 ) == false ) {
4096             std::ostringstream oss;
4097             oss << " Test: " << test_ << "\n"
4098                 << " Error: Invalid isSame evaluation\n"
4099                 << " Details:\n"
4100                 << "   First submatrix:\n" << sm1 << "\n"
4101                 << "   Second submatrix:\n" << sm2 << "\n";
4102             throw std::runtime_error( oss.str() );
4103          }
4104       }
4105 
4106       // isSame with non-matching submatrices (different number of rows)
4107       {
4108          auto cs  = blaze::columns( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
4109          auto sm1 = submatrix<aligned>( cs, 0UL, 0UL, 32UL, 3UL );
4110          auto sm2 = submatrix<aligned>( cs, 0UL, 0UL, 48UL, 3UL );
4111 
4112          if( blaze::isSame( sm1, sm2 ) == true ) {
4113             std::ostringstream oss;
4114             oss << " Test: " << test_ << "\n"
4115                 << " Error: Invalid isSame evaluation\n"
4116                 << " Details:\n"
4117                 << "   First submatrix:\n" << sm1 << "\n"
4118                 << "   Second submatrix:\n" << sm2 << "\n";
4119             throw std::runtime_error( oss.str() );
4120          }
4121       }
4122 
4123       // isSame with non-matching submatrices (different number of columns)
4124       {
4125          auto cs  = blaze::columns( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
4126          auto sm1 = submatrix<aligned>( cs, 0UL, 0UL, 32UL, 3UL );
4127          auto sm2 = submatrix<aligned>( cs, 0UL, 0UL, 32UL, 2UL );
4128 
4129          if( blaze::isSame( sm1, sm2 ) == true ) {
4130             std::ostringstream oss;
4131             oss << " Test: " << test_ << "\n"
4132                 << " Error: Invalid isSame evaluation\n"
4133                 << " Details:\n"
4134                 << "   First submatrix:\n" << sm1 << "\n"
4135                 << "   Second submatrix:\n" << sm2 << "\n";
4136             throw std::runtime_error( oss.str() );
4137          }
4138       }
4139 
4140       // isSame with non-matching submatrices (different row index)
4141       {
4142          auto cs  = blaze::columns( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
4143          auto sm1 = submatrix<aligned>( cs, 0UL, 0UL, 32UL, 3UL );
4144          auto sm2 = submatrix<aligned>( cs, 16UL, 0UL, 32UL, 3UL );
4145 
4146          if( blaze::isSame( sm1, sm2 ) == true ) {
4147             std::ostringstream oss;
4148             oss << " Test: " << test_ << "\n"
4149                 << " Error: Invalid isSame evaluation\n"
4150                 << " Details:\n"
4151                 << "   First submatrix:\n" << sm1 << "\n"
4152                 << "   Second submatrix:\n" << sm2 << "\n";
4153             throw std::runtime_error( oss.str() );
4154          }
4155       }
4156 
4157       // isSame with non-matching submatrices (different column index)
4158       {
4159          auto cs  = blaze::columns( tmat1_, { 0UL, 16UL, 32UL, 48UL } );
4160          auto sm1 = submatrix<aligned>( cs, 0UL, 0UL, 32UL, 3UL );
4161          auto sm2 = submatrix<aligned>( cs, 0UL, 1UL, 32UL, 3UL );
4162 
4163          if( blaze::isSame( sm1, sm2 ) == true ) {
4164             std::ostringstream oss;
4165             oss << " Test: " << test_ << "\n"
4166                 << " Error: Invalid isSame evaluation\n"
4167                 << " Details:\n"
4168                 << "   First submatrix:\n" << sm1 << "\n"
4169                 << "   Second submatrix:\n" << sm2 << "\n";
4170             throw std::runtime_error( oss.str() );
4171          }
4172       }
4173    }
4174 }
4175 //*************************************************************************************************
4176 
4177 
4178 //*************************************************************************************************
4179 /*!\brief Test of the \c submatrix() function with the Submatrix class template.
4180 //
4181 // \return void
4182 // \exception std::runtime_error Error detected.
4183 //
4184 // This function performs a test of the \c submatrix() function with the Submatrix
4185 // specialization. In case an error is detected, a \a std::runtime_error exception is thrown.
4186 */
testSubmatrix()4187 void DenseAlignedTest::testSubmatrix()
4188 {
4189    using blaze::submatrix;
4190    using blaze::aligned;
4191    using blaze::unaligned;
4192 
4193 
4194    //=====================================================================================
4195    // Row-major matrix tests
4196    //=====================================================================================
4197 
4198    {
4199       test_ = "Row-major submatrix() function";
4200 
4201       initialize();
4202 
4203       {
4204          ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 16UL, 32UL );
4205          ASMT sm2 = submatrix<aligned>  ( sm1  , 8UL,  0UL,  8UL, 16UL );
4206          USMT sm3 = submatrix<unaligned>( mat2_, 8UL, 16UL, 16UL, 32UL );
4207          USMT sm4 = submatrix<unaligned>( sm3  , 8UL,  0UL,  8UL, 16UL );
4208 
4209          if( sm2 != sm4 || mat1_ != mat2_ ) {
4210             std::ostringstream oss;
4211             oss << " Test: " << test_ << "\n"
4212                 << " Error: Submatrix function failed\n"
4213                 << " Details:\n"
4214                 << "   Result:\n" << sm2 << "\n"
4215                 << "   Expected result:\n" << sm4 << "\n";
4216             throw std::runtime_error( oss.str() );
4217          }
4218 
4219          if( sm2(1,1) != sm4(1,1) ) {
4220             std::ostringstream oss;
4221             oss << " Test: " << test_ << "\n"
4222                 << " Error: Function call operator access failed\n"
4223                 << " Details:\n"
4224                 << "   Result: " << sm2(1,1) << "\n"
4225                 << "   Expected result: " << sm4(1,1) << "\n";
4226             throw std::runtime_error( oss.str() );
4227          }
4228 
4229          if( *sm2.begin(1UL) != *sm4.begin(1UL) ) {
4230             std::ostringstream oss;
4231             oss << " Test: " << test_ << "\n"
4232                 << " Error: Iterator access failed\n"
4233                 << " Details:\n"
4234                 << "   Result: " << *sm2.begin(1UL) << "\n"
4235                 << "   Expected result: " << *sm4.begin(1UL) << "\n";
4236             throw std::runtime_error( oss.str() );
4237          }
4238       }
4239 
4240       try {
4241          ASMT sm1 = submatrix<aligned>( mat1_,  8UL, 16UL, 16UL, 32UL );
4242          ASMT sm2 = submatrix<aligned>( sm1  , 16UL,  0UL,  8UL,  8UL );
4243 
4244          std::ostringstream oss;
4245          oss << " Test: " << test_ << "\n"
4246              << " Error: Setup of out-of-bounds submatrix succeeded\n"
4247              << " Details:\n"
4248              << "   Result:\n" << sm2 << "\n";
4249          throw std::runtime_error( oss.str() );
4250       }
4251       catch( std::invalid_argument& ) {}
4252 
4253       try {
4254          ASMT sm1 = submatrix<aligned>( mat1_, 8UL, 16UL, 16UL, 32UL );
4255          ASMT sm2 = submatrix<aligned>( sm1  , 8UL, 32UL,  8UL,  8UL );
4256 
4257          std::ostringstream oss;
4258          oss << " Test: " << test_ << "\n"
4259              << " Error: Setup of out-of-bounds submatrix succeeded\n"
4260              << " Details:\n"
4261              << "   Result:\n" << sm2 << "\n";
4262          throw std::runtime_error( oss.str() );
4263       }
4264       catch( std::invalid_argument& ) {}
4265 
4266       try {
4267          ASMT sm1 = submatrix<aligned>( mat1_, 8UL, 16UL, 16UL, 32UL );
4268          ASMT sm2 = submatrix<aligned>( sm1  , 8UL,  0UL, 16UL, 24UL );
4269 
4270          std::ostringstream oss;
4271          oss << " Test: " << test_ << "\n"
4272              << " Error: Setup of out-of-bounds submatrix succeeded\n"
4273              << " Details:\n"
4274              << "   Result:\n" << sm2 << "\n";
4275          throw std::runtime_error( oss.str() );
4276       }
4277       catch( std::invalid_argument& ) {}
4278 
4279       try {
4280          ASMT sm1 = submatrix<aligned>( mat1_, 8UL, 16UL, 16UL, 32UL );
4281          ASMT sm2 = submatrix<aligned>( sm1  , 8UL,  0UL,  8UL, 40UL );
4282 
4283          std::ostringstream oss;
4284          oss << " Test: " << test_ << "\n"
4285              << " Error: Setup of out-of-bounds submatrix succeeded\n"
4286              << " Details:\n"
4287              << "   Result:\n" << sm2 << "\n";
4288          throw std::runtime_error( oss.str() );
4289       }
4290       catch( std::invalid_argument& ) {}
4291    }
4292 
4293 
4294    //=====================================================================================
4295    // Column-major matrix tests
4296    //=====================================================================================
4297 
4298    {
4299       test_ = "Column-major submatrix() function";
4300 
4301       initialize();
4302 
4303       {
4304          AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 32UL, 16UL );
4305          AOSMT sm2 = submatrix<aligned>  ( sm1   ,  0UL, 8UL, 16UL,  8UL );
4306          UOSMT sm3 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 32UL, 16UL );
4307          UOSMT sm4 = submatrix<unaligned>( sm3   ,  0UL, 8UL, 16UL,  8UL );
4308 
4309          if( sm2 != sm4 || mat1_ != mat2_ ) {
4310             std::ostringstream oss;
4311             oss << " Test: " << test_ << "\n"
4312                 << " Error: Submatrix function failed\n"
4313                 << " Details:\n"
4314                 << "   Result:\n" << sm2 << "\n"
4315                 << "   Expected result:\n" << sm4 << "\n";
4316             throw std::runtime_error( oss.str() );
4317          }
4318 
4319          if( sm2(1,1) != sm4(1,1) ) {
4320             std::ostringstream oss;
4321             oss << " Test: " << test_ << "\n"
4322                 << " Error: Function call operator access failed\n"
4323                 << " Details:\n"
4324                 << "   Result: " << sm2(1,1) << "\n"
4325                 << "   Expected result: " << sm4(1,1) << "\n";
4326             throw std::runtime_error( oss.str() );
4327          }
4328 
4329          if( *sm2.begin(1UL) != *sm4.begin(1UL) ) {
4330             std::ostringstream oss;
4331             oss << " Test: " << test_ << "\n"
4332                 << " Error: Iterator access failed\n"
4333                 << " Details:\n"
4334                 << "   Result: " << *sm2.begin(1UL) << "\n"
4335                 << "   Expected result: " << *sm4.begin(1UL) << "\n";
4336             throw std::runtime_error( oss.str() );
4337          }
4338       }
4339 
4340       try {
4341          AOSMT sm1 = submatrix<aligned>( tmat1_, 16UL, 8UL, 32UL, 16UL );
4342          AOSMT sm2 = submatrix<aligned>( sm1   , 32UL, 8UL,  8UL,  8UL );
4343 
4344          std::ostringstream oss;
4345          oss << " Test: " << test_ << "\n"
4346              << " Error: Setup of out-of-bounds submatrix succeeded\n"
4347              << " Details:\n"
4348              << "   Result:\n" << sm2 << "\n";
4349          throw std::runtime_error( oss.str() );
4350       }
4351       catch( std::invalid_argument& ) {}
4352 
4353       try {
4354          AOSMT sm1 = submatrix<aligned>( tmat1_, 16UL,  8UL, 32UL, 16UL );
4355          AOSMT sm2 = submatrix<aligned>( sm1   ,  0UL, 16UL,  8UL,  8UL );
4356 
4357          std::ostringstream oss;
4358          oss << " Test: " << test_ << "\n"
4359              << " Error: Setup of out-of-bounds submatrix succeeded\n"
4360              << " Details:\n"
4361              << "   Result:\n" << sm2 << "\n";
4362          throw std::runtime_error( oss.str() );
4363       }
4364       catch( std::invalid_argument& ) {}
4365 
4366       try {
4367          AOSMT sm1 = submatrix<aligned>( tmat1_, 16UL, 8UL, 32UL, 16UL );
4368          AOSMT sm2 = submatrix<aligned>( sm1   ,  0UL, 8UL, 40UL,  8UL );
4369 
4370          std::ostringstream oss;
4371          oss << " Test: " << test_ << "\n"
4372              << " Error: Setup of out-of-bounds submatrix succeeded\n"
4373              << " Details:\n"
4374              << "   Result:\n" << sm2 << "\n";
4375          throw std::runtime_error( oss.str() );
4376       }
4377       catch( std::invalid_argument& ) {}
4378 
4379       try {
4380          AOSMT sm1 = submatrix<aligned>( tmat1_, 16UL, 8UL, 32UL, 16UL );
4381          AOSMT sm2 = submatrix<aligned>( sm1   ,  0UL, 8UL, 24UL, 16UL );
4382 
4383          std::ostringstream oss;
4384          oss << " Test: " << test_ << "\n"
4385              << " Error: Setup of out-of-bounds submatrix succeeded\n"
4386              << " Details:\n"
4387              << "   Result:\n" << sm2 << "\n";
4388          throw std::runtime_error( oss.str() );
4389       }
4390       catch( std::invalid_argument& ) {}
4391    }
4392 }
4393 //*************************************************************************************************
4394 
4395 
4396 //*************************************************************************************************
4397 /*!\brief Test of the \c row() function with the Submatrix class template.
4398 //
4399 // \return void
4400 // \exception std::runtime_error Error detected.
4401 //
4402 // This function performs a test of the \c row() function with the Submatrix specialization.
4403 // In case an error is detected, a \a std::runtime_error exception is thrown.
4404 */
testRow()4405 void DenseAlignedTest::testRow()
4406 {
4407    using blaze::submatrix;
4408    using blaze::row;
4409    using blaze::aligned;
4410    using blaze::unaligned;
4411 
4412 
4413    //=====================================================================================
4414    // Row-major matrix tests
4415    //=====================================================================================
4416 
4417    {
4418       test_ = "Row-major row() function";
4419 
4420       initialize();
4421 
4422       {
4423          ASMT sm1  = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
4424          USMT sm2  = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
4425          auto row1 = row( sm1, 1UL );
4426          auto row2 = row( sm2, 1UL );
4427 
4428          if( row1 != row2 ) {
4429             std::ostringstream oss;
4430             oss << " Test: " << test_ << "\n"
4431                 << " Error: Row function failed\n"
4432                 << " Details:\n"
4433                 << "   Result:\n" << row1 << "\n"
4434                 << "   Expected result:\n" << row2 << "\n";
4435             throw std::runtime_error( oss.str() );
4436          }
4437 
4438          if( row1[1] != row2[1] ) {
4439             std::ostringstream oss;
4440             oss << " Test: " << test_ << "\n"
4441                 << " Error: Subscript operator access failed\n"
4442                 << " Details:\n"
4443                 << "   Result: " << row1[1] << "\n"
4444                 << "   Expected result: " << row2[1] << "\n";
4445             throw std::runtime_error( oss.str() );
4446          }
4447 
4448          if( *row1.begin() != *row2.begin() ) {
4449             std::ostringstream oss;
4450             oss << " Test: " << test_ << "\n"
4451                 << " Error: Iterator access failed\n"
4452                 << " Details:\n"
4453                 << "   Result: " << *row1.begin() << "\n"
4454                 << "   Expected result: " << *row2.begin() << "\n";
4455             throw std::runtime_error( oss.str() );
4456          }
4457       }
4458 
4459       try {
4460          ASMT sm1  = submatrix<aligned>( mat1_, 8UL, 16UL, 8UL, 16UL );
4461          auto row8 = row( sm1, 8UL );
4462 
4463          std::ostringstream oss;
4464          oss << " Test: " << test_ << "\n"
4465              << " Error: Setup of out-of-bounds row succeeded\n"
4466              << " Details:\n"
4467              << "   Result:\n" << row8 << "\n";
4468          throw std::runtime_error( oss.str() );
4469       }
4470       catch( std::invalid_argument& ) {}
4471    }
4472 
4473 
4474    //=====================================================================================
4475    // Column-major matrix tests
4476    //=====================================================================================
4477 
4478    {
4479       test_ = "Column-major row() function";
4480 
4481       initialize();
4482 
4483       {
4484          AOSMT sm1  = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
4485          UOSMT sm2  = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
4486          auto  row1 = row( sm1, 1UL );
4487          auto  row2 = row( sm2, 1UL );
4488 
4489          if( row1 != row2 ) {
4490             std::ostringstream oss;
4491             oss << " Test: " << test_ << "\n"
4492                 << " Error: Row function failed\n"
4493                 << " Details:\n"
4494                 << "   Result:\n" << row1 << "\n"
4495                 << "   Expected result:\n" << row2 << "\n";
4496             throw std::runtime_error( oss.str() );
4497          }
4498 
4499          if( row1[1] != row2[1] ) {
4500             std::ostringstream oss;
4501             oss << " Test: " << test_ << "\n"
4502                 << " Error: Subscript operator access failed\n"
4503                 << " Details:\n"
4504                 << "   Result: " << row1[1] << "\n"
4505                 << "   Expected result: " << row2[1] << "\n";
4506             throw std::runtime_error( oss.str() );
4507          }
4508 
4509          if( *row1.begin() != *row2.begin() ) {
4510             std::ostringstream oss;
4511             oss << " Test: " << test_ << "\n"
4512                 << " Error: Iterator access failed\n"
4513                 << " Details:\n"
4514                 << "   Result: " << *row1.begin() << "\n"
4515                 << "   Expected result: " << *row2.begin() << "\n";
4516             throw std::runtime_error( oss.str() );
4517          }
4518       }
4519 
4520       try {
4521          AOSMT sm1   = submatrix<aligned>( tmat1_, 16UL, 8UL, 16UL, 8UL );
4522          auto  row16 = row( sm1, 16UL );
4523 
4524          std::ostringstream oss;
4525          oss << " Test: " << test_ << "\n"
4526              << " Error: Setup of out-of-bounds row succeeded\n"
4527              << " Details:\n"
4528              << "   Result:\n" << row16 << "\n";
4529          throw std::runtime_error( oss.str() );
4530       }
4531       catch( std::invalid_argument& ) {}
4532    }
4533 }
4534 //*************************************************************************************************
4535 
4536 
4537 //*************************************************************************************************
4538 /*!\brief Test of the \c rows() function with the Submatrix class template.
4539 //
4540 // \return void
4541 // \exception std::runtime_error Error detected.
4542 //
4543 // This function performs a test of the \c rows() function with the Submatrix specialization.
4544 // In case an error is detected, a \a std::runtime_error exception is thrown.
4545 */
testRows()4546 void DenseAlignedTest::testRows()
4547 {
4548    using blaze::submatrix;
4549    using blaze::rows;
4550    using blaze::aligned;
4551    using blaze::unaligned;
4552 
4553 
4554    //=====================================================================================
4555    // Row-major matrix tests (initializer_list)
4556    //=====================================================================================
4557 
4558    {
4559       test_ = "Row-major rows() function (initializer_list)";
4560 
4561       initialize();
4562 
4563       {
4564          ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
4565          USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
4566          auto rs1 = rows( sm1, { 0UL, 2UL, 4UL, 6UL } );
4567          auto rs2 = rows( sm2, { 0UL, 2UL, 4UL, 6UL } );
4568 
4569          if( rs1 != rs2 ) {
4570             std::ostringstream oss;
4571             oss << " Test: " << test_ << "\n"
4572                 << " Error: Rows function failed\n"
4573                 << " Details:\n"
4574                 << "   Result:\n" << rs1 << "\n"
4575                 << "   Expected result:\n" << rs2 << "\n";
4576             throw std::runtime_error( oss.str() );
4577          }
4578 
4579          if( rs1(1,1) != rs2(1,1) ) {
4580             std::ostringstream oss;
4581             oss << " Test: " << test_ << "\n"
4582                 << " Error: Function call operator access failed\n"
4583                 << " Details:\n"
4584                 << "   Result: " << rs1(1,1) << "\n"
4585                 << "   Expected result: " << rs2(1,1) << "\n";
4586             throw std::runtime_error( oss.str() );
4587          }
4588 
4589          if( *rs1.begin( 1UL ) != *rs2.begin( 1UL ) ) {
4590             std::ostringstream oss;
4591             oss << " Test: " << test_ << "\n"
4592                 << " Error: Iterator access failed\n"
4593                 << " Details:\n"
4594                 << "   Result: " << *rs1.begin( 1UL ) << "\n"
4595                 << "   Expected result: " << *rs2.begin( 1UL ) << "\n";
4596             throw std::runtime_error( oss.str() );
4597          }
4598       }
4599 
4600       try {
4601          ASMT sm1 = submatrix<aligned>( mat1_, 8UL, 16UL, 8UL, 16UL );
4602          auto rs  = rows( sm1, { 8UL } );
4603 
4604          std::ostringstream oss;
4605          oss << " Test: " << test_ << "\n"
4606              << " Error: Setup of out-of-bounds row selection succeeded\n"
4607              << " Details:\n"
4608              << "   Result:\n" << rs << "\n";
4609          throw std::runtime_error( oss.str() );
4610       }
4611       catch( std::invalid_argument& ) {}
4612    }
4613 
4614 
4615    //=====================================================================================
4616    // Row-major matrix tests (std::array)
4617    //=====================================================================================
4618 
4619    {
4620       test_ = "Row-major rows() function (std::array)";
4621 
4622       initialize();
4623 
4624       {
4625          std::array<int,4UL> indices{ 0UL, 2UL, 4UL, 6UL };
4626 
4627          ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
4628          USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
4629          auto rs1 = rows( sm1, indices );
4630          auto rs2 = rows( sm2, indices );
4631 
4632          if( rs1 != rs2 ) {
4633             std::ostringstream oss;
4634             oss << " Test: " << test_ << "\n"
4635                 << " Error: Rows function failed\n"
4636                 << " Details:\n"
4637                 << "   Result:\n" << rs1 << "\n"
4638                 << "   Expected result:\n" << rs2 << "\n";
4639             throw std::runtime_error( oss.str() );
4640          }
4641 
4642          if( rs1(1,1) != rs2(1,1) ) {
4643             std::ostringstream oss;
4644             oss << " Test: " << test_ << "\n"
4645                 << " Error: Function call operator access failed\n"
4646                 << " Details:\n"
4647                 << "   Result: " << rs1(1,1) << "\n"
4648                 << "   Expected result: " << rs2(1,1) << "\n";
4649             throw std::runtime_error( oss.str() );
4650          }
4651 
4652          if( *rs1.begin( 1UL ) != *rs2.begin( 1UL ) ) {
4653             std::ostringstream oss;
4654             oss << " Test: " << test_ << "\n"
4655                 << " Error: Iterator access failed\n"
4656                 << " Details:\n"
4657                 << "   Result: " << *rs1.begin( 1UL ) << "\n"
4658                 << "   Expected result: " << *rs2.begin( 1UL ) << "\n";
4659             throw std::runtime_error( oss.str() );
4660          }
4661       }
4662 
4663       try {
4664          std::array<int,1UL> indices{ 8UL };
4665 
4666          ASMT sm1 = submatrix<aligned>( mat1_, 8UL, 16UL, 8UL, 16UL );
4667          auto rs  = rows( sm1, indices );
4668 
4669          std::ostringstream oss;
4670          oss << " Test: " << test_ << "\n"
4671              << " Error: Setup of out-of-bounds row selection succeeded\n"
4672              << " Details:\n"
4673              << "   Result:\n" << rs << "\n";
4674          throw std::runtime_error( oss.str() );
4675       }
4676       catch( std::invalid_argument& ) {}
4677    }
4678 
4679 
4680    //=====================================================================================
4681    // Row-major matrix tests (lambda expression)
4682    //=====================================================================================
4683 
4684    {
4685       test_ = "Row-major rows() function (lambda expression)";
4686 
4687       initialize();
4688 
4689       {
4690          ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
4691          USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
4692          auto rs1 = rows( sm1, []( size_t i ){ return i*2UL; }, 4UL );
4693          auto rs2 = rows( sm2, []( size_t i ){ return i*2UL; }, 4UL );
4694 
4695          if( rs1 != rs2 ) {
4696             std::ostringstream oss;
4697             oss << " Test: " << test_ << "\n"
4698                 << " Error: Rows function failed\n"
4699                 << " Details:\n"
4700                 << "   Result:\n" << rs1 << "\n"
4701                 << "   Expected result:\n" << rs2 << "\n";
4702             throw std::runtime_error( oss.str() );
4703          }
4704 
4705          if( rs1(1,1) != rs2(1,1) ) {
4706             std::ostringstream oss;
4707             oss << " Test: " << test_ << "\n"
4708                 << " Error: Function call operator access failed\n"
4709                 << " Details:\n"
4710                 << "   Result: " << rs1(1,1) << "\n"
4711                 << "   Expected result: " << rs2(1,1) << "\n";
4712             throw std::runtime_error( oss.str() );
4713          }
4714 
4715          if( *rs1.begin( 1UL ) != *rs2.begin( 1UL ) ) {
4716             std::ostringstream oss;
4717             oss << " Test: " << test_ << "\n"
4718                 << " Error: Iterator access failed\n"
4719                 << " Details:\n"
4720                 << "   Result: " << *rs1.begin( 1UL ) << "\n"
4721                 << "   Expected result: " << *rs2.begin( 1UL ) << "\n";
4722             throw std::runtime_error( oss.str() );
4723          }
4724       }
4725 
4726       try {
4727          ASMT sm1 = submatrix<aligned>( mat1_, 8UL, 16UL, 8UL, 16UL );
4728          auto rs  = rows( sm1, []( size_t ){ return 8UL; }, 1UL );
4729 
4730          std::ostringstream oss;
4731          oss << " Test: " << test_ << "\n"
4732              << " Error: Setup of out-of-bounds row selection succeeded\n"
4733              << " Details:\n"
4734              << "   Result:\n" << rs << "\n";
4735          throw std::runtime_error( oss.str() );
4736       }
4737       catch( std::invalid_argument& ) {}
4738    }
4739 
4740 
4741    //=====================================================================================
4742    // Column-major matrix tests (initializer_list)
4743    //=====================================================================================
4744 
4745    {
4746       test_ = "Column-major rows() function (initializer_list)";
4747 
4748       initialize();
4749 
4750       {
4751          AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
4752          UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
4753          auto  rs1 = rows( sm1, { 0UL, 2UL, 4UL, 6UL } );
4754          auto  rs2 = rows( sm2, { 0UL, 2UL, 4UL, 6UL } );
4755 
4756          if( rs1 != rs2 ) {
4757             std::ostringstream oss;
4758             oss << " Test: " << test_ << "\n"
4759                 << " Error: Rows function failed\n"
4760                 << " Details:\n"
4761                 << "   Result:\n" << rs1 << "\n"
4762                 << "   Expected result:\n" << rs2 << "\n";
4763             throw std::runtime_error( oss.str() );
4764          }
4765 
4766          if( rs1(1,1) != rs2(1,1) ) {
4767             std::ostringstream oss;
4768             oss << " Test: " << test_ << "\n"
4769                 << " Error: Function call operator access failed\n"
4770                 << " Details:\n"
4771                 << "   Result: " << rs1(1,1) << "\n"
4772                 << "   Expected result: " << rs2(1,1) << "\n";
4773             throw std::runtime_error( oss.str() );
4774          }
4775 
4776          if( *rs1.begin( 1UL ) != *rs2.begin( 1UL ) ) {
4777             std::ostringstream oss;
4778             oss << " Test: " << test_ << "\n"
4779                 << " Error: Iterator access failed\n"
4780                 << " Details:\n"
4781                 << "   Result: " << *rs1.begin( 1UL ) << "\n"
4782                 << "   Expected result: " << *rs2.begin( 1UL ) << "\n";
4783             throw std::runtime_error( oss.str() );
4784          }
4785       }
4786 
4787       try {
4788          AOSMT sm1   = submatrix<aligned>( tmat1_, 16UL, 8UL, 16UL, 8UL );
4789          auto  row16 = rows( sm1, { 16UL } );
4790 
4791          std::ostringstream oss;
4792          oss << " Test: " << test_ << "\n"
4793              << " Error: Setup of out-of-bounds row selection succeeded\n"
4794              << " Details:\n"
4795              << "   Result:\n" << row16 << "\n";
4796          throw std::runtime_error( oss.str() );
4797       }
4798       catch( std::invalid_argument& ) {}
4799    }
4800 
4801 
4802    //=====================================================================================
4803    // Column-major matrix tests (std::array)
4804    //=====================================================================================
4805 
4806    {
4807       test_ = "Column-major rows() function (std::array)";
4808 
4809       initialize();
4810 
4811       {
4812          std::array<int,4UL> indices{ 0UL, 2UL, 4UL, 6UL };
4813 
4814          AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
4815          UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
4816          auto  rs1 = rows( sm1, indices );
4817          auto  rs2 = rows( sm2, indices );
4818 
4819          if( rs1 != rs2 ) {
4820             std::ostringstream oss;
4821             oss << " Test: " << test_ << "\n"
4822                 << " Error: Rows function failed\n"
4823                 << " Details:\n"
4824                 << "   Result:\n" << rs1 << "\n"
4825                 << "   Expected result:\n" << rs2 << "\n";
4826             throw std::runtime_error( oss.str() );
4827          }
4828 
4829          if( rs1(1,1) != rs2(1,1) ) {
4830             std::ostringstream oss;
4831             oss << " Test: " << test_ << "\n"
4832                 << " Error: Function call operator access failed\n"
4833                 << " Details:\n"
4834                 << "   Result: " << rs1(1,1) << "\n"
4835                 << "   Expected result: " << rs2(1,1) << "\n";
4836             throw std::runtime_error( oss.str() );
4837          }
4838 
4839          if( *rs1.begin( 1UL ) != *rs2.begin( 1UL ) ) {
4840             std::ostringstream oss;
4841             oss << " Test: " << test_ << "\n"
4842                 << " Error: Iterator access failed\n"
4843                 << " Details:\n"
4844                 << "   Result: " << *rs1.begin( 1UL ) << "\n"
4845                 << "   Expected result: " << *rs2.begin( 1UL ) << "\n";
4846             throw std::runtime_error( oss.str() );
4847          }
4848       }
4849 
4850       try {
4851          std::array<int,1UL> indices{ 16UL };
4852 
4853          AOSMT sm1   = submatrix<aligned>( tmat1_, 16UL, 8UL, 16UL, 8UL );
4854          auto  row16 = rows( sm1, indices );
4855 
4856          std::ostringstream oss;
4857          oss << " Test: " << test_ << "\n"
4858              << " Error: Setup of out-of-bounds row selection succeeded\n"
4859              << " Details:\n"
4860              << "   Result:\n" << row16 << "\n";
4861          throw std::runtime_error( oss.str() );
4862       }
4863       catch( std::invalid_argument& ) {}
4864    }
4865 
4866 
4867    //=====================================================================================
4868    // Column-major matrix tests (lambda expression)
4869    //=====================================================================================
4870 
4871    {
4872       test_ = "Column-major rows() function (lambda expression)";
4873 
4874       initialize();
4875 
4876       {
4877          AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
4878          UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
4879          auto  rs1 = rows( sm1, []( size_t i ){ return i*2UL; }, 4UL );
4880          auto  rs2 = rows( sm2, []( size_t i ){ return i*2UL; }, 4UL );
4881 
4882          if( rs1 != rs2 ) {
4883             std::ostringstream oss;
4884             oss << " Test: " << test_ << "\n"
4885                 << " Error: Rows function failed\n"
4886                 << " Details:\n"
4887                 << "   Result:\n" << rs1 << "\n"
4888                 << "   Expected result:\n" << rs2 << "\n";
4889             throw std::runtime_error( oss.str() );
4890          }
4891 
4892          if( rs1(1,1) != rs2(1,1) ) {
4893             std::ostringstream oss;
4894             oss << " Test: " << test_ << "\n"
4895                 << " Error: Function call operator access failed\n"
4896                 << " Details:\n"
4897                 << "   Result: " << rs1(1,1) << "\n"
4898                 << "   Expected result: " << rs2(1,1) << "\n";
4899             throw std::runtime_error( oss.str() );
4900          }
4901 
4902          if( *rs1.begin( 1UL ) != *rs2.begin( 1UL ) ) {
4903             std::ostringstream oss;
4904             oss << " Test: " << test_ << "\n"
4905                 << " Error: Iterator access failed\n"
4906                 << " Details:\n"
4907                 << "   Result: " << *rs1.begin( 1UL ) << "\n"
4908                 << "   Expected result: " << *rs2.begin( 1UL ) << "\n";
4909             throw std::runtime_error( oss.str() );
4910          }
4911       }
4912 
4913       try {
4914          AOSMT sm1   = submatrix<aligned>( tmat1_, 16UL, 8UL, 16UL, 8UL );
4915          auto  row16 = rows( sm1, []( size_t ){ return 16UL; }, 1UL );
4916 
4917          std::ostringstream oss;
4918          oss << " Test: " << test_ << "\n"
4919              << " Error: Setup of out-of-bounds row selection succeeded\n"
4920              << " Details:\n"
4921              << "   Result:\n" << row16 << "\n";
4922          throw std::runtime_error( oss.str() );
4923       }
4924       catch( std::invalid_argument& ) {}
4925    }
4926 }
4927 //*************************************************************************************************
4928 
4929 
4930 //*************************************************************************************************
4931 /*!\brief Test of the \c column() function with the Submatrix class template.
4932 //
4933 // \return void
4934 // \exception std::runtime_error Error detected.
4935 //
4936 // This function performs a test of the \c column() function with the Submatrix specialization.
4937 // In case an error is detected, a \a std::runtime_error exception is thrown.
4938 */
testColumn()4939 void DenseAlignedTest::testColumn()
4940 {
4941    using blaze::submatrix;
4942    using blaze::column;
4943    using blaze::aligned;
4944    using blaze::unaligned;
4945 
4946 
4947    //=====================================================================================
4948    // Row-major matrix tests
4949    //=====================================================================================
4950 
4951    {
4952       test_ = "Row-major column() function";
4953 
4954       initialize();
4955 
4956       {
4957          ASMT sm1  = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
4958          USMT sm2  = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
4959          auto col1 = column( sm1, 1UL );
4960          auto col2 = column( sm2, 1UL );
4961 
4962          if( col1 != col2 ) {
4963             std::ostringstream oss;
4964             oss << " Test: " << test_ << "\n"
4965                 << " Error: Column function failed\n"
4966                 << " Details:\n"
4967                 << "   Result:\n" << col1 << "\n"
4968                 << "   Expected result:\n" << col2 << "\n";
4969             throw std::runtime_error( oss.str() );
4970          }
4971 
4972          if( col1[1] != col2[1] ) {
4973             std::ostringstream oss;
4974             oss << " Test: " << test_ << "\n"
4975                 << " Error: Subscript operator access failed\n"
4976                 << " Details:\n"
4977                 << "   Result: " << col1[1] << "\n"
4978                 << "   Expected result: " << col2[1] << "\n";
4979             throw std::runtime_error( oss.str() );
4980          }
4981 
4982          if( *col1.begin() != *col2.begin() ) {
4983             std::ostringstream oss;
4984             oss << " Test: " << test_ << "\n"
4985                 << " Error: Iterator access failed\n"
4986                 << " Details:\n"
4987                 << "   Result: " << *col1.begin() << "\n"
4988                 << "   Expected result: " << *col2.begin() << "\n";
4989             throw std::runtime_error( oss.str() );
4990          }
4991       }
4992 
4993       try {
4994          ASMT sm1   = submatrix<aligned>( mat1_, 8UL, 16UL, 8UL, 16UL );
4995          auto col16 = column( sm1, 16UL );
4996 
4997          std::ostringstream oss;
4998          oss << " Test: " << test_ << "\n"
4999              << " Error: Setup of out-of-bounds column succeeded\n"
5000              << " Details:\n"
5001              << "   Result:\n" << col16 << "\n";
5002          throw std::runtime_error( oss.str() );
5003       }
5004       catch( std::invalid_argument& ) {}
5005    }
5006 
5007 
5008    //=====================================================================================
5009    // Column-major matrix tests
5010    //=====================================================================================
5011 
5012    {
5013       test_ = "Column-major column() function";
5014 
5015       initialize();
5016 
5017       {
5018          AOSMT sm1  = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
5019          UOSMT sm2  = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
5020          auto  col1 = column( sm1, 1UL );
5021          auto  col2 = column( sm2, 1UL );
5022 
5023          if( col1 != col2 ) {
5024             std::ostringstream oss;
5025             oss << " Test: " << test_ << "\n"
5026                 << " Error: Column function failed\n"
5027                 << " Details:\n"
5028                 << "   Result:\n" << col1 << "\n"
5029                 << "   Expected result:\n" << col2 << "\n";
5030             throw std::runtime_error( oss.str() );
5031          }
5032 
5033          if( col1[1] != col2[1] ) {
5034             std::ostringstream oss;
5035             oss << " Test: " << test_ << "\n"
5036                 << " Error: Subscript operator access failed\n"
5037                 << " Details:\n"
5038                 << "   Result: " << col1[1] << "\n"
5039                 << "   Expected result: " << col2[1] << "\n";
5040             throw std::runtime_error( oss.str() );
5041          }
5042 
5043          if( *col1.begin() != *col2.begin() ) {
5044             std::ostringstream oss;
5045             oss << " Test: " << test_ << "\n"
5046                 << " Error: Iterator access failed\n"
5047                 << " Details:\n"
5048                 << "   Result: " << *col1.begin() << "\n"
5049                 << "   Expected result: " << *col2.begin() << "\n";
5050             throw std::runtime_error( oss.str() );
5051          }
5052       }
5053 
5054       try {
5055          AOSMT sm1  = submatrix<aligned>( tmat1_, 16UL, 8UL, 16UL, 8UL );
5056          auto  col8 = column( sm1, 8UL );
5057 
5058          std::ostringstream oss;
5059          oss << " Test: " << test_ << "\n"
5060              << " Error: Setup of out-of-bounds column succeeded\n"
5061              << " Details:\n"
5062              << "   Result:\n" << col8 << "\n";
5063          throw std::runtime_error( oss.str() );
5064       }
5065       catch( std::invalid_argument& ) {}
5066    }
5067 }
5068 //*************************************************************************************************
5069 
5070 
5071 //*************************************************************************************************
5072 /*!\brief Test of the \c columns() function with the Submatrix class template.
5073 //
5074 // \return void
5075 // \exception std::runtime_error Error detected.
5076 //
5077 // This function performs a test of the \c columns() function with the Submatrix specialization.
5078 // In case an error is detected, a \a std::runtime_error exception is thrown.
5079 */
testColumns()5080 void DenseAlignedTest::testColumns()
5081 {
5082    using blaze::submatrix;
5083    using blaze::rows;
5084    using blaze::aligned;
5085    using blaze::unaligned;
5086 
5087 
5088    //=====================================================================================
5089    // Row-major matrix tests (initializer_list)
5090    //=====================================================================================
5091 
5092    {
5093       test_ = "Row-major columns() function (initializer_list)";
5094 
5095       initialize();
5096 
5097       {
5098          ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
5099          USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
5100          auto cs1 = columns( sm1, { 0UL, 2UL, 4UL, 6UL } );
5101          auto cs2 = columns( sm2, { 0UL, 2UL, 4UL, 6UL } );
5102 
5103          if( cs1 != cs2 ) {
5104             std::ostringstream oss;
5105             oss << " Test: " << test_ << "\n"
5106                 << " Error: Rows function failed\n"
5107                 << " Details:\n"
5108                 << "   Result:\n" << cs1 << "\n"
5109                 << "   Expected result:\n" << cs2 << "\n";
5110             throw std::runtime_error( oss.str() );
5111          }
5112 
5113          if( cs1(1,1) != cs2(1,1) ) {
5114             std::ostringstream oss;
5115             oss << " Test: " << test_ << "\n"
5116                 << " Error: Function call operator access failed\n"
5117                 << " Details:\n"
5118                 << "   Result: " << cs1(1,1) << "\n"
5119                 << "   Expected result: " << cs2(1,1) << "\n";
5120             throw std::runtime_error( oss.str() );
5121          }
5122 
5123          if( *cs1.begin( 1UL ) != *cs2.begin( 1UL ) ) {
5124             std::ostringstream oss;
5125             oss << " Test: " << test_ << "\n"
5126                 << " Error: Iterator access failed\n"
5127                 << " Details:\n"
5128                 << "   Result: " << *cs1.begin( 1UL ) << "\n"
5129                 << "   Expected result: " << *cs2.begin( 1UL ) << "\n";
5130             throw std::runtime_error( oss.str() );
5131          }
5132       }
5133 
5134       try {
5135          ASMT sm1 = submatrix<aligned>( mat1_, 8UL, 16UL, 8UL, 16UL );
5136          auto cs  = columns( sm1, { 16UL } );
5137 
5138          std::ostringstream oss;
5139          oss << " Test: " << test_ << "\n"
5140              << " Error: Setup of out-of-bounds column selection succeeded\n"
5141              << " Details:\n"
5142              << "   Result:\n" << cs << "\n";
5143          throw std::runtime_error( oss.str() );
5144       }
5145       catch( std::invalid_argument& ) {}
5146    }
5147 
5148 
5149    //=====================================================================================
5150    // Row-major matrix tests (std::array)
5151    //=====================================================================================
5152 
5153    {
5154       test_ = "Row-major columns() function (std::array)";
5155 
5156       initialize();
5157 
5158       {
5159          std::array<int,4UL> indices{ 0UL, 2UL, 4UL, 6UL };
5160 
5161          ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
5162          USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
5163          auto cs1 = columns( sm1, indices );
5164          auto cs2 = columns( sm2, indices );
5165 
5166          if( cs1 != cs2 ) {
5167             std::ostringstream oss;
5168             oss << " Test: " << test_ << "\n"
5169                 << " Error: Rows function failed\n"
5170                 << " Details:\n"
5171                 << "   Result:\n" << cs1 << "\n"
5172                 << "   Expected result:\n" << cs2 << "\n";
5173             throw std::runtime_error( oss.str() );
5174          }
5175 
5176          if( cs1(1,1) != cs2(1,1) ) {
5177             std::ostringstream oss;
5178             oss << " Test: " << test_ << "\n"
5179                 << " Error: Function call operator access failed\n"
5180                 << " Details:\n"
5181                 << "   Result: " << cs1(1,1) << "\n"
5182                 << "   Expected result: " << cs2(1,1) << "\n";
5183             throw std::runtime_error( oss.str() );
5184          }
5185 
5186          if( *cs1.begin( 1UL ) != *cs2.begin( 1UL ) ) {
5187             std::ostringstream oss;
5188             oss << " Test: " << test_ << "\n"
5189                 << " Error: Iterator access failed\n"
5190                 << " Details:\n"
5191                 << "   Result: " << *cs1.begin( 1UL ) << "\n"
5192                 << "   Expected result: " << *cs2.begin( 1UL ) << "\n";
5193             throw std::runtime_error( oss.str() );
5194          }
5195       }
5196 
5197       try {
5198          std::array<int,1UL> indices{ 16UL };
5199 
5200          ASMT sm1 = submatrix<aligned>( mat1_, 8UL, 16UL, 8UL, 16UL );
5201          auto cs  = columns( sm1, indices );
5202 
5203          std::ostringstream oss;
5204          oss << " Test: " << test_ << "\n"
5205              << " Error: Setup of out-of-bounds column selection succeeded\n"
5206              << " Details:\n"
5207              << "   Result:\n" << cs << "\n";
5208          throw std::runtime_error( oss.str() );
5209       }
5210       catch( std::invalid_argument& ) {}
5211    }
5212 
5213 
5214    //=====================================================================================
5215    // Row-major matrix tests (lambda expression)
5216    //=====================================================================================
5217 
5218    {
5219       test_ = "Row-major columns() function (lambda expression)";
5220 
5221       initialize();
5222 
5223       {
5224          ASMT sm1 = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
5225          USMT sm2 = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
5226          auto cs1 = columns( sm1, []( size_t i ){ return i*2UL; }, 4UL );
5227          auto cs2 = columns( sm2, []( size_t i ){ return i*2UL; }, 4UL );
5228 
5229          if( cs1 != cs2 ) {
5230             std::ostringstream oss;
5231             oss << " Test: " << test_ << "\n"
5232                 << " Error: Rows function failed\n"
5233                 << " Details:\n"
5234                 << "   Result:\n" << cs1 << "\n"
5235                 << "   Expected result:\n" << cs2 << "\n";
5236             throw std::runtime_error( oss.str() );
5237          }
5238 
5239          if( cs1(1,1) != cs2(1,1) ) {
5240             std::ostringstream oss;
5241             oss << " Test: " << test_ << "\n"
5242                 << " Error: Function call operator access failed\n"
5243                 << " Details:\n"
5244                 << "   Result: " << cs1(1,1) << "\n"
5245                 << "   Expected result: " << cs2(1,1) << "\n";
5246             throw std::runtime_error( oss.str() );
5247          }
5248 
5249          if( *cs1.begin( 1UL ) != *cs2.begin( 1UL ) ) {
5250             std::ostringstream oss;
5251             oss << " Test: " << test_ << "\n"
5252                 << " Error: Iterator access failed\n"
5253                 << " Details:\n"
5254                 << "   Result: " << *cs1.begin( 1UL ) << "\n"
5255                 << "   Expected result: " << *cs2.begin( 1UL ) << "\n";
5256             throw std::runtime_error( oss.str() );
5257          }
5258       }
5259 
5260       try {
5261          ASMT sm1 = submatrix<aligned>( mat1_, 8UL, 16UL, 8UL, 16UL );
5262          auto cs  = columns( sm1, []( size_t ){ return 16UL; }, 1UL );
5263 
5264          std::ostringstream oss;
5265          oss << " Test: " << test_ << "\n"
5266              << " Error: Setup of out-of-bounds column selection succeeded\n"
5267              << " Details:\n"
5268              << "   Result:\n" << cs << "\n";
5269          throw std::runtime_error( oss.str() );
5270       }
5271       catch( std::invalid_argument& ) {}
5272    }
5273 
5274 
5275    //=====================================================================================
5276    // Column-major matrix tests (initializer_list)
5277    //=====================================================================================
5278 
5279    {
5280       test_ = "Column-major columns() function (initializer_list)";
5281 
5282       initialize();
5283 
5284       {
5285          AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
5286          UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
5287          auto cs1 = columns( sm1, { 0UL, 2UL, 4UL, 6UL } );
5288          auto cs2 = columns( sm2, { 0UL, 2UL, 4UL, 6UL } );
5289 
5290          if( cs1 != cs2 ) {
5291             std::ostringstream oss;
5292             oss << " Test: " << test_ << "\n"
5293                 << " Error: Rows function failed\n"
5294                 << " Details:\n"
5295                 << "   Result:\n" << cs1 << "\n"
5296                 << "   Expected result:\n" << cs2 << "\n";
5297             throw std::runtime_error( oss.str() );
5298          }
5299 
5300          if( cs1(1,1) != cs2(1,1) ) {
5301             std::ostringstream oss;
5302             oss << " Test: " << test_ << "\n"
5303                 << " Error: Function call operator access failed\n"
5304                 << " Details:\n"
5305                 << "   Result: " << cs1(1,1) << "\n"
5306                 << "   Expected result: " << cs2(1,1) << "\n";
5307             throw std::runtime_error( oss.str() );
5308          }
5309 
5310          if( *cs1.begin( 1UL ) != *cs2.begin( 1UL ) ) {
5311             std::ostringstream oss;
5312             oss << " Test: " << test_ << "\n"
5313                 << " Error: Iterator access failed\n"
5314                 << " Details:\n"
5315                 << "   Result: " << *cs1.begin( 1UL ) << "\n"
5316                 << "   Expected result: " << *cs2.begin( 1UL ) << "\n";
5317             throw std::runtime_error( oss.str() );
5318          }
5319       }
5320 
5321       try {
5322          AOSMT sm1 = submatrix<aligned>( tmat1_, 16UL, 8UL, 16UL, 8UL );
5323          auto cs  = columns( sm1, { 8UL } );
5324 
5325          std::ostringstream oss;
5326          oss << " Test: " << test_ << "\n"
5327              << " Error: Setup of out-of-bounds column selection succeeded\n"
5328              << " Details:\n"
5329              << "   Result:\n" << cs << "\n";
5330          throw std::runtime_error( oss.str() );
5331       }
5332       catch( std::invalid_argument& ) {}
5333    }
5334 
5335 
5336    //=====================================================================================
5337    // Column-major matrix tests (std::array)
5338    //=====================================================================================
5339 
5340    {
5341       test_ = "Column-major columns() function (std::array)";
5342 
5343       initialize();
5344 
5345       {
5346          std::array<int,4UL> indices{ 0UL, 2UL, 4UL, 6UL };
5347 
5348          AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
5349          UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
5350          auto cs1 = columns( sm1, indices );
5351          auto cs2 = columns( sm2, indices );
5352 
5353          if( cs1 != cs2 ) {
5354             std::ostringstream oss;
5355             oss << " Test: " << test_ << "\n"
5356                 << " Error: Rows function failed\n"
5357                 << " Details:\n"
5358                 << "   Result:\n" << cs1 << "\n"
5359                 << "   Expected result:\n" << cs2 << "\n";
5360             throw std::runtime_error( oss.str() );
5361          }
5362 
5363          if( cs1(1,1) != cs2(1,1) ) {
5364             std::ostringstream oss;
5365             oss << " Test: " << test_ << "\n"
5366                 << " Error: Function call operator access failed\n"
5367                 << " Details:\n"
5368                 << "   Result: " << cs1(1,1) << "\n"
5369                 << "   Expected result: " << cs2(1,1) << "\n";
5370             throw std::runtime_error( oss.str() );
5371          }
5372 
5373          if( *cs1.begin( 1UL ) != *cs2.begin( 1UL ) ) {
5374             std::ostringstream oss;
5375             oss << " Test: " << test_ << "\n"
5376                 << " Error: Iterator access failed\n"
5377                 << " Details:\n"
5378                 << "   Result: " << *cs1.begin( 1UL ) << "\n"
5379                 << "   Expected result: " << *cs2.begin( 1UL ) << "\n";
5380             throw std::runtime_error( oss.str() );
5381          }
5382       }
5383 
5384       try {
5385          std::array<int,1UL> indices{ 8UL };
5386 
5387          AOSMT sm1 = submatrix<aligned>( tmat1_, 16UL, 8UL, 16UL, 8UL );
5388          auto cs  = columns( sm1, indices );
5389 
5390          std::ostringstream oss;
5391          oss << " Test: " << test_ << "\n"
5392              << " Error: Setup of out-of-bounds column selection succeeded\n"
5393              << " Details:\n"
5394              << "   Result:\n" << cs << "\n";
5395          throw std::runtime_error( oss.str() );
5396       }
5397       catch( std::invalid_argument& ) {}
5398    }
5399 
5400 
5401    //=====================================================================================
5402    // Column-major matrix tests (lambda expression)
5403    //=====================================================================================
5404 
5405    {
5406       test_ = "Column-major columns() function (lambda expression)";
5407 
5408       initialize();
5409 
5410       {
5411          AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
5412          UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
5413          auto cs1 = columns( sm1, []( size_t i ){ return i*2UL; }, 4UL );
5414          auto cs2 = columns( sm2, []( size_t i ){ return i*2UL; }, 4UL );
5415 
5416          if( cs1 != cs2 ) {
5417             std::ostringstream oss;
5418             oss << " Test: " << test_ << "\n"
5419                 << " Error: Rows function failed\n"
5420                 << " Details:\n"
5421                 << "   Result:\n" << cs1 << "\n"
5422                 << "   Expected result:\n" << cs2 << "\n";
5423             throw std::runtime_error( oss.str() );
5424          }
5425 
5426          if( cs1(1,1) != cs2(1,1) ) {
5427             std::ostringstream oss;
5428             oss << " Test: " << test_ << "\n"
5429                 << " Error: Function call operator access failed\n"
5430                 << " Details:\n"
5431                 << "   Result: " << cs1(1,1) << "\n"
5432                 << "   Expected result: " << cs2(1,1) << "\n";
5433             throw std::runtime_error( oss.str() );
5434          }
5435 
5436          if( *cs1.begin( 1UL ) != *cs2.begin( 1UL ) ) {
5437             std::ostringstream oss;
5438             oss << " Test: " << test_ << "\n"
5439                 << " Error: Iterator access failed\n"
5440                 << " Details:\n"
5441                 << "   Result: " << *cs1.begin( 1UL ) << "\n"
5442                 << "   Expected result: " << *cs2.begin( 1UL ) << "\n";
5443             throw std::runtime_error( oss.str() );
5444          }
5445       }
5446 
5447       try {
5448          AOSMT sm1 = submatrix<aligned>( tmat1_, 16UL, 8UL, 16UL, 8UL );
5449          auto cs  = columns( sm1, []( size_t ){ return 8UL; }, 1UL );
5450 
5451          std::ostringstream oss;
5452          oss << " Test: " << test_ << "\n"
5453              << " Error: Setup of out-of-bounds column selection succeeded\n"
5454              << " Details:\n"
5455              << "   Result:\n" << cs << "\n";
5456          throw std::runtime_error( oss.str() );
5457       }
5458       catch( std::invalid_argument& ) {}
5459    }
5460 }
5461 //*************************************************************************************************
5462 
5463 
5464 //*************************************************************************************************
5465 /*!\brief Test of the \c band() function with the Submatrix class template.
5466 //
5467 // \return void
5468 // \exception std::runtime_error Error detected.
5469 //
5470 // This function performs a test of the \c band() function with the Submatrix specialization.
5471 // In case an error is detected, a \a std::runtime_error exception is thrown.
5472 */
testBand()5473 void DenseAlignedTest::testBand()
5474 {
5475    using blaze::submatrix;
5476    using blaze::band;
5477    using blaze::aligned;
5478    using blaze::unaligned;
5479 
5480 
5481    //=====================================================================================
5482    // Row-major matrix tests
5483    //=====================================================================================
5484 
5485    {
5486       test_ = "Row-major band() function";
5487 
5488       initialize();
5489 
5490       {
5491          ASMT sm1  = submatrix<aligned>  ( mat1_, 8UL, 16UL, 8UL, 16UL );
5492          USMT sm2  = submatrix<unaligned>( mat2_, 8UL, 16UL, 8UL, 16UL );
5493          auto b1 = band( sm1, 1L );
5494          auto b2 = band( sm2, 1L );
5495 
5496          if( b1 != b2 ) {
5497             std::ostringstream oss;
5498             oss << " Test: " << test_ << "\n"
5499                 << " Error: Band function failed\n"
5500                 << " Details:\n"
5501                 << "   Result:\n" << b1 << "\n"
5502                 << "   Expected result:\n" << b2 << "\n";
5503             throw std::runtime_error( oss.str() );
5504          }
5505 
5506          if( b1[1] != b2[1] ) {
5507             std::ostringstream oss;
5508             oss << " Test: " << test_ << "\n"
5509                 << " Error: Subscript operator access failed\n"
5510                 << " Details:\n"
5511                 << "   Result: " << b1[1] << "\n"
5512                 << "   Expected result: " << b2[1] << "\n";
5513             throw std::runtime_error( oss.str() );
5514          }
5515 
5516          if( *b1.begin() != *b2.begin() ) {
5517             std::ostringstream oss;
5518             oss << " Test: " << test_ << "\n"
5519                 << " Error: Iterator access failed\n"
5520                 << " Details:\n"
5521                 << "   Result: " << *b1.begin() << "\n"
5522                 << "   Expected result: " << *b2.begin() << "\n";
5523             throw std::runtime_error( oss.str() );
5524          }
5525       }
5526 
5527       try {
5528          ASMT sm = submatrix<aligned>( mat1_, 8UL, 16UL, 8UL, 16UL );
5529          auto b8 = band( sm, -8L );
5530 
5531          std::ostringstream oss;
5532          oss << " Test: " << test_ << "\n"
5533              << " Error: Setup of out-of-bounds band succeeded\n"
5534              << " Details:\n"
5535              << "   Result:\n" << b8 << "\n";
5536          throw std::runtime_error( oss.str() );
5537       }
5538       catch( std::invalid_argument& ) {}
5539    }
5540 
5541 
5542    //=====================================================================================
5543    // Column-major matrix tests
5544    //=====================================================================================
5545 
5546    {
5547       test_ = "Column-major band() function";
5548 
5549       initialize();
5550 
5551       {
5552          AOSMT sm1 = submatrix<aligned>  ( tmat1_, 16UL, 8UL, 16UL, 8UL );
5553          UOSMT sm2 = submatrix<unaligned>( tmat2_, 16UL, 8UL, 16UL, 8UL );
5554          auto  b1  = band( sm1, 1L );
5555          auto  b2  = band( sm2, 1L );
5556 
5557          if( b1 != b2 ) {
5558             std::ostringstream oss;
5559             oss << " Test: " << test_ << "\n"
5560                 << " Error: Band function failed\n"
5561                 << " Details:\n"
5562                 << "   Result:\n" << b1 << "\n"
5563                 << "   Expected result:\n" << b2 << "\n";
5564             throw std::runtime_error( oss.str() );
5565          }
5566 
5567          if( b1[1] != b2[1] ) {
5568             std::ostringstream oss;
5569             oss << " Test: " << test_ << "\n"
5570                 << " Error: Subscript operator access failed\n"
5571                 << " Details:\n"
5572                 << "   Result: " << b1[1] << "\n"
5573                 << "   Expected result: " << b2[1] << "\n";
5574             throw std::runtime_error( oss.str() );
5575          }
5576 
5577          if( *b1.begin() != *b2.begin() ) {
5578             std::ostringstream oss;
5579             oss << " Test: " << test_ << "\n"
5580                 << " Error: Iterator access failed\n"
5581                 << " Details:\n"
5582                 << "   Result: " << *b1.begin() << "\n"
5583                 << "   Expected result: " << *b2.begin() << "\n";
5584             throw std::runtime_error( oss.str() );
5585          }
5586       }
5587 
5588       try {
5589          AOSMT sm1 = submatrix<aligned>( tmat1_, 16UL, 8UL, 16UL, 8UL );
5590          auto  b8  = band( sm1, 8L );
5591 
5592          std::ostringstream oss;
5593          oss << " Test: " << test_ << "\n"
5594              << " Error: Setup of out-of-bounds band succeeded\n"
5595              << " Details:\n"
5596              << "   Result:\n" << b8 << "\n";
5597          throw std::runtime_error( oss.str() );
5598       }
5599       catch( std::invalid_argument& ) {}
5600    }
5601 }
5602 //*************************************************************************************************
5603 
5604 
5605 
5606 
5607 //=================================================================================================
5608 //
5609 //  UTILITY FUNCTIONS
5610 //
5611 //=================================================================================================
5612 
5613 //*************************************************************************************************
5614 /*!\brief Initialization of all member matrices.
5615 //
5616 // \return void
5617 // \exception std::runtime_error Error detected.
5618 //
5619 // This function initializes all member matrices to specific predetermined values.
5620 */
initialize()5621 void DenseAlignedTest::initialize()
5622 {
5623    // Initializing the row-major dynamic matrices
5624    randomize( mat1_, int(randmin), int(randmax) );
5625    mat2_ = mat1_;
5626 
5627    // Initializing the column-major dynamic matrices
5628    randomize( tmat1_, int(randmin), int(randmax) );
5629    tmat2_ = tmat1_;
5630 }
5631 //*************************************************************************************************
5632 
5633 } // namespace submatrix
5634 
5635 } // namespace views
5636 
5637 } // namespace mathtest
5638 
5639 } // namespace blazetest
5640 
5641 
5642 
5643 
5644 //=================================================================================================
5645 //
5646 //  MAIN FUNCTION
5647 //
5648 //=================================================================================================
5649 
5650 //*************************************************************************************************
main()5651 int main()
5652 {
5653    std::cout << "   Running Submatrix dense aligned test (part 2)..." << std::endl;
5654 
5655    try
5656    {
5657       RUN_SUBMATRIX_DENSEALIGNED_TEST;
5658    }
5659    catch( std::exception& ex ) {
5660       std::cerr << "\n\n ERROR DETECTED during Submatrix dense aligned test (part 2):\n"
5661                 << ex.what() << "\n";
5662       return EXIT_FAILURE;
5663    }
5664 
5665    return EXIT_SUCCESS;
5666 }
5667 //*************************************************************************************************
5668