19#include "matpack_concepts.h"
31class Array :
public std::vector<base> {
36 explicit Array(Index n) :
std::vector<base>(n) {}
38 Array(Index n,
const base& fillvalue) :
std::vector<base>(n) {
39 std::fill(this->begin(), this->end(), fillvalue);
44 Array(
Array&& A) noexcept : std::vector<base>(std::move(A)) {}
46 Array(std::initializer_list<base> init) :
std::vector<base>(init) {}
48 template <
class base2,
size_t N>
49 explicit Array(
const std::array<base2, N>& input)
50 :
std::vector<base>(input.begin(), input.end()) {
51 static_assert(std::is_convertible<base2, base>::value,
52 "Must be convertible");
55 Array(std::vector<base> x) :
std::vector<base>(
std::move(x)) {}
59 std::fill(this->begin(), this->end(), x);
64 this->resize(A.size());
65 std::copy(A.begin(), A.end(), this->begin());
70 std::vector<base>::operator=(std::move(A));
76 size_t s = this->size();
78 return static_cast<Index
>(s);
85 return std::vector<base>::operator[](n);
91 return std::vector<base>::operator[](n);
96 for (Index i = 0; i < n; i++) std::vector<base>::push_back(elem);
102 typename Array::const_iterator i =
v.begin();
103 const typename Array::const_iterator end =
v.end();
106 os << std::setw(3) << *i;
110 for (; i != end; ++i) {
111 os <<
" " << std::setw(3) << *i;
135 for (; xi != xe; ++xi) {
151 for (; xi != xe; ++xi) {
174 for (Index i = 0; i < x.
nelem(); ++i)
175 if (
w == x[i])
return i;
197 for (Index i = 0; i < x.
nelem(); ++i)
198 if (
w == x[i]) pos.push_back(i);
226 for (Index i = 0; i < aa.nelem(); i++) {
227 N_aa += aa[i].nelem();
242 for (Index i = 0; i < outer; i++) {
254template <
typename T,
typename... Ts>
255constexpr std::array<T, 1 +
sizeof...(Ts)>
stdarrayify(
const T& first,
256 const Ts&... the_rest) {
257 return {first, T(the_rest)...};
262 const char*
const sep =
" ",
263 const char*
const beg =
"") {
264 std::ostringstream os;
265 for (
auto& x : list) os << beg << x << sep;
std::string stringify(const Array< T > &list, const char *const sep=" ", const char *const beg="")
Index TotalNumberOfElements(const Array< Array< base > > &aa)
Determine total number of elements in an ArrayOfArray.
Index FlattenedIndex(const Array< Array< base > > &aa, Index outer, Index inner=0)
Determine the index of an element in a flattened version of the array.
Index find_first(const Array< base > &x, const base &w)
Find first occurance.
base max(const Array< base > &x)
Max function.
base min(const Array< base > &x)
Min function.
void find_all(ArrayOfIndex &pos, const Array< base > &x, const base &w)
Find all occurances.
constexpr std::array< T, 1+sizeof...(Ts)> stdarrayify(const T &first, const Ts &... the_rest)
Make a std::array of a list of variables (must be 1-long at least)
This can be used to make arrays out of anything.
Array(Index n, const base &fillvalue)
Array(const std::array< base2, N > &input)
Array & operator=(base x)
void push_back_n(const base &elem, const Index n)
Array(std::vector< base > x)
Array & operator=(const Array &A)
base & operator[](const Index n)
friend std::ostream & operator<<(std::ostream &os, const Array &v)
Array(std::initializer_list< base > init)
const base & operator[](const Index n) const
Index nelem() const ARTS_NOEXCEPT
Array & operator=(Array &&A) noexcept
Array(Array &&A) noexcept
Helper comparison class to sort an array or vector based on an ArrayOfNumeric.
CmpArrayOfNumeric(const ArrayOfNumeric &vec)
const ArrayOfNumeric & values
bool operator()(const int &a, const int &b) const
#define ARTS_ASSERT(condition,...)