cmatrix.Matrix.find_sub_matrix

Matrix.find_sub_matrix()

Search the sub)matrix in the self matrix. The given sub must be smaller than the self matrix.

Parameters

Type

Description

sub

Matrix

the matrix to search

Returns
Boolean
  • True mean the sub)matrix is in the main matrix

  • False mean the sub)matrix isn’t contained in the main matrix

Examples

>>> mat=gaussian(5,0,0)
>>> Print(mat)
| +1.000 | +4.000 | +6.000 | +4.000 | +1.000 |
| +4.000 | +16.000 | +24.000 | +16.000 | +4.000 |
| +6.000 | +24.000 | +36.000 | +24.000 | +6.000 |
| +4.000 | +16.000 | +24.000 | +16.000 | +4.000 |
| +1.000 | +4.000 | +6.000 | +4.000 | +1.000 |
printed
>>> xtract=mat.xtract_sub_matrix([1,1],[4,4])
>>> Print(xtract)
| +16.000 | +24.000 | +16.000 |
| +24.000 | +36.000 | +24.000 |
| +16.000 | +24.000 | +16.000 |
printed
>>> mat2=unit(5)
>>> Print(mat2)
| +1.000 | +0.000 | +0.000 | +0.000 | +0.000 |
| +0.000 | +1.000 | +0.000 | +0.000 | +0.000 |
| +0.000 | +0.000 | +1.000 | +0.000 | +0.000 |
| +0.000 | +0.000 | +0.000 | +1.000 | +0.000 |
| +0.000 | +0.000 | +0.000 | +0.000 | +1.000 |
printed
>>> mat.find_sub_matrix(xtract)
True
>>> mat2.find_sub_matrix(xtract)
False