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/Col_bones.hpp | 288 +++++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 src/armadillo/include/armadillo_bits/Col_bones.hpp (limited to 'src/armadillo/include/armadillo_bits/Col_bones.hpp') diff --git a/src/armadillo/include/armadillo_bits/Col_bones.hpp b/src/armadillo/include/armadillo_bits/Col_bones.hpp new file mode 100644 index 0000000..b3f0ab6 --- /dev/null +++ b/src/armadillo/include/armadillo_bits/Col_bones.hpp @@ -0,0 +1,288 @@ +// 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 Col +//! @{ + +//! Class for column vectors (matrices with only one column) + +template +class Col : public Mat + { + public: + + typedef eT elem_type; + typedef typename get_pod_type::result pod_type; + + static constexpr bool is_col = true; + static constexpr bool is_row = false; + static constexpr bool is_xvec = false; + + inline Col(); + inline Col(const Col& X); + + inline explicit Col(const uword n_elem); + inline explicit Col(const uword in_rows, const uword in_cols); + inline explicit Col(const SizeMat& s); + + template inline explicit Col(const uword n_elem, const arma_initmode_indicator&); + template inline explicit Col(const uword in_rows, const uword in_cols, const arma_initmode_indicator&); + template inline explicit Col(const SizeMat& s, const arma_initmode_indicator&); + + template inline Col(const uword n_elem, const fill::fill_class& f); + template inline Col(const uword in_rows, const uword in_cols, const fill::fill_class& f); + template inline Col(const SizeMat& s, const fill::fill_class& f); + + inline Col(const uword N, const fill::scalar_holder f); + inline Col(const uword in_rows, const uword in_cols, const fill::scalar_holder f); + inline Col(const SizeMat& s, const fill::scalar_holder f); + + inline Col(const char* text); + inline Col& operator=(const char* text); + + inline Col(const std::string& text); + inline Col& operator=(const std::string& text); + + inline Col(const std::vector& x); + inline Col& operator=(const std::vector& x); + + inline Col(const std::initializer_list& list); + inline Col& operator=(const std::initializer_list& list); + + inline Col(Col&& m); + inline Col& operator=(Col&& m); + + // inline Col(Mat&& m); + // inline Col& operator=(Mat&& m); + + inline Col& operator=(const eT val); + inline Col& operator=(const Col& m); + + template inline Col(const Base& X); + template inline Col& operator=(const Base& X); + + template inline explicit Col(const SpBase& X); + template inline Col& operator=(const SpBase& X); + + inline Col( eT* aux_mem, const uword aux_length, const bool copy_aux_mem = true, const bool strict = false); + inline Col(const eT* aux_mem, const uword aux_length); + + template + inline explicit Col(const Base& A, const Base& B); + + template inline Col(const BaseCube& X); + template inline Col& operator=(const BaseCube& X); + + inline Col(const subview_cube& X); + inline Col& operator=(const subview_cube& X); + + arma_frown("use braced initialiser list instead") inline mat_injector operator<<(const eT val); + + arma_warn_unused arma_inline const Op,op_htrans> t() const; + arma_warn_unused arma_inline const Op,op_htrans> ht() const; + arma_warn_unused arma_inline const Op,op_strans> st() const; + + arma_warn_unused arma_inline const Op,op_strans> as_row() const; + + arma_inline subview_col row(const uword row_num); + arma_inline const subview_col row(const uword row_num) const; + + using Mat::rows; + using Mat::operator(); + + arma_inline subview_col rows(const uword in_row1, const uword in_row2); + arma_inline const subview_col rows(const uword in_row1, const uword in_row2) const; + + arma_inline subview_col subvec(const uword in_row1, const uword in_row2); + arma_inline const subview_col subvec(const uword in_row1, const uword in_row2) const; + + arma_inline subview_col rows(const span& row_span); + arma_inline const subview_col rows(const span& row_span) const; + + arma_inline subview_col subvec(const span& row_span); + arma_inline const subview_col subvec(const span& row_span) const; + + arma_inline subview_col operator()(const span& row_span); + arma_inline const subview_col operator()(const span& row_span) const; + + arma_inline subview_col subvec(const uword start_row, const SizeMat& s); + arma_inline const subview_col subvec(const uword start_row, const SizeMat& s) const; + + arma_inline subview_col head(const uword N); + arma_inline const subview_col head(const uword N) const; + + arma_inline subview_col tail(const uword N); + arma_inline const subview_col tail(const uword N) const; + + arma_inline subview_col head_rows(const uword N); + arma_inline const subview_col head_rows(const uword N) const; + + arma_inline subview_col tail_rows(const uword N); + arma_inline const subview_col tail_rows(const uword N) const; + + + inline void shed_row (const uword row_num); + inline void shed_rows(const uword in_row1, const uword in_row2); + + template inline void shed_rows(const Base& indices); + + arma_deprecated inline void insert_rows(const uword row_num, const uword N, const bool set_to_zero); + inline void insert_rows(const uword row_num, const uword N); + + template inline void insert_rows(const uword row_num, const Base& X); + + + arma_warn_unused arma_inline eT& at(const uword i); + arma_warn_unused arma_inline const eT& at(const uword i) const; + + arma_warn_unused arma_inline eT& at(const uword in_row, const uword in_col); + arma_warn_unused arma_inline const eT& at(const uword in_row, const uword in_col) const; + + + typedef eT* row_iterator; + typedef const eT* const_row_iterator; + + inline row_iterator begin_row(const uword row_num); + inline const_row_iterator begin_row(const uword row_num) const; + + inline row_iterator end_row (const uword row_num); + inline const_row_iterator end_row (const uword row_num) const; + + + template class fixed; + + + protected: + + inline Col(const arma_fixed_indicator&, const uword in_n_elem, const eT* in_mem); + + + public: + + #if defined(ARMA_EXTRA_COL_PROTO) + #include ARMA_INCFILE_WRAP(ARMA_EXTRA_COL_PROTO) + #endif + }; + + + +template +template +class Col::fixed : public Col + { + private: + + static constexpr bool use_extra = (fixed_n_elem > arma_config::mat_prealloc); + + arma_align_mem eT mem_local_extra[ (use_extra) ? fixed_n_elem : 1 ]; + + + public: + + typedef fixed Col_fixed_type; + + typedef eT elem_type; + typedef typename get_pod_type::result pod_type; + + static constexpr bool is_col = true; + static constexpr bool is_row = false; + static constexpr bool is_xvec = false; + + static const uword n_rows; // value provided below the class definition + static const uword n_cols; // value provided below the class definition + static const uword n_elem; // value provided below the class definition + + arma_inline fixed(); + arma_inline fixed(const fixed& X); + inline fixed(const subview_cube& X); + + inline fixed(const fill::scalar_holder f); + template inline fixed(const fill::fill_class& f); + template inline fixed(const Base& A); + template inline fixed(const Base& A, const Base& B); + + inline fixed(const eT* aux_mem); + + inline fixed(const char* text); + inline fixed(const std::string& text); + + template inline Col& operator=(const Base& A); + + inline Col& operator=(const eT val); + inline Col& operator=(const char* text); + inline Col& operator=(const std::string& text); + inline Col& operator=(const subview_cube& X); + + using Col::operator(); + + inline fixed(const std::initializer_list& list); + inline Col& operator=(const std::initializer_list& list); + + arma_inline Col& operator=(const fixed& X); + + #if defined(ARMA_GOOD_COMPILER) + template inline Col& operator=(const eOp& X); + template inline Col& operator=(const eGlue& X); + #endif + + arma_warn_unused arma_inline const Op< Col_fixed_type, op_htrans > t() const; + arma_warn_unused arma_inline const Op< Col_fixed_type, op_htrans > ht() const; + arma_warn_unused arma_inline const Op< Col_fixed_type, op_strans > st() const; + + arma_warn_unused arma_inline const eT& at_alt (const uword i) const; + + arma_warn_unused arma_inline eT& operator[] (const uword i); + arma_warn_unused arma_inline const eT& operator[] (const uword i) const; + arma_warn_unused arma_inline eT& at (const uword i); + arma_warn_unused arma_inline const eT& at (const uword i) const; + arma_warn_unused arma_inline eT& operator() (const uword i); + arma_warn_unused arma_inline const eT& operator() (const uword i) const; + + arma_warn_unused arma_inline eT& at (const uword in_row, const uword in_col); + arma_warn_unused arma_inline const eT& at (const uword in_row, const uword in_col) const; + arma_warn_unused arma_inline eT& operator() (const uword in_row, const uword in_col); + arma_warn_unused arma_inline const eT& operator() (const uword in_row, const uword in_col) const; + + arma_warn_unused arma_inline eT* memptr(); + arma_warn_unused arma_inline const eT* memptr() const; + + inline const Col& fill(const eT val); + inline const Col& zeros(); + inline const Col& ones(); + }; + + + +// these definitions are outside of the class due to bizarre C++ rules; +// C++17 has inline variables to address this shortcoming + +template +template +const uword Col::fixed::n_rows = fixed_n_elem; + +template +template +const uword Col::fixed::n_cols = 1u; + +template +template +const uword Col::fixed::n_elem = fixed_n_elem; + + + +//! @} -- cgit v1.2.1