Coder Social home page Coder Social logo

linalg's People

Contributors

yklcs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

linalg's Issues

Cannot Transpose Non-square Matrices

Transposing a matrix is well defined even if a matrix is non-square. However, this module keeps failing to transpose a non-square matrix. The code was
M = linalg.Matrix([[1],[2],[3]])
M.T()
and this led to an IndexError.

Traceback (most recent call last):
File "<pyshell#10>", line 1, in
M.T()
File "C:\Users\SYJ\AppData\Local\Programs\Python\Python36\lib\site-packages\linalg\types.py", line 63, in transpose
return linalg.unary.transpose(self)
File "C:\Users\SYJ\AppData\Local\Programs\Python\Python36\lib\site-packages\linalg\unary.py", line 71, in transpose
return Matrix([[mat[a][b] for a in range(y)] for b in range(x)])
File "C:\Users\SYJ\AppData\Local\Programs\Python\Python36\lib\site-packages\linalg\unary.py", line 71, in
return Matrix([[mat[a][b] for a in range(y)] for b in range(x)])
File "C:\Users\SYJ\AppData\Local\Programs\Python\Python36\lib\site-packages\linalg\unary.py", line 71, in
return Matrix([[mat[a][b] for a in range(y)] for b in range(x)])
IndexError: list index out of range

I tried to transpose a different matrix,
M = linalg.Matrix([[1,2,3],[4,5,6]])
M.T()
and same error raised.

Traceback (most recent call last):
File "<pyshell#29>", line 1, in
M.T()
File "C:\Users\SYJ\AppData\Local\Programs\Python\Python36\lib\site-packages\linalg\types.py", line 63, in transpose
return linalg.unary.transpose(self)
File "C:\Users\SYJ\AppData\Local\Programs\Python\Python36\lib\site-packages\linalg\unary.py", line 71, in transpose
return Matrix([[mat[a][b] for a in range(y)] for b in range(x)])
File "C:\Users\SYJ\AppData\Local\Programs\Python\Python36\lib\site-packages\linalg\unary.py", line 71, in
return Matrix([[mat[a][b] for a in range(y)] for b in range(x)])
File "C:\Users\SYJ\AppData\Local\Programs\Python\Python36\lib\site-packages\linalg\unary.py", line 71, in
return Matrix([[mat[a][b] for a in range(y)] for b in range(x)])
File "C:\Users\SYJ\AppData\Local\Programs\Python\Python36\lib\site-packages\linalg\types.py", line 121, in getitem
return self.matrix[i]
IndexError: list index out of range

Maybe the location of variables 'x' and 'y' had been changed in this part?

return Matrix([[mat[a][b] for a in range(y)] for b in range(x)])

This should be...

return Matrix([[mat[a][b] for a in range(x)] for b in range(y)])

like this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.