WaveSimPP 1.0
A C library for solving the wave equation and reconstructing the wave field
All Classes Namespaces Functions Modules Pages
Namespaces | Functions
Np

Namespaces

namespace  np
 Custom implementation of numpy in C++.
 

Functions

template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator* (boost::multi_array< T, ND > const &lhs, boost::multi_array< T, ND > const &rhs)
 Multiplication operator between two multi arrays, element-wise.
 
template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator* (T const &lhs, boost::multi_array< T, ND > const &rhs)
 Multiplication operator between a multi array and a scalar.
 
template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator* (boost::multi_array< T, ND > const &lhs, T const &rhs)
 Multiplication operator between a multi array and a scalar.
 
template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator+ (boost::multi_array< T, ND > const &lhs, boost::multi_array< T, ND > const &rhs)
 Addition operator between two multi arrays, element wise.
 
template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator+ (T const &lhs, boost::multi_array< T, ND > const &rhs)
 Addition operator between a multi array and a scalar.
 
template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator+ (boost::multi_array< T, ND > const &lhs, T const &rhs)
 Addition operator between a scalar and a multi array.
 
template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator- (boost::multi_array< T, ND > const &lhs, boost::multi_array< T, ND > const &rhs)
 Minus operator between two multi arrays, element-wise.
 
template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator- (T const &lhs, boost::multi_array< T, ND > const &rhs)
 Minus operator between a scalar and a multi array, element-wise.
 
template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator- (boost::multi_array< T, ND > const &lhs, T const &rhs)
 Minus operator between a multi array and a scalar, element-wise.
 
template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator/ (boost::multi_array< T, ND > const &lhs, boost::multi_array< T, ND > const &rhs)
 Division between two multi arrays, element wise.
 
template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator/ (T const &lhs, boost::multi_array< T, ND > const &rhs)
 Division between a scalar and a multi array, element wise.
 
template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator/ (boost::multi_array< T, ND > const &lhs, T const &rhs)
 Division between a multi array and a scalar, element wise.
 
matplot::vector_2d np::convert_to_matplot (const boost::multi_array< double, 2 > &arr)
 Convert a 2D boost::multi_array to a matplot::vector_2d.
 

Detailed Description

Function Documentation

◆ convert_to_matplot()

matplot::vector_2d np::convert_to_matplot ( const boost::multi_array< double, 2 > &  arr)
inline

Convert a 2D boost::multi_array to a matplot::vector_2d.

Definition at line 16 of file np_to_matplot.hpp.

17 {
18 std::vector<double> x = matplot::linspace(0, 0, arr.shape()[0]);
19 std::vector<double> y = matplot::linspace(00, 0, arr.shape()[1]);
20 matplot::vector_2d result = std::get<0>(matplot::meshgrid(x, y));
21 // std::cout << "arr.shape()[0] = " << arr.shape()[0] << " arr.shape()[1] = " << arr.shape()[1] << std::endl;
22 for (size_t i = 0; i < arr.shape()[0]; i++)
23 {
24 for (size_t j = 0; j < arr.shape()[1]; j++)
25 {
26 result[i][j] = arr[i][j];
27 }
28 }
29 return result;
30 }

◆ operator*() [1/3]

template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator* ( boost::multi_array< T, ND > const &  lhs,
boost::multi_array< T, ND > const &  rhs 
)
inline

Multiplication operator between two multi arrays, element-wise.

Definition at line 504 of file np.hpp.

505{
506 std::function<T(T, T)> func = std::multiplies<T>();
507 return np::element_wise_duo_apply(lhs, rhs, func);
508}
constexpr boost::multi_array< T, ND > element_wise_duo_apply(boost::multi_array< T, ND > const &lhs, boost::multi_array< T, ND > const &rhs, std::function< T(T, T)> func)
Definition: np.hpp:337

◆ operator*() [2/3]

template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator* ( boost::multi_array< T, ND > const &  lhs,
T const &  rhs 
)
inline

Multiplication operator between a multi array and a scalar.

