comparison armadillo-3.900.4/include/armadillo_bits/Base_bones.hpp @ 49:1ec0e2823891

Switch to using subrepo copies of qm-dsp, nnls-chroma, vamp-plugin-sdk; update Armadillo version; assume build without external BLAS/LAPACK
author Chris Cannam
date Thu, 13 Jun 2013 10:25:24 +0100
parents
children
comparison
equal deleted inserted replaced
48:69251e11a913 49:1ec0e2823891
1 // Copyright (C) 2008-2012 NICTA (www.nicta.com.au)
2 // Copyright (C) 2008-2012 Conrad Sanderson
3 //
4 // This Source Code Form is subject to the terms of the Mozilla Public
5 // License, v. 2.0. If a copy of the MPL was not distributed with this
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
8
9 //! \addtogroup Base
10 //! @{
11
12
13
14 template<typename derived>
15 struct Base_blas_elem_type
16 {
17 arma_inline const Op<derived,op_inv> i(const bool slow = false) const; //!< matrix inverse
18 };
19
20
21 template<typename derived>
22 struct Base_other_elem_type
23 {
24 };
25
26
27 template<typename derived, bool condition>
28 struct Base_extra {};
29
30 template<typename derived>
31 struct Base_extra<derived, true> { typedef Base_blas_elem_type<derived> result; };
32
33 template<typename derived>
34 struct Base_extra<derived, false> { typedef Base_other_elem_type<derived> result; };
35
36
37
38 template<typename elem_type, typename derived>
39 struct Base_eval_Mat
40 {
41 const derived& eval() const;
42 };
43
44
45 template<typename elem_type, typename derived>
46 struct Base_eval_expr
47 {
48 Mat<elem_type> eval() const; //!< force the immediate evaluation of a delayed expression
49 };
50
51
52 template<typename elem_type, typename derived, bool condition>
53 struct Base_eval {};
54
55 template<typename elem_type, typename derived>
56 struct Base_eval<elem_type, derived, true> { typedef Base_eval_Mat<elem_type, derived> result; };
57
58 template<typename elem_type, typename derived>
59 struct Base_eval<elem_type, derived, false> { typedef Base_eval_expr<elem_type, derived> result; };
60
61
62
63 //! Class for static polymorphism, modelled after the "Curiously Recurring Template Pattern" (CRTP).
64 //! Used for type-safe downcasting in functions that restrict their input(s) to be classes that are
65 //! derived from Base (e.g. Mat, Op, Glue, diagview, subview).
66 //! A Base object can be converted to a Mat object by the unwrap class.
67
68 template<typename elem_type, typename derived>
69 struct Base
70 : public Base_extra<derived, is_supported_blas_type<elem_type>::value>::result
71 , public Base_eval<elem_type, derived, is_Mat<derived>::value>::result
72 {
73 arma_inline const derived& get_ref() const;
74
75 arma_inline const Op<derived,op_htrans> t() const; //!< Hermitian transpose
76 arma_inline const Op<derived,op_htrans> ht() const; //!< Hermitian transpose
77 arma_inline const Op<derived,op_strans> st() const; //!< simple transpose
78
79 inline void print(const std::string extra_text = "") const;
80 inline void print(std::ostream& user_stream, const std::string extra_text = "") const;
81
82 inline void raw_print(const std::string extra_text = "") const;
83 inline void raw_print(std::ostream& user_stream, const std::string extra_text = "") const;
84 };
85
86
87
88 //! @}