Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you intend "matrix multiplication", there is no "right order": "matrix multiplication" is associative (http://en.wikipedia.org/wiki/Matrix_multiplication).

Numpy has a "matrix" type, so you can write:

        In [7]: A = numpy.matrix('1 2; 3 4; 5 6')                                                         
        In [8]: B = numpy.matrix('1 2 3; 4 5 6')                                                          
        In [9]: C = numpy.matrix('1; 2; 3')                                                               

        In [10]: A * B * C
        Out[10]: 
        matrix([[ 78],                                                                                    
                [170],                                                                                    
                [262]])                                                                                   
        
        In [11]: (A * B) * C                                                                              
        Out[11]:                                                                                          
        matrix([[ 78],
                [170],                                                                                    
                [262]])                                                                                   

        In [12]: A * (B * C)                                                                              
        Out[12]: 
        matrix([[ 78],                                                                                    
                [170],
                [262]])


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: