From c3db1ead0385cf790471ca455a197fbf4d2e8ea0 Mon Sep 17 00:00:00 2001 From: conrad Date: Wed, 9 Jul 2025 13:48:27 +1000 Subject: [PATCH] ensure junk args are const and are explicitly ignored --- include/armadillo_bits/op_norm_bones.hpp | 22 +++++++++++++--------- include/armadillo_bits/op_norm_meat.hpp | 6 ++++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/armadillo_bits/op_norm_bones.hpp b/include/armadillo_bits/op_norm_bones.hpp index c9e25087..e415096e 100644 --- a/include/armadillo_bits/op_norm_bones.hpp +++ b/include/armadillo_bits/op_norm_bones.hpp @@ -27,16 +27,20 @@ class op_norm template arma_hot inline static typename T1::pod_type vec_norm_1(const Proxy& P, const typename arma_not_cx::result* junk = nullptr); template arma_hot inline static typename T1::pod_type vec_norm_1(const Proxy& P, const typename arma_cx_only::result* junk = nullptr); - template arma_hot inline static eT vec_norm_1_direct_std(const Mat& X, const typename arma_blas_real_only::result* junk = nullptr); - template arma_hot inline static eT vec_norm_1_direct_std(const Mat& X, const typename arma_fp16_only::result* junk = nullptr); - template arma_hot inline static eT vec_norm_1_direct_mem(const uword N, const eT* A); + + template arma_hot inline static eT vec_norm_1_direct_std(const Mat& X, const typename arma_blas_real_only::result* junk = nullptr); + template arma_hot inline static eT vec_norm_1_direct_std(const Mat& X, const typename arma_fp16_only::result* junk = nullptr); + + template arma_hot inline static eT vec_norm_1_direct_mem(const uword N, const eT* A); template arma_hot inline static typename T1::pod_type vec_norm_2(const Proxy& P, const typename arma_not_cx::result* junk = nullptr); template arma_hot inline static typename T1::pod_type vec_norm_2(const Proxy& P, const typename arma_cx_only::result* junk = nullptr); - template arma_hot inline static eT vec_norm_2_direct_std(const Mat& X, const typename arma_blas_real_only::result* junk = nullptr); - template arma_hot inline static eT vec_norm_2_direct_std(const Mat& X, const typename arma_fp16_only::result* junk = nullptr); - template arma_hot inline static eT vec_norm_2_direct_mem(const uword N, const eT* A); - template arma_hot inline static eT vec_norm_2_direct_robust(const Mat& X); + + template arma_hot inline static eT vec_norm_2_direct_std(const Mat& X, const typename arma_blas_real_only::result* junk = nullptr); + template arma_hot inline static eT vec_norm_2_direct_std(const Mat& X, const typename arma_fp16_only::result* junk = nullptr); + + template arma_hot inline static eT vec_norm_2_direct_mem(const uword N, const eT* A); + template arma_hot inline static eT vec_norm_2_direct_robust(const Mat& X); template arma_hot inline static typename T1::pod_type vec_norm_k(const Proxy& P, const int k); @@ -44,8 +48,8 @@ class op_norm template arma_hot inline static typename T1::pod_type vec_norm_min(const Proxy& P); template inline static typename get_pod_type::result mat_norm_1(const Mat& X); - template inline static typename get_pod_type::result mat_norm_2(const Mat& X, typename arma_blas_real_or_cx_only::result* junk = nullptr); - template inline static typename get_pod_type::result mat_norm_2(const Mat& X, typename arma_fp16_only::result* junk = nullptr); + template inline static typename get_pod_type::result mat_norm_2(const Mat& X, const typename arma_blas_real_or_cx_only::result* junk = nullptr); + template inline static typename get_pod_type::result mat_norm_2(const Mat& X, const typename arma_fp16_only::result* junk = nullptr); template inline static typename get_pod_type::result mat_norm_inf(const Mat& X); }; diff --git a/include/armadillo_bits/op_norm_meat.hpp b/include/armadillo_bits/op_norm_meat.hpp index f26cb462..62cfcdc3 100644 --- a/include/armadillo_bits/op_norm_meat.hpp +++ b/include/armadillo_bits/op_norm_meat.hpp @@ -931,9 +931,10 @@ op_norm::mat_norm_1(const Mat& X) template inline typename get_pod_type::result -op_norm::mat_norm_2(const Mat& X, typename arma_blas_real_or_cx_only::result* junk) +op_norm::mat_norm_2(const Mat& X, const typename arma_blas_real_or_cx_only::result* junk) { arma_debug_sigprint(); + arma_ignore(junk); typedef typename get_pod_type::result T; @@ -953,9 +954,10 @@ op_norm::mat_norm_2(const Mat& X, typename arma_blas_real_or_cx_only::re template inline typename get_pod_type::result -op_norm::mat_norm_2(const Mat& X, typename arma_fp16_only::result* junk) +op_norm::mat_norm_2(const Mat& X, const typename arma_fp16_only::result* junk) { arma_debug_sigprint(); + arma_ignore(junk); arma_stop_logic_error("norm(): matrix 2-norm currently not supported for fp16; try norm2est() instead");