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 --- src/armadillo/include/armadillo_bits/fn_join.hpp | 502 +++++++++++++++++++++++ 1 file changed, 502 insertions(+) create mode 100644 src/armadillo/include/armadillo_bits/fn_join.hpp (limited to 'src/armadillo/include/armadillo_bits/fn_join.hpp') diff --git a/src/armadillo/include/armadillo_bits/fn_join.hpp b/src/armadillo/include/armadillo_bits/fn_join.hpp new file mode 100644 index 0000000..6d3ed07 --- /dev/null +++ b/src/armadillo/include/armadillo_bits/fn_join.hpp @@ -0,0 +1,502 @@ +// 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 fn_join +//! @{ + + + +template +arma_warn_unused +inline +typename +enable_if2 + < + (is_arma_type::value && is_arma_type::value && is_same_type::value), + const Glue + >::result +join_cols(const T1& A, const T2& B) + { + arma_extra_debug_sigprint(); + + return Glue(A, B); + } + + + +template +arma_warn_unused +inline +Mat +join_cols(const Base& A, const Base& B, const Base& C) + { + arma_extra_debug_sigprint(); + + Mat out; + + glue_join_cols::apply(out, A.get_ref(), B.get_ref(), C.get_ref()); + + return out; + } + + + +template +arma_warn_unused +inline +Mat +join_cols(const Base& A, const Base& B, const Base& C, const Base& D) + { + arma_extra_debug_sigprint(); + + Mat out; + + glue_join_cols::apply(out, A.get_ref(), B.get_ref(), C.get_ref(), D.get_ref()); + + return out; + } + + + +template +arma_warn_unused +inline +typename +enable_if2 + < + (is_arma_type::value && is_arma_type::value && is_same_type::value), + const Glue + >::result +join_vert(const T1& A, const T2& B) + { + arma_extra_debug_sigprint(); + + return Glue(A, B); + } + + + +template +arma_warn_unused +inline +Mat +join_vert(const Base& A, const Base& B, const Base& C) + { + arma_extra_debug_sigprint(); + + Mat out; + + glue_join_cols::apply(out, A.get_ref(), B.get_ref(), C.get_ref()); + + return out; + } + + + +template +arma_warn_unused +inline +Mat +join_vert(const Base& A, const Base& B, const Base& C, const Base& D) + { + arma_extra_debug_sigprint(); + + Mat out; + + glue_join_cols::apply(out, A.get_ref(), B.get_ref(), C.get_ref(), D.get_ref()); + + return out; + } + + + +template +arma_warn_unused +inline +typename +enable_if2 + < + (is_arma_type::value && is_arma_type::value && is_same_type::value), + const Glue + >::result +join_rows(const T1& A, const T2& B) + { + arma_extra_debug_sigprint(); + + return Glue(A, B); + } + + + +template +arma_warn_unused +inline +Mat +join_rows(const Base& A, const Base& B, const Base& C) + { + arma_extra_debug_sigprint(); + + Mat out; + + glue_join_rows::apply(out, A.get_ref(), B.get_ref(), C.get_ref()); + + return out; + } + + + +template +arma_warn_unused +inline +Mat +join_rows(const Base& A, const Base& B, const Base& C, const Base& D) + { + arma_extra_debug_sigprint(); + + Mat out; + + glue_join_rows::apply(out, A.get_ref(), B.get_ref(), C.get_ref(), D.get_ref()); + + return out; + } + + + +template +arma_warn_unused +inline +typename +enable_if2 + < + (is_arma_type::value && is_arma_type::value && is_same_type::value), + const Glue + >::result +join_horiz(const T1& A, const T2& B) + { + arma_extra_debug_sigprint(); + + return Glue(A, B); + } + + + +template +arma_warn_unused +inline +Mat +join_horiz(const Base& A, const Base& B, const Base& C) + { + arma_extra_debug_sigprint(); + + Mat out; + + glue_join_rows::apply(out, A.get_ref(), B.get_ref(), C.get_ref()); + + return out; + } + + + +template +arma_warn_unused +inline +Mat +join_horiz(const Base& A, const Base& B, const Base& C, const Base& D) + { + arma_extra_debug_sigprint(); + + Mat out; + + glue_join_rows::apply(out, A.get_ref(), B.get_ref(), C.get_ref(), D.get_ref()); + + return out; + } + + + +// +// for cubes + +template +arma_warn_unused +inline +const GlueCube +join_slices(const BaseCube& A, const BaseCube& B) + { + arma_extra_debug_sigprint(); + + return GlueCube(A.get_ref(), B.get_ref()); + } + + + +template +arma_warn_unused +inline +Cube +join_slices(const Base& A, const Base& B) + { + arma_extra_debug_sigprint(); + + typedef typename T1::elem_type eT; + + const quasi_unwrap UA(A.get_ref()); + const quasi_unwrap UB(B.get_ref()); + + arma_debug_assert_same_size(UA.M.n_rows, UA.M.n_cols, UB.M.n_rows, UB.M.n_cols, "join_slices(): incompatible dimensions"); + + Cube out(UA.M.n_rows, UA.M.n_cols, 2, arma_nozeros_indicator()); + + arrayops::copy(out.slice_memptr(0), UA.M.memptr(), UA.M.n_elem); + arrayops::copy(out.slice_memptr(1), UB.M.memptr(), UB.M.n_elem); + + return out; + } + + + +template +arma_warn_unused +inline +Cube +join_slices(const Base& A, const BaseCube& B) + { + arma_extra_debug_sigprint(); + + typedef typename T1::elem_type eT; + + const quasi_unwrap U(A.get_ref()); + + const Cube M(const_cast(U.M.memptr()), U.M.n_rows, U.M.n_cols, 1, false); + + return join_slices(M,B); + } + + + +template +arma_warn_unused +inline +Cube +join_slices(const BaseCube& A, const Base& B) + { + arma_extra_debug_sigprint(); + + typedef typename T1::elem_type eT; + + const quasi_unwrap U(B.get_ref()); + + const Cube M(const_cast(U.M.memptr()), U.M.n_rows, U.M.n_cols, 1, false); + + return join_slices(A,M); + } + + + +// +// for sparse matrices + +template +arma_warn_unused +inline +const SpGlue +join_cols(const SpBase& A, const SpBase& B) + { + arma_extra_debug_sigprint(); + + return SpGlue(A.get_ref(), B.get_ref()); + } + + + +template +arma_warn_unused +inline +SpMat +join_cols(const SpBase& A, const SpBase& B, const SpBase& C) + { + arma_extra_debug_sigprint(); + + SpMat out; + + spglue_join_cols::apply(out, A.get_ref(), B.get_ref(), C.get_ref()); + + return out; + } + + + +template +arma_warn_unused +inline +SpMat +join_cols(const SpBase& A, const SpBase& B, const SpBase& C, const SpBase& D) + { + arma_extra_debug_sigprint(); + + SpMat out; + + spglue_join_cols::apply(out, A.get_ref(), B.get_ref(), C.get_ref(), D.get_ref()); + + return out; + } + + + +template +arma_warn_unused +inline +const SpGlue +join_vert(const SpBase& A, const SpBase& B) + { + arma_extra_debug_sigprint(); + + return SpGlue(A.get_ref(), B.get_ref()); + } + + + +template +arma_warn_unused +inline +SpMat +join_vert(const SpBase& A, const SpBase& B, const SpBase& C) + { + arma_extra_debug_sigprint(); + + SpMat out; + + spglue_join_cols::apply(out, A.get_ref(), B.get_ref(), C.get_ref()); + + return out; + } + + + +template +arma_warn_unused +inline +SpMat +join_vert(const SpBase& A, const SpBase& B, const SpBase& C, const SpBase& D) + { + arma_extra_debug_sigprint(); + + SpMat out; + + spglue_join_cols::apply(out, A.get_ref(), B.get_ref(), C.get_ref(), D.get_ref()); + + return out; + } + + + +template +arma_warn_unused +inline +const SpGlue +join_rows(const SpBase& A, const SpBase& B) + { + arma_extra_debug_sigprint(); + + return SpGlue(A.get_ref(), B.get_ref()); + } + + + +template +arma_warn_unused +inline +SpMat +join_rows(const SpBase& A, const SpBase& B, const SpBase& C) + { + arma_extra_debug_sigprint(); + + SpMat out; + + spglue_join_rows::apply(out, A.get_ref(), B.get_ref(), C.get_ref()); + + return out; + } + + + +template +arma_warn_unused +inline +SpMat +join_rows(const SpBase& A, const SpBase& B, const SpBase& C, const SpBase& D) + { + arma_extra_debug_sigprint(); + + SpMat out; + + spglue_join_rows::apply(out, A.get_ref(), B.get_ref(), C.get_ref(), D.get_ref()); + + return out; + } + + + +template +arma_warn_unused +inline +const SpGlue +join_horiz(const SpBase& A, const SpBase& B) + { + arma_extra_debug_sigprint(); + + return SpGlue(A.get_ref(), B.get_ref()); + } + + + +template +arma_warn_unused +inline +SpMat +join_horiz(const SpBase& A, const SpBase& B, const SpBase& C) + { + arma_extra_debug_sigprint(); + + SpMat out; + + spglue_join_rows::apply(out, A.get_ref(), B.get_ref(), C.get_ref()); + + return out; + } + + + +template +arma_warn_unused +inline +SpMat +join_horiz(const SpBase& A, const SpBase& B, const SpBase& C, const SpBase& D) + { + arma_extra_debug_sigprint(); + + SpMat out; + + spglue_join_rows::apply(out, A.get_ref(), B.get_ref(), C.get_ref(), D.get_ref()); + + return out; + } + + + +//! @} -- cgit v1.2.1