On Mar 9, 2010, at 1:28 AM, Per Vognsen wrote:

> Which is preferable depends on the nature of the changes that your
> matrices will undergo. For dense linear algebra, it's common for most
> of a matrix to change with every operation. Hence you won't reap any
> benefits from the persistence of Clojure's maps.
> 
> The problem with your first implementation isn't the use of flat
> arrays but the fundamental inefficiency of a low-level
> get-entry/set-entry interface. Even for a mutable matrix data
> structure, I would consider such a thing.
> 
Sure.  BTW, I am not trying to build a matrix library.    What I was looking to 
do was understand the various ways of binding heterogeneous state together in 
clojure, and used a simple matrix function as an example.    So far have 
learned that maps are pretty fast, though slower than the equivalent object 
member access. 


> Many sequence operations and virtually all linear algebra operations
> produce matrices with a shape and size that is predictable ahead of
> time. Mapping a function over a matrix yields a matrix of the same
> size (an example is scalar multiplication). Mapping a function over
> two matrices of the same size yields a matrix of the same size (an
> example is matrix addition). Transposing a matrix of size m x n yields
> a matrix of size n x m. Multiplying a matrix of size m x p with a
> matrix of size p x n yields a matrix of size m x n.

Indeed.   For matrix work I use the ejml library.   My example was just for 
learning purposes.   Thanks for all of the feedback

> 
> These are the kind of primitive operations you should build your
> interface on. With this, you can use float-arrays preallocated to just
> the right size, fill in the entries by whatever means (e.g. calls to
> user-provided functions in the case of mapping), and return that.
> Everything is purely functional from the exterior.

I agree that for most matrix work it is appealing to use in a pure-functional 
form externally. 

> 
> -Per

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to