1 //=================================================================================================
2 /*!
3 //  \file src/mathtest/views/rows/DenseGeneralTest1.cpp
4 //  \brief Source file for the Rows dense general test (part 1)
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/CompressedMatrix.h>
44 #include <blaze/math/CustomMatrix.h>
45 #include <blaze/math/DynamicMatrix.h>
46 #include <blaze/math/DynamicVector.h>
47 #include <blaze/util/Memory.h>
48 #include <blaze/util/policies/Deallocate.h>
49 #include <blazetest/mathtest/views/rows/DenseGeneralTest.h>
50 
51 #ifdef BLAZE_USE_HPX_THREADS
52 #  include <hpx/hpx_main.hpp>
53 #endif
54 
55 
56 namespace blazetest {
57 
58 namespace mathtest {
59 
60 namespace views {
61 
62 namespace rows {
63 
64 //=================================================================================================
65 //
66 //  CONSTRUCTORS
67 //
68 //=================================================================================================
69 
70 //*************************************************************************************************
71 /*!\brief Constructor for the Rows dense general test.
72 //
73 // \exception std::runtime_error Operation error detected.
74 */
DenseGeneralTest()75 DenseGeneralTest::DenseGeneralTest()
76    : mat_ ( 5UL, 4UL )
77    , tmat_( 5UL, 4UL )
78 {
79    testConstructors();
80    testAssignment();
81    testAddAssign();
82    testSubAssign();
83    testSchurAssign();
84    testMultAssign();
85 }
86 //*************************************************************************************************
87 
88 
89 
90 
91 //=================================================================================================
92 //
93 //  TEST FUNCTIONS
94 //
95 //=================================================================================================
96 
97 //*************************************************************************************************
98 /*!\brief Test of the Rows constructors.
99 //
100 // \return void
101 // \exception std::runtime_error Error detected.
102 //
103 // This function performs a test of all constructors of the Rows specialization. In case
104 // an error is detected, a \a std::runtime_error exception is thrown.
105 */
testConstructors()106 void DenseGeneralTest::testConstructors()
107 {
108    using blaze::index_sequence;
109    using blaze::initializer_list;
110 
111 
112    //=====================================================================================
113    // Row-major setup via index_sequence
114    //=====================================================================================
115 
116    {
117       test_ = "Row-major Rows constructor (index_sequence)";
118 
119       initialize();
120 
121       // Setup of a regular row selection
122       {
123          auto rs = blaze::rows( mat_, index_sequence<0,4,2>() );
124 
125          if( rs.rows() != 3UL || rs.columns() != mat_.columns() ||
126              rs(0,0) != mat_(0,0) || rs(0,1) != mat_(0,1) || rs(0,2) != mat_(0,2) || rs(0,3) != mat_(0,3) ||
127              rs(1,0) != mat_(4,0) || rs(1,1) != mat_(4,1) || rs(1,2) != mat_(4,2) || rs(1,3) != mat_(4,3) ||
128              rs(2,0) != mat_(2,0) || rs(2,1) != mat_(2,1) || rs(2,2) != mat_(2,2) || rs(2,3) != mat_(2,3) ) {
129             std::ostringstream oss;
130             oss << " Test: " << test_ << "\n"
131                 << " Error: Setup of row selection failed\n"
132                 << " Details:\n"
133                 << "   Result:\n" << rs << "\n";
134             throw std::runtime_error( oss.str() );
135          }
136       }
137 
138       // Trying to setup an out-of-bounds row selection
139       try {
140          auto rs = blaze::rows( mat_, index_sequence<5>() );
141 
142          std::ostringstream oss;
143          oss << " Test: " << test_ << "\n"
144              << " Error: Setup of out-of-bounds row selection succeeded\n"
145              << " Details:\n"
146              << "   Result:\n" << rs << "\n";
147          throw std::runtime_error( oss.str() );
148       }
149       catch( std::invalid_argument& ) {}
150 
151       // Setup of a row selection on a compile-time row selection
152       {
153          auto rs1 = blaze::rows( mat_, index_sequence<0,4,2>() );
154          auto rs2 = blaze::rows( rs1, index_sequence<2,1>() );
155 
156          if( rs2.rows() != 2UL || rs2.columns() != mat_.columns() ||
157              rs2(0,0) != mat_(2,0) || rs2(0,1) != mat_(2,1) || rs2(0,2) != mat_(2,2) || rs2(0,3) != mat_(2,3) ||
158              rs2(1,0) != mat_(4,0) || rs2(1,1) != mat_(4,1) || rs2(1,2) != mat_(4,2) || rs2(1,3) != mat_(4,3) ) {
159             std::ostringstream oss;
160             oss << " Test: " << test_ << "\n"
161                 << " Error: Setup of row selection failed\n"
162                 << " Details:\n"
163                 << "   Result:\n" << rs2 << "\n";
164             throw std::runtime_error( oss.str() );
165          }
166       }
167 
168       // Setup of a row selection on an explicit row selection
169       {
170          auto rs1 = blaze::rows( mat_, { 0, 4, 2 } );
171          auto rs2 = blaze::rows( rs1, index_sequence<2,1>() );
172 
173          if( rs2.rows() != 2UL || rs2.columns() != mat_.columns() ||
174              rs2(0,0) != mat_(2,0) || rs2(0,1) != mat_(2,1) || rs2(0,2) != mat_(2,2) || rs2(0,3) != mat_(2,3) ||
175              rs2(1,0) != mat_(4,0) || rs2(1,1) != mat_(4,1) || rs2(1,2) != mat_(4,2) || rs2(1,3) != mat_(4,3) ) {
176             std::ostringstream oss;
177             oss << " Test: " << test_ << "\n"
178                 << " Error: Setup of row selection failed\n"
179                 << " Details:\n"
180                 << "   Result:\n" << rs2 << "\n";
181             throw std::runtime_error( oss.str() );
182          }
183       }
184 
185       // Setup of a row selection on an implicit row selection
186       {
187          const std::array<size_t,3UL> indices{ 0, 4, 2 };
188          auto rs1 = blaze::rows( mat_, [indices]( size_t i ){ return indices[i]; }, 3UL );
189          auto rs2 = blaze::rows( rs1, index_sequence<2,1>() );
190 
191          if( rs2.rows() != 2UL || rs2.columns() != mat_.columns() ||
192              rs2(0,0) != mat_(2,0) || rs2(0,1) != mat_(2,1) || rs2(0,2) != mat_(2,2) || rs2(0,3) != mat_(2,3) ||
193              rs2(1,0) != mat_(4,0) || rs2(1,1) != mat_(4,1) || rs2(1,2) != mat_(4,2) || rs2(1,3) != mat_(4,3) ) {
194             std::ostringstream oss;
195             oss << " Test: " << test_ << "\n"
196                 << " Error: Setup of row selection failed\n"
197                 << " Details:\n"
198                 << "   Result:\n" << rs2 << "\n";
199             throw std::runtime_error( oss.str() );
200          }
201       }
202    }
203 
204 
205    //=====================================================================================
206    // Row-major setup via initializer_list
207    //=====================================================================================
208 
209    {
210       test_ = "Row-major Rows constructor (initializer_list)";
211 
212       initialize();
213 
214       // Setup of empty row selection
215       {
216          std::initializer_list<size_t> indices{};
217          auto rs = blaze::rows( mat_, indices );
218 
219          if( rs.rows() != 0UL || rs.columns() != mat_.columns() ) {
220             std::ostringstream oss;
221             oss << " Test: " << test_ << "\n"
222                 << " Error: Setup of empty row selection failed\n"
223                 << " Details:\n"
224                 << "   Result:\n" << rs << "\n";
225             throw std::runtime_error( oss.str() );
226          }
227       }
228 
229       // Setup of a regular row selection
230       {
231          auto rs = blaze::rows( mat_, { 0, 4, 2 } );
232 
233          if( rs.rows() != 3UL || rs.columns() != mat_.columns() ||
234              rs(0,0) != mat_(0,0) || rs(0,1) != mat_(0,1) || rs(0,2) != mat_(0,2) || rs(0,3) != mat_(0,3) ||
235              rs(1,0) != mat_(4,0) || rs(1,1) != mat_(4,1) || rs(1,2) != mat_(4,2) || rs(1,3) != mat_(4,3) ||
236              rs(2,0) != mat_(2,0) || rs(2,1) != mat_(2,1) || rs(2,2) != mat_(2,2) || rs(2,3) != mat_(2,3) ) {
237             std::ostringstream oss;
238             oss << " Test: " << test_ << "\n"
239                 << " Error: Setup of row selection failed\n"
240                 << " Details:\n"
241                 << "   Result:\n" << rs << "\n";
242             throw std::runtime_error( oss.str() );
243          }
244       }
245 
246       // Trying to setup an out-of-bounds row selection
247       try {
248          auto rs = blaze::rows( mat_, { 5 } );
249 
250          std::ostringstream oss;
251          oss << " Test: " << test_ << "\n"
252              << " Error: Setup of out-of-bounds row selection succeeded\n"
253              << " Details:\n"
254              << "   Result:\n" << rs << "\n";
255          throw std::runtime_error( oss.str() );
256       }
257       catch( std::invalid_argument& ) {}
258 
259       // Setup of a row selection on a compile-time row selection
260       {
261          auto rs1 = blaze::rows( mat_, index_sequence<0,4,2>() );
262          auto rs2 = blaze::rows( rs1, { 2, 1 } );
263 
264          if( rs2.rows() != 2UL || rs2.columns() != mat_.columns() ||
265              rs2(0,0) != mat_(2,0) || rs2(0,1) != mat_(2,1) || rs2(0,2) != mat_(2,2) || rs2(0,3) != mat_(2,3) ||
266              rs2(1,0) != mat_(4,0) || rs2(1,1) != mat_(4,1) || rs2(1,2) != mat_(4,2) || rs2(1,3) != mat_(4,3) ) {
267             std::ostringstream oss;
268             oss << " Test: " << test_ << "\n"
269                 << " Error: Setup of row selection failed\n"
270                 << " Details:\n"
271                 << "   Result:\n" << rs2 << "\n";
272             throw std::runtime_error( oss.str() );
273          }
274       }
275 
276       // Setup of a row selection on an explicit row selection
277       {
278          auto rs1 = blaze::rows( mat_, { 0, 4, 2 } );
279          auto rs2 = blaze::rows( rs1, { 2, 1 } );
280 
281          if( rs2.rows() != 2UL || rs2.columns() != mat_.columns() ||
282              rs2(0,0) != mat_(2,0) || rs2(0,1) != mat_(2,1) || rs2(0,2) != mat_(2,2) || rs2(0,3) != mat_(2,3) ||
283              rs2(1,0) != mat_(4,0) || rs2(1,1) != mat_(4,1) || rs2(1,2) != mat_(4,2) || rs2(1,3) != mat_(4,3) ) {
284             std::ostringstream oss;
285             oss << " Test: " << test_ << "\n"
286                 << " Error: Setup of row selection failed\n"
287                 << " Details:\n"
288                 << "   Result:\n" << rs2 << "\n";
289             throw std::runtime_error( oss.str() );
290          }
291       }
292 
293       // Setup of a row selection on an implicit row selection
294       {
295          const std::array<size_t,3UL> indices{ 0, 4, 2 };
296          auto rs1 = blaze::rows( mat_, [indices]( size_t i ){ return indices[i]; }, 3UL );
297          auto rs2 = blaze::rows( rs1, { 2, 1 } );
298 
299          if( rs2.rows() != 2UL || rs2.columns() != mat_.columns() ||
300              rs2(0,0) != mat_(2,0) || rs2(0,1) != mat_(2,1) || rs2(0,2) != mat_(2,2) || rs2(0,3) != mat_(2,3) ||
301              rs2(1,0) != mat_(4,0) || rs2(1,1) != mat_(4,1) || rs2(1,2) != mat_(4,2) || rs2(1,3) != mat_(4,3) ) {
302             std::ostringstream oss;
303             oss << " Test: " << test_ << "\n"
304                 << " Error: Setup of row selection failed\n"
305                 << " Details:\n"
306                 << "   Result:\n" << rs2 << "\n";
307             throw std::runtime_error( oss.str() );
308          }
309       }
310    }
311 
312 
313    //=====================================================================================
314    // Row-major setup via std::vector
315    //=====================================================================================
316 
317    {
318       test_ = "Row-major Rows constructor (std::vector)";
319 
320       initialize();
321 
322       // Setup of empty row selection
323       {
324          std::vector<size_t> indices;
325          auto rs = blaze::rows( mat_, indices );
326 
327          if( rs.rows() != 0UL || rs.columns() != mat_.columns() ) {
328             std::ostringstream oss;
329             oss << " Test: " << test_ << "\n"
330                 << " Error: Setup of empty row selection failed\n"
331                 << " Details:\n"
332                 << "   Result:\n" << rs << "\n";
333             throw std::runtime_error( oss.str() );
334          }
335       }
336 
337       // Setup of a regular row selection
338       {
339          std::vector<size_t> indices{ 0, 4, 2 };
340          auto rs = blaze::rows( mat_, indices );
341 
342          if( rs.rows() != 3UL || rs.columns() != mat_.columns() ||
343              rs(0,0) != mat_(0,0) || rs(0,1) != mat_(0,1) || rs(0,2) != mat_(0,2) || rs(0,3) != mat_(0,3) ||
344              rs(1,0) != mat_(4,0) || rs(1,1) != mat_(4,1) || rs(1,2) != mat_(4,2) || rs(1,3) != mat_(4,3) ||
345              rs(2,0) != mat_(2,0) || rs(2,1) != mat_(2,1) || rs(2,2) != mat_(2,2) || rs(2,3) != mat_(2,3) ) {
346             std::ostringstream oss;
347             oss << " Test: " << test_ << "\n"
348                 << " Error: Setup of row selection failed\n"
349                 << " Details:\n"
350                 << "   Result:\n" << rs << "\n";
351             throw std::runtime_error( oss.str() );
352          }
353       }
354 
355       // Trying to setup an out-of-bounds row selection
356       try {
357          std::vector<size_t> indices{ 5 };
358          auto rs = blaze::rows( mat_, indices );
359 
360          std::ostringstream oss;
361          oss << " Test: " << test_ << "\n"
362              << " Error: Setup of out-of-bounds row selection succeeded\n"
363              << " Details:\n"
364              << "   Result:\n" << rs << "\n";
365          throw std::runtime_error( oss.str() );
366       }
367       catch( std::invalid_argument& ) {}
368 
369       // Setup of a row selection on a compile-time row selection
370       {
371          auto rs1 = blaze::rows( mat_, index_sequence<0,4,2>() );
372 
373          const std::vector<size_t> indices{ 2, 1 };
374          auto rs2 = blaze::rows( rs1, indices );
375 
376          if( rs2.rows() != 2UL || rs2.columns() != mat_.columns() ||
377              rs2(0,0) != mat_(2,0) || rs2(0,1) != mat_(2,1) || rs2(0,2) != mat_(2,2) || rs2(0,3) != mat_(2,3) ||
378              rs2(1,0) != mat_(4,0) || rs2(1,1) != mat_(4,1) || rs2(1,2) != mat_(4,2) || rs2(1,3) != mat_(4,3) ) {
379             std::ostringstream oss;
380             oss << " Test: " << test_ << "\n"
381                 << " Error: Setup of row selection failed\n"
382                 << " Details:\n"
383                 << "   Result:\n" << rs2 << "\n";
384             throw std::runtime_error( oss.str() );
385          }
386       }
387 
388       // Setup of a row selection on an explicit row selection
389       {
390          auto rs1 = blaze::rows( mat_, { 0, 4, 2 } );
391 
392          const std::vector<size_t> indices{ 2, 1 };
393          auto rs2 = blaze::rows( rs1, indices );
394 
395          if( rs2.rows() != 2UL || rs2.columns() != mat_.columns() ||
396              rs2(0,0) != mat_(2,0) || rs2(0,1) != mat_(2,1) || rs2(0,2) != mat_(2,2) || rs2(0,3) != mat_(2,3) ||
397              rs2(1,0) != mat_(4,0) || rs2(1,1) != mat_(4,1) || rs2(1,2) != mat_(4,2) || rs2(1,3) != mat_(4,3) ) {
398             std::ostringstream oss;
399             oss << " Test: " << test_ << "\n"
400                 << " Error: Setup of row selection failed\n"
401                 << " Details:\n"
402                 << "   Result:\n" << rs2 << "\n";
403             throw std::runtime_error( oss.str() );
404          }
405       }
406 
407       // Setup of a row selection on an implicit row selection
408       {
409          const std::array<size_t,3UL> indices1{ 0, 4, 2 };
410          auto rs1 = blaze::rows( mat_, [indices1]( size_t i ){ return indices1[i]; }, 3UL );
411 
412          const std::vector<size_t> indices2{ 2, 1 };
413          auto rs2 = blaze::rows( rs1, indices2 );;
414 
415          if( rs2.rows() != 2UL || rs2.columns() != mat_.columns() ||
416              rs2(0,0) != mat_(2,0) || rs2(0,1) != mat_(2,1) || rs2(0,2) != mat_(2,2) || rs2(0,3) != mat_(2,3) ||
417              rs2(1,0) != mat_(4,0) || rs2(1,1) != mat_(4,1) || rs2(1,2) != mat_(4,2) || rs2(1,3) != mat_(4,3) ) {
418             std::ostringstream oss;
419             oss << " Test: " << test_ << "\n"
420                 << " Error: Setup of row selection failed\n"
421                 << " Details:\n"
422                 << "   Result:\n" << rs2 << "\n";
423             throw std::runtime_error( oss.str() );
424          }
425       }
426    }
427 
428 
429    //=====================================================================================
430    // Row-major setup via std::array
431    //=====================================================================================
432 
433    {
434       test_ = "Row-major Rows constructor (std::array)";
435 
436       initialize();
437 
438       // Setup of a regular row selection
439       {
440          std::array<size_t,3UL> indices{ 0, 4, 2 };
441          auto rs = blaze::rows( mat_, indices );
442 
443          if( rs.rows() != 3UL || rs.columns() != mat_.columns() ||
444              rs(0,0) != mat_(0,0) || rs(0,1) != mat_(0,1) || rs(0,2) != mat_(0,2) || rs(0,3) != mat_(0,3) ||
445              rs(1,0) != mat_(4,0) || rs(1,1) != mat_(4,1) || rs(1,2) != mat_(4,2) || rs(1,3) != mat_(4,3) ||
446              rs(2,0) != mat_(2,0) || rs(2,1) != mat_(2,1) || rs(2,2) != mat_(2,2) || rs(2,3) != mat_(2,3) ) {
447             std::ostringstream oss;
448             oss << " Test: " << test_ << "\n"
449                 << " Error: Setup of row selection failed\n"
450                 << " Details:\n"
451                 << "   Result:\n" << rs << "\n";
452             throw std::runtime_error( oss.str() );
453          }
454       }
455 
456       // Trying to setup an out-of-bounds row selection
457       try {
458          std::array<size_t,1UL> indices{ 5 };
459          auto rs = blaze::rows( mat_, indices );
460 
461          std::ostringstream oss;
462          oss << " Test: " << test_ << "\n"
463              << " Error: Setup of out-of-bounds row selection succeeded\n"
464              << " Details:\n"
465              << "   Result:\n" << rs << "\n";
466          throw std::runtime_error( oss.str() );
467       }
468       catch( std::invalid_argument& ) {}
469 
470       // Setup of a row selection on a compile-time row selection
471       {
472          auto rs1 = blaze::rows( mat_, index_sequence<0,4,2>() );
473 
474          const std::array<size_t,2UL> indices{ 2, 1 };
475          auto rs2 = blaze::rows( rs1, indices );
476 
477          if( rs2.rows() != 2UL || rs2.columns() != mat_.columns() ||
478              rs2(0,0) != mat_(2,0) || rs2(0,1) != mat_(2,1) || rs2(0,2) != mat_(2,2) || rs2(0,3) != mat_(2,3) ||
479              rs2(1,0) != mat_(4,0) || rs2(1,1) != mat_(4,1) || rs2(1,2) != mat_(4,2) || rs2(1,3) != mat_(4,3) ) {
480             std::ostringstream oss;
481             oss << " Test: " << test_ << "\n"
482                 << " Error: Setup of row selection failed\n"
483                 << " Details:\n"
484                 << "   Result:\n" << rs2 << "\n";
485             throw std::runtime_error( oss.str() );
486          }
487       }
488 
489       // Setup of a row selection on an explicit row selection
490       {
491          auto rs1 = blaze::rows( mat_, { 0, 4, 2 } );
492 
493          const std::array<size_t,2UL> indices{ 2, 1 };
494          auto rs2 = blaze::rows( rs1, indices );
495 
496          if( rs2.rows() != 2UL || rs2.columns() != mat_.columns() ||
497              rs2(0,0) != mat_(2,0) || rs2(0,1) != mat_(2,1) || rs2(0,2) != mat_(2,2) || rs2(0,3) != mat_(2,3) ||
498              rs2(1,0) != mat_(4,0) || rs2(1,1) != mat_(4,1) || rs2(1,2) != mat_(4,2) || rs2(1,3) != mat_(4,3) ) {
499             std::ostringstream oss;
500             oss << " Test: " << test_ << "\n"
501                 << " Error: Setup of row selection failed\n"
502                 << " Details:\n"
503                 << "   Result:\n" << rs2 << "\n";
504             throw std::runtime_error( oss.str() );
505          }
506       }
507 
508       // Setup of a row selection on an implicit row selection
509       {
510          const std::array<size_t,3UL> indices1{ 0, 4, 2 };
511          auto rs1 = blaze::rows( mat_, [indices1]( size_t i ){ return indices1[i]; }, 3UL );
512 
513          const std::array<size_t,2UL> indices2{ 2, 1 };
514          auto rs2 = blaze::rows( rs1, indices2 );
515 
516          if( rs2.rows() != 2UL || rs2.columns() != mat_.columns() ||
517              rs2(0,0) != mat_(2,0) || rs2(0,1) != mat_(2,1) || rs2(0,2) != mat_(2,2) || rs2(0,3) != mat_(2,3) ||
518              rs2(1,0) != mat_(4,0) || rs2(1,1) != mat_(4,1) || rs2(1,2) != mat_(4,2) || rs2(1,3) != mat_(4,3) ) {
519             std::ostringstream oss;
520             oss << " Test: " << test_ << "\n"
521                 << " Error: Setup of row selection failed\n"
522                 << " Details:\n"
523                 << "   Result:\n" << rs2 << "\n";
524             throw std::runtime_error( oss.str() );
525          }
526       }
527    }
528 
529 
530    //=====================================================================================
531    // Row-major setup via lambda expression
532    //=====================================================================================
533 
534    {
535       test_ = "Row-major Rows constructor (lambda expression)";
536 
537       initialize();
538 
539       // Setup of empty row selection
540       {
541          auto rs = blaze::rows( mat_, []( size_t ){ return 0UL; }, 0UL );
542 
543          if( rs.rows() != 0UL || rs.columns() != mat_.columns() ) {
544             std::ostringstream oss;
545             oss << " Test: " << test_ << "\n"
546                 << " Error: Setup of empty row selection failed\n"
547                 << " Details:\n"
548                 << "   Result:\n" << rs << "\n";
549             throw std::runtime_error( oss.str() );
550          }
551       }
552 
553       // Setup of a regular row selection
554       {
555          const std::array<size_t,3UL> indices{ 0, 4, 2 };
556          auto rs = blaze::rows( mat_, [indices]( size_t i ){ return indices[i]; }, 3UL );
557 
558          if( rs.rows() != 3UL || rs.columns() != mat_.columns() ||
559              rs(0,0) != mat_(0,0) || rs(0,1) != mat_(0,1) || rs(0,2) != mat_(0,2) || rs(0,3) != mat_(0,3) ||
560              rs(1,0) != mat_(4,0) || rs(1,1) != mat_(4,1) || rs(1,2) != mat_(4,2) || rs(1,3) != mat_(4,3) ||
561              rs(2,0) != mat_(2,0) || rs(2,1) != mat_(2,1) || rs(2,2) != mat_(2,2) || rs(2,3) != mat_(2,3) ) {
562             std::ostringstream oss;
563             oss << " Test: " << test_ << "\n"
564                 << " Error: Setup of row selection failed\n"
565                 << " Details:\n"
566                 << "   Result:\n" << rs << "\n";
567             throw std::runtime_error( oss.str() );
568          }
569       }
570 
571       // Trying to setup an out-of-bounds row selection
572       try {
573          auto rs = blaze::rows( mat_, []( size_t ){ return 5UL; }, 1UL );
574 
575          std::ostringstream oss;
576          oss << " Test: " << test_ << "\n"
577              << " Error: Setup of out-of-bounds row selection succeeded\n"
578              << " Details:\n"
579              << "   Result:\n" << rs << "\n";
580          throw std::runtime_error( oss.str() );
581       }
582       catch( std::invalid_argument& ) {}
583 
584       // Setup of a row selection on a compile-time row selection
585       {
586          auto rs1 = blaze::rows( mat_, index_sequence<0,4,2>() );
587 
588          const std::array<size_t,2UL> indices{ 2, 1 };
589          auto rs2 = blaze::rows( rs1, [indices]( size_t i ){ return indices[i]; }, 2UL );
590 
591          if( rs2.rows() != 2UL || rs2.columns() != mat_.columns() ||
592              rs2(0,0) != mat_(2,0) || rs2(0,1) != mat_(2,1) || rs2(0,2) != mat_(2,2) || rs2(0,3) != mat_(2,3) ||
593              rs2(1,0) != mat_(4,0) || rs2(1,1) != mat_(4,1) || rs2(1,2) != mat_(4,2) || rs2(1,3) != mat_(4,3) ) {
594             std::ostringstream oss;
595             oss << " Test: " << test_ << "\n"
596                 << " Error: Setup of row selection failed\n"
597                 << " Details:\n"
598                 << "   Result:\n" << rs2 << "\n";
599             throw std::runtime_error( oss.str() );
600          }
601       }
602 
603       // Setup of a row selection on an explicit row selection
604       {
605          auto rs1 = blaze::rows( mat_, { 0, 4, 2 } );
606 
607          const std::array<size_t,2UL> indices{ 2, 1 };
608          auto rs2 = blaze::rows( rs1, [indices]( size_t i ){ return indices[i]; }, 2UL );
609 
610          if( rs2.rows() != 2UL || rs2.columns() != mat_.columns() ||
611              rs2(0,0) != mat_(2,0) || rs2(0,1) != mat_(2,1) || rs2(0,2) != mat_(2,2) || rs2(0,3) != mat_(2,3) ||
612              rs2(1,0) != mat_(4,0) || rs2(1,1) != mat_(4,1) || rs2(1,2) != mat_(4,2) || rs2(1,3) != mat_(4,3) ) {
613             std::ostringstream oss;
614             oss << " Test: " << test_ << "\n"
615                 << " Error: Setup of row selection failed\n"
616                 << " Details:\n"
617                 << "   Result:\n" << rs2 << "\n";
618             throw std::runtime_error( oss.str() );
619          }
620       }
621 
622       // Setup of a row selection on an implicit row selection
623       {
624          const std::array<size_t,3UL> indices1{ 0, 4, 2 };
625          auto rs1 = blaze::rows( mat_, [indices1]( size_t i ){ return indices1[i]; }, 3UL );
626 
627          const std::array<size_t,2UL> indices2{ 2, 1 };
628          auto rs2 = blaze::rows( rs1, [indices2]( size_t i ){ return indices2[i]; }, 2UL );
629 
630          if( rs2.rows() != 2UL || rs2.columns() != mat_.columns() ||
631              rs2(0,0) != mat_(2,0) || rs2(0,1) != mat_(2,1) || rs2(0,2) != mat_(2,2) || rs2(0,3) != mat_(2,3) ||
632              rs2(1,0) != mat_(4,0) || rs2(1,1) != mat_(4,1) || rs2(1,2) != mat_(4,2) || rs2(1,3) != mat_(4,3) ) {
633             std::ostringstream oss;
634             oss << " Test: " << test_ << "\n"
635                 << " Error: Setup of row selection failed\n"
636                 << " Details:\n"
637                 << "   Result:\n" << rs2 << "\n";
638             throw std::runtime_error( oss.str() );
639          }
640       }
641    }
642 
643 
644    //=====================================================================================
645    // Row-major setup of random in-bounds element selection
646    //=====================================================================================
647 
648    {
649       test_ = "Row-major Rows constructor (stress test)";
650 
651       initialize();
652 
653       for( size_t rep=0UL; rep<100UL; ++rep )
654       {
655          blaze::DynamicVector<size_t> indices( blaze::rand<size_t>( 1UL, 20UL ) );
656          randomize( indices, 0UL, mat_.rows()-1UL );
657          auto rs = blaze::rows( mat_, indices.data(), indices.size() );
658 
659          for( size_t i=0UL; i<rs.rows(); ++i ) {
660             for( size_t j=0UL; j<rs.columns(); ++j ) {
661                if( rs(i,j) != mat_(indices[i],j) ) {
662                   std::ostringstream oss;
663                   oss << " Test: " << test_ << "\n"
664                       << " Error: Setup of row selection failed\n"
665                       << " Details:\n"
666                       << "   Indices:\n" << indices << "\n"
667                       << "   Row selection:\n" << rs << "\n"
668                       << "   Matrix:\n" << mat_ << "\n";
669                   throw std::runtime_error( oss.str() );
670                }
671             }
672          }
673       }
674    }
675 
676 
677    //=====================================================================================
678    // Column-major setup via index_sequence
679    //=====================================================================================
680 
681    {
682       test_ = "Column-major Rows constructor (index_sequence)";
683 
684       initialize();
685 
686       // Setup of a regular row selection
687       {
688          auto rs = blaze::rows( tmat_, index_sequence<0,4,2>() );
689 
690          if( rs.rows() != 3UL || rs.columns() != tmat_.columns() ||
691              rs(0,0) != tmat_(0,0) || rs(0,1) != tmat_(0,1) || rs(0,2) != tmat_(0,2) || rs(0,3) != tmat_(0,3) ||
692              rs(1,0) != tmat_(4,0) || rs(1,1) != tmat_(4,1) || rs(1,2) != tmat_(4,2) || rs(1,3) != tmat_(4,3) ||
693              rs(2,0) != tmat_(2,0) || rs(2,1) != tmat_(2,1) || rs(2,2) != tmat_(2,2) || rs(2,3) != tmat_(2,3) ) {
694             std::ostringstream oss;
695             oss << " Test: " << test_ << "\n"
696                 << " Error: Setup of row selection failed\n"
697                 << " Details:\n"
698                 << "   Result:\n" << rs << "\n";
699             throw std::runtime_error( oss.str() );
700          }
701       }
702 
703       // Trying to setup an out-of-bounds row selection
704       try {
705          auto rs = blaze::rows( tmat_, index_sequence<5>() );
706 
707          std::ostringstream oss;
708          oss << " Test: " << test_ << "\n"
709              << " Error: Setup of out-of-bounds row selection succeeded\n"
710              << " Details:\n"
711              << "   Result:\n" << rs << "\n";
712          throw std::runtime_error( oss.str() );
713       }
714       catch( std::invalid_argument& ) {}
715 
716       // Setup of a row selection on a compile-time row selection
717       {
718          auto rs1 = blaze::rows( tmat_, index_sequence<0,4,2>() );
719          auto rs2 = blaze::rows( rs1, index_sequence<2,1>() );
720 
721          if( rs2.rows() != 2UL || rs2.columns() != tmat_.columns() ||
722              rs2(0,0) != tmat_(2,0) || rs2(0,1) != tmat_(2,1) || rs2(0,2) != tmat_(2,2) || rs2(0,3) != tmat_(2,3) ||
723              rs2(1,0) != tmat_(4,0) || rs2(1,1) != tmat_(4,1) || rs2(1,2) != tmat_(4,2) || rs2(1,3) != tmat_(4,3) ) {
724             std::ostringstream oss;
725             oss << " Test: " << test_ << "\n"
726                 << " Error: Setup of row selection failed\n"
727                 << " Details:\n"
728                 << "   Result:\n" << rs2 << "\n";
729             throw std::runtime_error( oss.str() );
730          }
731       }
732 
733       // Setup of a row selection on an explicit row selection
734       {
735          auto rs1 = blaze::rows( tmat_, { 0, 4, 2 } );
736          auto rs2 = blaze::rows( rs1, index_sequence<2,1>() );
737 
738          if( rs2.rows() != 2UL || rs2.columns() != tmat_.columns() ||
739              rs2(0,0) != tmat_(2,0) || rs2(0,1) != tmat_(2,1) || rs2(0,2) != tmat_(2,2) || rs2(0,3) != tmat_(2,3) ||
740              rs2(1,0) != tmat_(4,0) || rs2(1,1) != tmat_(4,1) || rs2(1,2) != tmat_(4,2) || rs2(1,3) != tmat_(4,3) ) {
741             std::ostringstream oss;
742             oss << " Test: " << test_ << "\n"
743                 << " Error: Setup of row selection failed\n"
744                 << " Details:\n"
745                 << "   Result:\n" << rs2 << "\n";
746             throw std::runtime_error( oss.str() );
747          }
748       }
749 
750       // Setup of a row selection on an implicit row selection
751       {
752          const std::array<size_t,3UL> indices{ 0, 4, 2 };
753          auto rs1 = blaze::rows( tmat_, [indices]( size_t i ){ return indices[i]; }, 3UL );
754          auto rs2 = blaze::rows( rs1, index_sequence<2,1>() );
755 
756          if( rs2.rows() != 2UL || rs2.columns() != tmat_.columns() ||
757              rs2(0,0) != tmat_(2,0) || rs2(0,1) != tmat_(2,1) || rs2(0,2) != tmat_(2,2) || rs2(0,3) != tmat_(2,3) ||
758              rs2(1,0) != tmat_(4,0) || rs2(1,1) != tmat_(4,1) || rs2(1,2) != tmat_(4,2) || rs2(1,3) != tmat_(4,3) ) {
759             std::ostringstream oss;
760             oss << " Test: " << test_ << "\n"
761                 << " Error: Setup of row selection failed\n"
762                 << " Details:\n"
763                 << "   Result:\n" << rs2 << "\n";
764             throw std::runtime_error( oss.str() );
765          }
766       }
767    }
768 
769 
770    //=====================================================================================
771    // Column-major setup via initializer_list
772    //=====================================================================================
773 
774    {
775       test_ = "Column-major Rows constructor (initializer_list)";
776 
777       initialize();
778 
779       // Setup of empty row selection
780       {
781          std::initializer_list<size_t> indices{};
782          auto rs = blaze::rows( tmat_, indices );
783 
784          if( rs.rows() != 0UL || rs.columns() != tmat_.columns() ) {
785             std::ostringstream oss;
786             oss << " Test: " << test_ << "\n"
787                 << " Error: Setup of empty row selection failed\n"
788                 << " Details:\n"
789                 << "   Result:\n" << rs << "\n";
790             throw std::runtime_error( oss.str() );
791          }
792       }
793 
794       // Setup of a regular row selection
795       {
796          auto rs = blaze::rows( tmat_, { 0, 4, 2 } );
797 
798          if( rs.rows() != 3UL || rs.columns() != tmat_.columns() ||
799              rs(0,0) != tmat_(0,0) || rs(0,1) != tmat_(0,1) || rs(0,2) != tmat_(0,2) || rs(0,3) != tmat_(0,3) ||
800              rs(1,0) != tmat_(4,0) || rs(1,1) != tmat_(4,1) || rs(1,2) != tmat_(4,2) || rs(1,3) != tmat_(4,3) ||
801              rs(2,0) != tmat_(2,0) || rs(2,1) != tmat_(2,1) || rs(2,2) != tmat_(2,2) || rs(2,3) != tmat_(2,3) ) {
802             std::ostringstream oss;
803             oss << " Test: " << test_ << "\n"
804                 << " Error: Setup of row selection failed\n"
805                 << " Details:\n"
806                 << "   Result:\n" << rs << "\n";
807             throw std::runtime_error( oss.str() );
808          }
809       }
810 
811       // Trying to setup an out-of-bounds row selection
812       try {
813          auto rs = blaze::rows( tmat_, { 5 } );
814 
815          std::ostringstream oss;
816          oss << " Test: " << test_ << "\n"
817              << " Error: Setup of out-of-bounds row selection succeeded\n"
818              << " Details:\n"
819              << "   Result:\n" << rs << "\n";
820          throw std::runtime_error( oss.str() );
821       }
822       catch( std::invalid_argument& ) {}
823 
824       // Setup of a row selection on a compile-time row selection
825       {
826          auto rs1 = blaze::rows( tmat_, index_sequence<0,4,2>() );
827          auto rs2 = blaze::rows( rs1, { 2, 1 } );
828 
829          if( rs2.rows() != 2UL || rs2.columns() != tmat_.columns() ||
830              rs2(0,0) != tmat_(2,0) || rs2(0,1) != tmat_(2,1) || rs2(0,2) != tmat_(2,2) || rs2(0,3) != tmat_(2,3) ||
831              rs2(1,0) != tmat_(4,0) || rs2(1,1) != tmat_(4,1) || rs2(1,2) != tmat_(4,2) || rs2(1,3) != tmat_(4,3) ) {
832             std::ostringstream oss;
833             oss << " Test: " << test_ << "\n"
834                 << " Error: Setup of row selection failed\n"
835                 << " Details:\n"
836                 << "   Result:\n" << rs2 << "\n";
837             throw std::runtime_error( oss.str() );
838          }
839       }
840 
841       // Setup of a row selection on an explicit row selection
842       {
843          auto rs1 = blaze::rows( tmat_, { 0, 4, 2 } );
844          auto rs2 = blaze::rows( rs1, { 2, 1 } );
845 
846          if( rs2.rows() != 2UL || rs2.columns() != tmat_.columns() ||
847              rs2(0,0) != tmat_(2,0) || rs2(0,1) != tmat_(2,1) || rs2(0,2) != tmat_(2,2) || rs2(0,3) != tmat_(2,3) ||
848              rs2(1,0) != tmat_(4,0) || rs2(1,1) != tmat_(4,1) || rs2(1,2) != tmat_(4,2) || rs2(1,3) != tmat_(4,3) ) {
849             std::ostringstream oss;
850             oss << " Test: " << test_ << "\n"
851                 << " Error: Setup of row selection failed\n"
852                 << " Details:\n"
853                 << "   Result:\n" << rs2 << "\n";
854             throw std::runtime_error( oss.str() );
855          }
856       }
857 
858       // Setup of a row selection on an implicit row selection
859       {
860          const std::array<size_t,3UL> indices{ 0, 4, 2 };
861          auto rs1 = blaze::rows( tmat_, [indices]( size_t i ){ return indices[i]; }, 3UL );
862          auto rs2 = blaze::rows( rs1, { 2, 1 } );
863 
864          if( rs2.rows() != 2UL || rs2.columns() != tmat_.columns() ||
865              rs2(0,0) != tmat_(2,0) || rs2(0,1) != tmat_(2,1) || rs2(0,2) != tmat_(2,2) || rs2(0,3) != tmat_(2,3) ||
866              rs2(1,0) != tmat_(4,0) || rs2(1,1) != tmat_(4,1) || rs2(1,2) != tmat_(4,2) || rs2(1,3) != tmat_(4,3) ) {
867             std::ostringstream oss;
868             oss << " Test: " << test_ << "\n"
869                 << " Error: Setup of row selection failed\n"
870                 << " Details:\n"
871                 << "   Result:\n" << rs2 << "\n";
872             throw std::runtime_error( oss.str() );
873          }
874       }
875    }
876 
877 
878    //=====================================================================================
879    // Column-major setup via std::vector
880    //=====================================================================================
881 
882    {
883       test_ = "Column-major Rows constructor (std::vector)";
884 
885       initialize();
886 
887       // Setup of empty row selection
888       {
889          std::vector<size_t> indices;
890          auto rs = blaze::rows( tmat_, indices );
891 
892          if( rs.rows() != 0UL || rs.columns() != tmat_.columns() ) {
893             std::ostringstream oss;
894             oss << " Test: " << test_ << "\n"
895                 << " Error: Setup of empty row selection failed\n"
896                 << " Details:\n"
897                 << "   Result:\n" << rs << "\n";
898             throw std::runtime_error( oss.str() );
899          }
900       }
901 
902       // Setup of a regular row selection
903       {
904          std::vector<size_t> indices{ 0, 4, 2 };
905          auto rs = blaze::rows( tmat_, indices );
906 
907          if( rs.rows() != 3UL || rs.columns() != tmat_.columns() ||
908              rs(0,0) != tmat_(0,0) || rs(0,1) != tmat_(0,1) || rs(0,2) != tmat_(0,2) || rs(0,3) != tmat_(0,3) ||
909              rs(1,0) != tmat_(4,0) || rs(1,1) != tmat_(4,1) || rs(1,2) != tmat_(4,2) || rs(1,3) != tmat_(4,3) ||
910              rs(2,0) != tmat_(2,0) || rs(2,1) != tmat_(2,1) || rs(2,2) != tmat_(2,2) || rs(2,3) != tmat_(2,3) ) {
911             std::ostringstream oss;
912             oss << " Test: " << test_ << "\n"
913                 << " Error: Setup of row selection failed\n"
914                 << " Details:\n"
915                 << "   Result:\n" << rs << "\n";
916             throw std::runtime_error( oss.str() );
917          }
918       }
919 
920       // Trying to setup an out-of-bounds row selection
921       try {
922          std::vector<size_t> indices{ 5 };
923          auto rs = blaze::rows( tmat_, indices );
924 
925          std::ostringstream oss;
926          oss << " Test: " << test_ << "\n"
927              << " Error: Setup of out-of-bounds row selection succeeded\n"
928              << " Details:\n"
929              << "   Result:\n" << rs << "\n";
930          throw std::runtime_error( oss.str() );
931       }
932       catch( std::invalid_argument& ) {}
933 
934       // Setup of a row selection on a compile-time row selection
935       {
936          auto rs1 = blaze::rows( tmat_, index_sequence<0,4,2>() );
937 
938          const std::vector<size_t> indices{ 2, 1 };
939          auto rs2 = blaze::rows( rs1, indices );
940 
941          if( rs2.rows() != 2UL || rs2.columns() != tmat_.columns() ||
942              rs2(0,0) != tmat_(2,0) || rs2(0,1) != tmat_(2,1) || rs2(0,2) != tmat_(2,2) || rs2(0,3) != tmat_(2,3) ||
943              rs2(1,0) != tmat_(4,0) || rs2(1,1) != tmat_(4,1) || rs2(1,2) != tmat_(4,2) || rs2(1,3) != tmat_(4,3) ) {
944             std::ostringstream oss;
945             oss << " Test: " << test_ << "\n"
946                 << " Error: Setup of row selection failed\n"
947                 << " Details:\n"
948                 << "   Result:\n" << rs2 << "\n";
949             throw std::runtime_error( oss.str() );
950          }
951       }
952 
953       // Setup of a row selection on an explicit row selection
954       {
955          auto rs1 = blaze::rows( tmat_, { 0, 4, 2 } );
956 
957          const std::vector<size_t> indices{ 2, 1 };
958          auto rs2 = blaze::rows( rs1, indices );
959 
960          if( rs2.rows() != 2UL || rs2.columns() != tmat_.columns() ||
961              rs2(0,0) != tmat_(2,0) || rs2(0,1) != tmat_(2,1) || rs2(0,2) != tmat_(2,2) || rs2(0,3) != tmat_(2,3) ||
962              rs2(1,0) != tmat_(4,0) || rs2(1,1) != tmat_(4,1) || rs2(1,2) != tmat_(4,2) || rs2(1,3) != tmat_(4,3) ) {
963             std::ostringstream oss;
964             oss << " Test: " << test_ << "\n"
965                 << " Error: Setup of row selection failed\n"
966                 << " Details:\n"
967                 << "   Result:\n" << rs2 << "\n";
968             throw std::runtime_error( oss.str() );
969          }
970       }
971 
972       // Setup of a row selection on an implicit row selection
973       {
974          const std::array<size_t,3UL> indices1{ 0, 4, 2 };
975          auto rs1 = blaze::rows( tmat_, [indices1]( size_t i ){ return indices1[i]; }, 3UL );
976 
977          const std::vector<size_t> indices2{ 2, 1 };
978          auto rs2 = blaze::rows( rs1, indices2 );;
979 
980          if( rs2.rows() != 2UL || rs2.columns() != tmat_.columns() ||
981              rs2(0,0) != tmat_(2,0) || rs2(0,1) != tmat_(2,1) || rs2(0,2) != tmat_(2,2) || rs2(0,3) != tmat_(2,3) ||
982              rs2(1,0) != tmat_(4,0) || rs2(1,1) != tmat_(4,1) || rs2(1,2) != tmat_(4,2) || rs2(1,3) != tmat_(4,3) ) {
983             std::ostringstream oss;
984             oss << " Test: " << test_ << "\n"
985                 << " Error: Setup of row selection failed\n"
986                 << " Details:\n"
987                 << "   Result:\n" << rs2 << "\n";
988             throw std::runtime_error( oss.str() );
989          }
990       }
991    }
992 
993 
994    //=====================================================================================
995    // Column-major setup via std::array
996    //=====================================================================================
997 
998    {
999       test_ = "Column-major Rows constructor (std::array)";
1000 
1001       initialize();
1002 
1003       // Setup of a regular row selection
1004       {
1005          std::array<size_t,3UL> indices{ 0, 4, 2 };
1006          auto rs = blaze::rows( tmat_, indices );
1007 
1008          if( rs.rows() != 3UL || rs.columns() != tmat_.columns() ||
1009              rs(0,0) != tmat_(0,0) || rs(0,1) != tmat_(0,1) || rs(0,2) != tmat_(0,2) || rs(0,3) != tmat_(0,3) ||
1010              rs(1,0) != tmat_(4,0) || rs(1,1) != tmat_(4,1) || rs(1,2) != tmat_(4,2) || rs(1,3) != tmat_(4,3) ||
1011              rs(2,0) != tmat_(2,0) || rs(2,1) != tmat_(2,1) || rs(2,2) != tmat_(2,2) || rs(2,3) != tmat_(2,3) ) {
1012             std::ostringstream oss;
1013             oss << " Test: " << test_ << "\n"
1014                 << " Error: Setup of row selection failed\n"
1015                 << " Details:\n"
1016                 << "   Result:\n" << rs << "\n";
1017             throw std::runtime_error( oss.str() );
1018          }
1019       }
1020 
1021       // Trying to setup an out-of-bounds row selection
1022       try {
1023          std::array<size_t,1UL> indices{ 5 };
1024          auto rs = blaze::rows( tmat_, indices );
1025 
1026          std::ostringstream oss;
1027          oss << " Test: " << test_ << "\n"
1028              << " Error: Setup of out-of-bounds row selection succeeded\n"
1029              << " Details:\n"
1030              << "   Result:\n" << rs << "\n";
1031          throw std::runtime_error( oss.str() );
1032       }
1033       catch( std::invalid_argument& ) {}
1034 
1035       // Setup of a row selection on a compile-time row selection
1036       {
1037          auto rs1 = blaze::rows( tmat_, index_sequence<0,4,2>() );
1038 
1039          const std::array<size_t,2UL> indices{ 2, 1 };
1040          auto rs2 = blaze::rows( rs1, indices );
1041 
1042          if( rs2.rows() != 2UL || rs2.columns() != tmat_.columns() ||
1043              rs2(0,0) != tmat_(2,0) || rs2(0,1) != tmat_(2,1) || rs2(0,2) != tmat_(2,2) || rs2(0,3) != tmat_(2,3) ||
1044              rs2(1,0) != tmat_(4,0) || rs2(1,1) != tmat_(4,1) || rs2(1,2) != tmat_(4,2) || rs2(1,3) != tmat_(4,3) ) {
1045             std::ostringstream oss;
1046             oss << " Test: " << test_ << "\n"
1047                 << " Error: Setup of row selection failed\n"
1048                 << " Details:\n"
1049                 << "   Result:\n" << rs2 << "\n";
1050             throw std::runtime_error( oss.str() );
1051          }
1052       }
1053 
1054       // Setup of a row selection on an explicit row selection
1055       {
1056          auto rs1 = blaze::rows( tmat_, { 0, 4, 2 } );
1057 
1058          const std::array<size_t,2UL> indices{ 2, 1 };
1059          auto rs2 = blaze::rows( rs1, indices );
1060 
1061          if( rs2.rows() != 2UL || rs2.columns() != tmat_.columns() ||
1062              rs2(0,0) != tmat_(2,0) || rs2(0,1) != tmat_(2,1) || rs2(0,2) != tmat_(2,2) || rs2(0,3) != tmat_(2,3) ||
1063              rs2(1,0) != tmat_(4,0) || rs2(1,1) != tmat_(4,1) || rs2(1,2) != tmat_(4,2) || rs2(1,3) != tmat_(4,3) ) {
1064             std::ostringstream oss;
1065             oss << " Test: " << test_ << "\n"
1066                 << " Error: Setup of row selection failed\n"
1067                 << " Details:\n"
1068                 << "   Result:\n" << rs2 << "\n";
1069             throw std::runtime_error( oss.str() );
1070          }
1071       }
1072 
1073       // Setup of a row selection on an implicit row selection
1074       {
1075          const std::array<size_t,3UL> indices1{ 0, 4, 2 };
1076          auto rs1 = blaze::rows( tmat_, [indices1]( size_t i ){ return indices1[i]; }, 3UL );
1077 
1078          const std::array<size_t,2UL> indices2{ 2, 1 };
1079          auto rs2 = blaze::rows( rs1, indices2 );
1080 
1081          if( rs2.rows() != 2UL || rs2.columns() != tmat_.columns() ||
1082              rs2(0,0) != tmat_(2,0) || rs2(0,1) != tmat_(2,1) || rs2(0,2) != tmat_(2,2) || rs2(0,3) != tmat_(2,3) ||
1083              rs2(1,0) != tmat_(4,0) || rs2(1,1) != tmat_(4,1) || rs2(1,2) != tmat_(4,2) || rs2(1,3) != tmat_(4,3) ) {
1084             std::ostringstream oss;
1085             oss << " Test: " << test_ << "\n"
1086                 << " Error: Setup of row selection failed\n"
1087                 << " Details:\n"
1088                 << "   Result:\n" << rs2 << "\n";
1089             throw std::runtime_error( oss.str() );
1090          }
1091       }
1092    }
1093 
1094 
1095    //=====================================================================================
1096    // Column-major setup via lambda expression
1097    //=====================================================================================
1098 
1099    {
1100       test_ = "Column-major Rows constructor (lambda expression)";
1101 
1102       initialize();
1103 
1104       // Setup of empty row selection
1105       {
1106          auto rs = blaze::rows( tmat_, []( size_t ){ return 0UL; }, 0UL );
1107 
1108          if( rs.rows() != 0UL || rs.columns() != tmat_.columns() ) {
1109             std::ostringstream oss;
1110             oss << " Test: " << test_ << "\n"
1111                 << " Error: Setup of empty row selection failed\n"
1112                 << " Details:\n"
1113                 << "   Result:\n" << rs << "\n";
1114             throw std::runtime_error( oss.str() );
1115          }
1116       }
1117 
1118       // Setup of a regular row selection
1119       {
1120          const std::array<size_t,3UL> indices{ 0, 4, 2 };
1121          auto rs = blaze::rows( tmat_, [indices]( size_t i ){ return indices[i]; }, 3UL );
1122 
1123          if( rs.rows() != 3UL || rs.columns() != tmat_.columns() ||
1124              rs(0,0) != tmat_(0,0) || rs(0,1) != tmat_(0,1) || rs(0,2) != tmat_(0,2) || rs(0,3) != tmat_(0,3) ||
1125              rs(1,0) != tmat_(4,0) || rs(1,1) != tmat_(4,1) || rs(1,2) != tmat_(4,2) || rs(1,3) != tmat_(4,3) ||
1126              rs(2,0) != tmat_(2,0) || rs(2,1) != tmat_(2,1) || rs(2,2) != tmat_(2,2) || rs(2,3) != tmat_(2,3) ) {
1127             std::ostringstream oss;
1128             oss << " Test: " << test_ << "\n"
1129                 << " Error: Setup of row selection failed\n"
1130                 << " Details:\n"
1131                 << "   Result:\n" << rs << "\n";
1132             throw std::runtime_error( oss.str() );
1133          }
1134       }
1135 
1136       // Trying to setup an out-of-bounds row selection
1137       try {
1138          auto rs = blaze::rows( tmat_, []( size_t ){ return 5UL; }, 1UL );
1139 
1140          std::ostringstream oss;
1141          oss << " Test: " << test_ << "\n"
1142              << " Error: Setup of out-of-bounds row selection succeeded\n"
1143              << " Details:\n"
1144              << "   Result:\n" << rs << "\n";
1145          throw std::runtime_error( oss.str() );
1146       }
1147       catch( std::invalid_argument& ) {}
1148 
1149       // Setup of a row selection on a compile-time row selection
1150       {
1151          auto rs1 = blaze::rows( tmat_, index_sequence<0,4,2>() );
1152 
1153          const std::array<size_t,2UL> indices{ 2, 1 };
1154          auto rs2 = blaze::rows( rs1, [indices]( size_t i ){ return indices[i]; }, 2UL );
1155 
1156          if( rs2.rows() != 2UL || rs2.columns() != tmat_.columns() ||
1157              rs2(0,0) != tmat_(2,0) || rs2(0,1) != tmat_(2,1) || rs2(0,2) != tmat_(2,2) || rs2(0,3) != tmat_(2,3) ||
1158              rs2(1,0) != tmat_(4,0) || rs2(1,1) != tmat_(4,1) || rs2(1,2) != tmat_(4,2) || rs2(1,3) != tmat_(4,3) ) {
1159             std::ostringstream oss;
1160             oss << " Test: " << test_ << "\n"
1161                 << " Error: Setup of row selection failed\n"
1162                 << " Details:\n"
1163                 << "   Result:\n" << rs2 << "\n";
1164             throw std::runtime_error( oss.str() );
1165          }
1166       }
1167 
1168       // Setup of a row selection on an explicit row selection
1169       {
1170          auto rs1 = blaze::rows( tmat_, { 0, 4, 2 } );
1171 
1172          const std::array<size_t,2UL> indices{ 2, 1 };
1173          auto rs2 = blaze::rows( rs1, [indices]( size_t i ){ return indices[i]; }, 2UL );
1174 
1175          if( rs2.rows() != 2UL || rs2.columns() != tmat_.columns() ||
1176              rs2(0,0) != tmat_(2,0) || rs2(0,1) != tmat_(2,1) || rs2(0,2) != tmat_(2,2) || rs2(0,3) != tmat_(2,3) ||
1177              rs2(1,0) != tmat_(4,0) || rs2(1,1) != tmat_(4,1) || rs2(1,2) != tmat_(4,2) || rs2(1,3) != tmat_(4,3) ) {
1178             std::ostringstream oss;
1179             oss << " Test: " << test_ << "\n"
1180                 << " Error: Setup of row selection failed\n"
1181                 << " Details:\n"
1182                 << "   Result:\n" << rs2 << "\n";
1183             throw std::runtime_error( oss.str() );
1184          }
1185       }
1186 
1187       // Setup of a row selection on an implicit row selection
1188       {
1189          const std::array<size_t,3UL> indices1{ 0, 4, 2 };
1190          auto rs1 = blaze::rows( tmat_, [indices1]( size_t i ){ return indices1[i]; }, 3UL );
1191 
1192          const std::array<size_t,2UL> indices2{ 2, 1 };
1193          auto rs2 = blaze::rows( rs1, [indices2]( size_t i ){ return indices2[i]; }, 2UL );
1194 
1195          if( rs2.rows() != 2UL || rs2.columns() != tmat_.columns() ||
1196              rs2(0,0) != tmat_(2,0) || rs2(0,1) != tmat_(2,1) || rs2(0,2) != tmat_(2,2) || rs2(0,3) != tmat_(2,3) ||
1197              rs2(1,0) != tmat_(4,0) || rs2(1,1) != tmat_(4,1) || rs2(1,2) != tmat_(4,2) || rs2(1,3) != tmat_(4,3) ) {
1198             std::ostringstream oss;
1199             oss << " Test: " << test_ << "\n"
1200                 << " Error: Setup of row selection failed\n"
1201                 << " Details:\n"
1202                 << "   Result:\n" << rs2 << "\n";
1203             throw std::runtime_error( oss.str() );
1204          }
1205       }
1206    }
1207 
1208 
1209    //=====================================================================================
1210    // Column-major setup of random in-bounds element selection
1211    //=====================================================================================
1212 
1213    {
1214       test_ = "Column-major Rows constructor (stress test)";
1215 
1216       initialize();
1217 
1218       for( size_t rep=0UL; rep<100UL; ++rep )
1219       {
1220          blaze::DynamicVector<size_t> indices( blaze::rand<size_t>( 1UL, 20UL ) );
1221          randomize( indices, 0UL, tmat_.rows()-1UL );
1222          auto rs = blaze::rows( tmat_, indices.data(), indices.size() );
1223 
1224          for( size_t i=0UL; i<rs.rows(); ++i ) {
1225             for( size_t j=0UL; j<rs.columns(); ++j ) {
1226                if( rs(i,j) != tmat_(indices[i],j) ) {
1227                   std::ostringstream oss;
1228                   oss << " Test: " << test_ << "\n"
1229                       << " Error: Setup of row selection failed\n"
1230                       << " Details:\n"
1231                       << "   Indices:\n" << indices << "\n"
1232                       << "   Row selection:\n" << rs << "\n"
1233                       << "   Matrix:\n" << tmat_ << "\n";
1234                   throw std::runtime_error( oss.str() );
1235                }
1236             }
1237          }
1238       }
1239    }
1240 }
1241 //*************************************************************************************************
1242 
1243 
1244 //*************************************************************************************************
1245 /*!\brief Test of the Rows assignment operators.
1246 //
1247 // \return void
1248 // \exception std::runtime_error Error detected.
1249 //
1250 // This function performs a test of all assignment operators of the Rows specialization.
1251 // In case an error is detected, a \a std::runtime_error exception is thrown.
1252 */
testAssignment()1253 void DenseGeneralTest::testAssignment()
1254 {
1255    using blaze::aligned;
1256    using blaze::unaligned;
1257    using blaze::padded;
1258    using blaze::unpadded;
1259    using blaze::rowMajor;
1260    using blaze::columnMajor;
1261 
1262 
1263    //=====================================================================================
1264    // Row-major homogeneous assignment
1265    //=====================================================================================
1266 
1267    {
1268       test_ = "Row-major Rows homogeneous assignment";
1269 
1270       initialize();
1271 
1272       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
1273       rs = 12;
1274 
1275       checkRows    ( rs  ,  2UL );
1276       checkColumns ( rs  ,  4UL );
1277       checkNonZeros( rs  ,  8UL );
1278       checkRows    ( mat_,  5UL );
1279       checkColumns ( mat_,  4UL );
1280       checkNonZeros( mat_, 14UL );
1281 
1282       if( rs(0,0) != 12 || rs(0,1) != 12 || rs(0,2) != 12 || rs(0,3) != 12 ||
1283           rs(1,0) != 12 || rs(1,1) != 12 || rs(1,2) != 12 || rs(1,3) != 12 ) {
1284          std::ostringstream oss;
1285          oss << " Test: " << test_ << "\n"
1286              << " Error: Assignment failed\n"
1287              << " Details:\n"
1288              << "   Result:\n" << rs << "\n"
1289              << "   Expected result:\n( 12 12 12 12 )\n( 12 12 12 12 )\n";
1290          throw std::runtime_error( oss.str() );
1291       }
1292 
1293       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1294           mat_(1,0) != 12 || mat_(1,1) != 12 || mat_(1,2) != 12 || mat_(1,3) != 12 ||
1295           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
1296           mat_(3,0) != 12 || mat_(3,1) != 12 || mat_(3,2) != 12 || mat_(3,3) != 12 ||
1297           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1298          std::ostringstream oss;
1299          oss << " Test: " << test_ << "\n"
1300              << " Error: Assignment failed\n"
1301              << " Details:\n"
1302              << "   Result:\n" << mat_ << "\n"
1303              << "   Expected result:\n(  0  0  0  0 )\n"
1304                                      "( 12 12 12 12 )\n"
1305                                      "( -2  0 -3  0 )\n"
1306                                      "( 12 12 12 12 )\n"
1307                                      "(  7 -8  9 10 )\n";
1308          throw std::runtime_error( oss.str() );
1309       }
1310    }
1311 
1312 
1313    //=====================================================================================
1314    // Row-major list assignment
1315    //=====================================================================================
1316 
1317    {
1318       test_ = "Row-major Rows list assignment (complete list)";
1319 
1320       initialize();
1321 
1322       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
1323       rs = { { 11, 0, 0, 12 }, { 0, 13, 14, 0 } };
1324 
1325       checkRows    ( rs  ,  2UL );
1326       checkColumns ( rs  ,  4UL );
1327       checkNonZeros( rs  ,  4UL );
1328       checkRows    ( mat_,  5UL );
1329       checkColumns ( mat_,  4UL );
1330       checkNonZeros( mat_, 10UL );
1331 
1332       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
1333           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
1334          std::ostringstream oss;
1335          oss << " Test: " << test_ << "\n"
1336              << " Error: Assignment failed\n"
1337              << " Details:\n"
1338              << "   Result:\n" << rs << "\n"
1339              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
1340          throw std::runtime_error( oss.str() );
1341       }
1342 
1343       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1344           mat_(1,0) !=  0 || mat_(1,1) != 13 || mat_(1,2) != 14 || mat_(1,3) !=  0 ||
1345           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
1346           mat_(3,0) != 11 || mat_(3,1) !=  0 || mat_(3,2) !=  0 || mat_(3,3) != 12 ||
1347           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1348          std::ostringstream oss;
1349          oss << " Test: " << test_ << "\n"
1350              << " Error: Assignment failed\n"
1351              << " Details:\n"
1352              << "   Result:\n" << mat_ << "\n"
1353              << "   Expected result:\n(  0  0  0  0 )\n"
1354                                      "(  0 13 14  0 )\n"
1355                                      "( -2  0 -3  0 )\n"
1356                                      "( 11  0  0 12 )\n"
1357                                      "(  7 -8  9 10 )\n";
1358          throw std::runtime_error( oss.str() );
1359       }
1360    }
1361 
1362    {
1363       test_ = "Row-major Rows list assignment (incomplete list)";
1364 
1365       initialize();
1366 
1367       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
1368       rs = { { 11, 0, 0, 12 }, { 0, 13, 14 } };
1369 
1370       checkRows    ( rs  ,  2UL );
1371       checkColumns ( rs  ,  4UL );
1372       checkNonZeros( rs  ,  4UL );
1373       checkRows    ( mat_,  5UL );
1374       checkColumns ( mat_,  4UL );
1375       checkNonZeros( mat_, 10UL );
1376 
1377       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
1378           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
1379          std::ostringstream oss;
1380          oss << " Test: " << test_ << "\n"
1381              << " Error: Assignment failed\n"
1382              << " Details:\n"
1383              << "   Result:\n" << rs << "\n"
1384              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
1385          throw std::runtime_error( oss.str() );
1386       }
1387 
1388       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1389           mat_(1,0) !=  0 || mat_(1,1) != 13 || mat_(1,2) != 14 || mat_(1,3) !=  0 ||
1390           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
1391           mat_(3,0) != 11 || mat_(3,1) !=  0 || mat_(3,2) !=  0 || mat_(3,3) != 12 ||
1392           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1393          std::ostringstream oss;
1394          oss << " Test: " << test_ << "\n"
1395              << " Error: Assignment failed\n"
1396              << " Details:\n"
1397              << "   Result:\n" << mat_ << "\n"
1398              << "   Expected result:\n(  0  0  0  0 )\n"
1399                                      "(  0 13 14  0 )\n"
1400                                      "( -2  0 -3  0 )\n"
1401                                      "( 11  0  0 12 )\n"
1402                                      "(  7 -8  9 10 )\n";
1403          throw std::runtime_error( oss.str() );
1404       }
1405    }
1406 
1407 
1408    //=====================================================================================
1409    // Row-major copy assignment
1410    //=====================================================================================
1411 
1412    {
1413       test_ = "Row-major Rows copy assignment (no aliasing)";
1414 
1415       initialize();
1416 
1417       MT mat{ {  0,  0,  0,  0 },
1418               { 11,  0, 12,  0 },
1419               {  0,  0,  0,  0 },
1420               { 13, 14, 15, 16 },
1421               {  0,  0,  0,  0 } };
1422 
1423       auto rs = blaze::rows( mat, { 3UL, 1UL } );
1424       rs = blaze::rows( mat_, { 3UL, 1UL } );
1425 
1426       checkRows    ( rs , 2UL );
1427       checkColumns ( rs , 4UL );
1428       checkNonZeros( rs , 4UL );
1429       checkRows    ( mat, 5UL );
1430       checkColumns ( mat, 4UL );
1431       checkNonZeros( mat, 4UL );
1432 
1433       if( rs(0,0) != 0 || rs(0,1) != 4 || rs(0,2) != 5 || rs(0,3) != -6 ||
1434           rs(1,0) != 0 || rs(1,1) != 1 || rs(1,2) != 0 || rs(1,3) !=  0 ) {
1435          std::ostringstream oss;
1436          oss << " Test: " << test_ << "\n"
1437              << " Error: Assignment failed\n"
1438              << " Details:\n"
1439              << "   Result:\n" << rs << "\n"
1440              << "   Expected result:\n(  0  4  5 -6 )\n(  0  1  0  0 )\n";
1441          throw std::runtime_error( oss.str() );
1442       }
1443 
1444       if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) != 0 || mat(0,3) !=  0 ||
1445           mat(1,0) != 0 || mat(1,1) != 1 || mat(1,2) != 0 || mat(1,3) !=  0 ||
1446           mat(2,0) != 0 || mat(2,1) != 0 || mat(2,2) != 0 || mat(2,3) !=  0 ||
1447           mat(3,0) != 0 || mat(3,1) != 4 || mat(3,2) != 5 || mat(3,3) != -6 ||
1448           mat(4,0) != 0 || mat(4,1) != 0 || mat(4,2) != 0 || mat(4,3) !=  0 ) {
1449          std::ostringstream oss;
1450          oss << " Test: " << test_ << "\n"
1451              << " Error: Assignment failed\n"
1452              << " Details:\n"
1453              << "   Result:\n" << mat << "\n"
1454              << "   Expected result:\n( 0  0  0  0 )\n"
1455                                      "( 0  1  0  0 )\n"
1456                                      "( 0  0  0  0 )\n"
1457                                      "( 0  4  5 -6 )\n"
1458                                      "( 0  0  0  0 )\n";
1459          throw std::runtime_error( oss.str() );
1460       }
1461    }
1462 
1463    {
1464       test_ = "Row-major Rows copy assignment (aliasing)";
1465 
1466       initialize();
1467 
1468       auto rs = blaze::rows( mat_, { 3UL, 4UL } );
1469       rs = blaze::rows( mat_, { 2UL, 3UL } );
1470 
1471       checkRows    ( rs  , 2UL );
1472       checkColumns ( rs  , 4UL );
1473       checkNonZeros( rs  , 5UL );
1474       checkRows    ( mat_, 5UL );
1475       checkColumns ( mat_, 4UL );
1476       checkNonZeros( mat_, 8UL );
1477 
1478       if( rs(0,0) != -2 || rs(0,1) != 0 || rs(0,2) != -3 || rs(0,3) !=  0 ||
1479           rs(1,0) !=  0 || rs(1,1) != 4 || rs(1,2) !=  5 || rs(1,3) != -6 ) {
1480          std::ostringstream oss;
1481          oss << " Test: " << test_ << "\n"
1482              << " Error: Assignment failed\n"
1483              << " Details:\n"
1484              << "   Result:\n" << rs << "\n"
1485              << "   Expected result:\n( -2  0 -3  0 )\n(  0  4  5 -6 )\n";
1486          throw std::runtime_error( oss.str() );
1487       }
1488 
1489       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1490           mat_(1,0) !=  0 || mat_(1,1) !=  1 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
1491           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
1492           mat_(3,0) != -2 || mat_(3,1) !=  0 || mat_(3,2) != -3 || mat_(3,3) !=  0 ||
1493           mat_(4,0) !=  0 || mat_(4,1) !=  4 || mat_(4,2) !=  5 || mat_(4,3) != -6 ) {
1494          std::ostringstream oss;
1495          oss << " Test: " << test_ << "\n"
1496              << " Error: Assignment failed\n"
1497              << " Details:\n"
1498              << "   Result:\n" << mat_ << "\n"
1499              << "   Expected result:\n(  0  0  0  0 )\n"
1500                                      "(  0  1  0  0 )\n"
1501                                      "( -2  0 -3  0 )\n"
1502                                      "( -2  0 -3  0 )\n"
1503                                      "(  0  4  5 -6 )\n";
1504          throw std::runtime_error( oss.str() );
1505       }
1506    }
1507 
1508 
1509    //=====================================================================================
1510    // Row-major dense matrix assignment
1511    //=====================================================================================
1512 
1513    {
1514       test_ = "Row-major/row-major dense matrix assignment (mixed type)";
1515 
1516       initialize();
1517 
1518       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
1519 
1520       const blaze::DynamicMatrix<short,rowMajor> mat{ { 11,  0,  0, 12 },
1521                                                       {  0, 13, 14,  0 } };
1522 
1523       rs = mat;
1524 
1525       checkRows    ( rs  ,  2UL );
1526       checkColumns ( rs  ,  4UL );
1527       checkNonZeros( rs  ,  4UL );
1528       checkRows    ( mat_,  5UL );
1529       checkColumns ( mat_,  4UL );
1530       checkNonZeros( mat_, 10UL );
1531 
1532       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
1533           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
1534          std::ostringstream oss;
1535          oss << " Test: " << test_ << "\n"
1536              << " Error: Assignment failed\n"
1537              << " Details:\n"
1538              << "   Result:\n" << rs << "\n"
1539              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
1540          throw std::runtime_error( oss.str() );
1541       }
1542 
1543       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1544           mat_(1,0) !=  0 || mat_(1,1) != 13 || mat_(1,2) != 14 || mat_(1,3) !=  0 ||
1545           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
1546           mat_(3,0) != 11 || mat_(3,1) !=  0 || mat_(3,2) !=  0 || mat_(3,3) != 12 ||
1547           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1548          std::ostringstream oss;
1549          oss << " Test: " << test_ << "\n"
1550              << " Error: Assignment failed\n"
1551              << " Details:\n"
1552              << "   Result:\n" << mat_ << "\n"
1553              << "   Expected result:\n(  0  0  0  0 )\n"
1554                                      "(  0 13 14  0 )\n"
1555                                      "( -2  0 -3  0 )\n"
1556                                      "( 11  0  0 12 )\n"
1557                                      "(  7 -8  9 10 )\n";
1558          throw std::runtime_error( oss.str() );
1559       }
1560    }
1561 
1562    {
1563       test_ = "Row-major/row-major dense matrix assignment (aligned/padded)";
1564 
1565       initialize();
1566 
1567       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
1568 
1569       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,rowMajor>;
1570       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 32UL ) );
1571       AlignedPadded mat( memory.get(), 2UL, 4UL, 16UL );
1572       mat = 0;
1573       mat(0,0) = 11;
1574       mat(0,3) = 12;
1575       mat(1,1) = 13;
1576       mat(1,2) = 14;
1577 
1578       rs = mat;
1579 
1580       checkRows    ( rs  ,  2UL );
1581       checkColumns ( rs  ,  4UL );
1582       checkNonZeros( rs  ,  4UL );
1583       checkRows    ( mat_,  5UL );
1584       checkColumns ( mat_,  4UL );
1585       checkNonZeros( mat_, 10UL );
1586 
1587       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
1588           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
1589          std::ostringstream oss;
1590          oss << " Test: " << test_ << "\n"
1591              << " Error: Assignment failed\n"
1592              << " Details:\n"
1593              << "   Result:\n" << rs << "\n"
1594              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
1595          throw std::runtime_error( oss.str() );
1596       }
1597 
1598       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1599           mat_(1,0) !=  0 || mat_(1,1) != 13 || mat_(1,2) != 14 || mat_(1,3) !=  0 ||
1600           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
1601           mat_(3,0) != 11 || mat_(3,1) !=  0 || mat_(3,2) !=  0 || mat_(3,3) != 12 ||
1602           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1603          std::ostringstream oss;
1604          oss << " Test: " << test_ << "\n"
1605              << " Error: Assignment failed\n"
1606              << " Details:\n"
1607              << "   Result:\n" << mat_ << "\n"
1608              << "   Expected result:\n(  0  0  0  0 )\n"
1609                                      "(  0 13 14  0 )\n"
1610                                      "( -2  0 -3  0 )\n"
1611                                      "( 11  0  0 12 )\n"
1612                                      "(  7 -8  9 10 )\n";
1613          throw std::runtime_error( oss.str() );
1614       }
1615    }
1616 
1617    {
1618       test_ = "Row-major/row-major dense matrix assignment (unaligned/unpadded)";
1619 
1620       initialize();
1621 
1622       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
1623 
1624       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,rowMajor>;
1625       std::unique_ptr<int[]> memory( new int[9UL] );
1626       UnalignedUnpadded mat( memory.get()+1UL, 2UL, 4UL );
1627       mat = 0;
1628       mat(0,0) = 11;
1629       mat(0,3) = 12;
1630       mat(1,1) = 13;
1631       mat(1,2) = 14;
1632 
1633       rs = mat;
1634 
1635       checkRows    ( rs  ,  2UL );
1636       checkColumns ( rs  ,  4UL );
1637       checkNonZeros( rs  ,  4UL );
1638       checkRows    ( mat_,  5UL );
1639       checkColumns ( mat_,  4UL );
1640       checkNonZeros( mat_, 10UL );
1641 
1642       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
1643           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
1644          std::ostringstream oss;
1645          oss << " Test: " << test_ << "\n"
1646              << " Error: Assignment failed\n"
1647              << " Details:\n"
1648              << "   Result:\n" << rs << "\n"
1649              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
1650          throw std::runtime_error( oss.str() );
1651       }
1652 
1653       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1654           mat_(1,0) !=  0 || mat_(1,1) != 13 || mat_(1,2) != 14 || mat_(1,3) !=  0 ||
1655           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
1656           mat_(3,0) != 11 || mat_(3,1) !=  0 || mat_(3,2) !=  0 || mat_(3,3) != 12 ||
1657           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1658          std::ostringstream oss;
1659          oss << " Test: " << test_ << "\n"
1660              << " Error: Assignment failed\n"
1661              << " Details:\n"
1662              << "   Result:\n" << mat_ << "\n"
1663              << "   Expected result:\n(  0  0  0  0 )\n"
1664                                      "(  0 13 14  0 )\n"
1665                                      "( -2  0 -3  0 )\n"
1666                                      "( 11  0  0 12 )\n"
1667                                      "(  7 -8  9 10 )\n";
1668          throw std::runtime_error( oss.str() );
1669       }
1670    }
1671 
1672    {
1673       test_ = "Row-major/column-major dense matrix assignment (mixed type)";
1674 
1675       initialize();
1676 
1677       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
1678 
1679       const blaze::DynamicMatrix<short,columnMajor> mat{ { 11,  0,  0, 12 },
1680                                                          {  0, 13, 14,  0 } };
1681 
1682       rs = mat;
1683 
1684       checkRows    ( rs  ,  2UL );
1685       checkColumns ( rs  ,  4UL );
1686       checkNonZeros( rs  ,  4UL );
1687       checkRows    ( mat_,  5UL );
1688       checkColumns ( mat_,  4UL );
1689       checkNonZeros( mat_, 10UL );
1690 
1691       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
1692           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
1693          std::ostringstream oss;
1694          oss << " Test: " << test_ << "\n"
1695              << " Error: Assignment failed\n"
1696              << " Details:\n"
1697              << "   Result:\n" << rs << "\n"
1698              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
1699          throw std::runtime_error( oss.str() );
1700       }
1701 
1702       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1703           mat_(1,0) !=  0 || mat_(1,1) != 13 || mat_(1,2) != 14 || mat_(1,3) !=  0 ||
1704           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
1705           mat_(3,0) != 11 || mat_(3,1) !=  0 || mat_(3,2) !=  0 || mat_(3,3) != 12 ||
1706           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1707          std::ostringstream oss;
1708          oss << " Test: " << test_ << "\n"
1709              << " Error: Assignment failed\n"
1710              << " Details:\n"
1711              << "   Result:\n" << mat_ << "\n"
1712              << "   Expected result:\n(  0  0  0  0 )\n"
1713                                      "(  0 13 14  0 )\n"
1714                                      "( -2  0 -3  0 )\n"
1715                                      "( 11  0  0 12 )\n"
1716                                      "(  7 -8  9 10 )\n";
1717          throw std::runtime_error( oss.str() );
1718       }
1719    }
1720 
1721    {
1722       test_ = "Row-major/column-major dense matrix assignment (aligned/padded)";
1723 
1724       initialize();
1725 
1726       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
1727 
1728       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,columnMajor>;
1729       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 64UL ) );
1730       AlignedPadded mat( memory.get(), 2UL, 4UL, 16UL );
1731       mat = 0;
1732       mat(0,0) = 11;
1733       mat(0,3) = 12;
1734       mat(1,1) = 13;
1735       mat(1,2) = 14;
1736 
1737       rs = mat;
1738 
1739       checkRows    ( rs  ,  2UL );
1740       checkColumns ( rs  ,  4UL );
1741       checkNonZeros( rs  ,  4UL );
1742       checkRows    ( mat_,  5UL );
1743       checkColumns ( mat_,  4UL );
1744       checkNonZeros( mat_, 10UL );
1745 
1746       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
1747           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
1748          std::ostringstream oss;
1749          oss << " Test: " << test_ << "\n"
1750              << " Error: Assignment failed\n"
1751              << " Details:\n"
1752              << "   Result:\n" << rs << "\n"
1753              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
1754          throw std::runtime_error( oss.str() );
1755       }
1756 
1757       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1758           mat_(1,0) !=  0 || mat_(1,1) != 13 || mat_(1,2) != 14 || mat_(1,3) !=  0 ||
1759           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
1760           mat_(3,0) != 11 || mat_(3,1) !=  0 || mat_(3,2) !=  0 || mat_(3,3) != 12 ||
1761           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1762          std::ostringstream oss;
1763          oss << " Test: " << test_ << "\n"
1764              << " Error: Assignment failed\n"
1765              << " Details:\n"
1766              << "   Result:\n" << mat_ << "\n"
1767              << "   Expected result:\n(  0  0  0  0 )\n"
1768                                      "(  0 13 14  0 )\n"
1769                                      "( -2  0 -3  0 )\n"
1770                                      "( 11  0  0 12 )\n"
1771                                      "(  7 -8  9 10 )\n";
1772          throw std::runtime_error( oss.str() );
1773       }
1774    }
1775 
1776    {
1777       test_ = "Row-major/column-major dense matrix assignment (unaligned/unpadded)";
1778 
1779       initialize();
1780 
1781       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
1782 
1783       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,columnMajor>;
1784       std::unique_ptr<int[]> memory( new int[9UL] );
1785       UnalignedUnpadded mat( memory.get()+1UL, 2UL, 4UL );
1786       mat = 0;
1787       mat(0,0) = 11;
1788       mat(0,3) = 12;
1789       mat(1,1) = 13;
1790       mat(1,2) = 14;
1791 
1792       rs = mat;
1793 
1794       checkRows    ( rs  ,  2UL );
1795       checkColumns ( rs  ,  4UL );
1796       checkNonZeros( rs  ,  4UL );
1797       checkRows    ( mat_,  5UL );
1798       checkColumns ( mat_,  4UL );
1799       checkNonZeros( mat_, 10UL );
1800 
1801       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
1802           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
1803          std::ostringstream oss;
1804          oss << " Test: " << test_ << "\n"
1805              << " Error: Assignment failed\n"
1806              << " Details:\n"
1807              << "   Result:\n" << rs << "\n"
1808              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
1809          throw std::runtime_error( oss.str() );
1810       }
1811 
1812       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1813           mat_(1,0) !=  0 || mat_(1,1) != 13 || mat_(1,2) != 14 || mat_(1,3) !=  0 ||
1814           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
1815           mat_(3,0) != 11 || mat_(3,1) !=  0 || mat_(3,2) !=  0 || mat_(3,3) != 12 ||
1816           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1817          std::ostringstream oss;
1818          oss << " Test: " << test_ << "\n"
1819              << " Error: Assignment failed\n"
1820              << " Details:\n"
1821              << "   Result:\n" << mat_ << "\n"
1822              << "   Expected result:\n(  0  0  0  0 )\n"
1823                                      "(  0 13 14  0 )\n"
1824                                      "( -2  0 -3  0 )\n"
1825                                      "( 11  0  0 12 )\n"
1826                                      "(  7 -8  9 10 )\n";
1827          throw std::runtime_error( oss.str() );
1828       }
1829    }
1830 
1831 
1832    //=====================================================================================
1833    // Row-major sparse matrix assignment
1834    //=====================================================================================
1835 
1836    {
1837       test_ = "Row-major/row-major sparse matrix assignment";
1838 
1839       initialize();
1840 
1841       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
1842 
1843       const blaze::CompressedMatrix<int,rowMajor> mat{ { 11,  0,  0, 12 },
1844                                                        {  0, 13, 14,  0 } };
1845 
1846       rs = mat;
1847 
1848       checkRows    ( rs  ,  2UL );
1849       checkColumns ( rs  ,  4UL );
1850       checkNonZeros( rs  ,  4UL );
1851       checkRows    ( mat_,  5UL );
1852       checkColumns ( mat_,  4UL );
1853       checkNonZeros( mat_, 10UL );
1854 
1855       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
1856           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
1857          std::ostringstream oss;
1858          oss << " Test: " << test_ << "\n"
1859              << " Error: Assignment failed\n"
1860              << " Details:\n"
1861              << "   Result:\n" << rs << "\n"
1862              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
1863          throw std::runtime_error( oss.str() );
1864       }
1865 
1866       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1867           mat_(1,0) !=  0 || mat_(1,1) != 13 || mat_(1,2) != 14 || mat_(1,3) !=  0 ||
1868           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
1869           mat_(3,0) != 11 || mat_(3,1) !=  0 || mat_(3,2) !=  0 || mat_(3,3) != 12 ||
1870           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1871          std::ostringstream oss;
1872          oss << " Test: " << test_ << "\n"
1873              << " Error: Assignment failed\n"
1874              << " Details:\n"
1875              << "   Result:\n" << mat_ << "\n"
1876              << "   Expected result:\n(  0  0  0  0 )\n"
1877                                      "(  0 13 14  0 )\n"
1878                                      "( -2  0 -3  0 )\n"
1879                                      "( 11  0  0 12 )\n"
1880                                      "(  7 -8  9 10 )\n";
1881          throw std::runtime_error( oss.str() );
1882       }
1883    }
1884 
1885    {
1886       test_ = "Row-major/column-major sparse matrix assignment";
1887 
1888       initialize();
1889 
1890       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
1891 
1892       const blaze::CompressedMatrix<int,columnMajor> mat{ { 11,  0,  0, 12 },
1893                                                           {  0, 13, 14,  0 } };
1894 
1895       rs = mat;
1896 
1897       checkRows    ( rs  ,  2UL );
1898       checkColumns ( rs  ,  4UL );
1899       checkNonZeros( rs  ,  4UL );
1900       checkRows    ( mat_,  5UL );
1901       checkColumns ( mat_,  4UL );
1902       checkNonZeros( mat_, 10UL );
1903 
1904       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
1905           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
1906          std::ostringstream oss;
1907          oss << " Test: " << test_ << "\n"
1908              << " Error: Assignment failed\n"
1909              << " Details:\n"
1910              << "   Result:\n" << rs << "\n"
1911              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
1912          throw std::runtime_error( oss.str() );
1913       }
1914 
1915       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1916           mat_(1,0) !=  0 || mat_(1,1) != 13 || mat_(1,2) != 14 || mat_(1,3) !=  0 ||
1917           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
1918           mat_(3,0) != 11 || mat_(3,1) !=  0 || mat_(3,2) !=  0 || mat_(3,3) != 12 ||
1919           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1920          std::ostringstream oss;
1921          oss << " Test: " << test_ << "\n"
1922              << " Error: Assignment failed\n"
1923              << " Details:\n"
1924              << "   Result:\n" << mat_ << "\n"
1925              << "   Expected result:\n(  0  0  0  0 )\n"
1926                                      "(  0 13 14  0 )\n"
1927                                      "( -2  0 -3  0 )\n"
1928                                      "( 11  0  0 12 )\n"
1929                                      "(  7 -8  9 10 )\n";
1930          throw std::runtime_error( oss.str() );
1931       }
1932    }
1933 
1934 
1935    //=====================================================================================
1936    // Column-major homogeneous assignment
1937    //=====================================================================================
1938 
1939    {
1940       test_ = "Column-major Rows homogeneous assignment";
1941 
1942       initialize();
1943 
1944       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
1945       rs = 12;
1946 
1947       checkRows    ( rs   ,  2UL );
1948       checkColumns ( rs   ,  4UL );
1949       checkNonZeros( rs   ,  8UL );
1950       checkRows    ( tmat_,  5UL );
1951       checkColumns ( tmat_,  4UL );
1952       checkNonZeros( tmat_, 14UL );
1953 
1954       if( rs(0,0) != 12 || rs(0,1) != 12 || rs(0,2) != 12 || rs(0,3) != 12 ||
1955           rs(1,0) != 12 || rs(1,1) != 12 || rs(1,2) != 12 || rs(1,3) != 12 ) {
1956          std::ostringstream oss;
1957          oss << " Test: " << test_ << "\n"
1958              << " Error: Assignment failed\n"
1959              << " Details:\n"
1960              << "   Result:\n" << rs << "\n"
1961              << "   Expected result:\n( 12 12 12 12 )\n( 12 12 12 12 )\n";
1962          throw std::runtime_error( oss.str() );
1963       }
1964 
1965       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
1966           tmat_(1,0) != 12 || tmat_(1,1) != 12 || tmat_(1,2) != 12 || tmat_(1,3) != 12 ||
1967           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
1968           tmat_(3,0) != 12 || tmat_(3,1) != 12 || tmat_(3,2) != 12 || tmat_(3,3) != 12 ||
1969           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
1970          std::ostringstream oss;
1971          oss << " Test: " << test_ << "\n"
1972              << " Error: Assignment failed\n"
1973              << " Details:\n"
1974              << "   Result:\n" << tmat_ << "\n"
1975              << "   Expected result:\n(  0  0  0  0 )\n"
1976                                      "( 12 12 12 12 )\n"
1977                                      "( -2  0 -3  0 )\n"
1978                                      "( 12 12 12 12 )\n"
1979                                      "(  7 -8  9 10 )\n";
1980          throw std::runtime_error( oss.str() );
1981       }
1982    }
1983 
1984 
1985    //=====================================================================================
1986    // Column-major list assignment
1987    //=====================================================================================
1988 
1989    {
1990       test_ = "Column-major Rows list assignment (complete list)";
1991 
1992       initialize();
1993 
1994       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
1995       rs = { { 11, 0, 0, 12 }, { 0, 13, 14, 0 } };
1996 
1997       checkRows    ( rs   ,  2UL );
1998       checkColumns ( rs   ,  4UL );
1999       checkNonZeros( rs   ,  4UL );
2000       checkRows    ( tmat_,  5UL );
2001       checkColumns ( tmat_,  4UL );
2002       checkNonZeros( tmat_, 10UL );
2003 
2004       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
2005           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
2006          std::ostringstream oss;
2007          oss << " Test: " << test_ << "\n"
2008              << " Error: Assignment failed\n"
2009              << " Details:\n"
2010              << "   Result:\n" << rs << "\n"
2011              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
2012          throw std::runtime_error( oss.str() );
2013       }
2014 
2015       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
2016           tmat_(1,0) !=  0 || tmat_(1,1) != 13 || tmat_(1,2) != 14 || tmat_(1,3) !=  0 ||
2017           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
2018           tmat_(3,0) != 11 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != 12 ||
2019           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
2020          std::ostringstream oss;
2021          oss << " Test: " << test_ << "\n"
2022              << " Error: Assignment failed\n"
2023              << " Details:\n"
2024              << "   Result:\n" << tmat_ << "\n"
2025              << "   Expected result:\n(  0  0  0  0 )\n"
2026                                      "(  0 13 14  0 )\n"
2027                                      "( -2  0 -3  0 )\n"
2028                                      "( 11  0  0 12 )\n"
2029                                      "(  7 -8  9 10 )\n";
2030          throw std::runtime_error( oss.str() );
2031       }
2032    }
2033 
2034    {
2035       test_ = "Column-major Rows list assignment (incomplete list)";
2036 
2037       initialize();
2038 
2039       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
2040       rs = { { 11, 0, 0, 12 }, { 0, 13, 14 } };
2041 
2042       checkRows    ( rs   ,  2UL );
2043       checkColumns ( rs   ,  4UL );
2044       checkNonZeros( rs   ,  4UL );
2045       checkRows    ( tmat_,  5UL );
2046       checkColumns ( tmat_,  4UL );
2047       checkNonZeros( tmat_, 10UL );
2048 
2049       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
2050           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
2051          std::ostringstream oss;
2052          oss << " Test: " << test_ << "\n"
2053              << " Error: Assignment failed\n"
2054              << " Details:\n"
2055              << "   Result:\n" << rs << "\n"
2056              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
2057          throw std::runtime_error( oss.str() );
2058       }
2059 
2060       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
2061           tmat_(1,0) !=  0 || tmat_(1,1) != 13 || tmat_(1,2) != 14 || tmat_(1,3) !=  0 ||
2062           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
2063           tmat_(3,0) != 11 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != 12 ||
2064           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
2065          std::ostringstream oss;
2066          oss << " Test: " << test_ << "\n"
2067              << " Error: Assignment failed\n"
2068              << " Details:\n"
2069              << "   Result:\n" << tmat_ << "\n"
2070              << "   Expected result:\n(  0  0  0  0 )\n"
2071                                      "(  0 13 14  0 )\n"
2072                                      "( -2  0 -3  0 )\n"
2073                                      "( 11  0  0 12 )\n"
2074                                      "(  7 -8  9 10 )\n";
2075          throw std::runtime_error( oss.str() );
2076       }
2077    }
2078 
2079 
2080    //=====================================================================================
2081    // Column-major copy assignment
2082    //=====================================================================================
2083 
2084    {
2085       test_ = "Column-major Rows copy assignment (no aliasing)";
2086 
2087       initialize();
2088 
2089       OMT mat{ {  0,  0,  0,  0 },
2090                { 11,  0, 12,  0 },
2091                {  0,  0,  0,  0 },
2092                { 13, 14, 15, 16 },
2093                {  0,  0,  0,  0 } };
2094 
2095       auto rs = blaze::rows( mat, { 3UL, 1UL } );
2096       rs = blaze::rows( tmat_, { 3UL, 1UL } );
2097 
2098       checkRows    ( rs , 2UL );
2099       checkColumns ( rs , 4UL );
2100       checkNonZeros( rs , 4UL );
2101       checkRows    ( mat, 5UL );
2102       checkColumns ( mat, 4UL );
2103       checkNonZeros( mat, 4UL );
2104 
2105       if( rs(0,0) != 0 || rs(0,1) != 4 || rs(0,2) != 5 || rs(0,3) != -6 ||
2106           rs(1,0) != 0 || rs(1,1) != 1 || rs(1,2) != 0 || rs(1,3) !=  0 ) {
2107          std::ostringstream oss;
2108          oss << " Test: " << test_ << "\n"
2109              << " Error: Assignment failed\n"
2110              << " Details:\n"
2111              << "   Result:\n" << rs << "\n"
2112              << "   Expected result:\n(  0  4  5 -6 )\n(  0  1  0  0 )\n";
2113          throw std::runtime_error( oss.str() );
2114       }
2115 
2116       if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) != 0 || mat(0,3) !=  0 ||
2117           mat(1,0) != 0 || mat(1,1) != 1 || mat(1,2) != 0 || mat(1,3) !=  0 ||
2118           mat(2,0) != 0 || mat(2,1) != 0 || mat(2,2) != 0 || mat(2,3) !=  0 ||
2119           mat(3,0) != 0 || mat(3,1) != 4 || mat(3,2) != 5 || mat(3,3) != -6 ||
2120           mat(4,0) != 0 || mat(4,1) != 0 || mat(4,2) != 0 || mat(4,3) !=  0 ) {
2121          std::ostringstream oss;
2122          oss << " Test: " << test_ << "\n"
2123              << " Error: Assignment failed\n"
2124              << " Details:\n"
2125              << "   Result:\n" << mat << "\n"
2126              << "   Expected result:\n( 0  0  0  0 )\n"
2127                                      "( 0  1  0  0 )\n"
2128                                      "( 0  0  0  0 )\n"
2129                                      "( 0  4  5 -6 )\n"
2130                                      "( 0  0  0  0 )\n";
2131          throw std::runtime_error( oss.str() );
2132       }
2133    }
2134 
2135    {
2136       test_ = "Column-major Rows copy assignment (aliasing)";
2137 
2138       initialize();
2139 
2140       auto rs = blaze::rows( tmat_, { 3UL, 4UL } );
2141       rs = blaze::rows( tmat_, { 2UL, 3UL } );
2142 
2143       checkRows    ( rs   , 2UL );
2144       checkColumns ( rs   , 4UL );
2145       checkNonZeros( rs   , 5UL );
2146       checkRows    ( tmat_, 5UL );
2147       checkColumns ( tmat_, 4UL );
2148       checkNonZeros( tmat_, 8UL );
2149 
2150       if( rs(0,0) != -2 || rs(0,1) != 0 || rs(0,2) != -3 || rs(0,3) !=  0 ||
2151           rs(1,0) !=  0 || rs(1,1) != 4 || rs(1,2) !=  5 || rs(1,3) != -6 ) {
2152          std::ostringstream oss;
2153          oss << " Test: " << test_ << "\n"
2154              << " Error: Assignment failed\n"
2155              << " Details:\n"
2156              << "   Result:\n" << rs << "\n"
2157              << "   Expected result:\n( -2  0 -3  0 )\n(  0  4  5 -6 )\n";
2158          throw std::runtime_error( oss.str() );
2159       }
2160 
2161       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
2162           tmat_(1,0) !=  0 || tmat_(1,1) !=  1 || tmat_(1,2) !=  0 || tmat_(1,3) !=  0 ||
2163           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
2164           tmat_(3,0) != -2 || tmat_(3,1) !=  0 || tmat_(3,2) != -3 || tmat_(3,3) !=  0 ||
2165           tmat_(4,0) !=  0 || tmat_(4,1) !=  4 || tmat_(4,2) !=  5 || tmat_(4,3) != -6 ) {
2166          std::ostringstream oss;
2167          oss << " Test: " << test_ << "\n"
2168              << " Error: Assignment failed\n"
2169              << " Details:\n"
2170              << "   Result:\n" << tmat_ << "\n"
2171              << "   Expected result:\n(  0  0  0  0 )\n"
2172                                      "(  0  1  0  0 )\n"
2173                                      "( -2  0 -3  0 )\n"
2174                                      "( -2  0 -3  0 )\n"
2175                                      "(  0  4  5 -6 )\n";
2176          throw std::runtime_error( oss.str() );
2177       }
2178    }
2179 
2180 
2181    //=====================================================================================
2182    // Column-major dense matrix assignment
2183    //=====================================================================================
2184 
2185    {
2186       test_ = "Column-major/row-major dense matrix assignment (mixed type)";
2187 
2188       initialize();
2189 
2190       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
2191 
2192       const blaze::DynamicMatrix<short,rowMajor> mat{ { 11,  0,  0, 12 },
2193                                                       {  0, 13, 14,  0 } };
2194 
2195       rs = mat;
2196 
2197       checkRows    ( rs   ,  2UL );
2198       checkColumns ( rs   ,  4UL );
2199       checkNonZeros( rs   ,  4UL );
2200       checkRows    ( tmat_,  5UL );
2201       checkColumns ( tmat_,  4UL );
2202       checkNonZeros( tmat_, 10UL );
2203 
2204       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
2205           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
2206          std::ostringstream oss;
2207          oss << " Test: " << test_ << "\n"
2208              << " Error: Assignment failed\n"
2209              << " Details:\n"
2210              << "   Result:\n" << rs << "\n"
2211              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
2212          throw std::runtime_error( oss.str() );
2213       }
2214 
2215       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
2216           tmat_(1,0) !=  0 || tmat_(1,1) != 13 || tmat_(1,2) != 14 || tmat_(1,3) !=  0 ||
2217           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
2218           tmat_(3,0) != 11 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != 12 ||
2219           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
2220          std::ostringstream oss;
2221          oss << " Test: " << test_ << "\n"
2222              << " Error: Assignment failed\n"
2223              << " Details:\n"
2224              << "   Result:\n" << tmat_ << "\n"
2225              << "   Expected result:\n(  0  0  0  0 )\n"
2226                                      "(  0 13 14  0 )\n"
2227                                      "( -2  0 -3  0 )\n"
2228                                      "( 11  0  0 12 )\n"
2229                                      "(  7 -8  9 10 )\n";
2230          throw std::runtime_error( oss.str() );
2231       }
2232    }
2233 
2234    {
2235       test_ = "Column-major/row-major dense matrix assignment (aligned/padded)";
2236 
2237       initialize();
2238 
2239       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
2240 
2241       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,rowMajor>;
2242       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 32UL ) );
2243       AlignedPadded mat( memory.get(), 2UL, 4UL, 16UL );
2244       mat = 0;
2245       mat(0,0) = 11;
2246       mat(0,3) = 12;
2247       mat(1,1) = 13;
2248       mat(1,2) = 14;
2249 
2250       rs = mat;
2251 
2252       checkRows    ( rs   ,  2UL );
2253       checkColumns ( rs   ,  4UL );
2254       checkNonZeros( rs   ,  4UL );
2255       checkRows    ( tmat_,  5UL );
2256       checkColumns ( tmat_,  4UL );
2257       checkNonZeros( tmat_, 10UL );
2258 
2259       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
2260           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
2261          std::ostringstream oss;
2262          oss << " Test: " << test_ << "\n"
2263              << " Error: Assignment failed\n"
2264              << " Details:\n"
2265              << "   Result:\n" << rs << "\n"
2266              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
2267          throw std::runtime_error( oss.str() );
2268       }
2269 
2270       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
2271           tmat_(1,0) !=  0 || tmat_(1,1) != 13 || tmat_(1,2) != 14 || tmat_(1,3) !=  0 ||
2272           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
2273           tmat_(3,0) != 11 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != 12 ||
2274           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
2275          std::ostringstream oss;
2276          oss << " Test: " << test_ << "\n"
2277              << " Error: Assignment failed\n"
2278              << " Details:\n"
2279              << "   Result:\n" << tmat_ << "\n"
2280              << "   Expected result:\n(  0  0  0  0 )\n"
2281                                      "(  0 13 14  0 )\n"
2282                                      "( -2  0 -3  0 )\n"
2283                                      "( 11  0  0 12 )\n"
2284                                      "(  7 -8  9 10 )\n";
2285          throw std::runtime_error( oss.str() );
2286       }
2287    }
2288 
2289    {
2290       test_ = "Column-major/row-major dense matrix assignment (unaligned/unpadded)";
2291 
2292       initialize();
2293 
2294       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
2295 
2296       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,rowMajor>;
2297       std::unique_ptr<int[]> memory( new int[9UL] );
2298       UnalignedUnpadded mat( memory.get()+1UL, 2UL, 4UL );
2299       mat = 0;
2300       mat(0,0) = 11;
2301       mat(0,3) = 12;
2302       mat(1,1) = 13;
2303       mat(1,2) = 14;
2304 
2305       rs = mat;
2306 
2307       checkRows    ( rs   ,  2UL );
2308       checkColumns ( rs   ,  4UL );
2309       checkNonZeros( rs   ,  4UL );
2310       checkRows    ( tmat_,  5UL );
2311       checkColumns ( tmat_,  4UL );
2312       checkNonZeros( tmat_, 10UL );
2313 
2314       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
2315           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
2316          std::ostringstream oss;
2317          oss << " Test: " << test_ << "\n"
2318              << " Error: Assignment failed\n"
2319              << " Details:\n"
2320              << "   Result:\n" << rs << "\n"
2321              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
2322          throw std::runtime_error( oss.str() );
2323       }
2324 
2325       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
2326           tmat_(1,0) !=  0 || tmat_(1,1) != 13 || tmat_(1,2) != 14 || tmat_(1,3) !=  0 ||
2327           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
2328           tmat_(3,0) != 11 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != 12 ||
2329           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
2330          std::ostringstream oss;
2331          oss << " Test: " << test_ << "\n"
2332              << " Error: Assignment failed\n"
2333              << " Details:\n"
2334              << "   Result:\n" << tmat_ << "\n"
2335              << "   Expected result:\n(  0  0  0  0 )\n"
2336                                      "(  0 13 14  0 )\n"
2337                                      "( -2  0 -3  0 )\n"
2338                                      "( 11  0  0 12 )\n"
2339                                      "(  7 -8  9 10 )\n";
2340          throw std::runtime_error( oss.str() );
2341       }
2342    }
2343 
2344    {
2345       test_ = "Column-major/column-major dense matrix assignment (mixed type)";
2346 
2347       initialize();
2348 
2349       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
2350 
2351       const blaze::DynamicMatrix<short,columnMajor> mat{ { 11,  0,  0, 12 },
2352                                                          {  0, 13, 14,  0 } };
2353 
2354       rs = mat;
2355 
2356       checkRows    ( rs   ,  2UL );
2357       checkColumns ( rs   ,  4UL );
2358       checkNonZeros( rs   ,  4UL );
2359       checkRows    ( tmat_,  5UL );
2360       checkColumns ( tmat_,  4UL );
2361       checkNonZeros( tmat_, 10UL );
2362 
2363       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
2364           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
2365          std::ostringstream oss;
2366          oss << " Test: " << test_ << "\n"
2367              << " Error: Assignment failed\n"
2368              << " Details:\n"
2369              << "   Result:\n" << rs << "\n"
2370              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
2371          throw std::runtime_error( oss.str() );
2372       }
2373 
2374       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
2375           tmat_(1,0) !=  0 || tmat_(1,1) != 13 || tmat_(1,2) != 14 || tmat_(1,3) !=  0 ||
2376           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
2377           tmat_(3,0) != 11 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != 12 ||
2378           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
2379          std::ostringstream oss;
2380          oss << " Test: " << test_ << "\n"
2381              << " Error: Assignment failed\n"
2382              << " Details:\n"
2383              << "   Result:\n" << tmat_ << "\n"
2384              << "   Expected result:\n(  0  0  0  0 )\n"
2385                                      "(  0 13 14  0 )\n"
2386                                      "( -2  0 -3  0 )\n"
2387                                      "( 11  0  0 12 )\n"
2388                                      "(  7 -8  9 10 )\n";
2389          throw std::runtime_error( oss.str() );
2390       }
2391    }
2392 
2393    {
2394       test_ = "Column-major/column-major dense matrix assignment (aligned/padded)";
2395 
2396       initialize();
2397 
2398       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
2399 
2400       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,columnMajor>;
2401       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 64UL ) );
2402       AlignedPadded mat( memory.get(), 2UL, 4UL, 16UL );
2403       mat = 0;
2404       mat(0,0) = 11;
2405       mat(0,3) = 12;
2406       mat(1,1) = 13;
2407       mat(1,2) = 14;
2408 
2409       rs = mat;
2410 
2411       checkRows    ( rs   ,  2UL );
2412       checkColumns ( rs   ,  4UL );
2413       checkNonZeros( rs   ,  4UL );
2414       checkRows    ( tmat_,  5UL );
2415       checkColumns ( tmat_,  4UL );
2416       checkNonZeros( tmat_, 10UL );
2417 
2418       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
2419           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
2420          std::ostringstream oss;
2421          oss << " Test: " << test_ << "\n"
2422              << " Error: Assignment failed\n"
2423              << " Details:\n"
2424              << "   Result:\n" << rs << "\n"
2425              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
2426          throw std::runtime_error( oss.str() );
2427       }
2428 
2429       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
2430           tmat_(1,0) !=  0 || tmat_(1,1) != 13 || tmat_(1,2) != 14 || tmat_(1,3) !=  0 ||
2431           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
2432           tmat_(3,0) != 11 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != 12 ||
2433           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
2434          std::ostringstream oss;
2435          oss << " Test: " << test_ << "\n"
2436              << " Error: Assignment failed\n"
2437              << " Details:\n"
2438              << "   Result:\n" << tmat_ << "\n"
2439              << "   Expected result:\n(  0  0  0  0 )\n"
2440                                      "(  0 13 14  0 )\n"
2441                                      "( -2  0 -3  0 )\n"
2442                                      "( 11  0  0 12 )\n"
2443                                      "(  7 -8  9 10 )\n";
2444          throw std::runtime_error( oss.str() );
2445       }
2446    }
2447 
2448    {
2449       test_ = "Column-major/column-major dense matrix assignment (unaligned/unpadded)";
2450 
2451       initialize();
2452 
2453       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
2454 
2455       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,columnMajor>;
2456       std::unique_ptr<int[]> memory( new int[9UL] );
2457       UnalignedUnpadded mat( memory.get()+1UL, 2UL, 4UL );
2458       mat = 0;
2459       mat(0,0) = 11;
2460       mat(0,3) = 12;
2461       mat(1,1) = 13;
2462       mat(1,2) = 14;
2463 
2464       rs = mat;
2465 
2466       checkRows    ( rs   ,  2UL );
2467       checkColumns ( rs   ,  4UL );
2468       checkNonZeros( rs   ,  4UL );
2469       checkRows    ( tmat_,  5UL );
2470       checkColumns ( tmat_,  4UL );
2471       checkNonZeros( tmat_, 10UL );
2472 
2473       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
2474           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
2475          std::ostringstream oss;
2476          oss << " Test: " << test_ << "\n"
2477              << " Error: Assignment failed\n"
2478              << " Details:\n"
2479              << "   Result:\n" << rs << "\n"
2480              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
2481          throw std::runtime_error( oss.str() );
2482       }
2483 
2484       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
2485           tmat_(1,0) !=  0 || tmat_(1,1) != 13 || tmat_(1,2) != 14 || tmat_(1,3) !=  0 ||
2486           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
2487           tmat_(3,0) != 11 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != 12 ||
2488           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
2489          std::ostringstream oss;
2490          oss << " Test: " << test_ << "\n"
2491              << " Error: Assignment failed\n"
2492              << " Details:\n"
2493              << "   Result:\n" << tmat_ << "\n"
2494              << "   Expected result:\n(  0  0  0  0 )\n"
2495                                      "(  0 13 14  0 )\n"
2496                                      "( -2  0 -3  0 )\n"
2497                                      "( 11  0  0 12 )\n"
2498                                      "(  7 -8  9 10 )\n";
2499          throw std::runtime_error( oss.str() );
2500       }
2501    }
2502 
2503 
2504    //=====================================================================================
2505    // Column-major sparse matrix assignment
2506    //=====================================================================================
2507 
2508    {
2509       test_ = "Column-major/row-major sparse matrix assignment";
2510 
2511       initialize();
2512 
2513       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
2514 
2515       const blaze::CompressedMatrix<int,rowMajor> mat{ { 11,  0,  0, 12 },
2516                                                        {  0, 13, 14,  0 } };
2517 
2518       rs = mat;
2519 
2520       checkRows    ( rs   ,  2UL );
2521       checkColumns ( rs   ,  4UL );
2522       checkNonZeros( rs   ,  4UL );
2523       checkRows    ( tmat_,  5UL );
2524       checkColumns ( tmat_,  4UL );
2525       checkNonZeros( tmat_, 10UL );
2526 
2527       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
2528           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
2529          std::ostringstream oss;
2530          oss << " Test: " << test_ << "\n"
2531              << " Error: Assignment failed\n"
2532              << " Details:\n"
2533              << "   Result:\n" << rs << "\n"
2534              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
2535          throw std::runtime_error( oss.str() );
2536       }
2537 
2538       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
2539           tmat_(1,0) !=  0 || tmat_(1,1) != 13 || tmat_(1,2) != 14 || tmat_(1,3) !=  0 ||
2540           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
2541           tmat_(3,0) != 11 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != 12 ||
2542           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
2543          std::ostringstream oss;
2544          oss << " Test: " << test_ << "\n"
2545              << " Error: Assignment failed\n"
2546              << " Details:\n"
2547              << "   Result:\n" << tmat_ << "\n"
2548              << "   Expected result:\n(  0  0  0  0 )\n"
2549                                      "(  0 13 14  0 )\n"
2550                                      "( -2  0 -3  0 )\n"
2551                                      "( 11  0  0 12 )\n"
2552                                      "(  7 -8  9 10 )\n";
2553          throw std::runtime_error( oss.str() );
2554       }
2555    }
2556 
2557    {
2558       test_ = "Column-major/column-major sparse matrix assignment";
2559 
2560       initialize();
2561 
2562       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
2563 
2564       const blaze::CompressedMatrix<int,columnMajor> mat{ { 11,  0,  0, 12 },
2565                                                           {  0, 13, 14,  0 } };
2566 
2567       rs = mat;
2568 
2569       checkRows    ( rs   ,  2UL );
2570       checkColumns ( rs   ,  4UL );
2571       checkNonZeros( rs   ,  4UL );
2572       checkRows    ( tmat_,  5UL );
2573       checkColumns ( tmat_,  4UL );
2574       checkNonZeros( tmat_, 10UL );
2575 
2576       if( rs(0,0) != 11 || rs(0,1) !=  0 || rs(0,2) !=  0 || rs(0,3) != 12 ||
2577           rs(1,0) !=  0 || rs(1,1) != 13 || rs(1,2) != 14 || rs(1,3) !=  0 ) {
2578          std::ostringstream oss;
2579          oss << " Test: " << test_ << "\n"
2580              << " Error: Assignment failed\n"
2581              << " Details:\n"
2582              << "   Result:\n" << rs << "\n"
2583              << "   Expected result:\n( 11  0  0 12 )\n(  0 13 14  0 )\n";
2584          throw std::runtime_error( oss.str() );
2585       }
2586 
2587       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
2588           tmat_(1,0) !=  0 || tmat_(1,1) != 13 || tmat_(1,2) != 14 || tmat_(1,3) !=  0 ||
2589           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
2590           tmat_(3,0) != 11 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != 12 ||
2591           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
2592          std::ostringstream oss;
2593          oss << " Test: " << test_ << "\n"
2594              << " Error: Assignment failed\n"
2595              << " Details:\n"
2596              << "   Result:\n" << tmat_ << "\n"
2597              << "   Expected result:\n(  0  0  0  0 )\n"
2598                                      "(  0 13 14  0 )\n"
2599                                      "( -2  0 -3  0 )\n"
2600                                      "( 11  0  0 12 )\n"
2601                                      "(  7 -8  9 10 )\n";
2602          throw std::runtime_error( oss.str() );
2603       }
2604    }
2605 }
2606 //*************************************************************************************************
2607 
2608 
2609 //*************************************************************************************************
2610 /*!\brief Test of the Rows addition assignment operators.
2611 //
2612 // \return void
2613 // \exception std::runtime_error Error detected.
2614 //
2615 // This function performs a test of the addition assignment operators of the Rows specialization.
2616 // In case an error is detected, a \a std::runtime_error exception is thrown.
2617 */
testAddAssign()2618 void DenseGeneralTest::testAddAssign()
2619 {
2620    using blaze::aligned;
2621    using blaze::unaligned;
2622    using blaze::padded;
2623    using blaze::unpadded;
2624    using blaze::rowMajor;
2625    using blaze::columnMajor;
2626 
2627 
2628    //=====================================================================================
2629    // Row-major Rows addition assignment
2630    //=====================================================================================
2631 
2632    {
2633       test_ = "Row-major Rows addition assignment (no aliasing)";
2634 
2635       initialize();
2636 
2637       MT mat{ {  0,  0,  0,  0 },
2638               { 11,  0, 12,  0 },
2639               {  0,  0,  0,  0 },
2640               { 13, 14, 15, 16 },
2641               {  0,  0,  0,  0 } };
2642 
2643       auto rs = blaze::rows( mat, { 3UL, 1UL } );
2644       rs += blaze::rows( mat_, { 3UL, 1UL } );
2645 
2646       checkRows    ( rs , 2UL );
2647       checkColumns ( rs , 4UL );
2648       checkNonZeros( rs , 7UL );
2649       checkRows    ( mat, 5UL );
2650       checkColumns ( mat, 4UL );
2651       checkNonZeros( mat, 7UL );
2652 
2653       if( rs(0,0) != 13 || rs(0,1) != 18 || rs(0,2) != 20 || rs(0,3) != 10 ||
2654           rs(1,0) != 11 || rs(1,1) !=  1 || rs(1,2) != 12 || rs(1,3) !=  0 ) {
2655          std::ostringstream oss;
2656          oss << " Test: " << test_ << "\n"
2657              << " Error: Addition assignment failed\n"
2658              << " Details:\n"
2659              << "   Result:\n" << rs << "\n"
2660              << "   Expected result:\n( 13 18 20 10 )\n( 11  1 12  0 )\n";
2661          throw std::runtime_error( oss.str() );
2662       }
2663 
2664       if( mat(0,0) !=  0 || mat(0,1) !=  0 || mat(0,2) !=  0 || mat(0,3) !=  0 ||
2665           mat(1,0) != 11 || mat(1,1) !=  1 || mat(1,2) != 12 || mat(1,3) !=  0 ||
2666           mat(2,0) !=  0 || mat(2,1) !=  0 || mat(2,2) !=  0 || mat(2,3) !=  0 ||
2667           mat(3,0) != 13 || mat(3,1) != 18 || mat(3,2) != 20 || mat(3,3) != 10 ||
2668           mat(4,0) !=  0 || mat(4,1) !=  0 || mat(4,2) !=  0 || mat(4,3) !=  0 ) {
2669          std::ostringstream oss;
2670          oss << " Test: " << test_ << "\n"
2671              << " Error: Addition assignment failed\n"
2672              << " Details:\n"
2673              << "   Result:\n" << mat << "\n"
2674              << "   Expected result:\n(  0  0  0  0 )\n"
2675                                      "( 11  1 12  0 )\n"
2676                                      "(  0  0  0  0 )\n"
2677                                      "( 13 18 20 10 )\n"
2678                                      "(  0  0  0  0 )\n";
2679          throw std::runtime_error( oss.str() );
2680       }
2681    }
2682 
2683    {
2684       test_ = "Row-major Rows addition assignment (aliasing)";
2685 
2686       initialize();
2687 
2688       auto rs = blaze::rows( mat_, { 3UL, 4UL } );
2689       rs += blaze::rows( mat_, { 2UL, 3UL } );
2690 
2691       checkRows    ( rs  , 2UL );
2692       checkColumns ( rs  , 4UL );
2693       checkNonZeros( rs  , 8UL );
2694       checkRows    ( mat_, 5UL );
2695       checkColumns ( mat_, 4UL );
2696       checkNonZeros( mat_, 11UL );
2697 
2698       if( rs(0,0) != -2 || rs(0,1) !=  4 || rs(0,2) !=  2 || rs(0,3) != -6 ||
2699           rs(1,0) !=  7 || rs(1,1) != -4 || rs(1,2) != 14 || rs(1,3) !=  4 ) {
2700          std::ostringstream oss;
2701          oss << " Test: " << test_ << "\n"
2702              << " Error: Addition assignment failed\n"
2703              << " Details:\n"
2704              << "   Result:\n" << rs << "\n"
2705              << "   Expected result:\n( -2  4  2 -6 )\n(  7 -4 14  4 )\n";
2706          throw std::runtime_error( oss.str() );
2707       }
2708 
2709       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
2710           mat_(1,0) !=  0 || mat_(1,1) !=  1 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
2711           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
2712           mat_(3,0) != -2 || mat_(3,1) !=  4 || mat_(3,2) !=  2 || mat_(3,3) != -6 ||
2713           mat_(4,0) !=  7 || mat_(4,1) != -4 || mat_(4,2) != 14 || mat_(4,3) !=  4 ) {
2714          std::ostringstream oss;
2715          oss << " Test: " << test_ << "\n"
2716              << " Error: Addition assignment failed\n"
2717              << " Details:\n"
2718              << "   Result:\n" << mat_ << "\n"
2719              << "   Expected result:\n(  0  0  0  0 )\n"
2720                                      "(  0  1  0  0 )\n"
2721                                      "( -2  0 -3  0 )\n"
2722                                      "( -2  4  2 -6 )\n"
2723                                      "(  7 -4 14  4 )\n";
2724          throw std::runtime_error( oss.str() );
2725       }
2726    }
2727 
2728 
2729    //=====================================================================================
2730    // Row-major dense matrix addition assignment
2731    //=====================================================================================
2732 
2733    {
2734       test_ = "Row-major/row-major dense matrix addition assignment (mixed type)";
2735 
2736       initialize();
2737 
2738       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
2739 
2740       const blaze::DynamicMatrix<short,rowMajor> mat{ { 11,  0,  0, 12 },
2741                                                       {  0, 13, 14,  0 } };
2742 
2743       rs += mat;
2744 
2745       checkRows    ( rs  ,  2UL );
2746       checkColumns ( rs  ,  4UL );
2747       checkNonZeros( rs  ,  6UL );
2748       checkRows    ( mat_,  5UL );
2749       checkColumns ( mat_,  4UL );
2750       checkNonZeros( mat_, 12UL );
2751 
2752       if( rs(0,0) != 11 || rs(0,1) !=  4 || rs(0,2) !=  5 || rs(0,3) != 6 ||
2753           rs(1,0) !=  0 || rs(1,1) != 14 || rs(1,2) != 14 || rs(1,3) != 0 ) {
2754          std::ostringstream oss;
2755          oss << " Test: " << test_ << "\n"
2756              << " Error: Addition assignment failed\n"
2757              << " Details:\n"
2758              << "   Result:\n" << rs << "\n"
2759              << "   Expected result:\n( 11  4 17 -6 )\n(  0 14 14  0 )\n";
2760          throw std::runtime_error( oss.str() );
2761       }
2762 
2763       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
2764           mat_(1,0) !=  0 || mat_(1,1) != 14 || mat_(1,2) != 14 || mat_(1,3) !=  0 ||
2765           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
2766           mat_(3,0) != 11 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) !=  6 ||
2767           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
2768          std::ostringstream oss;
2769          oss << " Test: " << test_ << "\n"
2770              << " Error: Addition assignment failed\n"
2771              << " Details:\n"
2772              << "   Result:\n" << mat_ << "\n"
2773              << "   Expected result:\n(  0  0  0  0 )\n"
2774                                      "(  0 14 14  0 )\n"
2775                                      "( -2  0 -3  0 )\n"
2776                                      "( 11  4  5  6 )\n"
2777                                      "(  7 -8  9 10 )\n";
2778          throw std::runtime_error( oss.str() );
2779       }
2780    }
2781 
2782    {
2783       test_ = "Row-major/row-major dense matrix addition assignment (aligned/padded)";
2784 
2785       initialize();
2786 
2787       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
2788 
2789       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,rowMajor>;
2790       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 32UL ) );
2791       AlignedPadded mat( memory.get(), 2UL, 4UL, 16UL );
2792       mat = 0;
2793       mat(0,0) = 11;
2794       mat(0,3) = 12;
2795       mat(1,1) = 13;
2796       mat(1,2) = 14;
2797 
2798       rs += mat;
2799 
2800       checkRows    ( rs  ,  2UL );
2801       checkColumns ( rs  ,  4UL );
2802       checkNonZeros( rs  ,  6UL );
2803       checkRows    ( mat_,  5UL );
2804       checkColumns ( mat_,  4UL );
2805       checkNonZeros( mat_, 12UL );
2806 
2807       if( rs(0,0) != 11 || rs(0,1) !=  4 || rs(0,2) !=  5 || rs(0,3) != 6 ||
2808           rs(1,0) !=  0 || rs(1,1) != 14 || rs(1,2) != 14 || rs(1,3) != 0 ) {
2809          std::ostringstream oss;
2810          oss << " Test: " << test_ << "\n"
2811              << " Error: Addition assignment failed\n"
2812              << " Details:\n"
2813              << "   Result:\n" << rs << "\n"
2814              << "   Expected result:\n( 11  4 17 -6 )\n(  0 14 14  0 )\n";
2815          throw std::runtime_error( oss.str() );
2816       }
2817 
2818       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
2819           mat_(1,0) !=  0 || mat_(1,1) != 14 || mat_(1,2) != 14 || mat_(1,3) !=  0 ||
2820           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
2821           mat_(3,0) != 11 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) !=  6 ||
2822           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
2823          std::ostringstream oss;
2824          oss << " Test: " << test_ << "\n"
2825              << " Error: Addition assignment failed\n"
2826              << " Details:\n"
2827              << "   Result:\n" << mat_ << "\n"
2828              << "   Expected result:\n(  0  0  0  0 )\n"
2829                                      "(  0 14 14  0 )\n"
2830                                      "( -2  0 -3  0 )\n"
2831                                      "( 11  4  5  6 )\n"
2832                                      "(  7 -8  9 10 )\n";
2833          throw std::runtime_error( oss.str() );
2834       }
2835    }
2836 
2837    {
2838       test_ = "Row-major/row-major dense matrix addition assignment (unaligned/unpadded)";
2839 
2840       initialize();
2841 
2842       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
2843 
2844       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,rowMajor>;
2845       std::unique_ptr<int[]> memory( new int[9UL] );
2846       UnalignedUnpadded mat( memory.get()+1UL, 2UL, 4UL );
2847       mat = 0;
2848       mat(0,0) = 11;
2849       mat(0,3) = 12;
2850       mat(1,1) = 13;
2851       mat(1,2) = 14;
2852 
2853       rs += mat;
2854 
2855       checkRows    ( rs  ,  2UL );
2856       checkColumns ( rs  ,  4UL );
2857       checkNonZeros( rs  ,  6UL );
2858       checkRows    ( mat_,  5UL );
2859       checkColumns ( mat_,  4UL );
2860       checkNonZeros( mat_, 12UL );
2861 
2862       if( rs(0,0) != 11 || rs(0,1) !=  4 || rs(0,2) !=  5 || rs(0,3) != 6 ||
2863           rs(1,0) !=  0 || rs(1,1) != 14 || rs(1,2) != 14 || rs(1,3) != 0 ) {
2864          std::ostringstream oss;
2865          oss << " Test: " << test_ << "\n"
2866              << " Error: Addition assignment failed\n"
2867              << " Details:\n"
2868              << "   Result:\n" << rs << "\n"
2869              << "   Expected result:\n( 11  4 17 -6 )\n(  0 14 14  0 )\n";
2870          throw std::runtime_error( oss.str() );
2871       }
2872 
2873       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
2874           mat_(1,0) !=  0 || mat_(1,1) != 14 || mat_(1,2) != 14 || mat_(1,3) !=  0 ||
2875           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
2876           mat_(3,0) != 11 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) !=  6 ||
2877           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
2878          std::ostringstream oss;
2879          oss << " Test: " << test_ << "\n"
2880              << " Error: Addition assignment failed\n"
2881              << " Details:\n"
2882              << "   Result:\n" << mat_ << "\n"
2883              << "   Expected result:\n(  0  0  0  0 )\n"
2884                                      "(  0 14 14  0 )\n"
2885                                      "( -2  0 -3  0 )\n"
2886                                      "( 11  4  5  6 )\n"
2887                                      "(  7 -8  9 10 )\n";
2888          throw std::runtime_error( oss.str() );
2889       }
2890    }
2891 
2892    {
2893       test_ = "Row-major/column-major dense matrix addition assignment (mixed type)";
2894 
2895       initialize();
2896 
2897       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
2898 
2899       const blaze::DynamicMatrix<short,columnMajor> mat{ { 11,  0,  0, 12 },
2900                                                          {  0, 13, 14,  0 } };
2901 
2902       rs += mat;
2903 
2904       checkRows    ( rs  ,  2UL );
2905       checkColumns ( rs  ,  4UL );
2906       checkNonZeros( rs  ,  6UL );
2907       checkRows    ( mat_,  5UL );
2908       checkColumns ( mat_,  4UL );
2909       checkNonZeros( mat_, 12UL );
2910 
2911       if( rs(0,0) != 11 || rs(0,1) !=  4 || rs(0,2) !=  5 || rs(0,3) != 6 ||
2912           rs(1,0) !=  0 || rs(1,1) != 14 || rs(1,2) != 14 || rs(1,3) != 0 ) {
2913          std::ostringstream oss;
2914          oss << " Test: " << test_ << "\n"
2915              << " Error: Addition assignment failed\n"
2916              << " Details:\n"
2917              << "   Result:\n" << rs << "\n"
2918              << "   Expected result:\n( 11  4 17 -6 )\n(  0 14 14  0 )\n";
2919          throw std::runtime_error( oss.str() );
2920       }
2921 
2922       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
2923           mat_(1,0) !=  0 || mat_(1,1) != 14 || mat_(1,2) != 14 || mat_(1,3) !=  0 ||
2924           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
2925           mat_(3,0) != 11 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) !=  6 ||
2926           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
2927          std::ostringstream oss;
2928          oss << " Test: " << test_ << "\n"
2929              << " Error: Addition assignment failed\n"
2930              << " Details:\n"
2931              << "   Result:\n" << mat_ << "\n"
2932              << "   Expected result:\n(  0  0  0  0 )\n"
2933                                      "(  0 14 14  0 )\n"
2934                                      "( -2  0 -3  0 )\n"
2935                                      "( 11  4  5  6 )\n"
2936                                      "(  7 -8  9 10 )\n";
2937          throw std::runtime_error( oss.str() );
2938       }
2939    }
2940 
2941    {
2942       test_ = "Row-major/column-major dense matrix addition assignment (aligned/padded)";
2943 
2944       initialize();
2945 
2946       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
2947 
2948       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,columnMajor>;
2949       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 64UL ) );
2950       AlignedPadded mat( memory.get(), 2UL, 4UL, 16UL );
2951       mat = 0;
2952       mat(0,0) = 11;
2953       mat(0,3) = 12;
2954       mat(1,1) = 13;
2955       mat(1,2) = 14;
2956 
2957       rs += mat;
2958 
2959       checkRows    ( rs  ,  2UL );
2960       checkColumns ( rs  ,  4UL );
2961       checkNonZeros( rs  ,  6UL );
2962       checkRows    ( mat_,  5UL );
2963       checkColumns ( mat_,  4UL );
2964       checkNonZeros( mat_, 12UL );
2965 
2966       if( rs(0,0) != 11 || rs(0,1) !=  4 || rs(0,2) !=  5 || rs(0,3) != 6 ||
2967           rs(1,0) !=  0 || rs(1,1) != 14 || rs(1,2) != 14 || rs(1,3) != 0 ) {
2968          std::ostringstream oss;
2969          oss << " Test: " << test_ << "\n"
2970              << " Error: Addition assignment failed\n"
2971              << " Details:\n"
2972              << "   Result:\n" << rs << "\n"
2973              << "   Expected result:\n( 11  4 17 -6 )\n(  0 14 14  0 )\n";
2974          throw std::runtime_error( oss.str() );
2975       }
2976 
2977       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
2978           mat_(1,0) !=  0 || mat_(1,1) != 14 || mat_(1,2) != 14 || mat_(1,3) !=  0 ||
2979           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
2980           mat_(3,0) != 11 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) !=  6 ||
2981           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
2982          std::ostringstream oss;
2983          oss << " Test: " << test_ << "\n"
2984              << " Error: Addition assignment failed\n"
2985              << " Details:\n"
2986              << "   Result:\n" << mat_ << "\n"
2987              << "   Expected result:\n(  0  0  0  0 )\n"
2988                                      "(  0 14 14  0 )\n"
2989                                      "( -2  0 -3  0 )\n"
2990                                      "( 11  4  5  6 )\n"
2991                                      "(  7 -8  9 10 )\n";
2992          throw std::runtime_error( oss.str() );
2993       }
2994    }
2995 
2996    {
2997       test_ = "Row-major/column-major dense matrix addition assignment (unaligned/unpadded)";
2998 
2999       initialize();
3000 
3001       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
3002 
3003       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,columnMajor>;
3004       std::unique_ptr<int[]> memory( new int[9UL] );
3005       UnalignedUnpadded mat( memory.get()+1UL, 2UL, 4UL );
3006       mat = 0;
3007       mat(0,0) = 11;
3008       mat(0,3) = 12;
3009       mat(1,1) = 13;
3010       mat(1,2) = 14;
3011 
3012       rs += mat;
3013 
3014       checkRows    ( rs  ,  2UL );
3015       checkColumns ( rs  ,  4UL );
3016       checkNonZeros( rs  ,  6UL );
3017       checkRows    ( mat_,  5UL );
3018       checkColumns ( mat_,  4UL );
3019       checkNonZeros( mat_, 12UL );
3020 
3021       if( rs(0,0) != 11 || rs(0,1) !=  4 || rs(0,2) !=  5 || rs(0,3) != 6 ||
3022           rs(1,0) !=  0 || rs(1,1) != 14 || rs(1,2) != 14 || rs(1,3) != 0 ) {
3023          std::ostringstream oss;
3024          oss << " Test: " << test_ << "\n"
3025              << " Error: Addition assignment failed\n"
3026              << " Details:\n"
3027              << "   Result:\n" << rs << "\n"
3028              << "   Expected result:\n( 11  4 17 -6 )\n(  0 14 14  0 )\n";
3029          throw std::runtime_error( oss.str() );
3030       }
3031 
3032       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
3033           mat_(1,0) !=  0 || mat_(1,1) != 14 || mat_(1,2) != 14 || mat_(1,3) !=  0 ||
3034           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
3035           mat_(3,0) != 11 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) !=  6 ||
3036           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
3037          std::ostringstream oss;
3038          oss << " Test: " << test_ << "\n"
3039              << " Error: Addition assignment failed\n"
3040              << " Details:\n"
3041              << "   Result:\n" << mat_ << "\n"
3042              << "   Expected result:\n(  0  0  0  0 )\n"
3043                                      "(  0 14 14  0 )\n"
3044                                      "( -2  0 -3  0 )\n"
3045                                      "( 11  4  5  6 )\n"
3046                                      "(  7 -8  9 10 )\n";
3047          throw std::runtime_error( oss.str() );
3048       }
3049    }
3050 
3051 
3052    //=====================================================================================
3053    // Row-major sparse matrix addition assignment
3054    //=====================================================================================
3055 
3056    {
3057       test_ = "Row-major/row-major sparse matrix addition assignment";
3058 
3059       initialize();
3060 
3061       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
3062 
3063       const blaze::CompressedMatrix<int,rowMajor> mat{ { 11,  0,  0, 12 },
3064                                                        {  0, 13, 14,  0 } };
3065 
3066       rs += mat;
3067 
3068       checkRows    ( rs  ,  2UL );
3069       checkColumns ( rs  ,  4UL );
3070       checkNonZeros( rs  ,  6UL );
3071       checkRows    ( mat_,  5UL );
3072       checkColumns ( mat_,  4UL );
3073       checkNonZeros( mat_, 12UL );
3074 
3075       if( rs(0,0) != 11 || rs(0,1) !=  4 || rs(0,2) !=  5 || rs(0,3) != 6 ||
3076           rs(1,0) !=  0 || rs(1,1) != 14 || rs(1,2) != 14 || rs(1,3) != 0 ) {
3077          std::ostringstream oss;
3078          oss << " Test: " << test_ << "\n"
3079              << " Error: Addition assignment failed\n"
3080              << " Details:\n"
3081              << "   Result:\n" << rs << "\n"
3082              << "   Expected result:\n( 11  4 17 -6 )\n(  0 14 14  0 )\n";
3083          throw std::runtime_error( oss.str() );
3084       }
3085 
3086       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
3087           mat_(1,0) !=  0 || mat_(1,1) != 14 || mat_(1,2) != 14 || mat_(1,3) !=  0 ||
3088           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
3089           mat_(3,0) != 11 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) !=  6 ||
3090           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
3091          std::ostringstream oss;
3092          oss << " Test: " << test_ << "\n"
3093              << " Error: Addition assignment failed\n"
3094              << " Details:\n"
3095              << "   Result:\n" << mat_ << "\n"
3096              << "   Expected result:\n(  0  0  0  0 )\n"
3097                                      "(  0 14 14  0 )\n"
3098                                      "( -2  0 -3  0 )\n"
3099                                      "( 11  4  5  6 )\n"
3100                                      "(  7 -8  9 10 )\n";
3101          throw std::runtime_error( oss.str() );
3102       }
3103    }
3104 
3105    {
3106       test_ = "Row-major/column-major sparse matrix addition assignment";
3107 
3108       initialize();
3109 
3110       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
3111 
3112       const blaze::CompressedMatrix<int,columnMajor> mat{ { 11,  0,  0, 12 },
3113                                                           {  0, 13, 14,  0 } };
3114 
3115       rs += mat;
3116 
3117       checkRows    ( rs  ,  2UL );
3118       checkColumns ( rs  ,  4UL );
3119       checkNonZeros( rs  ,  6UL );
3120       checkRows    ( mat_,  5UL );
3121       checkColumns ( mat_,  4UL );
3122       checkNonZeros( mat_, 12UL );
3123 
3124       if( rs(0,0) != 11 || rs(0,1) !=  4 || rs(0,2) !=  5 || rs(0,3) != 6 ||
3125           rs(1,0) !=  0 || rs(1,1) != 14 || rs(1,2) != 14 || rs(1,3) != 0 ) {
3126          std::ostringstream oss;
3127          oss << " Test: " << test_ << "\n"
3128              << " Error: Addition assignment failed\n"
3129              << " Details:\n"
3130              << "   Result:\n" << rs << "\n"
3131              << "   Expected result:\n( 11  4 17 -6 )\n(  0 14 14  0 )\n";
3132          throw std::runtime_error( oss.str() );
3133       }
3134 
3135       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
3136           mat_(1,0) !=  0 || mat_(1,1) != 14 || mat_(1,2) != 14 || mat_(1,3) !=  0 ||
3137           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
3138           mat_(3,0) != 11 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) !=  6 ||
3139           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
3140          std::ostringstream oss;
3141          oss << " Test: " << test_ << "\n"
3142              << " Error: Addition assignment failed\n"
3143              << " Details:\n"
3144              << "   Result:\n" << mat_ << "\n"
3145              << "   Expected result:\n(  0  0  0  0 )\n"
3146                                      "(  0 14 14  0 )\n"
3147                                      "( -2  0 -3  0 )\n"
3148                                      "( 11  4  5  6 )\n"
3149                                      "(  7 -8  9 10 )\n";
3150          throw std::runtime_error( oss.str() );
3151       }
3152    }
3153 
3154 
3155    //=====================================================================================
3156    // Column-major Rows addition assignment
3157    //=====================================================================================
3158 
3159    {
3160       test_ = "Column-major Rows addition assignment (no aliasing)";
3161 
3162       initialize();
3163 
3164       OMT mat{ {  0,  0,  0,  0 },
3165                { 11,  0, 12,  0 },
3166                {  0,  0,  0,  0 },
3167                { 13, 14, 15, 16 },
3168                {  0,  0,  0,  0 } };
3169 
3170       auto rs = blaze::rows( mat, { 3UL, 1UL } );
3171       rs += blaze::rows( tmat_, { 3UL, 1UL } );
3172 
3173       checkRows    ( rs , 2UL );
3174       checkColumns ( rs , 4UL );
3175       checkNonZeros( rs , 7UL );
3176       checkRows    ( mat, 5UL );
3177       checkColumns ( mat, 4UL );
3178       checkNonZeros( mat, 7UL );
3179 
3180       if( rs(0,0) != 13 || rs(0,1) != 18 || rs(0,2) != 20 || rs(0,3) != 10 ||
3181           rs(1,0) != 11 || rs(1,1) !=  1 || rs(1,2) != 12 || rs(1,3) !=  0 ) {
3182          std::ostringstream oss;
3183          oss << " Test: " << test_ << "\n"
3184              << " Error: Addition assignment failed\n"
3185              << " Details:\n"
3186              << "   Result:\n" << rs << "\n"
3187              << "   Expected result:\n( 13 18 20 10 )\n( 11  1 12  0 )\n";
3188          throw std::runtime_error( oss.str() );
3189       }
3190 
3191       if( mat(0,0) !=  0 || mat(0,1) !=  0 || mat(0,2) !=  0 || mat(0,3) !=  0 ||
3192           mat(1,0) != 11 || mat(1,1) !=  1 || mat(1,2) != 12 || mat(1,3) !=  0 ||
3193           mat(2,0) !=  0 || mat(2,1) !=  0 || mat(2,2) !=  0 || mat(2,3) !=  0 ||
3194           mat(3,0) != 13 || mat(3,1) != 18 || mat(3,2) != 20 || mat(3,3) != 10 ||
3195           mat(4,0) !=  0 || mat(4,1) !=  0 || mat(4,2) !=  0 || mat(4,3) !=  0 ) {
3196          std::ostringstream oss;
3197          oss << " Test: " << test_ << "\n"
3198              << " Error: Addition assignment failed\n"
3199              << " Details:\n"
3200              << "   Result:\n" << mat << "\n"
3201              << "   Expected result:\n(  0  0  0  0 )\n"
3202                                      "( 11  1 12  0 )\n"
3203                                      "(  0  0  0  0 )\n"
3204                                      "( 13 18 20 10 )\n"
3205                                      "(  0  0  0  0 )\n";
3206          throw std::runtime_error( oss.str() );
3207       }
3208    }
3209 
3210    {
3211       test_ = "Column-major Rows addition assignment (aliasing)";
3212 
3213       initialize();
3214 
3215       auto rs = blaze::rows( tmat_, { 3UL, 4UL } );
3216       rs += blaze::rows( tmat_, { 2UL, 3UL } );
3217 
3218       checkRows    ( rs   , 2UL );
3219       checkColumns ( rs   , 4UL );
3220       checkNonZeros( rs   , 8UL );
3221       checkRows    ( tmat_, 5UL );
3222       checkColumns ( tmat_, 4UL );
3223       checkNonZeros( tmat_, 11UL );
3224 
3225       if( rs(0,0) != -2 || rs(0,1) !=  4 || rs(0,2) !=  2 || rs(0,3) != -6 ||
3226           rs(1,0) !=  7 || rs(1,1) != -4 || rs(1,2) != 14 || rs(1,3) !=  4 ) {
3227          std::ostringstream oss;
3228          oss << " Test: " << test_ << "\n"
3229              << " Error: Addition assignment failed\n"
3230              << " Details:\n"
3231              << "   Result:\n" << rs << "\n"
3232              << "   Expected result:\n( -2  4  2 -6 )\n(  7 -4 14  4 )\n";
3233          throw std::runtime_error( oss.str() );
3234       }
3235 
3236       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
3237           tmat_(1,0) !=  0 || tmat_(1,1) !=  1 || tmat_(1,2) !=  0 || tmat_(1,3) !=  0 ||
3238           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
3239           tmat_(3,0) != -2 || tmat_(3,1) !=  4 || tmat_(3,2) !=  2 || tmat_(3,3) != -6 ||
3240           tmat_(4,0) !=  7 || tmat_(4,1) != -4 || tmat_(4,2) != 14 || tmat_(4,3) !=  4 ) {
3241          std::ostringstream oss;
3242          oss << " Test: " << test_ << "\n"
3243              << " Error: Addition assignment failed\n"
3244              << " Details:\n"
3245              << "   Result:\n" << tmat_ << "\n"
3246              << "   Expected result:\n(  0  0  0  0 )\n"
3247                                      "(  0  1  0  0 )\n"
3248                                      "( -2  0 -3  0 )\n"
3249                                      "( -2  4  2 -6 )\n"
3250                                      "(  7 -4 14  4 )\n";
3251          throw std::runtime_error( oss.str() );
3252       }
3253    }
3254 
3255 
3256    //=====================================================================================
3257    // Column-major dense matrix addition assignment
3258    //=====================================================================================
3259 
3260    {
3261       test_ = "Column-major/row-major dense matrix addition assignment (mixed type)";
3262 
3263       initialize();
3264 
3265       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
3266 
3267       const blaze::DynamicMatrix<short,rowMajor> mat{ { 11,  0,  0, 12 },
3268                                                       {  0, 13, 14,  0 } };
3269 
3270       rs += mat;
3271 
3272       checkRows    ( rs   ,  2UL );
3273       checkColumns ( rs   ,  4UL );
3274       checkNonZeros( rs   ,  6UL );
3275       checkRows    ( tmat_,  5UL );
3276       checkColumns ( tmat_,  4UL );
3277       checkNonZeros( tmat_, 12UL );
3278 
3279       if( rs(0,0) != 11 || rs(0,1) !=  4 || rs(0,2) !=  5 || rs(0,3) != 6 ||
3280           rs(1,0) !=  0 || rs(1,1) != 14 || rs(1,2) != 14 || rs(1,3) != 0 ) {
3281          std::ostringstream oss;
3282          oss << " Test: " << test_ << "\n"
3283              << " Error: Addition assignment failed\n"
3284              << " Details:\n"
3285              << "   Result:\n" << rs << "\n"
3286              << "   Expected result:\n( 11  4 17 -6 )\n(  0 14 14  0 )\n";
3287          throw std::runtime_error( oss.str() );
3288       }
3289 
3290       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
3291           tmat_(1,0) !=  0 || tmat_(1,1) != 14 || tmat_(1,2) != 14 || tmat_(1,3) !=  0 ||
3292           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
3293           tmat_(3,0) != 11 || tmat_(3,1) !=  4 || tmat_(3,2) !=  5 || tmat_(3,3) !=  6 ||
3294           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
3295          std::ostringstream oss;
3296          oss << " Test: " << test_ << "\n"
3297              << " Error: Addition assignment failed\n"
3298              << " Details:\n"
3299              << "   Result:\n" << tmat_ << "\n"
3300              << "   Expected result:\n(  0  0  0  0 )\n"
3301                                      "(  0 14 14  0 )\n"
3302                                      "( -2  0 -3  0 )\n"
3303                                      "( 11  4  5  6 )\n"
3304                                      "(  7 -8  9 10 )\n";
3305          throw std::runtime_error( oss.str() );
3306       }
3307    }
3308 
3309    {
3310       test_ = "Column-major/row-major dense matrix addition assignment (aligned/padded)";
3311 
3312       initialize();
3313 
3314       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
3315 
3316       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,rowMajor>;
3317       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 32UL ) );
3318       AlignedPadded mat( memory.get(), 2UL, 4UL, 16UL );
3319       mat = 0;
3320       mat(0,0) = 11;
3321       mat(0,3) = 12;
3322       mat(1,1) = 13;
3323       mat(1,2) = 14;
3324 
3325       rs += mat;
3326 
3327       checkRows    ( rs   ,  2UL );
3328       checkColumns ( rs   ,  4UL );
3329       checkNonZeros( rs   ,  6UL );
3330       checkRows    ( tmat_,  5UL );
3331       checkColumns ( tmat_,  4UL );
3332       checkNonZeros( tmat_, 12UL );
3333 
3334       if( rs(0,0) != 11 || rs(0,1) !=  4 || rs(0,2) !=  5 || rs(0,3) != 6 ||
3335           rs(1,0) !=  0 || rs(1,1) != 14 || rs(1,2) != 14 || rs(1,3) != 0 ) {
3336          std::ostringstream oss;
3337          oss << " Test: " << test_ << "\n"
3338              << " Error: Addition assignment failed\n"
3339              << " Details:\n"
3340              << "   Result:\n" << rs << "\n"
3341              << "   Expected result:\n( 11  4 17 -6 )\n(  0 14 14  0 )\n";
3342          throw std::runtime_error( oss.str() );
3343       }
3344 
3345       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
3346           tmat_(1,0) !=  0 || tmat_(1,1) != 14 || tmat_(1,2) != 14 || tmat_(1,3) !=  0 ||
3347           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
3348           tmat_(3,0) != 11 || tmat_(3,1) !=  4 || tmat_(3,2) !=  5 || tmat_(3,3) !=  6 ||
3349           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
3350          std::ostringstream oss;
3351          oss << " Test: " << test_ << "\n"
3352              << " Error: Addition assignment failed\n"
3353              << " Details:\n"
3354              << "   Result:\n" << tmat_ << "\n"
3355              << "   Expected result:\n(  0  0  0  0 )\n"
3356                                      "(  0 14 14  0 )\n"
3357                                      "( -2  0 -3  0 )\n"
3358                                      "( 11  4  5  6 )\n"
3359                                      "(  7 -8  9 10 )\n";
3360          throw std::runtime_error( oss.str() );
3361       }
3362    }
3363 
3364    {
3365       test_ = "Column-major/row-major dense matrix addition assignment (unaligned/unpadded)";
3366 
3367       initialize();
3368 
3369       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
3370 
3371       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,rowMajor>;
3372       std::unique_ptr<int[]> memory( new int[9UL] );
3373       UnalignedUnpadded mat( memory.get()+1UL, 2UL, 4UL );
3374       mat = 0;
3375       mat(0,0) = 11;
3376       mat(0,3) = 12;
3377       mat(1,1) = 13;
3378       mat(1,2) = 14;
3379 
3380       rs += mat;
3381 
3382       checkRows    ( rs   ,  2UL );
3383       checkColumns ( rs   ,  4UL );
3384       checkNonZeros( rs   ,  6UL );
3385       checkRows    ( tmat_,  5UL );
3386       checkColumns ( tmat_,  4UL );
3387       checkNonZeros( tmat_, 12UL );
3388 
3389       if( rs(0,0) != 11 || rs(0,1) !=  4 || rs(0,2) !=  5 || rs(0,3) != 6 ||
3390           rs(1,0) !=  0 || rs(1,1) != 14 || rs(1,2) != 14 || rs(1,3) != 0 ) {
3391          std::ostringstream oss;
3392          oss << " Test: " << test_ << "\n"
3393              << " Error: Addition assignment failed\n"
3394              << " Details:\n"
3395              << "   Result:\n" << rs << "\n"
3396              << "   Expected result:\n( 11  4 17 -6 )\n(  0 14 14  0 )\n";
3397          throw std::runtime_error( oss.str() );
3398       }
3399 
3400       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
3401           tmat_(1,0) !=  0 || tmat_(1,1) != 14 || tmat_(1,2) != 14 || tmat_(1,3) !=  0 ||
3402           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
3403           tmat_(3,0) != 11 || tmat_(3,1) !=  4 || tmat_(3,2) !=  5 || tmat_(3,3) !=  6 ||
3404           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
3405          std::ostringstream oss;
3406          oss << " Test: " << test_ << "\n"
3407              << " Error: Addition assignment failed\n"
3408              << " Details:\n"
3409              << "   Result:\n" << tmat_ << "\n"
3410              << "   Expected result:\n(  0  0  0  0 )\n"
3411                                      "(  0 14 14  0 )\n"
3412                                      "( -2  0 -3  0 )\n"
3413                                      "( 11  4  5  6 )\n"
3414                                      "(  7 -8  9 10 )\n";
3415          throw std::runtime_error( oss.str() );
3416       }
3417    }
3418 
3419    {
3420       test_ = "Column-major/column-major dense matrix addition assignment (mixed type)";
3421 
3422       initialize();
3423 
3424       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
3425 
3426       const blaze::DynamicMatrix<short,columnMajor> mat{ { 11,  0,  0, 12 },
3427                                                          {  0, 13, 14,  0 } };
3428 
3429       rs += mat;
3430 
3431       checkRows    ( rs   ,  2UL );
3432       checkColumns ( rs   ,  4UL );
3433       checkNonZeros( rs   ,  6UL );
3434       checkRows    ( tmat_,  5UL );
3435       checkColumns ( tmat_,  4UL );
3436       checkNonZeros( tmat_, 12UL );
3437 
3438       if( rs(0,0) != 11 || rs(0,1) !=  4 || rs(0,2) !=  5 || rs(0,3) != 6 ||
3439           rs(1,0) !=  0 || rs(1,1) != 14 || rs(1,2) != 14 || rs(1,3) != 0 ) {
3440          std::ostringstream oss;
3441          oss << " Test: " << test_ << "\n"
3442              << " Error: Addition assignment failed\n"
3443              << " Details:\n"
3444              << "   Result:\n" << rs << "\n"
3445              << "   Expected result:\n( 11  4 17 -6 )\n(  0 14 14  0 )\n";
3446          throw std::runtime_error( oss.str() );
3447       }
3448 
3449       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
3450           tmat_(1,0) !=  0 || tmat_(1,1) != 14 || tmat_(1,2) != 14 || tmat_(1,3) !=  0 ||
3451           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
3452           tmat_(3,0) != 11 || tmat_(3,1) !=  4 || tmat_(3,2) !=  5 || tmat_(3,3) !=  6 ||
3453           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
3454          std::ostringstream oss;
3455          oss << " Test: " << test_ << "\n"
3456              << " Error: Addition assignment failed\n"
3457              << " Details:\n"
3458              << "   Result:\n" << tmat_ << "\n"
3459              << "   Expected result:\n(  0  0  0  0 )\n"
3460                                      "(  0 14 14  0 )\n"
3461                                      "( -2  0 -3  0 )\n"
3462                                      "( 11  4  5  6 )\n"
3463                                      "(  7 -8  9 10 )\n";
3464          throw std::runtime_error( oss.str() );
3465       }
3466    }
3467 
3468    {
3469       test_ = "Column-major/column-major dense matrix addition assignment (aligned/padded)";
3470 
3471       initialize();
3472 
3473       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
3474 
3475       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,columnMajor>;
3476       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 64UL ) );
3477       AlignedPadded mat( memory.get(), 2UL, 4UL, 16UL );
3478       mat = 0;
3479       mat(0,0) = 11;
3480       mat(0,3) = 12;
3481       mat(1,1) = 13;
3482       mat(1,2) = 14;
3483 
3484       rs += mat;
3485 
3486       checkRows    ( rs   ,  2UL );
3487       checkColumns ( rs   ,  4UL );
3488       checkNonZeros( rs   ,  6UL );
3489       checkRows    ( tmat_,  5UL );
3490       checkColumns ( tmat_,  4UL );
3491       checkNonZeros( tmat_, 12UL );
3492 
3493       if( rs(0,0) != 11 || rs(0,1) !=  4 || rs(0,2) !=  5 || rs(0,3) != 6 ||
3494           rs(1,0) !=  0 || rs(1,1) != 14 || rs(1,2) != 14 || rs(1,3) != 0 ) {
3495          std::ostringstream oss;
3496          oss << " Test: " << test_ << "\n"
3497              << " Error: Addition assignment failed\n"
3498              << " Details:\n"
3499              << "   Result:\n" << rs << "\n"
3500              << "   Expected result:\n( 11  4 17 -6 )\n(  0 14 14  0 )\n";
3501          throw std::runtime_error( oss.str() );
3502       }
3503 
3504       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
3505           tmat_(1,0) !=  0 || tmat_(1,1) != 14 || tmat_(1,2) != 14 || tmat_(1,3) !=  0 ||
3506           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
3507           tmat_(3,0) != 11 || tmat_(3,1) !=  4 || tmat_(3,2) !=  5 || tmat_(3,3) !=  6 ||
3508           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
3509          std::ostringstream oss;
3510          oss << " Test: " << test_ << "\n"
3511              << " Error: Addition assignment failed\n"
3512              << " Details:\n"
3513              << "   Result:\n" << tmat_ << "\n"
3514              << "   Expected result:\n(  0  0  0  0 )\n"
3515                                      "(  0 14 14  0 )\n"
3516                                      "( -2  0 -3  0 )\n"
3517                                      "( 11  4  5  6 )\n"
3518                                      "(  7 -8  9 10 )\n";
3519          throw std::runtime_error( oss.str() );
3520       }
3521    }
3522 
3523    {
3524       test_ = "Column-major/column-major dense matrix addition assignment (unaligned/unpadded)";
3525 
3526       initialize();
3527 
3528       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
3529 
3530       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,columnMajor>;
3531       std::unique_ptr<int[]> memory( new int[9UL] );
3532       UnalignedUnpadded mat( memory.get()+1UL, 2UL, 4UL );
3533       mat = 0;
3534       mat(0,0) = 11;
3535       mat(0,3) = 12;
3536       mat(1,1) = 13;
3537       mat(1,2) = 14;
3538 
3539       rs += mat;
3540 
3541       checkRows    ( rs   ,  2UL );
3542       checkColumns ( rs   ,  4UL );
3543       checkNonZeros( rs   ,  6UL );
3544       checkRows    ( tmat_,  5UL );
3545       checkColumns ( tmat_,  4UL );
3546       checkNonZeros( tmat_, 12UL );
3547 
3548       if( rs(0,0) != 11 || rs(0,1) !=  4 || rs(0,2) !=  5 || rs(0,3) != 6 ||
3549           rs(1,0) !=  0 || rs(1,1) != 14 || rs(1,2) != 14 || rs(1,3) != 0 ) {
3550          std::ostringstream oss;
3551          oss << " Test: " << test_ << "\n"
3552              << " Error: Addition assignment failed\n"
3553              << " Details:\n"
3554              << "   Result:\n" << rs << "\n"
3555              << "   Expected result:\n( 11  4 17 -6 )\n(  0 14 14  0 )\n";
3556          throw std::runtime_error( oss.str() );
3557       }
3558 
3559       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
3560           tmat_(1,0) !=  0 || tmat_(1,1) != 14 || tmat_(1,2) != 14 || tmat_(1,3) !=  0 ||
3561           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
3562           tmat_(3,0) != 11 || tmat_(3,1) !=  4 || tmat_(3,2) !=  5 || tmat_(3,3) !=  6 ||
3563           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
3564          std::ostringstream oss;
3565          oss << " Test: " << test_ << "\n"
3566              << " Error: Addition assignment failed\n"
3567              << " Details:\n"
3568              << "   Result:\n" << tmat_ << "\n"
3569              << "   Expected result:\n(  0  0  0  0 )\n"
3570                                      "(  0 14 14  0 )\n"
3571                                      "( -2  0 -3  0 )\n"
3572                                      "( 11  4  5  6 )\n"
3573                                      "(  7 -8  9 10 )\n";
3574          throw std::runtime_error( oss.str() );
3575       }
3576    }
3577 
3578 
3579    //=====================================================================================
3580    // Column-major sparse matrix addition assignment
3581    //=====================================================================================
3582 
3583    {
3584       test_ = "Column-major/row-major sparse matrix addition assignment";
3585 
3586       initialize();
3587 
3588       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
3589 
3590       const blaze::CompressedMatrix<int,rowMajor> mat{ { 11,  0,  0, 12 },
3591                                                        {  0, 13, 14,  0 } };
3592 
3593       rs += mat;
3594 
3595       checkRows    ( rs   ,  2UL );
3596       checkColumns ( rs   ,  4UL );
3597       checkNonZeros( rs   ,  6UL );
3598       checkRows    ( tmat_,  5UL );
3599       checkColumns ( tmat_,  4UL );
3600       checkNonZeros( tmat_, 12UL );
3601 
3602       if( rs(0,0) != 11 || rs(0,1) !=  4 || rs(0,2) !=  5 || rs(0,3) != 6 ||
3603           rs(1,0) !=  0 || rs(1,1) != 14 || rs(1,2) != 14 || rs(1,3) != 0 ) {
3604          std::ostringstream oss;
3605          oss << " Test: " << test_ << "\n"
3606              << " Error: Addition assignment failed\n"
3607              << " Details:\n"
3608              << "   Result:\n" << rs << "\n"
3609              << "   Expected result:\n( 11  4 17 -6 )\n(  0 14 14  0 )\n";
3610          throw std::runtime_error( oss.str() );
3611       }
3612 
3613       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
3614           tmat_(1,0) !=  0 || tmat_(1,1) != 14 || tmat_(1,2) != 14 || tmat_(1,3) !=  0 ||
3615           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
3616           tmat_(3,0) != 11 || tmat_(3,1) !=  4 || tmat_(3,2) !=  5 || tmat_(3,3) !=  6 ||
3617           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
3618          std::ostringstream oss;
3619          oss << " Test: " << test_ << "\n"
3620              << " Error: Addition assignment failed\n"
3621              << " Details:\n"
3622              << "   Result:\n" << tmat_ << "\n"
3623              << "   Expected result:\n(  0  0  0  0 )\n"
3624                                      "(  0 14 14  0 )\n"
3625                                      "( -2  0 -3  0 )\n"
3626                                      "( 11  4  5  6 )\n"
3627                                      "(  7 -8  9 10 )\n";
3628          throw std::runtime_error( oss.str() );
3629       }
3630    }
3631 
3632    {
3633       test_ = "Column-major/column-major sparse matrix addition assignment";
3634 
3635       initialize();
3636 
3637       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
3638 
3639       const blaze::CompressedMatrix<int,columnMajor> mat{ { 11,  0,  0, 12 },
3640                                                           {  0, 13, 14,  0 } };
3641 
3642       rs += mat;
3643 
3644       checkRows    ( rs   ,  2UL );
3645       checkColumns ( rs   ,  4UL );
3646       checkNonZeros( rs   ,  6UL );
3647       checkRows    ( tmat_,  5UL );
3648       checkColumns ( tmat_,  4UL );
3649       checkNonZeros( tmat_, 12UL );
3650 
3651       if( rs(0,0) != 11 || rs(0,1) !=  4 || rs(0,2) !=  5 || rs(0,3) != 6 ||
3652           rs(1,0) !=  0 || rs(1,1) != 14 || rs(1,2) != 14 || rs(1,3) != 0 ) {
3653          std::ostringstream oss;
3654          oss << " Test: " << test_ << "\n"
3655              << " Error: Addition assignment failed\n"
3656              << " Details:\n"
3657              << "   Result:\n" << rs << "\n"
3658              << "   Expected result:\n( 11  4 17 -6 )\n(  0 14 14  0 )\n";
3659          throw std::runtime_error( oss.str() );
3660       }
3661 
3662       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
3663           tmat_(1,0) !=  0 || tmat_(1,1) != 14 || tmat_(1,2) != 14 || tmat_(1,3) !=  0 ||
3664           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
3665           tmat_(3,0) != 11 || tmat_(3,1) !=  4 || tmat_(3,2) !=  5 || tmat_(3,3) !=  6 ||
3666           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
3667          std::ostringstream oss;
3668          oss << " Test: " << test_ << "\n"
3669              << " Error: Addition assignment failed\n"
3670              << " Details:\n"
3671              << "   Result:\n" << tmat_ << "\n"
3672              << "   Expected result:\n(  0  0  0  0 )\n"
3673                                      "(  0 14 14  0 )\n"
3674                                      "( -2  0 -3  0 )\n"
3675                                      "( 11  4  5  6 )\n"
3676                                      "(  7 -8  9 10 )\n";
3677          throw std::runtime_error( oss.str() );
3678       }
3679    }
3680 }
3681 //*************************************************************************************************
3682 
3683 
3684 //*************************************************************************************************
3685 /*!\brief Test of the Rows subtraction assignment operators.
3686 //
3687 // \return void
3688 // \exception std::runtime_error Error detected.
3689 //
3690 // This function performs a test of the subtraction assignment operators of the Rows
3691 // specialization. In case an error is detected, a \a std::runtime_error exception is thrown.
3692 */
testSubAssign()3693 void DenseGeneralTest::testSubAssign()
3694 {
3695    using blaze::aligned;
3696    using blaze::unaligned;
3697    using blaze::padded;
3698    using blaze::unpadded;
3699    using blaze::rowMajor;
3700    using blaze::columnMajor;
3701 
3702 
3703    //=====================================================================================
3704    // Row-major Rows subtraction assignment
3705    //=====================================================================================
3706 
3707    {
3708       test_ = "Row-major Rows subtraction assignment (no aliasing)";
3709 
3710       initialize();
3711 
3712       MT mat{ {  0,  0,  0,  0 },
3713               { 11,  0, 12,  0 },
3714               {  0,  0,  0,  0 },
3715               { 13, 14, 15, 16 },
3716               {  0,  0,  0,  0 } };
3717 
3718       auto rs = blaze::rows( mat, { 3UL, 1UL } );
3719       rs -= blaze::rows( mat_, { 3UL, 1UL } );
3720 
3721       checkRows    ( rs , 2UL );
3722       checkColumns ( rs , 4UL );
3723       checkNonZeros( rs , 7UL );
3724       checkRows    ( mat, 5UL );
3725       checkColumns ( mat, 4UL );
3726       checkNonZeros( mat, 7UL );
3727 
3728       if( rs(0,0) != 13 || rs(0,1) != 10 || rs(0,2) != 10 || rs(0,3) != 22 ||
3729           rs(1,0) != 11 || rs(1,1) != -1 || rs(1,2) != 12 || rs(1,3) !=  0 ) {
3730          std::ostringstream oss;
3731          oss << " Test: " << test_ << "\n"
3732              << " Error: Subtraction assignment failed\n"
3733              << " Details:\n"
3734              << "   Result:\n" << rs << "\n"
3735              << "   Expected result:\n( 13 10 10 22 )\n( 11 -1 12  0 )\n";
3736          throw std::runtime_error( oss.str() );
3737       }
3738 
3739       if( mat(0,0) !=  0 || mat(0,1) !=  0 || mat(0,2) !=  0 || mat(0,3) !=  0 ||
3740           mat(1,0) != 11 || mat(1,1) != -1 || mat(1,2) != 12 || mat(1,3) !=  0 ||
3741           mat(2,0) !=  0 || mat(2,1) !=  0 || mat(2,2) !=  0 || mat(2,3) !=  0 ||
3742           mat(3,0) != 13 || mat(3,1) != 10 || mat(3,2) != 10 || mat(3,3) != 22 ||
3743           mat(4,0) !=  0 || mat(4,1) !=  0 || mat(4,2) !=  0 || mat(4,3) !=  0 ) {
3744          std::ostringstream oss;
3745          oss << " Test: " << test_ << "\n"
3746              << " Error: Subtraction assignment failed\n"
3747              << " Details:\n"
3748              << "   Result:\n" << mat << "\n"
3749              << "   Expected result:\n(  0  0  0  0 )\n"
3750                                      "( 11 -1 12  0 )\n"
3751                                      "(  0  0  0  0 )\n"
3752                                      "( 13 10 10 22 )\n"
3753                                      "(  0  0  0  0 )\n";
3754          throw std::runtime_error( oss.str() );
3755       }
3756    }
3757 
3758    {
3759       test_ = "Row-major Rows subtraction assignment (aliasing)";
3760 
3761       initialize();
3762 
3763       auto rs = blaze::rows( mat_, { 3UL, 4UL } );
3764       rs -= blaze::rows( mat_, { 2UL, 3UL } );
3765 
3766       checkRows    ( rs  , 2UL );
3767       checkColumns ( rs  , 4UL );
3768       checkNonZeros( rs  , 8UL );
3769       checkRows    ( mat_, 5UL );
3770       checkColumns ( mat_, 4UL );
3771       checkNonZeros( mat_, 11UL );
3772 
3773       if( rs(0,0) != 2 || rs(0,1) !=   4 || rs(0,2) != 8 || rs(0,3) != -6 ||
3774           rs(1,0) != 7 || rs(1,1) != -12 || rs(1,2) != 4 || rs(1,3) != 16 ) {
3775          std::ostringstream oss;
3776          oss << " Test: " << test_ << "\n"
3777              << " Error: Subtraction assignment failed\n"
3778              << " Details:\n"
3779              << "   Result:\n" << rs << "\n"
3780              << "   Expected result:\n( 2   4  8 -6 )\n( 7 -12  4 16 )\n";
3781          throw std::runtime_error( oss.str() );
3782       }
3783 
3784       if( mat_(0,0) !=  0 || mat_(0,1) !=   0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
3785           mat_(1,0) !=  0 || mat_(1,1) !=   1 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
3786           mat_(2,0) != -2 || mat_(2,1) !=   0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
3787           mat_(3,0) !=  2 || mat_(3,1) !=   4 || mat_(3,2) !=  8 || mat_(3,3) != -6 ||
3788           mat_(4,0) !=  7 || mat_(4,1) != -12 || mat_(4,2) !=  4 || mat_(4,3) != 16 ) {
3789          std::ostringstream oss;
3790          oss << " Test: " << test_ << "\n"
3791              << " Error: Subtraction assignment failed\n"
3792              << " Details:\n"
3793              << "   Result:\n" << mat_ << "\n"
3794              << "   Expected result:\n(  0   0  0  0 )\n"
3795                                      "(  0   1  0  0 )\n"
3796                                      "( -2   0 -3  0 )\n"
3797                                      "(  2   4  8 -6 )\n"
3798                                      "(  7 -12  4 16 )\n";
3799          throw std::runtime_error( oss.str() );
3800       }
3801    }
3802 
3803 
3804    //=====================================================================================
3805    // Row-major dense matrix subtraction assignment
3806    //=====================================================================================
3807 
3808    {
3809       test_ = "Row-major/row-major dense matrix subtraction assignment (mixed type)";
3810 
3811       initialize();
3812 
3813       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
3814 
3815       const blaze::DynamicMatrix<short,rowMajor> mat{ { 11,  0,  0, 12 },
3816                                                       {  0, 13, 14,  0 } };
3817 
3818       rs -= mat;
3819 
3820       checkRows    ( rs  ,  2UL );
3821       checkColumns ( rs  ,  4UL );
3822       checkNonZeros( rs  ,  6UL );
3823       checkRows    ( mat_,  5UL );
3824       checkColumns ( mat_,  4UL );
3825       checkNonZeros( mat_, 12UL );
3826 
3827       if( rs(0,0) != -11 || rs(0,1) !=   4 || rs(0,2) !=   5 || rs(0,3) != -18 ||
3828           rs(1,0) !=   0 || rs(1,1) != -12 || rs(1,2) != -14 || rs(1,3) !=   0 ) {
3829          std::ostringstream oss;
3830          oss << " Test: " << test_ << "\n"
3831              << " Error: Subtraction assignment failed\n"
3832              << " Details:\n"
3833              << "   Result:\n" << rs << "\n"
3834              << "   Expected result:\n( -11   4   5 -18 )\n(   0 -12 -14   0 )\n";
3835          throw std::runtime_error( oss.str() );
3836       }
3837 
3838       if( mat_(0,0) !=   0 || mat_(0,1) !=   0 || mat_(0,2) !=   0 || mat_(0,3) !=   0 ||
3839           mat_(1,0) !=   0 || mat_(1,1) != -12 || mat_(1,2) != -14 || mat_(1,3) !=   0 ||
3840           mat_(2,0) !=  -2 || mat_(2,1) !=   0 || mat_(2,2) !=  -3 || mat_(2,3) !=   0 ||
3841           mat_(3,0) != -11 || mat_(3,1) !=   4 || mat_(3,2) !=   5 || mat_(3,3) != -18 ||
3842           mat_(4,0) !=   7 || mat_(4,1) !=  -8 || mat_(4,2) !=   9 || mat_(4,3) !=  10 ) {
3843          std::ostringstream oss;
3844          oss << " Test: " << test_ << "\n"
3845              << " Error: Subtraction assignment failed\n"
3846              << " Details:\n"
3847              << "   Result:\n" << mat_ << "\n"
3848              << "   Expected result:\n(   0   0   0   0 )\n"
3849                                      "(   0 -12 -14   0 )\n"
3850                                      "(  -2   0  -3   0 )\n"
3851                                      "( -11   4   5 -18 )\n"
3852                                      "(   7  -8   9  10 )\n";
3853          throw std::runtime_error( oss.str() );
3854       }
3855    }
3856 
3857    {
3858       test_ = "Row-major/row-major dense matrix subtraction assignment (aligned/padded)";
3859 
3860       initialize();
3861 
3862       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
3863 
3864       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,rowMajor>;
3865       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 32UL ) );
3866       AlignedPadded mat( memory.get(), 2UL, 4UL, 16UL );
3867       mat = 0;
3868       mat(0,0) = 11;
3869       mat(0,3) = 12;
3870       mat(1,1) = 13;
3871       mat(1,2) = 14;
3872 
3873       rs -= mat;
3874 
3875       checkRows    ( rs  ,  2UL );
3876       checkColumns ( rs  ,  4UL );
3877       checkNonZeros( rs  ,  6UL );
3878       checkRows    ( mat_,  5UL );
3879       checkColumns ( mat_,  4UL );
3880       checkNonZeros( mat_, 12UL );
3881 
3882       if( rs(0,0) != -11 || rs(0,1) !=   4 || rs(0,2) !=   5 || rs(0,3) != -18 ||
3883           rs(1,0) !=   0 || rs(1,1) != -12 || rs(1,2) != -14 || rs(1,3) !=   0 ) {
3884          std::ostringstream oss;
3885          oss << " Test: " << test_ << "\n"
3886              << " Error: Subtraction assignment failed\n"
3887              << " Details:\n"
3888              << "   Result:\n" << rs << "\n"
3889              << "   Expected result:\n( -11   4   5 -18 )\n(   0 -12 -14   0 )\n";
3890          throw std::runtime_error( oss.str() );
3891       }
3892 
3893       if( mat_(0,0) !=   0 || mat_(0,1) !=   0 || mat_(0,2) !=   0 || mat_(0,3) !=   0 ||
3894           mat_(1,0) !=   0 || mat_(1,1) != -12 || mat_(1,2) != -14 || mat_(1,3) !=   0 ||
3895           mat_(2,0) !=  -2 || mat_(2,1) !=   0 || mat_(2,2) !=  -3 || mat_(2,3) !=   0 ||
3896           mat_(3,0) != -11 || mat_(3,1) !=   4 || mat_(3,2) !=   5 || mat_(3,3) != -18 ||
3897           mat_(4,0) !=   7 || mat_(4,1) !=  -8 || mat_(4,2) !=   9 || mat_(4,3) !=  10 ) {
3898          std::ostringstream oss;
3899          oss << " Test: " << test_ << "\n"
3900              << " Error: Subtraction assignment failed\n"
3901              << " Details:\n"
3902              << "   Result:\n" << mat_ << "\n"
3903              << "   Expected result:\n(   0   0   0   0 )\n"
3904                                      "(   0 -12 -14   0 )\n"
3905                                      "(  -2   0  -3   0 )\n"
3906                                      "( -11   4   5 -18 )\n"
3907                                      "(   7  -8   9  10 )\n";
3908          throw std::runtime_error( oss.str() );
3909       }
3910    }
3911 
3912    {
3913       test_ = "Row-major/row-major dense matrix subtraction assignment (unaligned/unpadded)";
3914 
3915       initialize();
3916 
3917       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
3918 
3919       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,rowMajor>;
3920       std::unique_ptr<int[]> memory( new int[9UL] );
3921       UnalignedUnpadded mat( memory.get()+1UL, 2UL, 4UL );
3922       mat = 0;
3923       mat(0,0) = 11;
3924       mat(0,3) = 12;
3925       mat(1,1) = 13;
3926       mat(1,2) = 14;
3927 
3928       rs -= mat;
3929 
3930       checkRows    ( rs  ,  2UL );
3931       checkColumns ( rs  ,  4UL );
3932       checkNonZeros( rs  ,  6UL );
3933       checkRows    ( mat_,  5UL );
3934       checkColumns ( mat_,  4UL );
3935       checkNonZeros( mat_, 12UL );
3936 
3937       if( rs(0,0) != -11 || rs(0,1) !=   4 || rs(0,2) !=   5 || rs(0,3) != -18 ||
3938           rs(1,0) !=   0 || rs(1,1) != -12 || rs(1,2) != -14 || rs(1,3) !=   0 ) {
3939          std::ostringstream oss;
3940          oss << " Test: " << test_ << "\n"
3941              << " Error: Subtraction assignment failed\n"
3942              << " Details:\n"
3943              << "   Result:\n" << rs << "\n"
3944              << "   Expected result:\n( -11   4   5 -18 )\n(   0 -12 -14   0 )\n";
3945          throw std::runtime_error( oss.str() );
3946       }
3947 
3948       if( mat_(0,0) !=   0 || mat_(0,1) !=   0 || mat_(0,2) !=   0 || mat_(0,3) !=   0 ||
3949           mat_(1,0) !=   0 || mat_(1,1) != -12 || mat_(1,2) != -14 || mat_(1,3) !=   0 ||
3950           mat_(2,0) !=  -2 || mat_(2,1) !=   0 || mat_(2,2) !=  -3 || mat_(2,3) !=   0 ||
3951           mat_(3,0) != -11 || mat_(3,1) !=   4 || mat_(3,2) !=   5 || mat_(3,3) != -18 ||
3952           mat_(4,0) !=   7 || mat_(4,1) !=  -8 || mat_(4,2) !=   9 || mat_(4,3) !=  10 ) {
3953          std::ostringstream oss;
3954          oss << " Test: " << test_ << "\n"
3955              << " Error: Subtraction assignment failed\n"
3956              << " Details:\n"
3957              << "   Result:\n" << mat_ << "\n"
3958              << "   Expected result:\n(   0   0   0   0 )\n"
3959                                      "(   0 -12 -14   0 )\n"
3960                                      "(  -2   0  -3   0 )\n"
3961                                      "( -11   4   5 -18 )\n"
3962                                      "(   7  -8   9  10 )\n";
3963          throw std::runtime_error( oss.str() );
3964       }
3965    }
3966 
3967    {
3968       test_ = "Row-major/column-major dense matrix subtraction assignment (mixed type)";
3969 
3970       initialize();
3971 
3972       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
3973 
3974       const blaze::DynamicMatrix<short,columnMajor> mat{ { 11,  0,  0, 12 },
3975                                                          {  0, 13, 14,  0 } };
3976 
3977       rs -= mat;
3978 
3979       checkRows    ( rs  ,  2UL );
3980       checkColumns ( rs  ,  4UL );
3981       checkNonZeros( rs  ,  6UL );
3982       checkRows    ( mat_,  5UL );
3983       checkColumns ( mat_,  4UL );
3984       checkNonZeros( mat_, 12UL );
3985 
3986       if( rs(0,0) != -11 || rs(0,1) !=   4 || rs(0,2) !=   5 || rs(0,3) != -18 ||
3987           rs(1,0) !=   0 || rs(1,1) != -12 || rs(1,2) != -14 || rs(1,3) !=   0 ) {
3988          std::ostringstream oss;
3989          oss << " Test: " << test_ << "\n"
3990              << " Error: Subtraction assignment failed\n"
3991              << " Details:\n"
3992              << "   Result:\n" << rs << "\n"
3993              << "   Expected result:\n( -11   4   5 -18 )\n(   0 -12 -14   0 )\n";
3994          throw std::runtime_error( oss.str() );
3995       }
3996 
3997       if( mat_(0,0) !=   0 || mat_(0,1) !=   0 || mat_(0,2) !=   0 || mat_(0,3) !=   0 ||
3998           mat_(1,0) !=   0 || mat_(1,1) != -12 || mat_(1,2) != -14 || mat_(1,3) !=   0 ||
3999           mat_(2,0) !=  -2 || mat_(2,1) !=   0 || mat_(2,2) !=  -3 || mat_(2,3) !=   0 ||
4000           mat_(3,0) != -11 || mat_(3,1) !=   4 || mat_(3,2) !=   5 || mat_(3,3) != -18 ||
4001           mat_(4,0) !=   7 || mat_(4,1) !=  -8 || mat_(4,2) !=   9 || mat_(4,3) !=  10 ) {
4002          std::ostringstream oss;
4003          oss << " Test: " << test_ << "\n"
4004              << " Error: Subtraction assignment failed\n"
4005              << " Details:\n"
4006              << "   Result:\n" << mat_ << "\n"
4007              << "   Expected result:\n(   0   0   0   0 )\n"
4008                                      "(   0 -12 -14   0 )\n"
4009                                      "(  -2   0  -3   0 )\n"
4010                                      "( -11   4   5 -18 )\n"
4011                                      "(   7  -8   9  10 )\n";
4012          throw std::runtime_error( oss.str() );
4013       }
4014    }
4015 
4016    {
4017       test_ = "Row-major/column-major dense matrix subtraction assignment (aligned/padded)";
4018 
4019       initialize();
4020 
4021       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
4022 
4023       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,columnMajor>;
4024       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 64UL ) );
4025       AlignedPadded mat( memory.get(), 2UL, 4UL, 16UL );
4026       mat = 0;
4027       mat(0,0) = 11;
4028       mat(0,3) = 12;
4029       mat(1,1) = 13;
4030       mat(1,2) = 14;
4031 
4032       rs -= mat;
4033 
4034       checkRows    ( rs  ,  2UL );
4035       checkColumns ( rs  ,  4UL );
4036       checkNonZeros( rs  ,  6UL );
4037       checkRows    ( mat_,  5UL );
4038       checkColumns ( mat_,  4UL );
4039       checkNonZeros( mat_, 12UL );
4040 
4041       if( rs(0,0) != -11 || rs(0,1) !=   4 || rs(0,2) !=   5 || rs(0,3) != -18 ||
4042           rs(1,0) !=   0 || rs(1,1) != -12 || rs(1,2) != -14 || rs(1,3) !=   0 ) {
4043          std::ostringstream oss;
4044          oss << " Test: " << test_ << "\n"
4045              << " Error: Subtraction assignment failed\n"
4046              << " Details:\n"
4047              << "   Result:\n" << rs << "\n"
4048              << "   Expected result:\n( -11   4   5 -18 )\n(   0 -12 -14   0 )\n";
4049          throw std::runtime_error( oss.str() );
4050       }
4051 
4052       if( mat_(0,0) !=   0 || mat_(0,1) !=   0 || mat_(0,2) !=   0 || mat_(0,3) !=   0 ||
4053           mat_(1,0) !=   0 || mat_(1,1) != -12 || mat_(1,2) != -14 || mat_(1,3) !=   0 ||
4054           mat_(2,0) !=  -2 || mat_(2,1) !=   0 || mat_(2,2) !=  -3 || mat_(2,3) !=   0 ||
4055           mat_(3,0) != -11 || mat_(3,1) !=   4 || mat_(3,2) !=   5 || mat_(3,3) != -18 ||
4056           mat_(4,0) !=   7 || mat_(4,1) !=  -8 || mat_(4,2) !=   9 || mat_(4,3) !=  10 ) {
4057          std::ostringstream oss;
4058          oss << " Test: " << test_ << "\n"
4059              << " Error: Subtraction assignment failed\n"
4060              << " Details:\n"
4061              << "   Result:\n" << mat_ << "\n"
4062              << "   Expected result:\n(   0   0   0   0 )\n"
4063                                      "(   0 -12 -14   0 )\n"
4064                                      "(  -2   0  -3   0 )\n"
4065                                      "( -11   4   5 -18 )\n"
4066                                      "(   7  -8   9  10 )\n";
4067          throw std::runtime_error( oss.str() );
4068       }
4069    }
4070 
4071    {
4072       test_ = "Row-major/column-major dense matrix subtraction assignment (unaligned/unpadded)";
4073 
4074       initialize();
4075 
4076       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
4077 
4078       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,columnMajor>;
4079       std::unique_ptr<int[]> memory( new int[9UL] );
4080       UnalignedUnpadded mat( memory.get()+1UL, 2UL, 4UL );
4081       mat = 0;
4082       mat(0,0) = 11;
4083       mat(0,3) = 12;
4084       mat(1,1) = 13;
4085       mat(1,2) = 14;
4086 
4087       rs -= mat;
4088 
4089       checkRows    ( rs  ,  2UL );
4090       checkColumns ( rs  ,  4UL );
4091       checkNonZeros( rs  ,  6UL );
4092       checkRows    ( mat_,  5UL );
4093       checkColumns ( mat_,  4UL );
4094       checkNonZeros( mat_, 12UL );
4095 
4096       if( rs(0,0) != -11 || rs(0,1) !=   4 || rs(0,2) !=   5 || rs(0,3) != -18 ||
4097           rs(1,0) !=   0 || rs(1,1) != -12 || rs(1,2) != -14 || rs(1,3) !=   0 ) {
4098          std::ostringstream oss;
4099          oss << " Test: " << test_ << "\n"
4100              << " Error: Subtraction assignment failed\n"
4101              << " Details:\n"
4102              << "   Result:\n" << rs << "\n"
4103              << "   Expected result:\n( -11   4   5 -18 )\n(   0 -12 -14   0 )\n";
4104          throw std::runtime_error( oss.str() );
4105       }
4106 
4107       if( mat_(0,0) !=   0 || mat_(0,1) !=   0 || mat_(0,2) !=   0 || mat_(0,3) !=   0 ||
4108           mat_(1,0) !=   0 || mat_(1,1) != -12 || mat_(1,2) != -14 || mat_(1,3) !=   0 ||
4109           mat_(2,0) !=  -2 || mat_(2,1) !=   0 || mat_(2,2) !=  -3 || mat_(2,3) !=   0 ||
4110           mat_(3,0) != -11 || mat_(3,1) !=   4 || mat_(3,2) !=   5 || mat_(3,3) != -18 ||
4111           mat_(4,0) !=   7 || mat_(4,1) !=  -8 || mat_(4,2) !=   9 || mat_(4,3) !=  10 ) {
4112          std::ostringstream oss;
4113          oss << " Test: " << test_ << "\n"
4114              << " Error: Subtraction assignment failed\n"
4115              << " Details:\n"
4116              << "   Result:\n" << mat_ << "\n"
4117              << "   Expected result:\n(   0   0   0   0 )\n"
4118                                      "(   0 -12 -14   0 )\n"
4119                                      "(  -2   0  -3   0 )\n"
4120                                      "( -11   4   5 -18 )\n"
4121                                      "(   7  -8   9  10 )\n";
4122          throw std::runtime_error( oss.str() );
4123       }
4124    }
4125 
4126 
4127    //=====================================================================================
4128    // Row-major sparse matrix subtraction assignment
4129    //=====================================================================================
4130 
4131    {
4132       test_ = "Row-major/row-major sparse matrix subtraction assignment";
4133 
4134       initialize();
4135 
4136       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
4137 
4138       const blaze::CompressedMatrix<int,rowMajor> mat{ { 11,  0,  0, 12 },
4139                                                        {  0, 13, 14,  0 } };
4140 
4141       rs -= mat;
4142 
4143       checkRows    ( rs  ,  2UL );
4144       checkColumns ( rs  ,  4UL );
4145       checkNonZeros( rs  ,  6UL );
4146       checkRows    ( mat_,  5UL );
4147       checkColumns ( mat_,  4UL );
4148       checkNonZeros( mat_, 12UL );
4149 
4150       if( rs(0,0) != -11 || rs(0,1) !=   4 || rs(0,2) !=   5 || rs(0,3) != -18 ||
4151           rs(1,0) !=   0 || rs(1,1) != -12 || rs(1,2) != -14 || rs(1,3) !=   0 ) {
4152          std::ostringstream oss;
4153          oss << " Test: " << test_ << "\n"
4154              << " Error: Subtraction assignment failed\n"
4155              << " Details:\n"
4156              << "   Result:\n" << rs << "\n"
4157              << "   Expected result:\n( -11   4   5 -18 )\n(   0 -12 -14   0 )\n";
4158          throw std::runtime_error( oss.str() );
4159       }
4160 
4161       if( mat_(0,0) !=   0 || mat_(0,1) !=   0 || mat_(0,2) !=   0 || mat_(0,3) !=   0 ||
4162           mat_(1,0) !=   0 || mat_(1,1) != -12 || mat_(1,2) != -14 || mat_(1,3) !=   0 ||
4163           mat_(2,0) !=  -2 || mat_(2,1) !=   0 || mat_(2,2) !=  -3 || mat_(2,3) !=   0 ||
4164           mat_(3,0) != -11 || mat_(3,1) !=   4 || mat_(3,2) !=   5 || mat_(3,3) != -18 ||
4165           mat_(4,0) !=   7 || mat_(4,1) !=  -8 || mat_(4,2) !=   9 || mat_(4,3) !=  10 ) {
4166          std::ostringstream oss;
4167          oss << " Test: " << test_ << "\n"
4168              << " Error: Subtraction assignment failed\n"
4169              << " Details:\n"
4170              << "   Result:\n" << mat_ << "\n"
4171              << "   Expected result:\n(   0   0   0   0 )\n"
4172                                      "(   0 -12 -14   0 )\n"
4173                                      "(  -2   0  -3   0 )\n"
4174                                      "( -11   4   5 -18 )\n"
4175                                      "(   7  -8   9  10 )\n";
4176          throw std::runtime_error( oss.str() );
4177       }
4178    }
4179 
4180    {
4181       test_ = "Row-major/column-major sparse matrix subtraction assignment";
4182 
4183       initialize();
4184 
4185       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
4186 
4187       const blaze::CompressedMatrix<int,columnMajor> mat{ { 11,  0,  0, 12 },
4188                                                           {  0, 13, 14,  0 } };
4189 
4190       rs -= mat;
4191 
4192       checkRows    ( rs  ,  2UL );
4193       checkColumns ( rs  ,  4UL );
4194       checkNonZeros( rs  ,  6UL );
4195       checkRows    ( mat_,  5UL );
4196       checkColumns ( mat_,  4UL );
4197       checkNonZeros( mat_, 12UL );
4198 
4199       if( rs(0,0) != -11 || rs(0,1) !=   4 || rs(0,2) !=   5 || rs(0,3) != -18 ||
4200           rs(1,0) !=   0 || rs(1,1) != -12 || rs(1,2) != -14 || rs(1,3) !=   0 ) {
4201          std::ostringstream oss;
4202          oss << " Test: " << test_ << "\n"
4203              << " Error: Subtraction assignment failed\n"
4204              << " Details:\n"
4205              << "   Result:\n" << rs << "\n"
4206              << "   Expected result:\n( -11   4   5 -18 )\n(   0 -12 -14   0 )\n";
4207          throw std::runtime_error( oss.str() );
4208       }
4209 
4210       if( mat_(0,0) !=   0 || mat_(0,1) !=   0 || mat_(0,2) !=   0 || mat_(0,3) !=   0 ||
4211           mat_(1,0) !=   0 || mat_(1,1) != -12 || mat_(1,2) != -14 || mat_(1,3) !=   0 ||
4212           mat_(2,0) !=  -2 || mat_(2,1) !=   0 || mat_(2,2) !=  -3 || mat_(2,3) !=   0 ||
4213           mat_(3,0) != -11 || mat_(3,1) !=   4 || mat_(3,2) !=   5 || mat_(3,3) != -18 ||
4214           mat_(4,0) !=   7 || mat_(4,1) !=  -8 || mat_(4,2) !=   9 || mat_(4,3) !=  10 ) {
4215          std::ostringstream oss;
4216          oss << " Test: " << test_ << "\n"
4217              << " Error: Subtraction assignment failed\n"
4218              << " Details:\n"
4219              << "   Result:\n" << mat_ << "\n"
4220              << "   Expected result:\n(   0   0   0   0 )\n"
4221                                      "(   0 -12 -14   0 )\n"
4222                                      "(  -2   0  -3   0 )\n"
4223                                      "( -11   4   5 -18 )\n"
4224                                      "(   7  -8   9  10 )\n";
4225          throw std::runtime_error( oss.str() );
4226       }
4227    }
4228 
4229 
4230    //=====================================================================================
4231    // Column-major Rows subtraction assignment
4232    //=====================================================================================
4233 
4234    {
4235       test_ = "Column-major Rows subtraction assignment (no aliasing)";
4236 
4237       initialize();
4238 
4239       MT mat{ {  0,  0,  0,  0 },
4240               { 11,  0, 12,  0 },
4241               {  0,  0,  0,  0 },
4242               { 13, 14, 15, 16 },
4243               {  0,  0,  0,  0 } };
4244 
4245       auto rs = blaze::rows( mat, { 3UL, 1UL } );
4246       rs -= blaze::rows( mat_, { 3UL, 1UL } );
4247 
4248       checkRows    ( rs , 2UL );
4249       checkColumns ( rs , 4UL );
4250       checkNonZeros( rs , 7UL );
4251       checkRows    ( mat, 5UL );
4252       checkColumns ( mat, 4UL );
4253       checkNonZeros( mat, 7UL );
4254 
4255       if( rs(0,0) != 13 || rs(0,1) != 10 || rs(0,2) != 10 || rs(0,3) != 22 ||
4256           rs(1,0) != 11 || rs(1,1) != -1 || rs(1,2) != 12 || rs(1,3) !=  0 ) {
4257          std::ostringstream oss;
4258          oss << " Test: " << test_ << "\n"
4259              << " Error: Subtraction assignment failed\n"
4260              << " Details:\n"
4261              << "   Result:\n" << rs << "\n"
4262              << "   Expected result:\n( 13 10 10 22 )\n( 11 -1 12  0 )\n";
4263          throw std::runtime_error( oss.str() );
4264       }
4265 
4266       if( mat(0,0) !=  0 || mat(0,1) !=  0 || mat(0,2) !=  0 || mat(0,3) !=  0 ||
4267           mat(1,0) != 11 || mat(1,1) != -1 || mat(1,2) != 12 || mat(1,3) !=  0 ||
4268           mat(2,0) !=  0 || mat(2,1) !=  0 || mat(2,2) !=  0 || mat(2,3) !=  0 ||
4269           mat(3,0) != 13 || mat(3,1) != 10 || mat(3,2) != 10 || mat(3,3) != 22 ||
4270           mat(4,0) !=  0 || mat(4,1) !=  0 || mat(4,2) !=  0 || mat(4,3) !=  0 ) {
4271          std::ostringstream oss;
4272          oss << " Test: " << test_ << "\n"
4273              << " Error: Subtraction assignment failed\n"
4274              << " Details:\n"
4275              << "   Result:\n" << mat << "\n"
4276              << "   Expected result:\n(  0  0  0  0 )\n"
4277                                      "( 11 -1 12  0 )\n"
4278                                      "(  0  0  0  0 )\n"
4279                                      "( 13 10 10 22 )\n"
4280                                      "(  0  0  0  0 )\n";
4281          throw std::runtime_error( oss.str() );
4282       }
4283    }
4284 
4285    {
4286       test_ = "Column-major Rows subtraction assignment (aliasing)";
4287 
4288       initialize();
4289 
4290       auto rs = blaze::rows( mat_, { 3UL, 4UL } );
4291       rs -= blaze::rows( mat_, { 2UL, 3UL } );
4292 
4293       checkRows    ( rs  , 2UL );
4294       checkColumns ( rs  , 4UL );
4295       checkNonZeros( rs  , 8UL );
4296       checkRows    ( mat_, 5UL );
4297       checkColumns ( mat_, 4UL );
4298       checkNonZeros( mat_, 11UL );
4299 
4300       if( rs(0,0) != 2 || rs(0,1) !=   4 || rs(0,2) != 8 || rs(0,3) != -6 ||
4301           rs(1,0) != 7 || rs(1,1) != -12 || rs(1,2) != 4 || rs(1,3) != 16 ) {
4302          std::ostringstream oss;
4303          oss << " Test: " << test_ << "\n"
4304              << " Error: Subtraction assignment failed\n"
4305              << " Details:\n"
4306              << "   Result:\n" << rs << "\n"
4307              << "   Expected result:\n( 2   4  8 -6 )\n( 7 -12  4 16 )\n";
4308          throw std::runtime_error( oss.str() );
4309       }
4310 
4311       if( mat_(0,0) !=  0 || mat_(0,1) !=   0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
4312           mat_(1,0) !=  0 || mat_(1,1) !=   1 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
4313           mat_(2,0) != -2 || mat_(2,1) !=   0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
4314           mat_(3,0) !=  2 || mat_(3,1) !=   4 || mat_(3,2) !=  8 || mat_(3,3) != -6 ||
4315           mat_(4,0) !=  7 || mat_(4,1) != -12 || mat_(4,2) !=  4 || mat_(4,3) != 16 ) {
4316          std::ostringstream oss;
4317          oss << " Test: " << test_ << "\n"
4318              << " Error: Subtraction assignment failed\n"
4319              << " Details:\n"
4320              << "   Result:\n" << mat_ << "\n"
4321              << "   Expected result:\n(  0   0  0  0 )\n"
4322                                      "(  0   1  0  0 )\n"
4323                                      "( -2   0 -3  0 )\n"
4324                                      "(  2   4  8 -6 )\n"
4325                                      "(  7 -12  4 16 )\n";
4326          throw std::runtime_error( oss.str() );
4327       }
4328    }
4329 
4330 
4331    //=====================================================================================
4332    // Column-major dense matrix subtraction assignment
4333    //=====================================================================================
4334 
4335    {
4336       test_ = "Column-major/row-major dense matrix subtraction assignment (mixed type)";
4337 
4338       initialize();
4339 
4340       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
4341 
4342       const blaze::DynamicMatrix<short,rowMajor> mat{ { 11,  0,  0, 12 },
4343                                                       {  0, 13, 14,  0 } };
4344 
4345       rs -= mat;
4346 
4347       checkRows    ( rs  ,  2UL );
4348       checkColumns ( rs  ,  4UL );
4349       checkNonZeros( rs  ,  6UL );
4350       checkRows    ( mat_,  5UL );
4351       checkColumns ( mat_,  4UL );
4352       checkNonZeros( mat_, 12UL );
4353 
4354       if( rs(0,0) != -11 || rs(0,1) !=   4 || rs(0,2) !=   5 || rs(0,3) != -18 ||
4355           rs(1,0) !=   0 || rs(1,1) != -12 || rs(1,2) != -14 || rs(1,3) !=   0 ) {
4356          std::ostringstream oss;
4357          oss << " Test: " << test_ << "\n"
4358              << " Error: Subtraction assignment failed\n"
4359              << " Details:\n"
4360              << "   Result:\n" << rs << "\n"
4361              << "   Expected result:\n( -11   4   5 -18 )\n(   0 -12 -14   0 )\n";
4362          throw std::runtime_error( oss.str() );
4363       }
4364 
4365       if( mat_(0,0) !=   0 || mat_(0,1) !=   0 || mat_(0,2) !=   0 || mat_(0,3) !=   0 ||
4366           mat_(1,0) !=   0 || mat_(1,1) != -12 || mat_(1,2) != -14 || mat_(1,3) !=   0 ||
4367           mat_(2,0) !=  -2 || mat_(2,1) !=   0 || mat_(2,2) !=  -3 || mat_(2,3) !=   0 ||
4368           mat_(3,0) != -11 || mat_(3,1) !=   4 || mat_(3,2) !=   5 || mat_(3,3) != -18 ||
4369           mat_(4,0) !=   7 || mat_(4,1) !=  -8 || mat_(4,2) !=   9 || mat_(4,3) !=  10 ) {
4370          std::ostringstream oss;
4371          oss << " Test: " << test_ << "\n"
4372              << " Error: Subtraction assignment failed\n"
4373              << " Details:\n"
4374              << "   Result:\n" << mat_ << "\n"
4375              << "   Expected result:\n(   0   0   0   0 )\n"
4376                                      "(   0 -12 -14   0 )\n"
4377                                      "(  -2   0  -3   0 )\n"
4378                                      "( -11   4   5 -18 )\n"
4379                                      "(   7  -8   9  10 )\n";
4380          throw std::runtime_error( oss.str() );
4381       }
4382    }
4383 
4384    {
4385       test_ = "Column-major/row-major dense matrix subtraction assignment (aligned/padded)";
4386 
4387       initialize();
4388 
4389       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
4390 
4391       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,rowMajor>;
4392       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 32UL ) );
4393       AlignedPadded mat( memory.get(), 2UL, 4UL, 16UL );
4394       mat = 0;
4395       mat(0,0) = 11;
4396       mat(0,3) = 12;
4397       mat(1,1) = 13;
4398       mat(1,2) = 14;
4399 
4400       rs -= mat;
4401 
4402       checkRows    ( rs  ,  2UL );
4403       checkColumns ( rs  ,  4UL );
4404       checkNonZeros( rs  ,  6UL );
4405       checkRows    ( mat_,  5UL );
4406       checkColumns ( mat_,  4UL );
4407       checkNonZeros( mat_, 12UL );
4408 
4409       if( rs(0,0) != -11 || rs(0,1) !=   4 || rs(0,2) !=   5 || rs(0,3) != -18 ||
4410           rs(1,0) !=   0 || rs(1,1) != -12 || rs(1,2) != -14 || rs(1,3) !=   0 ) {
4411          std::ostringstream oss;
4412          oss << " Test: " << test_ << "\n"
4413              << " Error: Subtraction assignment failed\n"
4414              << " Details:\n"
4415              << "   Result:\n" << rs << "\n"
4416              << "   Expected result:\n( -11   4   5 -18 )\n(   0 -12 -14   0 )\n";
4417          throw std::runtime_error( oss.str() );
4418       }
4419 
4420       if( mat_(0,0) !=   0 || mat_(0,1) !=   0 || mat_(0,2) !=   0 || mat_(0,3) !=   0 ||
4421           mat_(1,0) !=   0 || mat_(1,1) != -12 || mat_(1,2) != -14 || mat_(1,3) !=   0 ||
4422           mat_(2,0) !=  -2 || mat_(2,1) !=   0 || mat_(2,2) !=  -3 || mat_(2,3) !=   0 ||
4423           mat_(3,0) != -11 || mat_(3,1) !=   4 || mat_(3,2) !=   5 || mat_(3,3) != -18 ||
4424           mat_(4,0) !=   7 || mat_(4,1) !=  -8 || mat_(4,2) !=   9 || mat_(4,3) !=  10 ) {
4425          std::ostringstream oss;
4426          oss << " Test: " << test_ << "\n"
4427              << " Error: Subtraction assignment failed\n"
4428              << " Details:\n"
4429              << "   Result:\n" << mat_ << "\n"
4430              << "   Expected result:\n(   0   0   0   0 )\n"
4431                                      "(   0 -12 -14   0 )\n"
4432                                      "(  -2   0  -3   0 )\n"
4433                                      "( -11   4   5 -18 )\n"
4434                                      "(   7  -8   9  10 )\n";
4435          throw std::runtime_error( oss.str() );
4436       }
4437    }
4438 
4439    {
4440       test_ = "Column-major/row-major dense matrix subtraction assignment (unaligned/unpadded)";
4441 
4442       initialize();
4443 
4444       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
4445 
4446       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,rowMajor>;
4447       std::unique_ptr<int[]> memory( new int[9UL] );
4448       UnalignedUnpadded mat( memory.get()+1UL, 2UL, 4UL );
4449       mat = 0;
4450       mat(0,0) = 11;
4451       mat(0,3) = 12;
4452       mat(1,1) = 13;
4453       mat(1,2) = 14;
4454 
4455       rs -= mat;
4456 
4457       checkRows    ( rs  ,  2UL );
4458       checkColumns ( rs  ,  4UL );
4459       checkNonZeros( rs  ,  6UL );
4460       checkRows    ( mat_,  5UL );
4461       checkColumns ( mat_,  4UL );
4462       checkNonZeros( mat_, 12UL );
4463 
4464       if( rs(0,0) != -11 || rs(0,1) !=   4 || rs(0,2) !=   5 || rs(0,3) != -18 ||
4465           rs(1,0) !=   0 || rs(1,1) != -12 || rs(1,2) != -14 || rs(1,3) !=   0 ) {
4466          std::ostringstream oss;
4467          oss << " Test: " << test_ << "\n"
4468              << " Error: Subtraction assignment failed\n"
4469              << " Details:\n"
4470              << "   Result:\n" << rs << "\n"
4471              << "   Expected result:\n( -11   4   5 -18 )\n(   0 -12 -14   0 )\n";
4472          throw std::runtime_error( oss.str() );
4473       }
4474 
4475       if( mat_(0,0) !=   0 || mat_(0,1) !=   0 || mat_(0,2) !=   0 || mat_(0,3) !=   0 ||
4476           mat_(1,0) !=   0 || mat_(1,1) != -12 || mat_(1,2) != -14 || mat_(1,3) !=   0 ||
4477           mat_(2,0) !=  -2 || mat_(2,1) !=   0 || mat_(2,2) !=  -3 || mat_(2,3) !=   0 ||
4478           mat_(3,0) != -11 || mat_(3,1) !=   4 || mat_(3,2) !=   5 || mat_(3,3) != -18 ||
4479           mat_(4,0) !=   7 || mat_(4,1) !=  -8 || mat_(4,2) !=   9 || mat_(4,3) !=  10 ) {
4480          std::ostringstream oss;
4481          oss << " Test: " << test_ << "\n"
4482              << " Error: Subtraction assignment failed\n"
4483              << " Details:\n"
4484              << "   Result:\n" << mat_ << "\n"
4485              << "   Expected result:\n(   0   0   0   0 )\n"
4486                                      "(   0 -12 -14   0 )\n"
4487                                      "(  -2   0  -3   0 )\n"
4488                                      "( -11   4   5 -18 )\n"
4489                                      "(   7  -8   9  10 )\n";
4490          throw std::runtime_error( oss.str() );
4491       }
4492    }
4493 
4494    {
4495       test_ = "Column-major/column-major dense matrix subtraction assignment (mixed type)";
4496 
4497       initialize();
4498 
4499       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
4500 
4501       const blaze::DynamicMatrix<short,columnMajor> mat{ { 11,  0,  0, 12 },
4502                                                          {  0, 13, 14,  0 } };
4503 
4504       rs -= mat;
4505 
4506       checkRows    ( rs  ,  2UL );
4507       checkColumns ( rs  ,  4UL );
4508       checkNonZeros( rs  ,  6UL );
4509       checkRows    ( mat_,  5UL );
4510       checkColumns ( mat_,  4UL );
4511       checkNonZeros( mat_, 12UL );
4512 
4513       if( rs(0,0) != -11 || rs(0,1) !=   4 || rs(0,2) !=   5 || rs(0,3) != -18 ||
4514           rs(1,0) !=   0 || rs(1,1) != -12 || rs(1,2) != -14 || rs(1,3) !=   0 ) {
4515          std::ostringstream oss;
4516          oss << " Test: " << test_ << "\n"
4517              << " Error: Subtraction assignment failed\n"
4518              << " Details:\n"
4519              << "   Result:\n" << rs << "\n"
4520              << "   Expected result:\n( -11   4   5 -18 )\n(   0 -12 -14   0 )\n";
4521          throw std::runtime_error( oss.str() );
4522       }
4523 
4524       if( mat_(0,0) !=   0 || mat_(0,1) !=   0 || mat_(0,2) !=   0 || mat_(0,3) !=   0 ||
4525           mat_(1,0) !=   0 || mat_(1,1) != -12 || mat_(1,2) != -14 || mat_(1,3) !=   0 ||
4526           mat_(2,0) !=  -2 || mat_(2,1) !=   0 || mat_(2,2) !=  -3 || mat_(2,3) !=   0 ||
4527           mat_(3,0) != -11 || mat_(3,1) !=   4 || mat_(3,2) !=   5 || mat_(3,3) != -18 ||
4528           mat_(4,0) !=   7 || mat_(4,1) !=  -8 || mat_(4,2) !=   9 || mat_(4,3) !=  10 ) {
4529          std::ostringstream oss;
4530          oss << " Test: " << test_ << "\n"
4531              << " Error: Subtraction assignment failed\n"
4532              << " Details:\n"
4533              << "   Result:\n" << mat_ << "\n"
4534              << "   Expected result:\n(   0   0   0   0 )\n"
4535                                      "(   0 -12 -14   0 )\n"
4536                                      "(  -2   0  -3   0 )\n"
4537                                      "( -11   4   5 -18 )\n"
4538                                      "(   7  -8   9  10 )\n";
4539          throw std::runtime_error( oss.str() );
4540       }
4541    }
4542 
4543    {
4544       test_ = "Column-major/column-major dense matrix subtraction assignment (aligned/padded)";
4545 
4546       initialize();
4547 
4548       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
4549 
4550       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,columnMajor>;
4551       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 64UL ) );
4552       AlignedPadded mat( memory.get(), 2UL, 4UL, 16UL );
4553       mat = 0;
4554       mat(0,0) = 11;
4555       mat(0,3) = 12;
4556       mat(1,1) = 13;
4557       mat(1,2) = 14;
4558 
4559       rs -= mat;
4560 
4561       checkRows    ( rs  ,  2UL );
4562       checkColumns ( rs  ,  4UL );
4563       checkNonZeros( rs  ,  6UL );
4564       checkRows    ( mat_,  5UL );
4565       checkColumns ( mat_,  4UL );
4566       checkNonZeros( mat_, 12UL );
4567 
4568       if( rs(0,0) != -11 || rs(0,1) !=   4 || rs(0,2) !=   5 || rs(0,3) != -18 ||
4569           rs(1,0) !=   0 || rs(1,1) != -12 || rs(1,2) != -14 || rs(1,3) !=   0 ) {
4570          std::ostringstream oss;
4571          oss << " Test: " << test_ << "\n"
4572              << " Error: Subtraction assignment failed\n"
4573              << " Details:\n"
4574              << "   Result:\n" << rs << "\n"
4575              << "   Expected result:\n( -11   4   5 -18 )\n(   0 -12 -14   0 )\n";
4576          throw std::runtime_error( oss.str() );
4577       }
4578 
4579       if( mat_(0,0) !=   0 || mat_(0,1) !=   0 || mat_(0,2) !=   0 || mat_(0,3) !=   0 ||
4580           mat_(1,0) !=   0 || mat_(1,1) != -12 || mat_(1,2) != -14 || mat_(1,3) !=   0 ||
4581           mat_(2,0) !=  -2 || mat_(2,1) !=   0 || mat_(2,2) !=  -3 || mat_(2,3) !=   0 ||
4582           mat_(3,0) != -11 || mat_(3,1) !=   4 || mat_(3,2) !=   5 || mat_(3,3) != -18 ||
4583           mat_(4,0) !=   7 || mat_(4,1) !=  -8 || mat_(4,2) !=   9 || mat_(4,3) !=  10 ) {
4584          std::ostringstream oss;
4585          oss << " Test: " << test_ << "\n"
4586              << " Error: Subtraction assignment failed\n"
4587              << " Details:\n"
4588              << "   Result:\n" << mat_ << "\n"
4589              << "   Expected result:\n(   0   0   0   0 )\n"
4590                                      "(   0 -12 -14   0 )\n"
4591                                      "(  -2   0  -3   0 )\n"
4592                                      "( -11   4   5 -18 )\n"
4593                                      "(   7  -8   9  10 )\n";
4594          throw std::runtime_error( oss.str() );
4595       }
4596    }
4597 
4598    {
4599       test_ = "Column-major/column-major dense matrix subtraction assignment (unaligned/unpadded)";
4600 
4601       initialize();
4602 
4603       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
4604 
4605       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,columnMajor>;
4606       std::unique_ptr<int[]> memory( new int[9UL] );
4607       UnalignedUnpadded mat( memory.get()+1UL, 2UL, 4UL );
4608       mat = 0;
4609       mat(0,0) = 11;
4610       mat(0,3) = 12;
4611       mat(1,1) = 13;
4612       mat(1,2) = 14;
4613 
4614       rs -= mat;
4615 
4616       checkRows    ( rs  ,  2UL );
4617       checkColumns ( rs  ,  4UL );
4618       checkNonZeros( rs  ,  6UL );
4619       checkRows    ( mat_,  5UL );
4620       checkColumns ( mat_,  4UL );
4621       checkNonZeros( mat_, 12UL );
4622 
4623       if( rs(0,0) != -11 || rs(0,1) !=   4 || rs(0,2) !=   5 || rs(0,3) != -18 ||
4624           rs(1,0) !=   0 || rs(1,1) != -12 || rs(1,2) != -14 || rs(1,3) !=   0 ) {
4625          std::ostringstream oss;
4626          oss << " Test: " << test_ << "\n"
4627              << " Error: Subtraction assignment failed\n"
4628              << " Details:\n"
4629              << "   Result:\n" << rs << "\n"
4630              << "   Expected result:\n( -11   4   5 -18 )\n(   0 -12 -14   0 )\n";
4631          throw std::runtime_error( oss.str() );
4632       }
4633 
4634       if( mat_(0,0) !=   0 || mat_(0,1) !=   0 || mat_(0,2) !=   0 || mat_(0,3) !=   0 ||
4635           mat_(1,0) !=   0 || mat_(1,1) != -12 || mat_(1,2) != -14 || mat_(1,3) !=   0 ||
4636           mat_(2,0) !=  -2 || mat_(2,1) !=   0 || mat_(2,2) !=  -3 || mat_(2,3) !=   0 ||
4637           mat_(3,0) != -11 || mat_(3,1) !=   4 || mat_(3,2) !=   5 || mat_(3,3) != -18 ||
4638           mat_(4,0) !=   7 || mat_(4,1) !=  -8 || mat_(4,2) !=   9 || mat_(4,3) !=  10 ) {
4639          std::ostringstream oss;
4640          oss << " Test: " << test_ << "\n"
4641              << " Error: Subtraction assignment failed\n"
4642              << " Details:\n"
4643              << "   Result:\n" << mat_ << "\n"
4644              << "   Expected result:\n(   0   0   0   0 )\n"
4645                                      "(   0 -12 -14   0 )\n"
4646                                      "(  -2   0  -3   0 )\n"
4647                                      "( -11   4   5 -18 )\n"
4648                                      "(   7  -8   9  10 )\n";
4649          throw std::runtime_error( oss.str() );
4650       }
4651    }
4652 
4653 
4654    //=====================================================================================
4655    // Column-major sparse matrix subtraction assignment
4656    //=====================================================================================
4657 
4658    {
4659       test_ = "Column-major/row-major sparse matrix subtraction assignment";
4660 
4661       initialize();
4662 
4663       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
4664 
4665       const blaze::CompressedMatrix<int,rowMajor> mat{ { 11,  0,  0, 12 },
4666                                                        {  0, 13, 14,  0 } };
4667 
4668       rs -= mat;
4669 
4670       checkRows    ( rs  ,  2UL );
4671       checkColumns ( rs  ,  4UL );
4672       checkNonZeros( rs  ,  6UL );
4673       checkRows    ( mat_,  5UL );
4674       checkColumns ( mat_,  4UL );
4675       checkNonZeros( mat_, 12UL );
4676 
4677       if( rs(0,0) != -11 || rs(0,1) !=   4 || rs(0,2) !=   5 || rs(0,3) != -18 ||
4678           rs(1,0) !=   0 || rs(1,1) != -12 || rs(1,2) != -14 || rs(1,3) !=   0 ) {
4679          std::ostringstream oss;
4680          oss << " Test: " << test_ << "\n"
4681              << " Error: Subtraction assignment failed\n"
4682              << " Details:\n"
4683              << "   Result:\n" << rs << "\n"
4684              << "   Expected result:\n( -11   4   5 -18 )\n(   0 -12 -14   0 )\n";
4685          throw std::runtime_error( oss.str() );
4686       }
4687 
4688       if( mat_(0,0) !=   0 || mat_(0,1) !=   0 || mat_(0,2) !=   0 || mat_(0,3) !=   0 ||
4689           mat_(1,0) !=   0 || mat_(1,1) != -12 || mat_(1,2) != -14 || mat_(1,3) !=   0 ||
4690           mat_(2,0) !=  -2 || mat_(2,1) !=   0 || mat_(2,2) !=  -3 || mat_(2,3) !=   0 ||
4691           mat_(3,0) != -11 || mat_(3,1) !=   4 || mat_(3,2) !=   5 || mat_(3,3) != -18 ||
4692           mat_(4,0) !=   7 || mat_(4,1) !=  -8 || mat_(4,2) !=   9 || mat_(4,3) !=  10 ) {
4693          std::ostringstream oss;
4694          oss << " Test: " << test_ << "\n"
4695              << " Error: Subtraction assignment failed\n"
4696              << " Details:\n"
4697              << "   Result:\n" << mat_ << "\n"
4698              << "   Expected result:\n(   0   0   0   0 )\n"
4699                                      "(   0 -12 -14   0 )\n"
4700                                      "(  -2   0  -3   0 )\n"
4701                                      "( -11   4   5 -18 )\n"
4702                                      "(   7  -8   9  10 )\n";
4703          throw std::runtime_error( oss.str() );
4704       }
4705    }
4706 
4707    {
4708       test_ = "Column-major/column-major sparse matrix subtraction assignment";
4709 
4710       initialize();
4711 
4712       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
4713 
4714       const blaze::CompressedMatrix<int,columnMajor> mat{ { 11,  0,  0, 12 },
4715                                                           {  0, 13, 14,  0 } };
4716 
4717       rs -= mat;
4718 
4719       checkRows    ( rs  ,  2UL );
4720       checkColumns ( rs  ,  4UL );
4721       checkNonZeros( rs  ,  6UL );
4722       checkRows    ( mat_,  5UL );
4723       checkColumns ( mat_,  4UL );
4724       checkNonZeros( mat_, 12UL );
4725 
4726       if( rs(0,0) != -11 || rs(0,1) !=   4 || rs(0,2) !=   5 || rs(0,3) != -18 ||
4727           rs(1,0) !=   0 || rs(1,1) != -12 || rs(1,2) != -14 || rs(1,3) !=   0 ) {
4728          std::ostringstream oss;
4729          oss << " Test: " << test_ << "\n"
4730              << " Error: Subtraction assignment failed\n"
4731              << " Details:\n"
4732              << "   Result:\n" << rs << "\n"
4733              << "   Expected result:\n( -11   4   5 -18 )\n(   0 -12 -14   0 )\n";
4734          throw std::runtime_error( oss.str() );
4735       }
4736 
4737       if( mat_(0,0) !=   0 || mat_(0,1) !=   0 || mat_(0,2) !=   0 || mat_(0,3) !=   0 ||
4738           mat_(1,0) !=   0 || mat_(1,1) != -12 || mat_(1,2) != -14 || mat_(1,3) !=   0 ||
4739           mat_(2,0) !=  -2 || mat_(2,1) !=   0 || mat_(2,2) !=  -3 || mat_(2,3) !=   0 ||
4740           mat_(3,0) != -11 || mat_(3,1) !=   4 || mat_(3,2) !=   5 || mat_(3,3) != -18 ||
4741           mat_(4,0) !=   7 || mat_(4,1) !=  -8 || mat_(4,2) !=   9 || mat_(4,3) !=  10 ) {
4742          std::ostringstream oss;
4743          oss << " Test: " << test_ << "\n"
4744              << " Error: Subtraction assignment failed\n"
4745              << " Details:\n"
4746              << "   Result:\n" << mat_ << "\n"
4747              << "   Expected result:\n(   0   0   0   0 )\n"
4748                                      "(   0 -12 -14   0 )\n"
4749                                      "(  -2   0  -3   0 )\n"
4750                                      "( -11   4   5 -18 )\n"
4751                                      "(   7  -8   9  10 )\n";
4752          throw std::runtime_error( oss.str() );
4753       }
4754    }
4755 }
4756 //*************************************************************************************************
4757 
4758 
4759 //*************************************************************************************************
4760 /*!\brief Test of the Rows Schur product assignment operators.
4761 //
4762 // \return void
4763 // \exception std::runtime_error Error detected.
4764 //
4765 // This function performs a test of the Schur product assignment operators of the Rows
4766 // specialization. In case an error is detected, a \a std::runtime_error exception is thrown.
4767 */
testSchurAssign()4768 void DenseGeneralTest::testSchurAssign()
4769 {
4770    using blaze::aligned;
4771    using blaze::unaligned;
4772    using blaze::padded;
4773    using blaze::unpadded;
4774    using blaze::rowMajor;
4775    using blaze::columnMajor;
4776 
4777 
4778    //=====================================================================================
4779    // Row-major Rows Schur product assignment
4780    //=====================================================================================
4781 
4782    {
4783       test_ = "Row-major Rows Schur product assignment (no aliasing)";
4784 
4785       initialize();
4786 
4787       MT mat{ { 0, 0, 0, 0 },
4788               { 1, 2, 3, 0 },
4789               { 0, 0, 0, 0 },
4790               { 4, 3, 2, 1 },
4791               { 0, 0, 0, 0 } };
4792 
4793       auto rs = blaze::rows( mat, { 3UL, 1UL } );
4794       rs %= blaze::rows( mat_, { 3UL, 1UL } );
4795 
4796       checkRows    ( rs , 2UL );
4797       checkColumns ( rs , 4UL );
4798       checkNonZeros( rs , 4UL );
4799       checkRows    ( mat, 5UL );
4800       checkColumns ( mat, 4UL );
4801       checkNonZeros( mat, 4UL );
4802 
4803       if( rs(0,0) != 0 || rs(0,1) != 12 || rs(0,2) != 10 || rs(0,3) != -6 ||
4804           rs(1,0) != 0 || rs(1,1) !=  2 || rs(1,2) !=  0 || rs(1,3) !=  0 ) {
4805          std::ostringstream oss;
4806          oss << " Test: " << test_ << "\n"
4807              << " Error: Schur product assignment failed\n"
4808              << " Details:\n"
4809              << "   Result:\n" << rs << "\n"
4810              << "   Expected result:\n( 0 12 10 -6 )\n( 0  2  0  0 )\n";
4811          throw std::runtime_error( oss.str() );
4812       }
4813 
4814       if( mat(0,0) != 0 || mat(0,1) !=  0 || mat(0,2) !=  0 || mat(0,3) !=  0 ||
4815           mat(1,0) != 0 || mat(1,1) !=  2 || mat(1,2) !=  0 || mat(1,3) !=  0 ||
4816           mat(2,0) != 0 || mat(2,1) !=  0 || mat(2,2) !=  0 || mat(2,3) !=  0 ||
4817           mat(3,0) != 0 || mat(3,1) != 12 || mat(3,2) != 10 || mat(3,3) != -6 ||
4818           mat(4,0) != 0 || mat(4,1) !=  0 || mat(4,2) !=  0 || mat(4,3) !=  0 ) {
4819          std::ostringstream oss;
4820          oss << " Test: " << test_ << "\n"
4821              << " Error: Schur product assignment failed\n"
4822              << " Details:\n"
4823              << "   Result:\n" << mat << "\n"
4824              << "   Expected result:\n(  0  0  0  0 )\n"
4825                                      "(  0  2  0  0 )\n"
4826                                      "(  0  0  0  0 )\n"
4827                                      "(  0 12 10 -6 )\n"
4828                                      "(  0  0  0  0 )\n";
4829          throw std::runtime_error( oss.str() );
4830       }
4831    }
4832 
4833    {
4834       test_ = "Row-major Rows Schur product assignment (aliasing)";
4835 
4836       initialize();
4837 
4838       auto rs = blaze::rows( mat_, { 3UL, 4UL } );
4839       rs %= blaze::rows( mat_, { 2UL, 3UL } );
4840 
4841       checkRows    ( rs  , 2UL );
4842       checkColumns ( rs  , 4UL );
4843       checkNonZeros( rs  , 4UL );
4844       checkRows    ( mat_, 5UL );
4845       checkColumns ( mat_, 4UL );
4846       checkNonZeros( mat_, 7UL );
4847 
4848       if( rs(0,0) != 0 || rs(0,1) !=   0 || rs(0,2) != -15 || rs(0,3) !=   0 ||
4849           rs(1,0) != 0 || rs(1,1) != -32 || rs(1,2) !=  45 || rs(1,3) != -60 ) {
4850          std::ostringstream oss;
4851          oss << " Test: " << test_ << "\n"
4852              << " Error: Schur product assignment failed\n"
4853              << " Details:\n"
4854              << "   Result:\n" << rs << "\n"
4855              << "   Expected result:\n( 0   0 -15   0 )\n( 0 -32  45 -60 )\n";
4856          throw std::runtime_error( oss.str() );
4857       }
4858 
4859       if( mat_(0,0) !=  0 || mat_(0,1) !=   0 || mat_(0,2) !=   0 || mat_(0,3) !=   0 ||
4860           mat_(1,0) !=  0 || mat_(1,1) !=   1 || mat_(1,2) !=   0 || mat_(1,3) !=   0 ||
4861           mat_(2,0) != -2 || mat_(2,1) !=   0 || mat_(2,2) !=  -3 || mat_(2,3) !=   0 ||
4862           mat_(3,0) !=  0 || mat_(3,1) !=   0 || mat_(3,2) != -15 || mat_(3,3) !=   0 ||
4863           mat_(4,0) !=  0 || mat_(4,1) != -32 || mat_(4,2) !=  45 || mat_(4,3) != -60 ) {
4864          std::ostringstream oss;
4865          oss << " Test: " << test_ << "\n"
4866              << " Error: Schur product assignment failed\n"
4867              << " Details:\n"
4868              << "   Result:\n" << mat_ << "\n"
4869              << "   Expected result:\n(  0   0   0   0 )\n"
4870                                      "(  0   1   0   0 )\n"
4871                                      "( -2   0  -3   0 )\n"
4872                                      "(  0   0 -15   0 )\n"
4873                                      "(  0 -32  45 -60 )\n";
4874          throw std::runtime_error( oss.str() );
4875       }
4876    }
4877 
4878 
4879    //=====================================================================================
4880    // Row-major dense matrix Schur product assignment
4881    //=====================================================================================
4882 
4883    {
4884       test_ = "Row-major/row-major dense matrix Schur product assignment (mixed type)";
4885 
4886       initialize();
4887 
4888       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
4889 
4890       const blaze::DynamicMatrix<short,rowMajor> mat{ { 0, -1, 0, -2 },
4891                                                       { 0,  2, 1,  0 } };
4892 
4893       rs %= mat;
4894 
4895       checkRows    ( rs  , 2UL );
4896       checkColumns ( rs  , 4UL );
4897       checkNonZeros( rs  , 3UL );
4898       checkRows    ( mat_, 5UL );
4899       checkColumns ( mat_, 4UL );
4900       checkNonZeros( mat_, 9UL );
4901 
4902       if( rs(0,0) != 0 || rs(0,1) != -4 || rs(0,2) != 0 || rs(0,3) != 12 ||
4903           rs(1,0) != 0 || rs(1,1) !=  2 || rs(1,2) != 0 || rs(1,3) !=  0 ) {
4904          std::ostringstream oss;
4905          oss << " Test: " << test_ << "\n"
4906              << " Error: Schur product assignment failed\n"
4907              << " Details:\n"
4908              << "   Result:\n" << rs << "\n"
4909              << "   Expected result:\n( 0 -4  0 12 )\n( 0  2  0  0 )\n";
4910          throw std::runtime_error( oss.str() );
4911       }
4912 
4913       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
4914           mat_(1,0) !=  0 || mat_(1,1) !=  2 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
4915           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
4916           mat_(3,0) !=  0 || mat_(3,1) != -4 || mat_(3,2) !=  0 || mat_(3,3) != 12 ||
4917           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
4918          std::ostringstream oss;
4919          oss << " Test: " << test_ << "\n"
4920              << " Error: Schur product assignment failed\n"
4921              << " Details:\n"
4922              << "   Result:\n" << mat_ << "\n"
4923              << "   Expected result:\n(  0  0  0  0 )\n"
4924                                      "(  0  2  0  0 )\n"
4925                                      "( -2  0 -3  0 )\n"
4926                                      "(  0 -4  0 12 )\n"
4927                                      "(  7 -8  9 10 )\n";
4928          throw std::runtime_error( oss.str() );
4929       }
4930    }
4931 
4932    {
4933       test_ = "Row-major/row-major dense matrix Schur product assignment (aligned/padded)";
4934 
4935       initialize();
4936 
4937       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
4938 
4939       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,rowMajor>;
4940       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 32UL ) );
4941       AlignedPadded mat( memory.get(), 2UL, 4UL, 16UL );
4942       mat = 0;
4943       mat(0,1) = -1;
4944       mat(0,3) = -2;
4945       mat(1,1) =  2;
4946       mat(1,2) =  1;
4947 
4948       rs %= mat;
4949 
4950       checkRows    ( rs  , 2UL );
4951       checkColumns ( rs  , 4UL );
4952       checkNonZeros( rs  , 3UL );
4953       checkRows    ( mat_, 5UL );
4954       checkColumns ( mat_, 4UL );
4955       checkNonZeros( mat_, 9UL );
4956 
4957       if( rs(0,0) != 0 || rs(0,1) != -4 || rs(0,2) != 0 || rs(0,3) != 12 ||
4958           rs(1,0) != 0 || rs(1,1) !=  2 || rs(1,2) != 0 || rs(1,3) !=  0 ) {
4959          std::ostringstream oss;
4960          oss << " Test: " << test_ << "\n"
4961              << " Error: Schur product assignment failed\n"
4962              << " Details:\n"
4963              << "   Result:\n" << rs << "\n"
4964              << "   Expected result:\n( 0 -4  0 12 )\n( 0  2  0  0 )\n";
4965          throw std::runtime_error( oss.str() );
4966       }
4967 
4968       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
4969           mat_(1,0) !=  0 || mat_(1,1) !=  2 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
4970           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
4971           mat_(3,0) !=  0 || mat_(3,1) != -4 || mat_(3,2) !=  0 || mat_(3,3) != 12 ||
4972           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
4973          std::ostringstream oss;
4974          oss << " Test: " << test_ << "\n"
4975              << " Error: Schur product assignment failed\n"
4976              << " Details:\n"
4977              << "   Result:\n" << mat_ << "\n"
4978              << "   Expected result:\n(  0  0  0  0 )\n"
4979                                      "(  0  2  0  0 )\n"
4980                                      "( -2  0 -3  0 )\n"
4981                                      "(  0 -4  0 12 )\n"
4982                                      "(  7 -8  9 10 )\n";
4983          throw std::runtime_error( oss.str() );
4984       }
4985    }
4986 
4987    {
4988       test_ = "Row-major/row-major dense matrix Schur product assignment (unaligned/unpadded)";
4989 
4990       initialize();
4991 
4992       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
4993 
4994       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,rowMajor>;
4995       std::unique_ptr<int[]> memory( new int[9UL] );
4996       UnalignedUnpadded mat( memory.get()+1UL, 2UL, 4UL );
4997       mat = 0;
4998       mat(0,1) = -1;
4999       mat(0,3) = -2;
5000       mat(1,1) =  2;
5001       mat(1,2) =  1;
5002 
5003       rs %= mat;
5004 
5005       checkRows    ( rs  , 2UL );
5006       checkColumns ( rs  , 4UL );
5007       checkNonZeros( rs  , 3UL );
5008       checkRows    ( mat_, 5UL );
5009       checkColumns ( mat_, 4UL );
5010       checkNonZeros( mat_, 9UL );
5011 
5012       if( rs(0,0) != 0 || rs(0,1) != -4 || rs(0,2) != 0 || rs(0,3) != 12 ||
5013           rs(1,0) != 0 || rs(1,1) !=  2 || rs(1,2) != 0 || rs(1,3) !=  0 ) {
5014          std::ostringstream oss;
5015          oss << " Test: " << test_ << "\n"
5016              << " Error: Schur product assignment failed\n"
5017              << " Details:\n"
5018              << "   Result:\n" << rs << "\n"
5019              << "   Expected result:\n( 0 -4  0 12 )\n( 0  2  0  0 )\n";
5020          throw std::runtime_error( oss.str() );
5021       }
5022 
5023       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
5024           mat_(1,0) !=  0 || mat_(1,1) !=  2 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
5025           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
5026           mat_(3,0) !=  0 || mat_(3,1) != -4 || mat_(3,2) !=  0 || mat_(3,3) != 12 ||
5027           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
5028          std::ostringstream oss;
5029          oss << " Test: " << test_ << "\n"
5030              << " Error: Schur product assignment failed\n"
5031              << " Details:\n"
5032              << "   Result:\n" << mat_ << "\n"
5033              << "   Expected result:\n(  0  0  0  0 )\n"
5034                                      "(  0  2  0  0 )\n"
5035                                      "( -2  0 -3  0 )\n"
5036                                      "(  0 -4  0 12 )\n"
5037                                      "(  7 -8  9 10 )\n";
5038          throw std::runtime_error( oss.str() );
5039       }
5040    }
5041 
5042    {
5043       test_ = "Row-major/column-major dense matrix Schur product assignment (mixed type)";
5044 
5045       initialize();
5046 
5047       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
5048 
5049       const blaze::DynamicMatrix<short,columnMajor> mat{ { 0, -1, 0, -2 },
5050                                                          { 0,  2, 1,  0 } };
5051 
5052       rs %= mat;
5053 
5054       checkRows    ( rs  , 2UL );
5055       checkColumns ( rs  , 4UL );
5056       checkNonZeros( rs  , 3UL );
5057       checkRows    ( mat_, 5UL );
5058       checkColumns ( mat_, 4UL );
5059       checkNonZeros( mat_, 9UL );
5060 
5061       if( rs(0,0) != 0 || rs(0,1) != -4 || rs(0,2) != 0 || rs(0,3) != 12 ||
5062           rs(1,0) != 0 || rs(1,1) !=  2 || rs(1,2) != 0 || rs(1,3) !=  0 ) {
5063          std::ostringstream oss;
5064          oss << " Test: " << test_ << "\n"
5065              << " Error: Schur product assignment failed\n"
5066              << " Details:\n"
5067              << "   Result:\n" << rs << "\n"
5068              << "   Expected result:\n( 0 -4  0 12 )\n( 0  2  0  0 )\n";
5069          throw std::runtime_error( oss.str() );
5070       }
5071 
5072       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
5073           mat_(1,0) !=  0 || mat_(1,1) !=  2 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
5074           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
5075           mat_(3,0) !=  0 || mat_(3,1) != -4 || mat_(3,2) !=  0 || mat_(3,3) != 12 ||
5076           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
5077          std::ostringstream oss;
5078          oss << " Test: " << test_ << "\n"
5079              << " Error: Schur product assignment failed\n"
5080              << " Details:\n"
5081              << "   Result:\n" << mat_ << "\n"
5082              << "   Expected result:\n(  0  0  0  0 )\n"
5083                                      "(  0  2  0  0 )\n"
5084                                      "( -2  0 -3  0 )\n"
5085                                      "(  0 -4  0 12 )\n"
5086                                      "(  7 -8  9 10 )\n";
5087          throw std::runtime_error( oss.str() );
5088       }
5089    }
5090 
5091    {
5092       test_ = "Row-major/column-major dense matrix Schur product assignment (aligned/padded)";
5093 
5094       initialize();
5095 
5096       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
5097 
5098       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,columnMajor>;
5099       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 64UL ) );
5100       AlignedPadded mat( memory.get(), 2UL, 4UL, 16UL );
5101       mat = 0;
5102       mat(0,1) = -1;
5103       mat(0,3) = -2;
5104       mat(1,1) =  2;
5105       mat(1,2) =  1;
5106 
5107       rs %= mat;
5108 
5109       checkRows    ( rs  , 2UL );
5110       checkColumns ( rs  , 4UL );
5111       checkNonZeros( rs  , 3UL );
5112       checkRows    ( mat_, 5UL );
5113       checkColumns ( mat_, 4UL );
5114       checkNonZeros( mat_, 9UL );
5115 
5116       if( rs(0,0) != 0 || rs(0,1) != -4 || rs(0,2) != 0 || rs(0,3) != 12 ||
5117           rs(1,0) != 0 || rs(1,1) !=  2 || rs(1,2) != 0 || rs(1,3) !=  0 ) {
5118          std::ostringstream oss;
5119          oss << " Test: " << test_ << "\n"
5120              << " Error: Schur product assignment failed\n"
5121              << " Details:\n"
5122              << "   Result:\n" << rs << "\n"
5123              << "   Expected result:\n( 0 -4  0 12 )\n( 0  2  0  0 )\n";
5124          throw std::runtime_error( oss.str() );
5125       }
5126 
5127       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
5128           mat_(1,0) !=  0 || mat_(1,1) !=  2 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
5129           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
5130           mat_(3,0) !=  0 || mat_(3,1) != -4 || mat_(3,2) !=  0 || mat_(3,3) != 12 ||
5131           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
5132          std::ostringstream oss;
5133          oss << " Test: " << test_ << "\n"
5134              << " Error: Schur product assignment failed\n"
5135              << " Details:\n"
5136              << "   Result:\n" << mat_ << "\n"
5137              << "   Expected result:\n(  0  0  0  0 )\n"
5138                                      "(  0  2  0  0 )\n"
5139                                      "( -2  0 -3  0 )\n"
5140                                      "(  0 -4  0 12 )\n"
5141                                      "(  7 -8  9 10 )\n";
5142          throw std::runtime_error( oss.str() );
5143       }
5144    }
5145 
5146    {
5147       test_ = "Row-major/column-major dense matrix Schur product assignment (unaligned/unpadded)";
5148 
5149       initialize();
5150 
5151       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
5152 
5153       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,columnMajor>;
5154       std::unique_ptr<int[]> memory( new int[9UL] );
5155       UnalignedUnpadded mat( memory.get()+1UL, 2UL, 4UL );
5156       mat = 0;
5157       mat(0,1) = -1;
5158       mat(0,3) = -2;
5159       mat(1,1) =  2;
5160       mat(1,2) =  1;
5161 
5162       rs %= mat;
5163 
5164       checkRows    ( rs  , 2UL );
5165       checkColumns ( rs  , 4UL );
5166       checkNonZeros( rs  , 3UL );
5167       checkRows    ( mat_, 5UL );
5168       checkColumns ( mat_, 4UL );
5169       checkNonZeros( mat_, 9UL );
5170 
5171       if( rs(0,0) != 0 || rs(0,1) != -4 || rs(0,2) != 0 || rs(0,3) != 12 ||
5172           rs(1,0) != 0 || rs(1,1) !=  2 || rs(1,2) != 0 || rs(1,3) !=  0 ) {
5173          std::ostringstream oss;
5174          oss << " Test: " << test_ << "\n"
5175              << " Error: Schur product assignment failed\n"
5176              << " Details:\n"
5177              << "   Result:\n" << rs << "\n"
5178              << "   Expected result:\n( 0 -4  0 12 )\n( 0  2  0  0 )\n";
5179          throw std::runtime_error( oss.str() );
5180       }
5181 
5182       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
5183           mat_(1,0) !=  0 || mat_(1,1) !=  2 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
5184           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
5185           mat_(3,0) !=  0 || mat_(3,1) != -4 || mat_(3,2) !=  0 || mat_(3,3) != 12 ||
5186           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
5187          std::ostringstream oss;
5188          oss << " Test: " << test_ << "\n"
5189              << " Error: Schur product assignment failed\n"
5190              << " Details:\n"
5191              << "   Result:\n" << mat_ << "\n"
5192              << "   Expected result:\n(  0  0  0  0 )\n"
5193                                      "(  0  2  0  0 )\n"
5194                                      "( -2  0 -3  0 )\n"
5195                                      "(  0 -4  0 12 )\n"
5196                                      "(  7 -8  9 10 )\n";
5197          throw std::runtime_error( oss.str() );
5198       }
5199    }
5200 
5201 
5202    //=====================================================================================
5203    // Row-major sparse matrix Schur product assignment
5204    //=====================================================================================
5205 
5206    {
5207       test_ = "Row-major/row-major sparse matrix Schur product assignment";
5208 
5209       initialize();
5210 
5211       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
5212 
5213       const blaze::CompressedMatrix<int,rowMajor> mat{ { 0, -1, 0, -2 },
5214                                                        { 0,  2, 1,  0 } };
5215 
5216       rs %= mat;
5217 
5218       checkRows    ( rs  , 2UL );
5219       checkColumns ( rs  , 4UL );
5220       checkNonZeros( rs  , 3UL );
5221       checkRows    ( mat_, 5UL );
5222       checkColumns ( mat_, 4UL );
5223       checkNonZeros( mat_, 9UL );
5224 
5225       if( rs(0,0) != 0 || rs(0,1) != -4 || rs(0,2) != 0 || rs(0,3) != 12 ||
5226           rs(1,0) != 0 || rs(1,1) !=  2 || rs(1,2) != 0 || rs(1,3) !=  0 ) {
5227          std::ostringstream oss;
5228          oss << " Test: " << test_ << "\n"
5229              << " Error: Schur product assignment failed\n"
5230              << " Details:\n"
5231              << "   Result:\n" << rs << "\n"
5232              << "   Expected result:\n( 0 -4  0 12 )\n( 0  2  0  0 )\n";
5233          throw std::runtime_error( oss.str() );
5234       }
5235 
5236       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
5237           mat_(1,0) !=  0 || mat_(1,1) !=  2 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
5238           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
5239           mat_(3,0) !=  0 || mat_(3,1) != -4 || mat_(3,2) !=  0 || mat_(3,3) != 12 ||
5240           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
5241          std::ostringstream oss;
5242          oss << " Test: " << test_ << "\n"
5243              << " Error: Schur product assignment failed\n"
5244              << " Details:\n"
5245              << "   Result:\n" << mat_ << "\n"
5246              << "   Expected result:\n(  0  0  0  0 )\n"
5247                                      "(  0  2  0  0 )\n"
5248                                      "( -2  0 -3  0 )\n"
5249                                      "(  0 -4  0 12 )\n"
5250                                      "(  7 -8  9 10 )\n";
5251          throw std::runtime_error( oss.str() );
5252       }
5253    }
5254 
5255    {
5256       test_ = "Row-major/column-major sparse matrix Schur product assignment";
5257 
5258       initialize();
5259 
5260       auto rs = blaze::rows( mat_, { 3UL, 1UL } );
5261 
5262       const blaze::CompressedMatrix<int,columnMajor> mat{ { 0, -1, 0, -2 },
5263                                                           { 0,  2, 1,  0 } };
5264 
5265       rs %= mat;
5266 
5267       checkRows    ( rs  , 2UL );
5268       checkColumns ( rs  , 4UL );
5269       checkNonZeros( rs  , 3UL );
5270       checkRows    ( mat_, 5UL );
5271       checkColumns ( mat_, 4UL );
5272       checkNonZeros( mat_, 9UL );
5273 
5274       if( rs(0,0) != 0 || rs(0,1) != -4 || rs(0,2) != 0 || rs(0,3) != 12 ||
5275           rs(1,0) != 0 || rs(1,1) !=  2 || rs(1,2) != 0 || rs(1,3) !=  0 ) {
5276          std::ostringstream oss;
5277          oss << " Test: " << test_ << "\n"
5278              << " Error: Schur product assignment failed\n"
5279              << " Details:\n"
5280              << "   Result:\n" << rs << "\n"
5281              << "   Expected result:\n( 0 -4  0 12 )\n( 0  2  0  0 )\n";
5282          throw std::runtime_error( oss.str() );
5283       }
5284 
5285       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
5286           mat_(1,0) !=  0 || mat_(1,1) !=  2 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
5287           mat_(2,0) != -2 || mat_(2,1) !=  0 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
5288           mat_(3,0) !=  0 || mat_(3,1) != -4 || mat_(3,2) !=  0 || mat_(3,3) != 12 ||
5289           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
5290          std::ostringstream oss;
5291          oss << " Test: " << test_ << "\n"
5292              << " Error: Schur product assignment failed\n"
5293              << " Details:\n"
5294              << "   Result:\n" << mat_ << "\n"
5295              << "   Expected result:\n(  0  0  0  0 )\n"
5296                                      "(  0  2  0  0 )\n"
5297                                      "( -2  0 -3  0 )\n"
5298                                      "(  0 -4  0 12 )\n"
5299                                      "(  7 -8  9 10 )\n";
5300          throw std::runtime_error( oss.str() );
5301       }
5302    }
5303 
5304 
5305    //=====================================================================================
5306    // Column-major Rows Schur product assignment
5307    //=====================================================================================
5308 
5309    {
5310       test_ = "Column-major Rows Schur product assignment (no aliasing)";
5311 
5312       initialize();
5313 
5314       OMT mat{ { 0, 0, 0, 0 },
5315                { 1, 2, 3, 0 },
5316                { 0, 0, 0, 0 },
5317                { 4, 3, 2, 1 },
5318                { 0, 0, 0, 0 } };
5319 
5320       auto rs = blaze::rows( mat, { 3UL, 1UL } );
5321       rs %= blaze::rows( tmat_, { 3UL, 1UL } );
5322 
5323       checkRows    ( rs , 2UL );
5324       checkColumns ( rs , 4UL );
5325       checkNonZeros( rs , 4UL );
5326       checkRows    ( mat, 5UL );
5327       checkColumns ( mat, 4UL );
5328       checkNonZeros( mat, 4UL );
5329 
5330       if( rs(0,0) != 0 || rs(0,1) != 12 || rs(0,2) != 10 || rs(0,3) != -6 ||
5331           rs(1,0) != 0 || rs(1,1) !=  2 || rs(1,2) !=  0 || rs(1,3) !=  0 ) {
5332          std::ostringstream oss;
5333          oss << " Test: " << test_ << "\n"
5334              << " Error: Schur product assignment failed\n"
5335              << " Details:\n"
5336              << "   Result:\n" << rs << "\n"
5337              << "   Expected result:\n( 0 12 10 -6 )\n( 0  2  0  0 )\n";
5338          throw std::runtime_error( oss.str() );
5339       }
5340 
5341       if( mat(0,0) != 0 || mat(0,1) !=  0 || mat(0,2) !=  0 || mat(0,3) !=  0 ||
5342           mat(1,0) != 0 || mat(1,1) !=  2 || mat(1,2) !=  0 || mat(1,3) !=  0 ||
5343           mat(2,0) != 0 || mat(2,1) !=  0 || mat(2,2) !=  0 || mat(2,3) !=  0 ||
5344           mat(3,0) != 0 || mat(3,1) != 12 || mat(3,2) != 10 || mat(3,3) != -6 ||
5345           mat(4,0) != 0 || mat(4,1) !=  0 || mat(4,2) !=  0 || mat(4,3) !=  0 ) {
5346          std::ostringstream oss;
5347          oss << " Test: " << test_ << "\n"
5348              << " Error: Schur product assignment failed\n"
5349              << " Details:\n"
5350              << "   Result:\n" << mat << "\n"
5351              << "   Expected result:\n(  0  0  0  0 )\n"
5352                                      "(  0  2  0  0 )\n"
5353                                      "(  0  0  0  0 )\n"
5354                                      "(  0 12 10 -6 )\n"
5355                                      "(  0  0  0  0 )\n";
5356          throw std::runtime_error( oss.str() );
5357       }
5358    }
5359 
5360    {
5361       test_ = "Column-major Rows Schur product assignment (aliasing)";
5362 
5363       initialize();
5364 
5365       auto rs = blaze::rows( tmat_, { 3UL, 4UL } );
5366       rs %= blaze::rows( tmat_, { 2UL, 3UL } );
5367 
5368       checkRows    ( rs   , 2UL );
5369       checkColumns ( rs   , 4UL );
5370       checkNonZeros( rs   , 4UL );
5371       checkRows    ( tmat_, 5UL );
5372       checkColumns ( tmat_, 4UL );
5373       checkNonZeros( tmat_, 7UL );
5374 
5375       if( rs(0,0) != 0 || rs(0,1) !=   0 || rs(0,2) != -15 || rs(0,3) !=   0 ||
5376           rs(1,0) != 0 || rs(1,1) != -32 || rs(1,2) !=  45 || rs(1,3) != -60 ) {
5377          std::ostringstream oss;
5378          oss << " Test: " << test_ << "\n"
5379              << " Error: Schur product assignment failed\n"
5380              << " Details:\n"
5381              << "   Result:\n" << rs << "\n"
5382              << "   Expected result:\n( 0   0 -15   0 )\n( 0 -32  45 -60 )\n";
5383          throw std::runtime_error( oss.str() );
5384       }
5385 
5386       if( tmat_(0,0) !=  0 || tmat_(0,1) !=   0 || tmat_(0,2) !=   0 || tmat_(0,3) !=   0 ||
5387           tmat_(1,0) !=  0 || tmat_(1,1) !=   1 || tmat_(1,2) !=   0 || tmat_(1,3) !=   0 ||
5388           tmat_(2,0) != -2 || tmat_(2,1) !=   0 || tmat_(2,2) !=  -3 || tmat_(2,3) !=   0 ||
5389           tmat_(3,0) !=  0 || tmat_(3,1) !=   0 || tmat_(3,2) != -15 || tmat_(3,3) !=   0 ||
5390           tmat_(4,0) !=  0 || tmat_(4,1) != -32 || tmat_(4,2) !=  45 || tmat_(4,3) != -60 ) {
5391          std::ostringstream oss;
5392          oss << " Test: " << test_ << "\n"
5393              << " Error: Schur product assignment failed\n"
5394              << " Details:\n"
5395              << "   Result:\n" << tmat_ << "\n"
5396              << "   Expected result:\n(  0   0   0   0 )\n"
5397                                      "(  0   1   0   0 )\n"
5398                                      "( -2   0  -3   0 )\n"
5399                                      "(  0   0 -15   0 )\n"
5400                                      "(  0 -32  45 -60 )\n";
5401          throw std::runtime_error( oss.str() );
5402       }
5403    }
5404 
5405 
5406    //=====================================================================================
5407    // Column-major dense matrix Schur product assignment
5408    //=====================================================================================
5409 
5410    {
5411       test_ = "Column-major/row-major dense matrix Schur product assignment (mixed type)";
5412 
5413       initialize();
5414 
5415       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
5416 
5417       const blaze::DynamicMatrix<short,rowMajor> mat{ { 0, -1, 0, -2 },
5418                                                       { 0,  2, 1,  0 } };
5419 
5420       rs %= mat;
5421 
5422       checkRows    ( rs   , 2UL );
5423       checkColumns ( rs   , 4UL );
5424       checkNonZeros( rs   , 3UL );
5425       checkRows    ( tmat_, 5UL );
5426       checkColumns ( tmat_, 4UL );
5427       checkNonZeros( tmat_, 9UL );
5428 
5429       if( rs(0,0) != 0 || rs(0,1) != -4 || rs(0,2) != 0 || rs(0,3) != 12 ||
5430           rs(1,0) != 0 || rs(1,1) !=  2 || rs(1,2) != 0 || rs(1,3) !=  0 ) {
5431          std::ostringstream oss;
5432          oss << " Test: " << test_ << "\n"
5433              << " Error: Schur product assignment failed\n"
5434              << " Details:\n"
5435              << "   Result:\n" << rs << "\n"
5436              << "   Expected result:\n( 0 -4  0 12 )\n( 0  2  0  0 )\n";
5437          throw std::runtime_error( oss.str() );
5438       }
5439 
5440       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
5441           tmat_(1,0) !=  0 || tmat_(1,1) !=  2 || tmat_(1,2) !=  0 || tmat_(1,3) !=  0 ||
5442           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
5443           tmat_(3,0) !=  0 || tmat_(3,1) != -4 || tmat_(3,2) !=  0 || tmat_(3,3) != 12 ||
5444           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
5445          std::ostringstream oss;
5446          oss << " Test: " << test_ << "\n"
5447              << " Error: Schur product assignment failed\n"
5448              << " Details:\n"
5449              << "   Result:\n" << tmat_ << "\n"
5450              << "   Expected result:\n(  0  0  0  0 )\n"
5451                                      "(  0  2  0  0 )\n"
5452                                      "( -2  0 -3  0 )\n"
5453                                      "(  0 -4  0 12 )\n"
5454                                      "(  7 -8  9 10 )\n";
5455          throw std::runtime_error( oss.str() );
5456       }
5457    }
5458 
5459    {
5460       test_ = "Column-major/row-major dense matrix Schur product assignment (aligned/padded)";
5461 
5462       initialize();
5463 
5464       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
5465 
5466       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,rowMajor>;
5467       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 32UL ) );
5468       AlignedPadded mat( memory.get(), 2UL, 4UL, 16UL );
5469       mat = 0;
5470       mat(0,1) = -1;
5471       mat(0,3) = -2;
5472       mat(1,1) =  2;
5473       mat(1,2) =  1;
5474 
5475       rs %= mat;
5476 
5477       checkRows    ( rs   , 2UL );
5478       checkColumns ( rs   , 4UL );
5479       checkNonZeros( rs   , 3UL );
5480       checkRows    ( tmat_, 5UL );
5481       checkColumns ( tmat_, 4UL );
5482       checkNonZeros( tmat_, 9UL );
5483 
5484       if( rs(0,0) != 0 || rs(0,1) != -4 || rs(0,2) != 0 || rs(0,3) != 12 ||
5485           rs(1,0) != 0 || rs(1,1) !=  2 || rs(1,2) != 0 || rs(1,3) !=  0 ) {
5486          std::ostringstream oss;
5487          oss << " Test: " << test_ << "\n"
5488              << " Error: Schur product assignment failed\n"
5489              << " Details:\n"
5490              << "   Result:\n" << rs << "\n"
5491              << "   Expected result:\n( 0 -4  0 12 )\n( 0  2  0  0 )\n";
5492          throw std::runtime_error( oss.str() );
5493       }
5494 
5495       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
5496           tmat_(1,0) !=  0 || tmat_(1,1) !=  2 || tmat_(1,2) !=  0 || tmat_(1,3) !=  0 ||
5497           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
5498           tmat_(3,0) !=  0 || tmat_(3,1) != -4 || tmat_(3,2) !=  0 || tmat_(3,3) != 12 ||
5499           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
5500          std::ostringstream oss;
5501          oss << " Test: " << test_ << "\n"
5502              << " Error: Schur product assignment failed\n"
5503              << " Details:\n"
5504              << "   Result:\n" << tmat_ << "\n"
5505              << "   Expected result:\n(  0  0  0  0 )\n"
5506                                      "(  0  2  0  0 )\n"
5507                                      "( -2  0 -3  0 )\n"
5508                                      "(  0 -4  0 12 )\n"
5509                                      "(  7 -8  9 10 )\n";
5510          throw std::runtime_error( oss.str() );
5511       }
5512    }
5513 
5514    {
5515       test_ = "Column-major/row-major dense matrix Schur product assignment (unaligned/unpadded)";
5516 
5517       initialize();
5518 
5519       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
5520 
5521       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,rowMajor>;
5522       std::unique_ptr<int[]> memory( new int[9UL] );
5523       UnalignedUnpadded mat( memory.get()+1UL, 2UL, 4UL );
5524       mat = 0;
5525       mat(0,1) = -1;
5526       mat(0,3) = -2;
5527       mat(1,1) =  2;
5528       mat(1,2) =  1;
5529 
5530       rs %= mat;
5531 
5532       checkRows    ( rs   , 2UL );
5533       checkColumns ( rs   , 4UL );
5534       checkNonZeros( rs   , 3UL );
5535       checkRows    ( tmat_, 5UL );
5536       checkColumns ( tmat_, 4UL );
5537       checkNonZeros( tmat_, 9UL );
5538 
5539       if( rs(0,0) != 0 || rs(0,1) != -4 || rs(0,2) != 0 || rs(0,3) != 12 ||
5540           rs(1,0) != 0 || rs(1,1) !=  2 || rs(1,2) != 0 || rs(1,3) !=  0 ) {
5541          std::ostringstream oss;
5542          oss << " Test: " << test_ << "\n"
5543              << " Error: Schur product assignment failed\n"
5544              << " Details:\n"
5545              << "   Result:\n" << rs << "\n"
5546              << "   Expected result:\n( 0 -4  0 12 )\n( 0  2  0  0 )\n";
5547          throw std::runtime_error( oss.str() );
5548       }
5549 
5550       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
5551           tmat_(1,0) !=  0 || tmat_(1,1) !=  2 || tmat_(1,2) !=  0 || tmat_(1,3) !=  0 ||
5552           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
5553           tmat_(3,0) !=  0 || tmat_(3,1) != -4 || tmat_(3,2) !=  0 || tmat_(3,3) != 12 ||
5554           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
5555          std::ostringstream oss;
5556          oss << " Test: " << test_ << "\n"
5557              << " Error: Schur product assignment failed\n"
5558              << " Details:\n"
5559              << "   Result:\n" << tmat_ << "\n"
5560              << "   Expected result:\n(  0  0  0  0 )\n"
5561                                      "(  0  2  0  0 )\n"
5562                                      "( -2  0 -3  0 )\n"
5563                                      "(  0 -4  0 12 )\n"
5564                                      "(  7 -8  9 10 )\n";
5565          throw std::runtime_error( oss.str() );
5566       }
5567    }
5568 
5569    {
5570       test_ = "Column-major/column-major dense matrix Schur product assignment (mixed type)";
5571 
5572       initialize();
5573 
5574       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
5575 
5576       const blaze::DynamicMatrix<short,columnMajor> mat{ { 0, -1, 0, -2 },
5577                                                          { 0,  2, 1,  0 } };
5578 
5579       rs %= mat;
5580 
5581       checkRows    ( rs   , 2UL );
5582       checkColumns ( rs   , 4UL );
5583       checkNonZeros( rs   , 3UL );
5584       checkRows    ( tmat_, 5UL );
5585       checkColumns ( tmat_, 4UL );
5586       checkNonZeros( tmat_, 9UL );
5587 
5588       if( rs(0,0) != 0 || rs(0,1) != -4 || rs(0,2) != 0 || rs(0,3) != 12 ||
5589           rs(1,0) != 0 || rs(1,1) !=  2 || rs(1,2) != 0 || rs(1,3) !=  0 ) {
5590          std::ostringstream oss;
5591          oss << " Test: " << test_ << "\n"
5592              << " Error: Schur product assignment failed\n"
5593              << " Details:\n"
5594              << "   Result:\n" << rs << "\n"
5595              << "   Expected result:\n( 0 -4  0 12 )\n( 0  2  0  0 )\n";
5596          throw std::runtime_error( oss.str() );
5597       }
5598 
5599       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
5600           tmat_(1,0) !=  0 || tmat_(1,1) !=  2 || tmat_(1,2) !=  0 || tmat_(1,3) !=  0 ||
5601           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
5602           tmat_(3,0) !=  0 || tmat_(3,1) != -4 || tmat_(3,2) !=  0 || tmat_(3,3) != 12 ||
5603           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
5604          std::ostringstream oss;
5605          oss << " Test: " << test_ << "\n"
5606              << " Error: Schur product assignment failed\n"
5607              << " Details:\n"
5608              << "   Result:\n" << tmat_ << "\n"
5609              << "   Expected result:\n(  0  0  0  0 )\n"
5610                                      "(  0  2  0  0 )\n"
5611                                      "( -2  0 -3  0 )\n"
5612                                      "(  0 -4  0 12 )\n"
5613                                      "(  7 -8  9 10 )\n";
5614          throw std::runtime_error( oss.str() );
5615       }
5616    }
5617 
5618    {
5619       test_ = "Column-major/column-major dense matrix Schur product assignment (aligned/padded)";
5620 
5621       initialize();
5622 
5623       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
5624 
5625       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,columnMajor>;
5626       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 64UL ) );
5627       AlignedPadded mat( memory.get(), 2UL, 4UL, 16UL );
5628       mat = 0;
5629       mat(0,1) = -1;
5630       mat(0,3) = -2;
5631       mat(1,1) =  2;
5632       mat(1,2) =  1;
5633 
5634       rs %= mat;
5635 
5636       checkRows    ( rs   , 2UL );
5637       checkColumns ( rs   , 4UL );
5638       checkNonZeros( rs   , 3UL );
5639       checkRows    ( tmat_, 5UL );
5640       checkColumns ( tmat_, 4UL );
5641       checkNonZeros( tmat_, 9UL );
5642 
5643       if( rs(0,0) != 0 || rs(0,1) != -4 || rs(0,2) != 0 || rs(0,3) != 12 ||
5644           rs(1,0) != 0 || rs(1,1) !=  2 || rs(1,2) != 0 || rs(1,3) !=  0 ) {
5645          std::ostringstream oss;
5646          oss << " Test: " << test_ << "\n"
5647              << " Error: Schur product assignment failed\n"
5648              << " Details:\n"
5649              << "   Result:\n" << rs << "\n"
5650              << "   Expected result:\n( 0 -4  0 12 )\n( 0  2  0  0 )\n";
5651          throw std::runtime_error( oss.str() );
5652       }
5653 
5654       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
5655           tmat_(1,0) !=  0 || tmat_(1,1) !=  2 || tmat_(1,2) !=  0 || tmat_(1,3) !=  0 ||
5656           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
5657           tmat_(3,0) !=  0 || tmat_(3,1) != -4 || tmat_(3,2) !=  0 || tmat_(3,3) != 12 ||
5658           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
5659          std::ostringstream oss;
5660          oss << " Test: " << test_ << "\n"
5661              << " Error: Schur product assignment failed\n"
5662              << " Details:\n"
5663              << "   Result:\n" << tmat_ << "\n"
5664              << "   Expected result:\n(  0  0  0  0 )\n"
5665                                      "(  0  2  0  0 )\n"
5666                                      "( -2  0 -3  0 )\n"
5667                                      "(  0 -4  0 12 )\n"
5668                                      "(  7 -8  9 10 )\n";
5669          throw std::runtime_error( oss.str() );
5670       }
5671    }
5672 
5673    {
5674       test_ = "Column-major/column-major dense matrix Schur product assignment (unaligned/unpadded)";
5675 
5676       initialize();
5677 
5678       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
5679 
5680       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,columnMajor>;
5681       std::unique_ptr<int[]> memory( new int[9UL] );
5682       UnalignedUnpadded mat( memory.get()+1UL, 2UL, 4UL );
5683       mat = 0;
5684       mat(0,1) = -1;
5685       mat(0,3) = -2;
5686       mat(1,1) =  2;
5687       mat(1,2) =  1;
5688 
5689       rs %= mat;
5690 
5691       checkRows    ( rs   , 2UL );
5692       checkColumns ( rs   , 4UL );
5693       checkNonZeros( rs   , 3UL );
5694       checkRows    ( tmat_, 5UL );
5695       checkColumns ( tmat_, 4UL );
5696       checkNonZeros( tmat_, 9UL );
5697 
5698       if( rs(0,0) != 0 || rs(0,1) != -4 || rs(0,2) != 0 || rs(0,3) != 12 ||
5699           rs(1,0) != 0 || rs(1,1) !=  2 || rs(1,2) != 0 || rs(1,3) !=  0 ) {
5700          std::ostringstream oss;
5701          oss << " Test: " << test_ << "\n"
5702              << " Error: Schur product assignment failed\n"
5703              << " Details:\n"
5704              << "   Result:\n" << rs << "\n"
5705              << "   Expected result:\n( 0 -4  0 12 )\n( 0  2  0  0 )\n";
5706          throw std::runtime_error( oss.str() );
5707       }
5708 
5709       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
5710           tmat_(1,0) !=  0 || tmat_(1,1) !=  2 || tmat_(1,2) !=  0 || tmat_(1,3) !=  0 ||
5711           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
5712           tmat_(3,0) !=  0 || tmat_(3,1) != -4 || tmat_(3,2) !=  0 || tmat_(3,3) != 12 ||
5713           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
5714          std::ostringstream oss;
5715          oss << " Test: " << test_ << "\n"
5716              << " Error: Schur product assignment failed\n"
5717              << " Details:\n"
5718              << "   Result:\n" << tmat_ << "\n"
5719              << "   Expected result:\n(  0  0  0  0 )\n"
5720                                      "(  0  2  0  0 )\n"
5721                                      "( -2  0 -3  0 )\n"
5722                                      "(  0 -4  0 12 )\n"
5723                                      "(  7 -8  9 10 )\n";
5724          throw std::runtime_error( oss.str() );
5725       }
5726    }
5727 
5728 
5729    //=====================================================================================
5730    // Column-major sparse matrix Schur product assignment
5731    //=====================================================================================
5732 
5733    {
5734       test_ = "Column-major/row-major sparse matrix Schur product assignment";
5735 
5736       initialize();
5737 
5738       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
5739 
5740       const blaze::CompressedMatrix<int,rowMajor> mat{ { 0, -1, 0, -2 },
5741                                                        { 0,  2, 1,  0 } };
5742 
5743       rs %= mat;
5744 
5745       checkRows    ( rs   , 2UL );
5746       checkColumns ( rs   , 4UL );
5747       checkNonZeros( rs   , 3UL );
5748       checkRows    ( tmat_, 5UL );
5749       checkColumns ( tmat_, 4UL );
5750       checkNonZeros( tmat_, 9UL );
5751 
5752       if( rs(0,0) != 0 || rs(0,1) != -4 || rs(0,2) != 0 || rs(0,3) != 12 ||
5753           rs(1,0) != 0 || rs(1,1) !=  2 || rs(1,2) != 0 || rs(1,3) !=  0 ) {
5754          std::ostringstream oss;
5755          oss << " Test: " << test_ << "\n"
5756              << " Error: Schur product assignment failed\n"
5757              << " Details:\n"
5758              << "   Result:\n" << rs << "\n"
5759              << "   Expected result:\n( 0 -4  0 12 )\n( 0  2  0  0 )\n";
5760          throw std::runtime_error( oss.str() );
5761       }
5762 
5763       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
5764           tmat_(1,0) !=  0 || tmat_(1,1) !=  2 || tmat_(1,2) !=  0 || tmat_(1,3) !=  0 ||
5765           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
5766           tmat_(3,0) !=  0 || tmat_(3,1) != -4 || tmat_(3,2) !=  0 || tmat_(3,3) != 12 ||
5767           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
5768          std::ostringstream oss;
5769          oss << " Test: " << test_ << "\n"
5770              << " Error: Schur product assignment failed\n"
5771              << " Details:\n"
5772              << "   Result:\n" << tmat_ << "\n"
5773              << "   Expected result:\n(  0  0  0  0 )\n"
5774                                      "(  0  2  0  0 )\n"
5775                                      "( -2  0 -3  0 )\n"
5776                                      "(  0 -4  0 12 )\n"
5777                                      "(  7 -8  9 10 )\n";
5778          throw std::runtime_error( oss.str() );
5779       }
5780    }
5781 
5782    {
5783       test_ = "Column-major/column-major sparse matrix Schur product assignment";
5784 
5785       initialize();
5786 
5787       auto rs = blaze::rows( tmat_, { 3UL, 1UL } );
5788 
5789       const blaze::CompressedMatrix<int,columnMajor> mat{ { 0, -1, 0, -2 },
5790                                                           { 0,  2, 1,  0 } };
5791 
5792       rs %= mat;
5793 
5794       checkRows    ( rs   , 2UL );
5795       checkColumns ( rs   , 4UL );
5796       checkNonZeros( rs   , 3UL );
5797       checkRows    ( tmat_, 5UL );
5798       checkColumns ( tmat_, 4UL );
5799       checkNonZeros( tmat_, 9UL );
5800 
5801       if( rs(0,0) != 0 || rs(0,1) != -4 || rs(0,2) != 0 || rs(0,3) != 12 ||
5802           rs(1,0) != 0 || rs(1,1) !=  2 || rs(1,2) != 0 || rs(1,3) !=  0 ) {
5803          std::ostringstream oss;
5804          oss << " Test: " << test_ << "\n"
5805              << " Error: Schur product assignment failed\n"
5806              << " Details:\n"
5807              << "   Result:\n" << rs << "\n"
5808              << "   Expected result:\n( 0 -4  0 12 )\n( 0  2  0  0 )\n";
5809          throw std::runtime_error( oss.str() );
5810       }
5811 
5812       if( tmat_(0,0) !=  0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  0 || tmat_(0,3) !=  0 ||
5813           tmat_(1,0) !=  0 || tmat_(1,1) !=  2 || tmat_(1,2) !=  0 || tmat_(1,3) !=  0 ||
5814           tmat_(2,0) != -2 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  0 ||
5815           tmat_(3,0) !=  0 || tmat_(3,1) != -4 || tmat_(3,2) !=  0 || tmat_(3,3) != 12 ||
5816           tmat_(4,0) !=  7 || tmat_(4,1) != -8 || tmat_(4,2) !=  9 || tmat_(4,3) != 10 ) {
5817          std::ostringstream oss;
5818          oss << " Test: " << test_ << "\n"
5819              << " Error: Schur product assignment failed\n"
5820              << " Details:\n"
5821              << "   Result:\n" << tmat_ << "\n"
5822              << "   Expected result:\n(  0  0  0  0 )\n"
5823                                      "(  0  2  0  0 )\n"
5824                                      "( -2  0 -3  0 )\n"
5825                                      "(  0 -4  0 12 )\n"
5826                                      "(  7 -8  9 10 )\n";
5827          throw std::runtime_error( oss.str() );
5828       }
5829    }
5830 }
5831 //*************************************************************************************************
5832 
5833 
5834 //*************************************************************************************************
5835 /*!\brief Test of the Rows multiplication assignment operators.
5836 //
5837 // \return void
5838 // \exception std::runtime_error Error detected.
5839 //
5840 // This function performs a test of the multiplication assignment operators of the Rows
5841 // specialization. In case an error is detected, a \a std::runtime_error exception is thrown.
5842 */
testMultAssign()5843 void DenseGeneralTest::testMultAssign()
5844 {
5845    using blaze::aligned;
5846    using blaze::unaligned;
5847    using blaze::padded;
5848    using blaze::unpadded;
5849    using blaze::rowMajor;
5850    using blaze::columnMajor;
5851 
5852 
5853    //=====================================================================================
5854    // Row-major Rows multiplication assignment
5855    //=====================================================================================
5856 
5857    {
5858       test_ = "Row-major Rows multiplication assignment (no aliasing)";
5859 
5860       initialize();
5861 
5862       MT mat{ {  0,  0,  0,  0 },
5863               {  0,  1,  0,  0 },
5864               { -2,  0, -3,  0 },
5865               {  0,  4,  5, -6 },
5866               {  7, -8,  9, 10 } };
5867 
5868       auto rs = blaze::rows( mat, { 2UL, 0UL, 3UL, 1UL } );
5869       rs *= blaze::rows( mat_, { 1UL, 2UL, 2UL, 1UL } );
5870 
5871       checkRows    ( rs ,  4UL );
5872       checkColumns ( rs ,  4UL );
5873       checkNonZeros( rs ,  8UL );
5874       checkRows    ( mat,  5UL );
5875       checkColumns ( mat,  4UL );
5876       checkNonZeros( mat, 12UL );
5877 
5878       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
5879           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
5880           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
5881           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
5882          std::ostringstream oss;
5883          oss << " Test: " << test_ << "\n"
5884              << " Error: Multiplication assignment failed\n"
5885              << " Details:\n"
5886              << "   Result:\n" << rs << "\n"
5887              << "   Expected result:\n(   6  -2   9  0 )\n"
5888                                      "(   0   0  -3  0 )\n"
5889                                      "( -18  -6 -27  0 )\n"
5890                                      "(  -2   0  -3  0 )\n";
5891          throw std::runtime_error( oss.str() );
5892       }
5893 
5894       if( mat(0,0) !=   0 || mat(0,1) !=  0 || mat(0,2) !=   0 || mat(0,3) !=  0 ||
5895           mat(1,0) !=  -2 || mat(1,1) !=  0 || mat(1,2) !=  -3 || mat(1,3) !=  0 ||
5896           mat(2,0) !=   6 || mat(2,1) != -2 || mat(2,2) !=   9 || mat(2,3) !=  0 ||
5897           mat(3,0) != -18 || mat(3,1) != -6 || mat(3,2) != -27 || mat(3,3) !=  0 ||
5898           mat(4,0) !=   7 || mat(4,1) != -8 || mat(4,2) !=   9 || mat(4,3) != 10 ) {
5899          std::ostringstream oss;
5900          oss << " Test: " << test_ << "\n"
5901              << " Error: Multiplication assignment failed\n"
5902              << " Details:\n"
5903              << "   Result:\n" << mat << "\n"
5904              << "   Expected result:\n(   0   0   0   0 )\n"
5905                                      "(  -2   0  -3   0 )\n"
5906                                      "(   6  -2   9   0 )\n"
5907                                      "( -18  -6 -27   0 )\n"
5908                                      "(   7  -8   9  10 )\n";
5909          throw std::runtime_error( oss.str() );
5910       }
5911    }
5912 
5913    {
5914       test_ = "Row-major Rows multiplication assignment (aliasing)";
5915 
5916       initialize();
5917 
5918       auto rs = blaze::rows( mat_, { 2UL, 0UL, 3UL, 1UL } );
5919       rs *= blaze::rows( mat_, { 1UL, 2UL, 2UL, 1UL } );
5920 
5921       checkRows    ( rs  ,  4UL );
5922       checkColumns ( rs  ,  4UL );
5923       checkNonZeros( rs  ,  8UL );
5924       checkRows    ( mat_,  5UL );
5925       checkColumns ( mat_,  4UL );
5926       checkNonZeros( mat_, 12UL );
5927 
5928       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
5929           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
5930           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
5931           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
5932          std::ostringstream oss;
5933          oss << " Test: " << test_ << "\n"
5934              << " Error: Multiplication assignment failed\n"
5935              << " Details:\n"
5936              << "   Result:\n" << rs << "\n"
5937              << "   Expected result:\n(   6  -2   9  0 )\n"
5938                                      "(   0   0  -3  0 )\n"
5939                                      "( -18  -6 -27  0 )\n"
5940                                      "(  -2   0  -3  0 )\n";
5941          throw std::runtime_error( oss.str() );
5942       }
5943 
5944       if( mat_(0,0) !=   0 || mat_(0,1) !=  0 || mat_(0,2) !=   0 || mat_(0,3) !=  0 ||
5945           mat_(1,0) !=  -2 || mat_(1,1) !=  0 || mat_(1,2) !=  -3 || mat_(1,3) !=  0 ||
5946           mat_(2,0) !=   6 || mat_(2,1) != -2 || mat_(2,2) !=   9 || mat_(2,3) !=  0 ||
5947           mat_(3,0) != -18 || mat_(3,1) != -6 || mat_(3,2) != -27 || mat_(3,3) !=  0 ||
5948           mat_(4,0) !=   7 || mat_(4,1) != -8 || mat_(4,2) !=   9 || mat_(4,3) != 10 ) {
5949          std::ostringstream oss;
5950          oss << " Test: " << test_ << "\n"
5951              << " Error: Multiplication assignment failed\n"
5952              << " Details:\n"
5953              << "   Result:\n" << mat_ << "\n"
5954              << "   Expected result:\n(   0   0   0   0 )\n"
5955                                      "(  -2   0  -3   0 )\n"
5956                                      "(   6  -2   9   0 )\n"
5957                                      "( -18  -6 -27   0 )\n"
5958                                      "(   7  -8   9  10 )\n";
5959          throw std::runtime_error( oss.str() );
5960       }
5961    }
5962 
5963 
5964    //=====================================================================================
5965    // Row-major dense matrix multiplication assignment
5966    //=====================================================================================
5967 
5968    {
5969       test_ = "Row-major/row-major dense matrix multiplication assignment (mixed type)";
5970 
5971       initialize();
5972 
5973       auto rs = blaze::rows( mat_, { 2UL, 0UL, 3UL, 1UL } );
5974 
5975       const blaze::DynamicMatrix<short,rowMajor> mat{ {  0,  1,  0,  0 },
5976                                                       { -2,  0, -3,  0 },
5977                                                       { -2,  0, -3,  0 },
5978                                                       {  0,  1,  0,  0 } };
5979 
5980       rs *= mat;
5981 
5982       checkRows    ( rs  ,  4UL );
5983       checkColumns ( rs  ,  4UL );
5984       checkNonZeros( rs  ,  8UL );
5985       checkRows    ( mat_,  5UL );
5986       checkColumns ( mat_,  4UL );
5987       checkNonZeros( mat_, 12UL );
5988 
5989       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
5990           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
5991           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
5992           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
5993          std::ostringstream oss;
5994          oss << " Test: " << test_ << "\n"
5995              << " Error: Multiplication assignment failed\n"
5996              << " Details:\n"
5997              << "   Result:\n" << rs << "\n"
5998              << "   Expected result:\n(   6  -2   9  0 )\n"
5999                                      "(   0   0  -3  0 )\n"
6000                                      "( -18  -6 -27  0 )\n"
6001                                      "(  -2   0  -3  0 )\n";
6002          throw std::runtime_error( oss.str() );
6003       }
6004 
6005       if( mat_(0,0) !=   0 || mat_(0,1) !=  0 || mat_(0,2) !=   0 || mat_(0,3) !=  0 ||
6006           mat_(1,0) !=  -2 || mat_(1,1) !=  0 || mat_(1,2) !=  -3 || mat_(1,3) !=  0 ||
6007           mat_(2,0) !=   6 || mat_(2,1) != -2 || mat_(2,2) !=   9 || mat_(2,3) !=  0 ||
6008           mat_(3,0) != -18 || mat_(3,1) != -6 || mat_(3,2) != -27 || mat_(3,3) !=  0 ||
6009           mat_(4,0) !=   7 || mat_(4,1) != -8 || mat_(4,2) !=   9 || mat_(4,3) != 10 ) {
6010          std::ostringstream oss;
6011          oss << " Test: " << test_ << "\n"
6012              << " Error: Multiplication assignment failed\n"
6013              << " Details:\n"
6014              << "   Result:\n" << mat_ << "\n"
6015              << "   Expected result:\n(   0   0   0   0 )\n"
6016                                      "(  -2   0  -3   0 )\n"
6017                                      "(   6  -2   9   0 )\n"
6018                                      "( -18  -6 -27   0 )\n"
6019                                      "(   7  -8   9  10 )\n";
6020          throw std::runtime_error( oss.str() );
6021       }
6022    }
6023 
6024    {
6025       test_ = "Row-major/row-major dense matrix multiplication assignment (aligned/padded)";
6026 
6027       initialize();
6028 
6029       auto rs = blaze::rows( mat_, { 2UL, 0UL, 3UL, 1UL } );
6030 
6031       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,rowMajor>;
6032       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 64UL ) );
6033       AlignedPadded mat( memory.get(), 4UL, 4UL, 16UL );
6034       mat = { {  0,  1,  0,  0 },
6035               { -2,  0, -3,  0 },
6036               { -2,  0, -3,  0 },
6037               {  0,  1,  0,  0 } };
6038 
6039       rs *= mat;
6040 
6041       checkRows    ( rs  ,  4UL );
6042       checkColumns ( rs  ,  4UL );
6043       checkNonZeros( rs  ,  8UL );
6044       checkRows    ( mat_,  5UL );
6045       checkColumns ( mat_,  4UL );
6046       checkNonZeros( mat_, 12UL );
6047 
6048       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
6049           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
6050           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
6051           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
6052          std::ostringstream oss;
6053          oss << " Test: " << test_ << "\n"
6054              << " Error: Multiplication assignment failed\n"
6055              << " Details:\n"
6056              << "   Result:\n" << rs << "\n"
6057              << "   Expected result:\n(   6  -2   9  0 )\n"
6058                                      "(   0   0  -3  0 )\n"
6059                                      "( -18  -6 -27  0 )\n"
6060                                      "(  -2   0  -3  0 )\n";
6061          throw std::runtime_error( oss.str() );
6062       }
6063 
6064       if( mat_(0,0) !=   0 || mat_(0,1) !=  0 || mat_(0,2) !=   0 || mat_(0,3) !=  0 ||
6065           mat_(1,0) !=  -2 || mat_(1,1) !=  0 || mat_(1,2) !=  -3 || mat_(1,3) !=  0 ||
6066           mat_(2,0) !=   6 || mat_(2,1) != -2 || mat_(2,2) !=   9 || mat_(2,3) !=  0 ||
6067           mat_(3,0) != -18 || mat_(3,1) != -6 || mat_(3,2) != -27 || mat_(3,3) !=  0 ||
6068           mat_(4,0) !=   7 || mat_(4,1) != -8 || mat_(4,2) !=   9 || mat_(4,3) != 10 ) {
6069          std::ostringstream oss;
6070          oss << " Test: " << test_ << "\n"
6071              << " Error: Multiplication assignment failed\n"
6072              << " Details:\n"
6073              << "   Result:\n" << mat_ << "\n"
6074              << "   Expected result:\n(   0   0   0   0 )\n"
6075                                      "(  -2   0  -3   0 )\n"
6076                                      "(   6  -2   9   0 )\n"
6077                                      "( -18  -6 -27   0 )\n"
6078                                      "(   7  -8   9  10 )\n";
6079          throw std::runtime_error( oss.str() );
6080       }
6081    }
6082 
6083    {
6084       test_ = "Row-major/row-major dense matrix multiplication assignment (unaligned/unpadded)";
6085 
6086       initialize();
6087 
6088       auto rs = blaze::rows( mat_, { 2UL, 0UL, 3UL, 1UL } );
6089 
6090       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,rowMajor>;
6091       std::unique_ptr<int[]> memory( new int[17UL] );
6092       UnalignedUnpadded mat( memory.get()+1UL, 4UL, 4UL );
6093       mat = { {  0,  1,  0,  0 },
6094               { -2,  0, -3,  0 },
6095               { -2,  0, -3,  0 },
6096               {  0,  1,  0,  0 } };
6097 
6098       rs *= mat;
6099 
6100       checkRows    ( rs  ,  4UL );
6101       checkColumns ( rs  ,  4UL );
6102       checkNonZeros( rs  ,  8UL );
6103       checkRows    ( mat_,  5UL );
6104       checkColumns ( mat_,  4UL );
6105       checkNonZeros( mat_, 12UL );
6106 
6107       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
6108           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
6109           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
6110           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
6111          std::ostringstream oss;
6112          oss << " Test: " << test_ << "\n"
6113              << " Error: Multiplication assignment failed\n"
6114              << " Details:\n"
6115              << "   Result:\n" << rs << "\n"
6116              << "   Expected result:\n(   6  -2   9  0 )\n"
6117                                      "(   0   0  -3  0 )\n"
6118                                      "( -18  -6 -27  0 )\n"
6119                                      "(  -2   0  -3  0 )\n";
6120          throw std::runtime_error( oss.str() );
6121       }
6122 
6123       if( mat_(0,0) !=   0 || mat_(0,1) !=  0 || mat_(0,2) !=   0 || mat_(0,3) !=  0 ||
6124           mat_(1,0) !=  -2 || mat_(1,1) !=  0 || mat_(1,2) !=  -3 || mat_(1,3) !=  0 ||
6125           mat_(2,0) !=   6 || mat_(2,1) != -2 || mat_(2,2) !=   9 || mat_(2,3) !=  0 ||
6126           mat_(3,0) != -18 || mat_(3,1) != -6 || mat_(3,2) != -27 || mat_(3,3) !=  0 ||
6127           mat_(4,0) !=   7 || mat_(4,1) != -8 || mat_(4,2) !=   9 || mat_(4,3) != 10 ) {
6128          std::ostringstream oss;
6129          oss << " Test: " << test_ << "\n"
6130              << " Error: Multiplication assignment failed\n"
6131              << " Details:\n"
6132              << "   Result:\n" << mat_ << "\n"
6133              << "   Expected result:\n(   0   0   0   0 )\n"
6134                                      "(  -2   0  -3   0 )\n"
6135                                      "(   6  -2   9   0 )\n"
6136                                      "( -18  -6 -27   0 )\n"
6137                                      "(   7  -8   9  10 )\n";
6138          throw std::runtime_error( oss.str() );
6139       }
6140    }
6141 
6142    {
6143       test_ = "Row-major/column-major dense matrix multiplication assignment (mixed type)";
6144 
6145       initialize();
6146 
6147       auto rs = blaze::rows( mat_, { 2UL, 0UL, 3UL, 1UL } );
6148 
6149       const blaze::DynamicMatrix<short,columnMajor> mat{ {  0,  1,  0,  0 },
6150                                                          { -2,  0, -3,  0 },
6151                                                          { -2,  0, -3,  0 },
6152                                                          {  0,  1,  0,  0 } };
6153 
6154       rs *= mat;
6155 
6156       checkRows    ( rs  ,  4UL );
6157       checkColumns ( rs  ,  4UL );
6158       checkNonZeros( rs  ,  8UL );
6159       checkRows    ( mat_,  5UL );
6160       checkColumns ( mat_,  4UL );
6161       checkNonZeros( mat_, 12UL );
6162 
6163       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
6164           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
6165           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
6166           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
6167          std::ostringstream oss;
6168          oss << " Test: " << test_ << "\n"
6169              << " Error: Multiplication assignment failed\n"
6170              << " Details:\n"
6171              << "   Result:\n" << rs << "\n"
6172              << "   Expected result:\n(   6  -2   9  0 )\n"
6173                                      "(   0   0  -3  0 )\n"
6174                                      "( -18  -6 -27  0 )\n"
6175                                      "(  -2   0  -3  0 )\n";
6176          throw std::runtime_error( oss.str() );
6177       }
6178 
6179       if( mat_(0,0) !=   0 || mat_(0,1) !=  0 || mat_(0,2) !=   0 || mat_(0,3) !=  0 ||
6180           mat_(1,0) !=  -2 || mat_(1,1) !=  0 || mat_(1,2) !=  -3 || mat_(1,3) !=  0 ||
6181           mat_(2,0) !=   6 || mat_(2,1) != -2 || mat_(2,2) !=   9 || mat_(2,3) !=  0 ||
6182           mat_(3,0) != -18 || mat_(3,1) != -6 || mat_(3,2) != -27 || mat_(3,3) !=  0 ||
6183           mat_(4,0) !=   7 || mat_(4,1) != -8 || mat_(4,2) !=   9 || mat_(4,3) != 10 ) {
6184          std::ostringstream oss;
6185          oss << " Test: " << test_ << "\n"
6186              << " Error: Multiplication assignment failed\n"
6187              << " Details:\n"
6188              << "   Result:\n" << mat_ << "\n"
6189              << "   Expected result:\n(   0   0   0   0 )\n"
6190                                      "(  -2   0  -3   0 )\n"
6191                                      "(   6  -2   9   0 )\n"
6192                                      "( -18  -6 -27   0 )\n"
6193                                      "(   7  -8   9  10 )\n";
6194          throw std::runtime_error( oss.str() );
6195       }
6196    }
6197 
6198    {
6199       test_ = "Row-major/column-major dense matrix multiplication assignment (aligned/padded)";
6200 
6201       initialize();
6202 
6203       auto rs = blaze::rows( mat_, { 2UL, 0UL, 3UL, 1UL } );
6204 
6205       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,columnMajor>;
6206       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 64UL ) );
6207       AlignedPadded mat( memory.get(), 4UL, 4UL, 16UL );
6208       mat = { {  0,  1,  0,  0 },
6209               { -2,  0, -3,  0 },
6210               { -2,  0, -3,  0 },
6211               {  0,  1,  0,  0 } };
6212 
6213       rs *= mat;
6214 
6215       checkRows    ( rs  ,  4UL );
6216       checkColumns ( rs  ,  4UL );
6217       checkNonZeros( rs  ,  8UL );
6218       checkRows    ( mat_,  5UL );
6219       checkColumns ( mat_,  4UL );
6220       checkNonZeros( mat_, 12UL );
6221 
6222       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
6223           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
6224           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
6225           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
6226          std::ostringstream oss;
6227          oss << " Test: " << test_ << "\n"
6228              << " Error: Multiplication assignment failed\n"
6229              << " Details:\n"
6230              << "   Result:\n" << rs << "\n"
6231              << "   Expected result:\n(   6  -2   9  0 )\n"
6232                                      "(   0   0  -3  0 )\n"
6233                                      "( -18  -6 -27  0 )\n"
6234                                      "(  -2   0  -3  0 )\n";
6235          throw std::runtime_error( oss.str() );
6236       }
6237 
6238       if( mat_(0,0) !=   0 || mat_(0,1) !=  0 || mat_(0,2) !=   0 || mat_(0,3) !=  0 ||
6239           mat_(1,0) !=  -2 || mat_(1,1) !=  0 || mat_(1,2) !=  -3 || mat_(1,3) !=  0 ||
6240           mat_(2,0) !=   6 || mat_(2,1) != -2 || mat_(2,2) !=   9 || mat_(2,3) !=  0 ||
6241           mat_(3,0) != -18 || mat_(3,1) != -6 || mat_(3,2) != -27 || mat_(3,3) !=  0 ||
6242           mat_(4,0) !=   7 || mat_(4,1) != -8 || mat_(4,2) !=   9 || mat_(4,3) != 10 ) {
6243          std::ostringstream oss;
6244          oss << " Test: " << test_ << "\n"
6245              << " Error: Multiplication assignment failed\n"
6246              << " Details:\n"
6247              << "   Result:\n" << mat_ << "\n"
6248              << "   Expected result:\n(   0   0   0   0 )\n"
6249                                      "(  -2   0  -3   0 )\n"
6250                                      "(   6  -2   9   0 )\n"
6251                                      "( -18  -6 -27   0 )\n"
6252                                      "(   7  -8   9  10 )\n";
6253          throw std::runtime_error( oss.str() );
6254       }
6255    }
6256 
6257    {
6258       test_ = "Row-major/column-major dense matrix multiplication assignment (unaligned/unpadded)";
6259 
6260       initialize();
6261 
6262       auto rs = blaze::rows( mat_, { 2UL, 0UL, 3UL, 1UL } );
6263 
6264       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,columnMajor>;
6265       std::unique_ptr<int[]> memory( new int[17UL] );
6266       UnalignedUnpadded mat( memory.get()+1UL, 4UL, 4UL );
6267       mat = { {  0,  1,  0,  0 },
6268               { -2,  0, -3,  0 },
6269               { -2,  0, -3,  0 },
6270               {  0,  1,  0,  0 } };
6271 
6272       rs *= mat;
6273 
6274       checkRows    ( rs  ,  4UL );
6275       checkColumns ( rs  ,  4UL );
6276       checkNonZeros( rs  ,  8UL );
6277       checkRows    ( mat_,  5UL );
6278       checkColumns ( mat_,  4UL );
6279       checkNonZeros( mat_, 12UL );
6280 
6281       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
6282           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
6283           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
6284           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
6285          std::ostringstream oss;
6286          oss << " Test: " << test_ << "\n"
6287              << " Error: Multiplication assignment failed\n"
6288              << " Details:\n"
6289              << "   Result:\n" << rs << "\n"
6290              << "   Expected result:\n(   6  -2   9  0 )\n"
6291                                      "(   0   0  -3  0 )\n"
6292                                      "( -18  -6 -27  0 )\n"
6293                                      "(  -2   0  -3  0 )\n";
6294          throw std::runtime_error( oss.str() );
6295       }
6296 
6297       if( mat_(0,0) !=   0 || mat_(0,1) !=  0 || mat_(0,2) !=   0 || mat_(0,3) !=  0 ||
6298           mat_(1,0) !=  -2 || mat_(1,1) !=  0 || mat_(1,2) !=  -3 || mat_(1,3) !=  0 ||
6299           mat_(2,0) !=   6 || mat_(2,1) != -2 || mat_(2,2) !=   9 || mat_(2,3) !=  0 ||
6300           mat_(3,0) != -18 || mat_(3,1) != -6 || mat_(3,2) != -27 || mat_(3,3) !=  0 ||
6301           mat_(4,0) !=   7 || mat_(4,1) != -8 || mat_(4,2) !=   9 || mat_(4,3) != 10 ) {
6302          std::ostringstream oss;
6303          oss << " Test: " << test_ << "\n"
6304              << " Error: Multiplication assignment failed\n"
6305              << " Details:\n"
6306              << "   Result:\n" << mat_ << "\n"
6307              << "   Expected result:\n(   0   0   0   0 )\n"
6308                                      "(  -2   0  -3   0 )\n"
6309                                      "(   6  -2   9   0 )\n"
6310                                      "( -18  -6 -27   0 )\n"
6311                                      "(   7  -8   9  10 )\n";
6312          throw std::runtime_error( oss.str() );
6313       }
6314    }
6315 
6316 
6317    //=====================================================================================
6318    // Row-major sparse matrix multiplication assignment
6319    //=====================================================================================
6320 
6321    {
6322       test_ = "Row-major/row-major sparse matrix multiplication assignment";
6323 
6324       initialize();
6325 
6326       auto rs = blaze::rows( mat_, { 2UL, 0UL, 3UL, 1UL } );
6327 
6328       const blaze::CompressedMatrix<int,rowMajor> mat{ {  0,  1,  0,  0 },
6329                                                        { -2,  0, -3,  0 },
6330                                                        { -2,  0, -3,  0 },
6331                                                        {  0,  1,  0,  0 } };
6332 
6333       rs *= mat;
6334 
6335       checkRows    ( rs  ,  4UL );
6336       checkColumns ( rs  ,  4UL );
6337       checkNonZeros( rs  ,  8UL );
6338       checkRows    ( mat_,  5UL );
6339       checkColumns ( mat_,  4UL );
6340       checkNonZeros( mat_, 12UL );
6341 
6342       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
6343           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
6344           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
6345           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
6346          std::ostringstream oss;
6347          oss << " Test: " << test_ << "\n"
6348              << " Error: Multiplication assignment failed\n"
6349              << " Details:\n"
6350              << "   Result:\n" << rs << "\n"
6351              << "   Expected result:\n(   6  -2   9  0 )\n"
6352                                      "(   0   0  -3  0 )\n"
6353                                      "( -18  -6 -27  0 )\n"
6354                                      "(  -2   0  -3  0 )\n";
6355          throw std::runtime_error( oss.str() );
6356       }
6357 
6358       if( mat_(0,0) !=   0 || mat_(0,1) !=  0 || mat_(0,2) !=   0 || mat_(0,3) !=  0 ||
6359           mat_(1,0) !=  -2 || mat_(1,1) !=  0 || mat_(1,2) !=  -3 || mat_(1,3) !=  0 ||
6360           mat_(2,0) !=   6 || mat_(2,1) != -2 || mat_(2,2) !=   9 || mat_(2,3) !=  0 ||
6361           mat_(3,0) != -18 || mat_(3,1) != -6 || mat_(3,2) != -27 || mat_(3,3) !=  0 ||
6362           mat_(4,0) !=   7 || mat_(4,1) != -8 || mat_(4,2) !=   9 || mat_(4,3) != 10 ) {
6363          std::ostringstream oss;
6364          oss << " Test: " << test_ << "\n"
6365              << " Error: Multiplication assignment failed\n"
6366              << " Details:\n"
6367              << "   Result:\n" << mat_ << "\n"
6368              << "   Expected result:\n(   0   0   0   0 )\n"
6369                                      "(  -2   0  -3   0 )\n"
6370                                      "(   6  -2   9   0 )\n"
6371                                      "( -18  -6 -27   0 )\n"
6372                                      "(   7  -8   9  10 )\n";
6373          throw std::runtime_error( oss.str() );
6374       }
6375    }
6376 
6377    {
6378       test_ = "Row-major/column-major sparse matrix multiplication assignment";
6379 
6380       initialize();
6381 
6382       auto rs = blaze::rows( mat_, { 2UL, 0UL, 3UL, 1UL } );
6383 
6384       const blaze::CompressedMatrix<int,columnMajor> mat{ {  0,  1,  0,  0 },
6385                                                           { -2,  0, -3,  0 },
6386                                                           { -2,  0, -3,  0 },
6387                                                           {  0,  1,  0,  0 } };
6388 
6389       rs *= mat;
6390 
6391       checkRows    ( rs  ,  4UL );
6392       checkColumns ( rs  ,  4UL );
6393       checkNonZeros( rs  ,  8UL );
6394       checkRows    ( mat_,  5UL );
6395       checkColumns ( mat_,  4UL );
6396       checkNonZeros( mat_, 12UL );
6397 
6398       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
6399           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
6400           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
6401           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
6402          std::ostringstream oss;
6403          oss << " Test: " << test_ << "\n"
6404              << " Error: Multiplication assignment failed\n"
6405              << " Details:\n"
6406              << "   Result:\n" << rs << "\n"
6407              << "   Expected result:\n(   6  -2   9  0 )\n"
6408                                      "(   0   0  -3  0 )\n"
6409                                      "( -18  -6 -27  0 )\n"
6410                                      "(  -2   0  -3  0 )\n";
6411          throw std::runtime_error( oss.str() );
6412       }
6413 
6414       if( mat_(0,0) !=   0 || mat_(0,1) !=  0 || mat_(0,2) !=   0 || mat_(0,3) !=  0 ||
6415           mat_(1,0) !=  -2 || mat_(1,1) !=  0 || mat_(1,2) !=  -3 || mat_(1,3) !=  0 ||
6416           mat_(2,0) !=   6 || mat_(2,1) != -2 || mat_(2,2) !=   9 || mat_(2,3) !=  0 ||
6417           mat_(3,0) != -18 || mat_(3,1) != -6 || mat_(3,2) != -27 || mat_(3,3) !=  0 ||
6418           mat_(4,0) !=   7 || mat_(4,1) != -8 || mat_(4,2) !=   9 || mat_(4,3) != 10 ) {
6419          std::ostringstream oss;
6420          oss << " Test: " << test_ << "\n"
6421              << " Error: Multiplication assignment failed\n"
6422              << " Details:\n"
6423              << "   Result:\n" << mat_ << "\n"
6424              << "   Expected result:\n(   0   0   0   0 )\n"
6425                                      "(  -2   0  -3   0 )\n"
6426                                      "(   6  -2   9   0 )\n"
6427                                      "( -18  -6 -27   0 )\n"
6428                                      "(   7  -8   9  10 )\n";
6429          throw std::runtime_error( oss.str() );
6430       }
6431    }
6432 
6433 
6434    //=====================================================================================
6435    // Column-major Rows multiplication assignment
6436    //=====================================================================================
6437 
6438    {
6439       test_ = "Column-major Rows multiplication assignment (no aliasing)";
6440 
6441       initialize();
6442 
6443       OMT mat{ {  0,  0,  0,  0 },
6444                {  0,  1,  0,  0 },
6445                { -2,  0, -3,  0 },
6446                {  0,  4,  5, -6 },
6447                {  7, -8,  9, 10 } };
6448 
6449       auto rs = blaze::rows( mat, { 2UL, 0UL, 3UL, 1UL } );
6450       rs *= blaze::rows( tmat_, { 1UL, 2UL, 2UL, 1UL } );
6451 
6452       checkRows    ( rs ,  4UL );
6453       checkColumns ( rs ,  4UL );
6454       checkNonZeros( rs ,  8UL );
6455       checkRows    ( mat,  5UL );
6456       checkColumns ( mat,  4UL );
6457       checkNonZeros( mat, 12UL );
6458 
6459       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
6460           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
6461           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
6462           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
6463          std::ostringstream oss;
6464          oss << " Test: " << test_ << "\n"
6465              << " Error: Multiplication assignment failed\n"
6466              << " Details:\n"
6467              << "   Result:\n" << rs << "\n"
6468              << "   Expected result:\n(   6  -2   9  0 )\n"
6469                                      "(   0   0  -3  0 )\n"
6470                                      "( -18  -6 -27  0 )\n"
6471                                      "(  -2   0  -3  0 )\n";
6472          throw std::runtime_error( oss.str() );
6473       }
6474 
6475       if( mat(0,0) !=   0 || mat(0,1) !=  0 || mat(0,2) !=   0 || mat(0,3) !=  0 ||
6476           mat(1,0) !=  -2 || mat(1,1) !=  0 || mat(1,2) !=  -3 || mat(1,3) !=  0 ||
6477           mat(2,0) !=   6 || mat(2,1) != -2 || mat(2,2) !=   9 || mat(2,3) !=  0 ||
6478           mat(3,0) != -18 || mat(3,1) != -6 || mat(3,2) != -27 || mat(3,3) !=  0 ||
6479           mat(4,0) !=   7 || mat(4,1) != -8 || mat(4,2) !=   9 || mat(4,3) != 10 ) {
6480          std::ostringstream oss;
6481          oss << " Test: " << test_ << "\n"
6482              << " Error: Multiplication assignment failed\n"
6483              << " Details:\n"
6484              << "   Result:\n" << mat << "\n"
6485              << "   Expected result:\n(   0   0   0   0 )\n"
6486                                      "(  -2   0  -3   0 )\n"
6487                                      "(   6  -2   9   0 )\n"
6488                                      "( -18  -6 -27   0 )\n"
6489                                      "(   7  -8   9  10 )\n";
6490          throw std::runtime_error( oss.str() );
6491       }
6492    }
6493 
6494    {
6495       test_ = "Column-major Rows multiplication assignment (aliasing)";
6496 
6497       initialize();
6498 
6499       auto rs = blaze::rows( tmat_, { 2UL, 0UL, 3UL, 1UL } );
6500       rs *= blaze::rows( tmat_, { 1UL, 2UL, 2UL, 1UL } );
6501 
6502       checkRows    ( rs   ,  4UL );
6503       checkColumns ( rs   ,  4UL );
6504       checkNonZeros( rs   ,  8UL );
6505       checkRows    ( tmat_,  5UL );
6506       checkColumns ( tmat_,  4UL );
6507       checkNonZeros( tmat_, 12UL );
6508 
6509       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
6510           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
6511           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
6512           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
6513          std::ostringstream oss;
6514          oss << " Test: " << test_ << "\n"
6515              << " Error: Multiplication assignment failed\n"
6516              << " Details:\n"
6517              << "   Result:\n" << rs << "\n"
6518              << "   Expected result:\n(   6  -2   9  0 )\n"
6519                                      "(   0   0  -3  0 )\n"
6520                                      "( -18  -6 -27  0 )\n"
6521                                      "(  -2   0  -3  0 )\n";
6522          throw std::runtime_error( oss.str() );
6523       }
6524 
6525       if( tmat_(0,0) !=   0 || tmat_(0,1) !=  0 || tmat_(0,2) !=   0 || tmat_(0,3) !=  0 ||
6526           tmat_(1,0) !=  -2 || tmat_(1,1) !=  0 || tmat_(1,2) !=  -3 || tmat_(1,3) !=  0 ||
6527           tmat_(2,0) !=   6 || tmat_(2,1) != -2 || tmat_(2,2) !=   9 || tmat_(2,3) !=  0 ||
6528           tmat_(3,0) != -18 || tmat_(3,1) != -6 || tmat_(3,2) != -27 || tmat_(3,3) !=  0 ||
6529           tmat_(4,0) !=   7 || tmat_(4,1) != -8 || tmat_(4,2) !=   9 || tmat_(4,3) != 10 ) {
6530          std::ostringstream oss;
6531          oss << " Test: " << test_ << "\n"
6532              << " Error: Multiplication assignment failed\n"
6533              << " Details:\n"
6534              << "   Result:\n" << tmat_ << "\n"
6535              << "   Expected result:\n(   0   0   0   0 )\n"
6536                                      "(  -2   0  -3   0 )\n"
6537                                      "(   6  -2   9   0 )\n"
6538                                      "( -18  -6 -27   0 )\n"
6539                                      "(   7  -8   9  10 )\n";
6540          throw std::runtime_error( oss.str() );
6541       }
6542    }
6543 
6544 
6545    //=====================================================================================
6546    // Column-major dense matrix multiplication assignment
6547    //=====================================================================================
6548 
6549    {
6550       test_ = "Column-major/row-major dense matrix multiplication assignment (mixed type)";
6551 
6552       initialize();
6553 
6554       auto rs = blaze::rows( tmat_, { 2UL, 0UL, 3UL, 1UL } );
6555 
6556       const blaze::DynamicMatrix<short,rowMajor> mat{ {  0,  1,  0,  0 },
6557                                                       { -2,  0, -3,  0 },
6558                                                       { -2,  0, -3,  0 },
6559                                                       {  0,  1,  0,  0 } };
6560 
6561       rs *= mat;
6562 
6563       checkRows    ( rs   ,  4UL );
6564       checkColumns ( rs   ,  4UL );
6565       checkNonZeros( rs   ,  8UL );
6566       checkRows    ( tmat_,  5UL );
6567       checkColumns ( tmat_,  4UL );
6568       checkNonZeros( tmat_, 12UL );
6569 
6570       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
6571           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
6572           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
6573           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
6574          std::ostringstream oss;
6575          oss << " Test: " << test_ << "\n"
6576              << " Error: Multiplication assignment failed\n"
6577              << " Details:\n"
6578              << "   Result:\n" << rs << "\n"
6579              << "   Expected result:\n(   6  -2   9  0 )\n"
6580                                      "(   0   0  -3  0 )\n"
6581                                      "( -18  -6 -27  0 )\n"
6582                                      "(  -2   0  -3  0 )\n";
6583          throw std::runtime_error( oss.str() );
6584       }
6585 
6586       if( tmat_(0,0) !=   0 || tmat_(0,1) !=  0 || tmat_(0,2) !=   0 || tmat_(0,3) !=  0 ||
6587           tmat_(1,0) !=  -2 || tmat_(1,1) !=  0 || tmat_(1,2) !=  -3 || tmat_(1,3) !=  0 ||
6588           tmat_(2,0) !=   6 || tmat_(2,1) != -2 || tmat_(2,2) !=   9 || tmat_(2,3) !=  0 ||
6589           tmat_(3,0) != -18 || tmat_(3,1) != -6 || tmat_(3,2) != -27 || tmat_(3,3) !=  0 ||
6590           tmat_(4,0) !=   7 || tmat_(4,1) != -8 || tmat_(4,2) !=   9 || tmat_(4,3) != 10 ) {
6591          std::ostringstream oss;
6592          oss << " Test: " << test_ << "\n"
6593              << " Error: Multiplication assignment failed\n"
6594              << " Details:\n"
6595              << "   Result:\n" << tmat_ << "\n"
6596              << "   Expected result:\n(   0   0   0   0 )\n"
6597                                      "(  -2   0  -3   0 )\n"
6598                                      "(   6  -2   9   0 )\n"
6599                                      "( -18  -6 -27   0 )\n"
6600                                      "(   7  -8   9  10 )\n";
6601          throw std::runtime_error( oss.str() );
6602       }
6603    }
6604 
6605    {
6606       test_ = "Column-major/row-major dense matrix multiplication assignment (aligned/padded)";
6607 
6608       initialize();
6609 
6610       auto rs = blaze::rows( tmat_, { 2UL, 0UL, 3UL, 1UL } );
6611 
6612       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,rowMajor>;
6613       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 64UL ) );
6614       AlignedPadded mat( memory.get(), 4UL, 4UL, 16UL );
6615       mat = { {  0,  1,  0,  0 },
6616               { -2,  0, -3,  0 },
6617               { -2,  0, -3,  0 },
6618               {  0,  1,  0,  0 } };
6619 
6620       rs *= mat;
6621 
6622       checkRows    ( rs   ,  4UL );
6623       checkColumns ( rs   ,  4UL );
6624       checkNonZeros( rs   ,  8UL );
6625       checkRows    ( tmat_,  5UL );
6626       checkColumns ( tmat_,  4UL );
6627       checkNonZeros( tmat_, 12UL );
6628 
6629       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
6630           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
6631           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
6632           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
6633          std::ostringstream oss;
6634          oss << " Test: " << test_ << "\n"
6635              << " Error: Multiplication assignment failed\n"
6636              << " Details:\n"
6637              << "   Result:\n" << rs << "\n"
6638              << "   Expected result:\n(   6  -2   9  0 )\n"
6639                                      "(   0   0  -3  0 )\n"
6640                                      "( -18  -6 -27  0 )\n"
6641                                      "(  -2   0  -3  0 )\n";
6642          throw std::runtime_error( oss.str() );
6643       }
6644 
6645       if( tmat_(0,0) !=   0 || tmat_(0,1) !=  0 || tmat_(0,2) !=   0 || tmat_(0,3) !=  0 ||
6646           tmat_(1,0) !=  -2 || tmat_(1,1) !=  0 || tmat_(1,2) !=  -3 || tmat_(1,3) !=  0 ||
6647           tmat_(2,0) !=   6 || tmat_(2,1) != -2 || tmat_(2,2) !=   9 || tmat_(2,3) !=  0 ||
6648           tmat_(3,0) != -18 || tmat_(3,1) != -6 || tmat_(3,2) != -27 || tmat_(3,3) !=  0 ||
6649           tmat_(4,0) !=   7 || tmat_(4,1) != -8 || tmat_(4,2) !=   9 || tmat_(4,3) != 10 ) {
6650          std::ostringstream oss;
6651          oss << " Test: " << test_ << "\n"
6652              << " Error: Multiplication assignment failed\n"
6653              << " Details:\n"
6654              << "   Result:\n" << tmat_ << "\n"
6655              << "   Expected result:\n(   0   0   0   0 )\n"
6656                                      "(  -2   0  -3   0 )\n"
6657                                      "(   6  -2   9   0 )\n"
6658                                      "( -18  -6 -27   0 )\n"
6659                                      "(   7  -8   9  10 )\n";
6660          throw std::runtime_error( oss.str() );
6661       }
6662    }
6663 
6664    {
6665       test_ = "Column-major/row-major dense matrix multiplication assignment (unaligned/unpadded)";
6666 
6667       initialize();
6668 
6669       auto rs = blaze::rows( tmat_, { 2UL, 0UL, 3UL, 1UL } );
6670 
6671       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,rowMajor>;
6672       std::unique_ptr<int[]> memory( new int[17UL] );
6673       UnalignedUnpadded mat( memory.get()+1UL, 4UL, 4UL );
6674       mat = { {  0,  1,  0,  0 },
6675               { -2,  0, -3,  0 },
6676               { -2,  0, -3,  0 },
6677               {  0,  1,  0,  0 } };
6678 
6679       rs *= mat;
6680 
6681       checkRows    ( rs   ,  4UL );
6682       checkColumns ( rs   ,  4UL );
6683       checkNonZeros( rs   ,  8UL );
6684       checkRows    ( tmat_,  5UL );
6685       checkColumns ( tmat_,  4UL );
6686       checkNonZeros( tmat_, 12UL );
6687 
6688       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
6689           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
6690           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
6691           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
6692          std::ostringstream oss;
6693          oss << " Test: " << test_ << "\n"
6694              << " Error: Multiplication assignment failed\n"
6695              << " Details:\n"
6696              << "   Result:\n" << rs << "\n"
6697              << "   Expected result:\n(   6  -2   9  0 )\n"
6698                                      "(   0   0  -3  0 )\n"
6699                                      "( -18  -6 -27  0 )\n"
6700                                      "(  -2   0  -3  0 )\n";
6701          throw std::runtime_error( oss.str() );
6702       }
6703 
6704       if( tmat_(0,0) !=   0 || tmat_(0,1) !=  0 || tmat_(0,2) !=   0 || tmat_(0,3) !=  0 ||
6705           tmat_(1,0) !=  -2 || tmat_(1,1) !=  0 || tmat_(1,2) !=  -3 || tmat_(1,3) !=  0 ||
6706           tmat_(2,0) !=   6 || tmat_(2,1) != -2 || tmat_(2,2) !=   9 || tmat_(2,3) !=  0 ||
6707           tmat_(3,0) != -18 || tmat_(3,1) != -6 || tmat_(3,2) != -27 || tmat_(3,3) !=  0 ||
6708           tmat_(4,0) !=   7 || tmat_(4,1) != -8 || tmat_(4,2) !=   9 || tmat_(4,3) != 10 ) {
6709          std::ostringstream oss;
6710          oss << " Test: " << test_ << "\n"
6711              << " Error: Multiplication assignment failed\n"
6712              << " Details:\n"
6713              << "   Result:\n" << tmat_ << "\n"
6714              << "   Expected result:\n(   0   0   0   0 )\n"
6715                                      "(  -2   0  -3   0 )\n"
6716                                      "(   6  -2   9   0 )\n"
6717                                      "( -18  -6 -27   0 )\n"
6718                                      "(   7  -8   9  10 )\n";
6719          throw std::runtime_error( oss.str() );
6720       }
6721    }
6722 
6723    {
6724       test_ = "Column-major/column-major dense matrix multiplication assignment (mixed type)";
6725 
6726       initialize();
6727 
6728       auto rs = blaze::rows( tmat_, { 2UL, 0UL, 3UL, 1UL } );
6729 
6730       const blaze::DynamicMatrix<short,columnMajor> mat{ {  0,  1,  0,  0 },
6731                                                          { -2,  0, -3,  0 },
6732                                                          { -2,  0, -3,  0 },
6733                                                          {  0,  1,  0,  0 } };
6734 
6735       rs *= mat;
6736 
6737       checkRows    ( rs   ,  4UL );
6738       checkColumns ( rs   ,  4UL );
6739       checkNonZeros( rs   ,  8UL );
6740       checkRows    ( tmat_,  5UL );
6741       checkColumns ( tmat_,  4UL );
6742       checkNonZeros( tmat_, 12UL );
6743 
6744       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
6745           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
6746           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
6747           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
6748          std::ostringstream oss;
6749          oss << " Test: " << test_ << "\n"
6750              << " Error: Multiplication assignment failed\n"
6751              << " Details:\n"
6752              << "   Result:\n" << rs << "\n"
6753              << "   Expected result:\n(   6  -2   9  0 )\n"
6754                                      "(   0   0  -3  0 )\n"
6755                                      "( -18  -6 -27  0 )\n"
6756                                      "(  -2   0  -3  0 )\n";
6757          throw std::runtime_error( oss.str() );
6758       }
6759 
6760       if( tmat_(0,0) !=   0 || tmat_(0,1) !=  0 || tmat_(0,2) !=   0 || tmat_(0,3) !=  0 ||
6761           tmat_(1,0) !=  -2 || tmat_(1,1) !=  0 || tmat_(1,2) !=  -3 || tmat_(1,3) !=  0 ||
6762           tmat_(2,0) !=   6 || tmat_(2,1) != -2 || tmat_(2,2) !=   9 || tmat_(2,3) !=  0 ||
6763           tmat_(3,0) != -18 || tmat_(3,1) != -6 || tmat_(3,2) != -27 || tmat_(3,3) !=  0 ||
6764           tmat_(4,0) !=   7 || tmat_(4,1) != -8 || tmat_(4,2) !=   9 || tmat_(4,3) != 10 ) {
6765          std::ostringstream oss;
6766          oss << " Test: " << test_ << "\n"
6767              << " Error: Multiplication assignment failed\n"
6768              << " Details:\n"
6769              << "   Result:\n" << tmat_ << "\n"
6770              << "   Expected result:\n(   0   0   0   0 )\n"
6771                                      "(  -2   0  -3   0 )\n"
6772                                      "(   6  -2   9   0 )\n"
6773                                      "( -18  -6 -27   0 )\n"
6774                                      "(   7  -8   9  10 )\n";
6775          throw std::runtime_error( oss.str() );
6776       }
6777    }
6778 
6779    {
6780       test_ = "Column-major/column-major dense matrix multiplication assignment (aligned/padded)";
6781 
6782       initialize();
6783 
6784       auto rs = blaze::rows( tmat_, { 2UL, 0UL, 3UL, 1UL } );
6785 
6786       using AlignedPadded = blaze::CustomMatrix<int,aligned,padded,columnMajor>;
6787       std::unique_ptr<int[],blaze::Deallocate> memory( blaze::allocate<int>( 64UL ) );
6788       AlignedPadded mat( memory.get(), 4UL, 4UL, 16UL );
6789       mat = { {  0,  1,  0,  0 },
6790               { -2,  0, -3,  0 },
6791               { -2,  0, -3,  0 },
6792               {  0,  1,  0,  0 } };
6793 
6794       rs *= mat;
6795 
6796       checkRows    ( rs   ,  4UL );
6797       checkColumns ( rs   ,  4UL );
6798       checkNonZeros( rs   ,  8UL );
6799       checkRows    ( tmat_,  5UL );
6800       checkColumns ( tmat_,  4UL );
6801       checkNonZeros( tmat_, 12UL );
6802 
6803       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
6804           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
6805           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
6806           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
6807          std::ostringstream oss;
6808          oss << " Test: " << test_ << "\n"
6809              << " Error: Multiplication assignment failed\n"
6810              << " Details:\n"
6811              << "   Result:\n" << rs << "\n"
6812              << "   Expected result:\n(   6  -2   9  0 )\n"
6813                                      "(   0   0  -3  0 )\n"
6814                                      "( -18  -6 -27  0 )\n"
6815                                      "(  -2   0  -3  0 )\n";
6816          throw std::runtime_error( oss.str() );
6817       }
6818 
6819       if( tmat_(0,0) !=   0 || tmat_(0,1) !=  0 || tmat_(0,2) !=   0 || tmat_(0,3) !=  0 ||
6820           tmat_(1,0) !=  -2 || tmat_(1,1) !=  0 || tmat_(1,2) !=  -3 || tmat_(1,3) !=  0 ||
6821           tmat_(2,0) !=   6 || tmat_(2,1) != -2 || tmat_(2,2) !=   9 || tmat_(2,3) !=  0 ||
6822           tmat_(3,0) != -18 || tmat_(3,1) != -6 || tmat_(3,2) != -27 || tmat_(3,3) !=  0 ||
6823           tmat_(4,0) !=   7 || tmat_(4,1) != -8 || tmat_(4,2) !=   9 || tmat_(4,3) != 10 ) {
6824          std::ostringstream oss;
6825          oss << " Test: " << test_ << "\n"
6826              << " Error: Multiplication assignment failed\n"
6827              << " Details:\n"
6828              << "   Result:\n" << tmat_ << "\n"
6829              << "   Expected result:\n(   0   0   0   0 )\n"
6830                                      "(  -2   0  -3   0 )\n"
6831                                      "(   6  -2   9   0 )\n"
6832                                      "( -18  -6 -27   0 )\n"
6833                                      "(   7  -8   9  10 )\n";
6834          throw std::runtime_error( oss.str() );
6835       }
6836    }
6837 
6838    {
6839       test_ = "Column-major/column-major dense matrix multiplication assignment (unaligned/unpadded)";
6840 
6841       initialize();
6842 
6843       auto rs = blaze::rows( tmat_, { 2UL, 0UL, 3UL, 1UL } );
6844 
6845       using UnalignedUnpadded = blaze::CustomMatrix<int,unaligned,unpadded,columnMajor>;
6846       std::unique_ptr<int[]> memory( new int[17UL] );
6847       UnalignedUnpadded mat( memory.get()+1UL, 4UL, 4UL );
6848       mat = { {  0,  1,  0,  0 },
6849               { -2,  0, -3,  0 },
6850               { -2,  0, -3,  0 },
6851               {  0,  1,  0,  0 } };
6852 
6853       rs *= mat;
6854 
6855       checkRows    ( rs   ,  4UL );
6856       checkColumns ( rs   ,  4UL );
6857       checkNonZeros( rs   ,  8UL );
6858       checkRows    ( tmat_,  5UL );
6859       checkColumns ( tmat_,  4UL );
6860       checkNonZeros( tmat_, 12UL );
6861 
6862       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
6863           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
6864           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
6865           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
6866          std::ostringstream oss;
6867          oss << " Test: " << test_ << "\n"
6868              << " Error: Multiplication assignment failed\n"
6869              << " Details:\n"
6870              << "   Result:\n" << rs << "\n"
6871              << "   Expected result:\n(   6  -2   9  0 )\n"
6872                                      "(   0   0  -3  0 )\n"
6873                                      "( -18  -6 -27  0 )\n"
6874                                      "(  -2   0  -3  0 )\n";
6875          throw std::runtime_error( oss.str() );
6876       }
6877 
6878       if( tmat_(0,0) !=   0 || tmat_(0,1) !=  0 || tmat_(0,2) !=   0 || tmat_(0,3) !=  0 ||
6879           tmat_(1,0) !=  -2 || tmat_(1,1) !=  0 || tmat_(1,2) !=  -3 || tmat_(1,3) !=  0 ||
6880           tmat_(2,0) !=   6 || tmat_(2,1) != -2 || tmat_(2,2) !=   9 || tmat_(2,3) !=  0 ||
6881           tmat_(3,0) != -18 || tmat_(3,1) != -6 || tmat_(3,2) != -27 || tmat_(3,3) !=  0 ||
6882           tmat_(4,0) !=   7 || tmat_(4,1) != -8 || tmat_(4,2) !=   9 || tmat_(4,3) != 10 ) {
6883          std::ostringstream oss;
6884          oss << " Test: " << test_ << "\n"
6885              << " Error: Multiplication assignment failed\n"
6886              << " Details:\n"
6887              << "   Result:\n" << tmat_ << "\n"
6888              << "   Expected result:\n(   0   0   0   0 )\n"
6889                                      "(  -2   0  -3   0 )\n"
6890                                      "(   6  -2   9   0 )\n"
6891                                      "( -18  -6 -27   0 )\n"
6892                                      "(   7  -8   9  10 )\n";
6893          throw std::runtime_error( oss.str() );
6894       }
6895    }
6896 
6897 
6898    //=====================================================================================
6899    // Column-major sparse matrix multiplication assignment
6900    //=====================================================================================
6901 
6902    {
6903       test_ = "Column-major/row-major sparse matrix multiplication assignment";
6904 
6905       initialize();
6906 
6907       auto rs = blaze::rows( tmat_, { 2UL, 0UL, 3UL, 1UL } );
6908 
6909       const blaze::CompressedMatrix<int,rowMajor> mat{ {  0,  1,  0,  0 },
6910                                                        { -2,  0, -3,  0 },
6911                                                        { -2,  0, -3,  0 },
6912                                                        {  0,  1,  0,  0 } };
6913 
6914       rs *= mat;
6915 
6916       checkRows    ( rs   ,  4UL );
6917       checkColumns ( rs   ,  4UL );
6918       checkNonZeros( rs   ,  8UL );
6919       checkRows    ( tmat_,  5UL );
6920       checkColumns ( tmat_,  4UL );
6921       checkNonZeros( tmat_, 12UL );
6922 
6923       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
6924           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
6925           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
6926           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
6927          std::ostringstream oss;
6928          oss << " Test: " << test_ << "\n"
6929              << " Error: Multiplication assignment failed\n"
6930              << " Details:\n"
6931              << "   Result:\n" << rs << "\n"
6932              << "   Expected result:\n(   6  -2   9  0 )\n"
6933                                      "(   0   0  -3  0 )\n"
6934                                      "( -18  -6 -27  0 )\n"
6935                                      "(  -2   0  -3  0 )\n";
6936          throw std::runtime_error( oss.str() );
6937       }
6938 
6939       if( tmat_(0,0) !=   0 || tmat_(0,1) !=  0 || tmat_(0,2) !=   0 || tmat_(0,3) !=  0 ||
6940           tmat_(1,0) !=  -2 || tmat_(1,1) !=  0 || tmat_(1,2) !=  -3 || tmat_(1,3) !=  0 ||
6941           tmat_(2,0) !=   6 || tmat_(2,1) != -2 || tmat_(2,2) !=   9 || tmat_(2,3) !=  0 ||
6942           tmat_(3,0) != -18 || tmat_(3,1) != -6 || tmat_(3,2) != -27 || tmat_(3,3) !=  0 ||
6943           tmat_(4,0) !=   7 || tmat_(4,1) != -8 || tmat_(4,2) !=   9 || tmat_(4,3) != 10 ) {
6944          std::ostringstream oss;
6945          oss << " Test: " << test_ << "\n"
6946              << " Error: Multiplication assignment failed\n"
6947              << " Details:\n"
6948              << "   Result:\n" << tmat_ << "\n"
6949              << "   Expected result:\n(   0   0   0   0 )\n"
6950                                      "(  -2   0  -3   0 )\n"
6951                                      "(   6  -2   9   0 )\n"
6952                                      "( -18  -6 -27   0 )\n"
6953                                      "(   7  -8   9  10 )\n";
6954          throw std::runtime_error( oss.str() );
6955       }
6956    }
6957 
6958    {
6959       test_ = "Column-major/column-major sparse matrix multiplication assignment";
6960 
6961       initialize();
6962 
6963       auto rs = blaze::rows( tmat_, { 2UL, 0UL, 3UL, 1UL } );
6964 
6965       const blaze::CompressedMatrix<int,columnMajor> mat{ {  0,  1,  0,  0 },
6966                                                           { -2,  0, -3,  0 },
6967                                                           { -2,  0, -3,  0 },
6968                                                           {  0,  1,  0,  0 } };
6969 
6970       rs *= mat;
6971 
6972       checkRows    ( rs   ,  4UL );
6973       checkColumns ( rs   ,  4UL );
6974       checkNonZeros( rs   ,  8UL );
6975       checkRows    ( tmat_,  5UL );
6976       checkColumns ( tmat_,  4UL );
6977       checkNonZeros( tmat_, 12UL );
6978 
6979       if( rs(0,0) !=   6 || rs(0,1) != -2 || rs(0,2) !=   9 || rs(0,3) != 0 ||
6980           rs(1,0) !=   0 || rs(1,1) !=  0 || rs(1,2) !=   0 || rs(1,3) != 0 ||
6981           rs(2,0) != -18 || rs(2,1) != -6 || rs(2,2) != -27 || rs(2,3) != 0 ||
6982           rs(3,0) !=  -2 || rs(3,1) !=  0 || rs(3,2) !=  -3 || rs(3,3) != 0 ) {
6983          std::ostringstream oss;
6984          oss << " Test: " << test_ << "\n"
6985              << " Error: Multiplication assignment failed\n"
6986              << " Details:\n"
6987              << "   Result:\n" << rs << "\n"
6988              << "   Expected result:\n(   6  -2   9  0 )\n"
6989                                      "(   0   0  -3  0 )\n"
6990                                      "( -18  -6 -27  0 )\n"
6991                                      "(  -2   0  -3  0 )\n";
6992          throw std::runtime_error( oss.str() );
6993       }
6994 
6995       if( tmat_(0,0) !=   0 || tmat_(0,1) !=  0 || tmat_(0,2) !=   0 || tmat_(0,3) !=  0 ||
6996           tmat_(1,0) !=  -2 || tmat_(1,1) !=  0 || tmat_(1,2) !=  -3 || tmat_(1,3) !=  0 ||
6997           tmat_(2,0) !=   6 || tmat_(2,1) != -2 || tmat_(2,2) !=   9 || tmat_(2,3) !=  0 ||
6998           tmat_(3,0) != -18 || tmat_(3,1) != -6 || tmat_(3,2) != -27 || tmat_(3,3) !=  0 ||
6999           tmat_(4,0) !=   7 || tmat_(4,1) != -8 || tmat_(4,2) !=   9 || tmat_(4,3) != 10 ) {
7000          std::ostringstream oss;
7001          oss << " Test: " << test_ << "\n"
7002              << " Error: Multiplication assignment failed\n"
7003              << " Details:\n"
7004              << "   Result:\n" << tmat_ << "\n"
7005              << "   Expected result:\n(   0   0   0   0 )\n"
7006                                      "(  -2   0  -3   0 )\n"
7007                                      "(   6  -2   9   0 )\n"
7008                                      "( -18  -6 -27   0 )\n"
7009                                      "(   7  -8   9  10 )\n";
7010          throw std::runtime_error( oss.str() );
7011       }
7012    }
7013 }
7014 //*************************************************************************************************
7015 
7016 
7017 
7018 
7019 //=================================================================================================
7020 //
7021 //  UTILITY FUNCTIONS
7022 //
7023 //=================================================================================================
7024 
7025 //*************************************************************************************************
7026 /*!\brief Initialization of all member matrices.
7027 //
7028 // \return void
7029 // \exception std::runtime_error Error detected.
7030 //
7031 // This function initializes all member matrices to specific predetermined values.
7032 */
initialize()7033 void DenseGeneralTest::initialize()
7034 {
7035    // Initializing the row-major dynamic matrix
7036    mat_.reset();
7037    mat_(1,1) =  1;
7038    mat_(2,0) = -2;
7039    mat_(2,2) = -3;
7040    mat_(3,1) =  4;
7041    mat_(3,2) =  5;
7042    mat_(3,3) = -6;
7043    mat_(4,0) =  7;
7044    mat_(4,1) = -8;
7045    mat_(4,2) =  9;
7046    mat_(4,3) = 10;
7047 
7048    // Initializing the column-major dynamic matrix
7049    tmat_.reset();
7050    tmat_(1,1) =  1;
7051    tmat_(2,0) = -2;
7052    tmat_(2,2) = -3;
7053    tmat_(3,1) =  4;
7054    tmat_(3,2) =  5;
7055    tmat_(3,3) = -6;
7056    tmat_(4,0) =  7;
7057    tmat_(4,1) = -8;
7058    tmat_(4,2) =  9;
7059    tmat_(4,3) = 10;
7060 }
7061 //*************************************************************************************************
7062 
7063 } // namespace rows
7064 
7065 } // namespace views
7066 
7067 } // namespace mathtest
7068 
7069 } // namespace blazetest
7070 
7071 
7072 
7073 
7074 //=================================================================================================
7075 //
7076 //  MAIN FUNCTION
7077 //
7078 //=================================================================================================
7079 
7080 //*************************************************************************************************
main()7081 int main()
7082 {
7083    std::cout << "   Running Rows dense general test (part 1)..." << std::endl;
7084 
7085    try
7086    {
7087       RUN_ROWS_DENSEGENERAL_TEST;
7088    }
7089    catch( std::exception& ex ) {
7090       std::cerr << "\n\n ERROR DETECTED during Rows dense general test (part 1):\n"
7091                 << ex.what() << "\n";
7092       return EXIT_FAILURE;
7093    }
7094 
7095    return EXIT_SUCCESS;
7096 }
7097 //*************************************************************************************************
7098