Skip to main content

Hashing Technique and Ka-Ta-Pa-Yaadi Sutra



I was having a conversation with my friends about hashing technique that we use in programming. During such a conversation, I mentioned that infact I was introduced to the hashing technique when I was in 6th grade and in a Carnatic music class with a different name and nothing in connection to computer programming and much before I was introduced to Computers. So what has this concept of hashing got to do with Carnatic music, which is considered an ancient form of music prevalent in South India. Let me explain you this connection. First let us look at a broad definition of Hashing in programming, we know hashing as a concept of assigning a Value to a Key that is unique to fetch the values without any data corruption.

This very same hashing concept exists in Sanskrit or Vedic mathematics as Ka-Ta-Pa-Yaadi Sutra. Sutra means a formula. This sutra assigns a numeral in decimal system to a phonetic syllable or a sanskrit letter in the following fashion.  

K-Ta-Pa-Yaadi Sutra
Assign decimal number 0-9 to the consonants starting from  Ka,Ta,Pa,Ya Series (Hence the name for this sutra) like:

1
    2
     3
      4
      5
     6
     7
  8
     9
        0
ka/क 
kha/ख  
  ga/ग 
   gha/घ 
   nga/ङ 
   ca/च 
   cha/छ     
ja/ज 
  jha/झ
     nya/ञ
ṭa/ट      
 ṭha/
  ḍa/ड
   ḍha/ढ
   ṇa/ण
    ta/त
    tha/थ
da/द
  dha/ध
      na/न
pa/प
pha/फ
   ba/ब
   bha/भ
   ma/म
     -
      -
   -
      -
        -
ya/य
ra/र
    la/ल
     va/व
    śha/श
    sha/ष
     sa/स
ha/ह    
  La/



Given a word one can generate a number to it to be assigned uniquely to create a Hash table. For example the word 'dheera' in sanskrit generates a number 29 based on this algorithm.

Step 1: Flip the first two syllables of the word. 
            In this example: it becomes ra-dhee
Step 2: Read the numbers for the syllables from chart above to this new flipped word. 
             In this example: ra is 2, dhee is 9
Step 3: Return the hashing index number 29

It is interesting how this hashing concept was adopted in Carnatic Music to quickly recollect the Scale of a particular Raga from its name via this hashing index. Before we dive into the details I'd like to brief you the about the concept of notes and scale. If you are familiar, there are 7 predominant notes Sa-Ri-Ga-Ma-Pa-Dha-Ni. There are micro frequencies for Ri-Ga-Ma-Dha-Ni, lower note and a higher note for each of these. A combination of these notes are called a scale, which defines the basis for a Raga.

Let us represent the entire range of Notes as S-R1-R2/G1-G2-G3-M1-M2-P-D1-D2/N1-N2-N3 with 12 distinct notes. In some rAgas, lower note of Ga i.e, G1 is referred as higher note of Ri i.e, R2. Similarly the lower note of Ni (N1) is referred as higher note of Dha (D2). To generate a full scale (Sampoorna RAga Scale) there should be at least one of the micro tonal pairs to be present from the list of R-G-M-D-N in addition to S and P.  We can generate a series (Mela) of 72 scales by permuting the higher and lower notes of R-G-M-D-N in a cyclic (Chakra) fashion. This is called a Mela-Chakra (mela = series, chakra = cycle).

I would like you to see below reference table of MelaChakra with the index number 1 to 72. These scales were prevalent and popular with names of rAgas. For example, KalyaniShankarabharanaThodiBhairaviKharaharapriya. Later during 17th century Sri Venkatamakhin, a descendent of Sri Mutthu Swamy Dikshithar discovered all the popular rAgas that actually fit into this Mela Chakra scheme via ka-ta-pa-ya-adi Sutra. Based on Venkatamakhin's work, attempts were made to formalize Hindusthani Scales. However only up to a limit it could be formatted in this way and not the entire set of rAgas. 

Lets come back and see how this ka-ta-pa-yaadi sutra (Hashing algorithm as mentioned above) was applied to identify the RAga Scales from the name of a Sampoorna RAga.

