From eda5bc26f44ee9a6f83dcf8c91f17296d7fc509d Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Mon, 12 Feb 2024 14:52:43 +0100 Subject: Move into version control --- .../armadillo_bits/glue_relational_meat.hpp | 419 +++++++++++++++++++++ 1 file changed, 419 insertions(+) create mode 100644 src/armadillo/include/armadillo_bits/glue_relational_meat.hpp (limited to 'src/armadillo/include/armadillo_bits/glue_relational_meat.hpp') diff --git a/src/armadillo/include/armadillo_bits/glue_relational_meat.hpp b/src/armadillo/include/armadillo_bits/glue_relational_meat.hpp new file mode 100644 index 0000000..5728a09 --- /dev/null +++ b/src/armadillo/include/armadillo_bits/glue_relational_meat.hpp @@ -0,0 +1,419 @@ +// SPDX-License-Identifier: Apache-2.0 +// +// Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au) +// Copyright 2008-2016 National ICT Australia (NICTA) +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ------------------------------------------------------------------------ + + +//! \addtogroup glue_relational +//! @{ + + + +#undef operator_rel +#undef operator_str + +#undef arma_applier_mat +#undef arma_applier_cube + + +#define arma_applier_mat(operator_rel, operator_str) \ + {\ + const Proxy P1(X.A);\ + const Proxy P2(X.B);\ + \ + arma_debug_assert_same_size(P1, P2, operator_str);\ + \ + const bool bad_alias = (Proxy::has_subview && P1.is_alias(out)) || (Proxy::has_subview && P2.is_alias(out));\ + \ + if(bad_alias == false)\ + {\ + \ + const uword n_rows = P1.get_n_rows();\ + const uword n_cols = P1.get_n_cols();\ + \ + out.set_size(n_rows, n_cols);\ + \ + uword* out_mem = out.memptr();\ + \ + const bool use_at = (Proxy::use_at || Proxy::use_at);\ + \ + if(use_at == false)\ + {\ + typename Proxy::ea_type A = P1.get_ea();\ + typename Proxy::ea_type B = P2.get_ea();\ + \ + const uword n_elem = out.n_elem;\ + \ + for(uword i=0; i::stored_type> tmp1(P1.Q, P1.is_alias(out));\ + const unwrap_check::stored_type> tmp2(P2.Q, P2.is_alias(out));\ + \ + out = (tmp1.M) operator_rel (tmp2.M);\ + }\ + } + + + + +#define arma_applier_cube(operator_rel, operator_str) \ + {\ + const ProxyCube P1(X.A);\ + const ProxyCube P2(X.B);\ + \ + arma_debug_assert_same_size(P1, P2, operator_str);\ + \ + const bool bad_alias = (ProxyCube::has_subview && P1.is_alias(out)) || (ProxyCube::has_subview && P2.is_alias(out));\ + \ + if(bad_alias == false)\ + {\ + \ + const uword n_rows = P1.get_n_rows();\ + const uword n_cols = P1.get_n_cols();\ + const uword n_slices = P1.get_n_slices();\ + \ + out.set_size(n_rows, n_cols, n_slices);\ + \ + uword* out_mem = out.memptr();\ + \ + const bool use_at = (ProxyCube::use_at || ProxyCube::use_at);\ + \ + if(use_at == false)\ + {\ + typename ProxyCube::ea_type A = P1.get_ea();\ + typename ProxyCube::ea_type B = P2.get_ea();\ + \ + const uword n_elem = out.n_elem;\ + \ + for(uword i=0; i::stored_type> tmp1(P1.Q);\ + const unwrap_cube::stored_type> tmp2(P2.Q);\ + \ + out = (tmp1.M) operator_rel (tmp2.M);\ + }\ + } + + + +template +inline +void +glue_rel_lt::apply + ( + Mat & out, + const mtGlue& X + ) + { + arma_extra_debug_sigprint(); + + arma_applier_mat(<, "operator<"); + } + + + +template +inline +void +glue_rel_gt::apply + ( + Mat & out, + const mtGlue& X + ) + { + arma_extra_debug_sigprint(); + + arma_applier_mat(>, "operator>"); + } + + + +template +inline +void +glue_rel_lteq::apply + ( + Mat & out, + const mtGlue& X + ) + { + arma_extra_debug_sigprint(); + + arma_applier_mat(<=, "operator<="); + } + + + +template +inline +void +glue_rel_gteq::apply + ( + Mat & out, + const mtGlue& X + ) + { + arma_extra_debug_sigprint(); + + arma_applier_mat(>=, "operator>="); + } + + + +template +inline +void +glue_rel_eq::apply + ( + Mat & out, + const mtGlue& X + ) + { + arma_extra_debug_sigprint(); + + arma_applier_mat(==, "operator=="); + } + + + +template +inline +void +glue_rel_noteq::apply + ( + Mat & out, + const mtGlue& X + ) + { + arma_extra_debug_sigprint(); + + arma_applier_mat(!=, "operator!="); + } + + + +template +inline +void +glue_rel_and::apply + ( + Mat & out, + const mtGlue& X + ) + { + arma_extra_debug_sigprint(); + + arma_applier_mat(&&, "operator&&"); + } + + + +template +inline +void +glue_rel_or::apply + ( + Mat & out, + const mtGlue& X + ) + { + arma_extra_debug_sigprint(); + + arma_applier_mat(||, "operator||"); + } + + + +// +// +// + + + +template +inline +void +glue_rel_lt::apply + ( + Cube & out, + const mtGlueCube& X + ) + { + arma_extra_debug_sigprint(); + + arma_applier_cube(<, "operator<"); + } + + + +template +inline +void +glue_rel_gt::apply + ( + Cube & out, + const mtGlueCube& X + ) + { + arma_extra_debug_sigprint(); + + arma_applier_cube(>, "operator>"); + } + + + +template +inline +void +glue_rel_lteq::apply + ( + Cube & out, + const mtGlueCube& X + ) + { + arma_extra_debug_sigprint(); + + arma_applier_cube(<=, "operator<="); + } + + + +template +inline +void +glue_rel_gteq::apply + ( + Cube & out, + const mtGlueCube& X + ) + { + arma_extra_debug_sigprint(); + + arma_applier_cube(>=, "operator>="); + } + + + +template +inline +void +glue_rel_eq::apply + ( + Cube & out, + const mtGlueCube& X + ) + { + arma_extra_debug_sigprint(); + + arma_applier_cube(==, "operator=="); + } + + + +template +inline +void +glue_rel_noteq::apply + ( + Cube & out, + const mtGlueCube& X + ) + { + arma_extra_debug_sigprint(); + + arma_applier_cube(!=, "operator!="); + } + + + +template +inline +void +glue_rel_and::apply + ( + Cube & out, + const mtGlueCube& X + ) + { + arma_extra_debug_sigprint(); + + arma_applier_cube(&&, "operator&&"); + } + + + +template +inline +void +glue_rel_or::apply + ( + Cube & out, + const mtGlueCube& X + ) + { + arma_extra_debug_sigprint(); + + arma_applier_cube(||, "operator||"); + } + + + +#undef arma_applier_mat +#undef arma_applier_cube + + + +//! @} -- cgit v1.2.1