Program Listing for File cmb_dataset.h
↰ Return to documentation for file (include/cmb_dataset.h)
/*
*
* Copyright (c) Asbjørn M. Bonvik 1994, 1995, 2025-26.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CIMBA_CMB_DATASET_H
#define CIMBA_CMB_DATASET_H
#include "cmb_assert.h"
#include "cmb_datasummary.h"
/* May not always get defined from math.h, but we need it here */
#ifndef M_PI
#define M_PI 3.14159265358979323
#endif
struct cmb_dataset {
uint64_t cookie;
uint64_t cursize;
uint64_t count;
double min;
double max;
double *xa;
};
extern struct cmb_dataset *cmb_dataset_create(void);
extern void cmb_dataset_initialize(struct cmb_dataset *dsp);
extern void cmb_dataset_reset(struct cmb_dataset *dsp);
extern void cmb_dataset_terminate(struct cmb_dataset *dsp);
extern uint64_t cmb_dataset_copy(struct cmb_dataset *tgt,
const struct cmb_dataset *src);
extern uint64_t cmb_dataset_merge(struct cmb_dataset *tgt,
const struct cmb_dataset *s1,
const struct cmb_dataset *s2);
extern void cmb_dataset_destroy(struct cmb_dataset *dsp);
extern void cmb_dataset_sort(const struct cmb_dataset *dsp);
extern uint64_t cmb_dataset_add(struct cmb_dataset *dsp, double x);
extern uint64_t cmb_dataset_summarize(const struct cmb_dataset *dsp,
struct cmb_datasummary *dsump);
[[maybe_unused]]
static inline uint64_t cmb_dataset_count(const struct cmb_dataset *dsp)
{
cmb_assert_release(dsp != NULL);
return dsp->count;
}
[[maybe_unused]]
static inline double cmb_dataset_min(const struct cmb_dataset *dsp)
{
cmb_assert_release(dsp != NULL);
return dsp->min;
}
[[maybe_unused]]
static inline double cmb_dataset_max(const struct cmb_dataset *dsp)
{
cmb_assert_release(dsp != NULL);
return dsp->max;
}
extern double cmb_dataset_median(const struct cmb_dataset *dsp);
extern void cmb_dataset_fivenum_print(const struct cmb_dataset *dsp,
FILE *fp,
bool lead_ins);
extern void cmb_dataset_histogram_print(const struct cmb_dataset *dsp,
FILE *fp,
unsigned num_bins,
double low_lim,
double high_lim);
extern void cmb_dataset_print(const struct cmb_dataset *dsp, FILE *fp);
extern void cmb_dataset_ACF(const struct cmb_dataset *dsp,
unsigned n,
double *acf);
extern void cmb_dataset_PACF(const struct cmb_dataset *dsp,
unsigned n,
double *pacf,
double *acf);
extern void cmb_dataset_correlogram_print(const struct cmb_dataset *dsp,
FILE *fp,
unsigned n,
double *acf);
#endif /* CIMBA_CMB_DATASET_H */