Skip to content
ScientificDataFormatPublic

About

A C library to inter- and extrapolate multi-dimensional data

Resources

Stars

1 star

Watchers

2 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

NDTable

A C library to inter- and extrapolate values on regular N-dimensional grids.

Highlights

  • pure C — no dependencies
  • multi-dimensional — up to 32 dimensions
  • interpolation — hold, nearest, linear, Akima, Fritsch–Butland, Steffen
  • extrapolation — hold, linear, none
  • derivatives — partial derivatives w.r.t all dimensions

Quick start

#include "NDTable.h"

int main(void) {
    int ndims = 1;
    int dims[] = { 3 };
    double data[] = { 0.0, 1.0, 4.0 };
    const double *scales[] = { (const double[]){ 0.0, 1.0, 2.0 } };

    NDTable_h table = NDTable_create_table(ndims, dims, data, scales);
    if (!table) {
        return 1;
    }

    double params[] = { 1.5 };
    double value = 0.0;
    double derivative = 0.0;

    if (NDTable_evaluate(table, params, 0, NDTABLE_INTERP_LINEAR, NDTABLE_EXTRAP_HOLD, &value, &derivative) == 0) {
        /* value ≈ 2.5 at x = 1.5 with linear interpolation */
    }

    NDTable_free_table(table);
    return 0;
}

License

NDTable is released under the BSD-2-Clause license.

About

A C library to inter- and extrapolate multi-dimensional data

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages