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:
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include "./core/omp_config.h"
|
||||
#include "detail/neg_serial.h"
|
||||
|
||||
|
||||
namespace numerics{
|
||||
|
||||
// ---------------- Elementwise ----------------
|
||||
template <typename T>
|
||||
inline void inplace_neg(T& c) {
|
||||
detail::inplace_neg_scalar_serial(c);
|
||||
}
|
||||
template <typename T>
|
||||
inline T neg(const T c) {
|
||||
T out = c;
|
||||
inplace_neg(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void inplace_neg(utils::Matrix<T>& A) {
|
||||
detail::inplace_neg_elementwise_serial(A);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline utils::Matrix<T> neg(const utils::Matrix<T>& A) {
|
||||
utils::Matrix<T> out = A;
|
||||
inplace_neg(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void inplace_neg(utils::Vector<T>& v) {
|
||||
detail::inplace_neg_elementwise_serial(v);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline utils::Vector<T> neg(const utils::Vector<T>& v) {
|
||||
utils::Vector<T> out = v;
|
||||
inplace_neg(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user