SymmetricMatrix.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_H_
36 #define _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
48 #include <blaze/math/Forward.h>
66 
67 
68 namespace blaze {
69 
70 //=================================================================================================
71 //
72 // SYMMETRICMATRIX OPERATORS
73 //
74 //=================================================================================================
75 
76 //*************************************************************************************************
79 template< typename MT, bool SO, bool DF, bool NF >
80 inline void reset( SymmetricMatrix<MT,SO,DF,NF>& m );
81 
82 template< typename MT, bool SO, bool DF, bool NF >
83 inline void reset( SymmetricMatrix<MT,SO,DF,NF>& m, size_t i );
84 
85 template< typename MT, bool SO, bool DF, bool NF >
86 inline void clear( SymmetricMatrix<MT,SO,DF,NF>& m );
87 
88 template< typename MT, bool SO, bool DF, bool NF >
89 inline bool isDefault( const SymmetricMatrix<MT,SO,DF,NF>& m );
90 
91 template< typename MT, bool SO, bool DF, bool NF >
92 inline void swap( SymmetricMatrix<MT,SO,DF,NF>& a, SymmetricMatrix<MT,SO,DF,NF>& b ) /* throw() */;
94 //*************************************************************************************************
95 
96 
97 //*************************************************************************************************
104 template< typename MT // Type of the adapted matrix
105  , bool SO // Storage order of the adapted matrix
106  , bool DF // Density flag
107  , bool NF > // Numeric flag
109 {
110  m.reset();
111 }
112 //*************************************************************************************************
113 
114 
115 //*************************************************************************************************
128 template< typename MT // Type of the adapted matrix
129  , bool SO // Storage order of the adapted matrix
130  , bool DF // Density flag
131  , bool NF > // Numeric flag
132 inline void reset( SymmetricMatrix<MT,SO,DF,NF>& m, size_t i )
133 {
134  m.reset( i );
135 }
136 //*************************************************************************************************
137 
138 
139 //*************************************************************************************************
146 template< typename MT // Type of the adapted matrix
147  , bool SO // Storage order of the adapted matrix
148  , bool DF // Density flag
149  , bool NF > // Numeric flag
151 {
152  m.clear();
153 }
154 //*************************************************************************************************
155 
156 
157 //*************************************************************************************************
175 template< typename MT // Type of the adapted matrix
176  , bool SO // Storage order of the adapted matrix
177  , bool DF // Density flag
178  , bool NF > // Numeric flag
180 {
181  return isDefault( m.matrix_ );
182 }
183 //*************************************************************************************************
184 
185 
186 //*************************************************************************************************
195 template< typename MT // Type of the adapted matrix
196  , bool SO // Storage order of the adapted matrix
197  , bool DF // Density flag
198  , bool NF > // Numeric flag
200 {
201  a.swap( b );
202 }
203 //*************************************************************************************************
204 
205 
206 
207 
208 //=================================================================================================
209 //
210 // ROWS SPECIALIZATIONS
211 //
212 //=================================================================================================
213 
214 //*************************************************************************************************
216 template< typename MT, bool SO, bool DF, bool NF >
217 struct Rows< SymmetricMatrix<MT,SO,DF,NF> > : public Rows<MT>
218 {};
220 //*************************************************************************************************
221 
222 
223 
224 
225 //=================================================================================================
226 //
227 // COLUMNS SPECIALIZATIONS
228 //
229 //=================================================================================================
230 
231 //*************************************************************************************************
233 template< typename MT, bool SO, bool DF, bool NF >
234 struct Columns< SymmetricMatrix<MT,SO,DF,NF> > : public Columns<MT>
235 {};
237 //*************************************************************************************************
238 
239 
240 
241 
242 //=================================================================================================
243 //
244 // ISSQUARE SPECIALIZATIONS
245 //
246 //=================================================================================================
247 
248 //*************************************************************************************************
250 template< typename MT, bool SO, bool DF, bool NF >
251 struct IsSquare< SymmetricMatrix<MT,SO,DF,NF> > : public TrueType
252 {
253  enum { value = 1 };
254  typedef TrueType Type;
255 };
257 //*************************************************************************************************
258 
259 
260 
261 
262 //=================================================================================================
263 //
264 // ISSYMMETRIC SPECIALIZATIONS
265 //
266 //=================================================================================================
267 
268 //*************************************************************************************************
270 template< typename MT, bool SO, bool DF, bool NF >
271 struct IsSymmetric< SymmetricMatrix<MT,SO,DF,NF> > : public TrueType
272 {
273  enum { value = 1 };
274  typedef TrueType Type;
275 };
277 //*************************************************************************************************
278 
279 
280 
281 
282 //=================================================================================================
283 //
284 // HASCONSTDATAACCESS SPECIALIZATIONS
285 //
286 //=================================================================================================
287 
288 //*************************************************************************************************
290 template< typename MT, bool SO, bool NF >
291 struct HasConstDataAccess< SymmetricMatrix<MT,SO,true,NF> > : public TrueType
292 {
293  enum { value = 1 };
294  typedef TrueType Type;
295 };
297 //*************************************************************************************************
298 
299 
300 
301 
302 //=================================================================================================
303 //
304 // ISRESIZABLE SPECIALIZATIONS
305 //
306 //=================================================================================================
307 
308 //*************************************************************************************************
310 template< typename MT, bool SO, bool DF, bool NF >
311 struct IsResizable< SymmetricMatrix<MT,SO,DF,NF> > : public IsResizable<MT>::Type
312 {
313  enum { value = IsResizable<MT>::value };
314  typedef typename IsResizable<MT>::Type Type;
315 };
317 //*************************************************************************************************
318 
319 
320 
321 
322 //=================================================================================================
323 //
324 // ISADAPTOR SPECIALIZATIONS
325 //
326 //=================================================================================================
327 
328 //*************************************************************************************************
330 template< typename MT, bool SO, bool DF, bool NF >
331 struct IsAdaptor< SymmetricMatrix<MT,SO,DF,NF> > : public TrueType
332 {
333  enum { value = 1 };
334  typedef TrueType Type;
335 };
337 //*************************************************************************************************
338 
339 
340 
341 
342 //=================================================================================================
343 //
344 // REMOVEADAPTOR SPECIALIZATIONS
345 //
346 //=================================================================================================
347 
348 //*************************************************************************************************
350 template< typename MT, bool SO, bool DF, bool NF >
351 struct RemoveAdaptor< SymmetricMatrix<MT,SO,DF,NF> >
352 {
353  typedef MT Type;
354 };
356 //*************************************************************************************************
357 
358 
359 
360 
361 //=================================================================================================
362 //
363 // ADDTRAIT SPECIALIZATIONS
364 //
365 //=================================================================================================
366 
367 //*************************************************************************************************
369 template< typename MT, bool SO1, bool DF, bool NF, typename T, size_t M, size_t N, bool SO2 >
370 struct AddTrait< SymmetricMatrix<MT,SO1,DF,NF>, StaticMatrix<T,M,N,SO2> >
371 {
372  typedef typename AddTrait< MT, StaticMatrix<T,M,N,SO2> >::Type Type;
373 };
374 
375 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF, bool NF >
376 struct AddTrait< StaticMatrix<T,M,N,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
377 {
378  typedef typename AddTrait< StaticMatrix<T,M,N,SO1>, MT >::Type Type;
379 };
380 
381 template< typename MT, bool SO1, bool DF, bool NF, typename T, size_t M, size_t N, bool SO2 >
382 struct AddTrait< SymmetricMatrix<MT,SO1,DF,NF>, HybridMatrix<T,M,N,SO2> >
383 {
384  typedef typename AddTrait< MT, HybridMatrix<T,M,N,SO2> >::Type Type;
385 };
386 
387 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF, bool NF >
388 struct AddTrait< HybridMatrix<T,M,N,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
389 {
390  typedef typename AddTrait< HybridMatrix<T,M,N,SO1>, MT >::Type Type;
391 };
392 
393 template< typename MT, bool SO1, bool DF, bool NF, typename T, bool SO2 >
394 struct AddTrait< SymmetricMatrix<MT,SO1,DF,NF>, DynamicMatrix<T,SO2> >
395 {
396  typedef typename AddTrait< MT, DynamicMatrix<T,SO2> >::Type Type;
397 };
398 
399 template< typename T, bool SO1, typename MT, bool SO2, bool DF, bool NF >
400 struct AddTrait< DynamicMatrix<T,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
401 {
402  typedef typename AddTrait< DynamicMatrix<T,SO1>, MT >::Type Type;
403 };
404 
405 template< typename MT, bool SO1, bool DF, bool NF, typename T, bool SO2 >
406 struct AddTrait< SymmetricMatrix<MT,SO1,DF,NF>, CompressedMatrix<T,SO2> >
407 {
408  typedef typename AddTrait< MT, CompressedMatrix<T,SO2> >::Type Type;
409 };
410 
411 template< typename T, bool SO1, typename MT, bool SO2, bool DF, bool NF >
412 struct AddTrait< CompressedMatrix<T,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
413 {
414  typedef typename AddTrait< CompressedMatrix<T,SO1>, MT >::Type Type;
415 };
416 
417 template< typename MT1, bool SO1, bool DF1, bool NF1, typename MT2, bool SO2, bool DF2, bool NF2 >
418 struct AddTrait< SymmetricMatrix<MT1,SO1,DF1,NF1>, SymmetricMatrix<MT2,SO2,DF2,NF2> >
419 {
420  typedef SymmetricMatrix< typename AddTrait<MT1,MT2>::Type > Type;
421 };
423 //*************************************************************************************************
424 
425 
426 
427 
428 //=================================================================================================
429 //
430 // SUBTRAIT SPECIALIZATIONS
431 //
432 //=================================================================================================
433 
434 //*************************************************************************************************
436 template< typename MT, bool SO1, bool DF, bool NF, typename T, size_t M, size_t N, bool SO2 >
437 struct SubTrait< SymmetricMatrix<MT,SO1,DF,NF>, StaticMatrix<T,M,N,SO2> >
438 {
439  typedef typename SubTrait< MT, StaticMatrix<T,M,N,SO2> >::Type Type;
440 };
441 
442 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF, bool NF >
443 struct SubTrait< StaticMatrix<T,M,N,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
444 {
445  typedef typename SubTrait< StaticMatrix<T,M,N,SO1>, MT >::Type Type;
446 };
447 
448 template< typename MT, bool SO1, bool DF, bool NF, typename T, size_t M, size_t N, bool SO2 >
449 struct SubTrait< SymmetricMatrix<MT,SO1,DF,NF>, HybridMatrix<T,M,N,SO2> >
450 {
451  typedef typename SubTrait< MT, HybridMatrix<T,M,N,SO2> >::Type Type;
452 };
453 
454 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF, bool NF >
455 struct SubTrait< HybridMatrix<T,M,N,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
456 {
457  typedef typename SubTrait< HybridMatrix<T,M,N,SO1>, MT >::Type Type;
458 };
459 
460 template< typename MT, bool SO1, bool DF, bool NF, typename T, bool SO2 >
461 struct SubTrait< SymmetricMatrix<MT,SO1,DF,NF>, DynamicMatrix<T,SO2> >
462 {
463  typedef typename SubTrait< MT, DynamicMatrix<T,SO2> >::Type Type;
464 };
465 
466 template< typename T, bool SO1, typename MT, bool SO2, bool DF, bool NF >
467 struct SubTrait< DynamicMatrix<T,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
468 {
469  typedef typename SubTrait< DynamicMatrix<T,SO1>, MT >::Type Type;
470 };
471 
472 template< typename MT, bool SO1, bool DF, bool NF, typename T, bool SO2 >
473 struct SubTrait< SymmetricMatrix<MT,SO1,DF,NF>, CompressedMatrix<T,SO2> >
474 {
475  typedef typename SubTrait< MT, CompressedMatrix<T,SO2> >::Type Type;
476 };
477 
478 template< typename T, bool SO1, typename MT, bool SO2, bool DF, bool NF >
479 struct SubTrait< CompressedMatrix<T,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
480 {
481  typedef typename SubTrait< CompressedMatrix<T,SO1>, MT >::Type Type;
482 };
483 
484 template< typename MT1, bool SO1, bool DF1, bool NF1, typename MT2, bool SO2, bool DF2, bool NF2 >
485 struct SubTrait< SymmetricMatrix<MT1,SO1,DF1,NF1>, SymmetricMatrix<MT2,SO2,DF2,NF2> >
486 {
487  typedef SymmetricMatrix< typename SubTrait<MT1,MT2>::Type > Type;
488 };
490 //*************************************************************************************************
491 
492 
493 
494 
495 //=================================================================================================
496 //
497 // MULTTRAIT SPECIALIZATIONS
498 //
499 //=================================================================================================
500 
501 //*************************************************************************************************
503 template< typename MT, bool SO, bool DF, bool NF, typename T >
504 struct MultTrait< SymmetricMatrix<MT,SO,DF,NF>, T >
505 {
506  typedef SymmetricMatrix< typename MultTrait<MT,T>::Type > Type;
508 };
509 
510 template< typename T, typename MT, bool SO, bool DF, bool NF >
511 struct MultTrait< T, SymmetricMatrix<MT,SO,DF,NF> >
512 {
513  typedef SymmetricMatrix< typename MultTrait<T,MT>::Type > Type;
515 };
516 
517 template< typename MT, bool SO, bool DF, bool NF, typename T, size_t N >
518 struct MultTrait< SymmetricMatrix<MT,SO,DF,NF>, StaticVector<T,N,false> >
519 {
520  typedef typename MultTrait< MT, StaticVector<T,N,false> >::Type Type;
521 };
522 
523 template< typename T, size_t N, typename MT, bool SO, bool DF, bool NF >
524 struct MultTrait< StaticVector<T,N,true>, SymmetricMatrix<MT,SO,DF,NF> >
525 {
526  typedef typename MultTrait< StaticVector<T,N,true>, MT >::Type Type;
527 };
528 
529 template< typename MT, bool SO, bool DF, bool NF, typename T, size_t N >
530 struct MultTrait< SymmetricMatrix<MT,SO,DF,NF>, HybridVector<T,N,false> >
531 {
532  typedef typename MultTrait< MT, HybridVector<T,N,false> >::Type Type;
533 };
534 
535 template< typename T, size_t N, typename MT, bool SO, bool DF, bool NF >
536 struct MultTrait< HybridVector<T,N,true>, SymmetricMatrix<MT,SO,DF,NF> >
537 {
538  typedef typename MultTrait< HybridVector<T,N,true>, MT >::Type Type;
539 };
540 
541 template< typename MT, bool SO, bool DF, bool NF, typename T >
542 struct MultTrait< SymmetricMatrix<MT,SO,DF,NF>, DynamicVector<T,false> >
543 {
544  typedef typename MultTrait< MT, DynamicVector<T,false> >::Type Type;
545 };
546 
547 template< typename T, typename MT, bool SO, bool DF, bool NF >
548 struct MultTrait< DynamicVector<T,true>, SymmetricMatrix<MT,SO,DF,NF> >
549 {
550  typedef typename MultTrait< DynamicVector<T,true>, MT >::Type Type;
551 };
552 
553 template< typename MT, bool SO, bool DF, bool NF, typename T >
554 struct MultTrait< SymmetricMatrix<MT,SO,DF,NF>, CompressedVector<T,false> >
555 {
556  typedef typename MultTrait< MT, CompressedVector<T,false> >::Type Type;
557 };
558 
559 template< typename T, typename MT, bool SO, bool DF, bool NF >
560 struct MultTrait< CompressedVector<T,true>, SymmetricMatrix<MT,SO,DF,NF> >
561 {
562  typedef typename MultTrait< CompressedVector<T,true>, MT >::Type Type;
563 };
564 
565 template< typename MT, bool SO1, bool DF, bool NF, typename T, size_t M, size_t N, bool SO2 >
566 struct MultTrait< SymmetricMatrix<MT,SO1,DF,NF>, StaticMatrix<T,M,N,SO2> >
567 {
568  typedef typename MultTrait< MT, StaticMatrix<T,M,N,SO2> >::Type Type;
569 };
570 
571 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF, bool NF >
572 struct MultTrait< StaticMatrix<T,M,N,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
573 {
574  typedef typename MultTrait< StaticMatrix<T,M,N,SO1>, MT >::Type Type;
575 };
576 
577 template< typename MT, bool SO1, bool DF, bool NF, typename T, size_t M, size_t N, bool SO2 >
578 struct MultTrait< SymmetricMatrix<MT,SO1,DF,NF>, HybridMatrix<T,M,N,SO2> >
579 {
580  typedef typename MultTrait< MT, HybridMatrix<T,M,N,SO2> >::Type Type;
581 };
582 
583 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF, bool NF >
584 struct MultTrait< HybridMatrix<T,M,N,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
585 {
586  typedef typename MultTrait< HybridMatrix<T,M,N,SO1>, MT >::Type Type;
587 };
588 
589 template< typename MT, bool SO1, bool DF, bool NF, typename T, bool SO2 >
590 struct MultTrait< SymmetricMatrix<MT,SO1,DF,NF>, DynamicMatrix<T,SO2> >
591 {
592  typedef typename MultTrait< MT, DynamicMatrix<T,SO2> >::Type Type;
593 };
594 
595 template< typename T, bool SO1, typename MT, bool SO2, bool DF, bool NF >
596 struct MultTrait< DynamicMatrix<T,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
597 {
598  typedef typename MultTrait< DynamicMatrix<T,SO1>, MT >::Type Type;
599 };
600 
601 template< typename MT, bool SO1, bool DF, bool NF, typename T, bool SO2 >
602 struct MultTrait< SymmetricMatrix<MT,SO1,DF,NF>, CompressedMatrix<T,SO2> >
603 {
604  typedef typename MultTrait< MT, CompressedMatrix<T,SO2> >::Type Type;
605 };
606 
607 template< typename T, bool SO1, typename MT, bool SO2, bool DF, bool NF >
608 struct MultTrait< CompressedMatrix<T,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
609 {
610  typedef typename MultTrait< CompressedMatrix<T,SO1>, MT >::Type Type;
611 };
612 
613 template< typename MT1, bool SO1, bool DF1, bool NF1, typename MT2, bool SO2, bool DF2, bool NF2 >
614 struct MultTrait< SymmetricMatrix<MT1,SO1,DF1,NF1>, SymmetricMatrix<MT2,SO2,DF2,NF2> >
615 {
616  typedef typename MultTrait<MT1,MT2>::Type Type;
617 };
619 //*************************************************************************************************
620 
621 
622 
623 
624 //=================================================================================================
625 //
626 // DIVTRAIT SPECIALIZATIONS
627 //
628 //=================================================================================================
629 
630 //*************************************************************************************************
632 template< typename MT, bool SO, bool DF, bool NF, typename T >
633 struct DivTrait< SymmetricMatrix<MT,SO,DF,NF>, T >
634 {
635  typedef SymmetricMatrix< typename DivTrait<MT,T>::Type > Type;
637 };
639 //*************************************************************************************************
640 
641 
642 
643 
644 //=================================================================================================
645 //
646 // MATHTRAIT SPECIALIZATIONS
647 //
648 //=================================================================================================
649 
650 //*************************************************************************************************
652 template< typename MT1, bool SO1, bool DF1, bool NF1, typename MT2, bool SO2, bool DF2, bool NF2 >
653 struct MathTrait< SymmetricMatrix<MT1,SO1,DF1,NF1>, SymmetricMatrix<MT2,SO2,DF2,NF2> >
654 {
655  typedef SymmetricMatrix< typename MathTrait<MT1,MT2>::HighType > HighType;
656  typedef SymmetricMatrix< typename MathTrait<MT1,MT2>::LowType > LowType;
657 };
659 //*************************************************************************************************
660 
661 
662 
663 
664 //=================================================================================================
665 //
666 // SUBMATRIXTRAIT SPECIALIZATIONS
667 //
668 //=================================================================================================
669 
670 //*************************************************************************************************
672 template< typename MT, bool SO, bool DF, bool NF >
673 struct SubmatrixTrait< SymmetricMatrix<MT,SO,DF,NF> >
674 {
675  typedef typename SubmatrixTrait<MT>::Type Type;
676 };
678 //*************************************************************************************************
679 
680 
681 
682 
683 //=================================================================================================
684 //
685 // ROWTRAIT SPECIALIZATIONS
686 //
687 //=================================================================================================
688 
689 //*************************************************************************************************
691 template< typename MT, bool SO, bool DF, bool NF >
692 struct RowTrait< SymmetricMatrix<MT,SO,DF,NF> >
693 {
694  typedef typename RowTrait<MT>::Type Type;
695 };
697 //*************************************************************************************************
698 
699 
700 
701 
702 //=================================================================================================
703 //
704 // COLUMNTRAIT SPECIALIZATIONS
705 //
706 //=================================================================================================
707 
708 //*************************************************************************************************
710 template< typename MT, bool SO, bool DF, bool NF >
711 struct ColumnTrait< SymmetricMatrix<MT,SO,DF,NF> >
712 {
713  typedef typename ColumnTrait<MT>::Type Type;
714 };
716 //*************************************************************************************************
717 
718 } // namespace blaze
719 
720 #endif
Constraint on the data type.
Header file for the Rows type trait.
Header file for the subtraction trait.
Header file for the row trait.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:821
Matrix adapter for symmetric matrices.
Definition: Forward.h:51
Header file for the implementation of the base template of the SymmetricMatrix.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:861
Header file for the IsSquare type trait.
SymmetricMatrix specialization for dense matrices with non-numeric element type.
Header file for the multiplication trait.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for all forward declarations of the math module.
SymmetricMatrix specialization for sparse matrices with numeric element type.
Header file for the Columns type trait.
Header file for the RemoveAdaptor type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:841
Header file for the IsAdaptor type trait.
Header file for the HasConstDataAccess type trait.
SymmetricMatrix specialization for sparse matrices with non-numeric element type. ...
Header file for the addition trait.
Header file for the division trait.
Header file for the submatrix trait.
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:79
Header file for the column trait.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b)
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:200
SymmetricMatrix specialization for dense matrices with numeric element type.
Header file for the mathematical trait.
boost::true_type TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
Header file for the IsResizable type trait.