Sync public subset from Flux
This commit is contained in:
48
include/numerics/vecrandom.h
Normal file
48
include/numerics/vecrandom.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef _vecrandom_n_
|
||||
#define _vecrandom_n_
|
||||
|
||||
#include "./utils/vector.h"
|
||||
#include "./utils/matrix.h"
|
||||
#include "./core/omp_config.h"
|
||||
|
||||
namespace numerics{
|
||||
|
||||
template <typename T>
|
||||
void inplace_vecrandom_add(utils::Vector<T>& a, const T lower, const T higher) {
|
||||
|
||||
const uint64_t N = a.size();
|
||||
|
||||
utils::Vector<T> b;
|
||||
b.random(N, lower, higher);
|
||||
|
||||
a.inplace_add(b);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void inplace_vecrandom_mul(utils::Vector<T>& a, const T lower, const T higher) {
|
||||
|
||||
const uint64_t N = a.size();
|
||||
|
||||
utils::Vector<T> b;
|
||||
b.random(N, lower, higher);
|
||||
|
||||
a.inplace_multiply(b);
|
||||
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
utils::Vector<T> vecrandom_add(const utils::Vector<T>& a, const T lower, const T higher) {
|
||||
|
||||
const uint64_t N = a.size();
|
||||
|
||||
utils::Vector<T> b;
|
||||
inplace_vecrandom_add(b, lower, higher);
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
} // namespace numerics
|
||||
|
||||
#endif // _vecrandom_n_
|
||||
Reference in New Issue
Block a user