mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-27 12:04:27 +01:00
userland: make libs work
Working for build, but now test-user-mode-in-tree is not using --in-tree, TODO fix later on.
This commit is contained in:
20
lkmc/math.h
Normal file
20
lkmc/math.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef LKMC_MATH_H
|
||||
#define LKMC_MATH_H
|
||||
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
bool lkmc_vector_equal(size_t n, double *v1, double *v2, double max_err) {
|
||||
double sum = 0.0;
|
||||
double diff;
|
||||
size_t i;
|
||||
for (i = 0; i < n; ++i) {
|
||||
diff = v1[i] - v2[i];
|
||||
sum += diff * diff;
|
||||
}
|
||||
if (sqrt(sum)/n > max_err)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user