max@0: // Copyright (C) 2009-2012 NICTA (www.nicta.com.au) max@0: // Copyright (C) 2009-2012 Conrad Sanderson max@0: // max@0: // This file is part of the Armadillo C++ library. max@0: // It is provided without any warranty of fitness max@0: // for any purpose. You can redistribute this file max@0: // and/or modify it under the terms of the GNU max@0: // Lesser General Public License (LGPL) as published max@0: // by the Free Software Foundation, either version 3 max@0: // of the License or (at your option) any later version. max@0: // (see http://www.opensource.org/licenses for more info) max@0: max@0: max@0: //! \addtogroup glue_relational max@0: //! @{ max@0: max@0: max@0: max@0: #undef operator_rel max@0: #undef operator_str max@0: max@0: #undef arma_applier_mat max@0: #undef arma_applier_cube max@0: max@0: max@0: #define arma_applier_mat(operator_rel, operator_str) \ max@0: {\ max@0: const Proxy P1(X.A);\ max@0: const Proxy P2(X.B);\ max@0: \ max@0: arma_debug_assert_same_size(P1, P2, operator_str);\ max@0: \ max@0: const bool bad_alias = (Proxy::has_subview && P1.is_alias(out)) || (Proxy::has_subview && P2.is_alias(out));\ max@0: \ max@0: if(bad_alias == false)\ max@0: {\ max@0: \ max@0: const uword n_rows = P1.get_n_rows();\ max@0: const uword n_cols = P1.get_n_cols();\ max@0: \ max@0: out.set_size(n_rows, n_cols);\ max@0: \ max@0: uword* out_mem = out.memptr();\ max@0: \ max@0: const bool prefer_at_accessor = (Proxy::prefer_at_accessor || Proxy::prefer_at_accessor);\ max@0: \ max@0: if(prefer_at_accessor == false)\ max@0: {\ max@0: typename Proxy::ea_type A = P1.get_ea();\ max@0: typename Proxy::ea_type B = P2.get_ea();\ max@0: \ max@0: const uword n_elem = out.n_elem;\ max@0: \ max@0: for(uword i=0; i::stored_type> tmp1(P1.Q);\ max@0: const unwrap::stored_type> tmp2(P2.Q);\ max@0: \ max@0: out = (tmp1.M) operator_rel (tmp2.M);\ max@0: }\ max@0: } max@0: max@0: max@0: max@0: max@0: #define arma_applier_cube(operator_rel, operator_str) \ max@0: {\ max@0: const ProxyCube P1(X.A);\ max@0: const ProxyCube P2(X.B);\ max@0: \ max@0: arma_debug_assert_same_size(P1, P2, operator_str);\ max@0: \ max@0: const bool bad_alias = (ProxyCube::has_subview && P1.is_alias(out)) || (ProxyCube::has_subview && P2.is_alias(out));\ max@0: \ max@0: if(bad_alias == false)\ max@0: {\ max@0: \ max@0: const uword n_rows = P1.get_n_rows();\ max@0: const uword n_cols = P1.get_n_cols();\ max@0: const uword n_slices = P1.get_n_slices();\ max@0: \ max@0: out.set_size(n_rows, n_cols, n_slices);\ max@0: \ max@0: uword* out_mem = out.memptr();\ max@0: \ max@0: const bool prefer_at_accessor = (ProxyCube::prefer_at_accessor || ProxyCube::prefer_at_accessor);\ max@0: \ max@0: if(prefer_at_accessor == false)\ max@0: {\ max@0: typename ProxyCube::ea_type A = P1.get_ea();\ max@0: typename ProxyCube::ea_type B = P2.get_ea();\ max@0: \ max@0: const uword n_elem = out.n_elem;\ max@0: \ max@0: for(uword i=0; i::stored_type> tmp1(P1.Q);\ max@0: const unwrap_cube::stored_type> tmp2(P2.Q);\ max@0: \ max@0: out = (tmp1.M) operator_rel (tmp2.M);\ max@0: }\ max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: void max@0: glue_rel_lt::apply max@0: ( max@0: Mat & out, max@0: const mtGlue& X max@0: ) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_applier_mat(<, "operator<"); max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: void max@0: glue_rel_gt::apply max@0: ( max@0: Mat & out, max@0: const mtGlue& X max@0: ) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_applier_mat(>, "operator>"); max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: void max@0: glue_rel_lteq::apply max@0: ( max@0: Mat & out, max@0: const mtGlue& X max@0: ) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_applier_mat(<=, "operator<="); max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: void max@0: glue_rel_gteq::apply max@0: ( max@0: Mat & out, max@0: const mtGlue& X max@0: ) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_applier_mat(>=, "operator>="); max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: void max@0: glue_rel_eq::apply max@0: ( max@0: Mat & out, max@0: const mtGlue& X max@0: ) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_applier_mat(==, "operator=="); max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: void max@0: glue_rel_noteq::apply max@0: ( max@0: Mat & out, max@0: const mtGlue& X max@0: ) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_applier_mat(!=, "operator!="); max@0: } max@0: max@0: max@0: max@0: // max@0: // max@0: // max@0: max@0: max@0: max@0: template max@0: inline max@0: void max@0: glue_rel_lt::apply max@0: ( max@0: Cube & out, max@0: const mtGlueCube& X max@0: ) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_applier_cube(<, "operator<"); max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: void max@0: glue_rel_gt::apply max@0: ( max@0: Cube & out, max@0: const mtGlueCube& X max@0: ) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_applier_cube(>, "operator>"); max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: void max@0: glue_rel_lteq::apply max@0: ( max@0: Cube & out, max@0: const mtGlueCube& X max@0: ) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_applier_cube(<=, "operator<="); max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: void max@0: glue_rel_gteq::apply max@0: ( max@0: Cube & out, max@0: const mtGlueCube& X max@0: ) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_applier_cube(>=, "operator>="); max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: void max@0: glue_rel_eq::apply max@0: ( max@0: Cube & out, max@0: const mtGlueCube& X max@0: ) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_applier_cube(==, "operator=="); max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: void max@0: glue_rel_noteq::apply max@0: ( max@0: Cube & out, max@0: const mtGlueCube& X max@0: ) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: arma_applier_cube(!=, "operator!="); max@0: } max@0: max@0: max@0: max@0: #undef arma_applier_mat max@0: #undef arma_applier_cube max@0: max@0: max@0: max@0: //! @}