Next step is ramdom and equal. I also need to have a look at add and the serial naming of the functions.
This commit is contained in:
+37
-14
@@ -1,23 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "./utils/vector.h"
|
||||
#include "./utils/matrix.h"
|
||||
#include "./core/omp_config.h"
|
||||
#include "detail/abs_serial.h"
|
||||
|
||||
|
||||
namespace numerics{
|
||||
|
||||
template <typename T>
|
||||
T abs(const T a){
|
||||
|
||||
if(a < 0){
|
||||
return -a;
|
||||
}else{
|
||||
return a;
|
||||
}
|
||||
// ---------------- Elementwise ----------------
|
||||
template <typename T>
|
||||
inline void inplace_abs(T& c) {
|
||||
detail::inplace_abs_scalar_serial(c);
|
||||
}
|
||||
template <typename T>
|
||||
inline T abs(const T c) {
|
||||
T out = c;
|
||||
inplace_abs(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void inplace_abs(utils::Matrix<T>& A) {
|
||||
detail::inplace_abs_elementwise_serial(A);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline utils::Matrix<T> abs(const utils::Matrix<T>& A) {
|
||||
utils::Matrix<T> out = A;
|
||||
inplace_abs(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void inplace_abs(utils::Vector<T>& v) {
|
||||
detail::inplace_abs_elementwise_serial(v);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline utils::Vector<T> abs(const utils::Vector<T>& v) {
|
||||
utils::Vector<T> out = v;
|
||||
inplace_abs(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace numerics
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user