For example, There is a raga called KanaKangi. To find the scale, applying the above discussed algorithm, we take first two syllables, ka-na from the word KanaKangi. Flipping them, gives us na-ka, reading the assigned number from ka-ta-pa-yaadi table: na --> 0, ka --> 1. Therefore Kanakangi is hashed to 01. This is the first scale in the scale table below. S R1 G1 M1 P D1 N1 

Just for clarity, lets look at another example Meca-Kalyani. First two syllables me-ca, Flip the order, ca-me, read the assigned number ca --> 6, me (look for ma) --> 5. There by the Hash Index for Meca-Kalyani is 65. Bingo ! it is the 65th scale. S R2 G3 M2 P D2 N3.

I hope you saw the connection between Carnatic music and this hashing technique which is a very ancient technique found in Vedic Mathematics. The more closely one looks at such sophisticated systems that existed back in the days without computers, It just motivates me to look deeper into our vedic systems to solve some of the modern day problems. Anyways, thank you for reading this quite a technical article !! 

_________________________________________________________________________________

Reference:  Mela Chakra WikiPage

'Mēḷakartā Rāgas'
'Shuddha Madhyama''Prati Madhyama'
No.RagaScaleNo.RagaScale
1.Indu Chakra7. Rishi Chakra
1KanakangiS R1 G1 M1 P D1 N1 S'37SalagamS R1 G1 M2 P D1 N1 S'
2RatnangiS R1 G1 M1 P D1 N2 S'38JalarnavamS R1 G1 M2 P D1 N2 S'
3GanamurtiS R1 G1 M1 P D1 N3 S'39JhalavaraliS R1 G1 M2 P D1 N3 S'
4VanaspatiS R1 G1 M1 P D2 N2 S'40NavaneetamS R1 G1 M2 P D2 N2 S'
5ManavatiS R1 G1 M1 P D2 N3 S'41PavaniS R1 G1 M2 P D2 N3 S'
6TanarupiS R1 G1 M1 P D3 N3 S'42RaghupriyaS R1 G1 M2 P D3 N3 S'
2. Netra Chakra8. Vasu Chakra
7SenavatiS R1 G2 M1 P D1 N1 S'43GavambhodiS R1 G2 M2 P D1 N1 S'
8HanumatodiS R1 G2 M1 P D1 N2 S'44BhavapriyaS R1 G2 M2 P D1 N2 S'
9DhenukaS R1 G2 M1 P D1 N3 S'45ShubhapantuvaraliS R1 G2 M2 P D1 N3 S'
10NatakapriyaS R1 G2 M1 P D2 N2 S'46ShadvidamarginiS R1 G2 M2 P D2 N2 S'
11KokilapriyaS R1 G2 M1 P D2 N3 S'47SuvarnangiS R1 G2 M2 P D2 N3 S'
12RupavatiS R1 G2 M1 P D3 N3 S'48DivyamaniS R1 G2 M2 P D3 N3 S'
3. Agni Chakra9. Brahma Chakra
13GayakapriyaS R1 G3 M1 P D1 N1 S'49DhavalambariS R1 G3 M2 P D1 N1 S'
14VakulabharanamS R1 G3 M1 P D1 N2 S'50NamanarayaniS R1 G3 M2 P D1 N2 S'
15MayamalavagowlaS R1 G3 M1 P D1 N3 S'51KamavardaniS R1 G3 M2 P D1 N3 S'
16ChakravakamS R1 G3 M1 P D2 N2 S'52RamapriyaS R1 G3 M2 P D2 N2 S'
17SuryakantamS R1 G3 M1 P D2 N3 S'53GamanashramaS R1 G3 M2 P D2 N3 S'
18HatakambariS R1 G3 M1 P D3 N3 S'54VishwambariS R1 G3 M2 P D3 N3 S'
4. Veda Chakra10. Disi Chakra
19JhankaradhwaniS R2 G2 M1 P D1 N1 S'55ShamalangiS R2 G2 M2 P D1 N1 S'
20NatabhairaviS R2 G2 M1 P D1 N2 S'56ShanmukhapriyaS R2 G2 M2 P D1 N2 S'
21KeeravaniS R2 G2 M1 P D1 N3 S'57SimhendramadhyamamS R2 G2 M2 P D1 N3 S'
22KharaharapriyaS R2 G2 M1 P D2 N2 S'58HemavatiS R2 G2 M2 P D2 N2 S'
23GourimanohariS R2 G2 M1 P D2 N3 S'59DharmavatiS R2 G2 M2 P D2 N3 S'
24VarunapriyaS R2 G2 M1 P D3 N3 S'60NeetimatiS R2 G2 M2 P D3 N3 S'
5. Bana Chakra11. Rudra Chakra
25MararanjaniS R2 G3 M1 P D1 N1 S'61KantamaniS R2 G3 M2 P D1 N1 S'
26CharukesiS R2 G3 M1 P D1 N2 S'62RishabhapriyaS R2 G3 M2 P D1 N2 S'
27SarasangiS R2 G3 M1 P D1 N3 S'63LatangiS R2 G3 M2 P D1 N3 S'
28HarikambhojiS R2 G3 M1 P D2 N2 S'64VachaspatiS R2 G3 M2 P D2 N2 S'
29DheerasankarabharanamS R2 G3 M1 P D2 N3 S'65MechakalyaniS R2 G3 M2 P D2 N3 S'
30NaganandiniS R2 G3 M1 P D3 N3 S'66ChitrambariS R2 G3 M2 P D3 N3 S'
6. Rutu Chakra12. Aditya Chakra
31YagapriyaS R3 G3 M1 P D1 N1 S'67SucharitraS R3 G3 M2 P D1 N1 S'
32RagavardhiniS R3 G3 M1 P D1 N2 S'68Jyoti swarupiniS R3 G3 M2 P D1 N2 S'
33GangeyabhushaniS R3 G3 M1 P D1 N3 S'69DhatuvardaniS R3 G3 M2 P D1 N3 S'
34VagadheeswariS R3 G3 M1 P D2 N2 S'70NasikabhushaniS R3 G3 M2 P D2 N2 S'
35ShuliniS R3 G3 M1 P D2 N3 S'71KosalamS R3 G3 M2 P D2 N3 S'
36ChalanataS R3 G3 M1 P D3 N3 S'72RasikapriyaS R3 G3 M2 P D3 N3 S'

