2 posts
• Page **1** of **1**

I am a mechanical engineer - matrix stuff not being my friend - I have a sparce matrix, 5 x 5. I believe after some reading that a SLV-type solution, with scaled elements, gives me the best shot. Can someone advice on which routines in LAPACK to start with. A search indicated no scaling routines (can this be correct) ?? Thanks.

- Fred Lang
**Posts:**1**Joined:**Fri Aug 02, 2013 1:27 pm

Hi Fred,

your system is small (5x5) so don't consider it sparse.

Consider it as full with some zeros in it.

SLV-type

Getting away from matrices, I assume you have a linear system of 5 equations in

5 unknowns (x1,x2,x3,x4,x5) = x that you want to find.

You will also have 5 right hand sides (b1,b2,b3,b4,b5) = b.

In matrix terms: solve Ax = b where A is a 5x5 matrix

Suppose you had

then you could have a data file like

1.0 0.0 2.0 0.0 3.0

0.0 1.0 0.0 -5.0 0.0

0.0 7.0 0.0 0.0 4.0

6.0 0.0 0.0 2.0 0.0

0.0 0.0 1.0 1.0 1.0 : matrix a

8.0 9.0 5.0 2.0 3.0 : rhs b

Try something simple first

Scaling: if your system contains very big numbers and/or very small numbers then

scaling would be a good idea (see dgesvx) . But, go for smple first.

your system is small (5x5) so don't consider it sparse.

Consider it as full with some zeros in it.

SLV-type

Getting away from matrices, I assume you have a linear system of 5 equations in

5 unknowns (x1,x2,x3,x4,x5) = x that you want to find.

You will also have 5 right hand sides (b1,b2,b3,b4,b5) = b.

In matrix terms: solve Ax = b where A is a 5x5 matrix

Suppose you had

- Code: Select all
`x1 + 2*x3 + 3*x5 = 8`

x2 - 5*x4 = 9

7*x2 + 4*x5 = 5

6*x1 + 2*x4 = 2

x3 + x4 + x5 = 3

then you could have a data file like

1.0 0.0 2.0 0.0 3.0

0.0 1.0 0.0 -5.0 0.0

0.0 7.0 0.0 0.0 4.0

6.0 0.0 0.0 2.0 0.0

0.0 0.0 1.0 1.0 1.0 : matrix a

8.0 9.0 5.0 2.0 3.0 : rhs b

Try something simple first

- Code: Select all
`double precision a(5,5), b(5)`

integer ipiv(5), info

read(5,*) (a(i,1:5),i=1,5)

read(5,*) b(1:5)

call dgesv(5,1,a,5,ipiv,b,5,info)

if (info==0) print*,'solution :', b(1:5)

Scaling: if your system contains very big numbers and/or very small numbers then

scaling would be a good idea (see dgesvx) . But, go for smple first.

- lawrence mulholland
**Posts:**24**Joined:**Mon Jun 11, 2012 6:33 am**Location:**NAG Ltd, Oxford, UK

2 posts
• Page **1** of **1**

Users browsing this forum: No registered users and 1 guest