Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library
- MKL results do not match with MATLAB results

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Dharma

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-29-2011
04:43 AM

80 Views

MKL results do not match with MATLAB results

I am trying to solve an equation of this form using mkl.

- This algorithm solves the equation
- betaTrans = transpose(conjg(beta));
- Imat is an Identity matrix
- zplus = 1i*eta;
- g = inv( (E+1i*eta)*Imat - alpha - betaTrans*g*beta);
- The above equation can alos be written as
- A*X*B*X + C*X + I = 0
- where the unknown X = g
- A = betaTrans
- B = beta
- C = - ((E+1i*eta)*Imat - alpha)
- I = Imat
- alpha, beta, and Imat are square matrices of size N=NW*NU

I have attached the matlab script, fortran code and the make file. Matlab version 2010a, ifort 12.0.0, mkl 10.3.

thanks

Reddy

Link Copied

6 Replies

mecej4

Black Belt

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-31-2011
07:42 AM

80 Views

Only after this question has been answered satisfactorily can one start talking about algorithms and their behavior.

Dharma

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-31-2011
08:24 AM

80 Views

ax

xinit = -c/b

y = xinit

ic=0

do while( Residue < 1E-5 )

ic=ic+1

x = (-c - ay

y = 0.75*x+0.25*y

diffX = abs(y-x)

Residue = ay

print*,ic,Residue,diffX

end do

Now, in the above algorithm, i would expect the solutions to have a similar convergence path if the intial guess is same even though the quadratic has two possible solutions(which may be same or different).

In the above algorithm the only critical thing which would differe in MATLAB vs fortran implimentation is solving the linear equation (Eqn1). I use a direct solution (LU decompositn and then solve). The iteration path ( values of Residue and diffX) match (upto 3rd or 4th digit) between matlab and fortran for a while and then suddenly fortran iteration takes differen path. Now this happens for a very specific case and for all other cases that I have tested the results seem to match.

Thanks

Reddy

Dharma

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-04-2011
09:32 AM

80 Views

Looks like the problem is due to matrix being ill conditoned. I am doing the following iteration

The system is a N=8. A,B,C and X are all N by N matrices.

do while(fixedpoint)

D = (A*Xold+B)

solve: DX = -C ( i tried both gesv and gesvx)

Residue = clange('F',N,N,DX+C,work)

! inverse Condition number of D goes to 1E-12 as the simulation progresses

! gesvx does imporve the conditon number to 1E-7

! Residue is not going below 1E-2

! where as for the same problem matlab is able to solve the system some how

! and the residue is near 1E-6 as the solution converges.

X = 0.75*X+0.25*Xold

Xold = X

Fnorm = clange('F',N,N,AX

fixedpoint = (Fnorm > 1E-6)

end do

Can you suggest a fix. Also any idea how is matlab able to handle ill conditoned matrix. All of my claculations are being done in single precesion.

Thanks

Reddy

timintel

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-04-2011
05:15 PM

80 Views

Quoting dharmareddy84@gmail.com

Dharma

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-04-2011
06:03 PM

80 Views

mecej4

Black Belt

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-05-2011
04:00 PM

80 Views

If, indeed, you have a problem + algorithm combination with a condition number of 1E-16, you are liable to lose 16 decimal digits in calculating your results. Neither single-precision (23 bits, or 6 to 7 decimal digits) nor double precision (53 bits, or 15 to 16 decimal digits) will suffice to give meaningful results after a loss of 16 decimal digits.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

For more complete information about compiler optimizations, see our Optimization Notice.