From 4b72ceda110b23016e48dbcab69890931b2de062 Mon Sep 17 00:00:00 2001 From: conrad Date: Sun, 16 Jun 2024 18:20:21 +1000 Subject: [PATCH] add .as_dense() --- include/armadillo | 2 ++ include/armadillo_bits/SpBase_bones.hpp | 2 ++ include/armadillo_bits/SpBase_meat.hpp | 10 ++++++++++ include/armadillo_bits/SpCol_bones.hpp | 2 ++ include/armadillo_bits/SpCol_meat.hpp | 10 ++++++++++ include/armadillo_bits/SpRow_bones.hpp | 2 ++ include/armadillo_bits/SpRow_meat.hpp | 10 ++++++++++ include/armadillo_bits/SpSubview_bones.hpp | 4 ++++ include/armadillo_bits/SpSubview_meat.hpp | 20 ++++++++++++++++++++ include/armadillo_bits/arma_forward.hpp | 2 +- 10 files changed, 63 insertions(+), 1 deletion(-) diff --git a/include/armadillo b/include/armadillo index 6bf138bf..5c3f5995 100644 --- a/include/armadillo +++ b/include/armadillo @@ -326,6 +326,7 @@ namespace arma #include "armadillo_bits/op_sp_vecnorm_bones.hpp" #include "armadillo_bits/op_sp_diagvec_bones.hpp" #include "armadillo_bits/op_sp_nonzeros_bones.hpp" + #include "armadillo_bits/op_sp_as_dense_bones.hpp" #include "armadillo_bits/op_powmat_bones.hpp" #include "armadillo_bits/op_rank_bones.hpp" #include "armadillo_bits/op_row_as_mat_bones.hpp" @@ -778,6 +779,7 @@ namespace arma #include "armadillo_bits/op_sp_vecnorm_meat.hpp" #include "armadillo_bits/op_sp_diagvec_meat.hpp" #include "armadillo_bits/op_sp_nonzeros_meat.hpp" + #include "armadillo_bits/op_sp_as_dense_meat.hpp" #include "armadillo_bits/op_powmat_meat.hpp" #include "armadillo_bits/op_rank_meat.hpp" #include "armadillo_bits/op_row_as_mat_meat.hpp" diff --git a/include/armadillo_bits/SpBase_bones.hpp b/include/armadillo_bits/SpBase_bones.hpp index d16bf476..cc53e93b 100644 --- a/include/armadillo_bits/SpBase_bones.hpp +++ b/include/armadillo_bits/SpBase_bones.hpp @@ -109,6 +109,8 @@ struct SpBase arma_warn_unused inline const SpOp as_col() const; arma_warn_unused inline const SpOp as_row() const; + + arma_warn_unused inline const SpToDOp as_dense() const; }; diff --git a/include/armadillo_bits/SpBase_meat.hpp b/include/armadillo_bits/SpBase_meat.hpp index b8ba23e5..01cfb692 100644 --- a/include/armadillo_bits/SpBase_meat.hpp +++ b/include/armadillo_bits/SpBase_meat.hpp @@ -880,4 +880,14 @@ SpBase::as_row() const +template +inline +const SpToDOp +SpBase::as_dense() const + { + return SpToDOp( (*this).get_ref() ); + } + + + //! @} diff --git a/include/armadillo_bits/SpCol_bones.hpp b/include/armadillo_bits/SpCol_bones.hpp index f6e6de9f..03b4b5fa 100644 --- a/include/armadillo_bits/SpCol_bones.hpp +++ b/include/armadillo_bits/SpCol_bones.hpp @@ -62,6 +62,8 @@ class SpCol : public SpMat arma_warn_unused inline const SpOp,spop_htrans> ht() const; arma_warn_unused inline const SpOp,spop_strans> st() const; + arma_warn_unused inline const SpToDOp,op_sp_as_dense> as_dense() const; + inline void shed_row (const uword row_num); inline void shed_rows(const uword in_row1, const uword in_row2); diff --git a/include/armadillo_bits/SpCol_meat.hpp b/include/armadillo_bits/SpCol_meat.hpp index f43d8a3c..9ff3bf23 100644 --- a/include/armadillo_bits/SpCol_meat.hpp +++ b/include/armadillo_bits/SpCol_meat.hpp @@ -244,6 +244,16 @@ SpCol::st() const +template +inline +const SpToDOp,op_sp_as_dense> +SpCol::as_dense() const + { + return SpToDOp,op_sp_as_dense>(*this); + } + + + //! remove specified row template inline diff --git a/include/armadillo_bits/SpRow_bones.hpp b/include/armadillo_bits/SpRow_bones.hpp index fab171b7..c5fed2fa 100644 --- a/include/armadillo_bits/SpRow_bones.hpp +++ b/include/armadillo_bits/SpRow_bones.hpp @@ -62,6 +62,8 @@ class SpRow : public SpMat arma_warn_unused inline const SpOp,spop_htrans> ht() const; arma_warn_unused inline const SpOp,spop_strans> st() const; + arma_warn_unused inline const SpToDOp,op_sp_as_dense> as_dense() const; + inline void shed_col (const uword col_num); inline void shed_cols(const uword in_col1, const uword in_col2); diff --git a/include/armadillo_bits/SpRow_meat.hpp b/include/armadillo_bits/SpRow_meat.hpp index 596b016d..3d063bfb 100644 --- a/include/armadillo_bits/SpRow_meat.hpp +++ b/include/armadillo_bits/SpRow_meat.hpp @@ -246,6 +246,16 @@ SpRow::st() const +template +inline +const SpToDOp,op_sp_as_dense> +SpRow::as_dense() const + { + return SpToDOp,op_sp_as_dense>(*this); + } + + + //! remove specified columns template inline diff --git a/include/armadillo_bits/SpSubview_bones.hpp b/include/armadillo_bits/SpSubview_bones.hpp index 6be50b3a..fe32216e 100644 --- a/include/armadillo_bits/SpSubview_bones.hpp +++ b/include/armadillo_bits/SpSubview_bones.hpp @@ -361,6 +361,8 @@ class SpSubview_col : public SpSubview arma_warn_unused inline const SpOp,spop_htrans> ht() const; arma_warn_unused inline const SpOp,spop_strans> st() const; + arma_warn_unused inline const SpToDOp,op_sp_as_dense> as_dense() const; + protected: @@ -399,6 +401,8 @@ class SpSubview_row : public SpSubview arma_warn_unused inline const SpOp,spop_htrans> ht() const; arma_warn_unused inline const SpOp,spop_strans> st() const; + arma_warn_unused inline const SpToDOp,op_sp_as_dense> as_dense() const; + protected: diff --git a/include/armadillo_bits/SpSubview_meat.hpp b/include/armadillo_bits/SpSubview_meat.hpp index 8b2e704a..757be653 100644 --- a/include/armadillo_bits/SpSubview_meat.hpp +++ b/include/armadillo_bits/SpSubview_meat.hpp @@ -1907,6 +1907,16 @@ SpSubview_col::st() const +template +inline +const SpToDOp,op_sp_as_dense> +SpSubview_col::as_dense() const + { + return SpToDOp,op_sp_as_dense>(*this); + } + + + // // // @@ -2013,4 +2023,14 @@ SpSubview_row::st() const +template +inline +const SpToDOp,op_sp_as_dense> +SpSubview_row::as_dense() const + { + return SpToDOp,op_sp_as_dense>(*this); + } + + + //! @} diff --git a/include/armadillo_bits/arma_forward.hpp b/include/armadillo_bits/arma_forward.hpp index 06f4d1c7..1bad37f4 100644 --- a/include/armadillo_bits/arma_forward.hpp +++ b/include/armadillo_bits/arma_forward.hpp @@ -138,7 +138,7 @@ class spglue_min; class spglue_rel_lt; class spglue_rel_gt; - +class op_sp_as_dense; class op_internal_equ; class op_internal_plus;