97 template <
typename Iterator,
108 auto it = in.begin();
109 for (; it != in.end(); ++it)
push_back(*it);
141 assert(ind >= 0 && ind <
N);
146 assert(ind >= 0 && ind <
N);
151 assert(ind >= 0 && ind <
N);
156 assert(ind >= 0 && ind <
N);
190 template <
typename CompareType>
245 void print_column(std::ostream &stream,
const std::string &indent =
"")
const;
251 template <
typename T>
266 template <
typename T>
274 template <
typename T>
277 if (!(initial <=
final))
return seq;
281 while (seq.
back() <
final) {
291 template <
typename T>
298 if (seq[0] < seq[1]) {
299 if (
final < seq[1]) {
301 if (
final < initial) {
307 while (seq.
back() <
final) {
309 seq.
back() += increment;
313 }
else if (seq[1] < seq[0]) {
314 if (seq[1] <
final) {
316 if (initial <
final) {
322 while (
final < seq.
back()) {
324 seq.
back() += increment;
330 if (initial <
final ||
final < initial) seq.
clear();
337 template <
typename T>
344 if (NMax < RHS.
size()) {
347 for (i = 0; i < RHS.
size(); i++) push_back(RHS[i]);
351 while (N > RHS.
size()) pop_back();
355 while (N < RHS.
size()) push_back(RHS[N]);
357 while (i--) Vals[i] = RHS[i];
364 template <
typename T>
370 template <
typename T>
372 if (
this == &RHS)
return;
374 Index tN(N), tNMax(NMax);
389 template <
typename T>
394 while (N < new_N)
new (Vals + (N++)) T();
401 template <
typename T>
405 while (N < new_N)
new (Vals + (N++)) T(fill_val);
410 template <
typename T>
412 if (new_max <= N)
return;
416 tVal =
static_cast<T *
>(
operator new(new_max *
sizeof(T)));
417 for (
Index i = 0; i < N; i++) {
418 new (tVal + i) T(Vals[i]);
422 if (Vals)
operator delete(Vals);
430 template <
typename T>
435 Index new_Max = (N * ARRAY_EXTENSION_FACTOR() > N + ARRAY_MIN_EXTRA_SPACE())
436 ? (
Index)(N * ARRAY_EXTENSION_FACTOR())
437 : N + ARRAY_MIN_EXTRA_SPACE();
441 tVal =
static_cast<T *
>(
operator new(new_Max *
sizeof(T)));
444 new (tVal + N) T(toPush);
445 for (
Index i = 0; i < N; i++) {
446 new (tVal + i) T(Vals[i]);
450 if (Vals)
operator delete(Vals);
456 new (Vals + (N++)) T(toPush);
461 template <
typename T>
463 for (
Index i = ind + 1; i < N; i++) at(i - 1) = at(i);
471 template <
typename T>
473 if (N != RHS.
N)
return false;
476 for (i = 0; i < N; i++) {
477 if (!(at(i) == RHS[i])) {
486 template <
typename T>
488 if (size() != RHS.
size())
return size() < RHS.
size();
490 for (
Index i = 0; i < size(); i++) {
493 else if (at(i) > RHS[i])
500 template <
typename T>
502 if (size() != RHS.
size())
return size() > RHS.
size();
504 for (
Index i = 0; i < size(); i++) {
507 else if (at(i) < RHS[i])
514 template <
typename T>
518 <<
"ERROR: Tried to find maximum value of empty array! Exiting...\n";
525 for (
Index i = 1; i < size(); i++) {
526 if (at(imax) < at(i)) imax = i;
533 template <
typename T>
537 <<
"ERROR: Tried to find minimum value of empty array! Exiting...\n";
543 for (
Index i = 1; i < size(); i++) {
544 if (at(i) < at(imin)) imin = i;
551 template <
typename T>
554 for (
Index i = 0; i < size(); i++) {
561 template <
typename T>
563 assert(ind_begin <= ind_end && ind_end < size() &&
564 "Array::operator() indices out of bounds!");
566 sub.
reserve(ind_end - ind_begin);
567 while (ind_begin <= ind_end) {
574 template <
typename T>
576 for (
Index i = 0; i < N; i++) {
589 template <
typename T>
592 for (
Index i = 0; i < N; i++) {
603 template <
typename T>
606 for (
Index i = 0; i < N; i++) {
607 if (at(i) == test_elem) {
617 template <
typename T>
619 for (
Index i = 0; i < N; i++) {
620 if (at(i) == test_elem) {
630 template <
typename T>
632 for (
Index i = N - 1; i >= 0; i--) {
633 if (at(i) == test_elem) {
643 template <
typename T>
645 for (
Index i = 0; i < N; i++) {
655 template <
typename T>
657 const std::string &indent)
const {
658 for (
Index i = 0; i < N; i++) stream << indent << at(i) << std::endl;
662 template <
typename T>
664 for (
Index i = N - 1; i >= 0; i--) {
675 template <
typename T>
676 template <
typename CompareType>
684 int left, right, middle, pivot, curr, i;
699 left = queue_left[0];
700 right = queue_right[0];
710 middle = left + (right - left) / 2;
713 if (
comp.compare(at(left), at(middle))) {
714 if (
comp.compare(at(middle), at(right)))
717 if (
comp.compare(at(left), at(right)))
723 if (
comp.compare(at(right), at(middle)))
726 if (
comp.compare(at(right), at(left)))
734 swap_elem(pivot, right);
739 for (i = left; i < right; i++) {
740 if (
comp.compare(at(i), at(right))) {
747 swap_elem(curr, right);
754 if (left != curr - 1) {
761 if (curr + 1 != right) {
769 if (queue_left.
size() > max_q) max_q = queue_left.
size();
771 }
while (queue_left.
size() > 0);
779 template <
typename T>
784 for (
Index i = 0; i < size(); i++) {
785 for (
Index j = i + 1; j < size(); j++) {
796 template <
typename T>
798 for (
Index i = 0; i < size(); i++) {
799 for (
Index j = i + 1; j < size(); j++) {
807 template <
typename T>
809 reserve(size() + new_tail.
size());
811 for (
Index i = 0; i < Nadd; i++) push_back(new_tail[i]);
817 template <
typename T>
820 for (
Index i = 0; i < Nadd; i++) {
821 if (!
contains(new_tail[i])) push_back(new_tail[i]);
831 template <
typename T>
833 assert(perm_array.
size() == size());
836 for (
Index i = 0; i < perm_array.
size(); i++)
837 after_array.
push_back(at(perm_array[i]));
848 template <
typename T>
850 assert(perm_array.
size() == size());
853 for (
Index i = 0; i < perm_array.
size(); i++) {
854 if (i != perm_array[i]) {
855 after_array[perm_array[i]] = at(i);
864 template <
typename T>
866 Index i(N - 2), j(N - 1);
867 bool is_valid =
true;
871 while (at(j) <= at(i)) j--;
881 while (i < j) swap_elem(i++, j--);
891 template <
typename T>
894 for (
Index i = 0; i < size(); i++) {
895 iperm_array[at(i)] = i;
909 template <
typename T>
912 return ((trans_perm.
as_perm_inverse()).permute(*
this)).permute(trans_perm);
917 template <
typename T>
919 for (
Index i = 0; i < N - 1; i++) {
920 if (at(i + 1) < at(i))
return false;
928 template <
typename T>
930 for (
Index i = 0; i < N - 1; i++) {
931 if (at(i) < at(i + 1))
return false;
939 template <
typename T>
941 for (
Index i = 0; i < N - 1; i++) {
942 if (!(at(i) == at(i + 1)))
return false;
952 template <
typename T>
954 for (
Index i = 0; i < size(); i++) {
955 if (at(i) < 0 || at(i) >= size() ||
find(at(i)) < i)
return false;
964 template <
typename T>
966 for (
Index i = 0; i < size(); i++) {
967 if (at(i) == i)
return true;
981 if (array_out.
size() == 0) out <<
"[empty] ";
982 for (
Index i = 0; i < array_out.
size(); i++) {
983 out << array_out[i] <<
" ";
1003 template <
typename T>
1013 template <
typename T>
Basic std::vector like container (deprecated)
bool operator!=(const Array< T > &RHS) const
Array(Index init_N, const T &init_val)
bool almost_contains(const T &test_elem, double tol_val=TOL) const
const T & operator[](Index ind) const
bool operator>=(const Array< T > &RHS) const
Array(Iterator begin, Iterator end)
const T & at(Index ind) const
bool contains(const T &test_elem) const
T & operator[](Index ind)
Array(std::initializer_list< T > in)
void swap_elem(Index i, Index j)
static Index ARRAY_MIN_EXTRA_SPACE()
static double ARRAY_EXTENSION_FACTOR()
bool operator<=(const Array< T > &RHS) const
bool compare(const Array< T > &a, const Array< T > &b) const
ReturnArray & operator=(Array< T > &RHS)
ReturnArray(Array< T > &init_tens)
bool operator>(const Array< T > &RHS) const
bool all_in(const Array &superset) const
void reserve(Index new_max)
Array & append_unique(const Array &new_tail)
static ReturnArray< T > sequence(const T &initial, const T &increment, const T &final)
ReturnArray< T > sub_array(Index ind_begin, Index ind_end) const
Index reverse_find(const T &test_elem) const
Same as find, but starts from the last element of the Array.
ReturnArray< Index > as_perm_inverse() const
void swap(Array< T > &RHS)
Array & operator=(ReturnArray< T > &RHS)
Array< T > array_cat(const Array< T > &A1, const Array< T > &A2)
bool operator<(const Array< T > &RHS) const
Array & ipermute(const Array< Index > &perm_array)
bool is_descending() const
ReturnArray< Index > as_perm_transform_by(const Array< Index > &trans_perm) const
Index almost_find(const T &test_elem, double tol_val=TOL) const
Array & permute(const Array< Index > &perm_array)
static ReturnArray< T > sequence(const T &initial, const T &final)
void push_back(const T &toPush)
Index coincidence(const Array &superset) const
void sort(const CompareType &comp)
void print_column(std::ostream &stream, const std::string &indent="") const
Index incidences(const T &test_elem) const
void resize(Index new_N, const T &fill_val)
bool is_ascending() const
Array(ReturnArray< T > &RHS)
void sort(Array< Index > &ind_order)
bool operator==(const Array< T > &RHS) const
Array & append(const Array &new_tail)
Index find(const T &test_elem) const
Index almost_reverse_find(const T &test_elem, double tol_val=TOL) const
Same as almost_find, but start from the last element of the Array.
bool has_fixed_points() const
Array & operator=(const Array &RHS)
void swap(Array< T > &A1, Array< T > &A2)
Eigen::VectorXd comp(const Configuration &config)
Returns parametric composition, as calculated using PrimClex::param_comp.
std::enable_if< is_iterator< T >::type::value &&std::is_same< typename std::iterator_traits< T >::value_type, V >::type::value, void > enable_if_iterator_of
Template alias to enable a template function via SFINAE for an iterator with value_type V.
bool almost_equal(ClusterInvariants const &A, ClusterInvariants const &B, double tol)
Check if ClusterInvariants are equal.
std::ostream & operator<<(std::ostream &_stream, const FormattedPrintable &_formatted)
void swap(ConfigDoF &A, ConfigDoF &B)
Iterator find(Iterator begin, Iterator end, const T &value, BinaryCompare q)
Equivalent to std::find(begin, end, value), but with custom comparison.
bool contains(const Container &container, const T &value)
Equivalent to container.end() != std::find(container.begin(), container.end(), value)
bool valid_index(Index i)
INDEX_TYPE Index
For long integer indexing: