Haskell Linear Algebra Matrix Library for Arbitrary Element Types [closed] - haskell

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm looking for a Haskell linear algebra library that has the following features:
Matrix multiplication
Matrix addition
Matrix transposition
Rank calculation
Matrix inversion is a plus
and has the following properties:
arbitrary element (scalar) types (in particular element types that are not Storable instances). My elements are an instance of Num, additionally the multiplicative inverse can be calculated. The elements mathematically form a finite field (𝔽2256). That should be enough to implement the features mentioned above.
arbitrary matrix sizes (I'll probably need something like 100x100, but the matrix sizes will depend on the user's input so it should not be limited by anything else but the memory or the computational power available)
as fast as possible, but I'm aware that a library for arbitrary elements will probably not perform like a C/Fortran library that does the work (interfaced via FFI) because of the indirection of arbitrary (non Int, Double or similar) types. At least one pointer gets dereferenced when an element is touched
(written in Haskell, this is not a real requirement for me, but since my elements are no Storable instances the library has to be written in Haskell)
I already tried very hard and evaluated everything that looked promising (most of the libraries on Hackage directly state that they wont work for me). In particular I wrote test code using:
hmatrix, assumes Storable elements
Vec, but the documentation states:
Low Dimension : Although the dimensionality is limited only by what GHC will handle, the library is meant for 2,3 and 4 dimensions. For general linear algebra, check out the excellent hmatrix library and blas bindings
I looked into the code and the documentation of many more libraries but nothing seems to suit my needs :-(.
Update
Since there seems to be nothing, I started a project on GitHub which aims to develop such a library. The current state is very minimalistic, not optimized for speed at all and only the most basic functions have tests and therefore should work. But should you be interested in using or helping out developing it: Contact me (you'll find my mail address on my web site) or send pull requests.

well, I'm note really sure how much relevant my answer is but Im having good experiences with GNU GSL library and there is a wrapper for haskel:
http://hackage.haskell.org/package/bindings-gsl
Check it out, maybe it will help you

Related

Redoing the standard classes [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
As evidenced by the Typeclassopedia, the current stack of classes imported from category theory is a bit of a tangled accident of history, rather than a beautiful coherent whole.
In particular, this makes it rather difficult to follow what's happening.
What should this stuff look like, if petty concerns like backwards compatibility, code duplication or tractably short type signatures were not an issue?
For some subsets of the standard classes there have been attempts to give revised hierarchies.
Numeric Typeclasses
The Numeric Prelude. An experimental alternative hierarchy of numeric type classes
In particular, it provides a much richer set of mathematical abstractions.
Besides this, there are many other alternate designs:
Yet Another Prelude - a notable alternate prelude from Ross Paterson:
prelude-extras - higher order prelude functions
classy-prelude - a prelude with more classes
Categoric Typeclasses
There's been less work on the category-inspired classes, such as Functor, Monad, Monoid, Applicative and of course, Category.
The most important work is the
category-extras package, which provides a very rich library indeed, including the famous zygohistoprepromorphism.
Regarding the "categorical" classes, there is also The Other Prelude.
The class hierarchy outlined there has been implemented in Frege.

Haskell libraries overview and their quality [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I want to use Haskell in production. It has a lot of libraties but not all of them are stable, ready-to-use and well-developed. Some libraries with interesting conceptions have experimental status. Many libraries are still in minor versions (0.0.1 for example). Some of them just abandoned. Hackage too huge to monitor them, so I need a brief slice of the current libraries state, their prospects and suitability for use.
I understand that question is very broad, but this information will be useful to anyone in any way. Here we can gather information bit by bit and then use it for an informative paper.
So what libraries I can use for:
Fast arrays capable of handling millions of items
Fast and powerful maps (probably, Data.Map?)
Fast, generic and convenient trees
Queues, hashtables
Regular expressions
Finite state machines
Neural networks, genetic algorithms
Mathematical calculations
Physics (wich can be used in game developing)
GUI
Image processing (we have various image formats actually)
Working with databases (maybe ORM or some DSLs to generate SQL)
Functional reactive programming
OpenGL bindings (yes, HOpenGL is good), OpenAL and OpenCL bindings
Parsing (Parsec is great I think)
Multithread and parallel programming
Network
Multipurpose game engines
Something else?
What is also interesting to have the tools for:
Testing (QuickCheck)
Logging (Maybe hslogger)
Profiling
Debugging
Here the links to the similar topics:
What are the best Haskell libraries to operationalize a program?
Regex & String Libraries in Haskell
Libraries for strict data structures in Haskell
Memory efficient strings in Haskell
Which Haskell library for computer graphics geometry?
Which Haskell XML library to use?
Other links
Applications and libraries (list and brief description)
Regular expressions
Haskell libraries you should use
There are a hell of a lot of Haskell libraries now. What are we going to do about it?
Popular Haskell Packages: Q2 2010 report
Thank you.
I'll leave this as a community wiki - others people please feel free to add items or commentary in a reasonably concise manner.
Fast arrays capable of handling millions of items: Repa, Vector.
Fast and powerful maps: containers and unordered-containers.
Fast, generic and convenient trees:
Queues, hashtables: See the hashtables package for the latest and greatest.
Regular expressions: regex-pcre, regex-tdfa
Finite state machines: fsmActions - but it has version 0.4.3 alpha; fst - but not exactly a FSM. In some cases FRP will be useful instead of true FSM.
Neural networks, genetic algorithms: HNN is well established. As far as GA, we really have a framework (GA) and something that looks more complete (hgalib), but I haven't inspected it closely.
Mathematical calculations: hmatrix
Physics: dimensional.
GUI: GTK works well. I get the sense that wxhaskell generates more questions per-capita, but that's an informal impression.
Image processing: Parsing? Juicy-Pixels and JuicyPixels-Repa.
No, Image processing! The CV, Friday, yarr
Working with databases: Consider using the persistent-* wrappers, but also look at HDBC. PostgreSQL is stable. For Cassandra there are several but consider cql.
Functional reactive programming: Reactive-banana, netwire
OpenGL bindings: OpenGL, GL.
Parsing: Parsec, attoparsec, polyparse, frisby.
Multithread and parallel programming - See the parallel package and Control.Concurrency. monad-par is relatively new but frequently easier to reason about than the basic parallel library. See also async for concurrent IO.
Network - Depends. Network with blaze-builder, cereal, or binary. Also consider network-{conduit, enumerator, pipes}. There are several client/server wrappers out there as well.
Multipurpose game engines: For learning? gloss. Otherwise you probably need to roll your own but make use of OpenGL, GLUT, GTK, FRP, ogre bindings, SDL, and perhaps FunGEn if it's back on track.
Configuration management: configurator, config-ini.
XML Process: HaXml, HXT, xml-conduit - good, stable and powerful libraries.
Tools:
Testing - QuickCheck, LazySmallCheck, Test-Framework, hspec, HUnit
Logging - Yep, hslogger or dlist with the writer monad if that's all you need.
Profiling - hpc, thread scope, criterion, GHC time and space profiling utilities.
Debugging - GHCi debugging, unsafe (trace) debugging, making better property tests.
Related Questions:
Haskell library for 2D drawing
Filling the enclosed areas with random colors - Haskell - Friday

the meaning of lightweighted object [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Please, gurus, give me a detailed explanation of, in the Object-Oriented programming world, what is lightweight object? And in other computer science fields, what does lightweight means then? Is lightweight a design pattern? Is lightweight good, is bad?
There are many meanings for lightweight, but normally it means the object which has less amount of data or which process less amount of data. Sometimes a thread is called as a lightweight process as it does a less things than a process do. Its processing is also fast than the process. A lightweight object is one which has less amount members and which are of basic types (int, float) as member variables. A light function is the one which does very less things compared to others. Normally these are inline functions. (in C context).
There is no such patterns as lightweight pattern. But Normally the systems should be consists of lightweight objects so that the maintaining those objects could be easy.
The advantages are simple debugging, maintenance and easy understanding of code. The disadvantage could be lots of objects.
There is no lightweight pattern as such but the term is fairly used in the industry.
Lightweight X tend to be used in the case where we have a somewhat well known structure X. Lightweight X is then a version of X using fewer resources in some way or the other - or is subtly different from X in some way.
The term, as is the case for most computer science, is not well-defined and is loosely used.

Common programming mistakes for Haskell developers to avoid? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
In the spirit of the other common mistakes in questions, what are the most common mistakes that Haskell programmers make? I've been teaching myself Haskell for a little while and I am starting to feel comfortable enough with the language to start applying it in the real world.
The most common mistake I know of is introducing a space leak through lazy evaluation. There are lots of ways to achieve this mistake, but one that especially nails programmers with other functional-programming experience is to put a result in an accumulating parameter, thinking that the accumulating parameter will take constant space. In many cases the accumulating parameter takes linear space because parameters are not evaluated.
Another common mistake is to forget that let is always recursive. An unintentional
let x = ... x ...
can lead to baffling outcomes.
Most other common bad experiences manifest not as mistakes but as trouble getting programs past the type checker, or difficulty understanding the monadic I/O model. Difficulties with list comprehensions and with do notations occur occasionally.
In general the difficulties faced by beginning Haskell programmers include
Large language with many dark corners, especially in the type system
Trouble getting programs to compile, especially when they do I/O
Doing everything in the IO monad
Great difficulty predicting the time and space behavior of lazy functional programs
A common mistake for beginning Haskell programmers is to forget the difference between constructor and type namespaces. That was such a beginner's mistake that I'm about embarrassed to have my name attached to it, but I'm pretty confident that others will stumble upon that answer when they have a similar problem, so may as well keep it out there.
The difference between [] and [[]]: the empty list and the list with 1 element, namely the empty list. This one especially pops up in base cases of recursive functions.
Use non tail-recursive functions or not strict folds occurring to stack overflow.

Are units of measurement unique to F#? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I was reading Andrew Kennedy's blog post series on units of measurement in F# and it makes a lot of sense in a lot of cases. Are there any other languages that have such a system?
Edit: To be more clear, I mean the flexible units of measurement system where you can define your own arbitrarily.
Does TI-89 BASIC count? Enter 54_kg * (_c^2) and it will give you an answer in joules.
Other than that, I can't recall any languages that have it built in, but any language with decent OO should make it simple to roll your own. Which means someone else probably already did.
Google confirms. For example, here's one in Python. __repr__ could easily be amended to also select the most appropriate derived unit, etc.
CPAN has several modules for Perl: Physics::Unit, Data::Dimensions, Class::Measure, Math::Units::PhysicalValue, and a handful of others that will convert but don't really combine values with units.
Nemerle had compiler-checked Units of Measure in 2006.
http://nemerle.org
http://nemerle.org/forum.old/viewtopic.php?t=265&view=previous&sid=00f48f33fafd3d49cc6a92350b77d554
C++ has it, in the form of boost::units.
I'm not sure if this really counts, but the RPL system on my HP-48 calculator does have similar features. I can write 40_gal 5_l + and get the right answer of 156.416 liters.
I believe I saw that Fortress support this, I'll see if I can find a link.
I can't find a specific link, but the language specification makes mention of it in a couple of places. The 1.0 language specification also says that dimensions and units were temporarily dropped from the specification (along with a whole heap of other features) to match up with the current implementation. It's a work in progress, so I guess things are in flux.
F# is the first mainstream language to support this feature.
There is also a Java specification for units at http://jcp.org/en/jsr/detail?id=275 and you can already use it from here http://jscience.org/
Nemerle has something much better than F# !
You should check this one : http://rsdn.ru/forum/src/1823225.flat.aspx#1823225 .
It is really great .
And you can download here : http://rsdn.ru/File/27948/Oyster.Units.0.06.zip
Some example:
def m3 = 1 g;
def m4 = Si.Mass(m1);
WriteLine($"Mass in SI: $m4, in CGS: $m3");
def x1 = Si.Area(1 cm * 10 m);
WriteLine($"Area of 1 cm * 10 m = $x1 m");
I'm pretty sure Ada has it.
well I made QuantitySystem library especially for units in C#, however its not compile time checking
but I've tried to make it run as I wanted
also it supports expansion so you can define your unique units
http://QuantitySystem.CodePlex.com
also it can differentiate between Torque and Work :) [This was important for me]
the library approach is from Dimension to units
all I've seen till now units only approach.
I'm sure you'd be able to do this with most dynamic languages (javascript, python, ruby) by carefully monkey-patching some of the base-classes. You might get into problems though when working with imperial measurements.

Resources