34 lines
700 B
C++
34 lines
700 B
C++
#pragma once
|
|
|
|
#include "core/omp_config.h"
|
|
#include "utils/matrix.h"
|
|
|
|
|
|
namespace utils{
|
|
|
|
template <typename To, typename From>
|
|
void inplace_veccast(const utils::Vector<From>& a, utils::Vector<To>& b) {
|
|
if (a.size() != b.size()){
|
|
throw std::runtime_error("inplace_veccast: dimension mismatch");
|
|
}
|
|
|
|
uint64_t n = a.size();
|
|
|
|
for (uint64_t i = 0; i < n; ++i){
|
|
b[i] = static_cast<To>(a[i]);
|
|
}
|
|
}
|
|
|
|
|
|
template <typename To, typename From>
|
|
utils::Vector<To> veccast(const utils::Vector<From>& a) {
|
|
utils::Vector<To> b(a.size(), To{0});
|
|
|
|
inplace_veccast(a,b);
|
|
|
|
return b;
|
|
}
|
|
|
|
} // end namespace utils
|
|
|