1 // SPDX-License-Identifier: Apache-2.0 2 // 3 // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au) 4 // Copyright 2008-2016 National ICT Australia (NICTA) 5 // 6 // Licensed under the Apache License, Version 2.0 (the "License"); 7 // you may not use this file except in compliance with the License. 8 // You may obtain a copy of the License at 9 // http://www.apache.org/licenses/LICENSE-2.0 10 // 11 // Unless required by applicable law or agreed to in writing, software 12 // distributed under the License is distributed on an "AS IS" BASIS, 13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 // See the License for the specific language governing permissions and 15 // limitations under the License. 16 // ------------------------------------------------------------------------ 17 18 19 //! \addtogroup unwrap_spmat 20 //! @{ 21 22 23 24 template<typename T1> 25 struct unwrap_spmat 26 { 27 typedef typename T1::elem_type eT; 28 29 typedef SpMat<eT> stored_type; 30 31 inline unwrap_spmatunwrap_spmat32 unwrap_spmat(const T1& A) 33 : M(A) 34 { 35 arma_extra_debug_sigprint(); 36 } 37 38 const SpMat<eT> M; 39 40 template<typename eT2> is_aliasunwrap_spmat41 constexpr bool is_alias(const SpMat<eT2>&) const { return false; } 42 }; 43 44 45 46 template<typename eT> 47 struct unwrap_spmat< SpMat<eT> > 48 { 49 typedef SpMat<eT> stored_type; 50 51 inline unwrap_spmatunwrap_spmat52 unwrap_spmat(const SpMat<eT>& A) 53 : M(A) 54 { 55 arma_extra_debug_sigprint(); 56 57 M.sync(); 58 } 59 60 const SpMat<eT>& M; 61 62 template<typename eT2> is_aliasunwrap_spmat63 arma_inline bool is_alias(const SpMat<eT2>& X) const { return (void_ptr(&M) == void_ptr(&X)); } 64 }; 65 66 67 68 template<typename eT> 69 struct unwrap_spmat< SpRow<eT> > 70 { 71 typedef SpRow<eT> stored_type; 72 73 inline unwrap_spmatunwrap_spmat74 unwrap_spmat(const SpRow<eT>& A) 75 : M(A) 76 { 77 arma_extra_debug_sigprint(); 78 79 M.sync(); 80 } 81 82 const SpRow<eT>& M; 83 84 template<typename eT2> is_aliasunwrap_spmat85 arma_inline bool is_alias(const SpMat<eT2>& X) const { return (void_ptr(&M) == void_ptr(&X)); } 86 }; 87 88 89 90 template<typename eT> 91 struct unwrap_spmat< SpCol<eT> > 92 { 93 typedef SpCol<eT> stored_type; 94 95 inline unwrap_spmatunwrap_spmat96 unwrap_spmat(const SpCol<eT>& A) 97 : M(A) 98 { 99 arma_extra_debug_sigprint(); 100 101 M.sync(); 102 } 103 104 const SpCol<eT>& M; 105 106 template<typename eT2> is_aliasunwrap_spmat107 arma_inline bool is_alias(const SpMat<eT2>& X) const { return (void_ptr(&M) == void_ptr(&X)); } 108 }; 109 110 111 112 template<typename T1, typename spop_type> 113 struct unwrap_spmat< SpOp<T1, spop_type> > 114 { 115 typedef typename T1::elem_type eT; 116 117 typedef SpMat<eT> stored_type; 118 119 inline unwrap_spmatunwrap_spmat120 unwrap_spmat(const SpOp<T1, spop_type>& A) 121 : M(A) 122 { 123 arma_extra_debug_sigprint(); 124 } 125 126 const SpMat<eT> M; 127 128 template<typename eT2> is_aliasunwrap_spmat129 constexpr bool is_alias(const SpMat<eT2>&) const { return false; } 130 }; 131 132 133 134 template<typename T1, typename T2, typename spglue_type> 135 struct unwrap_spmat< SpGlue<T1, T2, spglue_type> > 136 { 137 typedef typename T1::elem_type eT; 138 139 typedef SpMat<eT> stored_type; 140 141 inline unwrap_spmatunwrap_spmat142 unwrap_spmat(const SpGlue<T1, T2, spglue_type>& A) 143 : M(A) 144 { 145 arma_extra_debug_sigprint(); 146 } 147 148 const SpMat<eT> M; 149 150 template<typename eT2> is_aliasunwrap_spmat151 constexpr bool is_alias(const SpMat<eT2>&) const { return false; } 152 }; 153 154 155 156 template<typename out_eT, typename T1, typename spop_type> 157 struct unwrap_spmat< mtSpOp<out_eT, T1, spop_type> > 158 { 159 typedef SpMat<out_eT> stored_type; 160 161 inline unwrap_spmatunwrap_spmat162 unwrap_spmat(const mtSpOp<out_eT, T1, spop_type>& A) 163 : M(A) 164 { 165 arma_extra_debug_sigprint(); 166 } 167 168 const SpMat<out_eT> M; 169 170 template<typename eT2> is_aliasunwrap_spmat171 constexpr bool is_alias(const SpMat<eT2>&) const { return false; } 172 }; 173 174 175 176 template<typename out_eT, typename T1, typename T2, typename spglue_type> 177 struct unwrap_spmat< mtSpGlue<out_eT, T1, T2, spglue_type> > 178 { 179 typedef SpMat<out_eT> stored_type; 180 181 inline unwrap_spmatunwrap_spmat182 unwrap_spmat(const mtSpGlue<out_eT, T1, T2, spglue_type>& A) 183 : M(A) 184 { 185 arma_extra_debug_sigprint(); 186 } 187 188 const SpMat<out_eT> M; 189 190 template<typename eT2> is_aliasunwrap_spmat191 constexpr bool is_alias(const SpMat<eT2>&) const { return false; } 192 }; 193 194 195 196 //! @} 197