1
$\begingroup$

I am looking for a simple subroutine in Fortran 90 (GNU Compiler) to solve linear equation of the type $AX=B$, where $A$ is an $n\times n$ symmetric matrix stored in the form of symmetric skyline matrix. I want a solution of this type:

X = skysolve(A,p,X,B,n)
A = {11,22,13,0,33,24,34,44,55,16,0,0,46,56,66}

where p is the index of diagonal elements p = {1,2,5,8,9,15}

It would be better if I could just have a simple subroutine kind of solution to this situation rather than a library.

$\endgroup$
3
  • $\begingroup$ Welcome to SciComp.SE! Am I correct in assuming that you are re-asking this question after having registered? If so, it might make sense to edit this question to include the additional information in the other question (and also describe what a "skyline matrix" is) and then delete the old question (if you can; otherwise flag for a moderator to delete it). $\endgroup$ Jan 16, 2016 at 13:45
  • $\begingroup$ Yes that is correct, I am unable to delete that question and unless I remove that content, cannot duplicate it here $\endgroup$ Jan 16, 2016 at 13:52
  • $\begingroup$ I've copied the content for you -- if that's not what you want, feel free to revert the edit (or make a comment). To edit your question yourself (to include the definition of a skyline matrix, for example ;)), you can use the grey edit link under the tags. $\endgroup$ Jan 16, 2016 at 14:25

1 Answer 1

3
$\begingroup$

I suggest taking a look at the FEAPpv finite element code written by Robert Taylor to accompany this book:

http://www.amazon.com/The-Finite-Element-Method-Fundamentals/dp/1856176339

You can download the fortran source code from this page:

http://www.ce.berkeley.edu/projects/feap/feappv/

The code contains two subroutines, datri and dasol that perform the factorization and solution, respectively, of a matrix stored in skyline format; you first call datri to the factor the matrix and then call dasol to perform the forward and backward substitutions.

There are sufficiently detailed comments in both subroutines to be able to use them. Here is a simple example with five equations and a symmetric matrix (entries below the diagonal are not included):

      program test
C
C  Solve A*U = b      
C        [2   -2    0    0   -1]
C        [0    3   -2    0    0]
C  A =   [0    0    5   -3    0]
C        [0    0    0   10    4]
C        [0    0    0    0   10] 
C
C The solution, U, is: 636.,619.,292.,74.,34.
C
        parameter (neqs = 5)
        real*8 au(7), ad(neqs), b(neqs), energy
        integer jp(neqs)
        data au/-2.,-2.,-3.,-1.,0.,0.,4./
        data ad/2.,3.,5.,10.,10./
        data b/0.,1.,0.,0.,0./
        data jp/0,1,2,3,7/
        call datri(0, au, ad, jp, neqs, neqs)
        call dasol(0, au, ad, b, jp, neqs, neqs, energy)
        write(6,*) 'solution', (b(i), i=1,neqs)
      end
$\endgroup$
2
  • $\begingroup$ I appreciate these subroutines, which are simpler in a way but there are many dependent subroutines and headers. I have tried adding them all and when I compiled I get a few warnings (Warning 3 Incorrect level in dot) and the result ends up with 'NaN' for all. I am using GNU Fortran using Codeblocks. $\endgroup$ Jan 17, 2016 at 7:20
  • $\begingroup$ I tested with gfortran 4.8.3 and get no warning messages. I added the exact solution to the comments in the example code above, by the way. $\endgroup$ Jan 17, 2016 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.