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 --- .../include/armadillo_bits/BaseCube_meat.hpp | 498 +++++++++++++++++++++ 1 file changed, 498 insertions(+) create mode 100644 src/armadillo/include/armadillo_bits/BaseCube_meat.hpp (limited to 'src/armadillo/include/armadillo_bits/BaseCube_meat.hpp') diff --git a/src/armadillo/include/armadillo_bits/BaseCube_meat.hpp b/src/armadillo/include/armadillo_bits/BaseCube_meat.hpp new file mode 100644 index 0000000..2d0df91 --- /dev/null +++ b/src/armadillo/include/armadillo_bits/BaseCube_meat.hpp @@ -0,0 +1,498 @@ +// 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 BaseCube +//! @{ + + + +template +arma_inline +const derived& +BaseCube::get_ref() const + { + return static_cast(*this); + } + + + +template +inline +void +BaseCube::print(const std::string extra_text) const + { + arma_extra_debug_sigprint(); + + const unwrap_cube tmp( (*this).get_ref() ); + + if(extra_text.length() != 0) + { + const std::streamsize orig_width = get_cout_stream().width(); + + get_cout_stream() << extra_text << '\n'; + + get_cout_stream().width(orig_width); + } + + arma_ostream::print(get_cout_stream(), tmp.M, true); + } + + + +template +inline +void +BaseCube::print(std::ostream& user_stream, const std::string extra_text) const + { + arma_extra_debug_sigprint(); + + const unwrap_cube tmp( (*this).get_ref() ); + + if(extra_text.length() != 0) + { + const std::streamsize orig_width = user_stream.width(); + + user_stream << extra_text << '\n'; + + user_stream.width(orig_width); + } + + arma_ostream::print(user_stream, tmp.M, true); + } + + + +template +inline +void +BaseCube::raw_print(const std::string extra_text) const + { + arma_extra_debug_sigprint(); + + const unwrap_cube tmp( (*this).get_ref() ); + + if(extra_text.length() != 0) + { + const std::streamsize orig_width = get_cout_stream().width(); + + get_cout_stream() << extra_text << '\n'; + + get_cout_stream().width(orig_width); + } + + arma_ostream::print(get_cout_stream(), tmp.M, false); + } + + + +template +inline +void +BaseCube::raw_print(std::ostream& user_stream, const std::string extra_text) const + { + arma_extra_debug_sigprint(); + + const unwrap_cube tmp( (*this).get_ref() ); + + if(extra_text.length() != 0) + { + const std::streamsize orig_width = user_stream.width(); + + user_stream << extra_text << '\n'; + + user_stream.width(orig_width); + } + + arma_ostream::print(user_stream, tmp.M, false); + } + + + +template +inline +void +BaseCube::brief_print(const std::string extra_text) const + { + arma_extra_debug_sigprint(); + + const unwrap_cube tmp( (*this).get_ref() ); + + if(extra_text.length() != 0) + { + const std::streamsize orig_width = get_cout_stream().width(); + + get_cout_stream() << extra_text << '\n'; + + get_cout_stream().width(orig_width); + } + + arma_ostream::brief_print(get_cout_stream(), tmp.M); + } + + + +template +inline +void +BaseCube::brief_print(std::ostream& user_stream, const std::string extra_text) const + { + arma_extra_debug_sigprint(); + + const unwrap_cube tmp( (*this).get_ref() ); + + if(extra_text.length() != 0) + { + const std::streamsize orig_width = user_stream.width(); + + user_stream << extra_text << '\n'; + + user_stream.width(orig_width); + } + + arma_ostream::brief_print(user_stream, tmp.M); + } + + + +template +inline +elem_type +BaseCube::min() const + { + return op_min::min( (*this).get_ref() ); + } + + + +template +inline +elem_type +BaseCube::max() const + { + return op_max::max( (*this).get_ref() ); + } + + + +template +inline +uword +BaseCube::index_min() const + { + const ProxyCube P( (*this).get_ref() ); + + uword index = 0; + + if(P.get_n_elem() == 0) + { + arma_debug_check(true, "index_min(): object has no elements"); + } + else + { + op_min::min_with_index(P, index); + } + + return index; + } + + + +template +inline +uword +BaseCube::index_max() const + { + const ProxyCube P( (*this).get_ref() ); + + uword index = 0; + + if(P.get_n_elem() == 0) + { + arma_debug_check(true, "index_max(): object has no elements"); + } + else + { + op_max::max_with_index(P, index); + } + + return index; + } + + + +template +inline +bool +BaseCube::is_zero(const typename get_pod_type::result tol) const + { + arma_extra_debug_sigprint(); + + typedef typename get_pod_type::result T; + + arma_debug_check( (tol < T(0)), "is_zero(): parameter 'tol' must be >= 0" ); + + if(ProxyCube::use_at || is_Cube::stored_type>::value) + { + const unwrap_cube U( (*this).get_ref() ); + + return arrayops::is_zero( U.M.memptr(), U.M.n_elem, tol ); + } + + const ProxyCube P( (*this).get_ref() ); + + const uword n_elem = P.get_n_elem(); + + if(n_elem == 0) { return false; } + + const typename ProxyCube::ea_type Pea = P.get_ea(); + + if(is_cx::yes) + { + for(uword i=0; i tol) { return false; } + if(eop_aux::arma_abs(val_imag) > tol) { return false; } + } + } + else // not complex + { + for(uword i=0; i < n_elem; ++i) + { + if(eop_aux::arma_abs(Pea[i]) > tol) { return false; } + } + } + + return true; + } + + + +template +inline +bool +BaseCube::is_empty() const + { + arma_extra_debug_sigprint(); + + const ProxyCube P( (*this).get_ref() ); + + return (P.get_n_elem() == uword(0)); + } + + + +template +inline +bool +BaseCube::is_finite() const + { + arma_extra_debug_sigprint(); + + if(arma_config::fast_math_warn) { arma_debug_warn_level(1, "is_finite(): detection of non-finite values is not reliable in fast math mode"); } + + if(is_Cube::stored_type>::value) + { + const unwrap_cube U( (*this).get_ref() ); + + return arrayops::is_finite( U.M.memptr(), U.M.n_elem ); + } + else + { + const ProxyCube P( (*this).get_ref() ); + + const uword n_r = P.get_n_rows(); + const uword n_c = P.get_n_cols(); + const uword n_s = P.get_n_slices(); + + for(uword s=0; s +inline +bool +BaseCube::has_inf() const + { + arma_extra_debug_sigprint(); + + if(arma_config::fast_math_warn) { arma_debug_warn_level(1, "has_inf(): detection of non-finite values is not reliable in fast math mode"); } + + if(is_Cube::stored_type>::value) + { + const unwrap_cube U( (*this).get_ref() ); + + return arrayops::has_inf( U.M.memptr(), U.M.n_elem ); + } + else + { + const ProxyCube P( (*this).get_ref() ); + + const uword n_r = P.get_n_rows(); + const uword n_c = P.get_n_cols(); + const uword n_s = P.get_n_slices(); + + for(uword s=0; s +inline +bool +BaseCube::has_nan() const + { + arma_extra_debug_sigprint(); + + if(arma_config::fast_math_warn) { arma_debug_warn_level(1, "has_nan(): detection of non-finite values is not reliable in fast math mode"); } + + if(is_Cube::stored_type>::value) + { + const unwrap_cube U( (*this).get_ref() ); + + return arrayops::has_nan( U.M.memptr(), U.M.n_elem ); + } + else + { + const ProxyCube P( (*this).get_ref() ); + + const uword n_r = P.get_n_rows(); + const uword n_c = P.get_n_cols(); + const uword n_s = P.get_n_slices(); + + for(uword s=0; s +inline +bool +BaseCube::has_nonfinite() const + { + arma_extra_debug_sigprint(); + + if(arma_config::fast_math_warn) { arma_debug_warn_level(1, "has_nonfinite(): detection of non-finite values is not reliable in fast math mode"); } + + if(is_Cube::stored_type>::value) + { + const unwrap_cube U( (*this).get_ref() ); + + return (arrayops::is_finite( U.M.memptr(), U.M.n_elem ) == false); + } + else + { + const ProxyCube P( (*this).get_ref() ); + + const uword n_r = P.get_n_rows(); + const uword n_c = P.get_n_cols(); + const uword n_s = P.get_n_slices(); + + for(uword s=0; s +inline +const CubeToMatOp +BaseCube::row_as_mat(const uword in_row) const + { + return CubeToMatOp( (*this).get_ref(), in_row ); + } + + + +template +inline +const CubeToMatOp +BaseCube::col_as_mat(const uword in_col) const + { + return CubeToMatOp( (*this).get_ref(), in_col ); + } + + + +// +// extra functions defined in BaseCube_eval_Cube + +template +arma_inline +const derived& +BaseCube_eval_Cube::eval() const + { + arma_extra_debug_sigprint(); + + return static_cast(*this); + } + + + +// +// extra functions defined in BaseCube_eval_expr + +template +inline +Cube +BaseCube_eval_expr::eval() const + { + arma_extra_debug_sigprint(); + + return Cube( static_cast(*this) ); + } + + + +//! @} -- cgit v1.2.1