Archive

Archive for the ‘Fun’ Category

John 3:30 He must increase and I must decrease.

October 14th, 2013 1 comment
An interesting conversation that I’d lately picked with my beloved student and friend Gnana Sundar over facebook on John 3:30’s interpretation through a computer program snippet.

John 3:30 He must become greater and I must become lesser.

void john_3_30() {
jesus++;
self–;
}

Sudarsun Santhiappan: syntax error, unless instance variables “jesus” and “self” are globally defined (by who is a question you should answer). in some sense, you can also connect this relationship to holy trinity.

Gnana Sundar: Sir, did you check your class”path”? What “compiler” are you using?

Sudarsun Santhiappan: compiler” is analogous to the “religion”, which defines the book of rules for a good living (lifetime of the application). class”path” is analogous to the “help” that you get from other “runnable” wisdom in the “RunTime” called “life”.

Ulagammal Paramasivam: It shud be int john_3_30 as the return of this can’t be void.

Sudarsun Santhiappan: i would argue that the return type can only be a boolean (if at all), whether you attained sanity & solace or not. It cannot be a discrete or continuous evaluation as there is nothing to compare against. typically, add the line “return !self;”. does it make sense? The interpretation could be “have you given up yourself completely (to jesus, if you may add) ?”.

Gnana Sundar: Ulags: 🙂 …. I do not want to return from this method. I want this to run in an eternity loop 🙂

Sudarsun Santhiappan: Pragmatic Error: John 3:30 does not endorse one time ++ or –, it is an iterative process, if i may presume. Moreover, one time ++ or — is not a stable and a viable solution to minimization. Anything, that’s gradually minimized or maximized tend to be stable for better and longer. So, i would disagree to your point Gnana. 🙂

Gnana Sundar: Sir, I totally agree with you that John 3:30 does not endorse a one time ++ or –. It is a continuous process until eternity sets in. But I’m sure that the environment in which this is going to run is going to have infinite stack segment. If you say life is “RunTime”, the one who instantiated me would have to worry about stack overflow . When He can have the memory and a scalable enviroment to hold this universe and its contents, I’m pretty syre he can do better memory management and garbage collection

Just to give you some context. The Book of John is one of the four gospel books from the bible. It was written by John, one of the disciples of Christ.

In John 3:30, John the Baptist (he is not one of Jesus’ disciples, he is different from the author) says, “He must increase, but I must increase”. John the Baptist is considered to be a harbinger for Christ. He lived in the actual times when the Jews were “eagerly and for real” waiting for the Messiah. He had so many disciples and followers. He was considered to be a prophet. His calling in life was to prepare the way for Christ’ entry. When Christ started his ministry of healing people and teaching about the Kingdom of Righteousness, John had more followers than Christ. So pride and envy could have easily set in John. People, John’s disciples, John’s followers were eagerly waiting for John’s reaction. AT this point of time he uttered, its time… “He must increase and I must decrease” (thus the fulfilling the calling in his life).

In the same way when one accepts Christ in His heart, he/she should tune his/her heart and mind to say, “He must increase and I must decrease” and understand the actual calling and meaning of accepting Christ and their existence

By the way, I do not consider bible as a “religious” text. Religion limits the boundaries of this book and one’s life. It is open source . It is a set of God inspired writings, written by disciples for other disciples.

Sudarsun Santhiappan: Well said.

அண்ணத்துரையின் திருமண பத்திரிக்கை

September 15th, 2013 No comments

 

Annadurai's Wedding Invitation

சுயநலவாதம்

September 13th, 2013 No comments

