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 arrayops 20 //! @{ 21 22 23 class arrayops 24 { 25 public: 26 27 template<typename eT> 28 arma_inline static void 29 copy(eT* dest, const eT* src, const uword n_elem); 30 31 template<typename eT> 32 arma_cold inline static void 33 copy_small(eT* dest, const eT* src, const uword n_elem); 34 35 template<typename eT> 36 inline static void 37 fill_zeros(eT* dest, const uword n_elem); 38 39 template<typename eT> 40 arma_hot inline static void 41 replace(eT* mem, const uword n_elem, const eT old_val, const eT new_val); 42 43 template<typename eT> 44 arma_hot inline static void 45 clean(eT* mem, const uword n_elem, const eT abs_limit, const typename arma_not_cx<eT>::result* junk = nullptr); 46 47 template<typename T> 48 arma_hot inline static void 49 clean(std::complex<T>* mem, const uword n_elem, const T abs_limit); 50 51 template<typename eT> 52 inline static void 53 clamp(eT* mem, const uword n_elem, const eT min_val, const eT max_val, const typename arma_not_cx<eT>::result* junk = nullptr); 54 55 template<typename T> 56 inline static void 57 clamp(std::complex<T>* mem, const uword n_elem, const std::complex<T>& min_val, const std::complex<T>& max_val); 58 59 60 // 61 // array = convert(array) 62 63 template<typename out_eT, typename in_eT> 64 arma_inline static void 65 convert_cx_scalar(out_eT& out, const in_eT& in, const typename arma_not_cx<out_eT>::result* junk1 = nullptr, const typename arma_not_cx< in_eT>::result* junk2 = nullptr); 66 67 template<typename out_eT, typename in_T> 68 arma_inline static void 69 convert_cx_scalar(out_eT& out, const std::complex<in_T>& in, const typename arma_not_cx<out_eT>::result* junk = nullptr); 70 71 template<typename out_T, typename in_T> 72 arma_inline static void 73 convert_cx_scalar(std::complex<out_T>& out, const std::complex< in_T>& in); 74 75 template<typename out_eT, typename in_eT> 76 arma_hot inline static void 77 convert(out_eT* dest, const in_eT* src, const uword n_elem); 78 79 template<typename out_eT, typename in_eT> 80 arma_hot inline static void 81 convert_cx(out_eT* dest, const in_eT* src, const uword n_elem); 82 83 84 // 85 // array op= array 86 87 template<typename eT> 88 arma_hot inline static 89 void 90 inplace_plus(eT* dest, const eT* src, const uword n_elem); 91 92 template<typename eT> 93 arma_hot inline static 94 void 95 inplace_minus(eT* dest, const eT* src, const uword n_elem); 96 97 template<typename eT> 98 arma_hot inline static 99 void 100 inplace_mul(eT* dest, const eT* src, const uword n_elem); 101 102 template<typename eT> 103 arma_hot inline static 104 void 105 inplace_div(eT* dest, const eT* src, const uword n_elem); 106 107 108 template<typename eT> 109 arma_hot inline static 110 void 111 inplace_plus_base(eT* dest, const eT* src, const uword n_elem); 112 113 template<typename eT> 114 arma_hot inline static 115 void 116 inplace_minus_base(eT* dest, const eT* src, const uword n_elem); 117 118 template<typename eT> 119 arma_hot inline static 120 void 121 inplace_mul_base(eT* dest, const eT* src, const uword n_elem); 122 123 template<typename eT> 124 arma_hot inline static 125 void 126 inplace_div_base(eT* dest, const eT* src, const uword n_elem); 127 128 129 // 130 // array op= scalar 131 132 template<typename eT> 133 arma_hot inline static 134 void 135 inplace_set(eT* dest, const eT val, const uword n_elem); 136 137 template<typename eT> 138 arma_hot inline static 139 void 140 inplace_set_simple(eT* dest, const eT val, const uword n_elem); 141 142 template<typename eT> 143 arma_hot inline static 144 void 145 inplace_set_base(eT* dest, const eT val, const uword n_elem); 146 147 template<typename eT> 148 arma_cold inline static 149 void 150 inplace_set_small(eT* dest, const eT val, const uword n_elem); 151 152 template<typename eT, const uword n_elem> 153 arma_hot inline static 154 void 155 inplace_set_fixed(eT* dest, const eT val); 156 157 template<typename eT> 158 arma_hot inline static 159 void 160 inplace_plus(eT* dest, const eT val, const uword n_elem); 161 162 template<typename eT> 163 arma_hot inline static 164 void 165 inplace_minus(eT* dest, const eT val, const uword n_elem); 166 167 template<typename eT> 168 arma_hot inline static void 169 inplace_mul(eT* dest, const eT val, const uword n_elem); 170 171 template<typename eT> 172 arma_hot inline static 173 void 174 inplace_div(eT* dest, const eT val, const uword n_elem); 175 176 177 template<typename eT> 178 arma_hot inline static 179 void 180 inplace_plus_base(eT* dest, const eT val, const uword n_elem); 181 182 template<typename eT> 183 arma_hot inline static 184 void 185 inplace_minus_base(eT* dest, const eT val, const uword n_elem); 186 187 template<typename eT> 188 arma_hot inline static void 189 inplace_mul_base(eT* dest, const eT val, const uword n_elem); 190 191 template<typename eT> 192 arma_hot inline static 193 void 194 inplace_div_base(eT* dest, const eT val, const uword n_elem); 195 196 197 // 198 // scalar = op(array) 199 200 template<typename eT> 201 arma_hot inline static 202 eT 203 accumulate(const eT* src, const uword n_elem); 204 205 template<typename eT> 206 arma_hot inline static 207 eT 208 product(const eT* src, const uword n_elem); 209 210 template<typename eT> 211 arma_hot inline static 212 bool 213 is_zero(const eT* mem, const uword n_elem, const eT abs_limit, const typename arma_not_cx<eT>::result* junk = nullptr); 214 215 template<typename T> 216 arma_hot inline static 217 bool 218 is_zero(const std::complex<T>* mem, const uword n_elem, const T abs_limit); 219 220 template<typename eT> 221 arma_hot inline static 222 bool 223 is_finite(const eT* src, const uword n_elem); 224 225 template<typename eT> 226 arma_hot inline static 227 bool 228 has_inf(const eT* src, const uword n_elem); 229 230 template<typename eT> 231 arma_hot inline static 232 bool 233 has_nan(const eT* src, const uword n_elem); 234 }; 235 236 237 238 //! @} 239