Skip to content

Commit

Permalink
vendor: Update vendored sources to igraph/igraph@8d24274
Browse files Browse the repository at this point in the history
chore: update plfit
  • Loading branch information
krlmlr committed Jan 6, 2025
1 parent ea35e47 commit f4098d2
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 132 deletions.
10 changes: 1 addition & 9 deletions src/vendor/cigraph/vendor/plfit/gss.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,7 @@
#ifndef __GSS_H__
#define __GSS_H__

#undef __BEGIN_DECLS
#undef __END_DECLS
#ifdef __cplusplus
# define __BEGIN_DECLS extern "C" {
# define __END_DECLS }
#else
# define __BEGIN_DECLS /* empty */
# define __END_DECLS /* empty */
#endif
#include "plfit_decls.h"

__BEGIN_DECLS

Expand Down
2 changes: 1 addition & 1 deletion src/vendor/cigraph/vendor/plfit/hzeta.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

/* Work around bug in some Windows SDK / MSVC versions where NAN is not a
* constant expression, triggering an error in the definition of
* hsl_sf_hzeta_eulermaclaurin_series_coeffs[] and
* hsl_sf_hzeta_eulermaclaurin_series_coeffs[] and
* hsl_sf_hzeta_eulermaclaurin_series_majorantratios[] below.
* We re-define NAN to the value it had in earlier MSVC versions.
* See https://github.com/igraph/igraph/issues/2701
Expand Down
10 changes: 1 addition & 9 deletions src/vendor/cigraph/vendor/plfit/hzeta.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,7 @@
#ifndef __HZETA_H__
#define __HZETA_H__

#undef __BEGIN_DECLS
#undef __END_DECLS
#ifdef __cplusplus
# define __BEGIN_DECLS extern "C" {
# define __END_DECLS }
#else
# define __BEGIN_DECLS /* empty */
# define __END_DECLS /* empty */
#endif
#include "plfit_decls.h"

__BEGIN_DECLS

Expand Down
11 changes: 1 addition & 10 deletions src/vendor/cigraph/vendor/plfit/kolmogorov.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,8 @@
#ifndef __KOLMOGOROV_H__
#define __KOLMOGOROV_H__

#undef __BEGIN_DECLS
#undef __END_DECLS
#ifdef __cplusplus
# define __BEGIN_DECLS extern "C" {
# define __END_DECLS }
#else
# define __BEGIN_DECLS /* empty */
# define __END_DECLS /* empty */
#endif

#include <stdlib.h>
#include "plfit_decls.h"

__BEGIN_DECLS

Expand Down
10 changes: 4 additions & 6 deletions src/vendor/cigraph/vendor/plfit/lbfgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#ifndef __LBFGS_H__
#define __LBFGS_H__

#ifdef __cplusplus
extern "C" {
#endif/*__cplusplus*/
#include "plfit_decls.h"

__BEGIN_DECLS

/*
* The default precision of floating point values is 64bit (double).
Expand Down Expand Up @@ -517,9 +517,7 @@ void lbfgs_free(lbfgsfloatval_t *x);

/** @} */

#ifdef __cplusplus
}
#endif/*__cplusplus*/
__END_DECLS



Expand Down
2 changes: 0 additions & 2 deletions src/vendor/cigraph/vendor/plfit/plfit.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "plfit_error.h"
#include "gss.h"
#include "lbfgs.h"
#include "plfit.h"
#include "kolmogorov.h"
#include "plfit_sampling.h"
#include "hzeta.h"

/* #define PLFIT_DEBUG */
Expand Down
49 changes: 21 additions & 28 deletions src/vendor/cigraph/vendor/plfit/plfit.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef __PLFIT_H__
#define __PLFIT_H__
#ifndef PLFIT_H
#define PLFIT_H

#include <stdlib.h>
#include "plfit_decls.h"
#include "plfit_error.h"
#include "plfit_mt.h"
#include "plfit_sampling.h"
#include "plfit_version.h"

#undef __BEGIN_DECLS
#undef __END_DECLS
#ifdef __cplusplus
# define __BEGIN_DECLS extern "C" {
# define __END_DECLS }
#else
# define __BEGIN_DECLS /* empty */
# define __END_DECLS /* empty */
#endif

__BEGIN_DECLS

typedef unsigned short int plfit_bool_t;
Expand Down Expand Up @@ -91,50 +84,50 @@ typedef struct _plfit_discrete_options_t {
plfit_mt_rng_t* rng;
} plfit_discrete_options_t;