Comments

Popular posts from this blog

A note on Parallels : Mysore and Tanjavoor Veena

  A note on Parallels : Mysore and Tanjavoor Veena To me, even to this day, Mysore and Tanjavoor represent the cultural bed of Karnataka and Tamil Nadu. In the past, these two cities indeed were the Capitals of erstwhile Kingdoms. They both were blessed by the stable governments from the Royals who ruled the respective provinces between 14th and 20th centuries. These erstwhile kings were not just rulers but also patrons of art, music, sculptures, and literature. Many new forms of art and music were developed, nurtured, and exchanged between the two states. Some of the Rulers themselves were musicians and artists. Both, Mysore and Tanjavoor grew pretty much same themes like music or painting or palaces or temple architectures. Yet, the subtle nuances at the core made them stand distinct from each other as different forms. It requires a careful pair of eyes to see these real differences. For a casual eye, both forms look alike. It makes me wonder how much wealth these Kingdoms mus

Do the Right Thing!

We all encounter dilemmas or deadlock situations in our day-to-day life. Doing the right thing under all situations is essential to being a responsible individual. But this 'Doing the Right thing' is very subjective and with reference to a natural state. Under Same situations, different people, act differently. For a sage, doing the right thing could be helping the needy; but for a terrorist, it could be to destruct the life of people. Our decisions are dominated by the influence from emotional and intelligent quotients based on our perceived experiences, be it personal or gathered from other sources. Similarly, beyond individuals, institutions, governments, communities, military, industry, economy etc. all entities have their own way of doing the right thing. In order to establish a peaceful world, it becomes necessary to have harmony between socio-economic-natural phenomena. Then defining what as 'Doing the right thing' that drives the system to its natural state o