<s> from sympy . matrices . expressions . factorizations import lu , LofCholesky , qr , svd <EOL> from sympy import Symbol , MatrixSymbol , ask , Q <EOL> n = Symbol ( '<STR_LIT:n>' ) <EOL> X = MatrixSymbol ( '<STR_LIT:X>' , n , n ) <EOL> def test_LU ( ) : <EOL> L , U = lu ( X ) <EOL> assert L . shape == U . shape == X . shape <EOL> assert ask ( Q . lower_triangular ( L ) ) <EOL> assert ask ( Q . upper_triangular ( U ) ) <EOL> def test_Cholesky ( ) : <EOL> L = LofCholesky ( X ) <EOL> def test_QR ( ) : <EOL> Q_ , R = qr ( X ) <EOL> assert Q_ . shape == R . shape == X . shape <EOL> assert ask ( Q . orthogonal ( Q_ ) ) <EOL> assert ask ( Q . upper_triangular ( R ) ) <EOL> def test_svd ( ) : <EOL> U , S , V = svd ( X ) <EOL> assert U . shape == S . shape == V . shape == X . shape <EOL> assert ask ( Q . orthogonal ( U ) ) <EOL> assert ask ( Q . orthogonal ( V ) ) <EOL> assert ask ( Q . diagonal ( S ) ) </s>
