From e03258f3cbaf095c586cceedc332a25979fefe09 Mon Sep 17 00:00:00 2001 From: conrad Date: Mon, 21 Feb 2022 12:28:36 +1000 Subject: [PATCH] split out rcond variants of op_inv --- include/armadillo | 2 + include/armadillo_bits/fn_inv.hpp | 2 +- include/armadillo_bits/op_inv_rcond_bones.hpp | 38 ++++++++ include/armadillo_bits/op_inv_rcond_meat.hpp | 88 +++++++++++++++++++ include/armadillo_bits/op_inv_spd_bones.hpp | 3 - include/armadillo_bits/op_inv_spd_meat.hpp | 32 ------- 6 files changed, 129 insertions(+), 36 deletions(-) create mode 100644 include/armadillo_bits/op_inv_rcond_bones.hpp create mode 100644 include/armadillo_bits/op_inv_rcond_meat.hpp diff --git a/include/armadillo b/include/armadillo index 7479eafb..8f20cab5 100644 --- a/include/armadillo +++ b/include/armadillo @@ -215,6 +215,7 @@ namespace arma #include "armadillo_bits/op_log_det_bones.hpp" #include "armadillo_bits/op_inv_gen_bones.hpp" #include "armadillo_bits/op_inv_spd_bones.hpp" + #include "armadillo_bits/op_inv_rcond_bones.hpp" #include "armadillo_bits/op_htrans_bones.hpp" #include "armadillo_bits/op_max_bones.hpp" #include "armadillo_bits/op_min_bones.hpp" @@ -646,6 +647,7 @@ namespace arma #include "armadillo_bits/op_log_det_meat.hpp" #include "armadillo_bits/op_inv_gen_meat.hpp" #include "armadillo_bits/op_inv_spd_meat.hpp" + #include "armadillo_bits/op_inv_rcond_meat.hpp" #include "armadillo_bits/op_htrans_meat.hpp" #include "armadillo_bits/op_max_meat.hpp" #include "armadillo_bits/op_index_max_meat.hpp" diff --git a/include/armadillo_bits/fn_inv.hpp b/include/armadillo_bits/fn_inv.hpp index 73d09624..61399f67 100644 --- a/include/armadillo_bits/fn_inv.hpp +++ b/include/armadillo_bits/fn_inv.hpp @@ -201,7 +201,7 @@ inv_sympd { arma_extra_debug_sigprint(); - const bool status = op_inv_spd::apply_direct_rcond(out_inv, out_rcond, X.get_ref()); + const bool status = op_inv_rcond::apply_direct_spd(out_inv, out_rcond, X.get_ref()); if(status == false) { diff --git a/include/armadillo_bits/op_inv_rcond_bones.hpp b/include/armadillo_bits/op_inv_rcond_bones.hpp new file mode 100644 index 00000000..0b0b11e1 --- /dev/null +++ b/include/armadillo_bits/op_inv_rcond_bones.hpp @@ -0,0 +1,38 @@ +// 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 op_inv_rcond +//! @{ + + + +class op_inv_rcond + : public traits_op_default + { + public: + + template + inline static bool apply_direct_gen(Mat& out_inv, typename T1::pod_type& out_rcond, const Base& expr); + + template + inline static bool apply_direct_spd(Mat& out_inv, typename T1::pod_type& out_rcond, const Base& expr); + }; + + + +//! @} diff --git a/include/armadillo_bits/op_inv_rcond_meat.hpp b/include/armadillo_bits/op_inv_rcond_meat.hpp new file mode 100644 index 00000000..02cb33c0 --- /dev/null +++ b/include/armadillo_bits/op_inv_rcond_meat.hpp @@ -0,0 +1,88 @@ +// 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 op_inv_rcond +//! @{ + + + +template +inline +bool +op_inv_rcond::apply_direct_gen(Mat& out_inv, typename T1::pod_type& out_rcond, const Base& expr) + { + arma_extra_debug_sigprint(); + + // NOTE: this is a temporary and rudimentary implementation + + typedef typename T1::elem_type eT; + typedef typename T1::pod_type T; + + const Mat A = expr.get_ref(); + + arma_debug_check( (A.is_square() == false), "inv_sympd(): given matrix must be square sized" ); + + const bool status = op_inv_gen::apply_direct(out_inv, A, uword(0)); + + if(status) + { + out_rcond = op_cond::rcond(expr.get_ref()); + } + else + { + out_rcond = T(0); + } + + return status; + } + + + +template +inline +bool +op_inv_rcond::apply_direct_spd(Mat& out_inv, typename T1::pod_type& out_rcond, const Base& expr) + { + arma_extra_debug_sigprint(); + + // NOTE: this is a temporary and rudimentary implementation + + typedef typename T1::elem_type eT; + typedef typename T1::pod_type T; + + const Mat A = expr.get_ref(); + + arma_debug_check( (A.is_square() == false), "inv_sympd(): given matrix must be square sized" ); + + const bool status = op_inv_spd::apply_direct(out_inv, A, uword(0)); + + if(status) + { + out_rcond = op_cond::rcond(expr.get_ref()); + } + else + { + out_rcond = T(0); + } + + return status; + } + + + +//! @} diff --git a/include/armadillo_bits/op_inv_spd_bones.hpp b/include/armadillo_bits/op_inv_spd_bones.hpp index d86d0640..8b6c00a9 100644 --- a/include/armadillo_bits/op_inv_spd_bones.hpp +++ b/include/armadillo_bits/op_inv_spd_bones.hpp @@ -45,9 +45,6 @@ class op_inv_spd template inline static bool apply_direct(Mat& out, const Base& expr, const uword flags); - - template - inline static bool apply_direct_rcond(Mat& out_inv, typename T1::pod_type& out_rcond, const Base& expr); }; diff --git a/include/armadillo_bits/op_inv_spd_meat.hpp b/include/armadillo_bits/op_inv_spd_meat.hpp index 48c53e98..f5f5996a 100644 --- a/include/armadillo_bits/op_inv_spd_meat.hpp +++ b/include/armadillo_bits/op_inv_spd_meat.hpp @@ -194,36 +194,4 @@ op_inv_spd::apply_direct(Mat& out, const Base -inline -bool -op_inv_spd::apply_direct_rcond(Mat& out_inv, typename T1::pod_type& out_rcond, const Base& expr) - { - arma_extra_debug_sigprint(); - - // NOTE: this is a temporary and rudimentary implementation - - typedef typename T1::elem_type eT; - typedef typename T1::pod_type T; - - const Mat A = expr.get_ref(); - - arma_debug_check( (A.is_square() == false), "inv_sympd(): given matrix must be square sized" ); - - const bool status = op_inv_spd::apply_direct(out_inv, A, uword(0)); - - if(status) - { - out_rcond = op_cond::rcond(expr.get_ref()); - } - else - { - out_rcond = T(0); - } - - return status; - } - - - //! @}