Spline Padding [module]

Here are the functions of the module splinekit.spline_padding.

splinekit.spline_padding.pad_p(data: ndarray[tuple[int], dtype[float64]], *, at: int) float

Periodic padding.

Returns the value of the \(k\)-th data sample after the data have been extended by periodic padding. The padded data \(f\) satisfy that

\[\forall k\in{\mathbb{Z}}:f[k]=f[k+K],\]

where \(K\) is the length of the unpadded data.

Periodic padding of data samples
k   ƒ1[k]ƒ2[k]ƒ3[k]ƒ4[k]ƒ5[k]ƒ6[k]
−20aabaae
−19abcbbf
−18aaacca
−17abbddb
−16aacaec
−15ababad
−14aabcbe
−13abcdcf
−12aaaada
−11abbbeb
−10aaccac
−9abadbd
−8aabace
−7abcbdf
−6aaacea
−5abbdab
−4aacabc
−3ababcd
−2aabcde
−1abcdef
0AAAAAA
1aBBBBB
2aaCCCC
3abaDDD
4aabaEE
5abcbaF
6aaacba
7abbdcb
8aacadc
9ababed
10aabcae
11abcdbf
12aaaaca
13abbbdb
14aaccec
15abadad
16aababe
17abcbcf
18aaacda
19abbdeb
20aacaac
21ababbd
22aabcce
23abcddf
24aaaaea
25abbbab
26aaccbc
27abadcd
28aabade
29abcbef

Parameters:
  • data (np.ndarray[tuple[int], np.dtype[np.float64]],) – Data to extend.

  • at (int) – Arbitrary index.

Returns:

The value of the padded data at the requested index.

Return type:

float

Examples

Load the library.
>>> import splinekit as sk
Short data at large index -42.
>>> sk.pad_p([1, 5, -3], at = -42)
1

splinekit.spline_padding.change_basis_p(data: ndarray[tuple[int], dtype[float64]], *, degree: int, source_basis: Bases, target_basis: Bases) None

In-place conversion of data coefficients from one spline basis to another, under periodic padding.

At input time, data is a one-dimensional numpy.ndarray of coefficients that is expressing the periodic uniform spline \(f\) of nonnegative degree \(n\) as a weighted sum of integer-shifted bases of the type source_basis.

At output time, data is a one-dimensional numpy.ndarray of coefficients that is expressing the same spline \(f\) as a weighted sum of integer-shifted bases of the type target_basis.

Parameters:
  • data (np.ndarray[tuple[int], np.dtype[np.float64]],) – Data to convert from one basis to another.

  • degree (int) – Nonnegative degree of the polynomial spline.

  • source_basis (int) – Type of the basis at input time.

  • target_basis (int) – Type of the basis at output time.

Returns:

The returned coefficients overwrite data.

Return type:

None

Examples

Load the libraries.
>>> import numpy as np
>>> import splinekit as sk
Arbitrary data samples with periodic padding.
>>> f = np.array([1, 5, -3], dtype = "float")
Cubic coefficients.
>>> c = f.copy()
>>> sk.change_basis_p(c, degree = 3, source_basis = sk.Bases.CARDINAL, target_basis = sk.Bases.BASIC)
>>> print(c)
[ 1.  9. -7.]

Notes

The computations are performed in-place.


splinekit.spline_padding.samples_to_coeff_p(data: ndarray[tuple[int], dtype[float64]], *, degree: int, pure_python: bool = False) None

In-place conversion of data samples into spline coefficients under periodic padding.

Replaces a one-dimensional numpy.ndarray of data samples \(f\) by spline coefficients \(c\) such that

\[\forall k\in[0\ldots K-1]:f[k]=\sum_{q\in{\mathbb{Z}}}\,c[q]\, \beta^{n}(k-q),\]

where \(K\) is the length of the provided data and \(\beta^{n}\) is a polynomial B-spline of nonnegative degree \(n.\) The data samples are assumed to conform to a periodic padding.

Parameters:
  • data (np.ndarray[tuple[int], np.dtype[np.float64]],) – Data to convert from samples to coefficients.

  • degree (int) – Nonnegative degree of the polynomial B-spline.

  • pure_python (bool) – The directive that forces the computations to be performed in Python.

Returns:

The returned coefficients overwrite data.

Return type:

None

Examples

Load the libraries.
>>> import numpy as np
>>> import splinekit as sk
Arbitrary data samples with periodic padding.
>>> f = np.array([1, 5, -3], dtype = "float")
Cubic coefficients.
>>> c = f.copy()
>>> sk.samples_to_coeff_p(c, degree = 3)
>>> print(c)
[ 1.  9. -7.]

Notes

The computations are performed in-place.


splinekit.spline_padding.coeff_to_samples_p(data: ndarray[tuple[int], dtype[float64]], *, degree: int) None

In-place conversion of spline coefficients into data samples under periodic padding.

