26 #include <type_traits>
89 template <class T, size_t alignment = std::alignment_of<T>::value>
class AlignedAllocator
102 static T * alloc (
size_t n)
110 size_t bytes = (n + (n % 2)) *
sizeof(T);
111 size_t align =
std::max(alignment,
sizeof(
void*));
114 void* aligned_ptr =
nullptr;
115 int err = posix_memalign(&aligned_ptr, align, bytes);
118 if (err != 0 or aligned_ptr ==
nullptr)
119 throw exception (
"[AlignedAllocator<T>::alloc] Aligned memory allocation error. Probably out of memory.");
122 T* ptr =
reinterpret_cast<T*
>(aligned_ptr);
125 *(ptr + n + (n % 2) - 1) = 0;
139 static void free (T * ptr)
161 class Alloc = AlignedAllocator <
227 :
N_(j - i),
array_(const_cast<T*>(&(*i))) {}
240 throw exception (
"[ArrayView::operator=] Cannot copy %ld elements to %ld fields!", v.
size(),
N_);
242 for (
size_t i = 0; i <
size(); i++)
258 throw exception (
"[ArrayView::operator[]] Index %ld out of bounds (size = %ld) !", i,
N_);
271 throw exception (
"[ArrayView::operator[]] Index %ld out of bounds (size = %ld) !", i,
N_);
293 T
const &
front (
int i = 0)
const {
return *(
data() + i); }
295 T
const &
back (
int i = 0)
const {
return *(
data() +
size() - 1 - i); }
298 void fill (T x) {
for (T & y : *
this) y = x; }
304 template <class = typename std::enable_if<is_scalar<T>::value>>
double norm ()
const
307 for (T
const & x : *
this)
309 return sqrt(sqrnorm);
342 Array (
size_t n, T x = T(0))
343 :
ArrayView<T>(n, Alloc::alloc(n)) {
for (
size_t i = 0; i <
size(); i++) (*
this)[i] = x; }
347 :
ArrayView<T>(n, Alloc::alloc(n)) {
for (
size_t i = 0; i <
size(); i++) (*
this)[i] = x[i]; }
351 :
ArrayView<T>(a.
size(), Alloc::alloc(a.
size())) {
for (
size_t i = 0; i <
size(); i++) (*
this)[i] = a[i]; }
355 :
ArrayView<T>(a.
size(), Alloc::alloc(a.
size())) {
for (
size_t i = 0; i <
size(); i++) (*
this)[i] = a[i]; }
363 :
ArrayView<T>(a.
size(), Alloc::alloc(a.
size())) {
for (
size_t i = 0; i <
size(); i++) (*
this)[i] = a[i]; }
367 :
ArrayView<T>(a.
end()-a.
begin(), Alloc::alloc(a.
end()-a.
begin())) {
size_t i = 0;
for (
auto it = a.begin(); it != a.end(); it++) (*
this)[i++] = *it; }
370 template <
typename ForwardIterator>
Array (ForwardIterator i, ForwardIterator j)
371 :
ArrayView<T>(std::distance(i,j), Alloc::alloc(std::distance(i,j)))
374 for (ForwardIterator k = i; k != j; k++)
414 for (
size_t i = 0; i < n; i++)
415 new_array[i] = (i <
size()) ? (*this)[i] : T(0);
462 for (
size_t i = 0; i <
size(); i++)
464 new_array[
size()] = a;
485 throw exception (
"Array has no element to pop!");
495 template <
class InputIterator>
void append (
496 InputIterator first, InputIterator last
499 for (
size_t i = 0; i <
size(); i++)
500 new_array[i] = (*
this)[i];
501 for (InputIterator it = first; it != last; it++)
502 new_array[
size() + it - first] = *it;
524 for (
int i = 0; i < it -
begin(); i++)
525 new_array[i] = std::move((*
this)[i]);
528 *(new_array + (it -
begin())) = std::move(x);
531 for (
int i = it -
begin(); i < (int)
size(); i++)
532 new_array[i+1] = std::move((*
this)[i]);
561 if (
data() ==
nullptr)
565 for (
size_t i = 0; i <
size(); i++)
575 if (
data() !=
nullptr)
652 template <
typename ForwardIterator>
NumberArray (ForwardIterator i, ForwardIterator j)
661 std::swap(
Nres_,a.Nres_);
662 std::swap(
name_, a.name_);
696 for (
size_t i = 0; i < n; i++)
697 new_array[i] = (i <
size()) ? (*this)[i] : T(0);
724 memcpy (new_array,
data(),
size() *
sizeof(T));
761 virtual T
const *
data ()
const
795 for (
size_t i =
size(); i > 0; i--)
796 (*
this)[i] = (*this)[i-1];
813 memcpy(new_array + 1,
data(),
size() *
sizeof(T));
816 if (
data() !=
nullptr)
844 memcpy(new_array,
data(),
size() *
sizeof(T));
847 if (
data() !=
nullptr)
876 template <
class InputIterator>
void append
878 InputIterator first, InputIterator last
884 Nres_ += last - first;
890 memcpy(new_array,
data(),
size() *
sizeof(T));
893 if (
data() !=
nullptr)
901 for (InputIterator it = first; it != last; it++)
945 for (
size_t i = 0; i <
size(); i++)
955 std::swap(
Nres_, b.Nres_);
963 for (
size_t i = 0; i <
size(); i++)
966 c[i] =
Complex(z.real(), -z.imag());
975 for (
size_t i = 0; i <
size(); i++)
978 ret += z.real() * z.real() + z.imag() * z.imag();
995 for (
size_t i = 0; i < n; i++)
996 c[i] = f((*
this)[i]);
1004 assert (right >= left);
1019 unsigned char const * dataptr =
reinterpret_cast<unsigned char const*
>(
data());
1022 size_t count =
size() *
sizeof(T);
1025 std::ostringstream hexa;
1026 hexa <<
"x'" << std::hex << std::setfill(
'0');
1029 for (
size_t i = 0; i < count; i++)
1030 hexa << std::setw(2) <<
static_cast<unsigned>(dataptr[i]);
1045 if (
data() !=
nullptr and
size() != 0)
1051 if ((s[0] !=
'x' and s[0] !=
'X') or s[1] !=
'\'' or s.back() !=
'\'')
1052 throw exception (
"[NumberArray::fromBlob] Blob has wrong format, %s.", s.c_str());
1055 std::string ss (s.begin() + 2, s.end() - 1);
1058 size_t bytes = ss.size() / 2;
1065 for (
size_t i = 0; i < bytes; i++)
1068 std::stringstream sst;
1071 sst << std::hex << ss.substr(2*i, 2);
1077 reinterpret_cast<char*
>(
data())[i] = byte;
1108 bool hdfsave (std::string name,
bool docompress =
false,
int consec = 10)
const
1112 HDFFile hdf(name, HDFFile::overwrite);
1114 if (not hdf.valid())
1121 std::tie(zero_blocks,elements) =
compress(consec);
1123 if (not zero_blocks.
empty())
1131 if (not elements.
empty())
1142 if (not hdf.write(
"array",
data(),
size()))
1168 HDFFile hdf(name, HDFFile::readonly);
1170 if (not hdf.valid())
1177 if (zero_blocks.
resize(hdf.size(
"zero_blocks")))
1178 if (not hdf.read(
"zero_blocks", &(zero_blocks[0]), zero_blocks.
size()))
1182 size_t size = hdf.size(
"array");
1185 if (
typeid(T) ==
typeid(
Complex))
1189 if (elements.
resize(size))
1191 if (not hdf.read(
"array", &(elements[0]), elements.
size()))
1196 if (
data() !=
nullptr)
1236 int zero_counter = 0;
1239 for (
size_t i = 0; i <
size(); i++)
1241 if ((*
this)[i] == 0.)
1246 else if (zero_counter >= consec)
1260 if (zero_counter >= 10)
1273 for (
size_t iblock = 0; iblock < nonzero_blocks.
size()/2; iblock++)
1275 int start = nonzero_blocks[2*iblock];
1276 int end = nonzero_blocks[2*iblock+1];
1283 return std::make_tuple(zero_blocks,carray);
1298 if (zero_blocks.
empty())
1302 size_t final_size =
size();
1303 for (
size_t i = 0; i < zero_blocks.
size()/2; i++)
1304 final_size += zero_blocks[2*i+1] - zero_blocks[2*i];
1308 memset(&(unpack[0]), 0, final_size *
sizeof(T));
1313 for (
size_t i = 0; i < zero_blocks.
size()/2; i++)
1315 int zero_start = zero_blocks[2*i];
1316 int zero_end = zero_blocks[2*i+1];
1320 &(unpack[0]) + this_end,
1322 (zero_start - this_end) *
sizeof(T)
1326 load_end += zero_start - this_end;
1327 this_end = zero_end;
1332 &(unpack[0]) + this_end,
1334 (final_size - this_end) *
sizeof(T)
1348 size_t N = a.
size();
1349 assert(N == b.
size());
1359 for (
size_t i = 0; i < N; i++)
1360 result += pa[i] * pb[i];
1380 auto ic = c.
begin();
1390 template <
typename T> std::ostream & operator << (std::ostream & out, ArrayView<T>
const & a)
1393 for (
size_t i = 0; i < a.size(); i++)
1437 for (
unsigned i = 0; i < samples; i++)
1439 space[i] = start + ((end - start) * T(i)) / T(samples - 1);
1464 if (x0 <= 0 or x1 <= 0 or x1 < x0)
1465 throw exception (
"[logspace] It must be 0 < x1 <= x2 !");
1480 for (
unsigned i = 0; i < samples; i++)
1482 grid[i] = x0 *
pow(x1 / x0, i / T(samples - 1));
1520 for (
unsigned i = 0; i < samples; i++)
1522 grid[i] = x0 + (x1 - x0) * (1. -
std::pow(q,i)) / (1. -
std::pow(q,samples));
1537 const char* filename
1551 const char* filename
1560 template <
typename Fetcher>
bool write_1D_data (
size_t m,
const char* filename, Fetcher fetch)
1562 std::ofstream f(filename);
1567 for (
size_t i = 0; i < m; i++)
1568 f << fetch(i) <<
"\n";
1586 template <
class Fetcher>
bool write_2D_data (
size_t m,
size_t n,
const char* filename, Fetcher fetch)
1588 std::ofstream f(filename);
1593 for (
size_t i = 0; i < m; i++)
1595 for (
size_t j = 0; j < n; j++)
1596 f << fetch(i,j) <<
" ";
1640 template <
typename ...Params> rArray
concatenate (rArray
const & v1, Params ...p)
1642 if (
sizeof...(p) == 0)
1650 for (
size_t i = 0; i < v1.
size(); i++)
1652 for (
size_t i = 0; i < v2.
size(); i++)
1653 v[i + v1.
size()] = v2[i];
1659 rArray
abs (
const cArrayView u);
1660 rArrays
abs (cArrays
const &u);
1666 for (T
const * it = a.
begin(); it != a.
end(); it++)
1676 for (T
const * it = a.
begin(); it != a.
end(); it++)
1687 auto iu = u.
begin();
1688 auto iv = v.begin();
1690 while (iu != u.
end())
1701 auto iu = u.
begin();
1702 auto iv = v.begin();
1704 while (iu != u.
end())
1713 size_t N = A.
size();
1716 for (
size_t i = 0; i < N; i++)
1725 size_t N = A.
size();
1728 for (
size_t i = 0; i < N; i++)
1737 size_t N = A.
size();
1740 for (
size_t i = 0; i < N; i++)
1749 size_t N = A.
size();
1752 for (
size_t i = 0; i < N; i++)
1772 return std::accumulate(v.
begin(), v.
end(), T(0));
1781 return std::accumulate (
1797 template <
typename T>
1801 for (
size_t i = 0; i < u.
size(); i++)
1807 template <
typename T>
1813 for (
size_t i = 0; i < u.
size(); i++)
1814 w[i] = (u[i] == v[i]);
1843 template <
typename TFunctor,
typename TArray>
1844 void eval (TFunctor f, TArray grid, TArray& vals)
1846 size_t N = grid.size();
1847 assert(N == vals.size());
1849 for (
size_t i = 0; i < N; i++)
1850 vals[i] = f(grid[i]);
1863 template <
typename T
idx,
typename Tval>
void merge (
1876 while (i1 < arr1.
size() and i2 < arr2.
size())
1878 if (idx1[i1] == idx2[i2])
1885 else if (idx1[i1] < idx2[i2])
1900 if (i1 == arr1.
size() and i2 < arr2.
size())
1917 partial_sizes[0] = 0;
1918 for (
size_t i = 0; i < arrays.size(); i++)
1919 partial_sizes[i+1] = partial_sizes[i] + arrays[i].
size();
1925 for (
size_t i = 0; i < arrays.size(); i++)
1927 if (arrays[i].
size() > 0)
1942 T
const * iv = v.
begin();
1946 while (iv != v.
end())
1951 if (iw == w.
begin() or *(iw - 1) != *iv)
1963 w.resize(iw - w.
begin());
1979 T prev = v[0], newv;
1980 for (
int i = 1; i < v.
size(); i++)
1982 newv = 0.5 * (prev + v[i]);
1991 std::ostringstream ss;
1992 for (
size_t i = 0; i < v.
size(); i++)
2003 rArray
threshold (
const rArrayView a,
double eps);
auto outer_product(const ArrayView< T1 > a, const ArrayView< T2 > b) -> NumberArray< decltype(T1(0)*T2(0))>
Outer product of two arrays.
Definition: arrays.h:1373
virtual T * data()
Data pointer.
Definition: arrays.h:757
Array view.
Definition: arrays.h:186
virtual void push_front(T const &a)
Add element to beginning.
Definition: arrays.h:789
NumberArray()
Definition: arrays.h:624
virtual ~ArrayView()
Definition: arrays.h:234
Array(const ArrayView< T > a)
Definition: arrays.h:354
bool hdfsave(std::string name, bool docompress=false, int consec=10) const
Save array to HDF file.
Definition: arrays.h:1108
NumberArray< double > sqrabs(NumberArray< Complex > const &A)
Return per-element square of absolute value.
Definition: arrays.cpp:71
bool empty() const
Check that size equals to zero.
Definition: arrays.h:906
NumberArray(ArrayView< T > const &a)
Definition: arrays.h:636
NumberArray(std::vector< T > const &a)
Definition: arrays.h:644
T & back(int i=0)
Definition: arrays.h:447
Basic memory allocator.
Definition: arrays.h:43
Array(ForwardIterator i, ForwardIterator j)
Definition: arrays.h:370
void fill(T x)
Fill the array with a value.
Definition: arrays.h:298
bool all(const ArrayView< bool > B)
Check that all values are "true".
Definition: arrays.h:1819
T const * const_iterator
Definition: arrays.h:611
rArray threshold(const rArrayView a, double eps)
Drop small elements of array (replace by zero).
Definition: arrays.cpp:136
T const * const_iterator
Definition: arrays.h:193
T const & front(int i=0) const
Definition: arrays.h:446
const_iterator cbegin() const
Definition: arrays.h:773
T & back(int i=0)
Definition: arrays.h:294
void merge(NumberArray< Tidx > &idx1, NumberArray< Tval > &arr1, NumberArray< Tidx > const &idx2, NumberArray< Tval > const &arr2)
Definition: arrays.h:1863
T * iterator
Definition: arrays.h:610
bool empty() const
Check that size equals to zero.
Definition: arrays.h:541
T & front(int i=0)
Definition: arrays.h:777
T pop_back()
Remove the last element.
Definition: arrays.h:864
const_iterator begin() const
Definition: arrays.h:289
NumberArray< T > sorted_unique(const ArrayView< T > v, int n=1)
Drop all redundant repetitions from sorted array.
Definition: arrays.h:1935
~Array()
Definition: arrays.h:379
std::string to_string(const ArrayView< T > v, char sep= ' ')
Convert ArrayView<T> to a string.
Definition: arrays.h:1989
NumberArray< T > cos(NumberArray< T > const &A)
Return per-element cosine.
Definition: arrays.h:1747
virtual size_t resize(size_t n)
Resize array.
Definition: arrays.h:685
NumberArray< double > atan2(NumberArray< double > const &A, NumberArray< double > const &B)
Return per-element atan2.
Definition: arrays.cpp:58
NumberArray< Complex > cArray
Definition: arrays.h:1610
T & front(int i=0)
Definition: arrays.h:445
A comfortable number array class.
Definition: arrays.h:171
T min(const ArrayView< T > a)
Minimal element of array.
Definition: arrays.h:1663
T DataType
Definition: arrays.h:609
NumberArray< T > & operator=(NumberArray< T > const &b)
Definition: arrays.h:929
virtual void push_back(T const &a)
Append an element to the end.
Definition: arrays.h:459
const_iterator begin() const
Definition: arrays.h:772
NumberArray< double > hypot(NumberArray< double > const &A, NumberArray< double > const &B)
Return per-element hypot.
Definition: arrays.cpp:45
NumberArray(NumberArray< T > const &a)
Definition: arrays.h:640
int size
Definition: misc.h:311
#define restrict
Definition: misc.h:88
Array< rArray > rArrays
Definition: arrays.h:1619
std::tuple< NumberArray< int >, NumberArray< T > > compress(int consec) const
Get compressed array.
Definition: arrays.h:1226
virtual T const * data() const
Definition: arrays.h:281
NumberArray< double > imagpart(NumberArray< Complex > const &A)
Return per-element imag part.
Definition: arrays.cpp:93
Array< T > & operator=(Array< T > const &b)
Definition: arrays.h:547
const_iterator end() const
Definition: arrays.h:775
constexpr T const & larger_of(T const &a, T const &b)
Constant-expression max.
Definition: misc.h:218
T operator|(const ArrayView< T > a, const ArrayView< T > b)
Scalar product of two arrays.
Definition: arrays.h:1345
NumberArray(size_t n, T const *x)
Definition: arrays.h:632
T const * const_iterator
Definition: arrays.h:333
void smoothen(ArrayView< T > v)
Running average.
Definition: arrays.h:1974
double norm() const
Compute usual 2-norm.
Definition: arrays.h:972
T * array_
Pointer to the array.
Definition: arrays.h:201
bool any(const ArrayView< bool > B)
Check if any value is "true".
Definition: arrays.h:1828
T & back(int i=0)
Definition: arrays.h:779
NumberArray< T > conj() const
Return complex conjugated array.
Definition: arrays.h:960
iterator begin()
Definition: arrays.h:288
const double e
Definition: special.h:44
Array(std::vector< T > const &a)
Definition: arrays.h:362
T const & front(int i=0) const
Definition: arrays.h:293
iterator end()
Definition: arrays.h:774
void eval(TFunctor f, TArray grid, TArray &vals)
Definition: arrays.h:1844
ArrayView< double > rArrayView
Definition: arrays.h:1614
NumberArray< T > decompress(NumberArray< int > const &zero_blocks) const
Decompress array.
Definition: arrays.h:1296
NumberArray< T > join(const ArrayView< NumberArray< T >> arrays)
Join elements from all subarrays.
Definition: arrays.h:1912
void append(InputIterator first, InputIterator last)
Append more items.
Definition: arrays.h:495
size_t Nres_
Allocated memory.
Definition: arrays.h:616
ArrayView(Array< T > const &a, size_t i=0, size_t n=0)
Definition: arrays.h:218
T & operator[](size_t i)
Element-wise access (non-const).
Definition: arrays.h:735
T * iterator
Definition: arrays.h:192
NumberArray< T > linspace(T start, T end, unsigned samples)
Generate uniform grid.
Definition: arrays.h:1422
ArrayView(size_t n, T *ptr)
Definition: arrays.h:210
bool empty() const
Check whether the size is equal to zero.
Definition: arrays.h:301
T DataType
Definition: arrays.h:191
Array< lArray > lArrays
Definition: arrays.h:1618
double norm() const
Two-norm (defined only for scalar data type).
Definition: arrays.h:304
NumberArray< T > sums(const ArrayView< NumberArray< T >> v)
Sum arrays.
Definition: arrays.h:1776
rArray concatenate()
Definition: arrays.h:1626
Array(Array< T > &&a)
Definition: arrays.h:358
Array(size_t n, T const *const x)
Definition: arrays.h:346
Array< iArray > iArrays
Definition: arrays.h:1617
T & operator[](size_t i)
Element-wise access (non-const).
Definition: arrays.h:249
void link(std::string name)
Link to HDF file.
Definition: arrays.h:1088
NumberArray< double > realpart(NumberArray< Complex > const &A)
Return per-element real part.
Definition: arrays.cpp:82
void insert(iterator it, T x)
Insert item.
Definition: arrays.h:518
ArrayView(ArrayView< T > const &a, size_t i=0, size_t n=0)
Definition: arrays.h:214
const_iterator begin() const
Definition: arrays.h:442
auto transform(Functor f) const -> NumberArray< decltype(f(T(0)))>
Apply a user transformation.
Definition: arrays.h:990
size_t size() const
Length of the array (number of elements).
Definition: arrays.h:276
T & front(int i=0)
Definition: arrays.h:292
T * iterator
Definition: arrays.h:332
class NodeIntegrator exception
const_iterator cend() const
Definition: arrays.h:776
T sum(const ArrayView< T > v)
Sum elements in array.
Definition: arrays.h:1770
std::string name_
HDF file to store to / load from.
Definition: arrays.h:619
iterator begin()
Definition: arrays.h:771
static T * alloc(size_t n)
Allocate array.
Definition: arrays.h:54
ArrayView< Complex > cArrayView
Definition: arrays.h:1615
T const & front(int i=0) const
Definition: arrays.h:778
iterator end()
Definition: arrays.h:443
NumberArray< long > lArray
Definition: arrays.h:1608
NumberArray< T > sin(NumberArray< T > const &A)
Return per-element sine.
Definition: arrays.h:1723
NumberArray(NumberArray< T > &&a)
Definition: arrays.h:656
size_t size() const
Return number of elements.
Definition: arrays.h:389
size_t N_
Number of elements in the array.
Definition: arrays.h:198
ArrayView(ArrayView< T > &&r)
Definition: arrays.h:230
size_t reserve(size_t n)
Reserve memory.
Definition: arrays.h:715
ArrayView< int > iArrayView
Definition: arrays.h:1612
bool hdfload()
Definition: arrays.h:1211
ArrayView(NumberArray< T > const &a, size_t i=0, size_t n=0)
Definition: arrays.h:222
bool hdfsave() const
Definition: arrays.h:1151
NumberArray< T > pow(NumberArray< T > const &u, double e)
Return per-element power.
Definition: arrays.h:1683
void append(InputIterator first, InputIterator last)
Append a range of values at end.
Definition: arrays.h:877
A comfortable data array class.
Definition: arrays.h:151
virtual T * data()
Data pointer.
Definition: arrays.h:433
static void free(T *ptr)
Free array.
Definition: arrays.h:68
ArrayView(const_iterator i, const_iterator j)
Definition: arrays.h:226
NumberArray< T > asin(NumberArray< T > const &A)
Return per-element arcsine.
Definition: arrays.h:1735
Alloc::alloc(n))
Definition: arrays.h:343
virtual size_t resize(size_t n)
Resize array.
Definition: arrays.h:400
NumberArray< double > rArray
Definition: arrays.h:1609
Array(std::initializer_list< T > a)
Definition: arrays.h:366
ArrayView()
Definition: arrays.h:206
name_()
Definition: arrays.h:629
virtual T * data()
Pointer to the data.
Definition: arrays.h:280
T DataType
Definition: arrays.h:331
virtual T pop_back()
Remove the last element from the array.
Definition: arrays.h:480
const_iterator end() const
Definition: arrays.h:291
Exception class.
Definition: misc.h:39
T const & back(int i=0) const
Definition: arrays.h:295
T const & back(int i=0) const
Definition: arrays.h:448
NumberArray< T > geomspace(T x0, T x1, size_t samples, double q)
Generate geometric grid.
Definition: arrays.h:1505
void fromBlob(std::string const &s)
Convert from SQL BLOB.
Definition: arrays.h:1043
ArrayView< long > lArrayView
Definition: arrays.h:1613
virtual T const * data() const
Definition: arrays.h:434
bool hdfload(std::string name)
Load array from HDF file.
Definition: arrays.h:1164
T const & back(int i=0) const
Definition: arrays.h:780
NumberArray(std::initializer_list< T > a)
Definition: arrays.h:648
T & operator[](size_t i)
Element-wise access (non-const).
Definition: arrays.h:426
ArrayView< T > slice(size_t left, size_t right) const
Return a subarray using ArrayView.
Definition: arrays.h:1002
NumberArray< T > sqrt(NumberArray< T > const &A)
Return per-element square root.
Definition: arrays.h:1711
virtual void push_back(T const &a)
Add element to end.
Definition: arrays.h:833
Array(Array< T > const &a)
Definition: arrays.h:350
rArray abs(const cArrayView u)
Definition: arrays.cpp:19
std::complex< double > Complex
Definition: complex.h:20
iterator end()
Definition: arrays.h:290
NumberArray(ForwardIterator i, ForwardIterator j)
Definition: arrays.h:652
bool write_2D_data(size_t m, size_t n, const char *filename, Fetcher fetch)
Definition: arrays.h:1586
Array()
Definition: arrays.h:338
T max(const ArrayView< T > a)
Maximal element of array.
Definition: arrays.h:1673
~NumberArray()
Definition: arrays.h:666
ArrayView< T > & operator=(const ArrayView< T > v)
Assignment operator.
Definition: arrays.h:237
virtual T const * data() const
Definition: arrays.h:761
std::string toBlob() const
Convert to SQL BLOB.
Definition: arrays.h:1016
const_iterator end() const
Definition: arrays.h:444
void write_array(const ArrayView< double > array, const char *filename)
Definition: arrays.cpp:104
bool write_1D_data(size_t m, const char *filename, Fetcher fetch)
Write elements.
Definition: arrays.h:1560
void drop()
Reset array: deallocate everything, resize to zero.
Definition: arrays.h:918
Array< cArray > cArrays
Definition: arrays.h:1620
Array< bool > operator==(const ArrayView< T > u, T x)
Definition: arrays.h:1798
size_t size() const
Item count.
Definition: arrays.h:673
iterator begin()
Definition: arrays.h:441
void clear()
Fill array with zeros.
Definition: arrays.h:912
NumberArray< T > logspace(T x0, T x1, size_t samples)
Generate logarithmic grid.
Definition: arrays.h:1462
NumberArray< int > iArray
Definition: arrays.h:1607