Chris@49: // Copyright (C) 2010-2013 NICTA (www.nicta.com.au) Chris@49: // Copyright (C) 2010-2013 Conrad Sanderson Chris@49: // Chris@49: // This Source Code Form is subject to the terms of the Mozilla Public Chris@49: // License, v. 2.0. If a copy of the MPL was not distributed with this Chris@49: // file, You can obtain one at http://mozilla.org/MPL/2.0/. Chris@49: Chris@49: Chris@49: //! \addtogroup eglue_core Chris@49: //! @{ Chris@49: Chris@49: Chris@49: Chris@49: #undef arma_applier_1u Chris@49: #undef arma_applier_1a Chris@49: #undef arma_applier_2 Chris@49: #undef arma_applier_3 Chris@49: #undef operatorA Chris@49: #undef operatorB Chris@49: Chris@49: #define arma_applier_1u(operatorA, operatorB) \ Chris@49: {\ Chris@49: uword i,j;\ Chris@49: \ Chris@49: for(i=0, j=1; j Chris@49: template Chris@49: arma_hot Chris@49: inline Chris@49: void Chris@49: eglue_core::apply(Mat& out, const eGlue& x) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: typedef typename T1::elem_type eT; Chris@49: Chris@49: const bool prefer_at_accessor = (Proxy::prefer_at_accessor || Proxy::prefer_at_accessor); Chris@49: Chris@49: // NOTE: we're assuming that the matrix has already been set to the correct size and there is no aliasing; Chris@49: // size setting and alias checking is done by either the Mat contructor or operator=() Chris@49: Chris@49: Chris@49: eT* out_mem = out.memptr(); Chris@49: Chris@49: if(prefer_at_accessor == false) Chris@49: { Chris@49: const uword n_elem = (Proxy::is_fixed || Proxy::is_fixed) ? x.get_n_elem() : out.n_elem; Chris@49: Chris@49: //if( memory::is_aligned(out_mem) ) Chris@49: if( memory::is_aligned(out_mem) && ((Proxy::is_fixed && Proxy::is_fixed) ? (x.get_n_elem() >= 32) : true) ) Chris@49: { Chris@49: memory::mark_as_aligned(out_mem); Chris@49: Chris@49: if(x.P1.is_aligned() && x.P2.is_aligned()) Chris@49: { Chris@49: typename Proxy::aligned_ea_type P1 = x.P1.get_aligned_ea(); Chris@49: typename Proxy::aligned_ea_type P2 = x.P2.get_aligned_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1a(=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(=, *); } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename Proxy::ea_type P1 = x.P1.get_ea(); Chris@49: typename Proxy::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename Proxy::ea_type P1 = x.P1.get_ea(); Chris@49: typename Proxy::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: const uword n_rows = x.get_n_rows(); Chris@49: const uword n_cols = x.get_n_cols(); Chris@49: Chris@49: const Proxy& P1 = x.P1; Chris@49: const Proxy& P2 = x.P2; Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_2(=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_2(=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_2(=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_2(=, *); } Chris@49: } Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: template Chris@49: arma_hot Chris@49: inline Chris@49: void Chris@49: eglue_core::apply_inplace_plus(Mat& out, const eGlue& x) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: const uword n_rows = x.get_n_rows(); Chris@49: const uword n_cols = x.get_n_cols(); Chris@49: Chris@49: arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "addition"); Chris@49: Chris@49: typedef typename T1::elem_type eT; Chris@49: Chris@49: eT* out_mem = out.memptr(); Chris@49: Chris@49: const bool prefer_at_accessor = (Proxy::prefer_at_accessor || Proxy::prefer_at_accessor); Chris@49: Chris@49: if(prefer_at_accessor == false) Chris@49: { Chris@49: const uword n_elem = (Proxy::is_fixed || Proxy::is_fixed) ? x.get_n_elem() : out.n_elem; Chris@49: Chris@49: if(memory::is_aligned(out_mem)) Chris@49: { Chris@49: memory::mark_as_aligned(out_mem); Chris@49: Chris@49: if(x.P1.is_aligned() && x.P2.is_aligned()) Chris@49: { Chris@49: typename Proxy::aligned_ea_type P1 = x.P1.get_aligned_ea(); Chris@49: typename Proxy::aligned_ea_type P2 = x.P2.get_aligned_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1a(+=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(+=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(+=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(+=, *); } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename Proxy::ea_type P1 = x.P1.get_ea(); Chris@49: typename Proxy::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(+=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(+=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(+=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(+=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename Proxy::ea_type P1 = x.P1.get_ea(); Chris@49: typename Proxy::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(+=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(+=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(+=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(+=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: const Proxy& P1 = x.P1; Chris@49: const Proxy& P2 = x.P2; Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_2(+=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_2(+=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_2(+=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_2(+=, *); } Chris@49: } Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: template Chris@49: arma_hot Chris@49: inline Chris@49: void Chris@49: eglue_core::apply_inplace_minus(Mat& out, const eGlue& x) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: const uword n_rows = x.get_n_rows(); Chris@49: const uword n_cols = x.get_n_cols(); Chris@49: Chris@49: arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "subtraction"); Chris@49: Chris@49: typedef typename T1::elem_type eT; Chris@49: Chris@49: eT* out_mem = out.memptr(); Chris@49: Chris@49: const bool prefer_at_accessor = (Proxy::prefer_at_accessor || Proxy::prefer_at_accessor); Chris@49: Chris@49: if(prefer_at_accessor == false) Chris@49: { Chris@49: const uword n_elem = (Proxy::is_fixed || Proxy::is_fixed) ? x.get_n_elem() : out.n_elem; Chris@49: Chris@49: if(memory::is_aligned(out_mem)) Chris@49: { Chris@49: memory::mark_as_aligned(out_mem); Chris@49: Chris@49: if(x.P1.is_aligned() && x.P2.is_aligned()) Chris@49: { Chris@49: typename Proxy::aligned_ea_type P1 = x.P1.get_aligned_ea(); Chris@49: typename Proxy::aligned_ea_type P2 = x.P2.get_aligned_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1a(-=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(-=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(-=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(-=, *); } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename Proxy::ea_type P1 = x.P1.get_ea(); Chris@49: typename Proxy::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(-=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(-=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(-=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(-=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename Proxy::ea_type P1 = x.P1.get_ea(); Chris@49: typename Proxy::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(-=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(-=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(-=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(-=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: const Proxy& P1 = x.P1; Chris@49: const Proxy& P2 = x.P2; Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_2(-=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_2(-=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_2(-=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_2(-=, *); } Chris@49: } Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: template Chris@49: arma_hot Chris@49: inline Chris@49: void Chris@49: eglue_core::apply_inplace_schur(Mat& out, const eGlue& x) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: const uword n_rows = x.get_n_rows(); Chris@49: const uword n_cols = x.get_n_cols(); Chris@49: Chris@49: arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "element-wise multiplication"); Chris@49: Chris@49: typedef typename T1::elem_type eT; Chris@49: Chris@49: eT* out_mem = out.memptr(); Chris@49: Chris@49: const bool prefer_at_accessor = (Proxy::prefer_at_accessor || Proxy::prefer_at_accessor); Chris@49: Chris@49: if(prefer_at_accessor == false) Chris@49: { Chris@49: const uword n_elem = (Proxy::is_fixed || Proxy::is_fixed) ? x.get_n_elem() : out.n_elem; Chris@49: Chris@49: if(memory::is_aligned(out_mem)) Chris@49: { Chris@49: memory::mark_as_aligned(out_mem); Chris@49: Chris@49: if(x.P1.is_aligned() && x.P2.is_aligned()) Chris@49: { Chris@49: typename Proxy::aligned_ea_type P1 = x.P1.get_aligned_ea(); Chris@49: typename Proxy::aligned_ea_type P2 = x.P2.get_aligned_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1a(*=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(*=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(*=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(*=, *); } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename Proxy::ea_type P1 = x.P1.get_ea(); Chris@49: typename Proxy::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(*=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(*=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(*=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(*=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename Proxy::ea_type P1 = x.P1.get_ea(); Chris@49: typename Proxy::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(*=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(*=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(*=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(*=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: const Proxy& P1 = x.P1; Chris@49: const Proxy& P2 = x.P2; Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_2(*=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_2(*=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_2(*=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_2(*=, *); } Chris@49: } Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: template Chris@49: arma_hot Chris@49: inline Chris@49: void Chris@49: eglue_core::apply_inplace_div(Mat& out, const eGlue& x) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: const uword n_rows = x.get_n_rows(); Chris@49: const uword n_cols = x.get_n_cols(); Chris@49: Chris@49: arma_debug_assert_same_size(out.n_rows, out.n_cols, n_rows, n_cols, "element-wise division"); Chris@49: Chris@49: typedef typename T1::elem_type eT; Chris@49: Chris@49: eT* out_mem = out.memptr(); Chris@49: Chris@49: const bool prefer_at_accessor = (Proxy::prefer_at_accessor || Proxy::prefer_at_accessor); Chris@49: Chris@49: if(prefer_at_accessor == false) Chris@49: { Chris@49: const uword n_elem = (Proxy::is_fixed || Proxy::is_fixed) ? x.get_n_elem() : out.n_elem; Chris@49: Chris@49: if(memory::is_aligned(out_mem)) Chris@49: { Chris@49: memory::mark_as_aligned(out_mem); Chris@49: Chris@49: if(x.P1.is_aligned() && x.P2.is_aligned()) Chris@49: { Chris@49: typename Proxy::aligned_ea_type P1 = x.P1.get_aligned_ea(); Chris@49: typename Proxy::aligned_ea_type P2 = x.P2.get_aligned_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1a(/=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(/=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(/=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(/=, *); } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename Proxy::ea_type P1 = x.P1.get_ea(); Chris@49: typename Proxy::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(/=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(/=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(/=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(/=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename Proxy::ea_type P1 = x.P1.get_ea(); Chris@49: typename Proxy::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(/=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(/=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(/=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(/=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: const Proxy& P1 = x.P1; Chris@49: const Proxy& P2 = x.P2; Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_2(/=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_2(/=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_2(/=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_2(/=, *); } Chris@49: } Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: // Chris@49: // cubes Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: template Chris@49: arma_hot Chris@49: inline Chris@49: void Chris@49: eglue_core::apply(Cube& out, const eGlueCube& x) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: typedef typename T1::elem_type eT; Chris@49: Chris@49: const bool prefer_at_accessor = (ProxyCube::prefer_at_accessor || ProxyCube::prefer_at_accessor); Chris@49: Chris@49: // NOTE: we're assuming that the cube has already been set to the correct size and there is no aliasing; Chris@49: // size setting and alias checking is done by either the Cube contructor or operator=() Chris@49: Chris@49: Chris@49: eT* out_mem = out.memptr(); Chris@49: Chris@49: if(prefer_at_accessor == false) Chris@49: { Chris@49: const uword n_elem = out.n_elem; Chris@49: Chris@49: if(memory::is_aligned(out_mem)) Chris@49: { Chris@49: memory::mark_as_aligned(out_mem); Chris@49: Chris@49: if(x.P1.is_aligned() && x.P2.is_aligned()) Chris@49: { Chris@49: typename ProxyCube::aligned_ea_type P1 = x.P1.get_aligned_ea(); Chris@49: typename ProxyCube::aligned_ea_type P2 = x.P2.get_aligned_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1a(=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(=, *); } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename ProxyCube::ea_type P1 = x.P1.get_ea(); Chris@49: typename ProxyCube::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename ProxyCube::ea_type P1 = x.P1.get_ea(); Chris@49: typename ProxyCube::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: const uword n_rows = x.get_n_rows(); Chris@49: const uword n_cols = x.get_n_cols(); Chris@49: const uword n_slices = x.get_n_slices(); Chris@49: Chris@49: const ProxyCube& P1 = x.P1; Chris@49: const ProxyCube& P2 = x.P2; Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_3(=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_3(=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_3(=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_3(=, *); } Chris@49: } Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: template Chris@49: arma_hot Chris@49: inline Chris@49: void Chris@49: eglue_core::apply_inplace_plus(Cube& out, const eGlueCube& x) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: const uword n_rows = x.get_n_rows(); Chris@49: const uword n_cols = x.get_n_cols(); Chris@49: const uword n_slices = x.get_n_slices(); Chris@49: Chris@49: arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "addition"); Chris@49: Chris@49: typedef typename T1::elem_type eT; Chris@49: Chris@49: eT* out_mem = out.memptr(); Chris@49: Chris@49: const bool prefer_at_accessor = (ProxyCube::prefer_at_accessor || ProxyCube::prefer_at_accessor); Chris@49: Chris@49: if(prefer_at_accessor == false) Chris@49: { Chris@49: const uword n_elem = out.n_elem; Chris@49: Chris@49: if(memory::is_aligned(out_mem)) Chris@49: { Chris@49: memory::mark_as_aligned(out_mem); Chris@49: Chris@49: if(x.P1.is_aligned() && x.P2.is_aligned()) Chris@49: { Chris@49: typename ProxyCube::aligned_ea_type P1 = x.P1.get_aligned_ea(); Chris@49: typename ProxyCube::aligned_ea_type P2 = x.P2.get_aligned_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1a(+=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(+=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(+=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(+=, *); } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename ProxyCube::ea_type P1 = x.P1.get_ea(); Chris@49: typename ProxyCube::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(+=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(+=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(+=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(+=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename ProxyCube::ea_type P1 = x.P1.get_ea(); Chris@49: typename ProxyCube::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(+=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(+=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(+=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(+=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: const ProxyCube& P1 = x.P1; Chris@49: const ProxyCube& P2 = x.P2; Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_3(+=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_3(+=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_3(+=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_3(+=, *); } Chris@49: } Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: template Chris@49: arma_hot Chris@49: inline Chris@49: void Chris@49: eglue_core::apply_inplace_minus(Cube& out, const eGlueCube& x) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: const uword n_rows = x.get_n_rows(); Chris@49: const uword n_cols = x.get_n_cols(); Chris@49: const uword n_slices = x.get_n_slices(); Chris@49: Chris@49: arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "subtraction"); Chris@49: Chris@49: typedef typename T1::elem_type eT; Chris@49: Chris@49: eT* out_mem = out.memptr(); Chris@49: Chris@49: const bool prefer_at_accessor = (ProxyCube::prefer_at_accessor || ProxyCube::prefer_at_accessor); Chris@49: Chris@49: if(prefer_at_accessor == false) Chris@49: { Chris@49: const uword n_elem = out.n_elem; Chris@49: Chris@49: if(memory::is_aligned(out_mem)) Chris@49: { Chris@49: memory::mark_as_aligned(out_mem); Chris@49: Chris@49: if(x.P1.is_aligned() && x.P2.is_aligned()) Chris@49: { Chris@49: typename ProxyCube::aligned_ea_type P1 = x.P1.get_aligned_ea(); Chris@49: typename ProxyCube::aligned_ea_type P2 = x.P2.get_aligned_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1a(-=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(-=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(-=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(-=, *); } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename ProxyCube::ea_type P1 = x.P1.get_ea(); Chris@49: typename ProxyCube::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(-=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(-=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(-=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(-=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename ProxyCube::ea_type P1 = x.P1.get_ea(); Chris@49: typename ProxyCube::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(-=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(-=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(-=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(-=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: const ProxyCube& P1 = x.P1; Chris@49: const ProxyCube& P2 = x.P2; Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_3(-=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_3(-=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_3(-=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_3(-=, *); } Chris@49: } Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: template Chris@49: arma_hot Chris@49: inline Chris@49: void Chris@49: eglue_core::apply_inplace_schur(Cube& out, const eGlueCube& x) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: const uword n_rows = x.get_n_rows(); Chris@49: const uword n_cols = x.get_n_cols(); Chris@49: const uword n_slices = x.get_n_slices(); Chris@49: Chris@49: arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise multiplication"); Chris@49: Chris@49: typedef typename T1::elem_type eT; Chris@49: Chris@49: eT* out_mem = out.memptr(); Chris@49: Chris@49: const bool prefer_at_accessor = (ProxyCube::prefer_at_accessor || ProxyCube::prefer_at_accessor); Chris@49: Chris@49: if(prefer_at_accessor == false) Chris@49: { Chris@49: const uword n_elem = out.n_elem; Chris@49: Chris@49: if(memory::is_aligned(out_mem)) Chris@49: { Chris@49: memory::mark_as_aligned(out_mem); Chris@49: Chris@49: if(x.P1.is_aligned() && x.P2.is_aligned()) Chris@49: { Chris@49: typename ProxyCube::aligned_ea_type P1 = x.P1.get_aligned_ea(); Chris@49: typename ProxyCube::aligned_ea_type P2 = x.P2.get_aligned_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1a(*=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(*=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(*=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(*=, *); } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename ProxyCube::ea_type P1 = x.P1.get_ea(); Chris@49: typename ProxyCube::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(*=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(*=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(*=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(*=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename ProxyCube::ea_type P1 = x.P1.get_ea(); Chris@49: typename ProxyCube::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(*=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(*=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(*=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(*=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: const ProxyCube& P1 = x.P1; Chris@49: const ProxyCube& P2 = x.P2; Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_3(*=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_3(*=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_3(*=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_3(*=, *); } Chris@49: } Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: template Chris@49: template Chris@49: arma_hot Chris@49: inline Chris@49: void Chris@49: eglue_core::apply_inplace_div(Cube& out, const eGlueCube& x) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: Chris@49: const uword n_rows = x.get_n_rows(); Chris@49: const uword n_cols = x.get_n_cols(); Chris@49: const uword n_slices = x.get_n_slices(); Chris@49: Chris@49: arma_debug_assert_same_size(out.n_rows, out.n_cols, out.n_slices, n_rows, n_cols, n_slices, "element-wise division"); Chris@49: Chris@49: typedef typename T1::elem_type eT; Chris@49: Chris@49: eT* out_mem = out.memptr(); Chris@49: Chris@49: const bool prefer_at_accessor = (ProxyCube::prefer_at_accessor || ProxyCube::prefer_at_accessor); Chris@49: Chris@49: if(prefer_at_accessor == false) Chris@49: { Chris@49: const uword n_elem = out.n_elem; Chris@49: Chris@49: if(memory::is_aligned(out_mem)) Chris@49: { Chris@49: memory::mark_as_aligned(out_mem); Chris@49: Chris@49: if(x.P1.is_aligned() && x.P2.is_aligned()) Chris@49: { Chris@49: typename ProxyCube::aligned_ea_type P1 = x.P1.get_aligned_ea(); Chris@49: typename ProxyCube::aligned_ea_type P2 = x.P2.get_aligned_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1a(/=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(/=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(/=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1a(/=, *); } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename ProxyCube::ea_type P1 = x.P1.get_ea(); Chris@49: typename ProxyCube::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(/=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(/=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(/=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(/=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: typename ProxyCube::ea_type P1 = x.P1.get_ea(); Chris@49: typename ProxyCube::ea_type P2 = x.P2.get_ea(); Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_1u(/=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(/=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(/=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_1u(/=, *); } Chris@49: } Chris@49: } Chris@49: else Chris@49: { Chris@49: const ProxyCube& P1 = x.P1; Chris@49: const ProxyCube& P2 = x.P2; Chris@49: Chris@49: if(is_same_type::value == true) { arma_applier_3(/=, +); } Chris@49: else if(is_same_type::value == true) { arma_applier_3(/=, -); } Chris@49: else if(is_same_type::value == true) { arma_applier_3(/=, /); } Chris@49: else if(is_same_type::value == true) { arma_applier_3(/=, *); } Chris@49: } Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: #undef arma_applier_1u Chris@49: #undef arma_applier_1a Chris@49: #undef arma_applier_2 Chris@49: #undef arma_applier_3 Chris@49: Chris@49: Chris@49: Chris@49: //! @}