|
|
| Author |
Message |
|
| aquarin |
Posted: Mon Sep 04, 2006 12:01 pm |
|
|
|
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. |
|
|
| Back to top |
|
| oscarh |
Posted: Wed Sep 06, 2006 8:19 am |
|
|
|
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. |
|
|
| Back to top |
|
| michal |
Posted: Wed Sep 06, 2006 1:20 pm |
|
|
|
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 |
|
| Back to top |
|
| aquarin2 |
Posted: Fri Sep 08, 2006 11:44 am |
|
|
|
Joined: 05 Sep 2006
Posts: 1
|
| No, the size of matrices is variable. I have created simple module that uses lists to represent matrices. |
|
|
| Back to top |
|
| jay |
Posted: Sat Sep 09, 2006 4:12 pm |
|
|
|
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 |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
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
|
|
|