add copying function
parent
93188a6120
commit
95d01f4589
|
@ -1 +1,2 @@
|
|||
target/
|
||||
Cargo.lock
|
||||
|
|
|
@ -231,8 +231,8 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "stattest"
|
||||
version = "0.0.0"
|
||||
source = "git+https://github.com/Tri11Paragon/stattest#d05d11f1515278904c1be74a76311e9c4550eeae"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/Tri11Paragon/stattest#f28a14740a90cc63f69d0fe26f63da96dad6e319"
|
||||
dependencies = [
|
||||
"rand",
|
||||
"statrs",
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#![crate_type="cdylib"]
|
||||
|
||||
use stattest::test::{ShapiroWilkError, ShapiroWilkStatus, ShapiroWilkTest};
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn test() {
|
||||
println!("Hello");
|
||||
|
@ -17,12 +19,7 @@ pub struct Bruh {
|
|||
weights_capacity: usize,
|
||||
}
|
||||
|
||||
#[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);
|
||||
fn create_bruh(result: Result<ShapiroWilkTest, ShapiroWilkError>) -> Bruh {
|
||||
match result {
|
||||
Ok(results) => {
|
||||
let (weights, weights_len, weights_capacity) = {
|
||||
|
@ -60,3 +57,27 @@ pub extern "C-unwind" fn willbert(data: *const f64, len: usize) -> 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)
|
||||
}
|
Loading…
Reference in New Issue