Erlang/OTP Forums

Author Message

<  Open Telecom Platform (OTP)  ~  Matrix manipulation.

aquarin
Posted: Mon Sep 04, 2006 12:01 pm Reply with quote
Joined: 04 Sep 2006 Posts: 1
What is the best way to represent Matices (list of lists?) and manipulate them, i.e. multiplication addition etc.
View user's profile Send private message
oscarh
Posted: Wed Sep 06, 2006 8:19 am Reply with quote
User Joined: 20 Jul 2006 Posts: 22
If the size of the matrice is static (or changes are *very* rare) you could use tuples,

Lists however are very convenient to traverse.
View user's profile Send private message
michal
Posted: Wed Sep 06, 2006 1:20 pm Reply with quote
User Joined: 20 Jul 2006 Posts: 44 Location: London
You can take a look at http://dada.perl.it/shootout/matrix.erlang.html

This implementation uses tuple of tuples to represent a matrix. In this case it is quite easy to access an element:
Code:
element(Column, element(Row, Matrix))

but as pointed out by Oscarh such a representation can be expensive. Every time you update an element, the whole matrix needs to be recreated.

_________________
http://www.erlang-consulting.com
View user's profile Send private message
aquarin2
Posted: Fri Sep 08, 2006 11:44 am Reply with quote
Joined: 05 Sep 2006 Posts: 1
No, the size of matrices is variable. I have created simple module that uses lists to represent matrices.
View user's profile Send private message
jay
Posted: Sat Sep 09, 2006 4:12 pm Reply with quote
User Joined: 06 Sep 2006 Posts: 139 Location: Los Angeles, CA USA
Ulf wrote a user contributed package called "lines". You could have a tuple for each line. His code was designed for accessing each line quickly. You could at least get some ideas from his code.

http://www.erlang.org/user.html
View user's profile Send private message Visit poster's website

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum