Thursday, May 29, 2008

There is another sky by Emily Dickinson

There is another sky,
Ever serene and fair,
And there is another sunshine,
Though it be darkness there;
Never mind faded forests, Austin,
Never mind silent fields -
Here is a little forest,
Whose leaf is ever green;
Here is a brighter garden,
Where not a frost has been;
In its unfading flowers
I hear the bright bee hum:
Prithee, my brother,
Into my garden come!

Poems Ring - New Post
Poems Ring - Old Post

Monday, May 19, 2008

Building C++ programs in Linux

This is very basic guide for getting anyone started with building and debugging C/C++ code in GDB.

I will put forth information about building in Linux. The best reference book for this is "Advanced Linux Programming" which is available for free

http://www.advancedlinuxprogramming.com


Building your own C++ code in linux.
I will take code sample which my friend Hari used while giving us GDB training sessions. He used the following code to explain us the way to use GDB for debugging.

list.h:-

#ifndef __LLIST_HEADER_INC__
#define __LLIST_HEADER_INC__

//////////////////////////////////////////////////////////////////////
#include
//////////////////////////////////////////////////////////////////////
// class LinkedList definition begins

class LinkedList
{
struct LLItem
{
int value;
struct LLItem *next, *prev;
};

public:
LinkedList ();
~LinkedList ();

void push (int val);
int pop ();
size_t size () { return m_iSize; };

private:
LLItem* m_pFirstNode, *m_pCurNode;
size_t m_iSize;
};

#endif // __LLIST_HEADER_INC__


List.cpp:-
#include "list.hpp"

//////////////////////////////////////////////////////////////////////
// class LinkedList implementation begins

LinkedList::LinkedList ()
: m_pFirstNode(NULL), m_pCurNode(NULL)
{
}

LinkedList::~LinkedList()
{
m_pCurNode = m_pFirstNode;
LLItem* tnode;
while (m_pCurNode)
{
tnode = m_pCurNode->next;
delete m_pCurNode;
m_pCurNode = tnode;
}
m_pFirstNode = NULL;
m_pCurNode = NULL;
}

void LinkedList::push (int val)
{
LLItem* cnode = m_pFirstNode;
while (cnode && cnode->next)
{
cnode = cnode->next;
}

LLItem* tnode = new LLItem ();
tnode->value = val;
cnode->next = tnode;
tnode->prev = cnode;
tnode->next = NULL;

++m_iSize;
}

int LinkedList::pop ()
{
LLItem* cnode = m_pFirstNode;
while (cnode && cnode->next)
{
cnode = cnode->next;
}

int value = cnode->value;
LLItem* pnode = cnode->prev;
pnode->next = NULL;
delete cnode;
--m_iSize;

return value;
}

// class LinkedList implementation ends
//////////////////////////////////////////////////////////////////////

Main.cpp:-
#include "list.h"
#include
#include

int
main ()
{
LinkedList* ll = new LinkedList ();
size_t list_size = 100000;
for (size_t i = 0; i < list_size; ++i)
{
ll->push (random ());
}
for (size_t i = 0; i < list_size; ++i)
{
std::cout << "Popped element " << ll->pop () << std::endl;
std::cout << "The current size is " << ll->size () << std::endl;
}
return 0;
}




The above code is linked list code. It's a buildable code however on execution, it will give segmentation fault. I have placed the code in my $HOME/LinkedList area. The files present are main.cpp, list.h and list.cpp


Creating Object File.

The C++ compiler is called g++ while a C compiler is called gcc. The method of operating is very similiar. Suppose you have main.c, then to compile it, following is the command

% gcc -c main.c

To compile a C source file, you use the -c option. The resulting object file is named main.o.

To compile c++ file we use g++ in similiar way

% g++ -c list.cpp

The -c option tells g++ to compile the program to an object file only; without it, g++ will attempt to link the program to produce an executable. After you’ve typed this command, you’ll have an object file called list.o. Similiarly

