6b8a7ab582
Sync public mirror / sync (push) Failing after 29s
almost complete. Need to doublecheck names for functions in *_serial.h
48 lines
999 B
C++
48 lines
999 B
C++
#pragma once
|
|
|
|
#include <cstdint> //uint64_t
|
|
//#include <stdexcept> // std::runtime_error
|
|
|
|
#include "../utils/vector.h"
|
|
#include "../utils/matrix.h"
|
|
|
|
namespace numerics::detail{
|
|
|
|
// ---------------- Matrix ----------------
|
|
template <typename T>
|
|
inline bool equal_serial(const utils::Matrix<T>& A, const utils::Matrix<T> & B) {
|
|
const uint64_t rows = A.rows();
|
|
const uint64_t cols = A.cols();
|
|
|
|
if ((rows != B.rows()) || (cols != B.cols())){
|
|
return false;
|
|
}
|
|
|
|
for (uint64_t i = 0; i < rows; ++i){
|
|
for (uint64_t j = 0; j < cols; ++j){
|
|
if (A(i,j) != B(i,j)){
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
// ---------------- Vector ----------------
|
|
template <typename T>
|
|
inline bool equal_serial(const utils::Vector<T>& v, const utils::Vector<T>& p) {
|
|
const uint64_t N = v.size();
|
|
if (N != p.size()){
|
|
return false;
|
|
}
|
|
for (uint64_t i = 0; i < N; ++i){
|
|
if ((v[i] != p[i])){
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
} // namespace numerics
|
|
|