Archive for the ‘Maths’ Category

Mandelbulb

Thursday, December 3rd, 2009

I noticed this linked from both Atom and Real-time Rendering blogs. Cyril Crassin, the guy behind the amazing gigavoxels raytracing, has got a 3d Mandelbrot fractal rendering in real time.

As we know there isn’t actually a 3rd dimension to the imaginary plane so some manipulation is required. The chap who discovered a good way of transforming it to 3d ( the Mandelbulb ) has a website which you can find here. Well worth reading and some pretty amazing images!

As a side note: I’ve owned the book: “Real-time Rendering” for a number of years now and it is an invaluable resource. The Real-time Rendering blog mentioned above is the blog by the authors of the book.

3D Gaussian Convolution

Thursday, July 30th, 2009

There hasn’t been much in the way of posts here lately as I’ve been really busy at work getting some new components built into the systems I work on. Not really hard but it’s frustrating things like trying to get various components and libraries written in different languages to work together. So lately I’ve not had the energy to do much work on the computer once I get home…

There has been a bit of interest in my 3D Gaussian convolution kernels. Although I explained the technique mathematically in an earlier post I never actually posted the code. As it is rather quick and quite a novel way of calculating the convolution for a xy plane I decided to post it so everyone can benefit from / improve upon the technique.  As always comments / bug reports etc are always welcome :)

(more…)

Numerical Precision

Friday, July 3rd, 2009

Numerical precision is an ongoing concern of mine especially in big / long running simulations and solvers.

I came across an article by Rob Farber on the scientificcomputing.com site this morning that asks the question “How much is Enough?”.  Although no definitive answers are presented the author summarizes the current and future concerns over accuracy.

Personally I don’t believe floating point is the way forward. Floating point is fast to calculate in hardware but is not always an ideal way of representing numbers. Although the various branches of mathematics are largely base independent humans are most comfortable with base 10 while computers are of course most comfortable with base 2. This does result in some situations when a calculation in base 10 with only a few decimals of precision gives precise results whereas a calculation in base 2 is incapable of giving a precise result even given N bits of precision although the result is probably acceptable after n bits.

I’m not presenting any solution to the precision problem, but merely pointing out that sometimes the issue is caused by:   using base 2 for calculations  and/or  the floating point representation of these numbers.

CUDA Emulator Output

Wednesday, June 10th, 2009

As many people have noticed the same code executed in Emulator mode gives different floating point results from the kernels run in Debug or Release mode.

Although I know what causes this I have never bothered to investigate the actual differences as most of the stuff I write runs entirely on the GPU. Recently I have had to compare results on the CPU<->GPU and wrote some code to change the FPU settings. Firstly a quick explanation:

By default the CPU (FPU) is set to use 80 bit floating point internally. This means that when you load in an integer (fild) or a single / double float (fld) it gets converted to a 80 bit number inside the FPU stack. All operations are performed internally at 80 bits and when storing the result it converts back to the correct floating point width (single / double)  (fst / fstp). 

This method of operation is desirable as it reduces the effect of rounding / truncating on the intermediate results.  Of course while very useful for computing on the CPU this is not how the CUDA devices operate.

(more…)

Large Data Sets and 3D Gaussian

Friday, April 17th, 2009

Firstly a small fix:

In the post about the 2D gaussian there was a typo:

f(2,2) = Ae^{-(\frac{2^2+2^2}{1.4^2})}

should read

f(2,2) = Ae^{-(\frac{2^2+2^2}{2(1.4^2)})}  

this has now been fixed in the original article.

 

Last night I successfully made my 2048*2048*2048 * 2 bytes data set. The random data was generated using the mersenne twister algorithm with a fixed seed so I can recreate it later if needed. I also created a smaller set of 512×512x512 in order to interactively test my kernels.

(more…)

2D Gaussian Function

Friday, March 27th, 2009

In my last post I mentioned using 5×5 Gaussian kernel as a Point Spread Function to make an image blurry.

What occured to me last night is that these Gaussian kernels are demonstrated so many times in image processing without any explanation of the underlying function used. A Gaussian function is in fact continuous and not like the 5×5 matrix I showed at all.

So to explain a bit more lets derive our 5×5 Gaussian kernel in the last post from the 2D Gaussian function (I’ve installed LaTex plugin to wordpress to make it a bit more readable):

(more…)