Compare commits
No commits in common. "d37b549025459d41c1a0a9aab2a61754e8577110" and "93188a61200d7d66302363057b8e74deac510029" have entirely different histories.
d37b549025
...
93188a6120
|
@ -1,2 +1 @@
|
||||||
target/
|
target/
|
||||||
Cargo.lock
|
|
||||||
|
|
|
@ -231,8 +231,8 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stattest"
|
name = "stattest"
|
||||||
version = "0.0.1"
|
version = "0.0.0"
|
||||||
source = "git+https://github.com/Tri11Paragon/stattest#f28a14740a90cc63f69d0fe26f63da96dad6e319"
|
source = "git+https://github.com/Tri11Paragon/stattest#d05d11f1515278904c1be74a76311e9c4550eeae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rand",
|
"rand",
|
||||||
"statrs",
|
"statrs",
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#![crate_type="cdylib"]
|
#![crate_type="cdylib"]
|
||||||
|
|
||||||
use stattest::test::{ShapiroWilkError, ShapiroWilkStatus, ShapiroWilkTest};
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn test() {
|
pub extern "C" fn test() {
|
||||||
println!("Hello");
|
println!("Hello");
|
||||||
|
@ -19,7 +17,12 @@ pub struct Bruh {
|
||||||
weights_capacity: usize,
|
weights_capacity: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_bruh(result: Result<ShapiroWilkTest, ShapiroWilkError>) -> Bruh {
|
#[no_mangle]
|
||||||
|
pub extern "C-unwind" fn willbert(data: *const f64, len: usize) -> Bruh {
|
||||||
|
use stattest::test::{ShapiroWilkError, ShapiroWilkStatus};
|
||||||
|
|
||||||
|
let slice = unsafe { std::slice::from_raw_parts(data, len) };
|
||||||
|
let result = stattest::test::ShapiroWilkTest::new(slice);
|
||||||
match result {
|
match result {
|
||||||
Ok(results) => {
|
Ok(results) => {
|
||||||
let (weights, weights_len, weights_capacity) = {
|
let (weights, weights_len, weights_capacity) = {
|
||||||
|
@ -57,27 +60,3 @@ fn create_bruh(result: Result<ShapiroWilkTest, ShapiroWilkError>) -> Bruh {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Safety
|
|
||||||
/// data must be a valid unique ptr to len f64's
|
|
||||||
/// requires input data to be sorted
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C-unwind" fn willbert(data: *const f64, len: usize) -> Bruh {
|
|
||||||
let slice = unsafe { std::slice::from_raw_parts(data, len) };
|
|
||||||
let result = ShapiroWilkTest::new_sorted(slice);
|
|
||||||
create_bruh(result)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C-unwind" fn willbert_unsorted(data: *mut f64, len: usize) -> Bruh {
|
|
||||||
let slice = unsafe { std::slice::from_raw_parts_mut(data, len) };
|
|
||||||
let result = ShapiroWilkTest::new(slice);
|
|
||||||
create_bruh(result)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C-unwind" fn willbert_unsorted_copy(data: *const f64, len: usize) -> Bruh {
|
|
||||||
let slice = unsafe { std::slice::from_raw_parts(data, len) };
|
|
||||||
let result = ShapiroWilkTest::new_copy(slice);
|
|
||||||
create_bruh(result)
|
|
||||||
}
|
|
|
@ -20,7 +20,6 @@
|
||||||
#define GP_IMAGE_TEST_EXTERN_H
|
#define GP_IMAGE_TEST_EXTERN_H
|
||||||
|
|
||||||
#include <blt/std/types.h>
|
#include <blt/std/types.h>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
struct shapiro_wilk_results
|
struct shapiro_wilk_results
|
||||||
{
|
{
|
||||||
|
@ -33,8 +32,6 @@ struct shapiro_wilk_results
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" shapiro_wilk_results willbert(const double* data, blt::size_t len);
|
extern "C" shapiro_wilk_results willbert(const double* data, blt::size_t len);
|
||||||
extern "C" shapiro_wilk_results willbert_unsorted(double* data, blt::size_t len);
|
|
||||||
extern "C" shapiro_wilk_results willbert_unsorted_copy(const double* data, blt::size_t len);
|
|
||||||
|
|
||||||
extern "C" void test();
|
extern "C" void test();
|
||||||
|
|
||||||
|
@ -45,22 +42,13 @@ class willbruh
|
||||||
public:
|
public:
|
||||||
explicit willbruh(const std::vector<double>& data): results(willbert(data.data(), data.size()))
|
explicit willbruh(const std::vector<double>& data): results(willbert(data.data(), data.size()))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
explicit willbruh(const double* data, blt::size_t size): results(willbert(data, size))
|
explicit willbruh(const double* data, blt::size_t size): results(willbert(data, size))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
|
||||||
* Takes ownership of the results, will free when out of scope.
|
|
||||||
*/
|
|
||||||
explicit willbruh(shapiro_wilk_results results): results(results)
|
|
||||||
{}
|
|
||||||
|
|
||||||
willbruh(const willbruh& copy) = delete;
|
willbruh(const willbruh& copy) = delete;
|
||||||
|
|
||||||
willbruh(const willbruh&& move) = delete;
|
willbruh(const willbruh&& move) = delete;
|
||||||
|
|
||||||
willbruh& operator=(const willbruh& copy) = delete;
|
willbruh& operator=(const willbruh& copy) = delete;
|
||||||
|
|
||||||
willbruh& operator=(const willbruh&& move) = delete;
|
willbruh& operator=(const willbruh&& move) = delete;
|
||||||
|
|
||||||
shapiro_wilk_results& get()
|
shapiro_wilk_results& get()
|
||||||
|
@ -68,8 +56,7 @@ class willbruh
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
shapiro_wilk_results* operator->()
|
shapiro_wilk_results* operator->(){
|
||||||
{
|
|
||||||
return &results;
|
return &results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,9 +66,4 @@ class willbruh
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void shapiro_test_local();
|
|
||||||
void shapiro_test_unsorted();
|
|
||||||
void shapiro_test_copy();
|
|
||||||
void shapiro_test_run();
|
|
||||||
|
|
||||||
#endif //GP_IMAGE_TEST_EXTERN_H
|
#endif //GP_IMAGE_TEST_EXTERN_H
|
||||||
|
|
137
src/extern.cpp
137
src/extern.cpp
|
@ -1,137 +0,0 @@
|
||||||
/*
|
|
||||||
* Created by Brett on 30/01/24.
|
|
||||||
* Licensed under GNU General Public License V3.0
|
|
||||||
* See LICENSE file for license detail
|
|
||||||
*/
|
|
||||||
#include "blt/std/assert.h"
|
|
||||||
#include "blt/std/logging.h"
|
|
||||||
#include "blt/profiling/profiler_v2.h"
|
|
||||||
#include <extern.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
const std::vector<double> large_c {
|
|
||||||
0.139E100, 0.157E100, 0.175E100, 0.256E100, 0.344E100, 0.413E100, 0.503E100, 0.577E100,
|
|
||||||
0.614E100, 0.655E100, 0.954E100, 1.392E100, 1.557E100, 1.648E100, 1.690E100, 1.994E100,
|
|
||||||
2.174E100, 2.206E100, 3.245E100, 3.510E100, 3.571E100, 4.354E100, 4.980E100, 6.084E100,
|
|
||||||
8.351E100};
|
|
||||||
|
|
||||||
const std::vector<double> normally_c {-0.4417998157703872,
|
|
||||||
-0.310841224215176,
|
|
||||||
-0.2544758389229413,
|
|
||||||
-0.21509882047762266,
|
|
||||||
-0.18254731741828356,
|
|
||||||
-0.1541570107663562,
|
|
||||||
-0.12852819470327187,
|
|
||||||
-0.1048199468783084,
|
|
||||||
-0.08247628697708857,
|
|
||||||
-0.061100278634889656,
|
|
||||||
-0.040388574421146996,
|
|
||||||
-0.020093702456713224,
|
|
||||||
0.0,
|
|
||||||
0.020093702456713224,
|
|
||||||
0.040388574421146996,
|
|
||||||
0.061100278634889656,
|
|
||||||
0.08247628697708857,
|
|
||||||
0.1048199468783084,
|
|
||||||
0.12852819470327187,
|
|
||||||
0.1541570107663562,
|
|
||||||
0.18254731741828356,
|
|
||||||
0.21509882047762266,
|
|
||||||
0.2544758389229413,
|
|
||||||
0.310841224215176,
|
|
||||||
0.4417998157703872};
|
|
||||||
|
|
||||||
const std::vector<double> nearly_c {
|
|
||||||
-0.44, -0.31, -0.25, -0.21, -0.18, -0.15, -0.12, -0.10, -0.08, -0.06, -0.04, -0.02,
|
|
||||||
0.0, 0.02, 0.04, 0.06, 0.08, 0.10, 0.12, 0.15, 0.18, 0.21, 0.25, 0.31, 0.44};
|
|
||||||
|
|
||||||
#undef BLT_DEBUG
|
|
||||||
#define BLT_DEBUG(...)
|
|
||||||
void shapiro_test_local()
|
|
||||||
{
|
|
||||||
auto normally = normally_c;
|
|
||||||
auto nearly = nearly_c;
|
|
||||||
auto large = large_c;
|
|
||||||
|
|
||||||
std::sort(normally.begin(), normally.end());
|
|
||||||
std::sort(nearly.begin(), nearly.end());
|
|
||||||
std::sort(large.begin(), large.end());
|
|
||||||
|
|
||||||
willbruh w1(normally);
|
|
||||||
BLT_ASSERT(w1->estimate == 0.9999999999999999);
|
|
||||||
BLT_ASSERT(w1->p_value == 1.0);
|
|
||||||
BLT_DEBUG("%f // %f", w1->estimate, w1->p_value);
|
|
||||||
|
|
||||||
willbruh w2(nearly);
|
|
||||||
BLT_ASSERT(w2->estimate == 0.9997987717271388);
|
|
||||||
BLT_ASSERT(w2->p_value == 1.0);
|
|
||||||
BLT_DEBUG("%f // %f", w2->estimate, w2->p_value);
|
|
||||||
|
|
||||||
willbruh w3(large);
|
|
||||||
BLT_ASSERT(w3->estimate == 0.8346662753181684);
|
|
||||||
BLT_ASSERT(w3->p_value == 0.0009134904817755807);
|
|
||||||
BLT_DEBUG("%f // %f", w3->estimate, w3->p_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void shapiro_test_unsorted()
|
|
||||||
{
|
|
||||||
auto normally = normally_c;
|
|
||||||
auto nearly = nearly_c;
|
|
||||||
auto large = large_c;
|
|
||||||
|
|
||||||
willbruh w1(willbert_unsorted(normally.data(), normally.size()));
|
|
||||||
BLT_ASSERT(w1->estimate == 0.9999999999999999);
|
|
||||||
BLT_ASSERT(w1->p_value == 1.0);
|
|
||||||
BLT_DEBUG("%f // %f", w1->estimate, w1->p_value);
|
|
||||||
|
|
||||||
willbruh w2(willbert_unsorted(nearly.data(), nearly.size()));
|
|
||||||
BLT_ASSERT(w2->estimate == 0.9997987717271388);
|
|
||||||
BLT_ASSERT(w2->p_value == 1.0);
|
|
||||||
BLT_DEBUG("%f // %f", w2->estimate, w2->p_value);
|
|
||||||
|
|
||||||
willbruh w3(willbert_unsorted(large.data(), large.size()));
|
|
||||||
BLT_ASSERT(w3->estimate == 0.8346662753181684);
|
|
||||||
BLT_ASSERT(w3->p_value == 0.0009134904817755807);
|
|
||||||
BLT_DEBUG("%f // %f", w3->estimate, w3->p_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void shapiro_test_copy()
|
|
||||||
{
|
|
||||||
auto normally = normally_c;
|
|
||||||
auto nearly = nearly_c;
|
|
||||||
auto large = large_c;
|
|
||||||
|
|
||||||
willbruh w1(willbert_unsorted_copy(normally.data(), normally.size()));
|
|
||||||
BLT_ASSERT(w1->estimate == 0.9999999999999999);
|
|
||||||
BLT_ASSERT(w1->p_value == 1.0);
|
|
||||||
BLT_DEBUG("%f // %f", w1->estimate, w1->p_value);
|
|
||||||
|
|
||||||
willbruh w2(willbert_unsorted_copy(nearly.data(), nearly.size()));
|
|
||||||
BLT_ASSERT(w2->estimate == 0.9997987717271388);
|
|
||||||
BLT_ASSERT(w2->p_value == 1.0);
|
|
||||||
BLT_DEBUG("%f // %f", w2->estimate, w2->p_value);
|
|
||||||
|
|
||||||
willbruh w3(willbert_unsorted_copy(large.data(), large.size()));
|
|
||||||
BLT_ASSERT(w3->estimate == 0.8346662753181684);
|
|
||||||
BLT_ASSERT(w3->p_value == 0.0009134904817755807);
|
|
||||||
BLT_DEBUG("%f // %f", w3->estimate, w3->p_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void shapiro_test_run()
|
|
||||||
{
|
|
||||||
const auto runs = 500000;
|
|
||||||
BLT_START_INTERVAL("shapiro", "copy");
|
|
||||||
for (size_t i = 0; i < runs; i++)
|
|
||||||
shapiro_test_copy();
|
|
||||||
BLT_END_INTERVAL("shapiro", "copy");
|
|
||||||
BLT_START_INTERVAL("shapiro", "unsorted_mut");
|
|
||||||
for (size_t i = 0; i < runs; i++)
|
|
||||||
shapiro_test_unsorted();
|
|
||||||
BLT_END_INTERVAL("shapiro", "unsorted_mut");
|
|
||||||
BLT_START_INTERVAL("shapiro", "local_sorted");
|
|
||||||
for (size_t i = 0; i < runs; i++)
|
|
||||||
shapiro_test_local();
|
|
||||||
BLT_END_INTERVAL("shapiro", "local_sorted");
|
|
||||||
BLT_PRINT_PROFILE("shapiro");
|
|
||||||
}
|
|
|
@ -261,8 +261,6 @@ float eval_DNF_SW(const image& img)
|
||||||
for (const auto& v : img.getData())
|
for (const auto& v : img.getData())
|
||||||
order.push_back(v.magnitude());
|
order.push_back(v.magnitude());
|
||||||
|
|
||||||
std::sort(order.begin(), order.end());
|
|
||||||
|
|
||||||
blt::size_t len = 5000;
|
blt::size_t len = 5000;
|
||||||
blt::size_t current_pos = 0;
|
blt::size_t current_pos = 0;
|
||||||
double total = 0;
|
double total = 0;
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include "blt/gfx/renderer/batch_2d_renderer.h"
|
#include "blt/gfx/renderer/batch_2d_renderer.h"
|
||||||
#include "blt/std/assert.h"
|
#include "blt/std/assert.h"
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "extern.h"
|
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
@ -114,7 +113,7 @@ class tree
|
||||||
|
|
||||||
static crossover_result_t crossover(tree* p1, tree* p2)
|
static crossover_result_t crossover(tree* p1, tree* p2)
|
||||||
{
|
{
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void evaluate()
|
void evaluate()
|
||||||
|
@ -216,7 +215,6 @@ void update(std::int32_t w, std::int32_t h)
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
shapiro_test_run();
|
|
||||||
blt::gfx::init(blt::gfx::window_data{"Window of GP test", init, update}.setSyncInterval(1));
|
blt::gfx::init(blt::gfx::window_data{"Window of GP test", init, update}.setSyncInterval(1));
|
||||||
global_matrices.cleanup();
|
global_matrices.cleanup();
|
||||||
resources.cleanup();
|
resources.cleanup();
|
||||||
|
|
Loading…
Reference in New Issue