Some other options are required when building large applications. The -I option is used to tell GCC where to search for header files. By default, GCC looks in the current directory and in the directories where headers for the standard libraries are installed. If you need to include header files from somewhere else, you’ll need the -I option.

In our case if we have kept out main.cpp in the $HOME/LinkedList area and placed our list.hpp in $HOME/LinkedList/Include area then we need to include the path of .hpp file while building.

% g++ -c -I ../include list..cpp

Note:- On doing "pwd" at prompt, It should display path $HOME/LinkedList

If you’re really building production code, you probably want to have GCC optimize the code so that it runs as quickly as possible.You can do this by using the -O2 command-line option. (GCC has several different levels of optimization; the second
level is appropriate for most programs.) For example, the following compiles list.cpp with optimization turned on:

% g++ -c -O2 list.cpp


Linking Object Files

Now we have objects of both main.cpp and list.cpp. One should always use g++ to link a program that contains C++ code, even if it also contains C code. If your program contains only C code, you should use gcc instead.
We link our code in following manner.

% g++ -o llist main.o llist.o

The -o option gives the name of the file to generate as output from the link step. g++ automatically links in the standard C runtime library containing the implementation of standard functions which have been used in code like cout, cin..... If one needs to link in another library, you would have to specifically link those library's with -l option. In Linux, library names almost always start with lib. For example, the Pluggable Authentication Module (PAM) library is called libpam.a. To link in libpam.a, you use a command like this:

% g++ -o llist main.o llist.o -lpam

The compiler automatically adds the lib prefix and the .a suffix. As with header files, the linker looks for libraries in some standard places, including the /lib and /usr/lib directories that contain the standard system libraries. If one wants the linker to search other directories as well, one should use the -L option, which is the parallel of the -I option. For example.

% g++ -ollist main.o llist.o -L/usr/local/lib/pam -lpam

Although you don’t have to use the -I option to get the preprocessor to search the current directory, you do have to use the -L option to get the linker to search the current directory. In particular, you could use the following to instruct the linker to find the test library in the current directory:

% gcc -o llist main.o llist.o -L. -ltest

Automated Object Building and Linking using Makefile.

The basic idea behind make is simple.One tells make what targets you want to build and then give rules explaining how to build them. One also specify dependencies that indicate when a particular target should be rebuilt. In our case, we have three target:- main.o, list.o and and llist.

Our llist depends upon our list.o and main.o. So for linking and creating our executable files, we need those two objects already created. Also the object files should be rebuilt whenever the corresponding source files change. On top of it, changes to the header file should result in all the source files including it to be rebuilt. In our case list.hpp also should cause both of the
object files to be rebuilt because both source files include that header file.

Also one might want to remove previously created object files and programs and then start fresh built. The rule
for this target uses the rm command to remove the files.

Here’s what Makefile contains:

llist: main.o list.o
g++ $(CFLAGS) -o llist main.o list.o

main.o: main.c list.hpp
g++ $(CFLAGS) -c main.cpp

list.o: list.cpp list.hpp
g++ $(CFLAGS) -c list.cpp

clean:
rm -f *.o llist


You can see that targets are listed on the left, followed by a colon and then any dependencies.
The rule to build that target is on the next line. The line with the rule on it must start with a Tab character, or make
will get confused.

If one types only

% make

on the command-line, you’ll see the following:
% make
g++ -c main.cpp
g++ -c list.cpp
g++ -o llist main.o list.o


You can see that make has automatically built the object files and then linked them. If you now change main.cpp in some trivial way and type make again, you’ll see the following:

% make
g++ -c main.cpp
g++ -o llist main.o list.o


Following command will clean the object files

% make clean
rm -f *.o llist


The $(CFLAGS) is a make variable.You can define this variable either in the Makefile itself or on the command line. GNU make will substitute the value of the variable when it executes the rule. So, for example, to recompile with optimization enabled, you would do this:

% make CFLAGS=-O2
g++ -O2 -c main.cpp
g++ -O2 -c list.cpp
g++ -o llist main.o list.o


For debugging with GDB, one will have to compile with debugging information enabled. Do this by adding the -g switch on the compilation command line. So we build using -g flag in makefile

% make CFLAGS=-g
g++ -g -c main.cpp
g++ -g -c list.cpp
g++ -g -o llist main.o list.o


When one compiles with -g, the compiler includes extra information in the object files and executables.The debugger uses this information to figure out which addresses correspond to which lines in which source files, how to print out local variables, and so forth.


Programming Ring - New Post
Programming Ring - Old Post

Tuesday, May 13, 2008

Birthday

Well today is m birthday....Born on 13th :)

Some quotes...


How do you expect me to remember your birthday, when you never look any older? happy birthday!

May u grow to be toothless!

God think the world is beautiful then he born u

Today is a day of celebration. why? because, years ago on the same day, god sent me my flesh and bone conscience. wishing my friendly inner voice a very happy birthday.

Hey,u r 1 year older now,1 year smarter now,1 year bigger now,and now u r 1 year closer to all your wishes.happy birthday

Not just a year older, but a year better.

Here's to another year of experience.

Age is all but a number.



General Post Ring - New Post
General Post Ring - Old Post

Friday, May 02, 2008

Hobby of Kings - Part 3

All information taken from various sites:- I will mention all possible sites in Hobby of Kings - Part 6. I personally have no information nor coins about coins of Lydia. I t is just that I found articles about them on websites, so I am just putting some basic information together at one place.


Coins of Lydia:-


Map of the Aegean world c. 800-600 BC, at the time Lydian Lions were minted. The areas in pink, including Athens, were controlled by the Ionian Greeks. The areas in orange, including Sparta, were controlled by the Dorian Greeks. The areas in yellow were controlled by other Greeks. The areas in light green, including Lydia, Thrace, and Macedonia, were controlled by non-Greeks, though the Macedonians were closely related to the Greeks and moving toward integration with Greece and the Lydians, with their capital of Sardis, were in close contact with the Ionian Greeks. (Map courtesy of Hypatia.org.)



South western part of present day Turkey was known in antiquity as Lydia. Ionians (greek settlers on the east coast of Asia minor) described their eastern neighbors Lydians as the people with dark hair and olive colored skin. There was a vigorous trade between the Ionian city states and Lydian kingdom. Lydian rulers and Ionian city state rulers were also related by marriage. Many historians and archaeologists speculate that increased trade was a spark for invention of the coins. Coins might had facilitated a move from cumbersome barter system of trade to simple system based on the money. Others speculate that they were stuck as offerings to the Gods in their religious ceremonies. Lydian coins found in Ionian mainland temple of Greek goddess Artemis (Romans called her Diana) during archeological excavation in 1951 gives credence to such speculation. Logically, both ideas make sense but we may never know.

‘The Lydians,’ says Herodotus , ‘were the first people we know of to strike coins of gold and of silver’. Writings of Herodotus (greek historian) also tell us that Lydian king Croesus had given great number of coins to the temple at Delphi. Croesus asked advice from the Oracle as to the success of his invasion of Persian kingdom. The Oracle told him that if he crossed the river he would destroy a great kingdom. Encouraged, he proceeded with the invasion. Ironically, Persian King Cyrus the Great won the war in 546 BCE and destroyed Lydian kingdom. Persian King acquired the Lydian mints and technology of making quality coins. Persians added copper to gold to prevent easy wear and tear of soft pure gold coins. Thus coin minting spread to Persia.

The dating of Lydian Lion coins is "the most challenging question in ancient Greek numismatic scholarship," according to Nicholas Cahill and John H. Kroll. I believe the Lydian electrum trites were minted during the reign of King Alyattes, c. 610-560 BC,[73]and that the first Lydian coinage was minted during the early part of Alyattes' reign (scholars disagree on the years of Alyattes' reign, with the date of his assuming power ranging between 619 and 609 BC and the date of his death typically being 561 or 560 BC). Alyattes was the father of Kroisos (Croesus), the Lydian king of legendary wealth who was likely the first to strike coins of pure gold and silver. The Mermnad (Mermnadae) dynasty of Lydia consisted of, in chronological order, Gyges, Ardys, Sadyattes, Alyattes, and Kroisos (Croesus).

