{"id":18847762,"url":"https://github.com/jacobwilliams/bspline-fortran","last_synced_at":"2026-01-27T03:03:32.819Z","repository":{"id":27810121,"uuid":"31299552","full_name":"jacobwilliams/bspline-fortran","owner":"jacobwilliams","description":"Multidimensional B-Spline Interpolation of Data on a Regular Grid","archived":false,"fork":false,"pushed_at":"2024-01-07T03:23:06.000Z","size":19553,"stargazers_count":176,"open_issues_count":12,"forks_count":55,"subscribers_count":22,"default_branch":"master","last_synced_at":"2024-12-30T13:56:38.558Z","etag":null,"topics":["b-spline","extrapolation","fortran","fortran-package-manager","interpolation","least-squares-curve-fitting","quadrature-integration","splines"],"latest_commit_sha":null,"homepage":"","language":"Fortran","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jacobwilliams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-02-25T05:58:13.000Z","updated_at":"2024-12-19T12:34:06.000Z","dependencies_parsed_at":"2023-10-14T17:05:35.330Z","dependency_job_id":"5659cbbe-2f71-419b-abb6-b8bd879389bb","html_url":"https://github.com/jacobwilliams/bspline-fortran","commit_stats":{"total_commits":225,"total_committers":3,"mean_commits":75.0,"dds":0.03555555555555556,"last_synced_commit":"85cbfe19d5ab2fd07b4424f2a0baa62045a0fafa"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobwilliams%2Fbspline-fortran","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobwilliams%2Fbspline-fortran/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobwilliams%2Fbspline-fortran/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacobwilliams%2Fbspline-fortran/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jacobwilliams","download_url":"https://codeload.github.com/jacobwilliams/bspline-fortran/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239783780,"owners_count":19696439,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["b-spline","extrapolation","fortran","fortran-package-manager","interpolation","least-squares-curve-fitting","quadrature-integration","splines"],"created_at":"2024-11-08T03:09:33.998Z","updated_at":"2026-01-27T03:03:32.787Z","avatar_url":"https://github.com/jacobwilliams.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"![bspline-fortran](media/bspline-fortran.png)\n============\n\nMultidimensional B-Spline Interpolation of Data on a Regular Grid.\n\n## Status\n[![Language](https://img.shields.io/badge/-Fortran-734f96?logo=fortran\u0026logoColor=white)](https://github.com/topics/fortran)\n[![GitHub release](https://img.shields.io/github/release/jacobwilliams/bspline-fortran.svg)](https://github.com/jacobwilliams/bspline-fortran/releases/latest)\n[![Build Status](https://github.com/jacobwilliams/bspline-fortran/actions/workflows/CI.yml/badge.svg)](https://github.com/jacobwilliams/bspline-fortran/actions)\n[![codecov](https://codecov.io/gh/jacobwilliams/bspline-fortran/branch/master/graph/badge.svg)](https://codecov.io/gh/jacobwilliams/bspline-fortran)\n[![last-commit](https://img.shields.io/github/last-commit/jacobwilliams/bspline-fortran)](https://github.com/jacobwilliams/bspline-fortran/commits/master)\n[![DOI](https://zenodo.org/badge/31299552.svg)](https://zenodo.org/badge/latestdoi/31299552)\n\n## Brief description\n\nThe library provides subroutines for 1D-6D interpolation and extrapolation using B-splines. The code is written in modern Fortran (i.e., Fortran 2003+). There are two ways to use the module, via a basic subroutine interface and an object-oriented interface. Both are thread safe.\n\n## Subroutine interface\n\nThe core routines for the subroutine interface are:\n\n```fortran\n!f(x)\nsubroutine db1ink(x,nx,fcn,kx,iknot,tx,bcoef,iflag)\nsubroutine db1val(xval,idx,tx,nx,kx,bcoef,f,iflag,inbvx,w0,extrap)\n\n!f(x,y)\nsubroutine db2ink(x,nx,y,ny,fcn,kx,ky,iknot,tx,ty,bcoef,iflag)\nsubroutine db2val(xval,yval,idx,idy,tx,ty,nx,ny,kx,ky,bcoef,f,iflag,inbvx,inbvy,iloy,w1,w0,extrap)\n\n!f(x,y,z)\nsubroutine db3ink(x,nx,y,ny,z,nz,fcn,kx,ky,kz,iknot,tx,ty,tz,bcoef,iflag)\nsubroutine db3val(xval,yval,zval,idx,idy,idz,tx,ty,tz,nx,ny,nz,kx,ky,kz,bcoef,f,iflag,inbvx,inbvy,inbvz,iloy,iloz,w2,w1,w0,extrap)\n\n!f(x,y,z,q)\nsubroutine db4ink(x,nx,y,ny,z,nz,q,nq,fcn,kx,ky,kz,kq,iknot,tx,ty,tz,tq,bcoef,iflag)\nsubroutine db4val(xval,yval,zval,qval,idx,idy,idz,idq,tx,ty,tz,tq,nx,ny,nz,nq,kx,ky,kz,kq,bcoef,f,iflag,inbvx,inbvy,inbvz,inbvq,iloy,iloz,iloq,w3,w2,w1,w0,extrap)\n\n!f(x,y,z,q,r)\nsubroutine db5ink(x,nx,y,ny,z,nz,q,nq,r,nr,fcn,kx,ky,kz,kq,kr,iknot,tx,ty,tz,tq,tr,bcoef,iflag)\nsubroutine db5val(xval,yval,zval,qval,rval,idx,idy,idz,idq,idr,tx,ty,tz,tq,tr,nx,ny,nz,nq,nr,kx,ky,kz,kq,kr,bcoef,f,iflag,inbvx,inbvy,inbvz,inbvq,inbvr,iloy,iloz,iloq,ilor,w4,w3,w2,w1,w0,extrap)\n\n!f(x,y,z,q,r,s)\nsubroutine db6ink(x,nx,y,ny,z,nz,q,nq,r,nr,s,ns,fcn,kx,ky,kz,kq,kr,ks,iknot,tx,ty,tz,tq,tr,ts,bcoef,iflag)\nsubroutine db6val(xval,yval,zval,qval,rval,sval,idx,idy,idz,idq,idr,ids,tx,ty,tz,tq,tr,ts,nx,ny,nz,nq,nr,ns,kx,ky,kz,kq,kr,ks,bcoef,f,iflag,inbvx,inbvy,inbvz,inbvq,inbvr,inbvs,iloy,iloz,iloq,ilor,ilos,w5,w4,w3,w2,w1,w0,extrap)\n```\n\nThe ```ink``` routines compute the interpolant coefficients, and the ```val``` routines evalute the interpolant at the specified value of each coordinate. The 2D and 3D routines are extensively refactored versions of the original routines from the [NIST Core Math Library](http://www.nist.gov/itl/math/mcsd-software.cfm).  The others are new, and are simply extensions of the same algorithm into the other dimensions.\n\n## Object-oriented interface\n\nIn addition to the main subroutines, an object-oriented interface is also provided. For example, for the 3D case:\n\n```Fortran\ntype(bspline_3d) :: s\ncall s%initialize(x,y,z,fcn,kx,ky,kz,iflag,extrap)\ncall s%evaluate(xval,yval,zval,idx,idy,idz,f,iflag)\ncall s%destroy()\n```\nWhich uses the default \"not-a-knot\" end conditions. You can also specify the knot vectors (in this case, `tx`, `ty`, and `tz`) manually during class initialization:\n\n```Fortran\ncall s%initialize(x,y,z,fcn,kx,ky,kz,tx,ty,tz,iflag,extrap)\n```\n\nThe various bspline classes can also be initialized using constructors, which have similar interfaces as the `initialize` methods. For example:\n\n```Fortran\ntype(bspline_3d) :: s\ns = bspline_3d(x,y,z,fcn,kx,ky,kz,iflag,extrap)\n```\n\n## Spline order\n\nThe various `k` inputs (i.e., `kx`, `ky`, etc.) specify the spline order for each dimension. The order is the polynomial degree + 1. For example:\n\n* `k=2` : Linear\n* `k=3` : Quadratic\n* `k=4` : Cubic\n* etc.\n\n## Extrapolation\n\nThe library optionally supports extrapolation for points outside the range of the coefficients. This is disabled by default (in which case an error code is returned for points outside the bounds). To enable extrapolation, use the optional `extrap` input to the various `db*val` subroutines or the `initialize` methods from the object-oriented interface.\n\n## Integration\n\nThe library also contains routines for computing definite integrals of bsplines. There are two methods (currently only for 1D):\n\n* Basic version: `db1sqad` (`integral` in the object-oriented interface) -- Computes the integral on `(x1,x2)` of a b-spline by applying a 2, 6, or 10 point Gauss formula on subintervals of `(x1,x2)`. This is only valid for orders \u003c= 20.\n* More general version: `db1fqad` (`fintegral` in the object-oriented interface) -- Computes the integral on `(x1,x2)` of a product of a user-defined function `fun(x)` and the ith derivative of a b-spline with an adaptive 8-point Legendre-Gauss algorithm.\n\nNote that extrapolation is not currently supported for these.\n\n## Least squares fitting\n\nThe BSpline-Fortran library also exports the `defc` subroutine, which can be used to fit B-spline polynomials to 1D data using a weighted least squares method. The `dfc` subroutine also allows for equality and inequality constraints to be imposed on the fitted curve. These procedures are not yet available in the object oriented interface.\n\n## Examples\n\nSee the [examples](https://github.com/jacobwilliams/bspline-fortran/tree/master/test) for more details. Note that, to compile and run some of the test programs, the [pyplot-fortran](https://github.com/jacobwilliams/pyplot-fortran) library  (which is used to generate plots) is required. This will automatically be downloaded by `FPM`.\n\n## Compiling\n\nThe library can be compiled with recent versions the Intel Fortran Compiler and GFortran (and presumably any other Fortran compiler that supports modern standards).\n\n### FPM\n\nA `fpm.toml` file is provided for compiling bspline-fortran with the [Fortran Package Manager](https://github.com/fortran-lang/fpm). For example, to build:\n\n```\nfpm build --profile release\n```\n\nBy default, the library is built with double precision (`real64`) real values and single precision (`int32`) integer values. Explicitly specifying the real or integer kinds can be done using the following processor flags:\n\nPreprocessor flag | Kind  | Number of bytes\n----------------- | ----- | ---------------\n`REAL32`  | `real(kind=real32)`  | 4\n`REAL64`  | `real(kind=real64)`  | 8\n`REAL128` | `real(kind=real128)` | 16\n\nPreprocessor flag | Kind  | Number of bytes\n----------------- | ----- | ---------------\n`INT8`  | `integer(kind=int8)`  | 1\n`INT16`  | `integer(kind=int16)`  | 2\n`INT32` | `integer(kind=int32)` | 4\n`INT64` | `integer(kind=int64)` | 8\n\nFor example, to build a single precision version of the library, use:\n\n```\nfpm build --profile release --flag \"-DREAL32\"\n```\n\nTo run the unit tests:\n\n```\nfpm test --profile release\n```\n\nTo use `bspline-fortran` within your fpm project, add the following to your `fpm.toml` file:\n```toml\n[dependencies]\nbspline-fortran = { git=\"https://github.com/jacobwilliams/bspline-fortran.git\" }\n```\n\nor, to use a specific version:\n```toml\n[dependencies]\nbspline-fortran = { git=\"https://github.com/jacobwilliams/bspline-fortran.git\", tag = \"7.3.0\"  }\n```\n\n### CMake\nA basic CMake configuration file is also included. For example, to build a static library:\n\n```bash\n cmake -S. -Bbuild\n cmake --build build\n```\n\nOr, to build a shared library, replace the first CMake command with:\n\n```bash\n cmake -S. -Bbuild -DBUILD_SHARED_LIBS=ON ..\n```\n\nFor a debug build:\n```bash\n cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=DEBUG ..\n```\n\n## Dependencies\n\nThe library requires some [BLAS](https://netlib.org/blas/) routines, which are included. However, the user may also choose to link to an external BLAS library. This can be done by using the `HAS_BLAS` compiler directive. For example:\n\n```\nfpm build --compiler gfortran --flag \"-DHAS_BLAS -lblas\"\n```\n\nHowever, note that an external BLAS can only be used if the library is compiled with double precision (`real64`) reals.\n\n## Documentation\n\nThe latest API documentation can be found [here](https://jacobwilliams.github.io/bspline-fortran/). This was generated from the source code using [FORD](https://github.com/Fortran-FOSS-Programmers/ford) (i.e. by running `ford ford.md`).\n\n## License\n\nThe bspline-fortran source code and related files and documentation are distributed under a permissive free software [license](https://github.com/jacobwilliams/bspline-fortran/blob/master/LICENSE) (BSD-style).\n\n### Keywords\n\n* Bspline, spline, interpolation, data fitting, multivariate interpolation, multidimensional interpolation, integration\n\n## See also\n\n * This library includes the public domain DBSPLIN and DTENSBS code from the [NIST Core Math Library](http://www.nist.gov/itl/math/mcsd-software.cfm) (CMLIB).\n * [SPLPAK](https://github.com/jacobwilliams/splpak) Multidimensional least-squares cubic spline fitting\n * [FINTERP](https://github.com/jacobwilliams/finterp) Multidimensional Linear Interpolation with Modern Fortran\n * [PCHIP](https://github.com/jacobwilliams/PCHIP) Piecewise Cubic Hermite Interpolation.\n * [Regridpack](https://github.com/jacobwilliams/regridpack) Linear or cubic interpolation for 1D-4D grids.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobwilliams%2Fbspline-fortran","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacobwilliams%2Fbspline-fortran","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacobwilliams%2Fbspline-fortran/lists"}