GP_Image_Test/include/extern.h

88 lines
2.4 KiB
C++

/*
* <Short Description>
* Copyright (C) 2024 Brett Terpstra
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef GP_IMAGE_TEST_EXTERN_H
#define GP_IMAGE_TEST_EXTERN_H
#include <blt/std/types.h>
#include <vector>
struct shapiro_wilk_results
{
blt::i8 error;
double estimate;
double p_value;
double* weights;
blt::size_t weights_len;
blt::size_t weights_capacity;
};
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();
class willbruh
{
private:
shapiro_wilk_results results;
public:
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))
{}
/**
* 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&& move) = delete;
willbruh& operator=(const willbruh& copy) = delete;
willbruh& operator=(const willbruh&& move) = delete;
shapiro_wilk_results& get()
{
return results;
}
shapiro_wilk_results* operator->()
{
return &results;
}
~willbruh()
{
free(results.weights);
}
};
void shapiro_test_local();
void shapiro_test_unsorted();
void shapiro_test_copy();
void shapiro_test_run();
#endif //GP_IMAGE_TEST_EXTERN_H