Passing from these statements of ancient writers to an examination of the earliest Asiatic essays in the craft of coining, we are led to ascribe to the seventh century B.C., and probably to the reign of Gyges (B.C. 687- 652), the founder of the dynasty of the Mermnadae and of the new Lydian empire, as distinguished from the Lydia of more remote antiquity, the first issues of the Lydian mint. Between 600-575 BCE, mainland greek city states learned technology of coin making and started producing their own coins. Silver coins started appearing in Aegina (595-456 BCE), Athens (575 BCE), Corinth (570 BCE). Thus coins spread to the western part of the eurasian continent.

Alyattes is infrequently referred to as Alyattes II. One well-respected ancient coin auction house recently changed its attributions of these coins to Alyattes II, and a few other auction houses and dealers have since followed suit. Wikipedia uses "Alyattes II," based on the online Encyclopaedia of the Orient, though this online work provides no references. The auction house that uses "Alyattes II" said it bases this on John Lempriere's 1788 Classical Dictionary (Biblioteca Classica), its full name being Classical Dictionary of Proper Names Mentioned in Ancient Authors Writ Large, With Chronological Table. This may have been the source used by the online Encyclopaedia of the Orient as well. But Classical Dictionary also doesn't reference its source of the "Alyattes II" usage.

It's likely that Classical Dictionary based it usage on ancient epigraphs or on works whose usage was based on ancient epigraphs, epigraphs being lists of kings on clay tablets and other media. According to the epigraphic tradition,, "Alyattes I" was an earlier king of Lydia, during the eighth century BC, and part of the Tylonid dynasty. The Tylonid dynasty allegedly consisted of Ardys I, Alyattes I, Myrsos, and Kandaules and preceded the Mermnad dynasty. The Tylonid dynasty, in turn, was allegedly preceded by the Heraklid (Sons of Herakles) dynasty, though sometimes the two dynasties are referred to as one, the Heraklid/Tylonid dynasty. According to these lists, the demigod Herakles was the progenitor of the Lydians.

Early numismatists such as Barclay Head believed that Lydian coins were minted as early as c. 700 BC,or even earlier, and some dealers today still date these coins the way they were dated a century ago, following "high chronology." But much archeological evidence has surfaced since then, and the dating of Lydian Lions has been inching forward in time, with most numismatists today arguing for later dating, or "low chronology." Kraay in 1976 wrote that the first coins were minted in "the second half of the seventh century BC,"Price in 1983 "the last quarter of the seventh century [BC],"G.K. Jenkins in 1990 "no earlier than in the late seventh century BC,"Carradice in 1995 likely from "the late seventh to early sixth centuries BC,"and Le Rider in 2001 not "before 590-580 [BC]."

First coins of Lydia were lumps of electrum (naturally occurring amalgam of silver & gold). Electurm lumps were found in mountain streams of Lydia. They were heated to soften, placed on a plate and struck with a punch and hammer. This formed an incuse on one side and marked them as coins.

These coins were produced at a mint constructed by Lydian king Ardys (652-15 BCE) in the capital city of Sardis. They were not true coins by present day definition because they were not of any standard weight & purity of metal or size. Smaller coin has one square incuse and larger coin has two square incuses on obverse and rough surface on reverse

1 Stater coin of electrum of Lydia at the time of King Ardys (652-15 BCE)


1/3 Stater coin of Lydia