Replaces a one-dimensional numpy.ndarray of spline coefficietnts \(c\) by data samples \(f\) such that

\[\forall k\in[0\ldots K-1]:\sum_{q\in{\mathbb{Z}}}\,c[q]\, \beta^{n}(k-q)=f[k],\]

where \(K\) is the length of the provided data and \(\beta^{n}\) is a polynomial B-spline of nonnegative degree \(n.\) The spline coefficients are assumed to conform to a periodic padding.

Parameters:
  • data (np.ndarray[tuple[int], np.dtype[np.float64]],) – Data to convert from coefficients to samples.

  • degree (int) – Nonnegative degree of the polynomial B-spline.

Returns:

The returned data samples overwrite data.

Return type:

None

Examples

Load the libraries.
>>> import numpy as np
>>> import splinekit as sk
Arbitrary spline coefficients with periodic padding.
>>> c = np.array([1, 9, -7], dtype = "float")
Data samples.
>>> f = c.copy()
>>> sk.coeff_to_samples_p(f, degree = 3)
>>> print(f)
[ 1.  5. -3.]

Notes

The computations are performed in-place.


splinekit.spline_padding.coeff_to_ortho_p(data: ndarray[tuple[int], dtype[float64]], *, degree: int) None

In-place conversion of B-spline coefficients into orthonormal-spline coefficients under periodic padding.

Replaces a one-dimensional numpy.ndarray of spline coefficients \(c\) by orthonormal-spline coefficients \(g\) such that

\[\forall x\in{\mathbb{R}}:\sum_{q\in{\mathbb{Z}}}\,c[q]\, \beta^{n}(x-q)=\sum_{q\in{\mathbb{Z}}}\,g[q]\,\phi^{n}(x-q),\]

where \(K\) is the length of the provided data, \(\beta^{n}\) is is a polynomial B-spline of nonnegative degree \(n,\) and \(\phi^{n}\) is an orthonormal polynomial spline. The spline coefficients are assumed to conform to a periodic padding of period \(K.\)

Parameters:
  • data (np.ndarray[tuple[int], np.dtype[np.float64]],) – Data to convert from spline coefficients to orthonormal coefficients.

  • degree (int) – Nonnegative degree of the polynomial B-spline.

Returns:

The returned coefficients overwrite data.

Return type:

None

Examples

Load the libraries.
>>> import numpy as np
>>> import splinekit as sk
Arbitrary cubic dual-spline coefficients with periodic padding.
>>> a1 = np.array([1, 2.75714286, -0.75714286], dtype = "float")
Spline coefficients.
>>> c = a1.copy()
>>> sk.samples_to_coeff_p(c, degree = 2 * 3 + 1)
Orthonormal coefficients.
>>> g = c.copy()
>>> sk.coeff_to_ortho_p(g, degree = 3)
The re-application of coeff_to_ortho_p yields back the dual coefficients, up to numerical accuracy.
>>> a2 = g.copy()
>>> sk.coeff_to_ortho_p(a2, degree = 3)
>>> print(a1 - a2)
[-2.22044605e-16 -1.06581410e-14  1.18793864e-14]

Notes

The computations are performed in-place.


splinekit.spline_padding.ortho_to_coeff_p(data: ndarray[tuple[int], dtype[float64]], *, degree: int) None

In-place conversion of orthonormal-spline coefficients into B-spline coefficients under periodic padding.

Replaces a one-dimensional numpy.ndarray of orthonormal spline coefficients \(g\) by B-spline coefficients \(c\) such that

\[\forall x\in{\mathbb{R}}:\sum_{q\in{\mathbb{Z}}}\,g[q]\, \phi^{n}(x-q)=\sum_{q\in{\mathbb{Z}}}\,c[q]\,\beta^{n}(x-q),\]

where \(K\) is the length of the provided data, \(\phi^{n}\) is an orthonormal polynomial spline of nonnegative degree \(n,\) and \(\beta^{n}\) is a polynomial B-spline. The orthonormal spline coefficients are assumed to conform to a periodic padding of period \(K.\)

Parameters:
  • data (np.ndarray[tuple[int], np.dtype[np.float64]],) – Data to convert from orthonormal coefficients to spline coefficients.

  • degree (int) – Nonnegative degree of the polynomial orthonormal-spline.

Returns:

The returned coefficients overwrite data.

Return type:

None

Examples

Load the libraries.
>>> import numpy as np
>>> import splinekit as sk
Arbitrary cubic spline coefficients with periodic padding.
>>> c1 = np.array([1, 9, -7], dtype = "float")
Dual-spline coefficients.
>>> a = c1.copy()
>>> sk.coeff_to_samples_p(a, degree = 2 * 3 + 1)
Orthonormal coefficients.
>>> g1 = a.copy()
>>> sk.ortho_to_coeff_p(g1, degree = 3)
The re-application of ortho_to_coeff_p yields back the spline coefficients, up to numerical accuracy.
>>> g2 = g1.copy()
>>> sk.ortho_to_coeff_p(g2, degree = 3)
>>> print(c1 - g2)
[ 3.33066907e-16  3.55271368e-15 -2.66453526e-15]

