Giter VIP home page Giter VIP logo

matrix-static's People

Contributors

bjornbm avatar davidsd avatar wchresta avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

bjornbm davidsd

matrix-static's Issues

rref gives Left "Attempt to invert a non-invertible matrix"

Looks like rref gives wrong results:

rref <$> (fromLists [[1, 2, 1], [(-2), (-3), 1], [3, 5, 0]] :: Maybe (Matrix 3 3 Double))

gives:

Just (Left "Attempt to invert a non-invertible matrix")

Although Python's sympy gives:

m = Matrix([[1,2,1], [-2,-3,1], [3,5,0]])
m.rref()

(Matrix([
 [1, 0, -5],
 [0, 1,  3],
 [0, 0,  0]]), (0, 1))

`pure` can give a matrix with the wrong dimensions

The Applicative instance for Data.Matrix.Static.Matrix appears to simply inherit the Applicative instance from Data.Matrix.Matrix:

deriving ( Eq, Functor, Applicative, Foldable, Traversable

However, the pure implementation for Data.Matrix.Matrix just creates a 1 by 1 matrix:

http://hackage.haskell.org/package/matrix-0.3.6.1/docs/src/Data-Matrix.html#line-194

This seems to be a problem. (Forgive me if I missed something -- I have just been reading the code, and I haven't tested this issue.)

Data.Matrix.prettyMatrix is a strange Show instance

Data.Matrix.prettyMatrix produces a String that looks nice on its own, but it doesn't have some properties that a good Show instance should have.

Firstly, when embedded inside other Strings obtained from Show, the results can be very strange. In my code, I have some datatypes that contain matrices, and I am logging the results to a file after using a general pretty-printer (http://hackage.haskell.org/package/pretty-show-1.10/docs/Text-Show-Pretty.html). When the pretty printer encounters matrices, it gets completely confused because they do not look like normal Haskell expressions.

Secondly, derived instances of Show have the following property, according to the documentation: "The result of show is a syntactically correct Haskell expression containing only constants, given the fixity declarations in force at the point where the type is declared. It contains only the constructor names defined in the data type, parentheses, and spaces. When labelled constructor fields are used, braces, commas, field names, and equal signs are also used." Several datatypes try to mimic this property in their Show instances. For example, show applied to a Map gives something like fromList [(1,2), (3,4)].

I propose that the Show instance for a matrix should use toLists, so that, for example, show-ing the 2x2 identity matrix gives either

-- This is in the same spirit as Data.Map, and gives an expression
-- that can be copied and pasted into ghci to give a matrix
fromLists [[1,0],[0,1]]

or just

-- This is in the spirit of Data.Vector. It gives an expression that cannot
-- precisely be copied into ghci, but it does follow Haskell syntax and is
-- shorter/simpler than the above
[[1,0],[0,1]]

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.