Hi recently I had a need to find out the bus bandwidth. The bus had 64 lines and assume that the speed of the bus is xMHz. This implies the bandwidth = (no.of lines) * (speed of each line). Bus Bandwidth = ((64/8)*x*10^6)/(2^20) MBytes/sec. A simple use of this metric is suppose you have SMP(Shared memory processors) with a common bus and the bandwidth of the bus is 1 GBytes/sec and you have several processors which have an (memory) Instruction bandwidth of 250 MBytes/sec you cannot connect more than 4 processors to saturate the bus.
Algorithms, Theory, Spirituality, Life, Technology, Food and Workout : trying to sort these deterministically in $\Theta(1)$ time (constant time).
Tuesday, February 27, 2007
[Tech] How to determine the bus bandwidth.
Thursday, February 22, 2007
[Tech] Pathetic non unix standard matlab editor
Monday, February 19, 2007
[SPICE2LAYOUT] 40% Complete
Need to get back home and study some stuff for a upcoming Friday jury.
Sunday, February 18, 2007
Algorithm for Permuting in place
I don't like explaining things just code it., here's code below
#include#include #include int a[10]; int b[10]; void ResetArray(){ unsigned int i; for(i=0;i<10;i++){ a[i] = i; } } void swap_elements(unsigned int i,unsigned int j){ int temp; temp = a[i]; a[i] = a[j]; a[j] = temp; } /*b is the swap list*/ void InplacePermute(int *perm){ unsigned int i; for(i=0;i<10;i++){ if(perm[i] < i){ perm[i] = perm[perm[i]]; } if(a[i] < i){ perm[a[i]] = perm[i]; } swap_elements(i,perm[i]); } } void PrintPermutation(void){ unsigned int i; for(i=0;i<10;i++){ printf("%d ",a[i]); } } int main(){ int runs=10; unsigned int i; do{ ResetArray(); printf("Please enter the permutation of size 10, 10 unique digits from 0-9\n"); for(i=0;i<10;i++){ if(scanf("%d",&b[i])<=0){ break; } assert(b[i] >=0 && b[i] <=10); } if(i<10){ break; } InplacePermute(b); printf("The permutation is::"); PrintPermutation(); }while(1); }
The following are testcases
7 3 2 1 4 8 9 0 5 6 8 9 1 2 5 6 7 3 4 0 1 2 3 4 5 6 7 8 0 9 1 3 4 8 9 0 7 6 5 2Well this week has been a little productive, got the space for http://phaedrus.sourceforge.net a library of randomized algorithms
Have Fun.... Vamsi.
Thursday, February 15, 2007
Passing multidimensional arrays to functions
int a[10][20];
int main(){
print_array(a); /*results in a crash.*/
}
void print_array(int **a,int i,int j){
printf("%d",a[i][j]); /*How stupid this can be?*/
}
Monday, February 12, 2007
I love PHP
Tuesday, January 30, 2007
[Tech] One more reason why MACRO's are Not Preferred over inlines.
...macro.h....
/***Dangerouse Macro1***/
#define print_int_value_twice(c) do{\
printf("first time %c second time %c\n",c,c);\
}while(0);
/***Stupid Preprocessor***/
#define my_error(c) do{\
fprintf(stderr,"Error::");
fprintf(stderr,c);
fprintf(stderr,"\n");
exit(1);
}while(0);
.....macro user ....
j=0;
print_int_value_twice(j++);
/*j incremented twice by the preprocessor*/
/*In this case the preprocessor is stupid
not treat the string spanned across several lines
as a incomplete macro argument and fails compilation.*/
my_error(" My error spans three lines
line1
line2");
Avoid MACROS start using inlines , if you define macros the users should use them with caution
Monday, January 29, 2007
[Personal] I was not good and never have been.....
Wednesday, January 24, 2007
[TECH-NON-TECH] SPICE2LAYOUT should I use BGL?
A Warm Welcome to a great new year 2007! This is my first blog after 24 days in the new year. Last time I had written my blog was on Dec 31, 2006, well this was the coldest new year eve I had. I just went to bed on Dec 31 night 2006. Its because I was with puppy taking care of puppy...we were really afraid on whats going to happen next....but it was great what happened next day was really a new begining in a new year things went excatly how I wanted (In fact I did'nt know what would be the best solution and just prayed "God! Please do something so that I will be comfortable after that")...a great going new year 2007 from there on, really had great time in Hyd from Jan-1 to Jan-6.....after that I took pathetic AeroSvit flight (Never Ever Take this shoddy airline) back to JFK, travelled all the way from NewYork to Hartford and took a cab to my place....its quite a tiresome journey to travel from India to U.S, next time I will travel by either BA ,Lufthansa or Emirates..... Now I need startoff my coding for the SPICE2LAYOUT project its been a while I took a break and its really a long one....Tomorrow Is a SRM from TopCoder....I was having a dilemma to use Boost Graph library or not...but I guess it will be fine if I write it on my own. Take care...keep Warm :) Cheers! Vamsi
Sunday, December 31, 2006
[PERSONAL] Lets solve the problem.....
I guess I have become a little bit more matured now, because I have to do things more responsibly now. I have a big responsibility now, I don't worry about it but I welcome it into my life, I'am ready to solve it and all the consequences...I will never run-away from the problem. But I need to be a little bit more practical also, well for any problem now there is no way out except to solve it.
So...LETS SOLVE THE PROBLEM RATHER RUNNING AWAY FROM IT....
And when you are solving problem's you need to be very methodological...I know its all spelling mistakes my blog...I may not be a great genius but I'll try my part to solve the problem. And when I solve the problem there will be no shortcuts.
Frankly I have been not getting great results for my Dynamic Programming based Border Length Minimization Problem. What to do I don't know I cannot really fake up any results. It's bad really bad. I leave it
Today puppy came out, she has been not liking the place where she is living but she has to for sometime, she should feel free and I'am a very lucky guy interms of that. I will always care for puppy and will solve the problem and not run away from it.
Happy new year 2007.....LETS SOLVE IT....that's the quote of this year.
Take care guys and keep having fun.....mean while I will lay back and keep thinking....
Friday, December 08, 2006
[NON-TECH] Travelling to india....
I should be indeed thankful to sudha for a ride from Storrs to Stamford. When I reached Stamford it was a little difficult to find out where ravi is and finally found ravi, went to circuit city to buy some stuff, later toured manhattan,brooklyn went to a great Italian restaurant, I really liked the hot bread and that olive oil to eat the bread, I never tried any Italian food apart from the normal pizza. Its really windy today in New York with -7 Centigrade, really had a hard time pulling all my luggage into the airport.....well found a wireless connection at the food court here, IT WORKS...well I'am writing this from that connection only, I need to wait till 4:00 PM to take my flight. Its a long wait.
Good that I got some charge on my laptop so that I can do some work today, I have many things pending, mac,tim,ion and raj. I need to get all the work done in this break good if I could make a proper schedule to fix up all the things.
Lets see how things work......luv....Vamsi
Thursday, December 07, 2006
I have not started any packing
Sunday, November 26, 2006
[TECH] Algorithm to find euler circuit in a graph in O(|E|)
Important observation I found is that, if we delete a cycle (delete all the edges which form a cycle) from the graph which has a Euler circuit, the property of the graph still remains, i.e the necessary and sufficient condition for the graph to have a Euler cycle is that every vertex should have even degree. And also there has to be a cycle at every vertex.
INPUT: G =(E,V) v = veuler_cycle = NULL; while(|E| > 0){ /*Find a cycle in G, start the search at v, returns c0 around which cycle is formed*/ c0 = FIND_CYCLE(G,v); v = GET_NON_ZERO_DEGREE_VERTEX(c0); /*Above can be done in constant time, using some space while finding the cycle */ MERGE(c0,euler_cyle); /*constant time operation, put c0 after an edge e1 in euler cycle which ends at vertex 'v', we can just remember the position of v n euler_cycle every time we merge*/ }
[TECH] Building tags on the complete source code...
I see that sometimes
$ctags -R *don't work. I just typed
$ctags -R *
in my cygwin it crashed
ctags.exe.stackdum. Well now the question is how do I build the tags on the complete source recursively if
-Rdon't work, we can use the the following to build the tags
$find . -name "*.c" -exec ctags -a \{\} \; -print; sort tags > tags1; mv tags1 tags;
The -a option appends to the existing tags file build
I initially thought that ctags keeps some seek information of the file in tags file,but just was amazed its a 3 column multientry text file, the first column is the tag which you are searching, second column is the file where is tag is and the most interesting part the 3 column is the search string for vim....hmmm see every one takes advantage of the plethora of things vim can do :)
Make_bp_profile ./RNAlib/ProfileDist.c /^PUBLIC float *Make_bp_profile(int length)$/ Make_swString ./RNAlib/stringdist.c /^PUBLIC swString *Make_swString(char *string)$/
.........luv.......Vamsi
Saturday, November 25, 2006
[TECH] Never use a file stream for lookahead reading while using lex.....
Just got the parser working....I did a lot of modification to mac's code, especially the grammar rules which have the lookahead information while parsing. The code tries to read from the
yyinfile stream of lex, but that is really pathetic because lex code is now optimize and it position in the lex buffer may not correspond to the position in the filestream...well this is what is the bug in code, well it took a while to fix. But its a good one.
I added lookahead rules
(st,bt)\n[\+]{linenum++;}
(st,bt)\n[\*].*${linenum++;} for lookahead extensions and comments in the spice syntax.
Tomorrow I'll get the layout printed ,,,,,,
Apart from this folks from india called and were telling me about the issues regarding priya pickles, well I think its really a slander against Ramoji Rao, any way I support this guy...yes may be after that great 3 day party at ramoji film city makes me baised, I guess you too will be baised once you receive that wonderful hospitality at hotel sitara in ramoji film city...when our team (verification group) went out there I saw mithun chakraborthy
..........luv..........Vamsi
Thursday, November 23, 2006
[TECH] SPICE layout generator.......
I have been a bit of slackish this week, but sure I want to start running soon.
Last night I read about the BPlane (Binned Plane datastructure used in micromagic, I need to implement that in magic soon).
Tonight, I thought about backing up my CVS repository regularly into my external hardrive, so that I can keep all my projects safe.
SPICE Layout generator
My new project, which generates cell layout from by reading from the SPICE files (transistor netlist) directly. I need to rewrite some of the code for the algorithm which tries to find the EULER trace in the transistors graph (and also its p-stack dual graph). Its exiting for me start it today....I'am in love with my life for the first time.......writing code is what I loved apart from all other tensions in life I love it
Tomorrow morning I'll be running for the sale in circuit city and best buy
[TECH] SRM327
http://www.topcoder.com/stat?c=problem_statement&pm=6871&rd=10007
/*
* topcoder_class1.java
*
* Created on November 22, 2006, 1:41 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package topcoder_srm1;
/**
*
* @author vamsi
*/
import java.lang.Math;
public class NiceOrUgly{
private boolean checkNice(char[] s_arr,int len){
int vcount=0;
int ccount=0;
int i;
for(i=0;i
I challenged some guy in this SRM got 50 bonus points.
..........luv......vamsi
Monday, November 20, 2006
[TECH] DAG's and Dynamic Programming......
Directed Acyclic Graph (DAG), directly embeds into dynamic programming....as from Vazirani's notes, the useful property of the DAG is that its nodes can be linearized (topologically). So if we process these nodes in the topological order we have sub-problems solved and the solution can be used for the next level. In the simple example of shortest path, we need (u1,v) , (u2,v) are the edges adjacent on the node v. To solve the shortest path problem we need the shortest path to u1, u2 to get the shortest path to v. The wonderful property of the DAG's is that if we start with the topological SOURCE (may be hypothetical by adding 0 weight edges), we are sure that we solved u1,u2 before solving v (if we process the nodes in topological order)
Longest monotonic subsequence in a given sequence, suppose the given sequence is '5,2,8,6,3,6,9,7' (The longest monotonically increasing sequence) in this is 2,3,6,9.
On the first look, it appears that it doesn't have sub-optimality inside it. In the sense take a subsequence '5,2,8' the longest monotonically increasing subsequence in this is is (5,8) or (2,8) but neither (5,8) and (2,8) is not in the overall longest monotonic subsequence, so the question is how dynamic programming works here??.....well people don't talk about the sub-optimality here......but still this can be solved by dynamic programming...
Let me restate the principle of optimality here...."If a optimization problem involves of sequences of decisions d1,d2,d3,d4...dn . The principle of suboptimality states that what ever decision you make initially the rest of the decisions should still optimize whats remaining after making decision d1...i.e
Any way I wrote the following code segment , S[i] = length of the longest monotonic subseqence ending at index i, input is a array of integers A[i].
global_max_length=-INFINITY;
PATH[N];
for(i=0;i
global_max_length , returns the length of the longest monotonic increasing sequence, and also prints the sequence
Apart from this life has been very cold, man today was REALLY_ __FREEZING__ here, I have cold the damn cold, I cannot drink cool drinks, eat any cold stuff it sucks......Well , I'll be going to India soon meet swapna,chamu...just talked to chamu on the phone, hope to see her and swappy soon...............THE LIFE GOES ON ON ON...by the way the GYM is closed till 26th and its cold outside I cannot even jog its really HELL out here
With love ...............Vamsi...............Tuesday, November 14, 2006
[TECH] Channel Router for cell synthesis......
Its quite an effort to get this thing working.....started on saturday night , worked on sunday, and monday night its done
perl had lot of kookups especially my $a,$b and my ($a,$b) are not the same, I pulled it from the manual. sometimes its really hard to fix this kind of errors, thanks for that wonderful debugger 'perl -d' , its really great to work with.
But I did'nt see if perl debugger has a backtrace kind of facility? just a gdb?
Life apart for my passion of the CGEN2MAGIC project, is quite slow need to study a lot about that Border Minimization Problem, also got the home work done on parallel algorithms and network flows.
I guess I'have started loving algorithms/problem solving...its really kewl
Take care....HAPPY CHILDRENS DAY.
Saturday, November 11, 2006
[TECH] Setting up VNC on LAN
Today I got my laptop dell-inspiron-640m, I have linux desktop running fedora connected to a wireless router which my friend uses, so totally we have 3 computers connected to the wireless router. Actually we have cloned the MAC address of my desktop onto the wireless router. Now I want to use my laptop and start working with vnc on my desktop. By default the port 5901 was firewalled, I had to setup the firewall to accept the tcp:5901. After which I had the probelems with the window manager, by default kde starts the twm& . So I edited the xstartup file to get the kde.
kwin & kdesktop & kicker &
You need all the three things to get the kde desktop up and running
Well thats all the infrastructure work, now I'am back to write the CHANNEL ROUTER for CGEN which I have not worked on for the last three days, due that motif-algorithm which I have been working on, last week I also had the polynomial algorithm for FINDING OUT ALL THE CUTS in the network flow graph.
Take care guys, I also had a long chat with swapna and that was really wonderful.