.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/basis/plot_basis_multivariate_1d.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_basis_plot_basis_multivariate_1d.py: Multivariate Basis ================== .. GENERATED FROM PYTHON SOURCE LINES 6-17 .. code-block:: Python # Author: Steven Golovkine # License: MIT # Load packages import numpy as np from FDApy.representation import MultivariateBasis from FDApy.representation import DenseArgvals from FDApy.visualization import plot_multivariate .. GENERATED FROM PYTHON SOURCE LINES 18-19 Similarly to the multivariate functional, it is possible to define multivariate basis functions using the :class:`~FDApy.representation.MultivariateBasis` object. Multivariate basis functions are defined as a list of univariate basis functions and are represented with a :class:`~FDApy.representation.MultivariateBasis` object. The univariate basis functions can be of whatever dimension (curves, surfaces, ...). There is no restriction on the number of elements in the list but each univariate element must have the same number of functions. .. GENERATED FROM PYTHON SOURCE LINES 21-24 First example ------------- First, we will define a multivariate basis where the first component is the Fourier basis and the second component is the Legendre basis. The number of functions in the basis is set to :math:`3` and the sampling points are defined as a :class:`~FDApy.representation.DenseArgvals` object with eleven points between :math:`0` and :math:`1` for the first component and with eleven points between :math:`0` and :math:`0.5` for the second component. .. GENERATED FROM PYTHON SOURCE LINES 24-37 .. code-block:: Python basis_name = ["fourier", "legendre"] argvals = [ DenseArgvals({"input_dim_0": np.linspace(0, 1, 11)}), DenseArgvals({"input_dim_0": np.linspace(0, 0.5, 11)}), ] n_functions = [3, 3] basis = MultivariateBasis(name=basis_name, n_functions=n_functions, argvals=argvals) _ = plot_multivariate(basis) .. image-sg:: /auto_examples/basis/images/sphx_glr_plot_basis_multivariate_1d_001.png :alt: plot basis multivariate 1d :srcset: /auto_examples/basis/images/sphx_glr_plot_basis_multivariate_1d_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 38-41 Second example -------------- The second example is a multivariate basis where the first component is a multidimensional basis built from the tensor product of the Fourier basis and the second component is a multidimensional basis built from the tensor product of the Legendre basis. The number of functions in the multivariate basis is set to :math:`3`. .. GENERATED FROM PYTHON SOURCE LINES 41-58 .. code-block:: Python # Parameters basis_name = [("fourier", "fourier"), ("legendre", "legendre")] argvals = [ DenseArgvals( {"input_dim_0": np.linspace(0, 1, 11), "input_dim_1": np.linspace(0, 0.5, 11)} ), DenseArgvals( {"input_dim_0": np.linspace(0, 0.5, 11), "input_dim_1": np.linspace(0, 1, 11)} ), ] n_functions = [(3, 3), (3, 3)] basis = MultivariateBasis(name=basis_name, n_functions=n_functions, argvals=argvals) _ = plot_multivariate(basis) .. image-sg:: /auto_examples/basis/images/sphx_glr_plot_basis_multivariate_1d_002.png :alt: plot basis multivariate 1d :srcset: /auto_examples/basis/images/sphx_glr_plot_basis_multivariate_1d_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 59-62 Third example ------------- The third example is a multivariate basis where the first component is a Fourier basis (unidimensional) and the second component is a tensor product of Legendre basis (multidimensional). The number of functions in the multivariate basis is set to :math:`9`. To be coherent with the number of functions in the Fourier basis, the number of functions in the Legendre basis is set to :math:`3` for each dimension (it results in :math:`3 \times 3 = 9` multidimensional functions). .. GENERATED FROM PYTHON SOURCE LINES 62-76 .. code-block:: Python # Parameters basis_name = ["fourier", ("legendre", "legendre")] argvals = [ DenseArgvals({"input_dim_0": np.linspace(0, 1, 11)}), DenseArgvals( {"input_dim_0": np.linspace(0, 0.5, 11), "input_dim_1": np.linspace(0, 1, 11)} ), ] n_functions = [9, (3, 3)] basis = MultivariateBasis(name=basis_name, n_functions=n_functions, argvals=argvals) _ = plot_multivariate(basis) .. image-sg:: /auto_examples/basis/images/sphx_glr_plot_basis_multivariate_1d_003.png :alt: plot basis multivariate 1d :srcset: /auto_examples/basis/images/sphx_glr_plot_basis_multivariate_1d_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.704 seconds) .. _sphx_glr_download_auto_examples_basis_plot_basis_multivariate_1d.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_basis_multivariate_1d.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_basis_multivariate_1d.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_basis_multivariate_1d.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_