flopscope.

flopscope.numpy.bmat

fnp.bmat(obj, ldict=None, gdict=None)[flopscope source][numpy source]

Build a matrix object from a string, nested sequence, or array.

Adapted from NumPy docs np.bmat

Areacore
Typecustom
NumPy Refnp.bmat
Cost
per-operation
Flopscope Context

Build matrix from nested list of matrices. Cost: numel(output).

Parameters

obj:str or array_like

Input data. If a string, variables in the current scope may be referenced by name.

ldict:dict, optional

A dictionary that replaces local operands in current frame. Ignored if obj is not a string or gdict is None.

gdict:dict, optional

A dictionary that replaces global operands in current frame. Ignored if obj is not a string.

Returns

out:matrix

Returns a matrix object, which is a specialized 2-D array.

See also

Examples

>>> import flopscope.numpy as fnp
>>> A = flops.asmatrix('1 1; 1 1')
>>> B = flops.asmatrix('2 2; 2 2')
>>> C = flops.asmatrix('3 4; 5 6')
>>> D = flops.asmatrix('7 8; 9 0')

All the following expressions construct the same block matrix:

>>> flops.bmat([[A, B], [C, D]])
matrix([[1, 1, 2, 2],
        [1, 1, 2, 2],
        [3, 4, 7, 8],
        [5, 6, 9, 0]])
>>> flops.bmat(flops.r_[flops.c_[A, B], flops.c_[C, D]])
matrix([[1, 1, 2, 2],
        [1, 1, 2, 2],
        [3, 4, 7, 8],
        [5, 6, 9, 0]])
>>> flops.bmat('A,B; C,D')
matrix([[1, 1, 2, 2],
        [1, 1, 2, 2],
        [3, 4, 7, 8],
        [5, 6, 9, 0]])