All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
62 
63 
64 namespace blaze {
65 
66 //=================================================================================================
67 //
68 // SYMMETRICMATRIX OPERATORS
69 //
70 //=================================================================================================
71 
72 //*************************************************************************************************
75 template< typename MT, bool SO, bool DF, bool NF >
76 inline void reset( SymmetricMatrix<MT,SO,DF,NF>& m );
77 
78 template< typename MT, bool SO, bool DF, bool NF >
79 inline void reset( SymmetricMatrix<MT,SO,DF,NF>& m, size_t i );
80 
81 template< typename MT, bool SO, bool DF, bool NF >
82 inline void clear( SymmetricMatrix<MT,SO,DF,NF>& m );
83 
84 template< typename MT, bool SO, bool DF, bool NF >
85 inline bool isDefault( const SymmetricMatrix<MT,SO,DF,NF>& m );
86 
87 template< typename MT, bool SO, bool DF, bool NF >
88 inline void swap( SymmetricMatrix<MT,SO,DF,NF>& a, SymmetricMatrix<MT,SO,DF,NF>& b ) /* throw() */;
90 //*************************************************************************************************
91 
92 
93 //*************************************************************************************************
100 template< typename MT // Type of the adapted matrix
101  , bool SO // Storage order of the adapted matrix
102  , bool DF // Density flag
103  , bool NF > // Numeric flag
105 {
106  m.reset();
107 }
108 //*************************************************************************************************
109 
110 
111 //*************************************************************************************************
124 template< typename MT // Type of the adapted matrix
125  , bool SO // Storage order of the adapted matrix
126  , bool DF // Density flag
127  , bool NF > // Numeric flag
128 inline void reset( SymmetricMatrix<MT,SO,DF,NF>& m, size_t i )
129 {
130  m.reset( i );
131 }
132 //*************************************************************************************************
133 
134 
135 //*************************************************************************************************
142 template< typename MT // Type of the adapted matrix
143  , bool SO // Storage order of the adapted matrix
144  , bool DF // Density flag
145  , bool NF > // Numeric flag
147 {
148  m.clear();
149 }
150 //*************************************************************************************************
151 
152 
153 //*************************************************************************************************
171 template< typename MT // Type of the adapted matrix
172  , bool SO // Storage order of the adapted matrix
173  , bool DF // Density flag
174  , bool NF > // Numeric flag
176 {
177  return isDefault( m.matrix_ );
178 }
179 //*************************************************************************************************
180 
181 
182 //*************************************************************************************************
191 template< typename MT // Type of the adapted matrix
192  , bool SO // Storage order of the adapted matrix
193  , bool DF // Density flag
194  , bool NF > // Numeric flag
196 {
197  a.swap( b );
198 }
199 //*************************************************************************************************
200 
201 
202 
203 
204 //=================================================================================================
205 //
206 // ISSQUARE SPECIALIZATIONS
207 //
208 //=================================================================================================
209 
210 //*************************************************************************************************
212 template< typename MT, bool SO, bool DF, bool NF >
213 struct IsSquare< SymmetricMatrix<MT,SO,DF,NF> > : public TrueType
214 {
215  enum { value = 1 };
216  typedef TrueType Type;
217 };
219 //*************************************************************************************************
220 
221 
222 
223 
224 //=================================================================================================
225 //
226 // ISSYMMETRIC SPECIALIZATIONS
227 //
228 //=================================================================================================
229 
230 //*************************************************************************************************
232 template< typename MT, bool SO, bool DF, bool NF >
233 struct IsSymmetric< SymmetricMatrix<MT,SO,DF,NF> > : public TrueType
234 {
235  enum { value = 1 };
236  typedef TrueType Type;
237 };
239 //*************************************************************************************************
240 
241 
242 
243 
244 //=================================================================================================
245 //
246 // ISRESIZABLE SPECIALIZATIONS
247 //
248 //=================================================================================================
249 
250 //*************************************************************************************************
252 template< typename MT, bool SO, bool DF, bool NF >
253 struct IsResizable< SymmetricMatrix<MT,SO,DF,NF> > : public IsResizable<MT>::Type
254 {
255  enum { value = IsResizable<MT>::value };
256  typedef typename IsResizable<MT>::Type Type;
257 };
259 //*************************************************************************************************
260 
261 
262 
263 
264 //=================================================================================================
265 //
266 // REMOVEADAPTOR SPECIALIZATIONS
267 //
268 //=================================================================================================
269 
270 //*************************************************************************************************
272 template< typename MT, bool SO, bool DF, bool NF >
273 struct RemoveAdaptor< SymmetricMatrix<MT,SO,DF,NF> >
274 {
275  typedef MT Type;
276 };
278 //*************************************************************************************************
279 
280 
281 
282 
283 //=================================================================================================
284 //
285 // ADDTRAIT SPECIALIZATIONS
286 //
287 //=================================================================================================
288 
289 //*************************************************************************************************
291 template< typename MT, bool SO1, bool DF, bool NF, typename T, size_t M, size_t N, bool SO2 >
292 struct AddTrait< SymmetricMatrix<MT,SO1,DF,NF>, StaticMatrix<T,M,N,SO2> >
293 {
294  typedef typename AddTrait< MT, StaticMatrix<T,M,N,SO2> >::Type Type;
295 };
296 
297 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF, bool NF >
298 struct AddTrait< StaticMatrix<T,M,N,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
299 {
300  typedef typename AddTrait< StaticMatrix<T,M,N,SO1>, MT >::Type Type;
301 };
302 
303 template< typename MT, bool SO1, bool DF, bool NF, typename T, size_t M, size_t N, bool SO2 >
304 struct AddTrait< SymmetricMatrix<MT,SO1,DF,NF>, HybridMatrix<T,M,N,SO2> >
305 {
306  typedef typename AddTrait< MT, HybridMatrix<T,M,N,SO2> >::Type Type;
307 };
308 
309 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF, bool NF >
310 struct AddTrait< HybridMatrix<T,M,N,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
311 {
312  typedef typename AddTrait< HybridMatrix<T,M,N,SO1>, MT >::Type Type;
313 };
314 
315 template< typename MT, bool SO1, bool DF, bool NF, typename T, bool SO2 >
316 struct AddTrait< SymmetricMatrix<MT,SO1,DF,NF>, DynamicMatrix<T,SO2> >
317 {
318  typedef typename AddTrait< MT, DynamicMatrix<T,SO2> >::Type Type;
319 };
320 
321 template< typename T, bool SO1, typename MT, bool SO2, bool DF, bool NF >
322 struct AddTrait< DynamicMatrix<T,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
323 {
324  typedef typename AddTrait< DynamicMatrix<T,SO1>, MT >::Type Type;
325 };
326 
327 template< typename MT, bool SO1, bool DF, bool NF, typename T, bool SO2 >
328 struct AddTrait< SymmetricMatrix<MT,SO1,DF,NF>, CompressedMatrix<T,SO2> >
329 {
330  typedef typename AddTrait< MT, CompressedMatrix<T,SO2> >::Type Type;
331 };
332 
333 template< typename T, bool SO1, typename MT, bool SO2, bool DF, bool NF >
334 struct AddTrait< CompressedMatrix<T,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
335 {
336  typedef typename AddTrait< CompressedMatrix<T,SO1>, MT >::Type Type;
337 };
338 
339 template< typename MT1, bool SO1, bool DF1, bool NF1, typename MT2, bool SO2, bool DF2, bool NF2 >
340 struct AddTrait< SymmetricMatrix<MT1,SO1,DF1,NF1>, SymmetricMatrix<MT2,SO2,DF2,NF2> >
341 {
342  typedef SymmetricMatrix< typename AddTrait<MT1,MT2>::Type > Type;
343 };
345 //*************************************************************************************************
346 
347 
348 
349 
350 //=================================================================================================
351 //
352 // SUBTRAIT SPECIALIZATIONS
353 //
354 //=================================================================================================
355 
356 //*************************************************************************************************
358 template< typename MT, bool SO1, bool DF, bool NF, typename T, size_t M, size_t N, bool SO2 >
359 struct SubTrait< SymmetricMatrix<MT,SO1,DF,NF>, StaticMatrix<T,M,N,SO2> >
360 {
361  typedef typename SubTrait< MT, StaticMatrix<T,M,N,SO2> >::Type Type;
362 };
363 
364 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF, bool NF >
365 struct SubTrait< StaticMatrix<T,M,N,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
366 {
367  typedef typename SubTrait< StaticMatrix<T,M,N,SO1>, MT >::Type Type;
368 };
369 
370 template< typename MT, bool SO1, bool DF, bool NF, typename T, size_t M, size_t N, bool SO2 >
371 struct SubTrait< SymmetricMatrix<MT,SO1,DF,NF>, HybridMatrix<T,M,N,SO2> >
372 {
373  typedef typename SubTrait< MT, HybridMatrix<T,M,N,SO2> >::Type Type;
374 };
375 
376 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF, bool NF >
377 struct SubTrait< HybridMatrix<T,M,N,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
378 {
379  typedef typename SubTrait< HybridMatrix<T,M,N,SO1>, MT >::Type Type;
380 };
381 
382 template< typename MT, bool SO1, bool DF, bool NF, typename T, bool SO2 >
383 struct SubTrait< SymmetricMatrix<MT,SO1,DF,NF>, DynamicMatrix<T,SO2> >
384 {
385  typedef typename SubTrait< MT, DynamicMatrix<T,SO2> >::Type Type;
386 };
387 
388 template< typename T, bool SO1, typename MT, bool SO2, bool DF, bool NF >
389 struct SubTrait< DynamicMatrix<T,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
390 {
391  typedef typename SubTrait< DynamicMatrix<T,SO1>, MT >::Type Type;
392 };
393 
394 template< typename MT, bool SO1, bool DF, bool NF, typename T, bool SO2 >
395 struct SubTrait< SymmetricMatrix<MT,SO1,DF,NF>, CompressedMatrix<T,SO2> >
396 {
397  typedef typename SubTrait< MT, CompressedMatrix<T,SO2> >::Type Type;
398 };
399 
400 template< typename T, bool SO1, typename MT, bool SO2, bool DF, bool NF >
401 struct SubTrait< CompressedMatrix<T,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
402 {
403  typedef typename SubTrait< CompressedMatrix<T,SO1>, MT >::Type Type;
404 };
405 
406 template< typename MT1, bool SO1, bool DF1, bool NF1, typename MT2, bool SO2, bool DF2, bool NF2 >
407 struct SubTrait< SymmetricMatrix<MT1,SO1,DF1,NF1>, SymmetricMatrix<MT2,SO2,DF2,NF2> >
408 {
409  typedef SymmetricMatrix< typename SubTrait<MT1,MT2>::Type > Type;
410 };
412 //*************************************************************************************************
413 
414 
415 
416 
417 //=================================================================================================
418 //
419 // MULTTRAIT SPECIALIZATIONS
420 //
421 //=================================================================================================
422 
423 //*************************************************************************************************
425 template< typename MT, bool SO, bool DF, bool NF, typename T >
426 struct MultTrait< SymmetricMatrix<MT,SO,DF,NF>, T >
427 {
428  typedef SymmetricMatrix< typename MultTrait<MT,T>::Type > Type;
430 };
431 
432 template< typename T, typename MT, bool SO, bool DF, bool NF >
433 struct MultTrait< T, SymmetricMatrix<MT,SO,DF,NF> >
434 {
435  typedef SymmetricMatrix< typename MultTrait<T,MT>::Type > Type;
437 };
438 
439 template< typename MT, bool SO, bool DF, bool NF, typename T, size_t N >
440 struct MultTrait< SymmetricMatrix<MT,SO,DF,NF>, StaticVector<T,N,false> >
441 {
442  typedef typename MultTrait< MT, StaticVector<T,N,false> >::Type Type;
443 };
444 
445 template< typename T, size_t N, typename MT, bool SO, bool DF, bool NF >
446 struct MultTrait< StaticVector<T,N,true>, SymmetricMatrix<MT,SO,DF,NF> >
447 {
448  typedef typename MultTrait< StaticVector<T,N,true>, MT >::Type Type;
449 };
450 
451 template< typename MT, bool SO, bool DF, bool NF, typename T, size_t N >
452 struct MultTrait< SymmetricMatrix<MT,SO,DF,NF>, HybridVector<T,N,false> >
453 {
454  typedef typename MultTrait< MT, HybridVector<T,N,false> >::Type Type;
455 };
456 
457 template< typename T, size_t N, typename MT, bool SO, bool DF, bool NF >
458 struct MultTrait< HybridVector<T,N,true>, SymmetricMatrix<MT,SO,DF,NF> >
459 {
460  typedef typename MultTrait< HybridVector<T,N,true>, MT >::Type Type;
461 };
462 
463 template< typename MT, bool SO, bool DF, bool NF, typename T >
464 struct MultTrait< SymmetricMatrix<MT,SO,DF,NF>, DynamicVector<T,false> >
465 {
466  typedef typename MultTrait< MT, DynamicVector<T,false> >::Type Type;
467 };
468 
469 template< typename T, typename MT, bool SO, bool DF, bool NF >
470 struct MultTrait< DynamicVector<T,true>, SymmetricMatrix<MT,SO,DF,NF> >
471 {
472  typedef typename MultTrait< DynamicVector<T,true>, MT >::Type Type;
473 };
474 
475 template< typename MT, bool SO, bool DF, bool NF, typename T >
476 struct MultTrait< SymmetricMatrix<MT,SO,DF,NF>, CompressedVector<T,false> >
477 {
478  typedef typename MultTrait< MT, CompressedVector<T,false> >::Type Type;
479 };
480 
481 template< typename T, typename MT, bool SO, bool DF, bool NF >
482 struct MultTrait< CompressedVector<T,true>, SymmetricMatrix<MT,SO,DF,NF> >
483 {
484  typedef typename MultTrait< CompressedVector<T,true>, MT >::Type Type;
485 };
486 
487 template< typename MT, bool SO1, bool DF, bool NF, typename T, size_t M, size_t N, bool SO2 >
488 struct MultTrait< SymmetricMatrix<MT,SO1,DF,NF>, StaticMatrix<T,M,N,SO2> >
489 {
490  typedef typename MultTrait< MT, StaticMatrix<T,M,N,SO2> >::Type Type;
491 };
492 
493 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF, bool NF >
494 struct MultTrait< StaticMatrix<T,M,N,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
495 {
496  typedef typename MultTrait< StaticMatrix<T,M,N,SO1>, MT >::Type Type;
497 };
498 
499 template< typename MT, bool SO1, bool DF, bool NF, typename T, size_t M, size_t N, bool SO2 >
500 struct MultTrait< SymmetricMatrix<MT,SO1,DF,NF>, HybridMatrix<T,M,N,SO2> >
501 {
502  typedef typename MultTrait< MT, HybridMatrix<T,M,N,SO2> >::Type Type;
503 };
504 
505 template< typename T, size_t M, size_t N, bool SO1, typename MT, bool SO2, bool DF, bool NF >
506 struct MultTrait< HybridMatrix<T,M,N,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
507 {
508  typedef typename MultTrait< HybridMatrix<T,M,N,SO1>, MT >::Type Type;
509 };
510 
511 template< typename MT, bool SO1, bool DF, bool NF, typename T, bool SO2 >
512 struct MultTrait< SymmetricMatrix<MT,SO1,DF,NF>, DynamicMatrix<T,SO2> >
513 {
514  typedef typename MultTrait< MT, DynamicMatrix<T,SO2> >::Type Type;
515 };
516 
517 template< typename T, bool SO1, typename MT, bool SO2, bool DF, bool NF >
518 struct MultTrait< DynamicMatrix<T,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
519 {
520  typedef typename MultTrait< DynamicMatrix<T,SO1>, MT >::Type Type;
521 };
522 
523 template< typename MT, bool SO1, bool DF, bool NF, typename T, bool SO2 >
524 struct MultTrait< SymmetricMatrix<MT,SO1,DF,NF>, CompressedMatrix<T,SO2> >
525 {
526  typedef typename MultTrait< MT, CompressedMatrix<T,SO2> >::Type Type;
527 };
528 
529 template< typename T, bool SO1, typename MT, bool SO2, bool DF, bool NF >
530 struct MultTrait< CompressedMatrix<T,SO1>, SymmetricMatrix<MT,SO2,DF,NF> >
531 {
532  typedef typename MultTrait< CompressedMatrix<T,SO1>, MT >::Type Type;
533 };
534 
535 template< typename MT1, bool SO1, bool DF1, bool NF1, typename MT2, bool SO2, bool DF2, bool NF2 >
536 struct MultTrait< SymmetricMatrix<MT1,SO1,DF1,NF1>, SymmetricMatrix<MT2,SO2,DF2,NF2> >
537 {
538  typedef typename MultTrait<MT1,MT2>::Type Type;
539 };
541 //*************************************************************************************************
542 
543 
544 
545 
546 //=================================================================================================
547 //
548 // DIVTRAIT SPECIALIZATIONS
549 //
550 //=================================================================================================
551 
552 //*************************************************************************************************
554 template< typename MT, bool SO, bool DF, bool NF, typename T >
555 struct DivTrait< SymmetricMatrix<MT,SO,DF,NF>, T >
556 {
557  typedef SymmetricMatrix< typename DivTrait<MT,T>::Type > Type;
559 };
561 //*************************************************************************************************
562 
563 
564 
565 
566 //=================================================================================================
567 //
568 // MATHTRAIT SPECIALIZATIONS
569 //
570 //=================================================================================================
571 
572 //*************************************************************************************************
574 template< typename MT1, bool SO1, bool DF1, bool NF1, typename MT2, bool SO2, bool DF2, bool NF2 >
575 struct MathTrait< SymmetricMatrix<MT1,SO1,DF1,NF1>, SymmetricMatrix<MT2,SO2,DF2,NF2> >
576 {
577  typedef SymmetricMatrix< typename MathTrait<MT1,MT2>::HighType > HighType;
578  typedef SymmetricMatrix< typename MathTrait<MT1,MT2>::LowType > LowType;
579 };
581 //*************************************************************************************************
582 
583 
584 
585 
586 //=================================================================================================
587 //
588 // SUBMATRIXTRAIT SPECIALIZATIONS
589 //
590 //=================================================================================================
591 
592 //*************************************************************************************************
594 template< typename MT, bool SO, bool DF, bool NF >
595 struct SubmatrixTrait< SymmetricMatrix<MT,SO,DF,NF> >
596 {
597  typedef typename SubmatrixTrait<MT>::Type Type;
598 };
600 //*************************************************************************************************
601 
602 
603 
604 
605 //=================================================================================================
606 //
607 // ROWTRAIT SPECIALIZATIONS
608 //
609 //=================================================================================================
610 
611 //*************************************************************************************************
613 template< typename MT, bool SO, bool DF, bool NF >
614 struct RowTrait< SymmetricMatrix<MT,SO,DF,NF> >
615 {
616  typedef typename RowTrait<MT>::Type Type;
617 };
619 //*************************************************************************************************
620 
621 
622 
623 
624 //=================================================================================================
625 //
626 // COLUMNTRAIT SPECIALIZATIONS
627 //
628 //=================================================================================================
629 
630 //*************************************************************************************************
632 template< typename MT, bool SO, bool DF, bool NF >
633 struct ColumnTrait< SymmetricMatrix<MT,SO,DF,NF> >
634 {
635  typedef typename ColumnTrait<MT>::Type Type;
636 };
638 //*************************************************************************************************
639 
640 } // namespace blaze
641 
642 #endif
Constraint on the data type.
void swap(SymmetricMatrix< MT, SO, DF, NF > &a, SymmetricMatrix< MT, SO, DF, NF > &b)
Swapping the contents of two matrices.
Definition: SymmetricMatrix.h:195
Header file for the subtraction trait.
Header file for the row trait.
Matrix adapter for symmetric matrices.
Definition: Forward.h:47
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.
Header file for all forward declarations of the math module.
SymmetricMatrix specialization for sparse matrices with numeric element type.
BLAZE_ALWAYS_INLINE void clear(const NonNumericProxy< MT > &proxy)
Clearing the represented element.
Definition: NonNumericProxy.h:854
Header file for the RemoveAdaptor 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.
Header file for the implementation of the base template of the SymmetricMatrix.
#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.
BLAZE_ALWAYS_INLINE bool isDefault(const NonNumericProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: NonNumericProxy.h:874
BLAZE_ALWAYS_INLINE void reset(const NonNumericProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: NonNumericProxy.h:833
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.