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
-9
@@ -1,18 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "./utils/vector.h"
|
||||
#include "./utils/matrix.h"
|
||||
#include "./core/omp_config.h"
|
||||
#include "detail/exp_serial.h"
|
||||
|
||||
|
||||
namespace numerics{
|
||||
|
||||
|
||||
// ---------------- Elementwise ----------------
|
||||
template <typename T>
|
||||
T exp(const T a){
|
||||
return std::exp(a);
|
||||
inline void inplace_exp(T& c) {
|
||||
detail::inplace_exp_scalar_serial(c);
|
||||
}
|
||||
template <typename T>
|
||||
inline T exp(const T c) {
|
||||
T out = c;
|
||||
inplace_exp(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void inplace_exp(utils::Matrix<T>& A) {
|
||||
detail::inplace_exp_elementwise_serial(A);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline utils::Matrix<T> exp(const utils::Matrix<T>& A) {
|
||||
utils::Matrix<T> out = A;
|
||||
inplace_exp(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void inplace_exp(utils::Vector<T>& v) {
|
||||
detail::inplace_exp_elementwise_serial(v);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline utils::Vector<T> exp(const utils::Vector<T>& v) {
|
||||
utils::Vector<T> out = v;
|
||||
inplace_exp(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
} // namespace numerics
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user