Stata 15 help for _assert_mreldif

Title

[P] _assert_mreldif -- Assert that two matrices are the same

Syntax

_assert_mreldif matexp1 matexp2 [, options ]

_assert_mreldifs matexp1 matexp2 [, options ]

_assert_mreldifp matexp1 matexp2 [, options ]

option Description ------------------------------------------------------------------------- tol(#) tolerance for testing; default = 1e-8 nonames suppresses test that row and column stripes match nolist suppresses listing matrices if not equal -------------------------------------------------------------------------

These commands are intended for authors of certification scripts -- do-files used to test that commands work properly; see [P] cscript.

Description

_assert_mreldif assert that the matrices matexp1 and matexp2 are the same within tolerance tol().

_assert_mreldifs asserts that the columns of the matrices matexp1 and matexp2 are the same within tolerance tol(), up to the columnwise signs. Comparing matrices of eigenvectors or singular vectors is an example in which a test of equality up to the column sign is appropriate.

_assert_mreldifp asserts that the two matrices are conformable and span the same linear subspaces, comparing the orthonormal projections on these subspaces.

These commands allow matrix expressions. Be sure to use quoted expressions or expressions without white space.

All comparisons involve mreldif(), and hence do not treat the first and second argument symmetrically.

Options

tol(#) specifies the tolerance for mreldif-testing of differences in the matrix elements. The default is 1e-8.

nolist suppresses the listing of the matrices if the equality test fails.

nonames suppresses the verification that the row and column stripes match. If the test fails, the offending stripes are shown.

Example

matrix D = (2+(1e-10), 1-(1e-10), 1e-10) matrix D = diag(D) matrix symeigen U V = D

matrix input T_U = ( 1, 0, 0 \ 0, 1, 0 \ 0, 0, 1 ) matrix input T_V = ( 2.0000000001, .9999999999, 1.00000000000e-10 )

// V and T_V should be the same (within tolerance) _assert_mreldif V T_V

// test equality of U and T_U up to columnwise change of signs

_assert_mreldifs U T_U _assert_mreldifs U T_U, tol(1e-6) _assert_mreldifs U T_U, tol(1e-6) nonames


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index