How is rating calculated ?

I want to know how is the rated calculated for the codechef contests, for the long contest, short contest and lunchtime contests.

The long contest now allows partial points also.

Please explain how is the rating of all the contests calculated.

Thanks in advance!!!

The rating of CodeChef is based on ELO. Read more about it here:
http://blog.codechef.com/2010/12/27/a-surprise-in-store-this-new-year/

The rating algorithm is a function which takes 2 inputs in the form of Ratings before this contest and Ranks in this contest and gives the final Rating as output.
So rating before is already there in your a/c, now left second function i.e. rank. The ranking system is different for Short, Long & Lunchtime. You can read about ranking mechanism here :
http://www.codechef.com/rankings/