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:
+33
-12
@@ -1,25 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "./utils/vector.h"
|
||||
#include "./utils/matrix.h"
|
||||
#include "./core/omp_config.h"
|
||||
#include "detail/log_serial.h"
|
||||
|
||||
|
||||
namespace numerics{
|
||||
|
||||
|
||||
// ---------------- Elementwise ----------------
|
||||
template <typename T>
|
||||
void inplace_log(T a){
|
||||
a = std::log(a);
|
||||
inline void inplace_log(T& c) {
|
||||
detail::inplace_log_scalar_serial(c);
|
||||
}
|
||||
template <typename T>
|
||||
inline T log(const T c) {
|
||||
T out = c;
|
||||
inplace_log(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T log(const T a){
|
||||
T b = a;
|
||||
inplace_log(b);
|
||||
return b;
|
||||
inline void inplace_log(utils::Matrix<T>& A) {
|
||||
detail::inplace_log_elementwise_serial(A);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline utils::Matrix<T> log(const utils::Matrix<T>& A) {
|
||||
utils::Matrix<T> out = A;
|
||||
inplace_log(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void inplace_log(utils::Vector<T>& v) {
|
||||
detail::inplace_log_elementwise_serial(v);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline utils::Vector<T> log(const utils::Vector<T>& v) {
|
||||
utils::Vector<T> out = v;
|
||||
inplace_log(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
} // namespace numerics
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user