வான் துறந்து வலி துறந்த மனமோ,
ஊண் துறந்து உயிர் துறந்த இருப்போ;
கோண் துறந்து கொடை துறந்த உலகோ,
கோல் துறந்து கொள்கை துறந்த இருப்போ;
இவ்விரு இருப்புமே சுயநலவாதந்தானே!

 
முதலிரண்டு அடிகளில், உள்நோக்கிய பயணத்தினால் ஏற்படக்கூடிய சுயநலத்தை அறியமுடியும். இப்பயணத்தில் தன்னை அறிய முற்படும்போது ஒருமை மட்டுமே தெரியும். “நான்” என்ற எண்ணம் மட்டுமே தெரியும். மேற்கொண்டு பயணப்படும்போது, “நான்” என்ற எண்ணமும் மறையும். அப்போது ஒருமையும் கூட இருக்காது. பயணப்படுபவர் மற்றவர் பார்வையில் சுயநலவாதியாகவே தெரிவார், ஏனெனில் உணர்ச்சியற்ற சமாதி நிலையில் இருப்பவரிடம் அன்பு மட்டுமே கிட்டும்; பாசமோ, பற்றோ, ஆசையோ, அச்சமோ, கோபமோ, வெட்கமோ, பயமோ, ஏதும் இருக்காது!
 
அடுத்த இரண்டடிகளில், உலக வாழ்வில் ஏற்படும் சுயநலத்தை பற்றி அறியமுடியும். இங்கும் “நான்” என்ற எண்ணம் மேலோங்கி இருப்பது திண்ணம். அதில் சிறப்பு என்னவென்றால், “நான் மட்டுமே” என்ற எண்ணம் இருப்பதே அனைத்து துயருக்கும் அடிகாலாக அமைகிறது.
 
இரண்டுமே சுயநலவாதம் தான், ஆனால் வெவ்வேறு விதம். முதலில் உணரப்படுவது பிறநிலையால், இரண்டாவதில் உணரப்படுவது தன்நிலையால்.

ஒரு புலம்பல்!

September 13th, 2013 2 comments

தேடிய திரவியம் பக்கத்திலே
ஆடுது பாருங்க விட்டத்திலே
மூடிய வெண்பனி மொத்தத்திலே
வாடுது கண்மணி நட்டத்திலே.

வருவதும் வந்ததும் என்னது இல்லே
போவதும் போனதும் யாருதும் இல்லே
இருப்பதும் இருந்ததும் அறியரது இல்லே
வருவதும் போவதும் புரியரது இல்லே

How fast is integer arithmetic than floating point arithmetic?

June 19th, 2013 No comments
You may already know that integer arithmetic is faster than floating point arithmetic. But how fast? I had the same question in my mind. So created the following script to test the “fastness” for each data type.

#include <vector>
#include <iostream>
#include <cstdlib>
#include “Stopwatch.hpp”

template <typename T>
void test( size_t inArraySize, size_t inCorpusSize )
{
    typedef std::vector<T> array_t;
    typedef std::vector<array_t> arrays_t;

    std::cout << “constructing the corpus…”;

    Stopwatch sw;
    sw.Start();
    arrays_t corpus( inCorpusSize + 1);
    for ( size_t i = 0; i < inCorpusSize+1; ++i )
    {
        array_t &array = corpus[i];
        array.resize( inArraySize );
        for ( size_t j = 0; j < inArraySize; ++j )
        {
            array[j] = (T)( rand() );
        }
    }

    sw.Stop();
    std::cout << sw.Elapsed() << ” secs” << std::endl;

    std::cout << “scored in … “;
    sw.Start();
    array_t scores( inCorpusSize );
    const array_t &query = corpus[0];
    for ( size_t i = 1; i < inCorpusSize+1; ++i )
    {
        const array_t &array = corpus[i];

        register T &score = scores[i1];
        score = 0;
        for ( size_t j = 0; j < inArraySize; ++j )
        {
            score += array[j]*query[j];
        }
    }

    sw.Stop();
    std::cout << sw.Elapsed() << ” secs” << std::endl;

}

