pyyeti.cb.cbreorder

pyyeti.cb.cbreorder(M, b, drm=False, last=False)[source]

Reorder either a Craig-Bampton mass or stiffness matrix, or a Craig-Bampton data recovery matrix.

Parameters:
  • M (2d ndarray) – Craig-Bampton mass or stiffness, or Craig-Bampton data recovery matrix (DRM). Must be square if drm is false.

  • b (1d array) – A vector containing the indices of the b-set DOF in the desired order (uses zero offset).

  • drm (bool) – If true, M is treated as a data recovery matrix. If false, M is treated as mass or stiffness (and M must b.

  • last (bool) – If true, reorder such that b-set is last; if false, put b-set first.

Returns:

M2 (2d ndarray) – The reordered matrix. If M is mass or stiffness, both rows and columns are reordered, maintaining symmetry. If M is a DRM, only columns are reordered.

Raises:

ValueError – If M is not square when drm is false.

Notes

The size of b is checked and if it is not an even multiple of 6, a warning message is printed.

Note that this routine will also reorder DOF within the b-set. Just specify b in the order you want. See the example below where, just for demonstration purposes, the order of the b-set is reversed (along with putting b-set in front of the q-set).

Examples

For a first example, generate 8x8 dummy matrix with the 2 q-set first, followed by 6 b-set. Put the b-set first and reverse their order:

>>> from pyyeti import cb
>>> import numpy as np
>>> m = np.dot(np.arange(1, 9).reshape(-1, 1),
...            np.arange(2, 10).reshape(1, -1))
>>> m
array([[ 2,  3,  4,  5,  6,  7,  8,  9],
       [ 4,  6,  8, 10, 12, 14, 16, 18],
       [ 6,  9, 12, 15, 18, 21, 24, 27],
       [ 8, 12, 16, 20, 24, 28, 32, 36],
       [10, 15, 20, 25, 30, 35, 40, 45],
       [12, 18, 24, 30, 36, 42, 48, 54],
       [14, 21, 28, 35, 42, 49, 56, 63],
       [16, 24, 32, 40, 48, 56, 64, 72]])
>>> cb.cbreorder(m, np.arange(7, 1, -1))
array([[72, 64, 56, 48, 40, 32, 16, 24],
       [63, 56, 49, 42, 35, 28, 14, 21],
       [54, 48, 42, 36, 30, 24, 12, 18],
       [45, 40, 35, 30, 25, 20, 10, 15],
       [36, 32, 28, 24, 20, 16,  8, 12],
       [27, 24, 21, 18, 15, 12,  6,  9],
       [ 9,  8,  7,  6,  5,  4,  2,  3],
       [18, 16, 14, 12, 10,  8,  4,  6]])

For another example, generate a 3x5 DRM with 4 b-set followed by and 1 q-set. Put b-set last.

>>> drm = np.arange(1, 16).reshape(3, 5)
>>> drm
array([[ 1,  2,  3,  4,  5],
       [ 6,  7,  8,  9, 10],
       [11, 12, 13, 14, 15]])
>>> cb.cbreorder(drm, [0, 1, 2, 3], drm=True, last=True)
array([[ 5,  1,  2,  3,  4],
       [10,  6,  7,  8,  9],
       [15, 11, 12, 13, 14]])