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] −20 a a b a a e −19 a b c b b f −18 a a a c c a −17 a b b d d b −16 a a c a e c −15 a b a b a d −14 a a b c b e −13 a b c d c f −12 a a a a d a −11 a b b b e b −10 a a c c a c −9 a b a d b d −8 a a b a c e −7 a b c b d f −6 a a a c e a −5 a b b d a b −4 a a c a b c −3 a b a b c d −2 a a b c d e −1 a b c d e f 0 A A A A A A 1 a B B B B B 2 a a C C C C 3 a b a D D D 4 a a b a E E 5 a b c b a F 6 a a a c b a 7 a b b d c b 8 a a c a d c 9 a b a b e d 10 a a b c a e 11 a b c d b f 12 a a a a c a 13 a b b b d b 14 a a c c e c 15 a b a d a d 16 a a b a b e 17 a b c b c f 18 a a a c d a 19 a b b d e b 20 a a c a a c 21 a b a b b d 22 a a b c c e 23 a b c d d f 24 a a a a e a 25 a b b b a b 26 a a c c b c 27 a b a d c d 28 a a b a d e 29 a b c b e 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_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,
datais a one-dimensionalnumpy.ndarrayof coefficients that is expressing the periodic uniform spline \(f\) of nonnegative degree \(n\) as a weighted sum of integer-shifted bases of the typesource_basis.At output time,
datais a one-dimensionalnumpy.ndarrayof coefficients that is expressing the same spline \(f\) as a weighted sum of integer-shifted bases of the typetarget_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.ndarrayof 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.ndarrayof 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.ndarrayof 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_pyields 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.ndarrayof 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_pyields 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] −20 a a a c e a −19 a b b b d b −18 a a c a c c −17 a b b b b d −16 a a a c a e −15 a b b d b f −14 a a c c c e −13 a b b b d d −12 a a a a e c −11 a b b b d b −10 a a c c c a −9 a b b d b b −8 a a a c a c −7 a b b b b d −6 a a c a c e −5 a b b b d f −4 a a a c e e −3 a b b d d d −2 a a c c c c −1 a b b b b b 0 A A A A A A 1 a B B B B B 2 a a C C C C 3 a b b D D D 4 a a a c E E 5 a b b b d F 6 a a c a c e 7 a b b b b d 8 a a a c a c 9 a b b d b b 10 a a c c c a 11 a b b b d b 12 a a a a e c 13 a b b b d d 14 a a c c c e 15 a b b d b f 16 a a a c a e 17 a b b b b d 18 a a c a c c 19 a b b b d b 20 a a a c e a 21 a b b d d b 22 a a c c c c 23 a b b b b d 24 a a a a a e 25 a b b b b f 26 a a c c c e 27 a b b d d d 28 a a a c e c 29 a b b b d b - 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.ndarrayof 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] −20 a a b d a e −19 a b a c b f −18 a b a b c f −17 a a b a d e −16 a a c a e d −15 a b c b e c −14 a b b c d b −13 a a a d c a −12 a a a d b a −11 a b b c a b −10 a b c b a c −9 a a c a b d −8 a a b a c e −7 a b a b d f −6 a b a c e f −5 a a b d e e −4 a a c d d d −3 a b c c c c −2 a b b b b b −1 a a a a a a 0 A A A A A A 1 a B B B B B 2 a b C C C C 3 a a c D D D 4 a a b d E E 5 a b a c e F 6 a b a b d f 7 a a b a c e 8 a a c a b d 9 a b c b a c 10 a b b c a b 11 a a a d b a 12 a a a d c a 13 a b b c d b 14 a b c b e c 15 a a c a e d 16 a a b a d e 17 a b a b c f 18 a b a c b f 19 a a b d a e 20 a a c d a d 21 a b c c b c 22 a b b b c b 23 a a a a d a 24 a a a a e a 25 a b b b e b 26 a b c c d c 27 a a c d c d 28 a a b d b e 29 a b a c a 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_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.ndarrayof 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] −20 a (21 a − 20 b) (11 a − 10 c) (8 a − c − 6 d) (6 a − 5 e) (5 a − 4 f) −19 a (20 a − 19 b) (10 a + b − 10 c) (8 a − b − 6 d) (6 a − d − 4 e) (4 a + b − 4 f) −18 a (19 a − 18 b) (10 a − 9 c) (7 a − 6 d) (6 a − c − 4 e) (4 a + c − 4 f) −17 a (18 a − 17 b) (10 a − b − 8 c) (6 a + b − 6 d) (6 a − b − 4 e) (4 a + d − 4 f) −16 a (17 a − 16 b) (9 a − 8 c) (6 a + c − 6 d) (5 a − 4 e) (4 a + e − 4 f) −15 a (16 a − 15 b) (8 a + b − 8 c) (6 a − 5 d) (4 a + b − 4 e) (4 a − 3 f) −14 a (15 a − 14 b) (8 a − 7 c) (6 a − c − 4 d) (4 a + c − 4 e) (4 a − e − 2 f) −13 a (14 a − 13 b) (8 a − b − 6 c) (6 a − b − 4 d) (4 a + d − 4 e) (4 a − d − 2 f) −12 a (13 a − 12 b) (7 a − 6 c) (5 a − 4 d) (4 a − 3 e) (4 a − c − 2 f) −11 a (12 a − 11 b) (6 a + b − 6 c) (4 a + b − 4 d) (4 a − d − 2 e) (4 a − b − 2 f) −10 a (11 a − 10 b) (6 a − 5 c) (4 a + c − 4 d) (4 a − c − 2 e) (3 a − 2 f) −9 a (10 a − 9 b) (6 a − b − 4 c) (4 a − 3 d) (4 a − b − 2 e) (2 a + b − 2 f) −8 a (9 a − 8 b) (5 a − 4 c) (4 a − c − 2 d) (3 a − 2 e) (2 a + c − 2 f) −7 a (8 a − 7 b) (4 a + b − 4 c) (4 a − b − 2 d) (2 a + b − 2 e) (2 a + d − 2 f) −6 a (7 a − 6 b) (4 a − 3 c) (3 a − 2 d) (2 a + c − 2 e) (2 a + e − 2 f) −5 a (6 a − 5 b) (4 a − b − 2 c) (2 a + b − 2 d) (2 a + d − 2 e) (2 a − f) −4 a (5 a − 4 b) (3 a − 2 c) (2 a + c − 2 d) (2 a − e) (2 a − e) −3 a (4 a − 3 b) (2 a + b − 2 c) (2 a − d) (2 a − d) (2 a − d) −2 a (3 a − 2 b) (2 a − c) (2 a − c) (2 a − c) (2 a − c) −1 a (2 a − b) (2 a − b) (2 a − b) (2 a − b) (2 a − b) 0 A A A A A A 1 a B B B B B 2 a (−a + 2 b) C C C C 3 a (−2 a + 3 b) (−b + 2 c) D D D 4 a (−3 a + 4 b) (−a + 2 c) (−c + 2 d) E E 5 a (−4 a + 5 b) (−2 a + b + 2 c) (−b + 2 d) (−d + 2 e) F 6 a (−5 a + 6 b) (−2 a + 3 c) (−a + 2 d) (−c + 2 e) (−e + 2 f) 7 a (−6 a + 7 b) (−2 a − b + 4 c) (−2 a + b + 2 d) (−b + 2 e) (−d + 2 f) 8 a (−7 a + 8 b) (−3 a + 4 c) (−2 a + c + 2 d) (−a + 2 e) (−c + 2 f) 9 a (−8 a + 9 b) (−4 a + b + 4 c) (−2 a + 3 d) (−2 a + b + 2 e) (−b + 2 f) 10 a (−9 a + 10 b) (−4 a + 5 c) (−2 a − c + 4 d) (−2 a + c + 2 e) (−a + 2 f) 11 a (−10 a + 11 b) (−4 a − b + 6 c) (−2 a − b + 4 d) (−2 a + d + 2 e) (−2 a + b + 2 f) 12 a (−11 a + 12 b) (−5 a + 6 c) (−3 a + 4 d) (−2 a + 3 e) (−2 a + c + 2 f) 13 a (−12 a + 13 b) (−6 a + b + 6 c) (−4 a + b + 4 d) (−2 a − d + 4 e) (−2 a + d + 2 f) 14 a (−13 a + 14 b) (−6 a + 7 c) (−4 a + c + 4 d) (−2 a − c + 4 e) (−2 a + e + 2 f) 15 a (−14 a + 15 b) (−6 a − b + 8 c) (−4 a + 5 d) (−2 a − b + 4 e) (−2 a + 3 f) 16 a (−15 a + 16 b) (−7 a + 8 c) (−4 a − c + 6 d) (−3 a + 4 e) (−2 a − e + 4 f) 17 a (−16 a + 17 b) (−8 a + b + 8 c) (−4 a − b + 6 d) (−4 a + b + 4 e) (−2 a − d + 4 f) 18 a (−17 a + 18 b) (−8 a + 9 c) (−5 a + 6 d) (−4 a + c + 4 e) (−2 a − c + 4 f) 19 a (−18 a + 19 b) (−8 a − b + 10 c) (−6 a + b + 6 d) (−4 a + d + 4 e) (−2 a − b + 4 f) 20 a (−19 a + 20 b) (−9 a + 10 c) (−6 a + c + 6 d) (−4 a + 5 e) (−3 a + 4 f) 21 a (−20 a + 21 b) (−10 a + b + 10 c) (−6 a + 7 d) (−4 a − d + 6 e) (−4 a + b + 4 f) 22 a (−21 a + 22 b) (−10 a + 11 c) (−6 a − c + 8 d) (−4 a − c + 6 e) (−4 a + c + 4 f) 23 a (−22 a + 23 b) (−10 a − b + 12 c) (−6 a − b + 8 d) (−4 a − b + 6 e) (−4 a + d + 4 f) 24 a (−23 a + 24 b) (−11 a + 12 c) (−7 a + 8 d) (−5 a + 6 e) (−4 a + e + 4 f) 25 a (−24 a + 25 b) (−12 a + b + 12 c) (−8 a + b + 8 d) (−6 a + b + 6 e) (−4 a + 5 f) 26 a (−25 a + 26 b) (−12 a + 13 c) (−8 a + c + 8 d) (−6 a + c + 6 e) (−4 a − e + 6 f) 27 a (−26 a + 27 b) (−12 a − b + 14 c) (−8 a + 9 d) (−6 a + d + 6 e) (−4 a − d + 6 f) 28 a (−27 a + 28 b) (−13 a + 14 c) (−8 a − c + 10 d) (−6 a + 7 e) (−4 a − c + 6 f) 29 a (−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.ndarrayof 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] −20 a a −b −a a e −19 −a b −c −b b f −18 a −a a −c c −a −17 −a −b b −d d −b −16 a a c a e −c −15 −a b −a b −a −d −14 a −a −b c −b −e −13 −a −b −c d −c −f −12 a a a −a −d a −11 −a b b −b −e b −10 a −a c −c a c −9 −a −b −a −d b d −8 a a −b a c e −7 −a b −c b d f −6 a −a a c e −a −5 −a −b b d −a −b −4 a a c −a −b −c −3 −a b −a −b −c −d −2 a −a −b −c −d −e −1 −a −b −c −d −e −f 0 A A A A A A 1 −a B B B B B 2 a −a C C C C 3 −a −b −a D D D 4 a a −b −a E E 5 −a b −c −b −a F 6 a −a a −c −b −a 7 −a −b b −d −c −b 8 a a c a −d −c 9 −a b −a b −e −d 10 a −a −b c a −e 11 −a −b −c d b −f 12 a a a −a c a 13 −a b b −b d b 14 a −a c −c e c 15 −a −b −a −d −a d 16 a a −b a −b e 17 −a b −c b −c f 18 a −a a c −d −a 19 −a −b b d −e −b 20 a a c −a a −c 21 −a b −a −b b −d 22 a −a −b −c c −e 23 −a −b −c −d d −f 24 a a a a e a 25 −a b b b −a b 26 a −a c c −b c 27 −a −b −a d −c d 28 a a −b −a −d e 29 −a b −c −b −e 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_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.ndarrayof 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] −20 a −a −c a e −e −19 0 0 −b b 0 −d −18 −a a −a c −e −c −17 0 b 0 d −d −b −16 a 0 a 0 −c −a −15 0 −b b −d −b 0 −14 −a −a c −c −a a −13 0 0 0 −b 0 b −12 a a −c −a a c −11 0 b −b 0 b d −10 −a 0 −a a c e −9 0 −b 0 b d f −8 a −a a c e 0 −7 0 0 b d 0 −f −6 −a a c 0 −e −e −5 0 b 0 −d −d −d −4 a 0 −c −c −c −c −3 0 −b −b −b −b −b −2 −a −a −a −a −a −a −1 0 0 0 0 0 0 0 A A A A A A 1 0 B B B B B 2 −a 0 C C C C 3 0 −b 0 D D D 4 a −a −c 0 E E 5 0 0 −b −d 0 F 6 −a a −a −c −e 0 7 0 b 0 −b −d −f 8 a 0 a −a −c −e 9 0 −b b 0 −b −d 10 −a −a c a −a −c 11 0 0 0 b 0 −b 12 a a −c c a −a 13 0 b −b d b 0 14 −a 0 −a 0 c a 15 0 −b 0 −d d b 16 a −a a −c e c 17 0 0 b −b 0 d 18 −a a c −a −e e 19 0 b 0 0 −d f 20 a 0 −c a −c 0 21 0 −b −b b −b −f 22 −a −a −a c −a −e 23 0 0 0 d 0 −d 24 a a a 0 a −c 25 0 b b −d b −b 26 −a 0 c −c c −a 27 0 −b 0 −b d 0 28 a −a −c −a e a 29 0 0 −b 0 0 b - 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.ndarrayof 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] −20 a a −b −d a e −19 −a b −a −c b f −18 a −b a −b c −f −17 −a −a b −a d −e −16 a a c a e −d −15 −a b −c b −e −c −14 a −b −b c −d −b −13 −a −a −a d −c −a −12 a a a −d −b a −11 −a b b −c −a b −10 a −b c −b a c −9 −a −a −c −a b d −8 a a −b a c e −7 −a b −a b d f −6 a −b a c e −f −5 −a −a b d −e −e −4 a a c −d −d −d −3 −a b −c −c −c −c −2 a −b −b −b −b −b −1 −a −a −a −a −a −a 0 A A A A A A 1 −a B B B B B 2 a −b C C C C 3 −a −a −c D D D 4 a a −b −d E E 5 −a b −a −c −e F 6 a −b a −b −d −f 7 −a −a b −a −c −e 8 a a c a −b −d 9 −a b −c b −a −c 10 a −b −b c a −b 11 −a −a −a d b −a 12 a a a −d c a 13 −a b b −c d b 14 a −b c −b e c 15 −a −a −c −a −e d 16 a a −b a −d e 17 −a b −a b −c f 18 a −b a c −b −f 19 −a −a b d −a −e 20 a a c −d a −d 21 −a b −c −c b −c 22 a −b −b −b c −b 23 −a −a −a −a d −a 24 a a a a e a 25 −a b b b −e b 26 a −b c c −d c 27 −a −a −c d −c d 28 a a −b −d −b e 29 −a b −a −c −a 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_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.ndarrayof 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.