chebyshev

Chebyshev approximation.

Pure Nim score 30/100 · tests present · docs generated

Summary

Latest Version Unknown
License MIT
CI Status Passing
Downloads 0
Last Indexed 2026-07-21 05:24

Installation

nimble install chebyshev
choosenim install chebyshev
git clone https://github.com/jxy/chebyshev

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
chebyshev - - - - - - -

Source

Repository https://github.com/jxy/chebyshev
Homepage https://github.com/jxy/chebyshev
Documentation View Documentation
Registry Source nimble_official

README

Chebyshev approximation in Nim

This module implements Chebyshev polynomial approximation to an interval of a function. The approximation works for a single variable, and also for large scale sparse matrix operations as well.

User has to define a set of operations, specifically, apply, assign, and newOneOf, to be able to use the interface. When concept in Nim matures, we will use concept to enforce those.

See the end of the source code of this module for examples of use cases.

Types

Chebyshev = object
  coef*: seq[float]            ## Coefficients.
  center*, halfwidth*: float   ## Center and half width of the approximation interval.
  degree*: int                 ## Degree of the approximation.

Parameters for Chebyshev approximation.

Templates

template newChebyshev(ab: Slice[float]; n: int; fx: untyped): Chebyshev

Create a Chebyshev object with computed coefficients, given
the interval as in [a, b], maximum degree n, and the
function, fx given as an expression of type float, which uses
x as the parameter of type float.

template apply(chebyshev: Chebyshev; res: typed; op: typed; arg: typed)

Apply the chebyshev approximation of an Operator, op, on an
argument arg. The return type is the same as the arg. A proc
apply must be defined for op, as op.apply(output,input).

template chebyshevT(res: typed; n: int; op: typed; arg: typed)

Apply the Chebyshev polynomial of the first kind with degree,
n, of the operator op to the operand arg, and save the result
in res.

License

MIT license.  See the file, LICENSE, for detail.