int main( int argc, char **argv )
{
    if ( argc < 2 )
        return 1;

    int csize = atoi(argv[1]);
    int asize = atoi(argv[2]);

    std::cout << “testing float..” << std::endl;
    test<float>( asize, csize );

    std::cout << “testing double..” << std::endl;
    test<double>( asize, csize );

    std::cout << “testing long double..” << std::endl;
    test<long double>( asize, csize );

    std::cout << “testing int..” << std::endl;
    test<int>( asize, csize );

    std::cout << “testing unsigned int..” << std::endl;
    test<unsigned int>( asize, csize );

    std::cout << “testing short..” << std::endl;
    test<short>( asize, csize );

    std::cout << “testing unsigned short..” << std::endl;
    test<unsigned short>( asize, csize );

    std::cout << “testing char..” << std::endl;
    test<char>( asize, csize );

    std::cout << “testing unsigned char..” << std::endl;
    test<unsigned char>( asize, csize );

    std::cout << “testing long long..” << std::endl;
    test<long long>( asize, csize );

    std::cout << “testing unsigned long long..” << std::endl;
    test<unsigned long long>( asize, csize );

    return 0;
}

Syntax highlighting done by: /usr/bin/highlight -O html -t 4 -I -S cpp Main.cpp –inline-css -o /tmp/m.html

The result of running this script with vector size = 100 and corpus size = 1 million is shown below:
sudar@kiriya /opt/testing/bin $ ./tester 1000000 100
testing float..
constructing the corpus…1.447 secs
scored in … 1.731 secs

testing double..
constructing the corpus…1.543 secs
scored in … 1.836 secs

testing long double..
constructing the corpus…2.135 secs
scored in … 2.614 secs

testing int..
constructing the corpus…1.454 secs
scored in … 1.657 secs

testing unsigned int..
constructing the corpus…1.41 secs
scored in … 1.615 secs

testing short..
constructing the corpus…1.394 secs
scored in … 1.59 secs

testing unsigned short..
constructing the corpus…1.347 secs
scored in … 1.542 secs

testing char..
constructing the corpus…1.313 secs
scored in … 1.507 secs

testing unsigned char..
constructing the corpus…1.328 secs
scored in … 1.522 secs

testing long..
constructing the corpus…1.553 secs
scored in … 1.767 secs

testing unsigned long..
constructing the corpus…1.548 secs
scored in … 1.761 secs

  1. If you observe carefully, floating point calculations have taken more time than the fixed point calculations.
  2. Long Double took the longest time and it is the slowest.
  3. The reverse climax is that 64bit fixed calculation is slower than single-precision arithmetic.  An interesting read on multiplication is here.  The reason could be overflow due to the size of product register being 64 bits.
  4. The fastest is 8 bit calculation.  But unsigned 8 bit arithmetic is slower than signed.  Can’t explain why!
  5. For fixed point, unsigned calculations take less time than signed calculations, which can be understood by the additional time taken for 2’s complement arithmetic.
  6. Results can be different with different CPUs / Operating Systems, so infer accordingly.

Upgrade version of the testing application.
#include <vector>
#include <iostream>
#include <cstdlib>
#include “Stopwatch.hpp”
#include <string>
#include <map>

template <typename T>
double test( size_t inArraySize, size_t inCorpusSize )
{
     typedef std::vector<T> array_t;
     typedef std::vector<array_t> arrays_t;

     arrays_t corpus( 2 );
     for ( size_t i = 0; i < 2; ++i )
     {
          array_t &array = corpus[i];
          array.resize( inArraySize );
          for ( size_t j = 0; j < inArraySize; ++j )
          {
               array[j] = (T)( rand()%1000 );
          }
     }

     Stopwatch sw;
     sw.Start();
     const array_t &query = corpus[0];

     array_t scores( inCorpusSize );
     for ( register size_t i = 0; i < inCorpusSize; ++i )
     {
          const array_t &docu = corpus[1];
          T & score = scores[i];
          score = 0;
          for ( register size_t j = 0; j < inArraySize; ++j )
          {
               score += docu[j]*query[j];
          }
     }

     sw.Stop();
     return sw.Elapsed();
}

