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