LinearCombinationOfWPs

About the LinearCombinationOfWPs class

The WaveBlocks Project

@author: R. Bourquin @copyright: Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016 R. Bourquin @license: Modified BSD License

Inheritance diagram

Inheritance diagram of LinearCombinationOfWPs

Class documentation

class WaveBlocksND.LinearCombinationOfWPs(dimension, number_components, number_packets=0)[source]

This class represents linear combinations of general but compatible wavepackets of any kind.

__init__(dimension, number_components, number_packets=0)[source]

Initialize a new linear combination of general wavepackets. This object represents \Upsilon := \sum_{j=0}^{J-1} c_j \Psi_j. All J wavepackets \Psi_j have the same number N components and are defined in the D dimensional space.

Parameters:
  • dimension – The space dimension D the packets have.
  • ncomponents – The number N of components the packets have.
Returns:

An instance of LinearCombinationOfWPs.

__str__()[source]
Returns:A string describing the linear combination of general wavepackets \Upsilon = \sum_{j=0}^J c_j \Psi_j.
add_wavepacket(packet, coefficient=1.0)[source]

Add a new wavepacket to the linear combination.

Parameters:
  • packet (A Wavepacket subclass instance.) – The new wavepacket \Psi_j to add.
  • coefficient – The corresponding coefficient c_j, default is 1.0.
add_wavepackets(packetlist, coefficients=None)[source]

Add a list of new wavepackets to the linear combination.

Parameters:
  • packetlist (A list of Wavepacket subclass instances.) – A list of new wavepackets \{\Psi_j\}.
  • coefficients – The corresponding coefficient vector c, default is a vector of all 1.0.
evaluate_at(grid, component=None)[source]

Evaluate the linear combination of wavepackets \Upsilon at the given nodes \gamma.

Parameters:
  • grid (A class having a get_nodes method.) – The grid \Gamma containing the nodes \gamma.
  • component – The index i of a single component to evaluate. (Defaults to None for evaluating all components.)
Returns:

A list of arrays or a single array containing the values of the \Phi_i at the nodes \gamma.

get_coefficient(index)[source]

Get the coefficient c_j of the wavepacket \Psi_j.

Parameters:index – The index 0 \leq j < J of the coefficient to retrieve.
Returns:The coefficient c_j.
get_coefficients()[source]

Get the vector with all coefficients c_j of all wavepackets \Psi_j.

Returns:The vector c of all coefficients c_j. The vector is of shape (J, 1).
Type:An ndarray
get_description()[source]

Return a description of this linear combination object. A description is a dict containing all key-value pairs necessary to reconstruct the current instance. A description never contains any data.

get_dimension()
Returns:The space dimension D of all the wavepackets \Psi_j.
get_number_components()
Returns:The number N of components all the wavepackets \Psi_j have.
get_number_packets()
Returns:The number J of wavepackets in the linear combination \Upsilon := \sum_{j=0}^{J-1} c_j \Psi_j.
get_wavepacket(index)[source]

Get the wavepacket \Psi_j from the linear combination.

Parameters:index – The index 0 \leq j < J of the packet to retrieve.
Returns:The wavepacket \Psi_j.
Type:A Wavepacket subclass instance.
get_wavepackets()[source]

Get a list of all wavepackets \Psi_j in the linear combination.

Returns:A list of all wavepackets \Psi_j.
Type:A list of Wavepacket subclass instances.
remove_wavepacket(index)[source]

Remove a wavepacket \Psi_j from the linear combination.

Parameters:index – The index 0 \leq j < J of the packet to remove.
set_coefficient(index, coefficient)[source]

Set the coefficient c_j of the wavepacket \Psi_j.

Parameters:
  • index – The index 0 \leq j < J of the coefficient to retrieve.
  • coefficient – The coefficient c_j.
set_coefficients(coefficients)[source]

Update all the coefficients c of \Upsilon.

Parameters:coefficients (An ndarray) – The vector c.
set_wavepackets(packetlist)[source]

Set the list \{\Psi_j\}_j of new wavepackets.

Parameters:packetlist (A list of Wavepacket subclass instances.) – A list of new wavepackets \Psi_j.