pyyeti.ytools.multmd

pyyeti.ytools.multmd(a, b)[source]

Multiply a matrix and a diagonal, or two diagonals, in either order.

Parameters:
  • a (ndarray) – Matrix (2d array) or diagonal (1d array).

  • b (ndarray) – Matrix (2d array) or diagonal (1d array).

Returns:

c (ndarray) – Product of a * b.

Notes

This function should always be faster than numpy.dot() since the diagonal is not expanded to full size.

Examples

>>> from pyyeti import ytools
>>> import numpy as np
>>> a = np.array([[1, 2], [3, 4]])
>>> b = np.array([10, 100])
>>> ytools.multmd(a, b)
array([[ 10, 200],
       [ 30, 400]])
>>> ytools.multmd(b, a)
array([[ 10,  20],
       [300, 400]])
>>> ytools.multmd(b, b)
array([  100, 10000])