1 //=================================================================================================
2 /*!
3 //  \file src/mathtest/views/submatrix/SparseTest1.cpp
4 //  \brief Source file for the Submatrix sparse 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 <blaze/math/DynamicMatrix.h>
43 #include <blazetest/mathtest/views/submatrix/SparseTest.h>
44 
45 #ifdef BLAZE_USE_HPX_THREADS
46 #  include <hpx/hpx_main.hpp>
47 #endif
48 
49 
50 namespace blazetest {
51 
52 namespace mathtest {
53 
54 namespace views {
55 
56 namespace submatrix {
57 
58 //=================================================================================================
59 //
60 //  CONSTRUCTORS
61 //
62 //=================================================================================================
63 
64 //*************************************************************************************************
65 /*!\brief Constructor for the Submatrix sparse test.
66 //
67 // \exception std::runtime_error Operation error detected.
68 */
SparseTest()69 SparseTest::SparseTest()
70    : mat_ ( 5UL, 4UL )
71    , tmat_( 4UL, 5UL )
72 {
73    testConstructors();
74    testAssignment();
75    testAddAssign();
76    testSubAssign();
77    testSchurAssign();
78    testMultAssign();
79 }
80 //*************************************************************************************************
81 
82 
83 
84 
85 //=================================================================================================
86 //
87 //  TEST FUNCTIONS
88 //
89 //=================================================================================================
90 
91 //*************************************************************************************************
92 /*!\brief Test of the Submatrix constructors.
93 //
94 // \return void
95 // \exception std::runtime_error Error detected.
96 //
97 // This function performs a test of all constructors of the Submatrix specialization. In case
98 // an error is detected, a \a std::runtime_error exception is thrown.
99 */
testConstructors()100 void SparseTest::testConstructors()
101 {
102    //=====================================================================================
103    // Row-major submatrix tests
104    //=====================================================================================
105 
106    {
107       test_ = "Row-major Submatrix constructor";
108 
109       initialize();
110 
111       for( size_t row=0UL; row<mat_.rows(); ++row ) {
112          for( size_t column=0UL; column<mat_.columns(); ++column ) {
113             for( size_t m=1UL; (row+m)<mat_.rows(); ++m ) {
114                for( size_t n=1UL; (column+n)<mat_.columns(); ++n )
115                {
116                   SMT sm = blaze::submatrix( mat_, row, column, m, n );
117 
118                   for( size_t i=0UL; i<m; ++i ) {
119                      for( size_t j=0UL; j<n; ++j )
120                      {
121                         if( sm(i,j) != mat_(row+i,column+j) ) {
122                            std::ostringstream oss;
123                            oss << " Test: " << test_ << "\n"
124                                << " Error: Setup of sparse submatrix failed\n"
125                                << " Details:\n"
126                                << "   Index of first row    = " << row << "\n"
127                                << "   Index of first column = " << column << "\n"
128                                << "   Number of rows        = " << m << "\n"
129                                << "   Number of columns     = " << n << "\n"
130                                << "   Submatrix:\n" << sm << "\n"
131                                << "   Matrix:\n" << mat_ << "\n";
132                            throw std::runtime_error( oss.str() );
133                         }
134                      }
135                   }
136                }
137             }
138          }
139       }
140    }
141 
142 
143    //=====================================================================================
144    // Column-major submatrix tests
145    //=====================================================================================
146 
147    {
148       test_ = "Column-major Submatrix constructor";
149 
150       initialize();
151 
152       for( size_t column=0UL; column<tmat_.columns(); ++column ) {
153          for( size_t row=0UL; row<tmat_.rows(); ++row ) {
154             for( size_t n=1UL; (column+n)<tmat_.columns(); ++n ) {
155                for( size_t m=1UL; (row+m)<tmat_.rows(); ++m )
156                {
157                   OSMT sm = blaze::submatrix( tmat_, row, column, m, n );
158 
159                   for( size_t j=0UL; j<n; ++j ) {
160                      for( size_t i=0UL; i<m; ++i )
161                      {
162                         if( sm(i,j) != tmat_(row+i,column+j) ) {
163                            std::ostringstream oss;
164                            oss << " Test: " << test_ << "\n"
165                                << " Error: Setup of sparse submatrix failed\n"
166                                << " Details:\n"
167                                << "   Index of first row    = " << row << "\n"
168                                << "   Index of first column = " << column << "\n"
169                                << "   Number of rows        = " << m << "\n"
170                                << "   Number of columns     = " << n << "\n"
171                                << "   Submatrix:\n" << sm << "\n"
172                                << "   Matrix:\n" << tmat_ << "\n";
173                            throw std::runtime_error( oss.str() );
174                         }
175                      }
176                   }
177                }
178             }
179          }
180       }
181    }
182 }
183 //*************************************************************************************************
184 
185 
186 //*************************************************************************************************
187 /*!\brief Test of the Submatrix assignment operators.
188 //
189 // \return void
190 // \exception std::runtime_error Error detected.
191 //
192 // This function performs a test of all assignment operators of the Submatrix specialization.
193 // In case an error is detected, a \a std::runtime_error exception is thrown.
194 */
testAssignment()195 void SparseTest::testAssignment()
196 {
197    //=====================================================================================
198    // Row-major list assignment
199    //=====================================================================================
200 
201    {
202       test_ = "Row-major initializer list assignment (complete list)";
203 
204       initialize();
205 
206       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
207       sm = { { 1, 0, 3 }, { 0, 5, 0 } };
208 
209       checkRows    ( sm  ,  2UL );
210       checkColumns ( sm  ,  3UL );
211       checkNonZeros( sm  ,  3UL );
212       checkRows    ( mat_,  5UL );
213       checkColumns ( mat_,  4UL );
214       checkNonZeros( mat_, 10UL );
215 
216       if( sm(0,0) != 1 || sm(0,1) != 0 || sm(0,2) != 3 ||
217           sm(1,0) != 0 || sm(1,1) != 5 || sm(1,2) != 0 ) {
218          std::ostringstream oss;
219          oss << " Test: " << test_ << "\n"
220              << " Error: Assignment failed\n"
221              << " Details:\n"
222              << "   Result:\n" << sm << "\n"
223              << "   Expected result:\n( 1 0 3 )\n( 0 5 0 )\n";
224          throw std::runtime_error( oss.str() );
225       }
226 
227       if( mat_(0,0) != 0 || mat_(0,1) !=  0 || mat_(0,2) != 0 || mat_(0,3) !=  0 ||
228           mat_(1,0) != 1 || mat_(1,1) !=  0 || mat_(1,2) != 3 || mat_(1,3) !=  0 ||
229           mat_(2,0) != 0 || mat_(2,1) !=  5 || mat_(2,2) != 0 || mat_(2,3) !=  0 ||
230           mat_(3,0) != 0 || mat_(3,1) !=  4 || mat_(3,2) != 5 || mat_(3,3) != -6 ||
231           mat_(4,0) != 7 || mat_(4,1) != -8 || mat_(4,2) != 9 || mat_(4,3) != 10 ) {
232          std::ostringstream oss;
233          oss << " Test: " << test_ << "\n"
234              << " Error: Assignment failed\n"
235              << " Details:\n"
236              << "   Result:\n" << mat_ << "\n"
237              << "   Expected result:\n( 0  0  0  0 )\n"
238                                      "( 1  0  3  0 )\n"
239                                      "( 0  5  0  0 )\n"
240                                      "( 0  4  5 -6 )\n"
241                                      "( 7 -8  9 10 )\n";
242          throw std::runtime_error( oss.str() );
243       }
244    }
245 
246    {
247       test_ = "Row-major initializer list assignment (incomplete list)";
248 
249       initialize();
250 
251       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
252       sm = { { 1 }, { 4, 0, 6 } };
253 
254       checkRows    ( sm  ,  2UL );
255       checkColumns ( sm  ,  3UL );
256       checkNonZeros( sm  ,  3UL );
257       checkRows    ( mat_,  5UL );
258       checkColumns ( mat_,  4UL );
259       checkNonZeros( mat_, 10UL );
260 
261       if( sm(0,0) != 1 || sm(0,1) != 0 || sm(0,2) != 0 ||
262           sm(1,0) != 4 || sm(1,1) != 0 || sm(1,2) != 6 ) {
263          std::ostringstream oss;
264          oss << " Test: " << test_ << "\n"
265              << " Error: Assignment failed\n"
266              << " Details:\n"
267              << "   Result:\n" << sm << "\n"
268              << "   Expected result:\n( 1 0 0 )\n( 4 0 6 )\n";
269          throw std::runtime_error( oss.str() );
270       }
271 
272       if( mat_(0,0) != 0 || mat_(0,1) !=  0 || mat_(0,2) != 0 || mat_(0,3) !=  0 ||
273           mat_(1,0) != 1 || mat_(1,1) !=  0 || mat_(1,2) != 0 || mat_(1,3) !=  0 ||
274           mat_(2,0) != 4 || mat_(2,1) !=  0 || mat_(2,2) != 6 || mat_(2,3) !=  0 ||
275           mat_(3,0) != 0 || mat_(3,1) !=  4 || mat_(3,2) != 5 || mat_(3,3) != -6 ||
276           mat_(4,0) != 7 || mat_(4,1) != -8 || mat_(4,2) != 9 || mat_(4,3) != 10 ) {
277          std::ostringstream oss;
278          oss << " Test: " << test_ << "\n"
279              << " Error: Assignment failed\n"
280              << " Details:\n"
281              << "   Result:\n" << mat_ << "\n"
282              << "   Expected result:\n( 0  0  0  0 )\n"
283                                      "( 1  0  0  0 )\n"
284                                      "( 4  0  6  0 )\n"
285                                      "( 0  4  5 -6 )\n"
286                                      "( 7 -8  9 10 )\n";
287          throw std::runtime_error( oss.str() );
288       }
289    }
290 
291 
292    //=====================================================================================
293    // Row-major copy assignment
294    //=====================================================================================
295 
296    {
297       test_ = "Row-major Submatrix copy assignment (no aliasing)";
298 
299       initialize();
300 
301       MT mat( 5UL, 4UL, 3UL );
302       mat(1,0) = 11;
303       mat(2,0) = 12;
304       mat(2,2) = 13;
305 
306       SMT sm = blaze::submatrix( mat, 1UL, 0UL, 2UL, 3UL );
307       sm = blaze::submatrix( mat_, 2UL, 1UL, 2UL, 3UL );
308 
309       checkRows    ( sm  ,  2UL );
310       checkColumns ( sm  ,  3UL );
311       checkNonZeros( sm  ,  4UL );
312       checkRows    ( mat_,  5UL );
313       checkColumns ( mat_,  4UL );
314       checkNonZeros( mat_, 10UL );
315       checkRows    ( mat ,  5UL );
316       checkColumns ( mat ,  4UL );
317       checkNonZeros( mat ,  4UL );
318 
319       if( sm(0,0) != 0 || sm(0,1) != -3 || sm(0,2) !=  0 ||
320           sm(1,0) != 4 || sm(1,1) !=  5 || sm(1,2) != -6 ) {
321          std::ostringstream oss;
322          oss << " Test: " << test_ << "\n"
323              << " Error: Assignment failed\n"
324              << " Details:\n"
325              << "   Result:\n" << sm << "\n"
326              << "   Expected result:\n( 0 -3  0 )\n( 4  5 -6 )\n";
327          throw std::runtime_error( oss.str() );
328       }
329 
330       if( mat(0,0) != 0 || mat(0,1) !=  0 || mat(0,2) !=  0 || mat(0,3) != 0 ||
331           mat(1,0) != 0 || mat(1,1) != -3 || mat(1,2) !=  0 || mat(1,3) != 0 ||
332           mat(2,0) != 4 || mat(2,1) !=  5 || mat(2,2) != -6 || mat(2,3) != 0 ||
333           mat(3,0) != 0 || mat(3,1) !=  0 || mat(3,2) !=  0 || mat(3,3) != 0 ||
334           mat(4,0) != 0 || mat(4,1) !=  0 || mat(4,2) !=  0 || mat(4,3) != 0 ) {
335          std::ostringstream oss;
336          oss << " Test: " << test_ << "\n"
337              << " Error: Assignment failed\n"
338              << " Details:\n"
339              << "   Result:\n" << mat << "\n"
340              << "   Expected result:\n( 0  0  0  0 )\n"
341                                      "( 0 -3  0  0 )\n"
342                                      "( 4  5 -6  0 )\n"
343                                      "( 0  0  0  0 )\n"
344                                      "( 0  0  0  0 )\n";
345          throw std::runtime_error( oss.str() );
346       }
347    }
348 
349    {
350       test_ = "Row-major Submatrix copy assignment (aliasing)";
351 
352       initialize();
353 
354       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
355       sm = blaze::submatrix( mat_, 2UL, 1UL, 2UL, 3UL );
356 
357       /*
358       checkRows    ( sm  ,  2UL );
359       checkColumns ( sm  ,  3UL );
360       checkNonZeros( sm  ,  4UL );
361       checkRows    ( mat_,  5UL );
362       checkColumns ( mat_,  4UL );
363       checkNonZeros( mat_, 11UL );
364       */
365 
366       if( sm(0,0) != 0 || sm(0,1) != -3 || sm(0,2) !=  0 ||
367           sm(1,0) != 4 || sm(1,1) !=  5 || sm(1,2) != -6 ) {
368          std::ostringstream oss;
369          oss << " Test: " << test_ << "\n"
370              << " Error: Assignment failed\n"
371              << " Details:\n"
372              << "   Result:\n" << sm << "\n"
373              << "   Expected result:\n( 0 -3  0 )\n( 4  5 -6 )\n";
374          throw std::runtime_error( oss.str() );
375       }
376 
377       if( mat_(0,0) != 0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
378           mat_(1,0) != 0 || mat_(1,1) != -3 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
379           mat_(2,0) != 4 || mat_(2,1) !=  5 || mat_(2,2) != -6 || mat_(2,3) !=  0 ||
380           mat_(3,0) != 0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
381           mat_(4,0) != 7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
382          std::ostringstream oss;
383          oss << " Test: " << test_ << "\n"
384              << " Error: Assignment failed\n"
385              << " Details:\n"
386              << "   Result:\n" << mat_ << "\n"
387              << "   Expected result:\n( 0  0  0  0 )\n"
388                                      "( 0 -3  0  0 )\n"
389                                      "( 4  5 -6  0 )\n"
390                                      "( 0  4  5 -6 )\n"
391                                      "( 7 -8  9 10 )\n";
392          throw std::runtime_error( oss.str() );
393       }
394    }
395 
396 
397    //=====================================================================================
398    // Row-major dense matrix assignment
399    //=====================================================================================
400 
401    {
402       test_ = "Row-major/row-major dense matrix assignment";
403 
404       initialize();
405 
406       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
407 
408       blaze::DynamicMatrix<int,blaze::rowMajor> mat{ {  0, 11,  0 },
409                                                      { 12, 13, 14 } };
410 
411       sm = mat;
412 
413       checkRows    ( sm  ,  2UL );
414       checkColumns ( sm  ,  3UL );
415       checkNonZeros( sm  ,  4UL );
416       checkRows    ( mat_,  5UL );
417       checkColumns ( mat_,  4UL );
418       checkNonZeros( mat_, 11UL );
419 
420       if( sm(0,0) !=  0 || sm(0,1) != 11 || sm(0,2) !=  0 ||
421           sm(1,0) != 12 || sm(1,1) != 13 || sm(1,2) != 14 ) {
422          std::ostringstream oss;
423          oss << " Test: " << test_ << "\n"
424              << " Error: Assignment failed\n"
425              << " Details:\n"
426              << "   Result:\n" << sm << "\n"
427              << "   Expected result:\n(  0 11  0 )\n( 12 13 14 )\n";
428          throw std::runtime_error( oss.str() );
429       }
430 
431       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
432           mat_(1,0) !=  0 || mat_(1,1) != 11 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
433           mat_(2,0) != 12 || mat_(2,1) != 13 || mat_(2,2) != 14 || mat_(2,3) !=  0 ||
434           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
435           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
436          std::ostringstream oss;
437          oss << " Test: " << test_ << "\n"
438              << " Error: Assignment failed\n"
439              << " Details:\n"
440              << "   Result:\n" << mat_ << "\n"
441              << "   Expected result:\n(  0  0  0  0 )\n"
442                                      "(  0 11  0  0 )\n"
443                                      "( 12 13 14  0 )\n"
444                                      "(  0  4  5 -6 )\n"
445                                      "(  7 -8  9 10 )\n";
446          throw std::runtime_error( oss.str() );
447       }
448    }
449 
450    {
451       test_ = "Row-major/column-major dense matrix assignment";
452 
453       initialize();
454 
455       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
456 
457       blaze::DynamicMatrix<int,blaze::columnMajor> mat{ {  0, 11,  0 },
458                                                         { 12, 13, 14 } };
459 
460       sm = mat;
461 
462       checkRows    ( sm  ,  2UL );
463       checkColumns ( sm  ,  3UL );
464       checkNonZeros( sm  ,  4UL );
465       checkRows    ( mat_,  5UL );
466       checkColumns ( mat_,  4UL );
467       checkNonZeros( mat_, 11UL );
468 
469       if( sm(0,0) !=  0 || sm(0,1) != 11 || sm(0,2) !=  0 ||
470           sm(1,0) != 12 || sm(1,1) != 13 || sm(1,2) != 14 ) {
471          std::ostringstream oss;
472          oss << " Test: " << test_ << "\n"
473              << " Error: Assignment failed\n"
474              << " Details:\n"
475              << "   Result:\n" << sm << "\n"
476              << "   Expected result:\n(  0 11  0 )\n( 12 13 14 )\n";
477          throw std::runtime_error( oss.str() );
478       }
479 
480       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
481           mat_(1,0) !=  0 || mat_(1,1) != 11 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
482           mat_(2,0) != 12 || mat_(2,1) != 13 || mat_(2,2) != 14 || mat_(2,3) !=  0 ||
483           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
484           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
485          std::ostringstream oss;
486          oss << " Test: " << test_ << "\n"
487              << " Error: Assignment failed\n"
488              << " Details:\n"
489              << "   Result:\n" << mat_ << "\n"
490              << "   Expected result:\n(  0  0  0  0 )\n"
491                                      "(  0 11  0  0 )\n"
492                                      "( 12 13 14  0 )\n"
493                                      "(  0  4  5 -6 )\n"
494                                      "(  7 -8  9 10 )\n";
495          throw std::runtime_error( oss.str() );
496       }
497    }
498 
499 
500    //=====================================================================================
501    // Row-major sparse matrix assignment
502    //=====================================================================================
503 
504    {
505       test_ = "Row-major/row-major sparse matrix assignment";
506 
507       initialize();
508 
509       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
510 
511       blaze::CompressedMatrix<int,blaze::rowMajor> mat( 2UL, 3UL, 4UL );
512       mat(0,1) = 11;
513       mat(1,0) = 12;
514       mat(1,1) = 13;
515       mat(1,2) = 14;
516 
517       sm = mat;
518 
519       checkRows    ( sm  ,  2UL );
520       checkColumns ( sm  ,  3UL );
521       checkNonZeros( sm  ,  4UL );
522       checkRows    ( mat_,  5UL );
523       checkColumns ( mat_,  4UL );
524       checkNonZeros( mat_, 11UL );
525 
526       if( sm(0,0) !=  0 || sm(0,1) != 11 || sm(0,2) !=  0 ||
527           sm(1,0) != 12 || sm(1,1) != 13 || sm(1,2) != 14 ) {
528          std::ostringstream oss;
529          oss << " Test: " << test_ << "\n"
530              << " Error: Assignment failed\n"
531              << " Details:\n"
532              << "   Result:\n" << sm << "\n"
533              << "   Expected result:\n(  0 11  0 )\n( 12 13 14 )\n";
534          throw std::runtime_error( oss.str() );
535       }
536 
537       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
538           mat_(1,0) !=  0 || mat_(1,1) != 11 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
539           mat_(2,0) != 12 || mat_(2,1) != 13 || mat_(2,2) != 14 || mat_(2,3) !=  0 ||
540           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
541           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
542          std::ostringstream oss;
543          oss << " Test: " << test_ << "\n"
544              << " Error: Assignment failed\n"
545              << " Details:\n"
546              << "   Result:\n" << mat_ << "\n"
547              << "   Expected result:\n(  0  0  0  0 )\n"
548                                      "(  0 11  0  0 )\n"
549                                      "( 12 13 14  0 )\n"
550                                      "(  0  4  5 -6 )\n"
551                                      "(  7 -8  9 10 )\n";
552          throw std::runtime_error( oss.str() );
553       }
554    }
555 
556    {
557       test_ = "Row-major/column-major sparse matrix assignment";
558 
559       initialize();
560 
561       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
562 
563       blaze::CompressedMatrix<int,blaze::columnMajor> mat( 2UL, 3UL, 4UL );
564       mat(0,1) = 11;
565       mat(1,0) = 12;
566       mat(1,1) = 13;
567       mat(1,2) = 14;
568 
569       sm = mat;
570 
571       checkRows    ( sm  ,  2UL );
572       checkColumns ( sm  ,  3UL );
573       checkNonZeros( sm  ,  4UL );
574       checkRows    ( mat_,  5UL );
575       checkColumns ( mat_,  4UL );
576       checkNonZeros( mat_, 11UL );
577 
578       if( sm(0,0) !=  0 || sm(0,1) != 11 || sm(0,2) !=  0 ||
579           sm(1,0) != 12 || sm(1,1) != 13 || sm(1,2) != 14 ) {
580          std::ostringstream oss;
581          oss << " Test: " << test_ << "\n"
582              << " Error: Assignment failed\n"
583              << " Details:\n"
584              << "   Result:\n" << sm << "\n"
585              << "   Expected result:\n(  0 11  0 )\n( 12 13 14 )\n";
586          throw std::runtime_error( oss.str() );
587       }
588 
589       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
590           mat_(1,0) !=  0 || mat_(1,1) != 11 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
591           mat_(2,0) != 12 || mat_(2,1) != 13 || mat_(2,2) != 14 || mat_(2,3) !=  0 ||
592           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
593           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
594          std::ostringstream oss;
595          oss << " Test: " << test_ << "\n"
596              << " Error: Assignment failed\n"
597              << " Details:\n"
598              << "   Result:\n" << mat_ << "\n"
599              << "   Expected result:\n(  0  0  0  0 )\n"
600                                      "(  0 11  0  0 )\n"
601                                      "( 12 13 14  0 )\n"
602                                      "(  0  4  5 -6 )\n"
603                                      "(  7 -8  9 10 )\n";
604          throw std::runtime_error( oss.str() );
605       }
606    }
607 
608 
609    //=====================================================================================
610    // Column-major list assignment
611    //=====================================================================================
612 
613    {
614       test_ = "Column-major initializer list assignment (complete list)";
615 
616       initialize();
617 
618       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
619       sm = { { 1, 0 }, { 0, 4 }, { 5, 0 } };
620 
621       checkRows    ( sm   ,  3UL );
622       checkColumns ( sm   ,  2UL );
623       checkNonZeros( sm   ,  3UL );
624       checkRows    ( tmat_,  4UL );
625       checkColumns ( tmat_,  5UL );
626       checkNonZeros( tmat_, 10UL );
627 
628       if( sm(0,0) != 1 || sm(0,1) != 0 ||
629           sm(1,0) != 0 || sm(1,1) != 4 ||
630           sm(2,0) != 5 || sm(2,1) != 0 ) {
631          std::ostringstream oss;
632          oss << " Test: " << test_ << "\n"
633              << " Error: Assignment failed\n"
634              << " Details:\n"
635              << "   Result:\n" << sm << "\n"
636              << "   Expected result:\n( 1 0 )\n( 0 4 )\n( 5 0 )\n";
637          throw std::runtime_error( oss.str() );
638       }
639 
640       if( tmat_(0,0) != 0 || tmat_(0,1) != 1 || tmat_(0,2) != 0 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
641           tmat_(1,0) != 0 || tmat_(1,1) != 0 || tmat_(1,2) != 4 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
642           tmat_(2,0) != 0 || tmat_(2,1) != 5 || tmat_(2,2) != 0 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
643           tmat_(3,0) != 0 || tmat_(3,1) != 0 || tmat_(3,2) != 0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
644          std::ostringstream oss;
645          oss << " Test: " << test_ << "\n"
646              << " Error: Assignment failed\n"
647              << " Details:\n"
648              << "   Result:\n" << tmat_ << "\n"
649              << "   Expected result:\n( 0  1  0  0  7 )\n"
650                                      "( 0  0  4  4 -8 )\n"
651                                      "( 0  5  0  5  9 )\n"
652                                      "( 0  0  0 -6 10 )\n";
653          throw std::runtime_error( oss.str() );
654       }
655    }
656 
657    {
658       test_ = "Column-major initializer list assignment (incomplete list)";
659 
660       initialize();
661 
662       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
663       sm = { { 1 }, {}, { 5, 6 } };
664 
665       checkRows    ( sm   ,  3UL );
666       checkColumns ( sm   ,  2UL );
667       checkNonZeros( sm   ,  3UL );
668       checkRows    ( tmat_,  4UL );
669       checkColumns ( tmat_,  5UL );
670       checkNonZeros( tmat_, 10UL );
671 
672       if( sm(0,0) != 1 || sm(0,1) != 0 ||
673           sm(1,0) != 0 || sm(1,1) != 0 ||
674           sm(2,0) != 5 || sm(2,1) != 6 ) {
675          std::ostringstream oss;
676          oss << " Test: " << test_ << "\n"
677              << " Error: Assignment failed\n"
678              << " Details:\n"
679              << "   Result:\n" << sm << "\n"
680              << "   Expected result:\n( 1 0 )\n( 0 0 )\n( 5 6 )\n";
681          throw std::runtime_error( oss.str() );
682       }
683 
684       if( tmat_(0,0) != 0 || tmat_(0,1) != 1 || tmat_(0,2) != 0 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
685           tmat_(1,0) != 0 || tmat_(1,1) != 0 || tmat_(1,2) != 0 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
686           tmat_(2,0) != 0 || tmat_(2,1) != 5 || tmat_(2,2) != 6 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
687           tmat_(3,0) != 0 || tmat_(3,1) != 0 || tmat_(3,2) != 0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
688          std::ostringstream oss;
689          oss << " Test: " << test_ << "\n"
690              << " Error: Assignment failed\n"
691              << " Details:\n"
692              << "   Result:\n" << tmat_ << "\n"
693              << "   Expected result:\n( 0  1  0  0  7 )\n"
694                                      "( 0  0  0  4 -8 )\n"
695                                      "( 0  5  6  5  9 )\n"
696                                      "( 0  0  0 -6 10 )\n";
697          throw std::runtime_error( oss.str() );
698       }
699    }
700 
701 
702    //=====================================================================================
703    // Column-major copy assignment
704    //=====================================================================================
705 
706    {
707       test_ = "Column-major Submatrix copy assignment (no aliasing)";
708 
709       initialize();
710 
711       OMT mat( 4UL, 5UL, 3UL );
712       mat(0,1) = 11;
713       mat(0,2) = 12;
714       mat(2,2) = 13;
715 
716       OSMT sm = blaze::submatrix( mat, 0UL, 1UL, 3UL, 2UL );
717       sm = blaze::submatrix( tmat_, 1UL, 2UL, 3UL, 2UL );
718 
719       checkRows    ( sm   ,  3UL );
720       checkColumns ( sm   ,  2UL );
721       checkNonZeros( sm   ,  4UL );
722       checkRows    ( tmat_,  4UL );
723       checkColumns ( tmat_,  5UL );
724       checkNonZeros( tmat_, 10UL );
725       checkRows    ( mat  ,  4UL );
726       checkColumns ( mat  ,  5UL );
727       checkNonZeros( mat  ,  4UL );
728 
729       if( sm(0,0) !=  0 || sm(0,1) !=  4 ||
730           sm(1,0) != -3 || sm(1,1) !=  5 ||
731           sm(2,0) !=  0 || sm(2,1) != -6 ) {
732          std::ostringstream oss;
733          oss << " Test: " << test_ << "\n"
734              << " Error: Assignment failed\n"
735              << " Details:\n"
736              << "   Result:\n" << sm << "\n"
737              << "   Expected result:\n(  0  4 )\n( -3  5 )\n(  0 -6 )\n";
738          throw std::runtime_error( oss.str() );
739       }
740 
741       if( mat(0,0) != 0 || mat(0,1) !=  0 || mat(0,2) !=  4 || mat(0,3) != 0 || mat(0,4) != 0 ||
742           mat(1,0) != 0 || mat(1,1) != -3 || mat(1,2) !=  5 || mat(1,3) != 0 || mat(1,4) != 0 ||
743           mat(2,0) != 0 || mat(2,1) !=  0 || mat(2,2) != -6 || mat(2,3) != 0 || mat(2,4) != 0 ||
744           mat(3,0) != 0 || mat(3,1) !=  0 || mat(3,2) !=  0 || mat(3,3) != 0 || mat(3,4) != 0 ) {
745          std::ostringstream oss;
746          oss << " Test: " << test_ << "\n"
747              << " Error: Assignment failed\n"
748              << " Details:\n"
749              << "   Result:\n" << mat << "\n"
750              << "   Expected result:\n( 0  0  4  0  0 )\n"
751                                      "( 0 -3  5  0  0 )\n"
752                                      "( 0  0 -6  0  0 )\n"
753                                      "( 0  0  0  0  0 )\n";
754          throw std::runtime_error( oss.str() );
755       }
756    }
757 
758    {
759       test_ = "Column-major Submatrix copy assignment (aliasing)";
760 
761       initialize();
762 
763       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
764       sm = blaze::submatrix( tmat_, 1UL, 2UL, 3UL, 2UL );
765 
766       checkRows    ( sm   ,  3UL );
767       checkColumns ( sm   ,  2UL );
768       checkNonZeros( sm   ,  4UL );
769       checkRows    ( tmat_,  4UL );
770       checkColumns ( tmat_,  5UL );
771       checkNonZeros( tmat_, 11UL );
772 
773       if( sm(0,0) !=  0 || sm(0,1) !=  4 ||
774           sm(1,0) != -3 || sm(1,1) !=  5 ||
775           sm(2,0) !=  0 || sm(2,1) != -6 ) {
776          std::ostringstream oss;
777          oss << " Test: " << test_ << "\n"
778              << " Error: Assignment failed\n"
779              << " Details:\n"
780              << "   Result:\n" << sm << "\n"
781              << "   Expected result:\n(  0  4 )\n( -3  5 )\n(  0 -6 )\n";
782          throw std::runtime_error( oss.str() );
783       }
784 
785       if( tmat_(0,0) != 0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  4 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
786           tmat_(1,0) != 0 || tmat_(1,1) != -3 || tmat_(1,2) !=  5 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
787           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != -6 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
788           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
789          std::ostringstream oss;
790          oss << " Test: " << test_ << "\n"
791              << " Error: Assignment failed\n"
792              << " Details:\n"
793              << "   Result:\n" << tmat_ << "\n"
794              << "   Expected result:\n( 0  0  4  0  7 )\n"
795                                      "( 0 -3  5  4 -8 )\n"
796                                      "( 0  0 -6  5  9 )\n"
797                                      "( 0  0  0 -6 10 )\n";
798          throw std::runtime_error( oss.str() );
799       }
800    }
801 
802 
803    //=====================================================================================
804    // Column-major dense matrix assignment
805    //=====================================================================================
806 
807    {
808       test_ = "Column-major/row-major dense matrix assignment";
809 
810       initialize();
811 
812       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
813 
814       blaze::DynamicMatrix<int,blaze::rowMajor> mat{ {  0, 12 },
815                                                      { 11, 13 },
816                                                      {  0, 14 } };
817 
818       sm = mat;
819 
820       checkRows    ( sm   ,  3UL );
821       checkColumns ( sm   ,  2UL );
822       checkNonZeros( sm   ,  4UL );
823       checkRows    ( tmat_,  4UL );
824       checkColumns ( tmat_,  5UL );
825       checkNonZeros( tmat_, 11UL );
826 
827       if( sm(0,0) !=  0 || sm(0,1) != 12 ||
828           sm(1,0) != 11 || sm(1,1) != 13 ||
829           sm(2,0) !=  0 || sm(2,1) != 14 ) {
830          std::ostringstream oss;
831          oss << " Test: " << test_ << "\n"
832              << " Error: Assignment failed\n"
833              << " Details:\n"
834              << "   Result:\n" << sm << "\n"
835              << "   Expected result:\n(  0 12 )\n( 11 13 )\n(  0 14 )\n";
836          throw std::runtime_error( oss.str() );
837       }
838 
839       if( tmat_(0,0) != 0 || tmat_(0,1) !=  0 || tmat_(0,2) != 12 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
840           tmat_(1,0) != 0 || tmat_(1,1) != 11 || tmat_(1,2) != 13 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
841           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != 14 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
842           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
843          std::ostringstream oss;
844          oss << " Test: " << test_ << "\n"
845              << " Error: Assignment failed\n"
846              << " Details:\n"
847              << "   Result:\n" << tmat_ << "\n"
848              << "   Expected result:\n( 0  0 12  0  7 )\n"
849                                      "( 0 11 13  4 -8 )\n"
850                                      "( 0  0 14  5  9 )\n"
851                                      "( 0  0  0 -6 10 )\n";
852          throw std::runtime_error( oss.str() );
853       }
854    }
855 
856    {
857       test_ = "Column-major/column-major dense matrix assignment";
858 
859       initialize();
860 
861       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
862 
863       blaze::DynamicMatrix<int,blaze::columnMajor> mat{ {  0, 12 },
864                                                         { 11, 13 },
865                                                         {  0, 14 } };
866 
867       sm = mat;
868 
869       checkRows    ( sm   ,  3UL );
870       checkColumns ( sm   ,  2UL );
871       checkNonZeros( sm   ,  4UL );
872       checkRows    ( tmat_,  4UL );
873       checkColumns ( tmat_,  5UL );
874       checkNonZeros( tmat_, 11UL );
875 
876       if( sm(0,0) !=  0 || sm(0,1) != 12 ||
877           sm(1,0) != 11 || sm(1,1) != 13 ||
878           sm(2,0) !=  0 || sm(2,1) != 14 ) {
879          std::ostringstream oss;
880          oss << " Test: " << test_ << "\n"
881              << " Error: Assignment failed\n"
882              << " Details:\n"
883              << "   Result:\n" << sm << "\n"
884              << "   Expected result:\n(  0 12 )\n( 11 13 )\n(  0 14 )\n";
885          throw std::runtime_error( oss.str() );
886       }
887 
888       if( tmat_(0,0) != 0 || tmat_(0,1) !=  0 || tmat_(0,2) != 12 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
889           tmat_(1,0) != 0 || tmat_(1,1) != 11 || tmat_(1,2) != 13 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
890           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != 14 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
891           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
892          std::ostringstream oss;
893          oss << " Test: " << test_ << "\n"
894              << " Error: Assignment failed\n"
895              << " Details:\n"
896              << "   Result:\n" << tmat_ << "\n"
897              << "   Expected result:\n( 0  0 12  0  7 )\n"
898                                      "( 0 11 13  4 -8 )\n"
899                                      "( 0  0 14  5  9 )\n"
900                                      "( 0  0  0 -6 10 )\n";
901          throw std::runtime_error( oss.str() );
902       }
903    }
904 
905 
906    //=====================================================================================
907    // Column-major sparse matrix assignment
908    //=====================================================================================
909 
910    {
911       test_ = "Column-major/row-major sparse matrix assignment";
912 
913       initialize();
914 
915       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
916 
917       blaze::CompressedMatrix<int,blaze::rowMajor> mat( 3UL, 2UL, 4UL );
918       mat(1,0) = 11;
919       mat(0,1) = 12;
920       mat(1,1) = 13;
921       mat(2,1) = 14;
922 
923       sm = mat;
924 
925       checkRows    ( sm   ,  3UL );
926       checkColumns ( sm   ,  2UL );
927       checkNonZeros( sm   ,  4UL );
928       checkRows    ( tmat_,  4UL );
929       checkColumns ( tmat_,  5UL );
930       checkNonZeros( tmat_, 11UL );
931 
932       if( sm(0,0) !=  0 || sm(0,1) != 12 ||
933           sm(1,0) != 11 || sm(1,1) != 13 ||
934           sm(2,0) !=  0 || sm(2,1) != 14 ) {
935          std::ostringstream oss;
936          oss << " Test: " << test_ << "\n"
937              << " Error: Assignment failed\n"
938              << " Details:\n"
939              << "   Result:\n" << sm << "\n"
940              << "   Expected result:\n(  0 12 )\n( 11 13 )\n(  0 14 )\n";
941          throw std::runtime_error( oss.str() );
942       }
943 
944       if( tmat_(0,0) != 0 || tmat_(0,1) !=  0 || tmat_(0,2) != 12 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
945           tmat_(1,0) != 0 || tmat_(1,1) != 11 || tmat_(1,2) != 13 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
946           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != 14 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
947           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
948          std::ostringstream oss;
949          oss << " Test: " << test_ << "\n"
950              << " Error: Assignment failed\n"
951              << " Details:\n"
952              << "   Result:\n" << tmat_ << "\n"
953              << "   Expected result:\n( 0  0 12  0  7 )\n"
954                                      "( 0 11 13  4 -8 )\n"
955                                      "( 0  0 14  5  9 )\n"
956                                      "( 0  0  0 -6 10 )\n";
957          throw std::runtime_error( oss.str() );
958       }
959    }
960 
961    {
962       test_ = "Column-major/column-major sparse matrix assignment";
963 
964       initialize();
965 
966       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
967 
968       blaze::CompressedMatrix<int,blaze::columnMajor> mat( 3UL, 2UL, 4UL );
969       mat(1,0) = 11;
970       mat(0,1) = 12;
971       mat(1,1) = 13;
972       mat(2,1) = 14;
973 
974       sm = mat;
975 
976       checkRows    ( sm   ,  3UL );
977       checkColumns ( sm   ,  2UL );
978       checkNonZeros( sm   ,  4UL );
979       checkRows    ( tmat_,  4UL );
980       checkColumns ( tmat_,  5UL );
981       checkNonZeros( tmat_, 11UL );
982 
983       if( sm(0,0) !=  0 || sm(0,1) != 12 ||
984           sm(1,0) != 11 || sm(1,1) != 13 ||
985           sm(2,0) !=  0 || sm(2,1) != 14 ) {
986          std::ostringstream oss;
987          oss << " Test: " << test_ << "\n"
988              << " Error: Assignment failed\n"
989              << " Details:\n"
990              << "   Result:\n" << sm << "\n"
991              << "   Expected result:\n(  0 12 )\n( 11 13 )\n(  0 14 )\n";
992          throw std::runtime_error( oss.str() );
993       }
994 
995       if( tmat_(0,0) != 0 || tmat_(0,1) !=  0 || tmat_(0,2) != 12 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
996           tmat_(1,0) != 0 || tmat_(1,1) != 11 || tmat_(1,2) != 13 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
997           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != 14 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
998           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
999          std::ostringstream oss;
1000          oss << " Test: " << test_ << "\n"
1001              << " Error: Assignment failed\n"
1002              << " Details:\n"
1003              << "   Result:\n" << tmat_ << "\n"
1004              << "   Expected result:\n( 0  0 12  0  7 )\n"
1005                                      "( 0 11 13  4 -8 )\n"
1006                                      "( 0  0 14  5  9 )\n"
1007                                      "( 0  0  0 -6 10 )\n";
1008          throw std::runtime_error( oss.str() );
1009       }
1010    }
1011 }
1012 //*************************************************************************************************
1013 
1014 
1015 //*************************************************************************************************
1016 /*!\brief Test of the Submatrix addition assignment operators.
1017 //
1018 // \return void
1019 // \exception std::runtime_error Error detected.
1020 //
1021 // This function performs a test of the addition assignment operators of the Submatrix
1022 // specialization. In case an error is detected, a \a std::runtime_error exception is thrown.
1023 */
testAddAssign()1024 void SparseTest::testAddAssign()
1025 {
1026    //=====================================================================================
1027    // Row-major Submatrix addition assignment
1028    //=====================================================================================
1029 
1030    {
1031       test_ = "Row-major Submatrix addition assignment (no aliasing)";
1032 
1033       initialize();
1034 
1035       MT mat( 5UL, 4UL, 3UL );
1036       mat(1,0) = 11;
1037       mat(2,0) = 12;
1038       mat(2,2) = 13;
1039 
1040       SMT sm = blaze::submatrix( mat, 1UL, 0UL, 2UL, 3UL );
1041       sm += blaze::submatrix( mat_, 2UL, 1UL, 2UL, 3UL );
1042 
1043       checkRows    ( sm  ,  2UL );
1044       checkColumns ( sm  ,  3UL );
1045       checkNonZeros( sm  ,  5UL );
1046       checkRows    ( mat_,  5UL );
1047       checkColumns ( mat_,  4UL );
1048       checkNonZeros( mat_, 10UL );
1049       checkRows    ( mat ,  5UL );
1050       checkColumns ( mat ,  4UL );
1051       checkNonZeros( mat ,  5UL );
1052 
1053       if( sm(0,0) != 11 || sm(0,1) != -3 || sm(0,2) != 0 ||
1054           sm(1,0) != 16 || sm(1,1) !=  5 || sm(1,2) != 7 ) {
1055          std::ostringstream oss;
1056          oss << " Test: " << test_ << "\n"
1057              << " Error: Addition assignment failed\n"
1058              << " Details:\n"
1059              << "   Result:\n" << sm << "\n"
1060              << "   Expected result:\n( 11 -3  0 )\n( 16  5  7 )\n";
1061          throw std::runtime_error( oss.str() );
1062       }
1063 
1064       if( mat(0,0) !=  0 || mat(0,1) !=  0 || mat(0,2) != 0 || mat(0,3) != 0 ||
1065           mat(1,0) != 11 || mat(1,1) != -3 || mat(1,2) != 0 || mat(1,3) != 0 ||
1066           mat(2,0) != 16 || mat(2,1) !=  5 || mat(2,2) != 7 || mat(2,3) != 0 ||
1067           mat(3,0) !=  0 || mat(3,1) !=  0 || mat(3,2) != 0 || mat(3,3) != 0 ||
1068           mat(4,0) !=  0 || mat(4,1) !=  0 || mat(4,2) != 0 || mat(4,3) != 0 ) {
1069          std::ostringstream oss;
1070          oss << " Test: " << test_ << "\n"
1071              << " Error: Addition assignment failed\n"
1072              << " Details:\n"
1073              << "   Result:\n" << mat << "\n"
1074              << "   Expected result:\n(  0  0  0  0 )\n"
1075                                      "( 11 -3  0  0 )\n"
1076                                      "( 16  5  7  0 )\n"
1077                                      "(  0  0  0  0 )\n"
1078                                      "(  0  0  0  0 )\n";
1079          throw std::runtime_error( oss.str() );
1080       }
1081    }
1082 
1083    {
1084       test_ = "Row-major Submatrix addition assignment (aliasing)";
1085 
1086       initialize();
1087 
1088       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
1089       sm += blaze::submatrix( mat_, 2UL, 1UL, 2UL, 3UL );
1090 
1091       checkRows    ( sm  ,  2UL );
1092       checkColumns ( sm  ,  3UL );
1093       checkNonZeros( sm  ,  4UL );
1094       checkRows    ( mat_,  5UL );
1095       checkColumns ( mat_,  4UL );
1096       checkNonZeros( mat_, 11UL );
1097 
1098       if( sm(0,0) != 0 || sm(0,1) != -2 || sm(0,2) !=  0 ||
1099           sm(1,0) != 2 || sm(1,1) !=  5 || sm(1,2) != -9 ) {
1100          std::ostringstream oss;
1101          oss << " Test: " << test_ << "\n"
1102              << " Error: Addition assignment failed\n"
1103              << " Details:\n"
1104              << "   Result:\n" << sm << "\n"
1105              << "   Expected result:\n( 0 -2  0 )\n( 2  5 -9 )\n";
1106          throw std::runtime_error( oss.str() );
1107       }
1108 
1109       if( mat_(0,0) != 0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1110           mat_(1,0) != 0 || mat_(1,1) != -2 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
1111           mat_(2,0) != 2 || mat_(2,1) !=  5 || mat_(2,2) != -9 || mat_(2,3) !=  0 ||
1112           mat_(3,0) != 0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
1113           mat_(4,0) != 7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1114          std::ostringstream oss;
1115          oss << " Test: " << test_ << "\n"
1116              << " Error: Addition assignment failed\n"
1117              << " Details:\n"
1118              << "   Result:\n" << mat_ << "\n"
1119              << "   Expected result:\n( 0  0  0  0 )\n"
1120                                      "( 0 -2  0  0 )\n"
1121                                      "( 2  5 -9  0 )\n"
1122                                      "( 0  4  5 -6 )\n"
1123                                      "( 7 -8  9 10 )\n";
1124          throw std::runtime_error( oss.str() );
1125       }
1126    }
1127 
1128 
1129    //=====================================================================================
1130    // Row-major dense matrix addition assignment
1131    //=====================================================================================
1132 
1133    {
1134       test_ = "Row-major/row-major dense matrix addition assignment";
1135 
1136       initialize();
1137 
1138       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
1139 
1140       blaze::DynamicMatrix<int,blaze::rowMajor> mat{ {  0, 11,  0 },
1141                                                      { 12, 13, 14 } };
1142 
1143       sm += mat;
1144 
1145       checkRows    ( sm  ,  2UL );
1146       checkColumns ( sm  ,  3UL );
1147       checkNonZeros( sm  ,  4UL );
1148       checkRows    ( mat_,  5UL );
1149       checkColumns ( mat_,  4UL );
1150       checkNonZeros( mat_, 11UL );
1151 
1152       if( sm(0,0) !=  0 || sm(0,1) != 12 || sm(0,2) !=  0 ||
1153           sm(1,0) != 10 || sm(1,1) != 13 || sm(1,2) != 11 ) {
1154          std::ostringstream oss;
1155          oss << " Test: " << test_ << "\n"
1156              << " Error: Addition assignment failed\n"
1157              << " Details:\n"
1158              << "   Result:\n" << sm << "\n"
1159              << "   Expected result:\n(  0 12  0 )\n( 10 13 11 )\n";
1160          throw std::runtime_error( oss.str() );
1161       }
1162 
1163       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1164           mat_(1,0) !=  0 || mat_(1,1) != 12 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
1165           mat_(2,0) != 10 || mat_(2,1) != 13 || mat_(2,2) != 11 || mat_(2,3) !=  0 ||
1166           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
1167           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1168          std::ostringstream oss;
1169          oss << " Test: " << test_ << "\n"
1170              << " Error: Addition assignment failed\n"
1171              << " Details:\n"
1172              << "   Result:\n" << mat_ << "\n"
1173              << "   Expected result:\n(  0  0  0  0 )\n"
1174                                      "(  0 12  0  0 )\n"
1175                                      "( 10 13 11  0 )\n"
1176                                      "(  0  4  5 -6 )\n"
1177                                      "(  7 -8  9 10 )\n";
1178          throw std::runtime_error( oss.str() );
1179       }
1180    }
1181 
1182    {
1183       test_ = "Row-major/column-major dense matrix addition assignment";
1184 
1185       initialize();
1186 
1187       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
1188 
1189       blaze::DynamicMatrix<int,blaze::columnMajor> mat{ {  0, 11,  0 },
1190                                                         { 12, 13, 14 } };
1191 
1192       sm += mat;
1193 
1194       checkRows    ( sm  ,  2UL );
1195       checkColumns ( sm  ,  3UL );
1196       checkNonZeros( sm  ,  4UL );
1197       checkRows    ( mat_,  5UL );
1198       checkColumns ( mat_,  4UL );
1199       checkNonZeros( mat_, 11UL );
1200 
1201       if( sm(0,0) !=  0 || sm(0,1) != 12 || sm(0,2) !=  0 ||
1202           sm(1,0) != 10 || sm(1,1) != 13 || sm(1,2) != 11 ) {
1203          std::ostringstream oss;
1204          oss << " Test: " << test_ << "\n"
1205              << " Error: Addition assignment failed\n"
1206              << " Details:\n"
1207              << "   Result:\n" << sm << "\n"
1208              << "   Expected result:\n(  0 12  0 )\n( 10 13 11 )\n";
1209          throw std::runtime_error( oss.str() );
1210       }
1211 
1212       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1213           mat_(1,0) !=  0 || mat_(1,1) != 12 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
1214           mat_(2,0) != 10 || mat_(2,1) != 13 || mat_(2,2) != 11 || mat_(2,3) !=  0 ||
1215           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
1216           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1217          std::ostringstream oss;
1218          oss << " Test: " << test_ << "\n"
1219              << " Error: Addition assignment failed\n"
1220              << " Details:\n"
1221              << "   Result:\n" << mat_ << "\n"
1222              << "   Expected result:\n(  0  0  0  0 )\n"
1223                                      "(  0 12  0  0 )\n"
1224                                      "( 10 13 11  0 )\n"
1225                                      "(  0  4  5 -6 )\n"
1226                                      "(  7 -8  9 10 )\n";
1227          throw std::runtime_error( oss.str() );
1228       }
1229    }
1230 
1231 
1232    //=====================================================================================
1233    // Row-major sparse matrix addition assignment
1234    //=====================================================================================
1235 
1236    {
1237       test_ = "Row-major/row-major sparse matrix addition assignment";
1238 
1239       initialize();
1240 
1241       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
1242 
1243       blaze::CompressedMatrix<int,blaze::rowMajor> mat( 2UL, 3UL, 4UL );
1244       mat(0,1) = 11;
1245       mat(1,0) = 12;
1246       mat(1,1) = 13;
1247       mat(1,2) = 14;
1248 
1249       sm += mat;
1250 
1251       checkRows    ( sm  ,  2UL );
1252       checkColumns ( sm  ,  3UL );
1253       checkNonZeros( sm  ,  4UL );
1254       checkRows    ( mat_,  5UL );
1255       checkColumns ( mat_,  4UL );
1256       checkNonZeros( mat_, 11UL );
1257 
1258       if( sm(0,0) !=  0 || sm(0,1) != 12 || sm(0,2) !=  0 ||
1259           sm(1,0) != 10 || sm(1,1) != 13 || sm(1,2) != 11 ) {
1260          std::ostringstream oss;
1261          oss << " Test: " << test_ << "\n"
1262              << " Error: Addition assignment failed\n"
1263              << " Details:\n"
1264              << "   Result:\n" << sm << "\n"
1265              << "   Expected result:\n(  0 12  0 )\n( 10 13 11 )\n";
1266          throw std::runtime_error( oss.str() );
1267       }
1268 
1269       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1270           mat_(1,0) !=  0 || mat_(1,1) != 12 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
1271           mat_(2,0) != 10 || mat_(2,1) != 13 || mat_(2,2) != 11 || mat_(2,3) !=  0 ||
1272           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
1273           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1274          std::ostringstream oss;
1275          oss << " Test: " << test_ << "\n"
1276              << " Error: Addition assignment failed\n"
1277              << " Details:\n"
1278              << "   Result:\n" << mat_ << "\n"
1279              << "   Expected result:\n(  0  0  0  0 )\n"
1280                                      "(  0 12  0  0 )\n"
1281                                      "( 10 13 11  0 )\n"
1282                                      "(  0  4  5 -6 )\n"
1283                                      "(  7 -8  9 10 )\n";
1284          throw std::runtime_error( oss.str() );
1285       }
1286    }
1287 
1288    {
1289       test_ = "Row-major/column-major sparse matrix addition assignment";
1290 
1291       initialize();
1292 
1293       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
1294 
1295       blaze::CompressedMatrix<int,blaze::columnMajor> mat( 2UL, 3UL, 4UL );
1296       mat(0,1) = 11;
1297       mat(1,0) = 12;
1298       mat(1,1) = 13;
1299       mat(1,2) = 14;
1300 
1301       sm += mat;
1302 
1303       checkRows    ( sm  ,  2UL );
1304       checkColumns ( sm  ,  3UL );
1305       checkNonZeros( sm  ,  4UL );
1306       checkRows    ( mat_,  5UL );
1307       checkColumns ( mat_,  4UL );
1308       checkNonZeros( mat_, 11UL );
1309 
1310       if( sm(0,0) !=  0 || sm(0,1) != 12 || sm(0,2) !=  0 ||
1311           sm(1,0) != 10 || sm(1,1) != 13 || sm(1,2) != 11 ) {
1312          std::ostringstream oss;
1313          oss << " Test: " << test_ << "\n"
1314              << " Error: Addition assignment failed\n"
1315              << " Details:\n"
1316              << "   Result:\n" << sm << "\n"
1317              << "   Expected result:\n(  0 12  0 )\n( 10 13 11 )\n";
1318          throw std::runtime_error( oss.str() );
1319       }
1320 
1321       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1322           mat_(1,0) !=  0 || mat_(1,1) != 12 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
1323           mat_(2,0) != 10 || mat_(2,1) != 13 || mat_(2,2) != 11 || mat_(2,3) !=  0 ||
1324           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
1325           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1326          std::ostringstream oss;
1327          oss << " Test: " << test_ << "\n"
1328              << " Error: Addition assignment failed\n"
1329              << " Details:\n"
1330              << "   Result:\n" << mat_ << "\n"
1331              << "   Expected result:\n(  0  0  0  0 )\n"
1332                                      "(  0 12  0  0 )\n"
1333                                      "( 10 13 11  0 )\n"
1334                                      "(  0  4  5 -6 )\n"
1335                                      "(  7 -8  9 10 )\n";
1336          throw std::runtime_error( oss.str() );
1337       }
1338    }
1339 
1340 
1341    //=====================================================================================
1342    // Column-major Submatrix addition assignment
1343    //=====================================================================================
1344 
1345    {
1346       test_ = "Column-major Submatrix addition assignment (no aliasing)";
1347 
1348       initialize();
1349 
1350       OMT mat( 4UL, 5UL, 3UL );
1351       mat(0,1) = 11;
1352       mat(0,2) = 12;
1353       mat(2,2) = 13;
1354 
1355       OSMT sm = blaze::submatrix( mat, 0UL, 1UL, 3UL, 2UL );
1356       sm += blaze::submatrix( tmat_, 1UL, 2UL, 3UL, 2UL );
1357 
1358       checkRows    ( sm   ,  3UL );
1359       checkColumns ( sm   ,  2UL );
1360       checkNonZeros( sm   ,  5UL );
1361       checkRows    ( tmat_,  4UL );
1362       checkColumns ( tmat_,  5UL );
1363       checkNonZeros( tmat_, 10UL );
1364       checkRows    ( mat  ,  4UL );
1365       checkColumns ( mat  ,  5UL );
1366       checkNonZeros( mat  ,  5UL );
1367 
1368       if( sm(0,0) != 11 || sm(0,1) != 16 ||
1369           sm(1,0) != -3 || sm(1,1) !=  5 ||
1370           sm(2,0) !=  0 || sm(2,1) !=  7 ) {
1371          std::ostringstream oss;
1372          oss << " Test: " << test_ << "\n"
1373              << " Error: Addition assignment failed\n"
1374              << " Details:\n"
1375              << "   Result:\n" << sm << "\n"
1376              << "   Expected result:\n( 11 16 )\n( -3  5 )\n(  0  7 )\n";
1377          throw std::runtime_error( oss.str() );
1378       }
1379 
1380       if( mat(0,0) != 0 || mat(0,1) != 11 || mat(0,2) != 16 || mat(0,3) != 0 || mat(0,4) != 0 ||
1381           mat(1,0) != 0 || mat(1,1) != -3 || mat(1,2) !=  5 || mat(1,3) != 0 || mat(1,4) != 0 ||
1382           mat(2,0) != 0 || mat(2,1) !=  0 || mat(2,2) !=  7 || mat(2,3) != 0 || mat(2,4) != 0 ||
1383           mat(3,0) != 0 || mat(3,1) !=  0 || mat(3,2) !=  0 || mat(3,3) != 0 || mat(3,4) != 0 ) {
1384          std::ostringstream oss;
1385          oss << " Test: " << test_ << "\n"
1386              << " Error: Addition assignment failed\n"
1387              << " Details:\n"
1388              << "   Result:\n" << mat << "\n"
1389              << "   Expected result:\n( 0 11 16  0  0 )\n"
1390                                      "( 0 -3  5  0  0 )\n"
1391                                      "( 0  0  7  0  0 )\n"
1392                                      "( 0  0  0  0  0 )\n";
1393          throw std::runtime_error( oss.str() );
1394       }
1395    }
1396 
1397    {
1398       test_ = "Column-major Submatrix addition assignment (aliasing)";
1399 
1400       initialize();
1401 
1402       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
1403       sm += blaze::submatrix( tmat_, 1UL, 2UL, 3UL, 2UL );
1404 
1405       checkRows    ( sm   ,  3UL );
1406       checkColumns ( sm   ,  2UL );
1407       checkNonZeros( sm   ,  4UL );
1408       checkRows    ( tmat_,  4UL );
1409       checkColumns ( tmat_,  5UL );
1410       checkNonZeros( tmat_, 11UL );
1411 
1412       if( sm(0,0) !=  0 || sm(0,1) !=  2 ||
1413           sm(1,0) != -2 || sm(1,1) !=  5 ||
1414           sm(2,0) !=  0 || sm(2,1) != -9 ) {
1415          std::ostringstream oss;
1416          oss << " Test: " << test_ << "\n"
1417              << " Error: Addition assignment failed\n"
1418              << " Details:\n"
1419              << "   Result:\n" << sm << "\n"
1420              << "   Expected result:\n(  0  2 )\n( -2  5 )\n(  0 -9 )\n";
1421          throw std::runtime_error( oss.str() );
1422       }
1423 
1424       if( tmat_(0,0) != 0 || tmat_(0,1) !=  0 || tmat_(0,2) !=  2 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
1425           tmat_(1,0) != 0 || tmat_(1,1) != -2 || tmat_(1,2) !=  5 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
1426           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != -9 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
1427           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
1428          std::ostringstream oss;
1429          oss << " Test: " << test_ << "\n"
1430              << " Error: Addition assignment failed\n"
1431              << " Details:\n"
1432              << "   Result:\n" << tmat_ << "\n"
1433              << "   Expected result:\n( 0  0  2  0  7 )\n"
1434                                      "( 0 -2  5  4 -8 )\n"
1435                                      "( 0  0 -9  5  9 )\n"
1436                                      "( 0  0  0 -6 10 )\n";
1437          throw std::runtime_error( oss.str() );
1438       }
1439    }
1440 
1441 
1442    //=====================================================================================
1443    // Column-major dense matrix addition assignment
1444    //=====================================================================================
1445 
1446    {
1447       test_ = "Column-major/row-major dense matrix addition assignment";
1448 
1449       initialize();
1450 
1451       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
1452 
1453       blaze::DynamicMatrix<int,blaze::rowMajor> mat{ {  0, 12 },
1454                                                      { 11, 13 },
1455                                                      {  0, 14 } };
1456 
1457       sm += mat;
1458 
1459       checkRows    ( sm   ,  3UL );
1460       checkColumns ( sm   ,  2UL );
1461       checkNonZeros( sm   ,  4UL );
1462       checkRows    ( tmat_,  4UL );
1463       checkColumns ( tmat_,  5UL );
1464       checkNonZeros( tmat_, 11UL );
1465 
1466       if( sm(0,0) !=  0 || sm(0,1) != 10 ||
1467           sm(1,0) != 12 || sm(1,1) != 13 ||
1468           sm(2,0) !=  0 || sm(2,1) != 11 ) {
1469          std::ostringstream oss;
1470          oss << " Test: " << test_ << "\n"
1471              << " Error: Addition assignment failed\n"
1472              << " Details:\n"
1473              << "   Result:\n" << sm << "\n"
1474              << "   Expected result:\n(  0 10 )\n( 12 13 )\n(  0 11 )\n";
1475          throw std::runtime_error( oss.str() );
1476       }
1477 
1478       if( tmat_(0,0) != 0 || tmat_(0,1) !=  0 || tmat_(0,2) != 10 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
1479           tmat_(1,0) != 0 || tmat_(1,1) != 12 || tmat_(1,2) != 13 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
1480           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != 11 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
1481           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
1482          std::ostringstream oss;
1483          oss << " Test: " << test_ << "\n"
1484              << " Error: Addition assignment failed\n"
1485              << " Details:\n"
1486              << "   Result:\n" << tmat_ << "\n"
1487              << "   Expected result:\n( 0  0 10  0  7 )\n"
1488                                      "( 0 12 13  4 -8 )\n"
1489                                      "( 0  0 11  5  9 )\n"
1490                                      "( 0  0  0 -6 10 )\n";
1491          throw std::runtime_error( oss.str() );
1492       }
1493    }
1494 
1495    {
1496       test_ = "Column-major/column-major dense matrix addition assignment";
1497 
1498       initialize();
1499 
1500       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
1501 
1502       blaze::DynamicMatrix<int,blaze::columnMajor> mat{ {  0, 12 },
1503                                                         { 11, 13 },
1504                                                         {  0, 14 } };;
1505 
1506       sm += mat;
1507 
1508       checkRows    ( sm   ,  3UL );
1509       checkColumns ( sm   ,  2UL );
1510       checkNonZeros( sm   ,  4UL );
1511       checkRows    ( tmat_,  4UL );
1512       checkColumns ( tmat_,  5UL );
1513       checkNonZeros( tmat_, 11UL );
1514 
1515       if( sm(0,0) !=  0 || sm(0,1) != 10 ||
1516           sm(1,0) != 12 || sm(1,1) != 13 ||
1517           sm(2,0) !=  0 || sm(2,1) != 11 ) {
1518          std::ostringstream oss;
1519          oss << " Test: " << test_ << "\n"
1520              << " Error: Addition assignment failed\n"
1521              << " Details:\n"
1522              << "   Result:\n" << sm << "\n"
1523              << "   Expected result:\n(  0 10 )\n( 12 13 )\n(  0 11 )\n";
1524          throw std::runtime_error( oss.str() );
1525       }
1526 
1527       if( tmat_(0,0) != 0 || tmat_(0,1) !=  0 || tmat_(0,2) != 10 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
1528           tmat_(1,0) != 0 || tmat_(1,1) != 12 || tmat_(1,2) != 13 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
1529           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != 11 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
1530           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
1531          std::ostringstream oss;
1532          oss << " Test: " << test_ << "\n"
1533              << " Error: Addition assignment failed\n"
1534              << " Details:\n"
1535              << "   Result:\n" << tmat_ << "\n"
1536              << "   Expected result:\n( 0  0 10  0  7 )\n"
1537                                      "( 0 12 13  4 -8 )\n"
1538                                      "( 0  0 11  5  9 )\n"
1539                                      "( 0  0  0 -6 10 )\n";
1540          throw std::runtime_error( oss.str() );
1541       }
1542    }
1543 
1544 
1545    //=====================================================================================
1546    // Column-major sparse matrix addition assignment
1547    //=====================================================================================
1548 
1549    {
1550       test_ = "Column-major/row-major sparse matrix addition assignment";
1551 
1552       initialize();
1553 
1554       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
1555 
1556       blaze::CompressedMatrix<int,blaze::rowMajor> mat( 3UL, 2UL, 4UL );
1557       mat(1,0) = 11;
1558       mat(0,1) = 12;
1559       mat(1,1) = 13;
1560       mat(2,1) = 14;
1561 
1562       sm += mat;
1563 
1564       checkRows    ( sm   ,  3UL );
1565       checkColumns ( sm   ,  2UL );
1566       checkNonZeros( sm   ,  4UL );
1567       checkRows    ( tmat_,  4UL );
1568       checkColumns ( tmat_,  5UL );
1569       checkNonZeros( tmat_, 11UL );
1570 
1571       if( sm(0,0) !=  0 || sm(0,1) != 10 ||
1572           sm(1,0) != 12 || sm(1,1) != 13 ||
1573           sm(2,0) !=  0 || sm(2,1) != 11 ) {
1574          std::ostringstream oss;
1575          oss << " Test: " << test_ << "\n"
1576              << " Error: Addition assignment failed\n"
1577              << " Details:\n"
1578              << "   Result:\n" << sm << "\n"
1579              << "   Expected result:\n(  0 10 )\n( 12 13 )\n(  0 11 )\n";
1580          throw std::runtime_error( oss.str() );
1581       }
1582 
1583       if( tmat_(0,0) != 0 || tmat_(0,1) !=  0 || tmat_(0,2) != 10 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
1584           tmat_(1,0) != 0 || tmat_(1,1) != 12 || tmat_(1,2) != 13 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
1585           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != 11 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
1586           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
1587          std::ostringstream oss;
1588          oss << " Test: " << test_ << "\n"
1589              << " Error: Addition assignment failed\n"
1590              << " Details:\n"
1591              << "   Result:\n" << tmat_ << "\n"
1592              << "   Expected result:\n( 0  0 10  0  7 )\n"
1593                                      "( 0 12 13  4 -8 )\n"
1594                                      "( 0  0 11  5  9 )\n"
1595                                      "( 0  0  0 -6 10 )\n";
1596          throw std::runtime_error( oss.str() );
1597       }
1598    }
1599 
1600    {
1601       test_ = "Column-major/column-major sparse matrix addition assignment";
1602 
1603       initialize();
1604 
1605       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
1606 
1607       blaze::CompressedMatrix<int,blaze::columnMajor> mat( 3UL, 2UL, 4UL );
1608       mat(1,0) = 11;
1609       mat(0,1) = 12;
1610       mat(1,1) = 13;
1611       mat(2,1) = 14;
1612 
1613       sm += mat;
1614 
1615       checkRows    ( sm   ,  3UL );
1616       checkColumns ( sm   ,  2UL );
1617       checkNonZeros( sm   ,  4UL );
1618       checkRows    ( tmat_,  4UL );
1619       checkColumns ( tmat_,  5UL );
1620       checkNonZeros( tmat_, 11UL );
1621 
1622       if( sm(0,0) !=  0 || sm(0,1) != 10 ||
1623           sm(1,0) != 12 || sm(1,1) != 13 ||
1624           sm(2,0) !=  0 || sm(2,1) != 11 ) {
1625          std::ostringstream oss;
1626          oss << " Test: " << test_ << "\n"
1627              << " Error: Addition assignment failed\n"
1628              << " Details:\n"
1629              << "   Result:\n" << sm << "\n"
1630              << "   Expected result:\n(  0 10 )\n( 12 13 )\n(  0 11 )\n";
1631          throw std::runtime_error( oss.str() );
1632       }
1633 
1634       if( tmat_(0,0) != 0 || tmat_(0,1) !=  0 || tmat_(0,2) != 10 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
1635           tmat_(1,0) != 0 || tmat_(1,1) != 12 || tmat_(1,2) != 13 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
1636           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != 11 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
1637           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
1638          std::ostringstream oss;
1639          oss << " Test: " << test_ << "\n"
1640              << " Error: Addition assignment failed\n"
1641              << " Details:\n"
1642              << "   Result:\n" << tmat_ << "\n"
1643              << "   Expected result:\n( 0  0 10  0  7 )\n"
1644                                      "( 0 12 13  4 -8 )\n"
1645                                      "( 0  0 11  5  9 )\n"
1646                                      "( 0  0  0 -6 10 )\n";
1647          throw std::runtime_error( oss.str() );
1648       }
1649    }
1650 }
1651 //*************************************************************************************************
1652 
1653 
1654 //*************************************************************************************************
1655 /*!\brief Test of the Submatrix subtraction assignment operators.
1656 //
1657 // \return void
1658 // \exception std::runtime_error Error detected.
1659 //
1660 // This function performs a test of the subtraction assignment operators of the Submatrix
1661 // specialization. In case an error is detected, a \a std::runtime_error exception is thrown.
1662 */
testSubAssign()1663 void SparseTest::testSubAssign()
1664 {
1665    //=====================================================================================
1666    // Row-major Submatrix subtraction assignment
1667    //=====================================================================================
1668 
1669    {
1670       test_ = "Row-major Submatrix subtraction assignment (no aliasing)";
1671 
1672       initialize();
1673 
1674       MT mat( 5UL, 4UL, 3UL );
1675       mat(1,0) = 11;
1676       mat(2,0) = 12;
1677       mat(2,2) = 13;
1678 
1679       SMT sm = blaze::submatrix( mat, 1UL, 0UL, 2UL, 3UL );
1680       sm -= blaze::submatrix( mat_, 2UL, 1UL, 2UL, 3UL );
1681 
1682       checkRows    ( sm  ,  2UL );
1683       checkColumns ( sm  ,  3UL );
1684       checkNonZeros( sm  ,  5UL );
1685       checkRows    ( mat_,  5UL );
1686       checkColumns ( mat_,  4UL );
1687       checkNonZeros( mat_, 10UL );
1688       checkRows    ( mat ,  5UL );
1689       checkColumns ( mat ,  4UL );
1690       checkNonZeros( mat ,  5UL );
1691 
1692       if( sm(0,0) != 11 || sm(0,1) !=  3 || sm(0,2) !=  0 ||
1693           sm(1,0) !=  8 || sm(1,1) != -5 || sm(1,2) != 19 ) {
1694          std::ostringstream oss;
1695          oss << " Test: " << test_ << "\n"
1696              << " Error: Subtraction assignment failed\n"
1697              << " Details:\n"
1698              << "   Result:\n" << sm << "\n"
1699              << "   Expected result:\n( 11  3  0 )\n(  8 -5 19 )\n";
1700          throw std::runtime_error( oss.str() );
1701       }
1702 
1703       if( mat(0,0) !=  0 || mat(0,1) !=  0 || mat(0,2) !=  0 || mat(0,3) != 0 ||
1704           mat(1,0) != 11 || mat(1,1) !=  3 || mat(1,2) !=  0 || mat(1,3) != 0 ||
1705           mat(2,0) !=  8 || mat(2,1) != -5 || mat(2,2) != 19 || mat(2,3) != 0 ||
1706           mat(3,0) !=  0 || mat(3,1) !=  0 || mat(3,2) !=  0 || mat(3,3) != 0 ||
1707           mat(4,0) !=  0 || mat(4,1) !=  0 || mat(4,2) !=  0 || mat(4,3) != 0 ) {
1708          std::ostringstream oss;
1709          oss << " Test: " << test_ << "\n"
1710              << " Error: Subtraction assignment failed\n"
1711              << " Details:\n"
1712              << "   Result:\n" << mat << "\n"
1713              << "   Expected result:\n(  0  0  0  0 )\n"
1714                                      "( 11  3  0  0 )\n"
1715                                      "(  8 -5 19  0 )\n"
1716                                      "(  0  0  0  0 )\n"
1717                                      "(  0  0  0  0 )\n";
1718          throw std::runtime_error( oss.str() );
1719       }
1720    }
1721 
1722    {
1723       test_ = "Row-major Submatrix subtraction assignment (aliasing)";
1724 
1725       initialize();
1726 
1727       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
1728       sm -= blaze::submatrix( mat_, 2UL, 1UL, 2UL, 3UL );
1729 
1730       checkRows    ( sm  ,  2UL );
1731       checkColumns ( sm  ,  3UL );
1732       checkNonZeros( sm  ,  4UL );
1733       checkRows    ( mat_,  5UL );
1734       checkColumns ( mat_,  4UL );
1735       checkNonZeros( mat_, 11UL );
1736 
1737       if( sm(0,0) !=  0 || sm(0,1) !=  4 || sm(0,2) != 0 ||
1738           sm(1,0) != -6 || sm(1,1) != -5 || sm(1,2) != 3 ) {
1739          std::ostringstream oss;
1740          oss << " Test: " << test_ << "\n"
1741              << " Error: Subtraction assignment failed\n"
1742              << " Details:\n"
1743              << "   Result:\n" << sm << "\n"
1744              << "   Expected result:\n(  0  4  0 )\n( -6 -5  3 )\n";
1745          throw std::runtime_error( oss.str() );
1746       }
1747 
1748       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) != 0 || mat_(0,3) !=  0 ||
1749           mat_(1,0) !=  0 || mat_(1,1) !=  4 || mat_(1,2) != 0 || mat_(1,3) !=  0 ||
1750           mat_(2,0) != -6 || mat_(2,1) != -5 || mat_(2,2) != 3 || mat_(2,3) !=  0 ||
1751           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) != 5 || mat_(3,3) != -6 ||
1752           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) != 9 || mat_(4,3) != 10 ) {
1753          std::ostringstream oss;
1754          oss << " Test: " << test_ << "\n"
1755              << " Error: Subtraction assignment failed\n"
1756              << " Details:\n"
1757              << "   Result:\n" << mat_ << "\n"
1758              << "   Expected result:\n(  0  0  0  0 )\n"
1759                                      "(  0  4  0  0 )\n"
1760                                      "( -6 -5  3  0 )\n"
1761                                      "(  0  4  5 -6 )\n"
1762                                      "(  7 -8  9 10 )\n";
1763          throw std::runtime_error( oss.str() );
1764       }
1765    }
1766 
1767 
1768    //=====================================================================================
1769    // Row-major dense matrix subtraction assignment
1770    //=====================================================================================
1771 
1772    {
1773       test_ = "Row-major/row-major dense matrix subtraction assignment";
1774 
1775       initialize();
1776 
1777       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
1778 
1779       blaze::DynamicMatrix<int,blaze::rowMajor> mat{ {   0, -11,   0 },
1780                                                      { -12, -13, -14 } };
1781 
1782       sm -= mat;
1783 
1784       checkRows    ( sm  ,  2UL );
1785       checkColumns ( sm  ,  3UL );
1786       checkNonZeros( sm  ,  4UL );
1787       checkRows    ( mat_,  5UL );
1788       checkColumns ( mat_,  4UL );
1789       checkNonZeros( mat_, 11UL );
1790 
1791       if( sm(0,0) !=  0 || sm(0,1) != 12 || sm(0,2) !=  0 ||
1792           sm(1,0) != 10 || sm(1,1) != 13 || sm(1,2) != 11 ) {
1793          std::ostringstream oss;
1794          oss << " Test: " << test_ << "\n"
1795              << " Error: Subtraction assignment failed\n"
1796              << " Details:\n"
1797              << "   Result:\n" << sm << "\n"
1798              << "   Expected result:\n(  0 12  0 )\n( 12 13 14 )\n";
1799          throw std::runtime_error( oss.str() );
1800       }
1801 
1802       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1803           mat_(1,0) !=  0 || mat_(1,1) != 12 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
1804           mat_(2,0) != 10 || mat_(2,1) != 13 || mat_(2,2) != 11 || mat_(2,3) !=  0 ||
1805           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
1806           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1807          std::ostringstream oss;
1808          oss << " Test: " << test_ << "\n"
1809              << " Error: Subtraction assignment failed\n"
1810              << " Details:\n"
1811              << "   Result:\n" << mat_ << "\n"
1812              << "   Expected result:\n(  0  0  0  0 )\n"
1813                                      "(  0 12  0  0 )\n"
1814                                      "( 10 13 11  0 )\n"
1815                                      "(  0  4  5 -6 )\n"
1816                                      "(  7 -8  9 10 )\n";
1817          throw std::runtime_error( oss.str() );
1818       }
1819    }
1820 
1821    {
1822       test_ = "Row-major/column-major dense matrix subtraction assignment";
1823 
1824       initialize();
1825 
1826       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
1827 
1828       blaze::DynamicMatrix<int,blaze::columnMajor> mat{ {   0, -11,   0 },
1829                                                         { -12, -13, -14 } };
1830 
1831       sm -= mat;
1832 
1833       checkRows    ( sm  ,  2UL );
1834       checkColumns ( sm  ,  3UL );
1835       checkNonZeros( sm  ,  4UL );
1836       checkRows    ( mat_,  5UL );
1837       checkColumns ( mat_,  4UL );
1838       checkNonZeros( mat_, 11UL );
1839 
1840       if( sm(0,0) !=  0 || sm(0,1) != 12 || sm(0,2) !=  0 ||
1841           sm(1,0) != 10 || sm(1,1) != 13 || sm(1,2) != 11 ) {
1842          std::ostringstream oss;
1843          oss << " Test: " << test_ << "\n"
1844              << " Error: Subtraction assignment failed\n"
1845              << " Details:\n"
1846              << "   Result:\n" << sm << "\n"
1847              << "   Expected result:\n(  0 12  0 )\n( 10 13 11 )\n";
1848          throw std::runtime_error( oss.str() );
1849       }
1850 
1851       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1852           mat_(1,0) !=  0 || mat_(1,1) != 12 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
1853           mat_(2,0) != 10 || mat_(2,1) != 13 || mat_(2,2) != 11 || mat_(2,3) !=  0 ||
1854           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
1855           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1856          std::ostringstream oss;
1857          oss << " Test: " << test_ << "\n"
1858              << " Error: Subtraction assignment failed\n"
1859              << " Details:\n"
1860              << "   Result:\n" << mat_ << "\n"
1861              << "   Expected result:\n(  0  0  0  0 )\n"
1862                                      "(  0 12  0  0 )\n"
1863                                      "( 10 13 11  0 )\n"
1864                                      "(  0  4  5 -6 )\n"
1865                                      "(  7 -8  9 10 )\n";
1866          throw std::runtime_error( oss.str() );
1867       }
1868    }
1869 
1870 
1871    //=====================================================================================
1872    // Row-major sparse matrix subtraction assignment
1873    //=====================================================================================
1874 
1875    {
1876       test_ = "Row-major/row-major sparse matrix subtraction assignment";
1877 
1878       initialize();
1879 
1880       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
1881 
1882       blaze::CompressedMatrix<int,blaze::rowMajor> mat( 2UL, 3UL, 4UL );
1883       mat(0,1) = -11;
1884       mat(1,0) = -12;
1885       mat(1,1) = -13;
1886       mat(1,2) = -14;
1887 
1888       sm -= mat;
1889 
1890       checkRows    ( sm  ,  2UL );
1891       checkColumns ( sm  ,  3UL );
1892       checkNonZeros( sm  ,  4UL );
1893       checkRows    ( mat_,  5UL );
1894       checkColumns ( mat_,  4UL );
1895       checkNonZeros( mat_, 11UL );
1896 
1897       if( sm(0,0) !=  0 || sm(0,1) != 12 || sm(0,2) !=  0 ||
1898           sm(1,0) != 10 || sm(1,1) != 13 || sm(1,2) != 11 ) {
1899          std::ostringstream oss;
1900          oss << " Test: " << test_ << "\n"
1901              << " Error: Subtraction assignment failed\n"
1902              << " Details:\n"
1903              << "   Result:\n" << sm << "\n"
1904              << "   Expected result:\n(  0 12  0 )\n( 12 13 14 )\n";
1905          throw std::runtime_error( oss.str() );
1906       }
1907 
1908       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1909           mat_(1,0) !=  0 || mat_(1,1) != 12 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
1910           mat_(2,0) != 10 || mat_(2,1) != 13 || mat_(2,2) != 11 || mat_(2,3) !=  0 ||
1911           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
1912           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1913          std::ostringstream oss;
1914          oss << " Test: " << test_ << "\n"
1915              << " Error: Subtraction assignment failed\n"
1916              << " Details:\n"
1917              << "   Result:\n" << mat_ << "\n"
1918              << "   Expected result:\n(  0  0  0  0 )\n"
1919                                      "(  0 12  0  0 )\n"
1920                                      "( 10 13 11  0 )\n"
1921                                      "(  0  4  5 -6 )\n"
1922                                      "(  7 -8  9 10 )\n";
1923          throw std::runtime_error( oss.str() );
1924       }
1925    }
1926 
1927    {
1928       test_ = "Row-major/column-major sparse matrix subtraction assignment";
1929 
1930       initialize();
1931 
1932       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
1933 
1934       blaze::CompressedMatrix<int,blaze::columnMajor> mat( 2UL, 3UL, 4UL );
1935       mat(0,1) = -11;
1936       mat(1,0) = -12;
1937       mat(1,1) = -13;
1938       mat(1,2) = -14;
1939 
1940       sm -= mat;
1941 
1942       checkRows    ( sm  ,  2UL );
1943       checkColumns ( sm  ,  3UL );
1944       checkNonZeros( sm  ,  4UL );
1945       checkRows    ( mat_,  5UL );
1946       checkColumns ( mat_,  4UL );
1947       checkNonZeros( mat_, 11UL );
1948 
1949       if( sm(0,0) !=  0 || sm(0,1) != 12 || sm(0,2) !=  0 ||
1950           sm(1,0) != 10 || sm(1,1) != 13 || sm(1,2) != 11 ) {
1951          std::ostringstream oss;
1952          oss << " Test: " << test_ << "\n"
1953              << " Error: Subtraction assignment failed\n"
1954              << " Details:\n"
1955              << "   Result:\n" << sm << "\n"
1956              << "   Expected result:\n(  0 12  0 )\n( 12 13 14 )\n";
1957          throw std::runtime_error( oss.str() );
1958       }
1959 
1960       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
1961           mat_(1,0) !=  0 || mat_(1,1) != 12 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
1962           mat_(2,0) != 10 || mat_(2,1) != 13 || mat_(2,2) != 11 || mat_(2,3) !=  0 ||
1963           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
1964           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
1965          std::ostringstream oss;
1966          oss << " Test: " << test_ << "\n"
1967              << " Error: Subtraction assignment failed\n"
1968              << " Details:\n"
1969              << "   Result:\n" << mat_ << "\n"
1970              << "   Expected result:\n(  0  0  0  0 )\n"
1971                                      "(  0 12  0  0 )\n"
1972                                      "( 10 13 11  0 )\n"
1973                                      "(  0  4  5 -6 )\n"
1974                                      "(  7 -8  9 10 )\n";
1975          throw std::runtime_error( oss.str() );
1976       }
1977    }
1978 
1979 
1980    //=====================================================================================
1981    // Column-major Submatrix subtraction assignment
1982    //=====================================================================================
1983 
1984    {
1985       test_ = "Column-major Submatrix subtraction assignment (no aliasing)";
1986 
1987       initialize();
1988 
1989       OMT mat( 4UL, 5UL, 3UL );
1990       mat(0,1) = 11;
1991       mat(0,2) = 12;
1992       mat(2,2) = 13;
1993 
1994       OSMT sm = blaze::submatrix( mat, 0UL, 1UL, 3UL, 2UL );
1995       sm -= blaze::submatrix( tmat_, 1UL, 2UL, 3UL, 2UL );
1996 
1997       checkRows    ( sm   ,  3UL );
1998       checkColumns ( sm   ,  2UL );
1999       checkNonZeros( sm   ,  5UL );
2000       checkRows    ( tmat_,  4UL );
2001       checkColumns ( tmat_,  5UL );
2002       checkNonZeros( tmat_, 10UL );
2003       checkRows    ( mat  ,  4UL );
2004       checkColumns ( mat  ,  5UL );
2005       checkNonZeros( mat  ,  5UL );
2006 
2007       if( sm(0,0) != 11 || sm(0,1) !=  8 ||
2008           sm(1,0) !=  3 || sm(1,1) != -5 ||
2009           sm(2,0) !=  0 || sm(2,1) != 19 ) {
2010          std::ostringstream oss;
2011          oss << " Test: " << test_ << "\n"
2012              << " Error: Subtraction assignment failed\n"
2013              << " Details:\n"
2014              << "   Result:\n" << sm << "\n"
2015              << "   Expected result:\n( 11  8 )\n(  3 -5 )\n(  0 19 )\n";
2016          throw std::runtime_error( oss.str() );
2017       }
2018 
2019       if( mat(0,0) != 0 || mat(0,1) != 11 || mat(0,2) !=  8 || mat(0,3) != 0 || mat(0,4) != 0 ||
2020           mat(1,0) != 0 || mat(1,1) !=  3 || mat(1,2) != -5 || mat(1,3) != 0 || mat(1,4) != 0 ||
2021           mat(2,0) != 0 || mat(2,1) !=  0 || mat(2,2) != 19 || mat(2,3) != 0 || mat(2,4) != 0 ||
2022           mat(3,0) != 0 || mat(3,1) !=  0 || mat(3,2) !=  0 || mat(3,3) != 0 || mat(3,4) != 0 ) {
2023          std::ostringstream oss;
2024          oss << " Test: " << test_ << "\n"
2025              << " Error: Subtraction assignment failed\n"
2026              << " Details:\n"
2027              << "   Result:\n" << mat << "\n"
2028              << "   Expected result:\n( 0 11  8  0  0 )\n"
2029                                      "( 0  3 -5  0  0 )\n"
2030                                      "( 0  0 19  0  0 )\n"
2031                                      "( 0  0  0  0  0 )\n";
2032          throw std::runtime_error( oss.str() );
2033       }
2034    }
2035 
2036    {
2037       test_ = "Column-major Submatrix subtraction assignment (aliasing)";
2038 
2039       initialize();
2040 
2041       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
2042       sm -= blaze::submatrix( tmat_, 1UL, 2UL, 3UL, 2UL );
2043 
2044       checkRows    ( sm   ,  3UL );
2045       checkColumns ( sm   ,  2UL );
2046       checkNonZeros( sm   ,  4UL );
2047       checkRows    ( tmat_,  4UL );
2048       checkColumns ( tmat_,  5UL );
2049       checkNonZeros( tmat_, 11UL );
2050 
2051       if( sm(0,0) != 0 || sm(0,1) != -6 ||
2052           sm(1,0) != 4 || sm(1,1) != -5 ||
2053           sm(2,0) != 0 || sm(2,1) !=  3 ) {
2054          std::ostringstream oss;
2055          oss << " Test: " << test_ << "\n"
2056              << " Error: Subtraction assignment failed\n"
2057              << " Details:\n"
2058              << "   Result:\n" << sm << "\n"
2059              << "   Expected result:\n( 0 -6 )\n( 4 -5 )\n( 0  3 )\n";
2060          throw std::runtime_error( oss.str() );
2061       }
2062 
2063       if( tmat_(0,0) != 0 || tmat_(0,1) != 0 || tmat_(0,2) != -6 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
2064           tmat_(1,0) != 0 || tmat_(1,1) != 4 || tmat_(1,2) != -5 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
2065           tmat_(2,0) != 0 || tmat_(2,1) != 0 || tmat_(2,2) !=  3 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
2066           tmat_(3,0) != 0 || tmat_(3,1) != 0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
2067          std::ostringstream oss;
2068          oss << " Test: " << test_ << "\n"
2069              << " Error: Subtraction assignment failed\n"
2070              << " Details:\n"
2071              << "   Result:\n" << tmat_ << "\n"
2072              << "   Expected result:\n( 0  0 -6  0  7 )\n"
2073                                      "( 0  4 -5  4 -8 )\n"
2074                                      "( 0  0  3  5  9 )\n"
2075                                      "( 0  0  0 -6 10 )\n";
2076          throw std::runtime_error( oss.str() );
2077       }
2078    }
2079 
2080 
2081    //=====================================================================================
2082    // Column-major dense matrix subtraction assignment
2083    //=====================================================================================
2084 
2085    {
2086       test_ = "Column-major/row-major dense matrix subtraction assignment";
2087 
2088       initialize();
2089 
2090       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
2091 
2092       blaze::DynamicMatrix<int,blaze::rowMajor> mat{ {   0, -12 },
2093                                                      { -11, -13 },
2094                                                      {   0, -14 } };
2095 
2096       sm -= mat;
2097 
2098       checkRows    ( sm   ,  3UL );
2099       checkColumns ( sm   ,  2UL );
2100       checkNonZeros( sm   ,  4UL );
2101       checkRows    ( tmat_,  4UL );
2102       checkColumns ( tmat_,  5UL );
2103       checkNonZeros( tmat_, 11UL );
2104 
2105       if( sm(0,0) !=  0 || sm(0,1) != 10 ||
2106           sm(1,0) != 12 || sm(1,1) != 13 ||
2107           sm(2,0) !=  0 || sm(2,1) != 11 ) {
2108          std::ostringstream oss;
2109          oss << " Test: " << test_ << "\n"
2110              << " Error: Subtraction assignment failed\n"
2111              << " Details:\n"
2112              << "   Result:\n" << sm << "\n"
2113              << "   Expected result:\n(  0 10 )\n( 12 13 )\n(  0 11 )\n";
2114          throw std::runtime_error( oss.str() );
2115       }
2116 
2117       if( tmat_(0,0) != 0 || tmat_(0,1) !=  0 || tmat_(0,2) != 10 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
2118           tmat_(1,0) != 0 || tmat_(1,1) != 12 || tmat_(1,2) != 13 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
2119           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != 11 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
2120           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
2121          std::ostringstream oss;
2122          oss << " Test: " << test_ << "\n"
2123              << " Error: Subtraction assignment failed\n"
2124              << " Details:\n"
2125              << "   Result:\n" << tmat_ << "\n"
2126              << "   Expected result:\n( 0  0 10  0  7 )\n"
2127                                      "( 0 12 13  4 -8 )\n"
2128                                      "( 0  0 11  5  9 )\n"
2129                                      "( 0  0  0 -6 10 )\n";
2130          throw std::runtime_error( oss.str() );
2131       }
2132    }
2133 
2134    {
2135       test_ = "Column-major/column-major dense matrix subtraction assignment";
2136 
2137       initialize();
2138 
2139       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
2140 
2141       blaze::DynamicMatrix<int,blaze::columnMajor> mat{ {   0, -12 },
2142                                                         { -11, -13 },
2143                                                         {   0, -14 } };
2144 
2145       sm -= mat;
2146 
2147       checkRows    ( sm   ,  3UL );
2148       checkColumns ( sm   ,  2UL );
2149       checkNonZeros( sm   ,  4UL );
2150       checkRows    ( tmat_,  4UL );
2151       checkColumns ( tmat_,  5UL );
2152       checkNonZeros( tmat_, 11UL );
2153 
2154       if( sm(0,0) !=  0 || sm(0,1) != 10 ||
2155           sm(1,0) != 12 || sm(1,1) != 13 ||
2156           sm(2,0) !=  0 || sm(2,1) != 11 ) {
2157          std::ostringstream oss;
2158          oss << " Test: " << test_ << "\n"
2159              << " Error: Subtraction assignment failed\n"
2160              << " Details:\n"
2161              << "   Result:\n" << sm << "\n"
2162              << "   Expected result:\n(  0 10 )\n( 12 13 )\n(  0 11 )\n";
2163          throw std::runtime_error( oss.str() );
2164       }
2165 
2166       if( tmat_(0,0) != 0 || tmat_(0,1) !=  0 || tmat_(0,2) != 10 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
2167           tmat_(1,0) != 0 || tmat_(1,1) != 12 || tmat_(1,2) != 13 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
2168           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != 11 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
2169           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
2170          std::ostringstream oss;
2171          oss << " Test: " << test_ << "\n"
2172              << " Error: Subtraction assignment failed\n"
2173              << " Details:\n"
2174              << "   Result:\n" << tmat_ << "\n"
2175              << "   Expected result:\n( 0  0 10  0  7 )\n"
2176                                      "( 0 12 13  4 -8 )\n"
2177                                      "( 0  0 11  5  9 )\n"
2178                                      "( 0  0  0 -6 10 )\n";
2179          throw std::runtime_error( oss.str() );
2180       }
2181    }
2182 
2183 
2184    //=====================================================================================
2185    // Column-major sparse matrix subtraction assignment
2186    //=====================================================================================
2187 
2188    {
2189       test_ = "Column-major/row-major sparse matrix subtraction assignment";
2190 
2191       initialize();
2192 
2193       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
2194 
2195       blaze::CompressedMatrix<int,blaze::rowMajor> mat( 3UL, 2UL, 4UL );
2196       mat(1,0) = -11;
2197       mat(0,1) = -12;
2198       mat(1,1) = -13;
2199       mat(2,1) = -14;
2200 
2201       sm -= mat;
2202 
2203       checkRows    ( sm   ,  3UL );
2204       checkColumns ( sm   ,  2UL );
2205       checkNonZeros( sm   ,  4UL );
2206       checkRows    ( tmat_,  4UL );
2207       checkColumns ( tmat_,  5UL );
2208       checkNonZeros( tmat_, 11UL );
2209 
2210       if( sm(0,0) !=  0 || sm(0,1) != 10 ||
2211           sm(1,0) != 12 || sm(1,1) != 13 ||
2212           sm(2,0) !=  0 || sm(2,1) != 11 ) {
2213          std::ostringstream oss;
2214          oss << " Test: " << test_ << "\n"
2215              << " Error: Subtraction assignment failed\n"
2216              << " Details:\n"
2217              << "   Result:\n" << sm << "\n"
2218              << "   Expected result:\n(  0 10 )\n( 12 13 )\n(  0 11 )\n";
2219          throw std::runtime_error( oss.str() );
2220       }
2221 
2222       if( tmat_(0,0) != 0 || tmat_(0,1) !=  0 || tmat_(0,2) != 10 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
2223           tmat_(1,0) != 0 || tmat_(1,1) != 12 || tmat_(1,2) != 13 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
2224           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != 11 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
2225           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
2226          std::ostringstream oss;
2227          oss << " Test: " << test_ << "\n"
2228              << " Error: Subtraction assignment failed\n"
2229              << " Details:\n"
2230              << "   Result:\n" << tmat_ << "\n"
2231              << "   Expected result:\n( 0  0 10  0  7 )\n"
2232                                      "( 0 12 13  4 -8 )\n"
2233                                      "( 0  0 11  5  9 )\n"
2234                                      "( 0  0  0 -6 10 )\n";
2235          throw std::runtime_error( oss.str() );
2236       }
2237    }
2238 
2239    {
2240       test_ = "Column-major/column-major sparse matrix subtraction assignment";
2241 
2242       initialize();
2243 
2244       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
2245 
2246       blaze::CompressedMatrix<int,blaze::columnMajor> mat( 3UL, 2UL, 4UL );
2247       mat(1,0) = -11;
2248       mat(0,1) = -12;
2249       mat(1,1) = -13;
2250       mat(2,1) = -14;
2251 
2252       sm -= mat;
2253 
2254       checkRows    ( sm   ,  3UL );
2255       checkColumns ( sm   ,  2UL );
2256       checkNonZeros( sm   ,  4UL );
2257       checkRows    ( tmat_,  4UL );
2258       checkColumns ( tmat_,  5UL );
2259       checkNonZeros( tmat_, 11UL );
2260 
2261       if( sm(0,0) !=  0 || sm(0,1) != 10 ||
2262           sm(1,0) != 12 || sm(1,1) != 13 ||
2263           sm(2,0) !=  0 || sm(2,1) != 11 ) {
2264          std::ostringstream oss;
2265          oss << " Test: " << test_ << "\n"
2266              << " Error: Subtraction assignment failed\n"
2267              << " Details:\n"
2268              << "   Result:\n" << sm << "\n"
2269              << "   Expected result:\n(  0 10 )\n( 12 13 )\n(  0 11 )\n";
2270          throw std::runtime_error( oss.str() );
2271       }
2272 
2273       if( tmat_(0,0) != 0 || tmat_(0,1) !=  0 || tmat_(0,2) != 10 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
2274           tmat_(1,0) != 0 || tmat_(1,1) != 12 || tmat_(1,2) != 13 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
2275           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != 11 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
2276           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
2277          std::ostringstream oss;
2278          oss << " Test: " << test_ << "\n"
2279              << " Error: Subtraction assignment failed\n"
2280              << " Details:\n"
2281              << "   Result:\n" << tmat_ << "\n"
2282              << "   Expected result:\n( 0  0 10  0  7 )\n"
2283                                      "( 0 12 13  4 -8 )\n"
2284                                      "( 0  0 11  5  9 )\n"
2285                                      "( 0  0  0 -6 10 )\n";
2286          throw std::runtime_error( oss.str() );
2287       }
2288    }
2289 }
2290 //*************************************************************************************************
2291 
2292 
2293 //*************************************************************************************************
2294 /*!\brief Test of the Submatrix Schur product assignment operators.
2295 //
2296 // \return void
2297 // \exception std::runtime_error Error detected.
2298 //
2299 // This function performs a test of the Schur product assignment operators of the Submatrix
2300 // specialization. In case an error is detected, a \a std::runtime_error exception is thrown.
2301 */
testSchurAssign()2302 void SparseTest::testSchurAssign()
2303 {
2304    //=====================================================================================
2305    // Row-major Submatrix Schur product assignment
2306    //=====================================================================================
2307 
2308    {
2309       test_ = "Row-major Submatrix Schur product assignment (no aliasing)";
2310 
2311       initialize();
2312 
2313       MT mat( 5UL, 4UL, 3UL );
2314       mat(1,0) = 1;
2315       mat(2,0) = 2;
2316       mat(2,2) = 3;
2317 
2318       SMT sm = blaze::submatrix( mat, 1UL, 0UL, 2UL, 3UL );
2319       sm %= blaze::submatrix( mat_, 2UL, 1UL, 2UL, 3UL );
2320 
2321       checkRows    ( sm  ,  2UL );
2322       checkColumns ( sm  ,  3UL );
2323       checkNonZeros( sm  ,  2UL );
2324       checkRows    ( mat_,  5UL );
2325       checkColumns ( mat_,  4UL );
2326       checkNonZeros( mat_, 10UL );
2327       checkRows    ( mat ,  5UL );
2328       checkColumns ( mat ,  4UL );
2329       checkNonZeros( mat ,  2UL );
2330 
2331       if( sm(0,0) != 0 || sm(0,1) != 0 || sm(0,2) !=   0 ||
2332           sm(1,0) != 8 || sm(1,1) != 0 || sm(1,2) != -18 ) {
2333          std::ostringstream oss;
2334          oss << " Test: " << test_ << "\n"
2335              << " Error: Schur product assignment failed\n"
2336              << " Details:\n"
2337              << "   Result:\n" << sm << "\n"
2338              << "   Expected result:\n( 0  0   0 )\n( 8  0 -18 )\n";
2339          throw std::runtime_error( oss.str() );
2340       }
2341 
2342       if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) !=   0 || mat(0,3) != 0 ||
2343           mat(1,0) != 0 || mat(1,1) != 0 || mat(1,2) !=   0 || mat(1,3) != 0 ||
2344           mat(2,0) != 8 || mat(2,1) != 0 || mat(2,2) != -18 || mat(2,3) != 0 ||
2345           mat(3,0) != 0 || mat(3,1) != 0 || mat(3,2) !=   0 || mat(3,3) != 0 ||
2346           mat(4,0) != 0 || mat(4,1) != 0 || mat(4,2) !=   0 || mat(4,3) != 0 ) {
2347          std::ostringstream oss;
2348          oss << " Test: " << test_ << "\n"
2349              << " Error: Schur product assignment failed\n"
2350              << " Details:\n"
2351              << "   Result:\n" << mat << "\n"
2352              << "   Expected result:\n( 0  0   0  0 )\n"
2353                                      "( 0  0   0  0 )\n"
2354                                      "( 8  0 -18  0 )\n"
2355                                      "( 0  0   0  0 )\n"
2356                                      "( 0  0   0  0 )\n";
2357          throw std::runtime_error( oss.str() );
2358       }
2359    }
2360 
2361    {
2362       test_ = "Row-major Submatrix Schur product assignment (aliasing)";
2363 
2364       initialize();
2365 
2366       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
2367       sm %= blaze::submatrix( mat_, 2UL, 1UL, 2UL, 3UL );
2368 
2369       checkRows    ( sm  ,  2UL );
2370       checkColumns ( sm  ,  3UL );
2371       checkNonZeros( sm  ,  3UL );
2372       checkRows    ( mat_,  5UL );
2373       checkColumns ( mat_,  4UL );
2374       checkNonZeros( mat_, 10UL );
2375 
2376       if( sm(0,0) !=  0 || sm(0,1) != -3 || sm(0,2) !=  0 ||
2377           sm(1,0) != -8 || sm(1,1) !=  0 || sm(1,2) != 18 ) {
2378          std::ostringstream oss;
2379          oss << " Test: " << test_ << "\n"
2380              << " Error: Schur product assignment failed\n"
2381              << " Details:\n"
2382              << "   Result:\n" << sm << "\n"
2383              << "   Expected result:\n(  0 -3  0 )\n( -8  0 18 )\n";
2384          throw std::runtime_error( oss.str() );
2385       }
2386 
2387       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
2388           mat_(1,0) !=  0 || mat_(1,1) != -3 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
2389           mat_(2,0) != -8 || mat_(2,1) !=  0 || mat_(2,2) != 18 || mat_(2,3) !=  0 ||
2390           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
2391           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
2392          std::ostringstream oss;
2393          oss << " Test: " << test_ << "\n"
2394              << " Error: Schur product assignment failed\n"
2395              << " Details:\n"
2396              << "   Result:\n" << mat_ << "\n"
2397              << "   Expected result:\n(  0  0  0  0 )\n"
2398                                      "(  0 -3  0  0 )\n"
2399                                      "( -8  0 18  0 )\n"
2400                                      "(  0  4  5 -6 )\n"
2401                                      "(  7 -8  9 10 )\n";
2402          throw std::runtime_error( oss.str() );
2403       }
2404    }
2405 
2406 
2407    //=====================================================================================
2408    // Row-major dense matrix Schur product assignment
2409    //=====================================================================================
2410 
2411    {
2412       test_ = "Row-major/row-major dense matrix Schur product assignment";
2413 
2414       initialize();
2415 
2416       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
2417 
2418       blaze::DynamicMatrix<int,blaze::rowMajor> mat{ { 0, 1, 0 },
2419                                                      { 2, 3, 4 } };
2420 
2421       sm %= mat;
2422 
2423       checkRows    ( sm  ,  2UL );
2424       checkColumns ( sm  ,  3UL );
2425       checkNonZeros( sm  ,  3UL );
2426       checkRows    ( mat_,  5UL );
2427       checkColumns ( mat_,  4UL );
2428       checkNonZeros( mat_, 10UL );
2429 
2430       if( sm(0,0) !=  0 || sm(0,1) != 1 || sm(0,2) !=   0 ||
2431           sm(1,0) != -4 || sm(1,1) != 0 || sm(1,2) != -12 ) {
2432          std::ostringstream oss;
2433          oss << " Test: " << test_ << "\n"
2434              << " Error: Schur product assignment failed\n"
2435              << " Details:\n"
2436              << "   Result:\n" << sm << "\n"
2437              << "   Expected result:\n(  0  1   0 )\n( -4  0 -12 )\n";
2438          throw std::runtime_error( oss.str() );
2439       }
2440 
2441       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=   0 || mat_(0,3) !=  0 ||
2442           mat_(1,0) !=  0 || mat_(1,1) !=  1 || mat_(1,2) !=   0 || mat_(1,3) !=  0 ||
2443           mat_(2,0) != -4 || mat_(2,1) !=  0 || mat_(2,2) != -12 || mat_(2,3) !=  0 ||
2444           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=   5 || mat_(3,3) != -6 ||
2445           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=   9 || mat_(4,3) != 10 ) {
2446          std::ostringstream oss;
2447          oss << " Test: " << test_ << "\n"
2448              << " Error: Schur product assignment failed\n"
2449              << " Details:\n"
2450              << "   Result:\n" << mat_ << "\n"
2451              << "   Expected result:\n(  0  0   0  0 )\n"
2452                                      "(  0  1   0  0 )\n"
2453                                      "( -4  0 -12  0 )\n"
2454                                      "(  0  4   5 -6 )\n"
2455                                      "(  7 -8   9 10 )\n";
2456          throw std::runtime_error( oss.str() );
2457       }
2458    }
2459 
2460    {
2461       test_ = "Row-major/column-major dense matrix Schur product assignment";
2462 
2463       initialize();
2464 
2465       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
2466 
2467       blaze::DynamicMatrix<int,blaze::columnMajor> mat{ { 0, 1, 0 },
2468                                                         { 2, 3, 4 } };
2469 
2470       sm %= mat;
2471 
2472       checkRows    ( sm  ,  2UL );
2473       checkColumns ( sm  ,  3UL );
2474       checkNonZeros( sm  ,  3UL );
2475       checkRows    ( mat_,  5UL );
2476       checkColumns ( mat_,  4UL );
2477       checkNonZeros( mat_, 10UL );
2478 
2479       if( sm(0,0) !=  0 || sm(0,1) != 1 || sm(0,2) !=   0 ||
2480           sm(1,0) != -4 || sm(1,1) != 0 || sm(1,2) != -12 ) {
2481          std::ostringstream oss;
2482          oss << " Test: " << test_ << "\n"
2483              << " Error: Schur product assignment failed\n"
2484              << " Details:\n"
2485              << "   Result:\n" << sm << "\n"
2486              << "   Expected result:\n(  0  1   0 )\n( -4  0 -12 )\n";
2487          throw std::runtime_error( oss.str() );
2488       }
2489 
2490       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=   0 || mat_(0,3) !=  0 ||
2491           mat_(1,0) !=  0 || mat_(1,1) !=  1 || mat_(1,2) !=   0 || mat_(1,3) !=  0 ||
2492           mat_(2,0) != -4 || mat_(2,1) !=  0 || mat_(2,2) != -12 || mat_(2,3) !=  0 ||
2493           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=   5 || mat_(3,3) != -6 ||
2494           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=   9 || mat_(4,3) != 10 ) {
2495          std::ostringstream oss;
2496          oss << " Test: " << test_ << "\n"
2497              << " Error: Schur product assignment failed\n"
2498              << " Details:\n"
2499              << "   Result:\n" << mat_ << "\n"
2500              << "   Expected result:\n(  0  0   0  0 )\n"
2501                                      "(  0  1   0  0 )\n"
2502                                      "( -4  0 -12  0 )\n"
2503                                      "(  0  4   5 -6 )\n"
2504                                      "(  7 -8   9 10 )\n";
2505          throw std::runtime_error( oss.str() );
2506       }
2507    }
2508 
2509 
2510    //=====================================================================================
2511    // Row-major sparse matrix Schur product assignment
2512    //=====================================================================================
2513 
2514    {
2515       test_ = "Row-major/row-major sparse matrix Schur product assignment";
2516 
2517       initialize();
2518 
2519       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
2520 
2521       blaze::CompressedMatrix<int,blaze::rowMajor> mat( 2UL, 3UL, 4UL );
2522       mat(0,1) = 1;
2523       mat(1,0) = 2;
2524       mat(1,1) = 3;
2525       mat(1,2) = 4;
2526 
2527       sm %= mat;
2528 
2529       checkRows    ( sm  ,  2UL );
2530       checkColumns ( sm  ,  3UL );
2531       checkNonZeros( sm  ,  3UL );
2532       checkRows    ( mat_,  5UL );
2533       checkColumns ( mat_,  4UL );
2534       checkNonZeros( mat_, 10UL );
2535 
2536       if( sm(0,0) !=  0 || sm(0,1) != 1 || sm(0,2) !=   0 ||
2537           sm(1,0) != -4 || sm(1,1) != 0 || sm(1,2) != -12 ) {
2538          std::ostringstream oss;
2539          oss << " Test: " << test_ << "\n"
2540              << " Error: Schur product assignment failed\n"
2541              << " Details:\n"
2542              << "   Result:\n" << sm << "\n"
2543              << "   Expected result:\n(  0  1   0 )\n( -4  0 -12 )\n";
2544          throw std::runtime_error( oss.str() );
2545       }
2546 
2547       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=   0 || mat_(0,3) !=  0 ||
2548           mat_(1,0) !=  0 || mat_(1,1) !=  1 || mat_(1,2) !=   0 || mat_(1,3) !=  0 ||
2549           mat_(2,0) != -4 || mat_(2,1) !=  0 || mat_(2,2) != -12 || mat_(2,3) !=  0 ||
2550           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=   5 || mat_(3,3) != -6 ||
2551           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=   9 || mat_(4,3) != 10 ) {
2552          std::ostringstream oss;
2553          oss << " Test: " << test_ << "\n"
2554              << " Error: Schur product assignment failed\n"
2555              << " Details:\n"
2556              << "   Result:\n" << mat_ << "\n"
2557              << "   Expected result:\n(  0  0   0  0 )\n"
2558                                      "(  0  1   0  0 )\n"
2559                                      "( -4  0 -12  0 )\n"
2560                                      "(  0  4   5 -6 )\n"
2561                                      "(  7 -8   9 10 )\n";
2562          throw std::runtime_error( oss.str() );
2563       }
2564    }
2565 
2566    {
2567       test_ = "Row-major/column-major sparse matrix Schur product assignment";
2568 
2569       initialize();
2570 
2571       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 3UL );
2572 
2573       blaze::CompressedMatrix<int,blaze::columnMajor> mat( 2UL, 3UL, 4UL );
2574       mat(0,1) = 1;
2575       mat(1,0) = 2;
2576       mat(1,1) = 3;
2577       mat(1,2) = 4;
2578 
2579       sm %= mat;
2580 
2581       checkRows    ( sm  ,  2UL );
2582       checkColumns ( sm  ,  3UL );
2583       checkNonZeros( sm  ,  3UL );
2584       checkRows    ( mat_,  5UL );
2585       checkColumns ( mat_,  4UL );
2586       checkNonZeros( mat_, 10UL );
2587 
2588       if( sm(0,0) !=  0 || sm(0,1) != 1 || sm(0,2) !=   0 ||
2589           sm(1,0) != -4 || sm(1,1) != 0 || sm(1,2) != -12 ) {
2590          std::ostringstream oss;
2591          oss << " Test: " << test_ << "\n"
2592              << " Error: Schur product assignment failed\n"
2593              << " Details:\n"
2594              << "   Result:\n" << sm << "\n"
2595              << "   Expected result:\n(  0  1   0 )\n( -4  0 -12 )\n";
2596          throw std::runtime_error( oss.str() );
2597       }
2598 
2599       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=   0 || mat_(0,3) !=  0 ||
2600           mat_(1,0) !=  0 || mat_(1,1) !=  1 || mat_(1,2) !=   0 || mat_(1,3) !=  0 ||
2601           mat_(2,0) != -4 || mat_(2,1) !=  0 || mat_(2,2) != -12 || mat_(2,3) !=  0 ||
2602           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=   5 || mat_(3,3) != -6 ||
2603           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=   9 || mat_(4,3) != 10 ) {
2604          std::ostringstream oss;
2605          oss << " Test: " << test_ << "\n"
2606              << " Error: Schur product assignment failed\n"
2607              << " Details:\n"
2608              << "   Result:\n" << mat_ << "\n"
2609              << "   Expected result:\n(  0  0   0  0 )\n"
2610                                      "(  0  1   0  0 )\n"
2611                                      "( -4  0 -12  0 )\n"
2612                                      "(  0  4   5 -6 )\n"
2613                                      "(  7 -8   9 10 )\n";
2614          throw std::runtime_error( oss.str() );
2615       }
2616    }
2617 
2618 
2619    //=====================================================================================
2620    // Column-major Submatrix Schur product assignment
2621    //=====================================================================================
2622 
2623    {
2624       test_ = "Column-major Submatrix Schur product assignment (no aliasing)";
2625 
2626       initialize();
2627 
2628       OMT mat( 4UL, 5UL, 3UL );
2629       mat(0,1) = 1;
2630       mat(0,2) = 2;
2631       mat(2,2) = 3;
2632 
2633       OSMT sm = blaze::submatrix( mat, 0UL, 1UL, 3UL, 2UL );
2634       sm %= blaze::submatrix( tmat_, 1UL, 2UL, 3UL, 2UL );
2635 
2636       checkRows    ( sm   ,  3UL );
2637       checkColumns ( sm   ,  2UL );
2638       checkNonZeros( sm   ,  2UL );
2639       checkRows    ( tmat_,  4UL );
2640       checkColumns ( tmat_,  5UL );
2641       checkNonZeros( tmat_, 10UL );
2642       checkRows    ( mat  ,  4UL );
2643       checkColumns ( mat  ,  5UL );
2644       checkNonZeros( mat  ,  2UL );
2645 
2646       if( sm(0,0) != 0 || sm(0,1) !=   8 ||
2647           sm(1,0) != 0 || sm(1,1) !=   0 ||
2648           sm(2,0) != 0 || sm(2,1) != -18 ) {
2649          std::ostringstream oss;
2650          oss << " Test: " << test_ << "\n"
2651              << " Error: Schur product assignment failed\n"
2652              << " Details:\n"
2653              << "   Result:\n" << sm << "\n"
2654              << "   Expected result:\n( 0   8 )\n( 0   0 )\n( 0 -18 )\n";
2655          throw std::runtime_error( oss.str() );
2656       }
2657 
2658       if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) !=   8 || mat(0,3) != 0 || mat(0,4) != 0 ||
2659           mat(1,0) != 0 || mat(1,1) != 0 || mat(1,2) !=   0 || mat(1,3) != 0 || mat(1,4) != 0 ||
2660           mat(2,0) != 0 || mat(2,1) != 0 || mat(2,2) != -18 || mat(2,3) != 0 || mat(2,4) != 0 ||
2661           mat(3,0) != 0 || mat(3,1) != 0 || mat(3,2) !=   0 || mat(3,3) != 0 || mat(3,4) != 0 ) {
2662          std::ostringstream oss;
2663          oss << " Test: " << test_ << "\n"
2664              << " Error: Schur product assignment failed\n"
2665              << " Details:\n"
2666              << "   Result:\n" << mat << "\n"
2667              << "   Expected result:\n( 0  0   8  0  0 )\n"
2668                                      "( 0  0   0  0  0 )\n"
2669                                      "( 0  0 -18  0  0 )\n"
2670                                      "( 0  0   0  0  0 )\n";
2671          throw std::runtime_error( oss.str() );
2672       }
2673    }
2674 
2675    {
2676       test_ = "Column-major Submatrix Schur product assignment (aliasing)";
2677 
2678       initialize();
2679 
2680       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
2681       sm %= blaze::submatrix( tmat_, 1UL, 2UL, 3UL, 2UL );
2682 
2683       checkRows    ( sm   ,  3UL );
2684       checkColumns ( sm   ,  2UL );
2685       checkNonZeros( sm   ,  3UL );
2686       checkRows    ( tmat_,  4UL );
2687       checkColumns ( tmat_,  5UL );
2688       checkNonZeros( tmat_, 10UL );
2689 
2690       if( sm(0,0) !=  0 || sm(0,1) != -8 ||
2691           sm(1,0) != -3 || sm(1,1) !=  0 ||
2692           sm(2,0) !=  0 || sm(2,1) != 18 ) {
2693          std::ostringstream oss;
2694          oss << " Test: " << test_ << "\n"
2695              << " Error: Schur product assignment failed\n"
2696              << " Details:\n"
2697              << "   Result:\n" << sm << "\n"
2698              << "   Expected result:\n(  0 -8 )\n( -3  0 )\n(  0 18 )\n";
2699          throw std::runtime_error( oss.str() );
2700       }
2701 
2702       if( tmat_(0,0) != 0 || tmat_(0,1) !=  0 || tmat_(0,2) != -8 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
2703           tmat_(1,0) != 0 || tmat_(1,1) != -3 || tmat_(1,2) !=  0 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
2704           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != 18 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
2705           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
2706          std::ostringstream oss;
2707          oss << " Test: " << test_ << "\n"
2708              << " Error: Schur product assignment failed\n"
2709              << " Details:\n"
2710              << "   Result:\n" << tmat_ << "\n"
2711              << "   Expected result:\n( 0  0 -8  0  7 )\n"
2712                                      "( 0 -3  0  4 -8 )\n"
2713                                      "( 0  0 18  5  9 )\n"
2714                                      "( 0  0  0 -6 10 )\n";
2715          throw std::runtime_error( oss.str() );
2716       }
2717    }
2718 
2719 
2720    //=====================================================================================
2721    // Column-major dense matrix Schur product assignment
2722    //=====================================================================================
2723 
2724    {
2725       test_ = "Column-major/row-major dense matrix Schur product assignment";
2726 
2727       initialize();
2728 
2729       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
2730 
2731       blaze::DynamicMatrix<int,blaze::rowMajor> mat{ { 0, 2 },
2732                                                      { 1, 3 },
2733                                                      { 0, 4 } };
2734 
2735       sm %= mat;
2736 
2737       checkRows    ( sm   ,  3UL );
2738       checkColumns ( sm   ,  2UL );
2739       checkNonZeros( sm   ,  3UL );
2740       checkRows    ( tmat_,  4UL );
2741       checkColumns ( tmat_,  5UL );
2742       checkNonZeros( tmat_, 10UL );
2743 
2744       if( sm(0,0) != 0 || sm(0,1) !=  -4 ||
2745           sm(1,0) != 1 || sm(1,1) !=   0 ||
2746           sm(2,0) != 0 || sm(2,1) != -12 ) {
2747          std::ostringstream oss;
2748          oss << " Test: " << test_ << "\n"
2749              << " Error: Schur product assignment failed\n"
2750              << " Details:\n"
2751              << "   Result:\n" << sm << "\n"
2752              << "   Expected result:\n( 0  -4 )\n( 1   0 )\n( 0 -12 )\n";
2753          throw std::runtime_error( oss.str() );
2754       }
2755 
2756       if( tmat_(0,0) != 0 || tmat_(0,1) != 0 || tmat_(0,2) !=  -4 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
2757           tmat_(1,0) != 0 || tmat_(1,1) != 1 || tmat_(1,2) !=   0 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
2758           tmat_(2,0) != 0 || tmat_(2,1) != 0 || tmat_(2,2) != -12 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
2759           tmat_(3,0) != 0 || tmat_(3,1) != 0 || tmat_(3,2) !=   0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
2760          std::ostringstream oss;
2761          oss << " Test: " << test_ << "\n"
2762              << " Error: Schur product assignment failed\n"
2763              << " Details:\n"
2764              << "   Result:\n" << tmat_ << "\n"
2765              << "   Expected result:\n( 0  0  -4  0  7 )\n"
2766                                      "( 0  1   0  4 -8 )\n"
2767                                      "( 0  0 -12  5  9 )\n"
2768                                      "( 0  0   0 -6 10 )\n";
2769          throw std::runtime_error( oss.str() );
2770       }
2771    }
2772 
2773    {
2774       test_ = "Column-major/column-major dense matrix Schur product assignment";
2775 
2776       initialize();
2777 
2778       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
2779 
2780       blaze::DynamicMatrix<int,blaze::columnMajor> mat{ { 0, 2 },
2781                                                         { 1, 3 },
2782                                                         { 0, 4 } };;
2783 
2784       sm %= mat;
2785 
2786       checkRows    ( sm   ,  3UL );
2787       checkColumns ( sm   ,  2UL );
2788       checkNonZeros( sm   ,  3UL );
2789       checkRows    ( tmat_,  4UL );
2790       checkColumns ( tmat_,  5UL );
2791       checkNonZeros( tmat_, 10UL );
2792 
2793       if( sm(0,0) != 0 || sm(0,1) !=  -4 ||
2794           sm(1,0) != 1 || sm(1,1) !=   0 ||
2795           sm(2,0) != 0 || sm(2,1) != -12 ) {
2796          std::ostringstream oss;
2797          oss << " Test: " << test_ << "\n"
2798              << " Error: Schur product assignment failed\n"
2799              << " Details:\n"
2800              << "   Result:\n" << sm << "\n"
2801              << "   Expected result:\n( 0  -4 )\n( 1   0 )\n( 0 -12 )\n";
2802          throw std::runtime_error( oss.str() );
2803       }
2804 
2805       if( tmat_(0,0) != 0 || tmat_(0,1) != 0 || tmat_(0,2) !=  -4 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
2806           tmat_(1,0) != 0 || tmat_(1,1) != 1 || tmat_(1,2) !=   0 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
2807           tmat_(2,0) != 0 || tmat_(2,1) != 0 || tmat_(2,2) != -12 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
2808           tmat_(3,0) != 0 || tmat_(3,1) != 0 || tmat_(3,2) !=   0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
2809          std::ostringstream oss;
2810          oss << " Test: " << test_ << "\n"
2811              << " Error: Schur product assignment failed\n"
2812              << " Details:\n"
2813              << "   Result:\n" << tmat_ << "\n"
2814              << "   Expected result:\n( 0  0  -4  0  7 )\n"
2815                                      "( 0  1   0  4 -8 )\n"
2816                                      "( 0  0 -12  5  9 )\n"
2817                                      "( 0  0   0 -6 10 )\n";
2818          throw std::runtime_error( oss.str() );
2819       }
2820    }
2821 
2822 
2823    //=====================================================================================
2824    // Column-major sparse matrix Schur product assignment
2825    //=====================================================================================
2826 
2827    {
2828       test_ = "Column-major/row-major sparse matrix Schur product assignment";
2829 
2830       initialize();
2831 
2832       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
2833 
2834       blaze::CompressedMatrix<int,blaze::rowMajor> mat( 3UL, 2UL, 4UL );
2835       mat(1,0) = 1;
2836       mat(0,1) = 2;
2837       mat(1,1) = 3;
2838       mat(2,1) = 4;
2839 
2840       sm %= mat;
2841 
2842       checkRows    ( sm   ,  3UL );
2843       checkColumns ( sm   ,  2UL );
2844       checkNonZeros( sm   ,  3UL );
2845       checkRows    ( tmat_,  4UL );
2846       checkColumns ( tmat_,  5UL );
2847       checkNonZeros( tmat_, 10UL );
2848 
2849       if( sm(0,0) != 0 || sm(0,1) !=  -4 ||
2850           sm(1,0) != 1 || sm(1,1) !=   0 ||
2851           sm(2,0) != 0 || sm(2,1) != -12 ) {
2852          std::ostringstream oss;
2853          oss << " Test: " << test_ << "\n"
2854              << " Error: Schur product assignment failed\n"
2855              << " Details:\n"
2856              << "   Result:\n" << sm << "\n"
2857              << "   Expected result:\n( 0  -4 )\n( 1   0 )\n( 0 -12 )\n";
2858          throw std::runtime_error( oss.str() );
2859       }
2860 
2861       if( tmat_(0,0) != 0 || tmat_(0,1) != 0 || tmat_(0,2) !=  -4 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
2862           tmat_(1,0) != 0 || tmat_(1,1) != 1 || tmat_(1,2) !=   0 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
2863           tmat_(2,0) != 0 || tmat_(2,1) != 0 || tmat_(2,2) != -12 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
2864           tmat_(3,0) != 0 || tmat_(3,1) != 0 || tmat_(3,2) !=   0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
2865          std::ostringstream oss;
2866          oss << " Test: " << test_ << "\n"
2867              << " Error: Schur product assignment failed\n"
2868              << " Details:\n"
2869              << "   Result:\n" << tmat_ << "\n"
2870              << "   Expected result:\n( 0  0  -4  0  7 )\n"
2871                                      "( 0  1   0  4 -8 )\n"
2872                                      "( 0  0 -12  5  9 )\n"
2873                                      "( 0  0   0 -6 10 )\n";
2874          throw std::runtime_error( oss.str() );
2875       }
2876    }
2877 
2878    {
2879       test_ = "Column-major/column-major sparse matrix Schur product assignment";
2880 
2881       initialize();
2882 
2883       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 3UL, 2UL );
2884 
2885       blaze::CompressedMatrix<int,blaze::columnMajor> mat( 3UL, 2UL, 4UL );
2886       mat(1,0) = 1;
2887       mat(0,1) = 2;
2888       mat(1,1) = 3;
2889       mat(2,1) = 4;
2890 
2891       sm %= mat;
2892 
2893       checkRows    ( sm   ,  3UL );
2894       checkColumns ( sm   ,  2UL );
2895       checkNonZeros( sm   ,  3UL );
2896       checkRows    ( tmat_,  4UL );
2897       checkColumns ( tmat_,  5UL );
2898       checkNonZeros( tmat_, 10UL );
2899 
2900       if( sm(0,0) != 0 || sm(0,1) !=  -4 ||
2901           sm(1,0) != 1 || sm(1,1) !=   0 ||
2902           sm(2,0) != 0 || sm(2,1) != -12 ) {
2903          std::ostringstream oss;
2904          oss << " Test: " << test_ << "\n"
2905              << " Error: Schur product assignment failed\n"
2906              << " Details:\n"
2907              << "   Result:\n" << sm << "\n"
2908              << "   Expected result:\n( 0  -4 )\n( 1   0 )\n( 0 -12 )\n";
2909          throw std::runtime_error( oss.str() );
2910       }
2911 
2912       if( tmat_(0,0) != 0 || tmat_(0,1) != 0 || tmat_(0,2) !=  -4 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
2913           tmat_(1,0) != 0 || tmat_(1,1) != 1 || tmat_(1,2) !=   0 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
2914           tmat_(2,0) != 0 || tmat_(2,1) != 0 || tmat_(2,2) != -12 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
2915           tmat_(3,0) != 0 || tmat_(3,1) != 0 || tmat_(3,2) !=   0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
2916          std::ostringstream oss;
2917          oss << " Test: " << test_ << "\n"
2918              << " Error: Schur product assignment failed\n"
2919              << " Details:\n"
2920              << "   Result:\n" << tmat_ << "\n"
2921              << "   Expected result:\n( 0  0  -4  0  7 )\n"
2922                                      "( 0  1   0  4 -8 )\n"
2923                                      "( 0  0 -12  5  9 )\n"
2924                                      "( 0  0   0 -6 10 )\n";
2925          throw std::runtime_error( oss.str() );
2926       }
2927    }
2928 }
2929 //*************************************************************************************************
2930 
2931 
2932 //*************************************************************************************************
2933 /*!\brief Test of the Submatrix multiplication assignment operators.
2934 //
2935 // \return void
2936 // \exception std::runtime_error Error detected.
2937 //
2938 // This function performs a test of the multiplication assignment operators of the Submatrix
2939 // specialization. In case an error is detected, a \a std::runtime_error exception is thrown.
2940 */
testMultAssign()2941 void SparseTest::testMultAssign()
2942 {
2943    //=====================================================================================
2944    // Row-major Submatrix multiplication assignment
2945    //=====================================================================================
2946 
2947    {
2948       test_ = "Row-major Submatrix multiplication assignment (no aliasing)";
2949 
2950       initialize();
2951 
2952       MT mat( 5UL, 4UL, 4UL );
2953       mat(1,0) = 1;
2954       mat(1,1) = 1;
2955       mat(2,0) = 1;
2956       mat(2,1) = 1;
2957 
2958       SMT sm = blaze::submatrix( mat, 1UL, 0UL, 2UL, 2UL );
2959       sm *= blaze::submatrix( mat_, 2UL, 1UL, 2UL, 2UL );
2960 
2961       checkRows    ( sm  ,  2UL );
2962       checkColumns ( sm  ,  2UL );
2963       checkNonZeros( sm  ,  4UL );
2964       checkRows    ( mat_,  5UL );
2965       checkColumns ( mat_,  4UL );
2966       checkNonZeros( mat_, 10UL );
2967       checkRows    ( mat ,  5UL );
2968       checkColumns ( mat ,  4UL );
2969       checkNonZeros( mat ,  4UL );
2970 
2971       if( sm(0,0) != 4 || sm(0,1) != 2 ||
2972           sm(1,0) != 4 || sm(1,1) != 2 ) {
2973          std::ostringstream oss;
2974          oss << " Test: " << test_ << "\n"
2975              << " Error: Multiplication assignment failed\n"
2976              << " Details:\n"
2977              << "   Result:\n" << sm << "\n"
2978              << "   Expected result:\n( 4 2 )\n( 4 2 )\n";
2979          throw std::runtime_error( oss.str() );
2980       }
2981 
2982       if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) != 0 || mat(0,3) != 0 ||
2983           mat(1,0) != 4 || mat(1,1) != 2 || mat(1,2) != 0 || mat(1,3) != 0 ||
2984           mat(2,0) != 4 || mat(2,1) != 2 || mat(2,2) != 0 || mat(2,3) != 0 ||
2985           mat(3,0) != 0 || mat(3,1) != 0 || mat(3,2) != 0 || mat(3,3) != 0 ||
2986           mat(4,0) != 0 || mat(4,1) != 0 || mat(4,2) != 0 || mat(4,3) != 0 ) {
2987          std::ostringstream oss;
2988          oss << " Test: " << test_ << "\n"
2989              << " Error: Multiplication assignment failed\n"
2990              << " Details:\n"
2991              << "   Result:\n" << mat << "\n"
2992              << "   Expected result:\n( 0  0  0  0 )\n"
2993                                      "( 4  2  0  0 )\n"
2994                                      "( 4  2  0  0 )\n"
2995                                      "( 0  0  0  0 )\n"
2996                                      "( 0  0  0  0 )\n";
2997          throw std::runtime_error( oss.str() );
2998       }
2999    }
3000 
3001    {
3002       test_ = "Row-major Submatrix multiplication assignment (aliasing)";
3003 
3004       initialize();
3005 
3006       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 2UL );
3007       sm *= blaze::submatrix( mat_, 2UL, 1UL, 2UL, 2UL );
3008 
3009       checkRows    ( sm  ,  2UL );
3010       checkColumns ( sm  ,  2UL );
3011       checkNonZeros( sm  ,  3UL );
3012       checkRows    ( mat_,  5UL );
3013       checkColumns ( mat_,  4UL );
3014       checkNonZeros( mat_, 11UL );
3015 
3016       if( sm(0,0) != 4 || sm(0,1) != 5 ||
3017           sm(1,0) != 0 || sm(1,1) != 6 ) {
3018          std::ostringstream oss;
3019          oss << " Test: " << test_ << "\n"
3020              << " Error: Multiplication assignment failed\n"
3021              << " Details:\n"
3022              << "   Result:\n" << sm << "\n"
3023              << "   Expected result:\n( 4  5 )\n( 0  6 )\n";
3024          throw std::runtime_error( oss.str() );
3025       }
3026 
3027       if( mat_(0,0) != 0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
3028           mat_(1,0) != 4 || mat_(1,1) !=  5 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
3029           mat_(2,0) != 0 || mat_(2,1) !=  6 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
3030           mat_(3,0) != 0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
3031           mat_(4,0) != 7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
3032          std::ostringstream oss;
3033          oss << " Test: " << test_ << "\n"
3034              << " Error: Multiplication assignment failed\n"
3035              << " Details:\n"
3036              << "   Result:\n" << mat_ << "\n"
3037              << "   Expected result:\n( 0  0  0  0 )\n"
3038                                      "( 4  5  0  0 )\n"
3039                                      "( 0  6 -3  0 )\n"
3040                                      "( 0  4  5 -6 )\n"
3041                                      "( 7 -8  9 10 )\n";
3042          throw std::runtime_error( oss.str() );
3043       }
3044    }
3045 
3046 
3047    //=====================================================================================
3048    // Row-major dense matrix multiplication assignment
3049    //=====================================================================================
3050 
3051    {
3052       test_ = "Row-major/row-major dense matrix multiplication assignment";
3053 
3054       initialize();
3055 
3056       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 2UL );
3057 
3058       blaze::DynamicMatrix<int,blaze::rowMajor> mat{ { -11, -12 },
3059                                                      {  13,  14 } };
3060 
3061       sm *= mat;
3062 
3063       checkRows    ( sm  ,  2UL );
3064       checkColumns ( sm  ,  2UL );
3065       checkNonZeros( sm  ,  4UL );
3066       checkRows    ( mat_,  5UL );
3067       checkColumns ( mat_,  4UL );
3068       checkNonZeros( mat_, 12UL );
3069 
3070       if( sm(0,0) != 13 || sm(0,1) != 14 ||
3071           sm(1,0) != 22 || sm(1,1) != 24 ) {
3072          std::ostringstream oss;
3073          oss << " Test: " << test_ << "\n"
3074              << " Error: Multiplication assignment failed\n"
3075              << " Details:\n"
3076              << "   Result:\n" << sm << "\n"
3077              << "   Expected result:\n( 13 14 )\n( 22 24 )\n";
3078          throw std::runtime_error( oss.str() );
3079       }
3080 
3081       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
3082           mat_(1,0) != 13 || mat_(1,1) != 14 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
3083           mat_(2,0) != 22 || mat_(2,1) != 24 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
3084           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
3085           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
3086          std::ostringstream oss;
3087          oss << " Test: " << test_ << "\n"
3088              << " Error: Multiplication assignment failed\n"
3089              << " Details:\n"
3090              << "   Result:\n" << mat_ << "\n"
3091              << "   Expected result:\n(  0  0  0  0 )\n"
3092                                      "( 13 14  0  0 )\n"
3093                                      "( 22 24 -3  0 )\n"
3094                                      "(  0  4  5 -6 )\n"
3095                                      "(  7 -8  9 10 )\n";
3096          throw std::runtime_error( oss.str() );
3097       }
3098    }
3099 
3100    {
3101       test_ = "Row-major/column-major dense matrix multiplication assignment";
3102 
3103       initialize();
3104 
3105       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 2UL );
3106 
3107       blaze::DynamicMatrix<int,blaze::columnMajor> mat{ { -11, -12 },
3108                                                         {  13,  14 } };
3109 
3110       sm *= mat;
3111 
3112       checkRows    ( sm  ,  2UL );
3113       checkColumns ( sm  ,  2UL );
3114       checkNonZeros( sm  ,  4UL );
3115       checkRows    ( mat_,  5UL );
3116       checkColumns ( mat_,  4UL );
3117       checkNonZeros( mat_, 12UL );
3118 
3119       if( sm(0,0) != 13 || sm(0,1) != 14 ||
3120           sm(1,0) != 22 || sm(1,1) != 24 ) {
3121          std::ostringstream oss;
3122          oss << " Test: " << test_ << "\n"
3123              << " Error: Multiplication assignment failed\n"
3124              << " Details:\n"
3125              << "   Result:\n" << sm << "\n"
3126              << "   Expected result:\n( 13 14 )\n( 22 24 )\n";
3127          throw std::runtime_error( oss.str() );
3128       }
3129 
3130       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
3131           mat_(1,0) != 13 || mat_(1,1) != 14 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
3132           mat_(2,0) != 22 || mat_(2,1) != 24 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
3133           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
3134           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
3135          std::ostringstream oss;
3136          oss << " Test: " << test_ << "\n"
3137              << " Error: Multiplication assignment failed\n"
3138              << " Details:\n"
3139              << "   Result:\n" << mat_ << "\n"
3140              << "   Expected result:\n(  0  0  0  0 )\n"
3141                                      "( 13 14  0  0 )\n"
3142                                      "( 22 24 -3  0 )\n"
3143                                      "(  0  4  5 -6 )\n"
3144                                      "(  7 -8  9 10 )\n";
3145          throw std::runtime_error( oss.str() );
3146       }
3147    }
3148 
3149 
3150    //=====================================================================================
3151    // Row-major sparse matrix multiplication assignment
3152    //=====================================================================================
3153 
3154    {
3155       test_ = "Row-major/row-major sparse matrix multiplication assignment";
3156 
3157       initialize();
3158 
3159       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 2UL );
3160 
3161       blaze::CompressedMatrix<int,blaze::rowMajor> mat( 2UL, 2UL, 4UL );
3162       mat(0,0) = -11;
3163       mat(0,1) = -12;
3164       mat(1,0) =  13;
3165       mat(1,1) =  14;
3166 
3167       sm *= mat;
3168 
3169       checkRows    ( sm  ,  2UL );
3170       checkColumns ( sm  ,  2UL );
3171       checkNonZeros( sm  ,  4UL );
3172       checkRows    ( mat_,  5UL );
3173       checkColumns ( mat_,  4UL );
3174       checkNonZeros( mat_, 12UL );
3175 
3176       if( sm(0,0) != 13 || sm(0,1) != 14 ||
3177           sm(1,0) != 22 || sm(1,1) != 24 ) {
3178          std::ostringstream oss;
3179          oss << " Test: " << test_ << "\n"
3180              << " Error: Multiplication assignment failed\n"
3181              << " Details:\n"
3182              << "   Result:\n" << sm << "\n"
3183              << "   Expected result:\n( 13 14 )\n( 22 24 )\n";
3184          throw std::runtime_error( oss.str() );
3185       }
3186 
3187       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
3188           mat_(1,0) != 13 || mat_(1,1) != 14 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
3189           mat_(2,0) != 22 || mat_(2,1) != 24 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
3190           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
3191           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
3192          std::ostringstream oss;
3193          oss << " Test: " << test_ << "\n"
3194              << " Error: Multiplication assignment failed\n"
3195              << " Details:\n"
3196              << "   Result:\n" << mat_ << "\n"
3197              << "   Expected result:\n(  0  0  0  0 )\n"
3198                                      "( 13 14  0  0 )\n"
3199                                      "( 22 24 -3  0 )\n"
3200                                      "(  0  4  5 -6 )\n"
3201                                      "(  7 -8  9 10 )\n";
3202          throw std::runtime_error( oss.str() );
3203       }
3204    }
3205 
3206    {
3207       test_ = "Row-major/column-major sparse matrix multiplication assignment";
3208 
3209       initialize();
3210 
3211       SMT sm = blaze::submatrix( mat_, 1UL, 0UL, 2UL, 2UL );
3212 
3213       blaze::CompressedMatrix<int,blaze::columnMajor> mat( 2UL, 2UL, 4UL );
3214       mat(0,0) = -11;
3215       mat(0,1) = -12;
3216       mat(1,0) =  13;
3217       mat(1,1) =  14;
3218 
3219       sm *= mat;
3220 
3221       checkRows    ( sm  ,  2UL );
3222       checkColumns ( sm  ,  2UL );
3223       checkNonZeros( sm  ,  4UL );
3224       checkRows    ( mat_,  5UL );
3225       checkColumns ( mat_,  4UL );
3226       checkNonZeros( mat_, 12UL );
3227 
3228       if( sm(0,0) != 13 || sm(0,1) != 14 ||
3229           sm(1,0) != 22 || sm(1,1) != 24 ) {
3230          std::ostringstream oss;
3231          oss << " Test: " << test_ << "\n"
3232              << " Error: Multiplication assignment failed\n"
3233              << " Details:\n"
3234              << "   Result:\n" << sm << "\n"
3235              << "   Expected result:\n( 13 14 )\n( 22 24 )\n";
3236          throw std::runtime_error( oss.str() );
3237       }
3238 
3239       if( mat_(0,0) !=  0 || mat_(0,1) !=  0 || mat_(0,2) !=  0 || mat_(0,3) !=  0 ||
3240           mat_(1,0) != 13 || mat_(1,1) != 14 || mat_(1,2) !=  0 || mat_(1,3) !=  0 ||
3241           mat_(2,0) != 22 || mat_(2,1) != 24 || mat_(2,2) != -3 || mat_(2,3) !=  0 ||
3242           mat_(3,0) !=  0 || mat_(3,1) !=  4 || mat_(3,2) !=  5 || mat_(3,3) != -6 ||
3243           mat_(4,0) !=  7 || mat_(4,1) != -8 || mat_(4,2) !=  9 || mat_(4,3) != 10 ) {
3244          std::ostringstream oss;
3245          oss << " Test: " << test_ << "\n"
3246              << " Error: Multiplication assignment failed\n"
3247              << " Details:\n"
3248              << "   Result:\n" << mat_ << "\n"
3249              << "   Expected result:\n(  0  0  0  0 )\n"
3250                                      "( 13 14  0  0 )\n"
3251                                      "( 22 24 -3  0 )\n"
3252                                      "(  0  4  5 -6 )\n"
3253                                      "(  7 -8  9 10 )\n";
3254          throw std::runtime_error( oss.str() );
3255       }
3256    }
3257 
3258 
3259    //=====================================================================================
3260    // Column-major Submatrix multiplication assignment
3261    //=====================================================================================
3262 
3263    {
3264       test_ = "Column-major Submatrix multiplication assignment (no aliasing)";
3265 
3266       initialize();
3267 
3268       OMT mat( 4UL, 5UL, 4UL );
3269       mat(0,1) = 1;
3270       mat(0,2) = 1;
3271       mat(1,1) = 1;
3272       mat(1,2) = 1;
3273 
3274       OSMT sm = blaze::submatrix( mat, 0UL, 1UL, 2UL, 2UL );
3275       sm *= blaze::submatrix( tmat_, 1UL, 2UL, 2UL, 2UL );
3276 
3277       checkRows    ( sm   ,  2UL );
3278       checkColumns ( sm   ,  2UL );
3279       checkNonZeros( sm   ,  4UL );
3280       checkRows    ( tmat_,  4UL );
3281       checkColumns ( tmat_,  5UL );
3282       checkNonZeros( tmat_, 10UL );
3283       checkRows    ( mat  ,  4UL );
3284       checkColumns ( mat  ,  5UL );
3285       checkNonZeros( mat  ,  4UL );
3286 
3287       if( sm(0,0) != -3 || sm(0,1) != 9 ||
3288           sm(1,0) != -3 || sm(1,1) != 9 ) {
3289          std::ostringstream oss;
3290          oss << " Test: " << test_ << "\n"
3291              << " Error: Multiplication assignment failed\n"
3292              << " Details:\n"
3293              << "   Result:\n" << sm << "\n"
3294              << "   Expected result:\n( -3 -3 )\n(  9  9 )\n";
3295          throw std::runtime_error( oss.str() );
3296       }
3297 
3298       if( mat(0,0) != 0 || mat(0,1) != -3 || mat(0,2) != 9 || mat(0,3) != 0 || mat(0,4) != 0 ||
3299           mat(1,0) != 0 || mat(1,1) != -3 || mat(1,2) != 9 || mat(1,3) != 0 || mat(1,4) != 0 ||
3300           mat(2,0) != 0 || mat(2,1) !=  0 || mat(2,2) != 0 || mat(2,3) != 0 || mat(2,4) != 0 ||
3301           mat(3,0) != 0 || mat(3,1) !=  0 || mat(3,2) != 0 || mat(3,3) != 0 || mat(3,4) != 0 ) {
3302          std::ostringstream oss;
3303          oss << " Test: " << test_ << "\n"
3304              << " Error: Multiplication assignment failed\n"
3305              << " Details:\n"
3306              << "   Result:\n" << mat << "\n"
3307              << "   Expected result:\n( 0 -3  9  0  0 )\n"
3308                                      "( 0 -3  9  0  0 )\n"
3309                                      "( 0  0  0  0  0 )\n"
3310                                      "( 0  0  0  0  0 )\n";
3311          throw std::runtime_error( oss.str() );
3312       }
3313    }
3314 
3315    {
3316       test_ = "Column-major Submatrix multiplication assignment (aliasing)";
3317 
3318       initialize();
3319 
3320       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 2UL, 2UL );
3321       sm *= blaze::submatrix( tmat_, 1UL, 2UL, 2UL, 2UL );
3322 
3323       checkRows    ( sm   ,  2UL );
3324       checkColumns ( sm   ,  2UL );
3325       checkNonZeros( sm   ,  3UL );
3326       checkRows    ( tmat_,  4UL );
3327       checkColumns ( tmat_,  5UL );
3328       checkNonZeros( tmat_, 11UL );
3329 
3330       if( sm(0,0) != 6 || sm(0,1) != -10 ||
3331           sm(1,0) != 0 || sm(1,1) !=   4 ) {
3332          std::ostringstream oss;
3333          oss << " Test: " << test_ << "\n"
3334              << " Error: Multiplication assignment failed\n"
3335              << " Details:\n"
3336              << "   Result:\n" << sm << "\n"
3337              << "   Expected result:\n( 6 -10 )\n( 0   4 )\n";
3338          throw std::runtime_error( oss.str() );
3339       }
3340 
3341       if( tmat_(0,0) != 0 || tmat_(0,1) != 6 || tmat_(0,2) != -10 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
3342           tmat_(1,0) != 0 || tmat_(1,1) != 0 || tmat_(1,2) !=   4 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
3343           tmat_(2,0) != 0 || tmat_(2,1) != 0 || tmat_(2,2) !=  -3 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
3344           tmat_(3,0) != 0 || tmat_(3,1) != 0 || tmat_(3,2) !=   0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
3345          std::ostringstream oss;
3346          oss << " Test: " << test_ << "\n"
3347              << " Error: Multiplication assignment failed\n"
3348              << " Details:\n"
3349              << "   Result:\n" << tmat_ << "\n"
3350              << "   Expected result:\n( 0  6 -10  0  7 )\n"
3351                                      "( 0  0   4  4 -8 )\n"
3352                                      "( 0  0  -3  5  9 )\n"
3353                                      "( 0  0   0 -6 10 )\n";
3354          throw std::runtime_error( oss.str() );
3355       }
3356    }
3357 
3358 
3359    //=====================================================================================
3360    // Column-major dense matrix multiplication assignment
3361    //=====================================================================================
3362 
3363    {
3364       test_ = "Column-major/row-major dense matrix multiplication assignment";
3365 
3366       initialize();
3367 
3368       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 2UL, 2UL );
3369 
3370       blaze::DynamicMatrix<int,blaze::rowMajor> mat{ {  11,  12 },
3371                                                      { -13, -14 } };
3372 
3373       sm *= mat;
3374 
3375       checkRows    ( sm   ,  2UL );
3376       checkColumns ( sm   ,  2UL );
3377       checkNonZeros( sm   ,  4UL );
3378       checkRows    ( tmat_,  4UL );
3379       checkColumns ( tmat_,  5UL );
3380       checkNonZeros( tmat_, 12UL );
3381 
3382       if( sm(0,0) != 26 || sm(0,1) != 28 ||
3383           sm(1,0) != 11 || sm(1,1) != 12 ) {
3384          std::ostringstream oss;
3385          oss << " Test: " << test_ << "\n"
3386              << " Error: Multiplication assignment failed\n"
3387              << " Details:\n"
3388              << "   Result:\n" << sm << "\n"
3389              << "   Expected result:\n( 26 28 )\n( 11 12 )\n";
3390          throw std::runtime_error( oss.str() );
3391       }
3392 
3393       if( tmat_(0,0) != 0 || tmat_(0,1) != 26 || tmat_(0,2) != 28 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
3394           tmat_(1,0) != 0 || tmat_(1,1) != 11 || tmat_(1,2) != 12 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
3395           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
3396           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
3397          std::ostringstream oss;
3398          oss << " Test: " << test_ << "\n"
3399              << " Error: Multiplication assignment failed\n"
3400              << " Details:\n"
3401              << "   Result:\n" << tmat_ << "\n"
3402              << "   Expected result:\n( 0 26 28  0  7 )\n"
3403                                      "( 0 11 12  4 -8 )\n"
3404                                      "( 0  0 -3  5  9 )\n"
3405                                      "( 0  0  0 -6 10 )\n";
3406          throw std::runtime_error( oss.str() );
3407       }
3408    }
3409 
3410    {
3411       test_ = "Column-major/column-major dense matrix multiplication assignment";
3412 
3413       initialize();
3414 
3415       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 2UL, 2UL );
3416 
3417       blaze::DynamicMatrix<int,blaze::columnMajor> mat{ {  11,  12 },
3418                                                         { -13, -14 } };
3419 
3420       sm *= mat;
3421 
3422       checkRows    ( sm   ,  2UL );
3423       checkColumns ( sm   ,  2UL );
3424       checkNonZeros( sm   ,  4UL );
3425       checkRows    ( tmat_,  4UL );
3426       checkColumns ( tmat_,  5UL );
3427       checkNonZeros( tmat_, 12UL );
3428 
3429       if( sm(0,0) != 26 || sm(0,1) != 28 ||
3430           sm(1,0) != 11 || sm(1,1) != 12 ) {
3431          std::ostringstream oss;
3432          oss << " Test: " << test_ << "\n"
3433              << " Error: Multiplication assignment failed\n"
3434              << " Details:\n"
3435              << "   Result:\n" << sm << "\n"
3436              << "   Expected result:\n( 26 28 )\n( 11 12 )\n";
3437          throw std::runtime_error( oss.str() );
3438       }
3439 
3440       if( tmat_(0,0) != 0 || tmat_(0,1) != 26 || tmat_(0,2) != 28 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
3441           tmat_(1,0) != 0 || tmat_(1,1) != 11 || tmat_(1,2) != 12 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
3442           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
3443           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
3444          std::ostringstream oss;
3445          oss << " Test: " << test_ << "\n"
3446              << " Error: Multiplication assignment failed\n"
3447              << " Details:\n"
3448              << "   Result:\n" << tmat_ << "\n"
3449              << "   Expected result:\n( 0 26 28  0  7 )\n"
3450                                      "( 0 11 12  4 -8 )\n"
3451                                      "( 0  0 -3  5  9 )\n"
3452                                      "( 0  0  0 -6 10 )\n";
3453          throw std::runtime_error( oss.str() );
3454       }
3455    }
3456 
3457 
3458    //=====================================================================================
3459    // Column-major sparse matrix multiplication assignment
3460    //=====================================================================================
3461 
3462    {
3463       test_ = "Column-major/row-major sparse matrix multiplication assignment";
3464 
3465       initialize();
3466 
3467       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 2UL, 2UL );
3468 
3469       blaze::CompressedMatrix<int,blaze::rowMajor> mat( 2UL, 2UL, 4UL );
3470       mat(0,0) =  11;
3471       mat(0,1) =  12;
3472       mat(1,0) = -13;
3473       mat(1,1) = -14;
3474 
3475       sm *= mat;
3476 
3477       checkRows    ( sm   ,  2UL );
3478       checkColumns ( sm   ,  2UL );
3479       checkNonZeros( sm   ,  4UL );
3480       checkRows    ( tmat_,  4UL );
3481       checkColumns ( tmat_,  5UL );
3482       checkNonZeros( tmat_, 12UL );
3483 
3484       if( sm(0,0) != 26 || sm(0,1) != 28 ||
3485           sm(1,0) != 11 || sm(1,1) != 12 ) {
3486          std::ostringstream oss;
3487          oss << " Test: " << test_ << "\n"
3488              << " Error: Multiplication assignment failed\n"
3489              << " Details:\n"
3490              << "   Result:\n" << sm << "\n"
3491              << "   Expected result:\n( 26 28 )\n( 11 12 )\n";
3492          throw std::runtime_error( oss.str() );
3493       }
3494 
3495       if( tmat_(0,0) != 0 || tmat_(0,1) != 26 || tmat_(0,2) != 28 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
3496           tmat_(1,0) != 0 || tmat_(1,1) != 11 || tmat_(1,2) != 12 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
3497           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
3498           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
3499          std::ostringstream oss;
3500          oss << " Test: " << test_ << "\n"
3501              << " Error: Multiplication assignment failed\n"
3502              << " Details:\n"
3503              << "   Result:\n" << tmat_ << "\n"
3504              << "   Expected result:\n( 0 26 28  0  7 )\n"
3505                                      "( 0 11 12  4 -8 )\n"
3506                                      "( 0  0 -3  5  9 )\n"
3507                                      "( 0  0  0 -6 10 )\n";
3508          throw std::runtime_error( oss.str() );
3509       }
3510    }
3511 
3512    {
3513       test_ = "Column-major/column-major sparse matrix multiplication assignment";
3514 
3515       initialize();
3516 
3517       OSMT sm = blaze::submatrix( tmat_, 0UL, 1UL, 2UL, 2UL );
3518 
3519       blaze::CompressedMatrix<int,blaze::columnMajor> mat( 2UL, 2UL, 4UL );
3520       mat(0,0) =  11;
3521       mat(0,1) =  12;
3522       mat(1,0) = -13;
3523       mat(1,1) = -14;
3524 
3525       sm *= mat;
3526 
3527       checkRows    ( sm   ,  2UL );
3528       checkColumns ( sm   ,  2UL );
3529       checkNonZeros( sm   ,  4UL );
3530       checkRows    ( tmat_,  4UL );
3531       checkColumns ( tmat_,  5UL );
3532       checkNonZeros( tmat_, 12UL );
3533 
3534       if( sm(0,0) != 26 || sm(0,1) != 28 ||
3535           sm(1,0) != 11 || sm(1,1) != 12 ) {
3536          std::ostringstream oss;
3537          oss << " Test: " << test_ << "\n"
3538              << " Error: Multiplication assignment failed\n"
3539              << " Details:\n"
3540              << "   Result:\n" << sm << "\n"
3541              << "   Expected result:\n( 26 28 )\n( 11 12 )\n";
3542          throw std::runtime_error( oss.str() );
3543       }
3544 
3545       if( tmat_(0,0) != 0 || tmat_(0,1) != 26 || tmat_(0,2) != 28 || tmat_(0,3) !=  0 || tmat_(0,4) !=  7 ||
3546           tmat_(1,0) != 0 || tmat_(1,1) != 11 || tmat_(1,2) != 12 || tmat_(1,3) !=  4 || tmat_(1,4) != -8 ||
3547           tmat_(2,0) != 0 || tmat_(2,1) !=  0 || tmat_(2,2) != -3 || tmat_(2,3) !=  5 || tmat_(2,4) !=  9 ||
3548           tmat_(3,0) != 0 || tmat_(3,1) !=  0 || tmat_(3,2) !=  0 || tmat_(3,3) != -6 || tmat_(3,4) != 10 ) {
3549          std::ostringstream oss;
3550          oss << " Test: " << test_ << "\n"
3551              << " Error: Multiplication assignment failed\n"
3552              << " Details:\n"
3553              << "   Result:\n" << tmat_ << "\n"
3554              << "   Expected result:\n( 0 26 28  0  7 )\n"
3555                                      "( 0 11 12  4 -8 )\n"
3556                                      "( 0  0 -3  5  9 )\n"
3557                                      "( 0  0  0 -6 10 )\n";
3558          throw std::runtime_error( oss.str() );
3559       }
3560    }
3561 }
3562 //*************************************************************************************************
3563 
3564 
3565 
3566 
3567 //=================================================================================================
3568 //
3569 //  UTILITY FUNCTIONS
3570 //
3571 //=================================================================================================
3572 
3573 //*************************************************************************************************
3574 /*!\brief Initialization of all member matrices.
3575 //
3576 // \return void
3577 // \exception std::runtime_error Error detected.
3578 //
3579 // This function initializes all member matrices to specific predetermined values.
3580 */
initialize()3581 void SparseTest::initialize()
3582 {
3583    // Initializing the row-major compressed matrix
3584    mat_.reset();
3585    mat_(1,1) =  1;
3586    mat_(2,0) = -2;
3587    mat_(2,2) = -3;
3588    mat_(3,1) =  4;
3589    mat_(3,2) =  5;
3590    mat_(3,3) = -6;
3591    mat_(4,0) =  7;
3592    mat_(4,1) = -8;
3593    mat_(4,2) =  9;
3594    mat_(4,3) = 10;
3595 
3596    // Initializing the column-major compressed matrix
3597    tmat_.reset();
3598    tmat_(1,1) =  1;
3599    tmat_(0,2) = -2;
3600    tmat_(2,2) = -3;
3601    tmat_(1,3) =  4;
3602    tmat_(2,3) =  5;
3603    tmat_(3,3) = -6;
3604    tmat_(0,4) =  7;
3605    tmat_(1,4) = -8;
3606    tmat_(2,4) =  9;
3607    tmat_(3,4) = 10;
3608 }
3609 //*************************************************************************************************
3610 
3611 } // namespace submatrix
3612 
3613 } // namespace views
3614 
3615 } // namespace mathtest
3616 
3617 } // namespace blazetest
3618 
3619 
3620 
3621 
3622 //=================================================================================================
3623 //
3624 //  MAIN FUNCTION
3625 //
3626 //=================================================================================================
3627 
3628 //*************************************************************************************************
main()3629 int main()
3630 {
3631    std::cout << "   Running Submatrix sparse test (part 1)..." << std::endl;
3632 
3633    try
3634    {
3635       RUN_SUBMATRIX_SPARSE_TEST;
3636    }
3637    catch( std::exception& ex ) {
3638       std::cerr << "\n\n ERROR DETECTED during Submatrix sparse test (part 1):\n"
3639                 << ex.what() << "\n";
3640       return EXIT_FAILURE;
3641    }
3642 
3643    return EXIT_SUCCESS;
3644 }
3645 //*************************************************************************************************
3646