int main( int argc, char **argv )
{
     typedef double (*fun_t)( size_t, size_t );

     typedef std::pair < std::string, fun_t > named_fun_t;
     std::vector< named_fun_t > functions;

     functions.push_back( named_fun_t( “float”, test<float>) );
     functions.push_back( named_fun_t( “double”, test<double>) );
     functions.push_back( named_fun_t( “long double”, test<long double>) );
     functions.push_back( named_fun_t( “int”, test<int>) );
     functions.push_back( named_fun_t( “unsigned int”, test<unsigned int>) );
     functions.push_back( named_fun_t( “short”, test<short>) );
     functions.push_back( named_fun_t( “unsigned short”, test<unsigned short>) );
     functions.push_back( named_fun_t( “long long”, test<long long>) );
     functions.push_back( named_fun_t( “unsigned long long”, test<unsigned long long>) );
     functions.push_back( named_fun_t( “char”, test<char>) );
     functions.push_back( named_fun_t( “unsigned char”, test<unsigned char>) );

     if ( argc < 4 )
     {
          std::cout << argv[0] << ” <corpus_size> <array_size> <repeats>” << std::endl;
          return 1;
     }

     int csize = atoi(argv[1]);
     int asize = atoi(argv[2]);
     int iters = atoi(argv[3]);

     typedef std::map<std::string, double> timings_t;
     timings_t timings;

     for ( size_t j = 0; j < iters; ++j )
     {
          std::cout << \niteration #” << j+1 << std::endl;
          for ( size_t i = 0; i < functions.size(); ++i )
          {
               std::string name = functions[i].first;
               double timetaken = functions[i].second(asize, csize);

               timings[name] += timetaken;
               std::cout << “testing “ << name << “….” << timetaken << std::endl;
          }
     }

     std::string minstring;
     double minvalue = 99999.9;
     std::cout << \naverages” <<std::endl;
     for ( timings_t::iterator iter = timings.begin(), end = timings.end(); iter != end; ++iter )
     {
          iter->second /= (double)iters;
          std::cout << “average time for “ << iter->first << “: “ << iter->second << std::endl;

          if ( iter->second < minvalue )
          {
               minvalue = iter->second;
               minstring = iter->first;
          }
     }

     std::cout << “minimum timing is for “ << minstring << “: “ << minvalue << std::endl;
}

The result of running this script with vector size = 500 and corpus size = 1 million with 20 iterations is shown below:

iteration #1
testing float….1.473
testing double….1.469
testing long double….2.025
testing int….1.024
testing unsigned int….1.069
testing short….0.996
testing unsigned short….0.993
testing long long….1.004
testing unsigned long long….1.004
testing char….0.991
testing unsigned char….0.991

iteration #2
testing float….1.449
testing double….1.459
testing long double….2.011
testing int….1.002
testing unsigned int….1
testing short….0.985
testing unsigned short….0.99
testing long long….0.993
testing unsigned long long….0.993
testing char….0.983
testing unsigned char….0.992


..
iteration #20
testing float….1.448
testing double….1.45
testing long double….1.975
testing int….0.99
testing unsigned int….0.991
testing short….0.989
testing unsigned short….0.986
testing long long….0.997
testing unsigned long long….0.992
testing char….0.992
testing unsigned char….0.988

averages
average time for char: 0.99575
average time for double: 1.4665
average time for float: 1.4676
average time for int: 1.0046
average time for long double: 2.00115
average time for long long: 1.00585
average time for short: 0.99985
average time for unsigned char: 0.9945
average time for unsigned int: 1.0085
average time for unsigned long long: 1.0025
average time for unsigned short: 0.9963
minimum timing is for unsigned char: 0.9945

So, even in this test, char is the best choice!!