Notes

The computations are performed in-place.


splinekit.spline_padding.pad_n(data: ndarray[tuple[int], dtype[float64]], *, at: int) float

Narrow-mirror padding.

Returns the value of the \(k\)-th data sample after the data have been extended by narrow-mirror padding. The padded data \(f\) satisfy that

\[\begin{split}\forall k\in{\mathbb{Z}}:f[k]=\left\{\begin{array}{rcl}f[k]&=&f[-k]\\ f[k+K-1]&=&f[K-1-k],\end{array}\right.\end{split}\]

where \(K\) is the length of the unpadded data. The conditions of narrow-mirror padding imply the periodicity

\[\forall k\in{\mathbb{Z}}:f[k]=f[k+2\,K-2].\]

Narrow-mirror padding of data samples
k   ƒ1[k]ƒ2[k]ƒ3[k]ƒ4[k]ƒ5[k]ƒ6[k]
−20aaacea
−19abbbdb
−18aacacc
−17abbbbd
−16aaacae
−15abbdbf
−14aaccce
−13abbbdd
−12aaaaec
−11abbbdb
−10aaccca
−9abbdbb
−8aaacac
−7abbbbd
−6aacace
−5abbbdf
−4aaacee
−3abbddd
−2aacccc
−1abbbbb
0AAAAAA
1aBBBBB
2aaCCCC
3abbDDD
4aaacEE
5abbbdF
6aacace
7abbbbd
8aaacac
9abbdbb
10aaccca
11abbbdb
12aaaaec
13abbbdd
14aaccce
15abbdbf
16aaacae
17abbbbd
18aacacc
19abbbdb
20aaacea
21abbddb
22aacccc
23abbbbd
24aaaaae
25abbbbf
26aaccce
27abbddd
28aaacec
29abbbdb

Parameters:
  • data (np.ndarray[tuple[int], np.dtype[np.float64]],) – Data to extend.

  • at (int) – Arbitrary index.

Returns:

The value of the padded data at the requested index.

Return type:

float

Examples

Load the library.
>>> import splinekit as sk
Short data at large index -42.
>>> sk.pad_n([1, 5, -3], at = -42)
-3

splinekit.spline_padding.samples_to_coeff_n(data: ndarray[tuple[int], dtype[float64]], *, degree: int, pure_python: bool = False) None

In-place conversion of data samples into spline coefficients under narrow-mirror padding.

Replaces a one-dimensional numpy.ndarray of data samples \(f\) by spline coefficients \(c\) such that

\[\forall k\in[0\ldots K-1]:f[k]=\sum_{q\in{\mathbb{Z}}}\,c[q]\, \beta^{n}(k-q),\]

where \(K\) is the length of the provided data and \(\beta^{n}\) is a polynomial B-spline of nonnegative degree \(n.\) The spline coefficients are assumed to conform to a narrow-mirror padding.

Parameters:
  • data (np.ndarray[tuple[int], np.dtype[np.float64]],) – Data to convert from samples to coefficients.

  • degree (int) – Nonnegative degree of the polynomial B-spline.

  • pure_python (bool) – The directive that forces the computations to be performed in Python.

Returns:

The returned coefficients overwrite data.

Return type:

None

Examples

Load the libraries.
>>> import numpy as np
>>> import splinekit as sk
Cubic coefficients of arbitrary data with narrow-mirror padding.
>>> f = np.array([1, 5, -3], dtype = "float")
>>> c = f.copy()
>>> sk.samples_to_coeff_n(c, degree = 3)
>>> print(c)
[ -4.  11. -10.]

Notes

The computations are performed in-place.


splinekit.spline_padding.pad_w(data: ndarray[tuple[int], dtype[float64]], *, at: int) float

Wide-mirror padding.

Returns the value of the \(k\)-th data sample after the data have been extended by wide-mirror padding. The padded data \(f\) satisfy that

\[\begin{split}\forall k\in{\mathbb{Z}}:\left\{\begin{array}{rcl}f[x]&=&f[-1-x]\\ f[x+K]&=&f[K-1-x],\end{array}\right.\end{split}\]

where \(K\) is the length of the unpadded data. The conditions of wide-mirror padding imply the periodicity

\[\forall k\in{\mathbb{Z}}:f[k]=f[k+2\,K].\]

Wide-mirror padding of data samples
k   ƒ1[k]ƒ2[k]ƒ3[k]ƒ4[k]ƒ5[k]ƒ6[k]
−20aabdae
−19abacbf
−18ababcf
−17aabade
−16aacaed
−15abcbec
−14abbcdb
−13aaadca
−12aaadba
−11abbcab
−10abcbac
−9aacabd
−8aabace
−7ababdf
−6abacef
−5aabdee
−4aacddd
−3abcccc
−2abbbbb
−1aaaaaa
0AAAAAA
1aBBBBB
2abCCCC
3aacDDD
4aabdEE
5abaceF
6ababdf
7aabace
8aacabd
9abcbac
10abbcab
11aaadba
12aaadca
13abbcdb
14abcbec
15aacaed
16aabade
17ababcf
18abacbf
19aabdae
20aacdad
21abccbc
22abbbcb
23aaaada
24aaaaea
25abbbeb
26abccdc
27aacdcd
28aabdbe
29abacaf

Parameters:
  • data (np.ndarray[tuple[int], np.dtype[np.float64]],) – Data to extend.

  • at (int) – Arbitrary index.

Returns:

The value of the padded data at the requested index.

Return type:

float

Examples

Load the library.
>>> import splinekit as sk
Short data at large index -42.
>>> sk.pad_w([1, 5, -3], at = -42)
1

splinekit.spline_padding.samples_to_coeff_w(data: ndarray[tuple[int], dtype[float64]], *, degree: int, pure_python: bool = False) None

In-place conversion of data samples into spline coefficients under wide-mirror padding.

Replaces a one-dimensional numpy.ndarray of data samples \(f\) by spline coefficients \(c\) such that

\[\forall k\in[0\ldots K-1]:f[k]=\sum_{q\in{\mathbb{Z}}}\,c[q]\, \beta^{n}(k-q),\]

where \(K\) is the length of the provided data and \(\beta^{n}\) is a polynomial B-spline of nonnegative degree \(n.\) The spline coefficients are assumed to conform to a wide-mirror padding.

Parameters:
  • data (np.ndarray[tuple[int], np.dtype[np.float64]],) – Data to convert from samples to coefficients.

  • degree (int) – Nonnegative degree of the polynomial B-spline.

  • pure_python (bool) – The directive that forces the computations to be performed in Python.

Returns:

The returned coefficients overwrite data.

Return type:

None

Examples

Load the libraries.
>>> import numpy as np
>>> import splinekit as sk
Cubic coefficients of arbitrary data with wide-mirror padding.
>>> f = np.array([1, 5, -3], dtype = "float")
>>> c = f.copy()
>>> sk.samples_to_coeff_w(c, degree = 3)
>>> print(c)
[-0.6  9.  -5.4]

Notes

The computations are performed in-place.


splinekit.spline_padding.pad_a(data: ndarray[tuple[int], dtype[float64]], *, at: int) float

Anti-mirror padding.

Returns the value of the \(k\)-th data sample after the data have been extended by anti-mirror padding. The padded data \(f\) satisfy that

\[\begin{split}\forall k\in{\mathbb{Z}}:\left\{\begin{array}{rcl} f[k]-f[0]&=&f[0]-f[-k]\\ f[k+K-1]-f[K-1]&=&f[K-1]-f[K-1-k]\end{array}\right.\end{split}\]

where \(K\) is the length of the unpadded data. The conditions of anti-mirror padding imply the pseudo periodicity

\[\forall k\in{\mathbb{Z}}:f[k]=f[k+2\,K-2]-2\,\left(f[K-1]-f[0]\right).\]

Anti-mirror padding of data samples
k   ƒ1[k]ƒ2[k]ƒ3[k]ƒ4[k]ƒ5[k]ƒ6[k]
−20a(21 a − 20 b)(11 a − 10 c)(8 a − c − 6 d)(6 a − 5 e)(5 a − 4 f)
−19a(20 a − 19 b)(10 a + b − 10 c)(8 a − b − 6 d)(6 a − d − 4 e)(4 a + b − 4 f)
−18a(19 a − 18 b)(10 a − 9 c)(7 a − 6 d)(6 a − c − 4 e)(4 a + c − 4 f)
−17a(18 a − 17 b)(10 a − b − 8 c)(6 a + b − 6 d)(6 a − b − 4 e)(4 a + d − 4 f)
−16a(17 a − 16 b)(9 a − 8 c)(6 a + c − 6 d)(5 a − 4 e)(4 a + e − 4 f)
−15a(16 a − 15 b)(8 a + b − 8 c)(6 a − 5 d)(4 a + b − 4 e)(4 a − 3 f)
−14a(15 a − 14 b)(8 a − 7 c)(6 a − c − 4 d)(4 a + c − 4 e)(4 a − e − 2 f)
−13a(14 a − 13 b)(8 a − b − 6 c)(6 a − b − 4 d)(4 a + d − 4 e)(4 a − d − 2 f)
−12a(13 a − 12 b)(7 a − 6 c)(5 a − 4 d)(4 a − 3 e)(4 a − c − 2 f)
−11a(12 a − 11 b)(6 a + b − 6 c)(4 a + b − 4 d)(4 a − d − 2 e)(4 a − b − 2 f)
−10a(11 a − 10 b)(6 a − 5 c)(4 a + c − 4 d)(4 a − c − 2 e)(3 a − 2 f)
−9a(10 a − 9 b)(6 a − b − 4 c)(4 a − 3 d)(4 a − b − 2 e)(2 a + b − 2 f)
−8a(9 a − 8 b)(5 a − 4 c)(4 a − c − 2 d)(3 a − 2 e)(2 a + c − 2 f)
−7a(8 a − 7 b)(4 a + b − 4 c)(4 a − b − 2 d)(2 a + b − 2 e)(2 a + d − 2 f)
−6a(7 a − 6 b)(4 a − 3 c)(3 a − 2 d)(2 a + c − 2 e)(2 a + e − 2 f)
−5a(6 a − 5 b)(4 a − b − 2 c)(2 a + b − 2 d)(2 a + d − 2 e)(2 a − f)
−4a(5 a − 4 b)(3 a − 2 c)(2 a + c − 2 d)(2 a − e)(2 a − e)
−3a(4 a − 3 b)(2 a + b − 2 c)(2 a − d)(2 a − d)(2 a − d)
−2a(3 a − 2 b)(2 a − c)(2 a − c)(2 a − c)(2 a − c)
−1a(2 a − b)(2 a − b)(2 a − b)(2 a − b)(2 a − b)
0AAAAAA
1aBBBBB
2a(−a + 2 b)CCCC
3a(−2 a + 3 b)(−b + 2 c)DDD
4a(−3 a + 4 b)(−a + 2 c)(−c + 2 d)EE
5a(−4 a + 5 b)(−2 a + b + 2 c)(−b + 2 d)(−d + 2 e)F
6a(−5 a + 6 b)(−2 a + 3 c)(−a + 2 d)(−c + 2 e)(−e + 2 f)
7a(−6 a + 7 b)(−2 a − b + 4 c)(−2 a + b + 2 d)(−b + 2 e)(−d + 2 f)
8a(−7 a + 8 b)(−3 a + 4 c)(−2 a + c + 2 d)(−a + 2 e)(−c + 2 f)
9a(−8 a + 9 b)(−4 a + b + 4 c)(−2 a + 3 d)(−2 a + b + 2 e)(−b + 2 f)
10a(−9 a + 10 b)(−4 a + 5 c)(−2 a − c + 4 d)(−2 a + c + 2 e)(−a + 2 f)
11a(−10 a + 11 b)(−4 a − b + 6 c)(−2 a − b + 4 d)(−2 a + d + 2 e)(−2 a + b + 2 f)
12a(−11 a + 12 b)(−5 a + 6 c)(−3 a + 4 d)(−2 a + 3 e)(−2 a + c + 2 f)
13a(−12 a + 13 b)(−6 a + b + 6 c)(−4 a + b + 4 d)(−2 a − d + 4 e)(−2 a + d + 2 f)
14a(−13 a + 14 b)(−6 a + 7 c)(−4 a + c + 4 d)(−2 a − c + 4 e)(−2 a + e + 2 f)
15a(−14 a + 15 b)(−6 a − b + 8 c)(−4 a + 5 d)(−2 a − b + 4 e)(−2 a + 3 f)
16a(−15 a + 16 b)(−7 a + 8 c)(−4 a − c + 6 d)(−3 a + 4 e)(−2 a − e + 4 f)
17a(−16 a + 17 b)(−8 a + b + 8 c)(−4 a − b + 6 d)(−4 a + b + 4 e)(−2 a − d + 4 f)
18a(−17 a + 18 b)(−8 a + 9 c)(−5 a + 6 d)(−4 a + c + 4 e)(−2 a − c + 4 f)
19a(−18 a + 19 b)(−8 a − b + 10 c)(−6 a + b + 6 d)(−4 a + d + 4 e)(−2 a − b + 4 f)
20a(−19 a + 20 b)(−9 a + 10 c)(−6 a + c + 6 d)(−4 a + 5 e)(−3 a + 4 f)
21a(−20 a + 21 b)(−10 a + b + 10 c)(−6 a + 7 d)(−4 a − d + 6 e)(−4 a + b + 4 f)
22a(−21 a + 22 b)(−10 a + 11 c)(−6 a − c + 8 d)(−4 a − c + 6 e)(−4 a + c + 4 f)
23a(−22 a + 23 b)(−10 a − b + 12 c)(−6 a − b + 8 d)(−4 a − b + 6 e)(−4 a + d + 4 f)
24a(−23 a + 24 b)(−11 a + 12 c)(−7 a + 8 d)(−5 a + 6 e)(−4 a + e + 4 f)
25a(−24 a + 25 b)(−12 a + b + 12 c)(−8 a + b + 8 d)(−6 a + b + 6 e)(−4 a + 5 f)
26a(−25 a + 26 b)(−12 a + 13 c)(−8 a + c + 8 d)(−6 a + c + 6 e)(−4 a − e + 6 f)
27a(−26 a + 27 b)(−12 a − b + 14 c)(−8 a + 9 d)(−6 a + d + 6 e)(−4 a − d + 6 f)
28a(−27 a + 28 b)(−13 a + 14 c)(−8 a − c + 10 d)(−6 a + 7 e)(−4 a − c + 6 f)
29a(−28 a + 29 b)(−14 a + b + 14 c)(−8 a − b + 10 d)(−6 a − d + 8 e)(−4 a − b + 6 f)

Parameters:
  • data (np.ndarray[tuple[int], np.dtype[np.float64]],) – Data to extend.

  • at (int) – Arbitrary index.

Returns:

The value of the padded data at the requested index.

Return type:

float

Examples

Load the library.
>>> import splinekit as sk
Short data at large index -42.
>>> sk.pad_a([1, 5, -3], at = -42)
85

splinekit.spline_padding.samples_to_coeff_a(data: ndarray[tuple[int], dtype[float64]], *, degree: int, pure_python: bool = False) None

In-place conversion of data samples into spline coefficients under anti-mirror padding.

Replaces a one-dimensional numpy.ndarray of data samples \(f\) by spline coefficients \(c\) such that

\[\forall k\in[0\ldots K-1]:f[k]=\sum_{q\in{\mathbb{Z}}}\,c[q]\, \beta^{n}(k-q),\]

where \(K\) is the length of the provided data and \(\beta^{n}\) is a polynomial B-spline of nonnegative degree \(n.\) The spline coefficients are assumed to conform to a anti-mirror padding.

Parameters:
  • data (np.ndarray[tuple[int], np.dtype[np.float64]],) – Data to convert from samples to coefficients.

  • degree (int) – Nonnegative degree of the polynomial B-spline.

  • pure_python (bool) – The directive that forces the computations to be performed in Python.

Returns:

The returned coefficients overwrite data.

Return type:

None

Examples

Load the libraries.
>>> import numpy as np
>>> import splinekit as sk
Cubic coefficients of arbitrary data with anti-mirror padding.
>>> f = np.array([1, 5, -3], dtype = "float")
>>> c = f.copy()
>>> sk.samples_to_coeff_a(c, degree = 3)
>>> print(c)
[ 1.  8. -3.]

Notes

The computations are performed in-place.


splinekit.spline_padding.pad_np(data: ndarray[tuple[int], dtype[float64]], *, at: int) float

Nega-periodic padding.

Returns the value of the \(k\)-th data sample after the data have been extended by nega-periodic padding. The padded data \(f\) satisfy that

\[\forall k\in{\mathbb{Z}}:f[k+K]=-f[k],\]

where \(K\) is the length of the unpadded data. The conditions of nega-periodic padding imply the periodicity

\[\forall k\in{\mathbb{Z}}:f[k]=f[k+2\,K].\]

Nega-periodic padding of data samples
k   ƒ1[k]ƒ2[k]ƒ3[k]ƒ4[k]ƒ5[k]ƒ6[k]
−20aa−b−aae
−19−ab−c−bbf
−18a−aa−cc−a
−17−a−bb−dd−b
−16aacae−c
−15−ab−ab−a−d
−14a−a−bc−b−e
−13−a−b−cd−c−f
−12aaa−a−da
−11−abb−b−eb
−10a−ac−cac
−9−a−b−a−dbd
−8aa−bace
−7−ab−cbdf
−6a−aace−a
−5−a−bbd−a−b
−4aac−a−b−c
−3−ab−a−b−c−d
−2a−a−b−c−d−e
−1−a−b−c−d−e−f
0AAAAAA
1−aBBBBB
2a−aCCCC
3−a−b−aDDD
4aa−b−aEE
5−ab−c−b−aF
6a−aa−c−b−a
7−a−bb−d−c−b
8aaca−d−c
9−ab−ab−e−d
10a−a−bca−e
11−a−b−cdb−f
12aaa−aca
13−abb−bdb
14a−ac−cec
15−a−b−a−d−ad
16aa−ba−be
17−ab−cb−cf
18a−aac−d−a
19−a−bbd−e−b
20aac−aa−c
21−ab−a−bb−d
22a−a−b−cc−e
23−a−b−c−dd−f
24aaaaea
25−abbb−ab
26a−acc−bc
27−a−b−ad−cd
28aa−b−a−de
29−ab−c−b−ef

Parameters:
  • data (np.ndarray[tuple[int], np.dtype[np.float64]],) – Data to extend.

  • at (int) – Arbitrary index.

Returns:

The value of the padded data at the requested index.

Return type:

float

Examples

Load the library.
>>> import splinekit as sk
Short data at large index -42.
>>> sk.pad_np([1, 5, -3], at = -42)
1

splinekit.spline_padding.samples_to_coeff_np(data: ndarray[tuple[int], dtype[float64]], *, degree: int, pure_python: bool = False) None

In-place conversion of data samples into spline coefficients under nega-periodic padding.

Replaces a one-dimensional numpy.ndarray of data samples \(f\) by spline coefficients \(c\) such that

\[\forall k\in[0\ldots K-1]:f[k]=\sum_{q\in{\mathbb{Z}}}\,c[q]\, \beta^{n}(k-q),\]

where \(K\) is the length of the provided data and \(\beta^{n}\) is a polynomial B-spline of nonnegative degree \(n.\) The spline coefficients are assumed to conform to a nega-periodic padding.

Parameters:
  • data (np.ndarray[tuple[int], np.dtype[np.float64]],) – Data to convert from samples to coefficients.

  • degree (int) – Nonnegative degree of the polynomial B-spline.

  • pure_python (bool) – The directive that forces the computations to be performed in Python.

Returns:

The returned coefficients overwrite data.

Return type:

None

Examples

Load the libraries.
>>> import numpy as np
>>> import splinekit as sk
Cubic coefficients of arbitrary data with nega-periodic padding.
>>> f = np.array([1, 5, -3], dtype = "float")
>>> c = f.copy()
>>> sk.samples_to_coeff_np(c, degree = 3)
>>> print(c)
[-3.  10.2 -7.8]

Notes

The computations are performed in-place.


splinekit.spline_padding.pad_nn(data: ndarray[tuple[int], dtype[float64]], *, at: int) float

Nega-narrow-mirror padding.

Returns the value of the \(k\)-th data sample after the data have been extended by nega-narrow-mirror padding. The padded data \(f\) satisfy that

\[\begin{split}\forall k\in{\mathbb{Z}}:\left\{\begin{array}{rcl}f[k-1]&=&-f[-1-k]\\ f[k+K+1]&=&-f[K-1-k],\end{array}\right.\end{split}\]

where \(K\) is the length of the unpadded data. The conditions of nega-narrow-mirror padding imply the periodicity

\[\begin{split}\forall k\in{\mathbb{Z}}:\left\{\begin{array}{rcl}f[k]&=&f[k+2\,K+2]\\ f[k\,\left(K+1\right)-1]&=&0.\end{array}\right.\end{split}\]

Nega-narrow-mirror padding of data samples
k   ƒ1[k]ƒ2[k]ƒ3[k]ƒ4[k]ƒ5[k]ƒ6[k]
−20a−a−cae−e
−1900−bb0−d
−18−aa−ac−e−c
−170b0d−d−b
−16a0a0−c−a
−150−bb−d−b0
−14−a−ac−c−aa
−13000−b0b
−12aa−c−aac
−110b−b0bd
−10−a0−aace
−90−b0bdf
−8a−aace0
−700bd0−f
−6−aac0−e−e
−50b0−d−d−d
−4a0−c−c−c−c
−30−b−b−b−b−b
−2−a−a−a−a−a−a
−1000000
0AAAAAA
10BBBBB
2−a0CCCC
30−b0DDD
4a−a−c0EE
500−b−d0F
6−aa−a−c−e0
70b0−b−d−f
8a0a−a−c−e
90−bb0−b−d
10−a−aca−a−c
11000b0−b
12aa−cca−a
130b−bdb0
14−a0−a0ca
150−b0−ddb
16a−aa−cec
1700b−b0d
18−aac−a−ee
190b00−df
20a0−ca−c0
210−b−bb−b−f
22−a−a−ac−a−e
23000d0−d
24aaa0a−c
250bb−db−b
26−a0c−cc−a
270−b0−bd0
28a−a−c−aea
2900−b00b

Parameters:
  • data (np.ndarray[tuple[int], np.dtype[np.float64]],) – Data to extend.

  • at (int) – Arbitrary index.

Returns:

The value of the padded data at the requested index.

Return type:

float

Examples

Load the library.
>>> import splinekit as sk
Short data at large index -42.
>>> sk.pad_nn([1, 5, -3], at = -42)
-1

splinekit.spline_padding.samples_to_coeff_nn(data: ndarray[tuple[int], dtype[float64]], *, degree: int, pure_python: bool = False) None

In-place conversion of data samples into spline coefficients under nega-narrow-mirror padding.

Replaces a one-dimensional numpy.ndarray of data samples \(f\) by spline coefficients \(c\) such that

\[\forall k\in[0\ldots K-1]:f[k]=\sum_{q\in{\mathbb{Z}}}\,c[q]\, \beta^{n}(k-q),\]

where \(K\) is the length of the provided data and \(\beta^{n}\) is a polynomial B-spline of nonnegative degree \(n.\) The spline coefficients are assumed to conform to a nega-narrow-mirror padding.

Parameters:
  • data (np.ndarray[tuple[int], np.dtype[np.float64]],) – Data to convert from samples to coefficients.

  • degree (int) – Nonnegative degree of the polynomial B-spline.

  • pure_python (bool) – The directive that forces the computations to be performed in Python.

Returns:

The returned coefficients overwrite data.

Return type:

None

Examples

Load the libraries.
>>> import numpy as np
>>> import splinekit as sk
Cubic coefficients of arbitrary data with nega-narrow-mirror padding.
>>> f = np.array([1, 5, -3], dtype = "float")
>>> c = f.copy()
>>> sk.samples_to_coeff_nn(c, degree = 3)
>>> print(c)
[-0.85714286  9.42857143 -6.85714286]

Notes

The computations are performed in-place.


splinekit.spline_padding.pad_nw(data: ndarray[tuple[int], dtype[float64]], *, at: int) float

Nega-wide-mirror padding.

Returns the value of the \(k\)-th data sample after the data have been extended by nega-wide-mirror padding. The padded data \(f\) satisfy that

\[\begin{split}\forall k\in{\mathbb{Z}}:\left\{\begin{array}{rcl}f[k]&=&-f[-1-k]\\ f[k+K]&=&-f[K-1-k],\end{array}\right.\end{split}\]

where \(K\) is the length of the unpadded data. The conditions of nega-wide-mirror padding imply the periodicity

\[\forall k\in{\mathbb{Z}}:f[k]=f[k+2\,K].\]

Nega-wide-mirror padding of data samples
k   ƒ1[k]ƒ2[k]ƒ3[k]ƒ4[k]ƒ5[k]ƒ6[k]
−20aa−b−dae
−19−ab−a−cbf
−18a−ba−bc−f
−17−a−ab−ad−e
−16aacae−d
−15−ab−cb−e−c
−14a−b−bc−d−b
−13−a−a−ad−c−a
−12aaa−d−ba
−11−abb−c−ab
−10a−bc−bac
−9−a−a−c−abd
−8aa−bace
−7−ab−abdf
−6a−bace−f
−5−a−abd−e−e
−4aac−d−d−d
−3−ab−c−c−c−c
−2a−b−b−b−b−b
−1−a−a−a−a−a−a
0AAAAAA
1−aBBBBB
2a−bCCCC
3−a−a−cDDD
4aa−b−dEE
5−ab−a−c−eF
6a−ba−b−d−f
7−a−ab−a−c−e
8aaca−b−d
9−ab−cb−a−c
10a−b−bca−b
11−a−a−adb−a
12aaa−dca
13−abb−cdb
14a−bc−bec
15−a−a−c−a−ed
16aa−ba−de
17−ab−ab−cf
18a−bac−b−f
19−a−abd−a−e
20aac−da−d
21−ab−c−cb−c
22a−b−b−bc−b
23−a−a−a−ad−a
24aaaaea
25−abbb−eb
26a−bcc−dc
27−a−a−cd−cd
28aa−b−d−be
29−ab−a−c−af

Parameters:
  • data (np.ndarray[tuple[int], np.dtype[np.float64]],) – Data to extend.

  • at (int) – Arbitrary index.

Returns:

The value of the padded data at the requested index.

Return type:

float

Examples

Load the library.
>>> import splinekit as sk
Short data at large index -42.
>>> sk.pad_nw([1, 5, -3], at = -42)
1

splinekit.spline_padding.samples_to_coeff_nw(data: ndarray[tuple[int], dtype[float64]], *, degree: int, pure_python: bool = False) None

In-place conversion of data samples into spline coefficients under nega-wide-mirror padding.

Replaces a one-dimensional numpy.ndarray of data samples \(f\) by spline coefficients \(c\) such that

\[\forall k\in[0\ldots K-1]:f[k]=\sum_{q\in{\mathbb{Z}}}\,c[q]\, \beta^{n}(k-q),\]

where \(K\) is the length of the provided data and \(\beta^{n}\) is a polynomial B-spline of nonnegative degree \(n.\) The spline coefficients are assumed to conform to a nega-wide-mirror padding.

Parameters:
  • data (np.ndarray[tuple[int], np.dtype[np.float64]],) – Data to convert from samples to coefficients.

  • degree (int) – Nonnegative degree of the polynomial B-spline.

  • pure_python (bool) – The directive that forces the computations to be performed in Python.

Returns:

The returned coefficients overwrite data.

Return type:

None

Examples

Load the libraries.
>>> import numpy as np
>>> import splinekit as sk
Cubic coefficients of arbitrary data with nega-wide-mirror padding.
>>> f = np.array([1, 5, -3], dtype = "float")
>>> c = f.copy()
>>> sk.samples_to_coeff_nw(c, degree = 3)
>>> print(c)
[-1.4 10.2 -9.4]

Notes

The computations are performed in-place.