1 //=================================================================================================
2 /*!
3 // \file src/mathtest/operations/smatsmatsub/AliasingTest.cpp
4 // \brief Source file for the sparse matrix/sparse matrix subtraction aliasing test
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 <blazetest/mathtest/operations/smatsmatsub/AliasingTest.h>
43
44 #ifdef BLAZE_USE_HPX_THREADS
45 # include <hpx/hpx_main.hpp>
46 #endif
47
48
49 namespace blazetest {
50
51 namespace mathtest {
52
53 namespace operations {
54
55 namespace smatsmatsub {
56
57 //=================================================================================================
58 //
59 // CONSTRUCTORS
60 //
61 //=================================================================================================
62
63 //*************************************************************************************************
64 /*!\brief Constructor for the aliasing test class.
65 //
66 // \exception std::runtime_error Operation error detected.
67 */
AliasingTest()68 AliasingTest::AliasingTest()
69 : sA3x4_ ( 3UL, 4UL )
70 , sB4x3_ ( 4UL, 3UL )
71 , sC3x3_ ( 3UL, 3UL )
72 , sD3x3_ ( 3UL, 3UL )
73 , sE3x3_ ( 3UL, 3UL )
74 , tsA3x4_( 3UL, 4UL )
75 , tsB4x3_( 4UL, 3UL )
76 , tsC3x3_( 3UL, 3UL )
77 , tsD3x3_( 3UL, 3UL )
78 , tsE3x3_( 3UL, 3UL )
79 {
80 testSMatSMatSub ();
81 testSMatTSMatSub ();
82 testTSMatTSMatSub();
83 }
84 //*************************************************************************************************
85
86
87
88
89 //=================================================================================================
90 //
91 // TEST FUNCTIONS
92 //
93 //=================================================================================================
94
95 //*************************************************************************************************
96 /*!\brief Test of the sparse matrix/sparse matrix subtraction.
97 //
98 // \return void
99 // \exception std::runtime_error Error detected.
100 //
101 // This function performs aliasing tests for the sparse matrix/sparse matrix subtraction.
102 // In case an error is detected, a \a std::runtime_error exception is thrown.
103 */
testSMatSMatSub()104 void AliasingTest::testSMatSMatSub()
105 {
106 //=====================================================================================
107 // Subtraction
108 //=====================================================================================
109
110 // Assignment to left-hand side operand (1)
111 {
112 test_ = "SMatSMatSub - Assignment to left-hand side operand (1)";
113
114 initialize();
115
116 result_ = sC3x3_ - sD3x3_;
117 sC3x3_ = sC3x3_ - sD3x3_;
118
119 checkResult( sC3x3_, result_ );
120 }
121
122 // Assignment to left-hand side operand (2)
123 {
124 test_ = "SMatSMatSub - Assignment to left-hand side operand (2)";
125
126 initialize();
127
128 result_ = sC3x3_ - eval( sD3x3_ );
129 sC3x3_ = sC3x3_ - eval( sD3x3_ );
130
131 checkResult( sC3x3_, result_ );
132 }
133
134 // Assignment to first operand of left-hand side compound
135 {
136 test_ = "SMatSMatSub - Assignment to first operand of left-hand side compound";
137
138 initialize();
139
140 result_ = ( sA3x4_ * sB4x3_ ) - sD3x3_;
141 sA3x4_ = ( sA3x4_ * sB4x3_ ) - sD3x3_;
142
143 checkResult( sA3x4_, result_ );
144 }
145
146 // Assignment to second operand of left-hand side compound
147 {
148 test_ = "SMatSMatSub - Assignment to second operand of left-hand side compound";
149
150 initialize();
151
152 result_ = ( sA3x4_ * sB4x3_ ) - sD3x3_;
153 sB4x3_ = ( sA3x4_ * sB4x3_ ) - sD3x3_;
154
155 checkResult( sB4x3_, result_ );
156 }
157
158 // Assignment to right-hand side operand (1)
159 {
160 test_ = "SMatSMatSub - Assignment to right-hand side operand (1)";
161
162 initialize();
163
164 result_ = sC3x3_ - sD3x3_;
165 sD3x3_ = sC3x3_ - sD3x3_;
166
167 checkResult( sD3x3_, result_ );
168 }
169
170 // Assignment to right-hand side operand (2)
171 {
172 test_ = "SMatSMatSub - Assignment to right-hand side operand (2)";
173
174 initialize();
175
176 result_ = eval( sC3x3_ ) - sD3x3_;
177 sD3x3_ = eval( sC3x3_ ) - sD3x3_;
178
179 checkResult( sD3x3_, result_ );
180 }
181
182 // Assignment to first operand of right-hand side compound
183 {
184 test_ = "SMatSMatSub - Assignment to first operand of right-hand side compound";
185
186 initialize();
187
188 result_ = sC3x3_ - ( sA3x4_ * sB4x3_ );
189 sA3x4_ = sC3x3_ - ( sA3x4_ * sB4x3_ );
190
191 checkResult( sA3x4_, result_ );
192 }
193
194 // Assignment to second operand of right-hand side compound
195 {
196 test_ = "SMatSMatSub - Assignment to second operand of right-hand side compound";
197
198 initialize();
199
200 result_ = sC3x3_ - ( sA3x4_ * sB4x3_ );
201 sB4x3_ = sC3x3_ - ( sA3x4_ * sB4x3_ );
202
203 checkResult( sB4x3_, result_ );
204 }
205
206 // Complex operation: A = ( 2*A ) - ( B * C )
207 {
208 test_ = "SMatSMatSub - Complex operation: A = ( 2*A ) - ( B * C )";
209
210 initialize();
211
212 result_ = ( 2*sC3x3_ ) - ( sA3x4_ * sB4x3_ );
213 sC3x3_ = ( 2*sC3x3_ ) - ( sA3x4_ * sB4x3_ );
214
215 checkResult( sC3x3_, result_ );
216 }
217
218 // Complex operation: A = ( B * C ) - ( 2*A )
219 {
220 test_ = "SMatSMatSub - Complex operation: A = ( B * C ) - ( 2*A )";
221
222 initialize();
223
224 result_ = ( sA3x4_ * sB4x3_ ) - ( 2*sC3x3_ );
225 sC3x3_ = ( sA3x4_ * sB4x3_ ) - ( 2*sC3x3_ );
226
227 checkResult( sC3x3_, result_ );
228 }
229
230
231 //=====================================================================================
232 // Subtraction with addition assignment
233 //=====================================================================================
234
235 // Addition assignment to left-hand side operand (1)
236 {
237 test_ = "SMatSMatSub - Addition assignment to left-hand side operand (1)";
238
239 initialize();
240
241 result_ = sC3x3_;
242 result_ += sC3x3_ - sD3x3_;
243 sC3x3_ += sC3x3_ - sD3x3_;
244
245 checkResult( sC3x3_, result_ );
246 }
247
248 // Addition assignment to left-hand side operand (2)
249 {
250 test_ = "SMatSMatSub - Addition assignment to left-hand side operand (2)";
251
252 initialize();
253
254 result_ = sC3x3_;
255 result_ += sC3x3_ - eval( sD3x3_ );
256 sC3x3_ += sC3x3_ - eval( sD3x3_ );
257
258 checkResult( sC3x3_, result_ );
259 }
260
261 // Addition assignment to first operand of left-hand side compound
262 {
263 test_ = "SMatSMatSub - Addition assignment to first operand of left-hand side compound";
264
265 initialize();
266
267 result_ = sC3x3_;
268 result_ += ( sC3x3_ * sD3x3_ ) - sE3x3_;
269 sC3x3_ += ( sC3x3_ * sD3x3_ ) - sE3x3_;
270
271 checkResult( sC3x3_, result_ );
272 }
273
274 // Addition assignment to second operand of left-hand side compound
275 {
276 test_ = "SMatSMatSub - Addition assignment to second operand of left-hand side compound";
277
278 initialize();
279
280 result_ = sD3x3_;
281 result_ += ( sC3x3_ * sD3x3_ ) - sE3x3_;
282 sD3x3_ += ( sC3x3_ * sD3x3_ ) - sE3x3_;
283
284 checkResult( sD3x3_, result_ );
285 }
286
287 // Addition assignment to right-hand side operand (1)
288 {
289 test_ = "SMatSMatSub - Addition assignment to right-hand side operand (1)";
290
291 initialize();
292
293 result_ = sD3x3_;
294 result_ += sC3x3_ - sD3x3_;
295 sD3x3_ += sC3x3_ - sD3x3_;
296
297 checkResult( sD3x3_, result_ );
298 }
299
300 // Addition assignment to right-hand side operand (2)
301 {
302 test_ = "SMatSMatSub - Addition assignment to right-hand side operand (2)";
303
304 initialize();
305
306 result_ = sD3x3_;
307 result_ += eval( sC3x3_ ) - sD3x3_;
308 sD3x3_ += eval( sC3x3_ ) - sD3x3_;
309
310 checkResult( sD3x3_, result_ );
311 }
312
313 // Addition assignment to first operand of right-hand side compound
314 {
315 test_ = "SMatSMatSub - Addition assignment to first operand of right-hand side compound";
316
317 initialize();
318
319 result_ = sD3x3_;
320 result_ += sC3x3_ - ( sD3x3_ * sE3x3_ );
321 sD3x3_ += sC3x3_ - ( sD3x3_ * sE3x3_ );
322
323 checkResult( sD3x3_, result_ );
324 }
325
326 // Addition assignment to second operand of right-hand side compound
327 {
328 test_ = "SMatSMatSub - Addition assignment to second operand of right-hand side compound";
329
330 initialize();
331
332 result_ = sE3x3_;
333 result_ += sC3x3_ - ( sD3x3_ * sE3x3_ );
334 sE3x3_ += sC3x3_ - ( sD3x3_ * sE3x3_ );
335
336 checkResult( sE3x3_, result_ );
337 }
338
339 // Complex operation: A += ( 2*A ) - ( B * C )
340 {
341 test_ = "SMatSMatSub - Complex operation: A += ( 2*A ) - ( B * C )";
342
343 initialize();
344
345 result_ = sC3x3_;
346 result_ += ( 2*sC3x3_ ) - ( sA3x4_ * sB4x3_ );
347 sC3x3_ += ( 2*sC3x3_ ) - ( sA3x4_ * sB4x3_ );
348
349 checkResult( sC3x3_, result_ );
350 }
351
352 // Complex operation: A += ( B * C ) - ( 2*A )
353 {
354 test_ = "SMatSMatSub - Complex operation: A += ( B * C ) - ( 2*A )";
355
356 initialize();
357
358 result_ = sC3x3_;
359 result_ += ( sA3x4_ * sB4x3_ ) - ( 2*sC3x3_ );
360 sC3x3_ += ( sA3x4_ * sB4x3_ ) - ( 2*sC3x3_ );
361
362 checkResult( sC3x3_, result_ );
363 }
364
365
366 //=====================================================================================
367 // Subtraction with subtraction assignment
368 //=====================================================================================
369
370 // Subtraction assignment to left-hand side operand (1)
371 {
372 test_ = "SMatSMatSub - Subtraction assignment to left-hand side operand (1)";
373
374 initialize();
375
376 result_ = sC3x3_;
377 result_ -= sC3x3_ - sD3x3_;
378 sC3x3_ -= sC3x3_ - sD3x3_;
379
380 checkResult( sC3x3_, result_ );
381 }
382
383 // Subtraction assignment to left-hand side operand (2)
384 {
385 test_ = "SMatSMatSub - Subtraction assignment to left-hand side operand (2)";
386
387 initialize();
388
389 result_ = sC3x3_;
390 result_ -= sC3x3_ - eval( sD3x3_ );
391 sC3x3_ -= sC3x3_ - eval( sD3x3_ );
392
393 checkResult( sC3x3_, result_ );
394 }
395
396 // Subtraction assignment to first operand of left-hand side compound
397 {
398 test_ = "SMatSMatSub - Subtraction assignment to first operand of left-hand side compound";
399
400 initialize();
401
402 result_ = sC3x3_;
403 result_ -= ( sC3x3_ * sD3x3_ ) - sE3x3_;
404 sC3x3_ -= ( sC3x3_ * sD3x3_ ) - sE3x3_;
405
406 checkResult( sC3x3_, result_ );
407 }
408
409 // Subtraction assignment to second operand of left-hand side compound
410 {
411 test_ = "SMatSMatSub - Subtraction assignment to second operand of left-hand side compound";
412
413 initialize();
414
415 result_ = sD3x3_;
416 result_ -= ( sC3x3_ * sD3x3_ ) - sE3x3_;
417 sD3x3_ -= ( sC3x3_ * sD3x3_ ) - sE3x3_;
418
419 checkResult( sD3x3_, result_ );
420 }
421
422 // Subtraction assignment to right-hand side operand (1)
423 {
424 test_ = "SMatSMatSub - Subtraction assignment to right-hand side operand (1)";
425
426 initialize();
427
428 result_ = sD3x3_;
429 result_ -= sC3x3_ - sD3x3_;
430 sD3x3_ -= sC3x3_ - sD3x3_;
431
432 checkResult( sD3x3_, result_ );
433 }
434
435 // Subtraction assignment to right-hand side operand (2)
436 {
437 test_ = "SMatSMatSub - Subtraction assignment to right-hand side operand (2)";
438
439 initialize();
440
441 result_ = sD3x3_;
442 result_ -= eval( sC3x3_ ) - sD3x3_;
443 sD3x3_ -= eval( sC3x3_ ) - sD3x3_;
444
445 checkResult( sD3x3_, result_ );
446 }
447
448 // Subtraction assignment to first operand of right-hand side compound
449 {
450 test_ = "SMatSMatSub - Subtraction assignment to first operand of right-hand side compound";
451
452 initialize();
453
454 result_ = sD3x3_;
455 result_ -= sC3x3_ - ( sD3x3_ * sE3x3_ );
456 sD3x3_ -= sC3x3_ - ( sD3x3_ * sE3x3_ );
457
458 checkResult( sD3x3_, result_ );
459 }
460
461 // Subtraction assignment to second operand of right-hand side compound
462 {
463 test_ = "SMatSMatSub - Subtraction assignment to second operand of right-hand side compound";
464
465 initialize();
466
467 result_ = sE3x3_;
468 result_ -= sC3x3_ - ( sD3x3_ * sE3x3_ );
469 sE3x3_ -= sC3x3_ - ( sD3x3_ * sE3x3_ );
470
471 checkResult( sE3x3_, result_ );
472 }
473
474 // Complex operation: A -= ( 2*A ) - ( B * C )
475 {
476 test_ = "SMatSMatSub - Complex operation: A -= ( 2*A ) - ( B * C )";
477
478 initialize();
479
480 result_ = sC3x3_;
481 result_ -= ( 2*sC3x3_ ) - ( sA3x4_ * sB4x3_ );
482 sC3x3_ -= ( 2*sC3x3_ ) - ( sA3x4_ * sB4x3_ );
483
484 checkResult( sC3x3_, result_ );
485 }
486
487 // Complex operation: A -= ( B * C ) - ( 2*A )
488 {
489 test_ = "SMatSMatSub - Complex operation: A -= ( B * C ) - ( 2*A )";
490
491 initialize();
492
493 result_ = sC3x3_;
494 result_ -= ( sA3x4_ * sB4x3_ ) - ( 2*sC3x3_ );
495 sC3x3_ -= ( sA3x4_ * sB4x3_ ) - ( 2*sC3x3_ );
496
497 checkResult( sC3x3_, result_ );
498 }
499
500
501 //=====================================================================================
502 // Subtraction with Schur product assignment
503 //=====================================================================================
504
505 // Schur product assignment to left-hand side operand (1)
506 {
507 test_ = "SMatSMatSub - Schur product assignment to left-hand side operand (1)";
508
509 initialize();
510
511 result_ = sC3x3_;
512 result_ %= sC3x3_ - sD3x3_;
513 sC3x3_ %= sC3x3_ - sD3x3_;
514
515 checkResult( sC3x3_, result_ );
516 }
517
518 // Schur product assignment to left-hand side operand (2)
519 {
520 test_ = "SMatSMatSub - Schur product assignment to left-hand side operand (2)";
521
522 initialize();
523
524 result_ = sC3x3_;
525 result_ %= sC3x3_ - eval( sD3x3_ );
526 sC3x3_ %= sC3x3_ - eval( sD3x3_ );
527
528 checkResult( sC3x3_, result_ );
529 }
530
531 // Schur product assignment to first operand of left-hand side compound
532 {
533 test_ = "SMatSMatSub - Schur product assignment to first operand of left-hand side compound";
534
535 initialize();
536
537 result_ = sC3x3_;
538 result_ %= ( sC3x3_ * sD3x3_ ) - sE3x3_;
539 sC3x3_ %= ( sC3x3_ * sD3x3_ ) - sE3x3_;
540
541 checkResult( sC3x3_, result_ );
542 }
543
544 // Schur product assignment to second operand of left-hand side compound
545 {
546 test_ = "SMatSMatSub - Schur product assignment to second operand of left-hand side compound";
547
548 initialize();
549
550 result_ = sD3x3_;
551 result_ %= ( sC3x3_ * sD3x3_ ) - sE3x3_;
552 sD3x3_ %= ( sC3x3_ * sD3x3_ ) - sE3x3_;
553
554 checkResult( sD3x3_, result_ );
555 }
556
557 // Schur product assignment to right-hand side operand (1)
558 {
559 test_ = "SMatSMatSub - Schur product assignment to right-hand side operand (1)";
560
561 initialize();
562
563 result_ = sD3x3_;
564 result_ %= sC3x3_ - sD3x3_;
565 sD3x3_ %= sC3x3_ - sD3x3_;
566
567 checkResult( sD3x3_, result_ );
568 }
569
570 // Schur product assignment to right-hand side operand (2)
571 {
572 test_ = "SMatSMatSub - Schur product assignment to right-hand side operand (2)";
573
574 initialize();
575
576 result_ = sD3x3_;
577 result_ %= eval( sC3x3_ ) - sD3x3_;
578 sD3x3_ %= eval( sC3x3_ ) - sD3x3_;
579
580 checkResult( sD3x3_, result_ );
581 }
582
583 // Schur product assignment to first operand of right-hand side compound
584 {
585 test_ = "SMatSMatSub - Schur product assignment to first operand of right-hand side compound";
586
587 initialize();
588
589 result_ = sD3x3_;
590 result_ %= sC3x3_ - ( sD3x3_ * sE3x3_ );
591 sD3x3_ %= sC3x3_ - ( sD3x3_ * sE3x3_ );
592
593 checkResult( sD3x3_, result_ );
594 }
595
596 // Schur product assignment to second operand of right-hand side compound
597 {
598 test_ = "SMatSMatSub - Schur product assignment to second operand of right-hand side compound";
599
600 initialize();
601
602 result_ = sE3x3_;
603 result_ %= sC3x3_ - ( sD3x3_ * sE3x3_ );
604 sE3x3_ %= sC3x3_ - ( sD3x3_ * sE3x3_ );
605
606 checkResult( sE3x3_, result_ );
607 }
608
609 // Complex operation: A %= ( 2*A ) - ( B * C )
610 {
611 test_ = "SMatSMatSub - Complex operation: A %= ( 2*A ) - ( B * C )";
612
613 initialize();
614
615 result_ = sC3x3_;
616 result_ %= ( 2*sC3x3_ ) - ( sA3x4_ * sB4x3_ );
617 sC3x3_ %= ( 2*sC3x3_ ) - ( sA3x4_ * sB4x3_ );
618
619 checkResult( sC3x3_, result_ );
620 }
621
622 // Complex operation: A %= ( B * C ) - ( 2*A )
623 {
624 test_ = "SMatSMatSub - Complex operation: A %= ( B * C ) - ( 2*A )";
625
626 initialize();
627
628 result_ = sC3x3_;
629 result_ %= ( sA3x4_ * sB4x3_ ) - ( 2*sC3x3_ );
630 sC3x3_ %= ( sA3x4_ * sB4x3_ ) - ( 2*sC3x3_ );
631
632 checkResult( sC3x3_, result_ );
633 }
634
635
636 //=====================================================================================
637 // Subtraction with multiplication assignment
638 //=====================================================================================
639
640 // Multiplication assignment to left-hand side operand (1)
641 {
642 test_ = "SMatSMatSub - Multiplication assignment to left-hand side operand (1)";
643
644 initialize();
645
646 result_ = sC3x3_;
647 result_ *= sC3x3_ - sD3x3_;
648 sC3x3_ *= sC3x3_ - sD3x3_;
649
650 checkResult( sC3x3_, result_ );
651 }
652
653 // Multiplication assignment to left-hand side operand (2)
654 {
655 test_ = "SMatSMatSub - Multiplication assignment to left-hand side operand (2)";
656
657 initialize();
658
659 result_ = sC3x3_;
660 result_ *= sC3x3_ - eval( sD3x3_ );
661 sC3x3_ *= sC3x3_ - eval( sD3x3_ );
662
663 checkResult( sC3x3_, result_ );
664 }
665
666 // Multiplication assignment to first operand of left-hand side compound
667 {
668 test_ = "SMatSMatSub - Multiplication assignment to first operand of left-hand side compound";
669
670 initialize();
671
672 result_ = sC3x3_;
673 result_ *= ( sC3x3_ * sD3x3_ ) - sE3x3_;
674 sC3x3_ *= ( sC3x3_ * sD3x3_ ) - sE3x3_;
675
676 checkResult( sC3x3_, result_ );
677 }
678
679 // Multiplication assignment to second operand of left-hand side compound
680 {
681 test_ = "SMatSMatSub - Multiplication assignment to second operand of left-hand side compound";
682
683 initialize();
684
685 result_ = sD3x3_;
686 result_ *= ( sC3x3_ * sD3x3_ ) - sE3x3_;
687 sD3x3_ *= ( sC3x3_ * sD3x3_ ) - sE3x3_;
688
689 checkResult( sD3x3_, result_ );
690 }
691
692 // Multiplication assignment to right-hand side operand (1)
693 {
694 test_ = "SMatSMatSub - Multiplication assignment to right-hand side operand (1)";
695
696 initialize();
697
698 result_ = sD3x3_;
699 result_ *= sC3x3_ - sD3x3_;
700 sD3x3_ *= sC3x3_ - sD3x3_;
701
702 checkResult( sD3x3_, result_ );
703 }
704
705 // Multiplication assignment to right-hand side operand (2)
706 {
707 test_ = "SMatSMatSub - Multiplication assignment to right-hand side operand (2)";
708
709 initialize();
710
711 result_ = sD3x3_;
712 result_ *= eval( sC3x3_ ) - sD3x3_;
713 sD3x3_ *= eval( sC3x3_ ) - sD3x3_;
714
715 checkResult( sD3x3_, result_ );
716 }
717
718 // Multiplication assignment to first operand of right-hand side compound
719 {
720 test_ = "SMatSMatSub - Multiplication assignment to first operand of right-hand side compound";
721
722 initialize();
723
724 result_ = sD3x3_;
725 result_ *= sC3x3_ - ( sD3x3_ * sE3x3_ );
726 sD3x3_ *= sC3x3_ - ( sD3x3_ * sE3x3_ );
727
728 checkResult( sD3x3_, result_ );
729 }
730
731 // Multiplication assignment to second operand of right-hand side compound
732 {
733 test_ = "SMatSMatSub - Multiplication assignment to second operand of right-hand side compound";
734
735 initialize();
736
737 result_ = sE3x3_;
738 result_ *= sC3x3_ - ( sD3x3_ * sE3x3_ );
739 sE3x3_ *= sC3x3_ - ( sD3x3_ * sE3x3_ );
740
741 checkResult( sE3x3_, result_ );
742 }
743
744 // Complex operation: A *= ( 2*A ) - ( B * C )
745 {
746 test_ = "SMatSMatSub - Complex operation: A *= ( 2*A ) - ( B * C )";
747
748 initialize();
749
750 result_ = sC3x3_;
751 result_ *= ( 2*sC3x3_ ) - ( sA3x4_ * sB4x3_ );
752 sC3x3_ *= ( 2*sC3x3_ ) - ( sA3x4_ * sB4x3_ );
753
754 checkResult( sC3x3_, result_ );
755 }
756
757 // Complex operation: A *= ( B * C ) - ( 2*A )
758 {
759 test_ = "SMatSMatSub - Complex operation: A *= ( B * C ) - ( 2*A )";
760
761 initialize();
762
763 result_ = sC3x3_;
764 result_ *= ( sA3x4_ * sB4x3_ ) - ( 2*sC3x3_ );
765 sC3x3_ *= ( sA3x4_ * sB4x3_ ) - ( 2*sC3x3_ );
766
767 checkResult( sC3x3_, result_ );
768 }
769 }
770 //*************************************************************************************************
771
772
773 //*************************************************************************************************
774 /*!\brief Test of the sparse matrix/transpose sparse matrix subtraction.
775 //
776 // \return void
777 // \exception std::runtime_error Error detected.
778 //
779 // This function performs aliasing tests for the sparse matrix/transpose sparse matrix
780 // subtraction. In case an error is detected, a \a std::runtime_error exception is thrown.
781 */
testSMatTSMatSub()782 void AliasingTest::testSMatTSMatSub()
783 {
784 //=====================================================================================
785 // Subtraction
786 //=====================================================================================
787
788 // Assignment to left-hand side operand (1)
789 {
790 test_ = "SMatTSMatSub - Assignment to left-hand side operand (1)";
791
792 initialize();
793
794 result_ = sC3x3_ - tsD3x3_;
795 sC3x3_ = sC3x3_ - tsD3x3_;
796
797 checkResult( sC3x3_, result_ );
798 }
799
800 // Assignment to left-hand side operand (2)
801 {
802 test_ = "SMatTSMatSub - Assignment to left-hand side operand (2)";
803
804 initialize();
805
806 result_ = sC3x3_ - eval( tsD3x3_ );
807 sC3x3_ = sC3x3_ - eval( tsD3x3_ );
808
809 checkResult( sC3x3_, result_ );
810 }
811
812 // Assignment to first operand of left-hand side compound
813 {
814 test_ = "SMatTSMatSub - Assignment to first operand of left-hand side compound";
815
816 initialize();
817
818 result_ = ( sA3x4_ * sB4x3_ ) - tsD3x3_;
819 sA3x4_ = ( sA3x4_ * sB4x3_ ) - tsD3x3_;
820
821 checkResult( sA3x4_, result_ );
822 }
823
824 // Assignment to second operand of left-hand side compound
825 {
826 test_ = "SMatTSMatSub - Assignment to second operand of left-hand side compound";
827
828 initialize();
829
830 result_ = ( sA3x4_ * sB4x3_ ) - tsD3x3_;
831 sB4x3_ = ( sA3x4_ * sB4x3_ ) - tsD3x3_;
832
833 checkResult( sB4x3_, result_ );
834 }
835
836 // Assignment to right-hand side operand (1)
837 {
838 test_ = "SMatTSMatSub - Assignment to right-hand side operand (1)";
839
840 initialize();
841
842 result_ = sC3x3_ - tsD3x3_;
843 tsD3x3_ = sC3x3_ - tsD3x3_;
844
845 checkResult( tsD3x3_, result_ );
846 }
847
848 // Assignment to right-hand side operand (2)
849 {
850 test_ = "SMatTSMatSub - Assignment to right-hand side operand (2)";
851
852 initialize();
853
854 result_ = eval( sC3x3_ ) - tsD3x3_;
855 tsD3x3_ = eval( sC3x3_ ) - tsD3x3_;
856
857 checkResult( tsD3x3_, result_ );
858 }
859
860 // Assignment to first operand of right-hand side compound
861 {
862 test_ = "SMatTSMatSub - Assignment to first operand of right-hand side compound";
863
864 initialize();
865
866 result_ = sC3x3_ - ( tsA3x4_ * tsB4x3_ );
867 tsA3x4_ = sC3x3_ - ( tsA3x4_ * tsB4x3_ );
868
869 checkResult( tsA3x4_, result_ );
870 }
871
872 // Assignment to second operand of right-hand side compound
873 {
874 test_ = "SMatTSMatSub - Assignment to second operand of right-hand side compound";
875
876 initialize();
877
878 result_ = sC3x3_ - ( tsA3x4_ * tsB4x3_ );
879 tsB4x3_ = sC3x3_ - ( tsA3x4_ * tsB4x3_ );
880
881 checkResult( tsB4x3_, result_ );
882 }
883
884 // Complex operation: A = ( 2*A ) - ( B * C )
885 {
886 test_ = "SMatTSMatSub - Complex operation: A = ( 2*A ) - ( B * C )";
887
888 initialize();
889
890 result_ = ( 2*sC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
891 sC3x3_ = ( 2*sC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
892
893 checkResult( sC3x3_, result_ );
894 }
895
896 // Complex operation: A = ( B * C ) - ( 2*A )
897 {
898 test_ = "SMatTSMatSub - Complex operation: A = ( B * C ) - ( 2*A )";
899
900 initialize();
901
902 result_ = ( sA3x4_ * sB4x3_ ) - ( 2*tsC3x3_ );
903 tsC3x3_ = ( sA3x4_ * sB4x3_ ) - ( 2*tsC3x3_ );
904
905 checkResult( tsC3x3_, result_ );
906 }
907
908
909 //=====================================================================================
910 // Subtraction with addition assignment
911 //=====================================================================================
912
913 // Addition assignment to left-hand side operand (1)
914 {
915 test_ = "SMatTSMatSub - Addition assignment to left-hand side operand (1)";
916
917 initialize();
918
919 result_ = sC3x3_;
920 result_ += sC3x3_ - tsD3x3_;
921 sC3x3_ += sC3x3_ - tsD3x3_;
922
923 checkResult( sC3x3_, result_ );
924 }
925
926 // Addition assignment to left-hand side operand (2)
927 {
928 test_ = "SMatTSMatSub - Addition assignment to left-hand side operand (2)";
929
930 initialize();
931
932 result_ = sC3x3_;
933 result_ += sC3x3_ - eval( tsD3x3_ );
934 sC3x3_ += sC3x3_ - eval( tsD3x3_ );
935
936 checkResult( sC3x3_, result_ );
937 }
938
939 // Addition assignment to first operand of left-hand side compound
940 {
941 test_ = "SMatTSMatSub - Addition assignment to first operand of left-hand side compound";
942
943 initialize();
944
945 result_ = sC3x3_;
946 result_ += ( sC3x3_ * sD3x3_ ) - tsE3x3_;
947 sC3x3_ += ( sC3x3_ * sD3x3_ ) - tsE3x3_;
948
949 checkResult( sC3x3_, result_ );
950 }
951
952 // Addition assignment to second operand of left-hand side compound
953 {
954 test_ = "SMatTSMatSub - Addition assignment to second operand of left-hand side compound";
955
956 initialize();
957
958 result_ = sD3x3_;
959 result_ += ( sC3x3_ * sD3x3_ ) - tsE3x3_;
960 sD3x3_ += ( sC3x3_ * sD3x3_ ) - tsE3x3_;
961
962 checkResult( sD3x3_, result_ );
963 }
964
965 // Addition assignment to right-hand side operand (1)
966 {
967 test_ = "SMatTSMatSub - Addition assignment to right-hand side operand (1)";
968
969 initialize();
970
971 result_ = tsD3x3_;
972 result_ += sC3x3_ - tsD3x3_;
973 tsD3x3_ += sC3x3_ - tsD3x3_;
974
975 checkResult( tsD3x3_, result_ );
976 }
977
978 // Addition assignment to right-hand side operand (2)
979 {
980 test_ = "SMatTSMatSub - Addition assignment to right-hand side operand (2)";
981
982 initialize();
983
984 result_ = tsD3x3_;
985 result_ += eval( sC3x3_ ) - tsD3x3_;
986 tsD3x3_ += eval( sC3x3_ ) - tsD3x3_;
987
988 checkResult( tsD3x3_, result_ );
989 }
990
991 // Addition assignment to first operand of right-hand side compound
992 {
993 test_ = "SMatTSMatSub - Addition assignment to first operand of right-hand side compound";
994
995 initialize();
996
997 result_ = tsD3x3_;
998 result_ += sC3x3_ - ( tsD3x3_ * tsE3x3_ );
999 tsD3x3_ += sC3x3_ - ( tsD3x3_ * tsE3x3_ );
1000
1001 checkResult( tsD3x3_, result_ );
1002 }
1003
1004 // Addition assignment to second operand of right-hand side compound
1005 {
1006 test_ = "SMatTSMatSub - Addition assignment to second operand of right-hand side compound";
1007
1008 initialize();
1009
1010 result_ = tsE3x3_;
1011 result_ += sC3x3_ - ( tsD3x3_ * tsE3x3_ );
1012 tsE3x3_ += sC3x3_ - ( tsD3x3_ * tsE3x3_ );
1013
1014 checkResult( tsE3x3_, result_ );
1015 }
1016
1017 // Complex operation: A += ( 2*A ) - ( B * C )
1018 {
1019 test_ = "SMatTSMatSub - Complex operation: A += ( 2*A ) - ( B * C )";
1020
1021 initialize();
1022
1023 result_ = sC3x3_;
1024 result_ += ( 2*sC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
1025 sC3x3_ += ( 2*sC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
1026
1027 checkResult( sC3x3_, result_ );
1028 }
1029
1030 // Complex operation: A += ( B * C ) - ( 2*A )
1031 {
1032 test_ = "SMatTSMatSub - Complex operation: A += ( B * C ) - ( 2*A )";
1033
1034 initialize();
1035
1036 result_ = tsC3x3_;
1037 result_ += ( sA3x4_ * sB4x3_ ) - ( 2*tsC3x3_ );
1038 tsC3x3_ += ( sA3x4_ * sB4x3_ ) - ( 2*tsC3x3_ );
1039
1040 checkResult( tsC3x3_, result_ );
1041 }
1042
1043
1044 //=====================================================================================
1045 // Subtraction with subtraction assignment
1046 //=====================================================================================
1047
1048 // Subtraction assignment to left-hand side operand (1)
1049 {
1050 test_ = "SMatTSMatSub - Subtraction assignment to left-hand side operand (1)";
1051
1052 initialize();
1053
1054 result_ = sC3x3_;
1055 result_ -= sC3x3_ - tsD3x3_;
1056 sC3x3_ -= sC3x3_ - tsD3x3_;
1057
1058 checkResult( sC3x3_, result_ );
1059 }
1060
1061 // Subtraction assignment to left-hand side operand (2)
1062 {
1063 test_ = "SMatTSMatSub - Subtraction assignment to left-hand side operand (2)";
1064
1065 initialize();
1066
1067 result_ = sC3x3_;
1068 result_ -= sC3x3_ - eval( tsD3x3_ );
1069 sC3x3_ -= sC3x3_ - eval( tsD3x3_ );
1070
1071 checkResult( sC3x3_, result_ );
1072 }
1073
1074 // Subtraction assignment to first operand of left-hand side compound
1075 {
1076 test_ = "SMatTSMatSub - Subtraction assignment to first operand of left-hand side compound";
1077
1078 initialize();
1079
1080 result_ = sC3x3_;
1081 result_ -= ( sC3x3_ * sD3x3_ ) - tsE3x3_;
1082 sC3x3_ -= ( sC3x3_ * sD3x3_ ) - tsE3x3_;
1083
1084 checkResult( sC3x3_, result_ );
1085 }
1086
1087 // Subtraction assignment to second operand of left-hand side compound
1088 {
1089 test_ = "SMatTSMatSub - Subtraction assignment to second operand of left-hand side compound";
1090
1091 initialize();
1092
1093 result_ = sD3x3_;
1094 result_ -= ( sC3x3_ * sD3x3_ ) - tsE3x3_;
1095 sD3x3_ -= ( sC3x3_ * sD3x3_ ) - tsE3x3_;
1096
1097 checkResult( sD3x3_, result_ );
1098 }
1099
1100 // Subtraction assignment to right-hand side operand (1)
1101 {
1102 test_ = "SMatTSMatSub - Subtraction assignment to right-hand side operand (1)";
1103
1104 initialize();
1105
1106 result_ = tsD3x3_;
1107 result_ -= sC3x3_ - tsD3x3_;
1108 tsD3x3_ -= sC3x3_ - tsD3x3_;
1109
1110 checkResult( tsD3x3_, result_ );
1111 }
1112
1113 // Subtraction assignment to right-hand side operand (2)
1114 {
1115 test_ = "SMatTSMatSub - Subtraction assignment to right-hand side operand (2)";
1116
1117 initialize();
1118
1119 result_ = tsD3x3_;
1120 result_ -= eval( sC3x3_ ) - tsD3x3_;
1121 tsD3x3_ -= eval( sC3x3_ ) - tsD3x3_;
1122
1123 checkResult( tsD3x3_, result_ );
1124 }
1125
1126 // Subtraction assignment to first operand of right-hand side compound
1127 {
1128 test_ = "SMatTSMatSub - Subtraction assignment to first operand of right-hand side compound";
1129
1130 initialize();
1131
1132 result_ = tsD3x3_;
1133 result_ -= sC3x3_ - ( tsD3x3_ * tsE3x3_ );
1134 tsD3x3_ -= sC3x3_ - ( tsD3x3_ * tsE3x3_ );
1135
1136 checkResult( tsD3x3_, result_ );
1137 }
1138
1139 // Subtraction assignment to second operand of right-hand side compound
1140 {
1141 test_ = "SMatTSMatSub - Subtraction assignment to second operand of right-hand side compound";
1142
1143 initialize();
1144
1145 result_ = tsE3x3_;
1146 result_ -= sC3x3_ - ( tsD3x3_ * tsE3x3_ );
1147 tsE3x3_ -= sC3x3_ - ( tsD3x3_ * tsE3x3_ );
1148
1149 checkResult( tsE3x3_, result_ );
1150 }
1151
1152 // Complex operation: A -= ( 2*A ) - ( B * C )
1153 {
1154 test_ = "SMatTSMatSub - Complex operation: A -= ( 2*A ) - ( B * C )";
1155
1156 initialize();
1157
1158 result_ = sC3x3_;
1159 result_ -= ( 2*sC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
1160 sC3x3_ -= ( 2*sC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
1161
1162 checkResult( sC3x3_, result_ );
1163 }
1164
1165 // Complex operation: A -= ( B * C ) - ( 2*A )
1166 {
1167 test_ = "SMatTSMatSub - Complex operation: A -= ( B * C ) - ( 2*A )";
1168
1169 initialize();
1170
1171 result_ = tsC3x3_;
1172 result_ -= ( sA3x4_ * sB4x3_ ) - ( 2*tsC3x3_ );
1173 tsC3x3_ -= ( sA3x4_ * sB4x3_ ) - ( 2*tsC3x3_ );
1174
1175 checkResult( tsC3x3_, result_ );
1176 }
1177
1178
1179 //=====================================================================================
1180 // Subtraction with Schur product assignment
1181 //=====================================================================================
1182
1183 // Schur product assignment to left-hand side operand (1)
1184 {
1185 test_ = "SMatTSMatSub - Schur product assignment to left-hand side operand (1)";
1186
1187 initialize();
1188
1189 result_ = sC3x3_;
1190 result_ %= sC3x3_ - tsD3x3_;
1191 sC3x3_ %= sC3x3_ - tsD3x3_;
1192
1193 checkResult( sC3x3_, result_ );
1194 }
1195
1196 // Schur product assignment to left-hand side operand (2)
1197 {
1198 test_ = "SMatTSMatSub - Schur product assignment to left-hand side operand (2)";
1199
1200 initialize();
1201
1202 result_ = sC3x3_;
1203 result_ %= sC3x3_ - eval( tsD3x3_ );
1204 sC3x3_ %= sC3x3_ - eval( tsD3x3_ );
1205
1206 checkResult( sC3x3_, result_ );
1207 }
1208
1209 // Schur product assignment to first operand of left-hand side compound
1210 {
1211 test_ = "SMatTSMatSub - Schur product assignment to first operand of left-hand side compound";
1212
1213 initialize();
1214
1215 result_ = sC3x3_;
1216 result_ %= ( sC3x3_ * sD3x3_ ) - tsE3x3_;
1217 sC3x3_ %= ( sC3x3_ * sD3x3_ ) - tsE3x3_;
1218
1219 checkResult( sC3x3_, result_ );
1220 }
1221
1222 // Schur product assignment to second operand of left-hand side compound
1223 {
1224 test_ = "SMatTSMatSub - Schur product assignment to second operand of left-hand side compound";
1225
1226 initialize();
1227
1228 result_ = sD3x3_;
1229 result_ %= ( sC3x3_ * sD3x3_ ) - tsE3x3_;
1230 sD3x3_ %= ( sC3x3_ * sD3x3_ ) - tsE3x3_;
1231
1232 checkResult( sD3x3_, result_ );
1233 }
1234
1235 // Schur product assignment to right-hand side operand (1)
1236 {
1237 test_ = "SMatTSMatSub - Schur product assignment to right-hand side operand (1)";
1238
1239 initialize();
1240
1241 result_ = tsD3x3_;
1242 result_ %= sC3x3_ - tsD3x3_;
1243 tsD3x3_ %= sC3x3_ - tsD3x3_;
1244
1245 checkResult( tsD3x3_, result_ );
1246 }
1247
1248 // Schur product assignment to right-hand side operand (2)
1249 {
1250 test_ = "SMatTSMatSub - Schur product assignment to right-hand side operand (2)";
1251
1252 initialize();
1253
1254 result_ = tsD3x3_;
1255 result_ %= eval( sC3x3_ ) - tsD3x3_;
1256 tsD3x3_ %= eval( sC3x3_ ) - tsD3x3_;
1257
1258 checkResult( tsD3x3_, result_ );
1259 }
1260
1261 // Schur product assignment to first operand of right-hand side compound
1262 {
1263 test_ = "SMatTSMatSub - Schur product assignment to first operand of right-hand side compound";
1264
1265 initialize();
1266
1267 result_ = tsD3x3_;
1268 result_ %= sC3x3_ - ( tsD3x3_ * tsE3x3_ );
1269 tsD3x3_ %= sC3x3_ - ( tsD3x3_ * tsE3x3_ );
1270
1271 checkResult( tsD3x3_, result_ );
1272 }
1273
1274 // Schur product assignment to second operand of right-hand side compound
1275 {
1276 test_ = "SMatTSMatSub - Schur product assignment to second operand of right-hand side compound";
1277
1278 initialize();
1279
1280 result_ = tsE3x3_;
1281 result_ %= sC3x3_ - ( tsD3x3_ * tsE3x3_ );
1282 tsE3x3_ %= sC3x3_ - ( tsD3x3_ * tsE3x3_ );
1283
1284 checkResult( tsE3x3_, result_ );
1285 }
1286
1287 // Complex operation: A %= ( 2*A ) - ( B * C )
1288 {
1289 test_ = "SMatTSMatSub - Complex operation: A %= ( 2*A ) - ( B * C )";
1290
1291 initialize();
1292
1293 result_ = sC3x3_;
1294 result_ %= ( 2*sC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
1295 sC3x3_ %= ( 2*sC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
1296
1297 checkResult( sC3x3_, result_ );
1298 }
1299
1300 // Complex operation: A %= ( B * C ) - ( 2*A )
1301 {
1302 test_ = "SMatTSMatSub - Complex operation: A %= ( B * C ) - ( 2*A )";
1303
1304 initialize();
1305
1306 result_ = tsC3x3_;
1307 result_ %= ( sA3x4_ * sB4x3_ ) - ( 2*tsC3x3_ );
1308 tsC3x3_ %= ( sA3x4_ * sB4x3_ ) - ( 2*tsC3x3_ );
1309
1310 checkResult( tsC3x3_, result_ );
1311 }
1312
1313
1314 //=====================================================================================
1315 // Subtraction with multiplication assignment
1316 //=====================================================================================
1317
1318 // Multiplication assignment to left-hand side operand (1)
1319 {
1320 test_ = "SMatTSMatSub - Multiplication assignment to left-hand side operand (1)";
1321
1322 initialize();
1323
1324 result_ = sC3x3_;
1325 result_ *= sC3x3_ - tsD3x3_;
1326 sC3x3_ *= sC3x3_ - tsD3x3_;
1327
1328 checkResult( sC3x3_, result_ );
1329 }
1330
1331 // Multiplication assignment to left-hand side operand (2)
1332 {
1333 test_ = "SMatTSMatSub - Multiplication assignment to left-hand side operand (2)";
1334
1335 initialize();
1336
1337 result_ = sC3x3_;
1338 result_ *= sC3x3_ - eval( tsD3x3_ );
1339 sC3x3_ *= sC3x3_ - eval( tsD3x3_ );
1340
1341 checkResult( sC3x3_, result_ );
1342 }
1343
1344 // Multiplication assignment to first operand of left-hand side compound
1345 {
1346 test_ = "SMatTSMatSub - Multiplication assignment to first operand of left-hand side compound";
1347
1348 initialize();
1349
1350 result_ = sC3x3_;
1351 result_ *= ( sC3x3_ * sD3x3_ ) - tsE3x3_;
1352 sC3x3_ *= ( sC3x3_ * sD3x3_ ) - tsE3x3_;
1353
1354 checkResult( sC3x3_, result_ );
1355 }
1356
1357 // Multiplication assignment to second operand of left-hand side compound
1358 {
1359 test_ = "SMatTSMatSub - Multiplication assignment to second operand of left-hand side compound";
1360
1361 initialize();
1362
1363 result_ = sD3x3_;
1364 result_ *= ( sC3x3_ * sD3x3_ ) - tsE3x3_;
1365 sD3x3_ *= ( sC3x3_ * sD3x3_ ) - tsE3x3_;
1366
1367 checkResult( sD3x3_, result_ );
1368 }
1369
1370 // Multiplication assignment to right-hand side operand (1)
1371 {
1372 test_ = "SMatTSMatSub - Multiplication assignment to right-hand side operand (1)";
1373
1374 initialize();
1375
1376 result_ = tsD3x3_;
1377 result_ *= sC3x3_ - tsD3x3_;
1378 tsD3x3_ *= sC3x3_ - tsD3x3_;
1379
1380 checkResult( tsD3x3_, result_ );
1381 }
1382
1383 // Multiplication assignment to right-hand side operand (2)
1384 {
1385 test_ = "SMatTSMatSub - Multiplication assignment to right-hand side operand (2)";
1386
1387 initialize();
1388
1389 result_ = tsD3x3_;
1390 result_ *= eval( sC3x3_ ) - tsD3x3_;
1391 tsD3x3_ *= eval( sC3x3_ ) - tsD3x3_;
1392
1393 checkResult( tsD3x3_, result_ );
1394 }
1395
1396 // Multiplication assignment to first operand of right-hand side compound
1397 {
1398 test_ = "SMatTSMatSub - Multiplication assignment to first operand of right-hand side compound";
1399
1400 initialize();
1401
1402 result_ = tsD3x3_;
1403 result_ *= sC3x3_ - ( tsD3x3_ * tsE3x3_ );
1404 tsD3x3_ *= sC3x3_ - ( tsD3x3_ * tsE3x3_ );
1405
1406 checkResult( tsD3x3_, result_ );
1407 }
1408
1409 // Multiplication assignment to second operand of right-hand side compound
1410 {
1411 test_ = "SMatTSMatSub - Multiplication assignment to second operand of right-hand side compound";
1412
1413 initialize();
1414
1415 result_ = tsE3x3_;
1416 result_ *= sC3x3_ - ( tsD3x3_ * tsE3x3_ );
1417 tsE3x3_ *= sC3x3_ - ( tsD3x3_ * tsE3x3_ );
1418
1419 checkResult( tsE3x3_, result_ );
1420 }
1421
1422 // Complex operation: A *= ( 2*A ) - ( B * C )
1423 {
1424 test_ = "SMatTSMatSub - Complex operation: A *= ( 2*A ) - ( B * C )";
1425
1426 initialize();
1427
1428 result_ = sC3x3_;
1429 result_ *= ( 2*sC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
1430 sC3x3_ *= ( 2*sC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
1431
1432 checkResult( sC3x3_, result_ );
1433 }
1434
1435 // Complex operation: A *= ( B * C ) - ( 2*A )
1436 {
1437 test_ = "SMatTSMatSub - Complex operation: A *= ( B * C ) - ( 2*A )";
1438
1439 initialize();
1440
1441 result_ = tsC3x3_;
1442 result_ *= ( sA3x4_ * sB4x3_ ) - ( 2*tsC3x3_ );
1443 tsC3x3_ *= ( sA3x4_ * sB4x3_ ) - ( 2*tsC3x3_ );
1444
1445 checkResult( tsC3x3_, result_ );
1446 }
1447 }
1448 //*************************************************************************************************
1449
1450
1451 //*************************************************************************************************
1452 /*!\brief Test of the transpose sparse matrix/transpose sparse matrix subtraction.
1453 //
1454 // \return void
1455 // \exception std::runtime_error Error detected.
1456 //
1457 // This function performs aliasing tests for the transpose sparse matrix/transpose sparse
1458 // matrix subtraction. In case an error is detected, a \a std::runtime_error exception is
1459 // thrown.
1460 */
testTSMatTSMatSub()1461 void AliasingTest::testTSMatTSMatSub()
1462 {
1463 //=====================================================================================
1464 // Subtraction
1465 //=====================================================================================
1466
1467 // Assignment to left-hand side operand (1)
1468 {
1469 test_ = "TSMatTSMatSub - Assignment to left-hand side operand (1)";
1470
1471 initialize();
1472
1473 result_ = tsC3x3_ - tsD3x3_;
1474 tsC3x3_ = tsC3x3_ - tsD3x3_;
1475
1476 checkResult( tsC3x3_, result_ );
1477 }
1478
1479 // Assignment to left-hand side operand (2)
1480 {
1481 test_ = "TSMatTSMatSub - Assignment to left-hand side operand (2)";
1482
1483 initialize();
1484
1485 result_ = tsC3x3_ - eval( tsD3x3_ );
1486 tsC3x3_ = tsC3x3_ - eval( tsD3x3_ );
1487
1488 checkResult( tsC3x3_, result_ );
1489 }
1490
1491 // Assignment to first operand of left-hand side compound
1492 {
1493 test_ = "TSMatTSMatSub - Assignment to first operand of left-hand side compound";
1494
1495 initialize();
1496
1497 result_ = ( tsA3x4_ * tsB4x3_ ) - tsD3x3_;
1498 tsA3x4_ = ( tsA3x4_ * tsB4x3_ ) - tsD3x3_;
1499
1500 checkResult( tsA3x4_, result_ );
1501 }
1502
1503 // Assignment to second operand of left-hand side compound
1504 {
1505 test_ = "TSMatTSMatSub - Assignment to second operand of left-hand side compound";
1506
1507 initialize();
1508
1509 result_ = ( tsA3x4_ * tsB4x3_ ) - tsD3x3_;
1510 tsB4x3_ = ( tsA3x4_ * tsB4x3_ ) - tsD3x3_;
1511
1512 checkResult( tsB4x3_, result_ );
1513 }
1514
1515 // Assignment to right-hand side operand (1)
1516 {
1517 test_ = "TSMatTSMatSub - Assignment to right-hand side operand (1)";
1518
1519 initialize();
1520
1521 result_ = tsC3x3_ - tsD3x3_;
1522 tsD3x3_ = tsC3x3_ - tsD3x3_;
1523
1524 checkResult( tsD3x3_, result_ );
1525 }
1526
1527 // Assignment to right-hand side operand (2)
1528 {
1529 test_ = "TSMatTSMatSub - Assignment to right-hand side operand (2)";
1530
1531 initialize();
1532
1533 result_ = eval( tsC3x3_ ) - tsD3x3_;
1534 tsD3x3_ = eval( tsC3x3_ ) - tsD3x3_;
1535
1536 checkResult( tsD3x3_, result_ );
1537 }
1538
1539 // Assignment to first operand of right-hand side compound
1540 {
1541 test_ = "TSMatTSMatSub - Assignment to first operand of right-hand side compound";
1542
1543 initialize();
1544
1545 result_ = tsC3x3_ - ( tsA3x4_ * tsB4x3_ );
1546 tsA3x4_ = tsC3x3_ - ( tsA3x4_ * tsB4x3_ );
1547
1548 checkResult( tsA3x4_, result_ );
1549 }
1550
1551 // Assignment to second operand of right-hand side compound
1552 {
1553 test_ = "TSMatTSMatSub - Assignment to second operand of right-hand side compound";
1554
1555 initialize();
1556
1557 result_ = tsC3x3_ - ( tsA3x4_ * tsB4x3_ );
1558 tsB4x3_ = tsC3x3_ - ( tsA3x4_ * tsB4x3_ );
1559
1560 checkResult( tsB4x3_, result_ );
1561 }
1562
1563 // Complex operation: A = ( 2*A ) - ( B * C )
1564 {
1565 test_ = "TSMatTSMatSub - Complex operation: A = ( 2*A ) - ( B * C )";
1566
1567 initialize();
1568
1569 result_ = ( 2*tsC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
1570 tsC3x3_ = ( 2*tsC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
1571
1572 checkResult( tsC3x3_, result_ );
1573 }
1574
1575 // Complex operation: A = ( B * C ) - ( 2*A )
1576 {
1577 test_ = "TSMatTSMatSub - Complex operation: A = ( B * C ) - ( 2*A )";
1578
1579 initialize();
1580
1581 result_ = ( tsA3x4_ * tsB4x3_ ) - ( 2*tsC3x3_ );
1582 tsC3x3_ = ( tsA3x4_ * tsB4x3_ ) - ( 2*tsC3x3_ );
1583
1584 checkResult( tsC3x3_, result_ );
1585 }
1586
1587
1588 //=====================================================================================
1589 // Subtraction with addition assignment
1590 //=====================================================================================
1591
1592 // Addition assignment to left-hand side operand (1)
1593 {
1594 test_ = "TSMatTSMatSub - Addition assignment to left-hand side operand (1)";
1595
1596 initialize();
1597
1598 result_ = tsC3x3_;
1599 result_ += tsC3x3_ - tsD3x3_;
1600 tsC3x3_ += tsC3x3_ - tsD3x3_;
1601
1602 checkResult( tsC3x3_, result_ );
1603 }
1604
1605 // Addition assignment to left-hand side operand (2)
1606 {
1607 test_ = "TSMatTSMatSub - Addition assignment to left-hand side operand (2)";
1608
1609 initialize();
1610
1611 result_ = tsC3x3_;
1612 result_ += tsC3x3_ - eval( tsD3x3_ );
1613 tsC3x3_ += tsC3x3_ - eval( tsD3x3_ );
1614
1615 checkResult( tsC3x3_, result_ );
1616 }
1617
1618 // Addition assignment to first operand of left-hand side compound
1619 {
1620 test_ = "TSMatTSMatSub - Addition assignment to first operand of left-hand side compound";
1621
1622 initialize();
1623
1624 result_ = tsC3x3_;
1625 result_ += ( tsC3x3_ * tsD3x3_ ) - tsE3x3_;
1626 tsC3x3_ += ( tsC3x3_ * tsD3x3_ ) - tsE3x3_;
1627
1628 checkResult( tsC3x3_, result_ );
1629 }
1630
1631 // Addition assignment to second operand of left-hand side compound
1632 {
1633 test_ = "TSMatTSMatSub - Addition assignment to second operand of left-hand side compound";
1634
1635 initialize();
1636
1637 result_ = tsD3x3_;
1638 result_ += ( tsC3x3_ * tsD3x3_ ) - tsE3x3_;
1639 tsD3x3_ += ( tsC3x3_ * tsD3x3_ ) - tsE3x3_;
1640
1641 checkResult( tsD3x3_, result_ );
1642 }
1643
1644 // Addition assignment to right-hand side operand (1)
1645 {
1646 test_ = "TSMatTSMatSub - Addition assignment to right-hand side operand (1)";
1647
1648 initialize();
1649
1650 result_ = tsD3x3_;
1651 result_ += tsC3x3_ - tsD3x3_;
1652 tsD3x3_ += tsC3x3_ - tsD3x3_;
1653
1654 checkResult( tsD3x3_, result_ );
1655 }
1656
1657 // Addition assignment to right-hand side operand (2)
1658 {
1659 test_ = "TSMatTSMatSub - Addition assignment to right-hand side operand (2)";
1660
1661 initialize();
1662
1663 result_ = tsD3x3_;
1664 result_ += eval( tsC3x3_ ) - tsD3x3_;
1665 tsD3x3_ += eval( tsC3x3_ ) - tsD3x3_;
1666
1667 checkResult( tsD3x3_, result_ );
1668 }
1669
1670 // Addition assignment to first operand of right-hand side compound
1671 {
1672 test_ = "TSMatTSMatSub - Addition assignment to first operand of right-hand side compound";
1673
1674 initialize();
1675
1676 result_ = tsD3x3_;
1677 result_ += tsC3x3_ - ( tsD3x3_ * tsE3x3_ );
1678 tsD3x3_ += tsC3x3_ - ( tsD3x3_ * tsE3x3_ );
1679
1680 checkResult( tsD3x3_, result_ );
1681 }
1682
1683 // Addition assignment to second operand of right-hand side compound
1684 {
1685 test_ = "TSMatTSMatSub - Addition assignment to second operand of right-hand side compound";
1686
1687 initialize();
1688
1689 result_ = tsE3x3_;
1690 result_ += tsC3x3_ - ( tsD3x3_ * tsE3x3_ );
1691 tsE3x3_ += tsC3x3_ - ( tsD3x3_ * tsE3x3_ );
1692
1693 checkResult( tsE3x3_, result_ );
1694 }
1695
1696 // Complex operation: A += ( 2*A ) - ( B * C )
1697 {
1698 test_ = "TSMatTSMatSub - Complex operation: A += ( 2*A ) - ( B * C )";
1699
1700 initialize();
1701
1702 result_ = tsC3x3_;
1703 result_ += ( 2*tsC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
1704 tsC3x3_ += ( 2*tsC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
1705
1706 checkResult( tsC3x3_, result_ );
1707 }
1708
1709 // Complex operation: A += ( B * C ) - ( 2*A )
1710 {
1711 test_ = "TSMatTSMatSub - Complex operation: A += ( B * C ) - ( 2*A )";
1712
1713 initialize();
1714
1715 result_ = tsC3x3_;
1716 result_ += ( tsA3x4_ * tsB4x3_ ) - ( 2*tsC3x3_ );
1717 tsC3x3_ += ( tsA3x4_ * tsB4x3_ ) - ( 2*tsC3x3_ );
1718
1719 checkResult( tsC3x3_, result_ );
1720 }
1721
1722
1723 //=====================================================================================
1724 // Subtraction with subtraction assignment
1725 //=====================================================================================
1726
1727 // Subtraction assignment to left-hand side operand (1)
1728 {
1729 test_ = "TSMatTSMatSub - Subtraction assignment to left-hand side operand (1)";
1730
1731 initialize();
1732
1733 result_ = tsC3x3_;
1734 result_ -= tsC3x3_ - tsD3x3_;
1735 tsC3x3_ -= tsC3x3_ - tsD3x3_;
1736
1737 checkResult( tsC3x3_, result_ );
1738 }
1739
1740 // Subtraction assignment to left-hand side operand (2)
1741 {
1742 test_ = "TSMatTSMatSub - Subtraction assignment to left-hand side operand (2)";
1743
1744 initialize();
1745
1746 result_ = tsC3x3_;
1747 result_ -= tsC3x3_ - eval( tsD3x3_ );
1748 tsC3x3_ -= tsC3x3_ - eval( tsD3x3_ );
1749
1750 checkResult( tsC3x3_, result_ );
1751 }
1752
1753 // Subtraction assignment to first operand of left-hand side compound
1754 {
1755 test_ = "TSMatTSMatSub - Subtraction assignment to first operand of left-hand side compound";
1756
1757 initialize();
1758
1759 result_ = tsC3x3_;
1760 result_ -= ( tsC3x3_ * tsD3x3_ ) - tsE3x3_;
1761 tsC3x3_ -= ( tsC3x3_ * tsD3x3_ ) - tsE3x3_;
1762
1763 checkResult( tsC3x3_, result_ );
1764 }
1765
1766 // Subtraction assignment to second operand of left-hand side compound
1767 {
1768 test_ = "TSMatTSMatSub - Subtraction assignment to second operand of left-hand side compound";
1769
1770 initialize();
1771
1772 result_ = tsD3x3_;
1773 result_ -= ( tsC3x3_ * tsD3x3_ ) - tsE3x3_;
1774 tsD3x3_ -= ( tsC3x3_ * tsD3x3_ ) - tsE3x3_;
1775
1776 checkResult( tsD3x3_, result_ );
1777 }
1778
1779 // Subtraction assignment to right-hand side operand (1)
1780 {
1781 test_ = "TSMatTSMatSub - Subtraction assignment to right-hand side operand (1)";
1782
1783 initialize();
1784
1785 result_ = tsD3x3_;
1786 result_ -= tsC3x3_ - tsD3x3_;
1787 tsD3x3_ -= tsC3x3_ - tsD3x3_;
1788
1789 checkResult( tsD3x3_, result_ );
1790 }
1791
1792 // Subtraction assignment to right-hand side operand (2)
1793 {
1794 test_ = "TSMatTSMatSub - Subtraction assignment to right-hand side operand (2)";
1795
1796 initialize();
1797
1798 result_ = tsD3x3_;
1799 result_ -= eval( tsC3x3_ ) - tsD3x3_;
1800 tsD3x3_ -= eval( tsC3x3_ ) - tsD3x3_;
1801
1802 checkResult( tsD3x3_, result_ );
1803 }
1804
1805 // Subtraction assignment to first operand of right-hand side compound
1806 {
1807 test_ = "TSMatTSMatSub - Subtraction assignment to first operand of right-hand side compound";
1808
1809 initialize();
1810
1811 result_ = tsD3x3_;
1812 result_ -= tsC3x3_ - ( tsD3x3_ * tsE3x3_ );
1813 tsD3x3_ -= tsC3x3_ - ( tsD3x3_ * tsE3x3_ );
1814
1815 checkResult( tsD3x3_, result_ );
1816 }
1817
1818 // Subtraction assignment to second operand of right-hand side compound
1819 {
1820 test_ = "TSMatTSMatSub - Subtraction assignment to second operand of right-hand side compound";
1821
1822 initialize();
1823
1824 result_ = tsE3x3_;
1825 result_ -= tsC3x3_ - ( tsD3x3_ * tsE3x3_ );
1826 tsE3x3_ -= tsC3x3_ - ( tsD3x3_ * tsE3x3_ );
1827
1828 checkResult( tsE3x3_, result_ );
1829 }
1830
1831 // Complex operation: A -= ( 2*A ) - ( B * C )
1832 {
1833 test_ = "TSMatTSMatSub - Complex operation: A -= ( 2*A ) - ( B * C )";
1834
1835 initialize();
1836
1837 result_ = tsC3x3_;
1838 result_ -= ( 2*tsC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
1839 tsC3x3_ -= ( 2*tsC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
1840
1841 checkResult( tsC3x3_, result_ );
1842 }
1843
1844 // Complex operation: A -= ( B * C ) - ( 2*A )
1845 {
1846 test_ = "TSMatTSMatSub - Complex operation: A -= ( B * C ) - ( 2*A )";
1847
1848 initialize();
1849
1850 result_ = tsC3x3_;
1851 result_ -= ( tsA3x4_ * tsB4x3_ ) - ( 2*tsC3x3_ );
1852 tsC3x3_ -= ( tsA3x4_ * tsB4x3_ ) - ( 2*tsC3x3_ );
1853
1854 checkResult( tsC3x3_, result_ );
1855 }
1856
1857
1858 //=====================================================================================
1859 // Subtraction with Schur product assignment
1860 //=====================================================================================
1861
1862 // Schur product assignment to left-hand side operand (1)
1863 {
1864 test_ = "TSMatTSMatSub - Schur product assignment to left-hand side operand (1)";
1865
1866 initialize();
1867
1868 result_ = tsC3x3_;
1869 result_ %= tsC3x3_ - tsD3x3_;
1870 tsC3x3_ %= tsC3x3_ - tsD3x3_;
1871
1872 checkResult( tsC3x3_, result_ );
1873 }
1874
1875 // Schur product assignment to left-hand side operand (2)
1876 {
1877 test_ = "TSMatTSMatSub - Schur product assignment to left-hand side operand (2)";
1878
1879 initialize();
1880
1881 result_ = tsC3x3_;
1882 result_ %= tsC3x3_ - eval( tsD3x3_ );
1883 tsC3x3_ %= tsC3x3_ - eval( tsD3x3_ );
1884
1885 checkResult( tsC3x3_, result_ );
1886 }
1887
1888 // Schur product assignment to first operand of left-hand side compound
1889 {
1890 test_ = "TSMatTSMatSub - Schur product assignment to first operand of left-hand side compound";
1891
1892 initialize();
1893
1894 result_ = tsC3x3_;
1895 result_ %= ( tsC3x3_ * tsD3x3_ ) - tsE3x3_;
1896 tsC3x3_ %= ( tsC3x3_ * tsD3x3_ ) - tsE3x3_;
1897
1898 checkResult( tsC3x3_, result_ );
1899 }
1900
1901 // Schur product assignment to second operand of left-hand side compound
1902 {
1903 test_ = "TSMatTSMatSub - Schur product assignment to second operand of left-hand side compound";
1904
1905 initialize();
1906
1907 result_ = tsD3x3_;
1908 result_ %= ( tsC3x3_ * tsD3x3_ ) - tsE3x3_;
1909 tsD3x3_ %= ( tsC3x3_ * tsD3x3_ ) - tsE3x3_;
1910
1911 checkResult( tsD3x3_, result_ );
1912 }
1913
1914 // Schur product assignment to right-hand side operand (1)
1915 {
1916 test_ = "TSMatTSMatSub - Schur product assignment to right-hand side operand (1)";
1917
1918 initialize();
1919
1920 result_ = tsD3x3_;
1921 result_ %= tsC3x3_ - tsD3x3_;
1922 tsD3x3_ %= tsC3x3_ - tsD3x3_;
1923
1924 checkResult( tsD3x3_, result_ );
1925 }
1926
1927 // Schur product assignment to right-hand side operand (2)
1928 {
1929 test_ = "TSMatTSMatSub - Schur product assignment to right-hand side operand (2)";
1930
1931 initialize();
1932
1933 result_ = tsD3x3_;
1934 result_ %= eval( tsC3x3_ ) - tsD3x3_;
1935 tsD3x3_ %= eval( tsC3x3_ ) - tsD3x3_;
1936
1937 checkResult( tsD3x3_, result_ );
1938 }
1939
1940 // Schur product assignment to first operand of right-hand side compound
1941 {
1942 test_ = "TSMatTSMatSub - Schur product assignment to first operand of right-hand side compound";
1943
1944 initialize();
1945
1946 result_ = tsD3x3_;
1947 result_ %= tsC3x3_ - ( tsD3x3_ * tsE3x3_ );
1948 tsD3x3_ %= tsC3x3_ - ( tsD3x3_ * tsE3x3_ );
1949
1950 checkResult( tsD3x3_, result_ );
1951 }
1952
1953 // Schur product assignment to second operand of right-hand side compound
1954 {
1955 test_ = "TSMatTSMatSub - Schur product assignment to second operand of right-hand side compound";
1956
1957 initialize();
1958
1959 result_ = tsE3x3_;
1960 result_ %= tsC3x3_ - ( tsD3x3_ * tsE3x3_ );
1961 tsE3x3_ %= tsC3x3_ - ( tsD3x3_ * tsE3x3_ );
1962
1963 checkResult( tsE3x3_, result_ );
1964 }
1965
1966 // Complex operation: A %= ( 2*A ) - ( B * C )
1967 {
1968 test_ = "TSMatTSMatSub - Complex operation: A %= ( 2*A ) - ( B * C )";
1969
1970 initialize();
1971
1972 result_ = tsC3x3_;
1973 result_ %= ( 2*tsC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
1974 tsC3x3_ %= ( 2*tsC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
1975
1976 checkResult( tsC3x3_, result_ );
1977 }
1978
1979 // Complex operation: A %= ( B * C ) - ( 2*A )
1980 {
1981 test_ = "TSMatTSMatSub - Complex operation: A %= ( B * C ) - ( 2*A )";
1982
1983 initialize();
1984
1985 result_ = tsC3x3_;
1986 result_ %= ( tsA3x4_ * tsB4x3_ ) - ( 2*tsC3x3_ );
1987 tsC3x3_ %= ( tsA3x4_ * tsB4x3_ ) - ( 2*tsC3x3_ );
1988
1989 checkResult( tsC3x3_, result_ );
1990 }
1991
1992
1993 //=====================================================================================
1994 // Subtraction with multiplication assignment
1995 //=====================================================================================
1996
1997 // Multiplication assignment to left-hand side operand (1)
1998 {
1999 test_ = "TSMatTSMatSub - Multiplication assignment to left-hand side operand (1)";
2000
2001 initialize();
2002
2003 result_ = tsC3x3_;
2004 result_ *= tsC3x3_ - tsD3x3_;
2005 tsC3x3_ *= tsC3x3_ - tsD3x3_;
2006
2007 checkResult( tsC3x3_, result_ );
2008 }
2009
2010 // Multiplication assignment to left-hand side operand (2)
2011 {
2012 test_ = "TSMatTSMatSub - Multiplication assignment to left-hand side operand (2)";
2013
2014 initialize();
2015
2016 result_ = tsC3x3_;
2017 result_ *= tsC3x3_ - eval( tsD3x3_ );
2018 tsC3x3_ *= tsC3x3_ - eval( tsD3x3_ );
2019
2020 checkResult( tsC3x3_, result_ );
2021 }
2022
2023 // Multiplication assignment to first operand of left-hand side compound
2024 {
2025 test_ = "TSMatTSMatSub - Multiplication assignment to first operand of left-hand side compound";
2026
2027 initialize();
2028
2029 result_ = tsC3x3_;
2030 result_ *= ( tsC3x3_ * tsD3x3_ ) - tsE3x3_;
2031 tsC3x3_ *= ( tsC3x3_ * tsD3x3_ ) - tsE3x3_;
2032
2033 checkResult( tsC3x3_, result_ );
2034 }
2035
2036 // Multiplication assignment to second operand of left-hand side compound
2037 {
2038 test_ = "TSMatTSMatSub - Multiplication assignment to second operand of left-hand side compound";
2039
2040 initialize();
2041
2042 result_ = tsD3x3_;
2043 result_ *= ( tsC3x3_ * tsD3x3_ ) - tsE3x3_;
2044 tsD3x3_ *= ( tsC3x3_ * tsD3x3_ ) - tsE3x3_;
2045
2046 checkResult( tsD3x3_, result_ );
2047 }
2048
2049 // Multiplication assignment to right-hand side operand (1)
2050 {
2051 test_ = "TSMatTSMatSub - Multiplication assignment to right-hand side operand (1)";
2052
2053 initialize();
2054
2055 result_ = tsD3x3_;
2056 result_ *= tsC3x3_ - tsD3x3_;
2057 tsD3x3_ *= tsC3x3_ - tsD3x3_;
2058
2059 checkResult( tsD3x3_, result_ );
2060 }
2061
2062 // Multiplication assignment to right-hand side operand (2)
2063 {
2064 test_ = "TSMatTSMatSub - Multiplication assignment to right-hand side operand (2)";
2065
2066 initialize();
2067
2068 result_ = tsD3x3_;
2069 result_ *= eval( tsC3x3_ ) - tsD3x3_;
2070 tsD3x3_ *= eval( tsC3x3_ ) - tsD3x3_;
2071
2072 checkResult( tsD3x3_, result_ );
2073 }
2074
2075 // Multiplication assignment to first operand of right-hand side compound
2076 {
2077 test_ = "TSMatTSMatSub - Multiplication assignment to first operand of right-hand side compound";
2078
2079 initialize();
2080
2081 result_ = tsD3x3_;
2082 result_ *= tsC3x3_ - ( tsD3x3_ * tsE3x3_ );
2083 tsD3x3_ *= tsC3x3_ - ( tsD3x3_ * tsE3x3_ );
2084
2085 checkResult( tsD3x3_, result_ );
2086 }
2087
2088 // Multiplication assignment to second operand of right-hand side compound
2089 {
2090 test_ = "TSMatTSMatSub - Multiplication assignment to second operand of right-hand side compound";
2091
2092 initialize();
2093
2094 result_ = tsE3x3_;
2095 result_ *= tsC3x3_ - ( tsD3x3_ * tsE3x3_ );
2096 tsE3x3_ *= tsC3x3_ - ( tsD3x3_ * tsE3x3_ );
2097
2098 checkResult( tsE3x3_, result_ );
2099 }
2100
2101 // Complex operation: A *= ( 2*A ) - ( B * C )
2102 {
2103 test_ = "TSMatTSMatSub - Complex operation: A *= ( 2*A ) - ( B * C )";
2104
2105 initialize();
2106
2107 result_ = tsC3x3_;
2108 result_ *= ( 2*tsC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
2109 tsC3x3_ *= ( 2*tsC3x3_ ) - ( tsA3x4_ * tsB4x3_ );
2110
2111 checkResult( tsC3x3_, result_ );
2112 }
2113
2114 // Complex operation: A *= ( B * C ) - ( 2*A )
2115 {
2116 test_ = "TSMatTSMatSub - Complex operation: A *= ( B * C ) - ( 2*A )";
2117
2118 initialize();
2119
2120 result_ = tsC3x3_;
2121 result_ *= ( tsA3x4_ * tsB4x3_ ) - ( 2*tsC3x3_ );
2122 tsC3x3_ *= ( tsA3x4_ * tsB4x3_ ) - ( 2*tsC3x3_ );
2123
2124 checkResult( tsC3x3_, result_ );
2125 }
2126 }
2127 //*************************************************************************************************
2128
2129
2130
2131
2132 //=================================================================================================
2133 //
2134 // UTILITY FUNCTIONS
2135 //
2136 //=================================================================================================
2137
2138 //*************************************************************************************************
2139 /*!\brief Initialization of all member vectors and matrices.
2140 //
2141 // \return void
2142 // \exception std::runtime_error Error detected.
2143 //
2144 // This function initializes all member vectors and matrices to specific predetermined values.
2145 */
initialize()2146 void AliasingTest::initialize()
2147 {
2148 // Initializing the first row-major sparse matrix
2149 sA3x4_.resize( 3UL, 4UL, false );
2150 sA3x4_.reset();
2151 sA3x4_(0,0) = -1;
2152 sA3x4_(0,2) = -2;
2153 sA3x4_(1,1) = 2;
2154 sA3x4_(1,2) = -3;
2155 sA3x4_(1,3) = 1;
2156 sA3x4_(2,1) = 1;
2157 sA3x4_(2,2) = 2;
2158 sA3x4_(2,3) = 2;
2159
2160 // Initializing the second row-major sparse matrix
2161 sB4x3_.resize( 4UL, 3UL, false );
2162 sB4x3_.reset();
2163 sB4x3_(0,0) = 1;
2164 sB4x3_(0,2) = -3;
2165 sB4x3_(1,1) = -1;
2166 sB4x3_(2,1) = 2;
2167 sB4x3_(2,2) = 1;
2168 sB4x3_(3,0) = 2;
2169 sB4x3_(3,1) = 1;
2170 sB4x3_(3,2) = -2;
2171
2172 // Initializing the third row-major sparse matrix
2173 sC3x3_.resize( 3UL, 3UL, false );
2174 sC3x3_.reset();
2175 sC3x3_(0,0) = 1;
2176 sC3x3_(0,2) = 2;
2177 sC3x3_(1,1) = 3;
2178 sC3x3_(1,2) = -1;
2179 sC3x3_(2,0) = -1;
2180 sC3x3_(2,2) = 2;
2181
2182 // Initializing the fourth row-major sparse matrix
2183 sD3x3_.resize( 3UL, 3UL, false );
2184 sD3x3_.reset();
2185 sD3x3_(0,1) = -1;
2186 sD3x3_(1,0) = 1;
2187 sD3x3_(1,1) = -2;
2188 sD3x3_(1,2) = 2;
2189 sD3x3_(2,2) = -3;
2190
2191 // Initializing the fifth row-major sparse matrix
2192 sE3x3_.resize( 3UL, 3UL, false );
2193 sE3x3_.reset();
2194 sE3x3_(0,0) = 2;
2195 sE3x3_(1,1) = 1;
2196 sE3x3_(1,2) = -2;
2197 sE3x3_(2,0) = 1;
2198
2199 // Initializing the first column-major sparse matrix
2200 tsA3x4_.resize( 3UL, 4UL, false );
2201 tsA3x4_.reset();
2202 tsA3x4_(0,0) = -1;
2203 tsA3x4_(0,2) = -2;
2204 tsA3x4_(1,1) = 2;
2205 tsA3x4_(1,2) = -3;
2206 tsA3x4_(1,3) = 1;
2207 tsA3x4_(2,1) = 1;
2208 tsA3x4_(2,2) = 2;
2209 tsA3x4_(2,3) = 2;
2210
2211 // Initializing the second column-major sparse matrix
2212 tsB4x3_.resize( 4UL, 3UL, false );
2213 tsB4x3_.reset();
2214 tsB4x3_(0,0) = 1;
2215 tsB4x3_(0,2) = -3;
2216 tsB4x3_(1,1) = -1;
2217 tsB4x3_(2,1) = 2;
2218 tsB4x3_(2,2) = 1;
2219 tsB4x3_(3,0) = 2;
2220 tsB4x3_(3,1) = 1;
2221 tsB4x3_(3,2) = -2;
2222
2223 // Initializing the third column-major sparse matrix
2224 tsC3x3_.resize( 3UL, 3UL, false );
2225 tsC3x3_.reset();
2226 tsC3x3_(0,0) = 1;
2227 tsC3x3_(0,2) = 2;
2228 tsC3x3_(1,1) = 3;
2229 tsC3x3_(1,2) = -1;
2230 tsC3x3_(2,0) = -1;
2231 tsC3x3_(2,2) = 2;
2232
2233 // Initializing the fourth column-major sparse matrix
2234 tsD3x3_.resize( 3UL, 3UL, false );
2235 tsD3x3_.reset();
2236 tsD3x3_(0,1) = -1;
2237 tsD3x3_(1,0) = 1;
2238 tsD3x3_(1,1) = -2;
2239 tsD3x3_(1,2) = 2;
2240 tsD3x3_(2,2) = -3;
2241
2242 // Initializing the fifth column-major sparse matrix
2243 tsE3x3_.resize( 3UL, 3UL, false );
2244 tsE3x3_.reset();
2245 tsE3x3_(0,0) = 2;
2246 tsE3x3_(1,1) = 1;
2247 tsE3x3_(1,2) = -2;
2248 tsE3x3_(2,0) = 1;
2249 }
2250 //*************************************************************************************************
2251
2252 } // namespace smatsmatsub
2253
2254 } // namespace operations
2255
2256 } // namespace mathtest
2257
2258 } // namespace blazetest
2259
2260
2261
2262
2263 //=================================================================================================
2264 //
2265 // MAIN FUNCTION
2266 //
2267 //=================================================================================================
2268
2269 //*************************************************************************************************
main()2270 int main()
2271 {
2272 std::cout << " Running aliasing test..." << std::endl;
2273
2274 try
2275 {
2276 RUN_SMATSMATSUB_ALIASING_TEST;
2277 }
2278 catch( std::exception& ex ) {
2279 std::cerr << "\n\n ERROR DETECTED during aliasing test:\n"
2280 << ex.what() << "\n";
2281 return EXIT_FAILURE;
2282 }
2283
2284 return EXIT_SUCCESS;
2285 }
2286 //*************************************************************************************************
2287