1KWp Solar Power Plant

January 30th, 2013 22 comments

Phew! What a relief!

I have just finished installing a 1KWp solar power plant in my apartment.  It was an wonderful and tiring experience getting everything to work together, ofcourse with the help of several kind people who helped moving on with the work.  I think, my installation is the first domestic installation for a capacity >1KWp in my entire area, that is Thirumullaivoyil; may be the first in Ambattur + Avadi townships.  Whatever be it, I am very happy that I could get it up and running as per the plan.  The power plant can produce upto 4-5KWh everyday in winter+sunny and may be 5-6KWh in summer.  I have been able to attach everything in my home except for Fridge, Ovens, Water heater, A/C and washing machine.  Yeah! Mixie, Coffee Maker, Wet Grinder, Computers, Water purifier run in solar at my home!  I tried attaching Fridge to the unit, but the backup time in the nights drastically reduced.  By the way, the solar power supply is 24hours through out.  The secret is that the excess power produced in the day are backed up in huge batteries, so that the saved energy is dispensed through out the night for powering my bed room and other low power night utilities.

Things to procure for this DYI project:

  1. Solar Panels: There are several variety of panels available, but always choose polycrystalline (aka multi-crystalline) panels, as there are very efficiently within 30 degree deviation of sunlight inclination angle.  If you go for monocrystalline, they are efficient only when the sun is right on top of them, so you are forced to install a solar tracking device for an additional cost.  I had procured MNRE approved panels for Rs 46/watt including transportation and taxes from Akshayasolar.  My setup has 12V 150Wp x 6 and 100Wp x 2, put together 1100Wp of bright power.
  2. Inverter: There are several varieties of inverters available in the market. Solar Inverters are the ideal choice here, but for my specification I could not get a solar inverter within my budget.  Typically solar inverters are priced around Rs 30000 for a 1KW capacity.  So, I had decided to go to regular sine-wave inverters and convert that to a solar inverter myself.  To convert an inverter to a solar inverter, I had to get a solar charge controller and fabricate a control circuitry.  I have bought a 24V, 1.4KVA Amaron Inverter for Rs 7000, with 2 years warranty.  A typical inverter has a power-factor of 0.7 to 0.8, so I could load upto 1000W comfortably without frying the inverter.
  3. Batteries: This is the most critical part of any ESU (Energy Storage Unit), where the power is stored during surplus and released when solar incoming reduces.  On the contrary, there are EEU (Energy Export Unit), which directly converts the energy derived by the solar panels into useful power for consumption or resale back to the grid.  TANGEDCO does not buy from installations less than 1MWp, so ESU is my only option.  So storing the power, the popular choice is Exide Solar Tubular batteries.  But, I chose Sharana Batteries because their manufacturing unit is in Ambattur Industrial Estate, and their service guarantee was better than what Exide offered.  While buying batteries, one should be very careful about the capacity rating of the batteries.  By capacity, the common misnomer is the AH rating.  AH rating tells the current limits of a battery, but the capacity rating is mentioned as Cxx (eg: C10, C20, etc).  Typically, a 180AH/C20 battery is same as the 150AH/C10 battery or 100AH/C5.  In C20 rating, if the drain current should be 9A, the battery would supply energy for 20 hours.  The same battery would serve for 8.33 hours only if the drain current is 18A, but you would expect it to serve for 10 hours.  Likewise, the same battery would serve only for 2.77 hours, if the drain current was 36A where you would expect a backup time of 5 hours (see here the capacity has halfed!!).  I have purchased 2x180AH @C20 tall tubular batteries from Sharana with 2 years warranty for Rs 26000.
  4. Charge Controller: There are two types of charge controllers available namely PWM, MPPT. Solar panels, although rated as 12V, they generate voltages upto 21.6V (open-circuit).  They are optimal at around 16.4-17.4V, which is called the maximum power point.  In order to leverage the maximum power from the controller, I used MPPT charge controllers.  For 1.1KW at 24V, the Imax is 50A, but assuming 80% efficiency for panels, 40A MPPT is sufficient.  I got 40A 24V controller from Adaptek India, Adyar for Rs 13600 with 3 years warranty.
  5. Structure Fabrication: This is the messy part of the entire exercise as readymade units were not available.  Since I will be using 8 panels in total and I had to use just 100 sq.ft of space on the roof, I planned to build a two row beam structure to take the load.  The weight of a panel is roughly 10kg, to 40kgs per structure is the setting.  The design shall have a rectangular frame of size 10’x3′ made out of 1.5″ L section of steel.  The rectangular section shall be supported by two 2″x1″ C channel steel of height 1.5′, which I call the legs.  The legs shall rest on a 8″x8″ 6mm plate, which in turn shall be secured to the roof with four 10mm anchor-flush bolts.  I could get raw material and fabrication done in Mannurpet, Ambattur for Rs 8000.  The total weight of steel I had installed is about 50Kg to keep the 70Kg of panel structure load secured.

