-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add "internals" section - add a slight clarification to manual
- Loading branch information
Showing
3 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ Content | |
|
||
formulation | ||
manual | ||
internals | ||
benchmarks | ||
api | ||
changelog | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
.. _internals: | ||
|
||
.. currentmodule:: csaps | ||
|
||
Internals | ||
========= | ||
|
||
Spline Representation | ||
--------------------- | ||
|
||
The computed splines are represented by classes :class:`SplinePPForm` for univariate/multivariate | ||
and :class:`NdGridSplinePPForm` for nd-gridded data. | ||
|
||
The spline coefficients are stored in the numpy array. It is 2D 1xM array for univariate data, | ||
2D NxM array for multivariate data and 2D/ND array (tensor-product of univariate spline coefficients) | ||
for nd-gridded data. | ||
|
||
Let's look at a simple example. | ||
|
||
The multivariate data:: | ||
|
||
x = [1, 2, 3, 4] | ||
y = [(1, 2, 3, 4), (5, 6, 7, 8)] | ||
|
||
Compute the spline: | ||
|
||
.. code-block:: python | ||
>>> s = csaps(x, y).spline | ||
And print the spline info and coefficients array: | ||
|
||
.. code-block:: python | ||
>>> print(s) | ||
SplinePPForm | ||
breaks: [1. 2. 3. 4.] | ||
coeffs: shape (2, 12) | ||
pieces: 3 | ||
order: 4 | ||
ndim: 2 | ||
>>> print(s.coeffs) | ||
[[0. 0. 0. 0. 0. 0. 1. 1. 1. 1. 2. 3.] | ||
[0. 0. 0. 0. 0. 0. 1. 1. 1. 5. 6. 7.]] | ||
Each row in the array contain coefficients for all spline pieces for corresponding data. | ||
In our case we have 2D Y-data with shape (2, 4) and have the coefficients array with shape (2, 12) | ||
|
||
- 2 rows: 2 dimensions in the data | ||
- 12 columns: 3 pieces of the cubic spline (4-order) | ||
|
||
The spline pieces for each dimension are composed sequentially in the one row. | ||
Such representation allows us to compute tensor-product for nd-grid data and evaluate splines | ||
without superfluous manipulations and reshapes of the coefficients array. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters