SmtC: Show me the Code
Ole Peter Smith
Instituto de Matemática e Estatística
Universidade Federal de Goiás
http://www.olesmith.com.br

Matrices
O conhecimento adquirimos com os livros e os mestres.
A sabedoria aprendemos com o povo e os humildes.
Cora Coralina
< Matriz | Multiplicão | Escalar >

Multiplicação de Matrizes

  • Branch segundo argumento:
    Python Listing: ../../Code/Matrix.py.
        def __mul__(A,B):
            ## Matrix mul: Branches over type of second argument, B:
    
            if (B.__class__.__name__ in [ 'int','float' ]):
                #Scalar: Return Matrix,
                return A.__mul_Scalar__(B)
                
            if (B.__class__.__name__ in [ 'Vector' ]):
                #Vector: Return Vector,
                return A.__mul_Vector__(B)
            
            if (B.__class__.__name__ in [ 'Matrix' ]):
                #Matrix: Return Matrix
                return A.__mul_Matrix__(B)
            
            print "Matrix.mul: Invalid second argument type",B
            exit()
            
    
    • Escalar;
    • Vetor;
    • Matriz.
  • Scalar or Vector como Primeiro argumento [; c \underline{\underline{A}};] e [; \underline{v}^T \underline{\underline{A}};]
    Python Listing: ../../Code/Matrix.py.
        def __rmul__(A,B):
            return A.__mul__(B)
        
    
< Matriz | Multiplicão | Escalar >
Messages:
0 secs.