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,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint> //uint64_t
|
||||
#include <cmath> // std::log
|
||||
|
||||
#include "../utils/vector.h"
|
||||
#include "../utils/matrix.h"
|
||||
|
||||
namespace numerics::detail{
|
||||
|
||||
|
||||
// ---------------- Elemenwise ----------------
|
||||
template <typename T>
|
||||
void inplace_log_scalar_serial(T& c) {
|
||||
c = static_cast<T>(std::log(c));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void inplace_log_elementwise_serial(utils::Matrix<T>& A) {
|
||||
const uint64_t rows = A.rows();
|
||||
const uint64_t cols = A.cols();
|
||||
for (uint64_t i = 0; i < rows; ++i){
|
||||
for (uint64_t j = 0; j < cols; ++j){
|
||||
A(i,j) = static_cast<T>(std::log(A(i,j)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void inplace_log_elementwise_serial(utils::Vector<T>& v) {
|
||||
for (uint64_t i = 0; i < v.size(); ++i){
|
||||
v[i] = static_cast<T>(std::log(v[i]));
|
||||
}
|
||||
}
|
||||
} // namespace numerics
|
||||
|
||||
Reference in New Issue
Block a user