Definition at line 520 of file np.hpp.

521{
522 return rhs * lhs;
523}

◆ operator*() [3/3]

template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator* ( T const &  lhs,
boost::multi_array< T, ND > const &  rhs 
)
inline

Multiplication operator between a multi array and a scalar.

Definition at line 512 of file np.hpp.

513{
514 std::function<T(T)> func = [lhs](T item)
515 { return lhs * item; };
516 return np::element_wise_apply(rhs, func);
517}
::value constexpr boost::multi_array< T, ND > element_wise_apply(const boost::multi_array< T, ND > &input_array, std::function< T(T)> func)
Creates a new array and fills it with the values of the result of the function called on the input ar...
Definition: np.hpp:243

◆ operator+() [1/3]

template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator+ ( boost::multi_array< T, ND > const &  lhs,
boost::multi_array< T, ND > const &  rhs 
)

Addition operator between two multi arrays, element wise.

Definition at line 528 of file np.hpp.

529{
530 std::function<T(T, T)> func = std::plus<T>();
531 return np::element_wise_duo_apply(lhs, rhs, func);
532}

◆ operator+() [2/3]

template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator+ ( boost::multi_array< T, ND > const &  lhs,
T const &  rhs 
)
inline

Addition operator between a scalar and a multi array.

Definition at line 545 of file np.hpp.

546{
547 return rhs + lhs;
548}

◆ operator+() [3/3]

template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator+ ( T const &  lhs,
boost::multi_array< T, ND > const &  rhs 
)
inline

Addition operator between a multi array and a scalar.

Definition at line 536 of file np.hpp.

537{
538 std::function<T(T)> func = [lhs](T item)
539 { return lhs + item; };
540 return np::element_wise_apply(rhs, func);
541}

◆ operator-() [1/3]

template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator- ( boost::multi_array< T, ND > const &  lhs,
boost::multi_array< T, ND > const &  rhs 
)

Minus operator between two multi arrays, element-wise.

Definition at line 553 of file np.hpp.

554{
555 std::function<T(T, T)> func = std::minus<T>();
556 return np::element_wise_duo_apply(lhs, rhs, func);
557}

◆ operator-() [2/3]

template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator- ( boost::multi_array< T, ND > const &  lhs,
T const &  rhs 
)
inline

Minus operator between a multi array and a scalar, element-wise.

Definition at line 570 of file np.hpp.

571{
572 return rhs - lhs;
573}

◆ operator-() [3/3]

template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator- ( T const &  lhs,
boost::multi_array< T, ND > const &  rhs 
)
inline

Minus operator between a scalar and a multi array, element-wise.

Definition at line 561 of file np.hpp.

562{
563 std::function<T(T)> func = [lhs](T item)
564 { return lhs - item; };
565 return np::element_wise_apply(rhs, func);
566}

◆ operator/() [1/3]

template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator/ ( boost::multi_array< T, ND > const &  lhs,
boost::multi_array< T, ND > const &  rhs 
)

Division between two multi arrays, element wise.

Definition at line 578 of file np.hpp.

579{
580 std::function<T(T, T)> func = std::divides<T>();
581 return np::element_wise_duo_apply(lhs, rhs, func);
582}

◆ operator/() [2/3]

template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator/ ( boost::multi_array< T, ND > const &  lhs,
T const &  rhs 
)
inline

Division between a multi array and a scalar, element wise.

Definition at line 595 of file np.hpp.

596{
597 std::function<T(T)> func = [rhs](T item)
598 { return item / rhs; };
599 return np::element_wise_apply(lhs, func);
600}

◆ operator/() [3/3]

template<class T , long unsigned int ND>
boost::multi_array< T, ND > operator/ ( T const &  lhs,
boost::multi_array< T, ND > const &  rhs 
)
inline

Division between a scalar and a multi array, element wise.

Definition at line 586 of file np.hpp.

587{
588 std::function<T(T)> func = [lhs](T item)
589 { return lhs / item; };
590 return np::element_wise_apply(rhs, func);
591}