- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am new to MKL. I started by doing a basic example which creates an NxM matrix A. A consists of random numbers between -1 and 1 and can contain one digit after the decimal point only. For example, -0.1 might be there but not -0.12
I then used dgemm to calculate A*Atranspose.
I compared the answer to my manual calculation
For some elements, there appears to be some error.
For example if my manual calculation calculates 123.45 then dgemm is returning 123.45000000006789 . The lower digits are obviously junk as it is simply a sum of products of numbers to one decimal place each.
Is this expected behaviour?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes, this is an expected rounding error results
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for the response. Is there any advised way to handle this?
I was surprised to see it as I thought it would just be a simple "sumproduct" type of calculation for numbers exact to one significant digit, and therefore that each product would be exact, but I guess that there is some optimisation going on underneath.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your inputs cannot be represented exactly as binary floating point numbers. Try googling for "ieee 754 calculator".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
RJ: Your manual calculations will not match the computed results unless both were performed using the same number system. In particular, if your manual calculations were performed using base 10, you should expect differences.
Consider the number 0.110. Its mantissa can be expressed exactly in decimal with a single significant digit. In IEEE-64 bit binary, even 53 bits are not sufficient to represent the same number exactly.

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