utils

dg_maxwell.utils.add(a, b)[source]

For broadcasting purposes, To sum two arrays of different shapes, A function which can sum two variables is required.

Parameters:

a : arrayfire.Array [N M 1 1]

One of the arrays which need to be broadcasted and summed.

b : arrayfire.Array [1 M L 1]

One of the arrays which need to be broadcasted and summed.

Returns:

add : arrayfire.Array [N M L 1]

returns the sum of a and b. When used along with af.broadcast can be used to sum different size arrays.

dg_maxwell.utils.divide(a, b)[source]

For broadcasting purposes, To divide two arrays of different shapes, A function which can sum two variables is required.

Parameters:

a : arrayfire.Array [N M 1 1]

One of the arrays which need to be broadcasted and divided.

b : arrayfire.Array [1 M L 1]

One of the arrays which need to be broadcasted and divided.

Returns:

quotient : arrayfire.Array [N M L 1]

The quotient a / b. When used along with af.broadcast can be used to give quotient of two different size arrays by dividing elements of the broadcasted array.

dg_maxwell.utils.linspace(start, end, number_of_points)[source]

Linspace implementation using arrayfire.

Returns:

X : arrayfire.Array

An array which contains ‘number_of_points’ evenly spaced points between ‘start’ and ‘end’

dg_maxwell.utils.matmul_3D(a, b)[source]

Finds the matrix multiplication of \(Q\) pairs of matrices a and b.

Parameters:

a : af.Array [M N Q 1]

First set of \(Q\) 2D arrays \(N \neq 1\) and \(M \neq 1\).

b : af.Array [N P Q 1]

Second set of \(Q\) 2D arrays \(P \neq 1\).

Returns:

matmul : af.Array [M P Q 1]

Matrix multiplication of \(Q\) sets of 2D arrays.

dg_maxwell.utils.multiply(a, b)[source]

For broadcasting purposes, To divide two arrays of different shapes, A function which can sum two variables is required.

Parameters:

a : arrayfire.Array [N M 1 1]

One of the arrays which need to be broadcasted and multiplying.

b : arrayfire.Array [1 M L 1]

One of the arrays which need to be broadcasted and multiplying.

Returns:

product : arrayfire.Array [N M L 1]

The product a * b . When used along with af.broadcast can be used to give quotient of two different size arrays by multiplying elements of the broadcasted array.

dg_maxwell.utils.plot_line(points, axes_handler, grid_width=2.0, grid_color='blue')[source]

Plots curves using the given \((x, y)\) points. It joins the points using lines in the given order.

Parameters:

points : np.ndarray [N, 2]

\((x, y)\) coordinates of \(N\) points. First and second column stores \(x\) and \(y\) coordinates of an point.

axes_handler : matplotlib.axes.Axes

The plot handler being used to plot the element grid. You may generate it by calling the function pyplot.axes()

grid_width : float

Grid line width.

grid_color : str

Grid line color.

Returns:

None

dg_maxwell.utils.poly1d_product(poly_a, poly_b)[source]

Finds the product of two polynomials using the arrayfire convolve1 function.

Parameters:

poly_a : af.Array[N degree_a 1 1]

\(N\) polynomials of degree \(degree\)

poly_b : af.Array[N degree_b 1 1]

\(N\) polynomials of degree \(degree_b\)

dg_maxwell.utils.polyval_1d(polynomials, xi)[source]

Finds the value of the polynomials at the given \(\xi\) coordinates.

Parameters:

polynomials : af.Array [number_of_polynomials N 1 1]

number_of_polynomials \(2D\) polynomials of degree \(N - 1\) of the form

\[P(x) = a_0x^0 + a_1x^1 + ... \ a_{N - 1}x^{N - 1} + a_Nx^N\]

xi : af.Array [N 1 1 1]

\(\xi\) coordinates at which the \(i^{th}\) Lagrange basis polynomial is to be evaluated.

Returns:

af.Array [i.shape[0] xi.shape[0] 1 1]

Evaluated polynomials at given \(\xi\) coordinates

dg_maxwell.utils.power(a, b)[source]

For broadcasting purposes, To divide two arrays of different shapes, A function which can sum two variables is required.

Parameters:

a : arrayfire.Array [N M 1 1]

One of the arrays which need to be broadcasted and multiplying.

b : arrayfire.Array [1 M L 1]

One of the arrays which need to be broadcasted and multiplying.

Returns:

power : arrayfire.Array [N M L 1]

The quotient a / b. When used along with af.broadcast can be used to give quotient of two different size arrays by multiplying elements of the broadcasted array.

dg_maxwell.utils.shape(array)[source]