Tuesday, February 27, 2007

[Tech] How to determine the bus bandwidth.

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.  

Thursday, February 22, 2007

[Tech] Pathetic non unix standard matlab editor

Well I'm really pissed of this damn editor (matlab editor) , some how I cannot execute my program .m file from the command line so I had to use this matlab's editor to run my program, after using vi for long this is really pathetic, its more worse than windows I just did ctrl+c and ctrl+v it pased some junk instead of the code which I intended to paste.

Monday, February 19, 2007

[SPICE2LAYOUT] 40% Complete

Got back to the SPICE2LAYOUT project updated some Makefiles and added all the skeletal code today. By the mid of the week I should get this up and running, It also needs to have the channel router in that.
Need to get back home and study some stuff for a upcoming Friday jury.

Sunday, February 18, 2007

Algorithm for Permuting in place

Problem: Given a set of numbers S = 1...n and a permutation PI(S), how can you rearrange elements in S in O(n) time with no extra space.

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 2
Well 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

Got enlightened by this today. And realized the following.
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

Have been using PHP with apache to build some stuff really like programming in this I'am in love with PHP.