GP_Image_Test/include/extern.h

88 lines
2.4 KiB
C
Raw Normal View History

2024-01-29 15:55:28 -05:00
/*
* <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>
2024-01-30 00:52:48 -05:00
#include <vector>
2024-01-29 15:55:28 -05:00
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);
2024-01-30 00:52:48 -05:00
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);
2024-01-29 15:55:28 -05:00
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()))
{}
2024-01-30 00:52:48 -05:00
2024-01-29 15:55:28 -05:00
explicit willbruh(const double* data, blt::size_t size): results(willbert(data, size))
{}
2024-01-30 00:52:48 -05:00
/**
* Takes ownership of the results, will free when out of scope.
*/
explicit willbruh(shapiro_wilk_results results): results(results)
{}
2024-01-29 15:55:28 -05:00
willbruh(const willbruh& copy) = delete;
2024-01-30 00:52:48 -05:00
2024-01-29 15:55:28 -05:00
willbruh(const willbruh&& move) = delete;
willbruh& operator=(const willbruh& copy) = delete;
2024-01-30 00:52:48 -05:00
2024-01-29 15:55:28 -05:00
willbruh& operator=(const willbruh&& move) = delete;
shapiro_wilk_results& get()
{
return results;
}
2024-01-30 00:52:48 -05:00
shapiro_wilk_results* operator->()
{
2024-01-29 15:55:28 -05:00
return &results;
}
~willbruh()
{
free(results.weights);
}
};
2024-01-30 00:52:48 -05:00
void shapiro_test_local();
void shapiro_test_unsorted();
void shapiro_test_copy();
void shapiro_test_run();
2024-01-29 15:55:28 -05:00
#endif //GP_IMAGE_TEST_EXTERN_H