- 
                Notifications
    
You must be signed in to change notification settings  - Fork 5
 
Vector
        Philipp Gschwandtner edited this page Jun 6, 2017 
        ·
        3 revisions
      
    Defined in header "allscale/utils/vector.h"
template<typename T, std::size_t Dims>
class Vector;The Vector container represents an array of elements. It is most notably used as the coordinate_type of data structures such as Grid and StaticGrid. Special overloads are provided for one-, two-, and three-dimensional vectors that provide named members for their elements (x for Vector<1>, x and y for Vector<2>, and x, y, and z for Vector<3>).
| Member type | Definition | 
|---|---|
element_type | 
The type of elements contained in this vector | 
| Member function | Description | 
|---|---|
Vector() | 
Default-constructs a Vector
 | 
Vector(const T& e) | 
Constructs a Vector, initializing all elements with e
 | 
Vector(const Vector&) | 
Copy constructor | 
Vector(Vector&&) | 
Move constructor | 
template<typename R>Vector(const Vector<R,Dims>& other)
 | 
Constructor taking a Vector of elements of type R that can be converted to element_type
 | 
template<typename R>Vector(const std::array<R,Dims>& other)
 | 
Constructor taking a std::array of elements of type R that can be converted to element_type
 | 
template<typename R>Vector(const std::initializer_list<R>& values)
 | 
Constructor taking a std::initializer_list of elements of type R that can be converted to element_type
 | 
T& operator[](const std::size_t index) | 
Mutable read/write access operator | 
const T& operator[](const std::size_t index) const | 
Immutable read/write access operator | 
bool dominatedBy(const Vector<T,Dims>& other) const | 
Returns true if each element of other is greater or equal to the corresponding element of this Vector
 | 
bool strictlyDominatedBy(const Vector<T,Dims>& other) const | 
Returns true if each element of other is greater to the corresponding element of this Vector
 | 
friend std::ostream& operator<<(std::ostream& out, const Vector& vec) | 
Enables this vector to be printed | 
| Function | Description | 
|---|---|
template<typename T, std::size_t Dims, typename S>Vector<T,Dims>& operator+=(Vector<T,Dims>& a, const Vector<S,Dims>& b)
 | 
Element-wise compound addition-assignment | 
template<typename T, std::size_t Dims, typename S>Vector<T,Dims>& operator-=(Vector<T,Dims>& a, const Vector<S,Dims>& b)
 | 
Element-wise compound subtraction-assignment | 
template<typename T, std::size_t Dims, typename S>Vector<T,Dims>& operator*=(Vector<T,Dims>& a, const S& fac)
 | 
Element-wise compound multiplication-assignment | 
template<typename T, std::size_t Dims, typename S>Vector<T,Dims>& operator/=(Vector<T,Dims>& a, const S& fac)
 | 
Element-wise compound division-assignment | 
template<typename T, std::size_t Dims>Vector<T,Dims> operator+(const Vector<T,Dims>& a, const Vector<T,Dims>& b)
 | 
Element-wise addition operator taking two Vector objects | 
template<typename T, std::size_t Dims>Vector<T,Dims> operator-(const Vector<T, Dims>& a, const Vector<T, Dims>& b)
 | 
Element-wise subtraction operator taking two Vector objects | 
template<typename T, std::size_t Dims, typename S>Vector<T,Dims> operator*(const Vector<T, Dims>& vec, const S& fac)
 | 
Element-wise multiplication operator taking a Vector and a factor | 
template<typename T, std::size_t Dims, typename S>Vector<T, Dims> operator*(const S& fac, const Vector<T, Dims>& vec)
 | 
Element-wise multiplication operator taking a factor and a Vector
 | 
template<typename T, std::size_t Dims, typename S>Vector<T,Dims> operator/(const Vector<T, Dims>& vec, const S& fac)
 | 
Element-wise divison operator taking a Vector and a divisor | 
template<typename T, std::size_t Dims, typename Lambda>Vector<T,Dims> elementwise(const Vector<T,Dims>& a, const Vector<T,Dims>& b, const Lambda& op)
 | 
Combines two vectors element-wise using a user-defined function | 
template<typename T, std::size_t Dims>Vector<T,Dims> elementwiseMin(const Vector<T,Dims>& a, const Vector<T,Dims>& b)
 | 
Computes the element-wise minimum of two Vector objects | 
template<typename T, std::size_t Dims>Vector<T,Dims> elementwiseMax(const Vector<T,Dims>& a, const Vector<T,Dims>& b)
 | 
Computes the element-wise maximum of two Vector objects | 
template<typename T, std::size_t Dims>T sumOfSquares(const Vector<T,Dims>& vec)
 | 
Computes the sum of the squares of all elements of this Vector
 | 
template<typename T, std::size_t Dims>Vector<T,Dims> elementwiseProduct(const Vector<T,Dims>& a, const Vector<T,Dims>& b)
 | 
Computes the element-wise product of two Vector objects | 
template<typename T, std::size_t Dims>Vector<T,Dims> elementwiseDivision(const Vector<T,Dims>& a, const Vector<T,Dims>& b)
 | 
Computes the element-wise division of two Vector objects | 
template<typename T, std::size_t Dims>Vector<T,Dims> elementwiseRemainder(const Vector<T,Dims>& a, const Vector<T,Dims>& b)
 | 
Computes the element-wise remainder of two Vector objects | 
template<typename T, std::size_t Dims>Vector<T,Dims> elementwiseModulo(const Vector<T,Dims>& a, const Vector<T,Dims>& b)
 | 
Computes the element-wise remainder of two Vector objects | 
#include "allscale/utils/vector.h"
using allscale::utils;
// Create and initialize a two-dimensional Vector of doubles
Vector<double, 2> vector = { 1.0, 2.0 };
// Re-assign different values using named member access
vector.x = 2.0;
vector.y = 3.0;
// Create a second vector, initialize both elements with the value 10
Vector<doube, 2> anotherVector(10.0);
// Re-assign different values using access operator
anotherVector[0] = 11.0;
anotherVector[1] = 20.0;
// compute element-wise sum
auto result = vector + anotherVector;Part of the AllScale project - http://www.allscale.eu