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