For Programmers: Free Programming Magazines  


Home > Archive > Fortran > July 2004 > fortran equivalent to Matlab sparse matrix









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author fortran equivalent to Matlab sparse matrix
Thomas

2004-07-01, 3:57 am

Hi everybody

I am looking for a Fortran equivalent to the sparse function of
Matlab. I have three vectors (row_index,column_index,value), where
multiple entries to the same coordinate occur. The sparse function of
Matlab does the transformation into a sparse matrix very efficiently;
Is there anything like that in Fortran?
Any other ideas how to get a finite element stiffness matrix assembled
directly into a sparse matrix are appreciated as well!!

Thanks a lot

Thomas
B52B

2004-07-01, 8:57 am

Hi,

There are plenty of sparse formats and solvers.
SPARSKIT, Y12M, UMFPACK come to mind.

Regards,
B52


Thomas wrote:
> Hi everybody
>
> I am looking for a Fortran equivalent to the sparse function of
> Matlab. I have three vectors (row_index,column_index,value), where
> multiple entries to the same coordinate occur. The sparse function of
> Matlab does the transformation into a sparse matrix very efficiently;
> Is there anything like that in Fortran?
> Any other ideas how to get a finite element stiffness matrix assembled
> directly into a sparse matrix are appreciated as well!!
>
> Thanks a lot
>
> Thomas

andy2o

2004-07-01, 8:57 am

thomas_kocher@yahoo.com (Thomas) wrote in message news:<1c5c9a24.0406302243.3df59ec9@posting.google.com>...
> Hi everybody
>
> I am looking for a Fortran equivalent to the sparse function of
> Matlab. I have three vectors (row_index,column_index,value), where
> multiple entries to the same coordinate occur. The sparse function of
> Matlab does the transformation into a sparse matrix very efficiently;
> Is there anything like that in Fortran?
> Any other ideas how to get a finite element stiffness matrix assembled
> directly into a sparse matrix are appreciated as well!!
>
> Thanks a lot
>
> Thomas


Hi,

I don't know of anything quite as easy to use as Matlab's sparse
matrix functions. But there is a lot of choice for sparse matrix
libraries for Fortran, and other langauges. Many libraries are free.

There are several data formats in use for sparse matrix work. You will
need to choose a library that contains the computational functionality
you need, then convert your data into that library's preferred format.
Some libraries (HSL) have routines for converting between formats. The
format you have now is actually considered not efficient enough (due
to memory access pattern considerations) for use in calculations by
most libraries. The conversion routine should be easy to write.

Look at Jack Dongarra's guide to linear algebra software on the web,
at:

http://www.netlib.org/utk/people/Ja...arra/la-sw.html

for more information and a list of high quality libraries. I've used
routines from the HSL archive and the SLAP library linked from that
page. Both have been very successful for me (for FEM calculations).

For theoretical background see Yousef Saad's book on Iterative methods
which is online at http://www-users.cs.umn.edu/~saad/books.html If you
have questions about which type of sparse solver is appropriate for
your problem, you could post to sci.math.num-analysis.

Hope that helps.
andy

PS: Of course before you proceed, you should check what special
properties or sparsity structures your system of equations has (if
any). Sparse solvers which take account of the structure of a problem
are normally very much more efficient than those designed for
completely general sparse matrices. Because finite element methods are
so widely used there is a lot of choice out there, and many libraries
(HSL in particular, I seem to remember) have specially taylored
subroutines for these types of sparse problems.

PPS: I think the HSL archive contains routines for sparse nonlinear
problems too - certainly some libraries do.
Anton Strarikov

2004-07-13, 4:00 pm

B52B wrote:

> Hi,
>
> There are plenty of sparse formats and solvers.
> SPARSKIT, Y12M, UMFPACK come to mind.
>
> Regards,
> B52


Yes, but...
SPARSKIT, for example
1) written in F77, that not the best language for sparse matrices
2) badly written in a way of not the best performance (I know what I say,
for example, when you sort matrix with CSR in requre array on nnz elements,
it could be too much if your scale is really big, and really not necessary,
you can use just quicksort for sorting row by row, it much faster and
require much less additional memory)
3) support only real datatype
and so on.
Most of the libraries (at least free) have limited functionality and similar
problems.
Of course, If I need routine only for multiplication and linear solver - you
can manage somehow..but..

Current version of my personal library support now 4 different formats,
with conversion, with interoperability between formats (for example
sumation of block-matrix and CSR matrix, derect summation without
converting block-matrix to CSR), support different kind of datatypes and
interoperability between complex and real (for example not only suppoort
for A+B, when both complex or real, but also when one real and another is
complex and opposite) and so on.
And, for sure, if you need flexibility, it should be written in language
with dinammicaly allocatable memory, not F77. SO, my last investigations
telling me that there is still no good enough free library for sparse
matrices. So, I did it by myself :)


Anton.
beliavsky@aol.com

2004-07-13, 4:00 pm


Anton Strarikov <antst@tnp.krasn.ru> wrote:[color=darkred]
>B52B wrote:
>

Fortran codes for manipulation of sparse matrices are listed at the Open
Directory at http://www.dmoz.org/Computers/Progr...Algebra/Sparse/
. SMLIB is worth considering.




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com