ensign.cp_decomp.are_close

are_close(decomp0, decomp1, rtol=1e-05, atol=1e-08)[source]

Checks if weights and factor matrices are close according to tolerance.

Uses the following formula element-wise on weights and factor matrices:

abs(d0 - d1) <= (atol + rtol * abs(d1))

If this inequality is True for all elements then True is returned.

Parameters
decomp0, decomp1CPDecomp

Decompositions to compare for closeness

rtolfloat, optional

Relative tolerance

atolfloat, optional

Absolute tolerance

Returns
are_closebool

True if the decomposition weights and factor matrices are element-wise equal within a tolerance.