Later king of Lydia, Alyattes (610-561 BCE), son of Ardys set a weight standard for the coin (168 grains of wheat for Stater). The earliest issues, thought to date from the reign of Alyattes (about 610–560 BC) or perhaps his predecessor Sadyattes—both of the Mermnad dynasty—feature the Lydian kings’ emblem of a roaring lion, almost always with a curious knob, often called a “nose wart,” on its forehead. Reid Goldsborough has written a very thorough review of what is known about the history of these electrum lion coins of Lydia, and his essay includes citations to the relevant technical literature on the subject. Advancements in metallurgy at this time created coins using anvil die to make a design on the reverse of the coin. Lion''s head was the symbol of Mermnad dynasty. Standard weight met the second condition to be a true coin.

Stater of Lydia at the time of King Alyattes (610-561 BCE)
Two square incuses on obverse and head of a lion on reverse.


Credit of producing true coins in Lydia goes to King Coresus ( 561-46 BCE ) son of Alyattes. He set the standards for purity of metal (98 % gold or silver) and official seal of king on the obverse ( head a lion and Bull). This official seal guaranteed the value of the coin by the King. This met the third condition to be a true coin of the modern definition.

Gold stater of King Coresus ( 561-46 BCE )
Head a lion and bull on reverse and two square incuses on obverse.


Silver Double Siglos coin of King Coresus ( 561-46 BCE )
Head a lion and bull on reverse and two square incuses on obverse



Lydian electrum trite (4.71g, 13x10x4 mm).



This coin type, made of a gold and silver alloy, was in all likelihood the world's first, minted by King Alyattes in Sardis, Lydia, Asia Minor (present-day Turkey), c. 610-600 BC. It can be attributed, among other ways, as Weidauer 59-75 (Type 15).
The specimen pictured above weighs 4.71 grams, has a diameter of 13mm at its widest, and at 4mm, is thick as a nugget. It likely consists of about 55 percent gold, 43 percent silver, 2 percent copper, and trace amounts of lead and iron, with the the later variety consiting of slightly lower gold and higher silver, based upon analyses of these coins by a number of different researchers. The above variety can be attributed, among other ways, as Weidauer Type 15 and Mitchiner Group C.



RJO 55. Electrum 1/12 stater (1.19 g), about 610–560 BC. Obverse: lion’s head right with “nose wart.” Reverse: square incuse punch. A clear and well-centered example of Weidauer’s Type XVI, which is distinguished by the large number of chevrons on the lion’s neck (Weidauer, 1975: 24–25, pl. 10).



Some Other Coins Information:-

1) Thanjavur and Madurai Nayaks


3 coins are thanjavuar nayaks, 4th one is Madurai Nayak
sivaligam in one side and ram and laxeman in other sied

coin obv : ram lax and sita
rev standing king


2)Empress Maria Theresa (1740-1780)
http://www.jdsworld.net/article/m_theresa_thalers.html



Probable:- KM23, Burgau Mint, 1780 SF/X/, Large Mature Bust Restrike, (the "SF" is located under the obverse bust as S·F· while the "X" (saltire) follows the date on the reverse as 1780·X.

3)Indo-Dutch Pagoda


AU "new Porto Nova pagoda" 1747- 1787 (Negapatnam, Tuticorin, Colombo) (1670 - 1784)
Obv.: Formalized full length figure of the deity Rev.: Granulated raised surface. 3,6 gram. "Porto Novo" pagodas of this type were struck at Pulicat, Negapatam and Madras.
Mitchener 1979, 1594. S. Scholten 1229

4)1/4 Karshapan - SUNGA KINGDOM



3RD CENTURY BC
KAUSHAMBI REGION
SCARCE
COPPER - 1.7 GMS
14 MM
OBV: ELEPHANT WALKING TO LEFT
REV: THREE - ARCHED SYMBOL


5) Western Kshatrapas


Visvasimha (277 - 290 AD)
AR Drachm
Dated: Saka 200 (?) (278 AD (?))
Senior ISCH 355; Mitchiner ACW 2744v.
14 mm.
2.22 gm.
Die position=5h
reverse
Obverse: Bust right with close-fitting headdress; date (Brahmi) behind head. Brahmi legend.
Reverse: Three-arched hill (chaitya), crescents and star above, river below; Brahmi legend.


Coins Ring - New Post
Coins Ring - Old Post