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

from __future__ import print_function, division 

 

from sympy.matrices.expressions import MatrixExpr 

from sympy.core import S 

 

class DiagonalMatrix(MatrixExpr): 

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

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

 

    def _entry(self, i, j): 

        return S.Zero if i != j else self.arg[i, 0] 

 

class DiagonalOf(MatrixExpr): 

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

    shape = property(lambda self: (self.arg.shape[0], S.One)) 

 

    def _entry(self, i, j): 

        return self.arg[i, i]