Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

from __future__ import print_function, division 

 

from sympy.matrices.expressions import MatrixExpr 

from sympy import Q 

 

class Factorization(MatrixExpr): 

    arg = property(lambda self: self.args[0]) 

    shape = property(lambda self: self.arg.shape) 

 

class LofLU(Factorization): 

    predicates = Q.lower_triangular, 

class UofLU(Factorization): 

    predicates = Q.upper_triangular, 

 

class LofCholesky(LofLU): pass 

class UofCholesky(UofLU): pass 

 

class QofQR(Factorization): 

    predicates = Q.orthogonal, 

class RofQR(Factorization): 

    predicates = Q.upper_triangular, 

 

class EigenVectors(Factorization): 

    predicates = Q.orthogonal, 

class EigenValues(Factorization): 

    predicates = Q.diagonal, 

 

class UofSVD(Factorization): 

    predicates = Q.orthogonal, 

class SofSVD(Factorization): 

    predicates = Q.diagonal, 

class VofSVD(Factorization): 

    predicates = Q.orthogonal, 

 

 

def lu(expr): 

    return LofLU(expr), UofLU(expr) 

 

def qr(expr): 

    return QofQR(expr), RofQR(expr) 

 

def eig(expr): 

    return EigenValues(expr), EigenVectors(expr) 

 

def svd(expr): 

    return UofSVD(expr), SofSVD(expr), VofSVD(expr)