Template Class Array#
Defined in File array.hpp
Inheritance Relationships#
Derived Type#
public pele::MatrixAdapter< dtype >(Template Class MatrixAdapter)
Class Documentation#
-
template<typename dtype>
class Array# An Array class which acts in many ways like a numpy array.
This copy constructor and assignment operator act to wrap existing memory rather than copy the memory.
Subclassed by pele::MatrixAdapter< dtype >
Public Types
Public Functions
-
inline Array()#
create an array of size 0
-
inline Array(size_t size)#
construct an array with a given size
-
inline Array(size_t size, dtype const &val)#
construct an array with a given size, each element is a copy of val
-
inline Array(dtype *data, size_t size)#
wrap some data that is passed.
Do not take ownership of the data.
-
inline Array(dtype *data_begin, dtype *data_end)#
wrap the data between iterators.
This memory should never be deleted.
-
inline Array(std::vector<dtype> &x)#
wrap the data in a vector.
This memory should never be deleted.
-
inline void wrap(Array<dtype> x)#
wrap another array is implemented by shared_ptr parent class
Note, the input here is a const array, but this constructs a modifiable array. This is a loophole around the const declaration, but i’m not sure there is any way around it. The compiler complains if this is not here. e.g. for constructions like Array(x.copy())
This is commented because it just duplicates the default copy constructor
Array(Array<dtype> const & x) : _memory(x._memory) _data(x._data), _size(x._size) {} wrap another array
-
inline size_t size() const#
return the size of the array
-
inline const_iterator begin() const#
-
inline const_iterator end() const#
-
inline bool operator==(Array<dtype> const rhs) const#
return true if the two arrays wrap the same data
-
inline Array<dtype> &assign(const Array<dtype> &rhs)#
Assignment function: copy the data into the existing array.
arrays must be of same size
-
inline void free()#
wrap a new empty array.
-
inline bool empty() const#
Returns whether the array is empty (whether its size is 0).
-
inline long int reference_count() const#
-
inline dtype prod() const#
returns the product of all elements (reduces the array)
References: http://www.cplusplus.com/reference/functional/multiplies/ http://en.cppreference.com/w/cpp/algorithm/accumulate http://rosettacode.org/wiki/Sum_and_product_of_an_array
-
inline Array()#