HILA
|
\( n\times m \) Array type More...
#include <array.h>
Public Member Functions | |
Array ()=default | |
Default constructor. | |
Array (const Array< n, m, T > &v)=default | |
Copy constructor. | |
template<typename S , std::enable_if_t< hila::is_assignable< T &, S >::value, int > = 0> | |
Array (const S rhs) | |
Scalar constructor. | |
template<typename S , std::enable_if_t< hila::is_assignable< T &, S >::value, int > = 0> | |
Array (std::initializer_list< S > rhs) | |
Initializer list constructor. | |
Matrix< n, m, T > & | asMatrix () |
Cast Array to Matrix. | |
Vector< n, T > & | asVector () |
Cast Array1D to Vector. | |
constexpr int | columns () const |
Returns number of columns. | |
Array< n, m, T > | conj () const |
Returns element wise Complex conjugate of Array. | |
template<int q = n, int p = m, std::enable_if_t<(q==1||p==1), int > = 0> | |
T & | e (const int i) |
Standard array indexing operation for 1D Array. | |
template<int q = n, int p = m, std::enable_if_t<(q==1||p==1), int > = 0> | |
T | e (const int i) const |
Const overload. | |
T & | e (const int i, const int j) |
Const overload. | |
T | e (const int i, const int j) const |
Standard array indexing operation for 2D Array. | |
Array< n, m, T > & | gaussian_random (double width=1.0) |
Fill Array with Gaussian random elements. | |
Array< n, m, hila::arithmetic_type< T > > | imag () const |
return imaginary part | |
template<typename S , int n1, int m1> | |
bool | operator!= (const Array< n1, m1, S > &rhs) const |
Compare non-equality of two Arrays. | |
template<int n, int m, typename T > | |
Array< n, m, T > | operator* (Array< n, m, T > a, const Array< n, m, T > &b) |
Multiplication operator. | |
template<typename S , std::enable_if_t< std::is_convertible< hila::type_mul< T, S >, T >::value, int > = 0> | |
Array< n, m, T > & | operator*= (const Array< n, m, S > &rhs) & |
Multiply assign scalar or array. | |
template<typename S , std::enable_if_t< std::is_convertible< hila::type_mul< T, S >, T >::value, int > = 0> | |
Array< n, m, T > & | operator*= (const S rhs) & |
multiply assign with scalar | |
Array< n, m, T > | operator+ () const |
Unary + operator. | |
template<int n, int m, typename A , typename B > | |
auto | operator+ (const Array< n, m, A > &a, const Array< n, m, B > &b) |
Addition operator. | |
template<typename S , std::enable_if_t< std::is_convertible< S, T >::value, int > = 0> | |
Array< n, m, T > & | operator+= (const Array< n, m, S > &rhs) & |
Add assign operator with Array or scalar. | |
Array< n, m, T > | operator- () const |
Unary - operator. | |
template<int n, int m, typename A , typename B > | |
auto | operator- (const Array< n, m, A > &a, const Array< n, m, B > &b) |
Subtraction operator. | |
template<typename S , std::enable_if_t< std::is_convertible< S, T >::value, int > = 0> | |
Array< n, m, T > & | operator-= (const Array< n, m, S > &rhs) & |
Subtract assign operator with Array or scalar. | |
template<int n, int m, typename A , typename B > | |
auto | operator/ (const Array< n, m, A > &a, const Array< n, m, B > &b) |
Division operator. | |
template<typename S , std::enable_if_t< std::is_convertible< hila::type_div< T, S >, T >::value, int > = 0> | |
Array< n, m, T > & | operator/= (const Array< n, m, S > &rhs) & |
Division assign with array or scalar. | |
template<typename S , std::enable_if_t< hila::is_assignable< T &, S >::value, int > = 0> | |
Array< n, m, T > & | operator= (const S rhs) & |
Scalar assignment operator. | |
template<typename S , int n1, int m1> | |
bool | operator== (const Array< n1, m1, S > &rhs) const |
Compare equality of Arrays. | |
Array< n, m, T > & | random () |
Fill Array with random elements. | |
Array< n, m, hila::arithmetic_type< T > > | real () const |
Returns real part of Array. | |
constexpr int | rows () const |
Returns number of rows. | |
template<int q = n, int p = m, std::enable_if_t< q==1, int > = 0> | |
constexpr int | size () const |
Returns size of Vector Array or square Array. | |
template<int N> | |
Array< n, m, T > | sort (Vector< N, int > &permutation, hila::sort order=hila::sort::ascending) const |
implement sort as casting to array | |
hila::arithmetic_type< T > | squarenorm () const |
calculate square norm - sum of squared elements | |
std::string | str (int prec=8, char separator=' ') const |
Convert to string for printing. | |
Related Symbols | |
(Note that these are not member symbols.) | |
Arithmetic operations | |
template<int n, int m, typename T > | |
Array< n, m, T > | sqrt (Array< n, m, T > a) |
Square root. | |
template<int n, int m, typename T > | |
Array< n, m, T > | cbrt (Array< n, m, T > a) |
Cuberoot. | |
template<int n, int m, typename T > | |
Array< n, m, T > | exp (Array< n, m, T > a) |
Exponential. | |
template<int n, int m, typename T > | |
Array< n, m, T > | log (Array< n, m, T > a) |
Logarithm. | |
template<int n, int m, typename T > | |
Array< n, m, T > | sin (Array< n, m, T > a) |
Sine. | |
template<int n, int m, typename T > | |
Array< n, m, T > | cos (Array< n, m, T > a) |
Cosine. | |
template<int n, int m, typename T > | |
Array< n, m, T > | tan (Array< n, m, T > a) |
Tangent. | |
template<int n, int m, typename T > | |
Array< n, m, T > | asin (Array< n, m, T > a) |
Inverse Sine. | |
template<int n, int m, typename T > | |
Array< n, m, T > | acos (Array< n, m, T > a) |
Inverse Cosine. | |
template<int n, int m, typename T > | |
Array< n, m, T > | atan (Array< n, m, T > a) |
Inverse Tangent. | |
template<int n, int m, typename T > | |
Array< n, m, T > | sinh (Array< n, m, T > a) |
Hyperbolic Sine. | |
template<int n, int m, typename T > | |
Array< n, m, T > | cosh (Array< n, m, T > a) |
Hyperbolic Cosine. | |
template<int n, int m, typename T > | |
Array< n, m, T > | tanh (Array< n, m, T > a) |
Hyperbolic tangent. | |
template<int n, int m, typename T > | |
Array< n, m, T > | asinh (Array< n, m, T > a) |
Inverse Hyperbolic Sine. | |
template<int n, int m, typename T > | |
Array< n, m, T > | acosh (Array< n, m, T > a) |
Inverse Hyperbolic Cosine. | |
template<int n, int m, typename T > | |
Array< n, m, T > | atanh (Array< n, m, T > a) |
Inverse Hyperbolic Tangent. | |
template<int n, int m, typename T > | |
Array< n, m, T > | pow (Array< n, m, T > a, int b) |
Power. | |
template<int n, int m, typename T , std::enable_if_t< hila::is_arithmetic< T >::value, int > = 0> | |
Array< n, m, T > | round (Array< n, m, T > a) |
Rounding. | |
template<int n, int m, typename T , std::enable_if_t< hila::is_arithmetic< T >::value, int > = 0> | |
Array< n, m, T > | floor (Array< n, m, T > a) |
Floor. | |
template<int n, int m, typename T , std::enable_if_t< hila::is_arithmetic< T >::value, int > = 0> | |
Array< n, m, T > | ceil (Array< n, m, T > a) |
Ceiling. | |
template<int n, int m, typename T , std::enable_if_t< hila::is_arithmetic< T >::value, int > = 0> | |
Array< n, m, T > | trunc (Array< n, m, T > a) |
Truncation. | |
\( n\times m \) Array type
Acts as array class which stores data in a simple C style array.
Main functionality which the Array class offers is to supplement the fall backs of storing information in a Matrix data structure.
For example assigning a value to each element with the Matrix class is not directly possible using the assignment operator=. This is because assignment with matrices is defined as \( M = a = a*I \) where M is a general matrix, a is a scalar and I an identity matrix. The result would only assign a to the diagonal elements.
Unlike the Matrix object, the Array object assigns element wise. This allows filling the Array with the assignment operator. Additionally element wise operations are useable as long as they are defined for the Array type. For example the operation:
is defined, since the \(sin\) function is defined for doubles.
The above operation would not work for matrices, but with casting operations. Matrix::asArray and Array::asMatrix one can take full advantage of element wise operations.
n | Number of rows |
m | Number of columns |
T | Array element type |
Default constructor.
The following ways of constructing a matrix are:
Allocates undefined \( n\times m\) Array.
|
default |
|
inlineexplicit |
Scalar constructor.
Construct with given scalar which is assigned to all elements in array
S | Type for scalar |
rhs | Scalar to assign |
|
inline |
Initializer list constructor.
Construction from c++ initializer list.
S | Element type of initializer list |
rhs | Initializer list to assign |
|
inlineconstexpr |
|
inline |
Standard array indexing operation for 1D Array.
Example for Vector Array:
i | Vector index type |
|
inline |
|
inline |
Compare non-equality of two Arrays.
Negation of operator==()
S | |
n1 | |
m1 |
rhs |
|
inline |
Multiplication operator.
Defined for the following operations
Array*Array:
NOTE: Arrays must share same dimensionality
Scalar * Array / Array * Scalar:
NOTE: Exact definition exist in overloaded functions that can be viewed in source code.
n | Number of rows |
m | Number of columns |
T | Array element type |
a | |
b |
|
inline |
Multiply assign scalar or array.
Multiplication works element wise
Multiply assign operator can be used in the following ways
Multiply assign Array:
Multiply assign scalar:
S |
rhs |
|
inline |
Addition operator.
Defined for the following operations
NOTE: Arrays must share same dimensionality
Scalar + Array / Array + Scalar:
NOTE: Exact definition exist in overloaded functions that can be viewed in source code.
n | Number of rows |
m | Number of columns |
T | Array element type |
a | |
b |
|
inline |
Add assign operator with Array or scalar.
Add assign operator can be used in the following ways
Add assign Array:
Requires that Arrays have same dimensions
Add assign scalar:
Adds scalar \( a \) to Array uniformly
S | Element type of rhs |
rhs | Array to add |
|
inline |
Subtraction operator.
Defined for the following operations
NOTE: Arrays must share same dimensionality
Scalar - Array / Array - Scalar:
NOTE: Exact definition exist in overloaded functions that can be viewed in source code.
n | Number of rows |
m | Number of columns |
T | Array element type |
a | |
b |
|
inline |
Subtract assign operator with Array or scalar.
Subtract assign operator can be used in the following ways
Subtract assign Array:
Subtract assign scalar:
Subtract scalar uniformly from square matrix
S |
rhs |
|
inline |
Division operator.
Defined for the following operations
Array/Array:
NOTE: Arrays must share same dimensionality
Scalar / Array / Array / Scalar:
NOTE: Exact definition exist in overloaded functions that can be viewed in source code.
n | Number of rows |
m | Number of columns |
T | Array element type |
a | |
b |
|
inline |
Division assign with array or scalar.
Division works element wise
Division assign operator can be used in the following ways
Division assign Array:
Division assign scalar:
S |
rhs |
|
inline |
Scalar assignment operator.
The following ways to assign an Array are:
Assignment from Array:
Assignment from scalar:
Assignment from scalar assigns the scalar uniformly to the array
|
inlineconstexpr |
|
inlineconstexpr |
|
related |
|
related |
|
related |
|
related |