Can't get exact solution. Why ?
- From: "eigen21@xxxxxxxxx" <eigen21@xxxxxxxxx>
- Date: 24 Feb 2006 00:04:00 -0800
I'm using Compaq Visual fortran 6.1 (window XP platform)
My problem is simple
I hope to solve x of A*x = b
A = [ 4 2 0 0 0 0 ;
2 4 2 0 0 0 ;
0 2 4 2 0 0 ;
0 0 2 4 2 0 ;
0 0 0 2 4 2 ;
0 0 0 0 2 4 ] --> symmetric
b = [1;1;1;1;1;1]
In matCAD. I can get solution
x =
0.214
0.071
0.143
0.143
0.071
0.214
BUT !!, when I used sparse solver DSSKYD in compaq fortran CXML, I get
strange result agian and agian...
x =
0.2198413
0.0603175
0.1595238
0.1206349
0.1190476
0.1904762
I set as following in code
:
:
PARAMETER IDEBUG = 7
PARAMETER NMAX = 1000
PARAMETER NMAX_SKY = 11000
PARAMETER NSIZE = 6
INTEGER(4) N
INTEGER(4) IAUDIAG(NMAX)
INTEGER(4) NAU
INTEGER(4) LDBX
INTEGER(4) NBX
INTEGER(4) IPARAM(100)
INTEGER(4) IWRK
INTEGER(4) IERROR
REAL(8) AU(NMAX_SKY)
REAL(8) RPARAM(100)
REAL(8) RWRK
:
:
REAL(8) A(NSIZE,NSIZE), BX(NSIZE)
:
:
! CONSTRUCT [A], [BX]
DO I=1,NSIZE
A(I,I) = 4.
BX(I) = 1.
ENDDO
DO I = 1, (NSIZE-1)
A(I,I+1) = 2.
A(I+1,I) = 2.
ENDDO
:
:
CALL CONVERT_TO_SKYLINE(A,AU,IAUDIAG,NAU)
! parameters
N = NSIZE
LDBX = NMAX
NBX = 1
IPARAM(1) = 100
IPARAM(2) = 1200
IPARAM(3) = 2*N
IPARAM(4) = 0
IPARAM(5) = IDEBUG
IPARAM(6) = 2
IPARAM(7) = 1
IPARAM(8) = 1
IPARAM(9) = 0
IPARAM(10) = 1
RPARAM(1) = 1.D-12
IWRK = IPARAM(3)
RWRK = 0.
CALL DSSKYD(N,AU,IAUDIAG,NAU, BX,LDBX,NBX, IPARAM,RPARAM,
IWRK,RWRK,IERROR)
:
:
SUBROUTINE CONVERT_TO_SKYLINE(A,AU,IAUDIAG,NAU)
REAL(8),INTENT(IN)::A(:,:)
REAL(8),INTENT(OUT)::AU(:)
INTEGER(4),INTENT(OUT)::IAUDIAG(:)
INTEGER(4),INTENT(OUT)::NAU
INTEGER LOC,COUNTER
DO I=1,NSIZE
! SEARCH NON-ZERO VALUE
DO J=1,I
! IF NON ZERO VALUE FOUND, EXIT
IF (A(J,I)<>0) THEN
LOC = J
GO TO 10
ENDIF
ENDDO
10 DO J=LOC,I
NAU = NAU + 1
COUNTER = COUNTER + 1
AU(COUNTER) = A(J,I)
ENDDO
IAUDIAG(I) = COUNTER
END DO
END SUBROUTINE
**********************************************
I can't find mistake here
Could you find the mistake in this code ?
Thank you in advance
.
- Follow-Ups:
- Re: Can't get exact solution. Why ?
- From: eigen21@xxxxxxxxx
- Re: Can't get exact solution. Why ?
- From: Mr Hrundi V Bakshi
- Re: Can't get exact solution. Why ?
- From: e p chandler
- Re: Can't get exact solution. Why ?
- From: Arjen Markus
- Re: Can't get exact solution. Why ?
- Prev by Date: Re: Easy way to put Comment in CVF
- Next by Date: Re: Variable length/precision formats?
- Previous by thread: Trouble with MPI, populating matrix
- Next by thread: Re: Can't get exact solution. Why ?
- Index(es):