annotate armadillo-3.900.4/include/armadillo_bits/eGlue_meat.hpp @ 84:55a047986812 tip

Update library URI so as not to be document-local
author Chris Cannam
date Wed, 22 Apr 2020 14:21:57 +0100
parents 1ec0e2823891
children
rev   line source
Chris@49 1 // Copyright (C) 2010-2013 NICTA (www.nicta.com.au)
Chris@49 2 // Copyright (C) 2010-2013 Conrad Sanderson
Chris@49 3 //
Chris@49 4 // This Source Code Form is subject to the terms of the Mozilla Public
Chris@49 5 // License, v. 2.0. If a copy of the MPL was not distributed with this
Chris@49 6 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
Chris@49 7
Chris@49 8
Chris@49 9 //! \addtogroup eGlue
Chris@49 10 //! @{
Chris@49 11
Chris@49 12
Chris@49 13
Chris@49 14 template<typename T1, typename T2, typename eglue_type>
Chris@49 15 arma_inline
Chris@49 16 eGlue<T1,T2,eglue_type>::~eGlue()
Chris@49 17 {
Chris@49 18 arma_extra_debug_sigprint();
Chris@49 19 }
Chris@49 20
Chris@49 21
Chris@49 22
Chris@49 23 template<typename T1, typename T2, typename eglue_type>
Chris@49 24 arma_inline
Chris@49 25 eGlue<T1,T2,eglue_type>::eGlue(const T1& in_A, const T2& in_B)
Chris@49 26 : P1(in_A)
Chris@49 27 , P2(in_B)
Chris@49 28 {
Chris@49 29 arma_extra_debug_sigprint();
Chris@49 30
Chris@49 31 // arma_debug_assert_same_size( P1, P2, eglue_type::text() );
Chris@49 32 arma_debug_assert_same_size
Chris@49 33 (
Chris@49 34 P1.get_n_rows(), P1.get_n_cols(),
Chris@49 35 P2.get_n_rows(), P2.get_n_cols(),
Chris@49 36 eglue_type::text()
Chris@49 37 );
Chris@49 38 }
Chris@49 39
Chris@49 40
Chris@49 41
Chris@49 42 template<typename T1, typename T2, typename eglue_type>
Chris@49 43 arma_inline
Chris@49 44 uword
Chris@49 45 eGlue<T1,T2,eglue_type>::get_n_rows() const
Chris@49 46 {
Chris@49 47 return is_row ? 1 : ( Proxy<T1>::is_fixed ? P1.get_n_rows() : ( Proxy<T2>::is_fixed ? P2.get_n_rows() : P1.get_n_rows() ) );
Chris@49 48 }
Chris@49 49
Chris@49 50
Chris@49 51
Chris@49 52 template<typename T1, typename T2, typename eglue_type>
Chris@49 53 arma_inline
Chris@49 54 uword
Chris@49 55 eGlue<T1,T2,eglue_type>::get_n_cols() const
Chris@49 56 {
Chris@49 57 return is_col ? 1 : ( Proxy<T1>::is_fixed ? P1.get_n_cols() : ( Proxy<T2>::is_fixed ? P2.get_n_cols() : P1.get_n_cols() ) );
Chris@49 58 }
Chris@49 59
Chris@49 60
Chris@49 61
Chris@49 62 template<typename T1, typename T2, typename eglue_type>
Chris@49 63 arma_inline
Chris@49 64 uword
Chris@49 65 eGlue<T1,T2,eglue_type>::get_n_elem() const
Chris@49 66 {
Chris@49 67 return Proxy<T1>::is_fixed ? P1.get_n_elem() : ( Proxy<T2>::is_fixed ? P2.get_n_elem() : P1.get_n_elem() ) ;
Chris@49 68 }
Chris@49 69
Chris@49 70
Chris@49 71
Chris@49 72 template<typename T1, typename T2, typename eglue_type>
Chris@49 73 arma_inline
Chris@49 74 typename T1::elem_type
Chris@49 75 eGlue<T1,T2,eglue_type>::operator[] (const uword ii) const
Chris@49 76 {
Chris@49 77 // the optimiser will keep only one return statement
Chris@49 78
Chris@49 79 typedef typename T1::elem_type eT;
Chris@49 80
Chris@49 81 if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1[ii] + P2[ii]; }
Chris@49 82 else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1[ii] - P2[ii]; }
Chris@49 83 else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1[ii] / P2[ii]; }
Chris@49 84 else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1[ii] * P2[ii]; }
Chris@49 85 else return eT(0);
Chris@49 86 }
Chris@49 87
Chris@49 88
Chris@49 89
Chris@49 90 template<typename T1, typename T2, typename eglue_type>
Chris@49 91 arma_inline
Chris@49 92 typename T1::elem_type
Chris@49 93 eGlue<T1,T2,eglue_type>::at(const uword row, const uword col) const
Chris@49 94 {
Chris@49 95 // the optimiser will keep only one return statement
Chris@49 96
Chris@49 97 typedef typename T1::elem_type eT;
Chris@49 98
Chris@49 99 if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1.at(row,col) + P2.at(row,col); }
Chris@49 100 else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1.at(row,col) - P2.at(row,col); }
Chris@49 101 else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1.at(row,col) / P2.at(row,col); }
Chris@49 102 else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1.at(row,col) * P2.at(row,col); }
Chris@49 103 else return eT(0);
Chris@49 104 }
Chris@49 105
Chris@49 106
Chris@49 107
Chris@49 108 template<typename T1, typename T2, typename eglue_type>
Chris@49 109 arma_inline
Chris@49 110 typename T1::elem_type
Chris@49 111 eGlue<T1,T2,eglue_type>::at_alt(const uword ii) const
Chris@49 112 {
Chris@49 113 // the optimiser will keep only one return statement
Chris@49 114
Chris@49 115 typedef typename T1::elem_type eT;
Chris@49 116
Chris@49 117 if(is_same_type<eglue_type, eglue_plus >::value == true) { return P1.at_alt(ii) + P2.at_alt(ii); }
Chris@49 118 else if(is_same_type<eglue_type, eglue_minus>::value == true) { return P1.at_alt(ii) - P2.at_alt(ii); }
Chris@49 119 else if(is_same_type<eglue_type, eglue_div >::value == true) { return P1.at_alt(ii) / P2.at_alt(ii); }
Chris@49 120 else if(is_same_type<eglue_type, eglue_schur>::value == true) { return P1.at_alt(ii) * P2.at_alt(ii); }
Chris@49 121 else return eT(0);
Chris@49 122 }
Chris@49 123
Chris@49 124
Chris@49 125
Chris@49 126 //! @}