Solar Power Plant Sizing chart is here.

More to continue..

Birthday Note…

August 16th, 2012 No comments

Filled with joy and laughter,
You’d been my soul that matter;
May your prayers be answered,
For my heart & mind be gathered;
Words not enough for the expression,
No such thing exists as your compassion;
Me blessed for you being my wife,
Thee the best person of my life;
Although you are just thirty,
You’d been my Almighty…

Birthday note’s that I’d written for my wife on her birthday after missing to greet her early in the morning! Sigh!

Lately become an English Novel Reader…

August 5th, 2012 No comments
I never had the habit of reading English books, if they were not technical, be it text books or magazines.  The same applied to Tamil books as well, as I found not patient enough to read a long story.  But I am avid reader of Philosophical, Religious books on Tamil.  Something changed when I saw the book “S.M.S எம்டன் 22.09.1914” by “திவாகர்”.  It was the first 250 pages novel I had ever read in my entire life apart from the non-detail books of the 10th grade schooling.  Later, I got absorbed by mystery stories by Dan Brown after watching all the movie versions of it.  My first English novel was “The Digital Fortress” and now I am reading “The Lost Symbol” by Dan Brown.  I have “Deception Point” ready with me.

Lots of probably used books were put on sale in my area, which opened up an opportunity for extending my reading horizon at an economical cost.  I bagged several books for Rs 80 per book today.  The list is below.
  1. The Curious Incident of the Dog in the Night-Time, Mark Haddon
  2. Labyrinth, Kate Mosse
  3. Secrets of Mary Magdalene, Dan Burstein & Arne de Keijzer
  4. Can you crack the Enigma Code? Richard Belfield
  5. The Maths Gene, Keith Devlin
  6. One Life to Ride, Ajit Harisinghani
  7. Beyond Angels and Demons, Rene Chandelle
  8. The Archimedes Codex, Reviel Netz & William Noel
  9. Twenty Thousand Leagues under the Sea, Jules Verne
  10. Meta Maths, Gregory Chiatin
  11. The Soddit, A.R.R.R Roberts
  12. Winkle, Clifford Chase
  13. Longitude, Dava Sobel

Never know, when I will be able to finish all these books, but I am positive that some day, I would be feeling happy to have bought them and stored them indeed.

Tags: , ,

Naan Ee

July 7th, 2012 No comments

I watched this movie tonight at Rakki.  After a long time i had a satisfaction of watching a good and interesting movie in tamil. This movie is definitely one of its kind that one could not avoid appreciating.  The casting for the Fly character is really wonderous. Thanks the animators from India and Russia. Looks like indo-russia collaboration is working out well. The villian character is very well done.  Although there are some logical glitches, this movie is a great entertainer. I loved every bit of it.

Photos that I’d enjoyed taking…

July 2nd, 2012 3 comments

Tags: ,