int plfit_continuous_options_init(plfit_continuous_options_t* options);
int plfit_discrete_options_init(plfit_discrete_options_t* options);
PLFIT_EXPORT int plfit_continuous_options_init(plfit_continuous_options_t* options);
PLFIT_EXPORT int plfit_discrete_options_init(plfit_discrete_options_t* options);

extern const plfit_continuous_options_t plfit_continuous_default_options;
extern const plfit_discrete_options_t plfit_discrete_default_options;
PLFIT_EXPORT extern const plfit_continuous_options_t plfit_continuous_default_options;
PLFIT_EXPORT extern const plfit_discrete_options_t plfit_discrete_default_options;

/********** continuous power law distribution fitting **********/

int plfit_log_likelihood_continuous(const double* xs, size_t n, double alpha,
PLFIT_EXPORT int plfit_log_likelihood_continuous(const double* xs, size_t n, double alpha,
double xmin, double* l);
int plfit_estimate_alpha_continuous(const double* xs, size_t n, double xmin,
PLFIT_EXPORT int plfit_estimate_alpha_continuous(const double* xs, size_t n, double xmin,
const plfit_continuous_options_t* options, plfit_result_t* result);
int plfit_continuous(const double* xs, size_t n,
PLFIT_EXPORT int plfit_continuous(const double* xs, size_t n,
const plfit_continuous_options_t* options, plfit_result_t* result);

/*********** discrete power law distribution fitting ***********/

int plfit_estimate_alpha_discrete(const double* xs, size_t n, double xmin,
PLFIT_EXPORT int plfit_estimate_alpha_discrete(const double* xs, size_t n, double xmin,
const plfit_discrete_options_t* options, plfit_result_t *result);
int plfit_log_likelihood_discrete(const double* xs, size_t n, double alpha, double xmin, double* l);
int plfit_discrete(const double* xs, size_t n, const plfit_discrete_options_t* options,
PLFIT_EXPORT int plfit_log_likelihood_discrete(const double* xs, size_t n, double alpha, double xmin, double* l);
PLFIT_EXPORT int plfit_discrete(const double* xs, size_t n, const plfit_discrete_options_t* options,
plfit_result_t* result);

/***** resampling routines to generate synthetic replicates ****/

int plfit_resample_continuous(const double* xs, size_t n, double alpha, double xmin,
PLFIT_EXPORT int plfit_resample_continuous(const double* xs, size_t n, double alpha, double xmin,
size_t num_samples, plfit_mt_rng_t* rng, double* result);
int plfit_resample_discrete(const double* xs, size_t n, double alpha, double xmin,
PLFIT_EXPORT int plfit_resample_discrete(const double* xs, size_t n, double alpha, double xmin,
size_t num_samples, plfit_mt_rng_t* rng, double* result);

/******** calculating the p-value of a fitted model only *******/

int plfit_calculate_p_value_continuous(const double* xs, size_t n,
PLFIT_EXPORT int plfit_calculate_p_value_continuous(const double* xs, size_t n,
const plfit_continuous_options_t* options, plfit_bool_t xmin_fixed,
plfit_result_t *result);
int plfit_calculate_p_value_discrete(const double* xs, size_t n,
PLFIT_EXPORT int plfit_calculate_p_value_discrete(const double* xs, size_t n,
const plfit_discrete_options_t* options, plfit_bool_t xmin_fixed,
plfit_result_t *result);

/************* calculating descriptive statistics **************/

int plfit_moments(const double* data, size_t n, double* mean, double* variance,
PLFIT_EXPORT int plfit_moments(const double* data, size_t n, double* mean, double* variance,
double* skewness, double* kurtosis);

__END_DECLS

#endif /* __PLFIT_H__ */
#endif /* PLFIT_H */
35 changes: 35 additions & 0 deletions src/vendor/cigraph/vendor/plfit/plfit_decls.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* plfit_decls.h
*
* Copyright (C) 2024 Tamas Nepusz
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef PLFIT_DECLS_H
#define PLFIT_DECLS_H

#undef __BEGIN_DECLS
#undef __END_DECLS
#ifdef __cplusplus
#define __BEGIN_DECLS extern "C" {
#define __END_DECLS }
#else
#define __BEGIN_DECLS /* empty */
#define __END_DECLS /* empty */
#endif

#define PLFIT_EXPORT /* empty */

#endif /* PLFIT_DECLS_H */
35 changes: 10 additions & 25 deletions src/vendor/cigraph/vendor/plfit/plfit_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef __ERROR_H__
#define __ERROR_H__
#ifndef PLFIT_ERROR_H
#define PLFIT_ERROR_H

#undef __BEGIN_DECLS
#undef __END_DECLS
#ifdef __cplusplus
# define __BEGIN_DECLS extern "C" {
# define __END_DECLS }
#else
# define __BEGIN_DECLS /* empty */
# define __END_DECLS /* empty */
#endif
#include "plfit_decls.h"

__BEGIN_DECLS

Expand Down Expand Up @@ -66,22 +58,15 @@ enum {

typedef void plfit_error_handler_t(const char*, const char*, int, int);

extern plfit_error_handler_t plfit_error_handler_abort;
extern plfit_error_handler_t plfit_error_handler_ignore;
extern plfit_error_handler_t plfit_error_handler_printignore;

plfit_error_handler_t* plfit_set_error_handler(plfit_error_handler_t* new_handler);
PLFIT_EXPORT extern plfit_error_handler_t plfit_error_handler_abort;
PLFIT_EXPORT extern plfit_error_handler_t plfit_error_handler_ignore;
PLFIT_EXPORT extern plfit_error_handler_t plfit_error_handler_printignore;

void plfit_error(const char *reason, const char *file, int line, int plfit_errno);
const char* plfit_strerror(const int plfit_errno);
PLFIT_EXPORT plfit_error_handler_t* plfit_set_error_handler(plfit_error_handler_t* new_handler);

void plfit_error_handler_abort(const char *reason, const char *file, int line,
int plfit_errno);
void plfit_error_handler_ignore(const char *reason, const char *file, int line,
int plfit_errno);
void plfit_error_handler_printignore(const char *reason, const char *file, int line,
int plfit_errno);
PLFIT_EXPORT void plfit_error(const char *reason, const char *file, int line, int plfit_errno);
PLFIT_EXPORT const char* plfit_strerror(const int plfit_errno);

__END_DECLS

#endif /* __ERROR_H__ */
#endif /* PLFIT_ERROR_H */
25 changes: 8 additions & 17 deletions src/vendor/cigraph/vendor/plfit/plfit_mt.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,11 @@
* This file has been placed in the public domain.
*/

#ifndef __PLFIT_MT_H__
#define __PLFIT_MT_H__
#ifndef PLFIT_MT_H
#define PLFIT_MT_H

#include <stdint.h>

#undef __BEGIN_DECLS
#undef __END_DECLS
#ifdef __cplusplus
# define __BEGIN_DECLS extern "C" {
# define __END_DECLS }
#else
# define __BEGIN_DECLS /* empty */
# define __END_DECLS /* empty */
#endif
#include "plfit_decls.h"

__BEGIN_DECLS

Expand Down Expand Up @@ -55,7 +46,7 @@ typedef struct {
*
* \param rng the random number generator to initialize
*/
void plfit_mt_init(plfit_mt_rng_t* rng);
PLFIT_EXPORT void plfit_mt_init(plfit_mt_rng_t* rng);

/**
* \brief Initializes a Mersenne Twister random number generator, seeding it
Expand All @@ -70,7 +61,7 @@ void plfit_mt_init(plfit_mt_rng_t* rng);
* be initialized from the built-in RNG as if \ref plfit_mt_init()
* was called.
*/
void plfit_mt_init_from_rng(plfit_mt_rng_t* rng, plfit_mt_rng_t* seeder);
PLFIT_EXPORT void plfit_mt_init_from_rng(plfit_mt_rng_t* rng, plfit_mt_rng_t* seeder);

/**
* \brief Returns the next 32-bit random number from the given Mersenne Twister
Expand All @@ -79,7 +70,7 @@ void plfit_mt_init_from_rng(plfit_mt_rng_t* rng, plfit_mt_rng_t* seeder);
* \param rng the random number generator to use
* \return the next 32-bit random number from the generator
*/
uint32_t plfit_mt_random(plfit_mt_rng_t* rng);
PLFIT_EXPORT uint32_t plfit_mt_random(plfit_mt_rng_t* rng);

/**
* \brief Returns a uniformly distributed double from the interval [0;1)
Expand All @@ -89,8 +80,8 @@ uint32_t plfit_mt_random(plfit_mt_rng_t* rng);
* \param rng the random number generator to use
* \return a uniformly distributed random number from the interval [0;1)
*/
double plfit_mt_uniform_01(plfit_mt_rng_t* rng);
PLFIT_EXPORT double plfit_mt_uniform_01(plfit_mt_rng_t* rng);

__END_DECLS

#endif
#endif /* PLFIT_MT_H */
Loading

0 comments on commit f4098d2

Please sign in to comment.