My Experiments with Life

December 2, 2009

Polynomial Multiplication

Filed under: Uncategorized — alanabraham @ 5:13 am

Yesterday evening, Irshad came with some polynomial multiplication problem in C .

Q : Get the resultant polynomial after the multiplication of n polynomials

Thought lots of methods like matrix multiplication to implement this

I thought of creating a program by reducing the multiplication and use addition instead and over the condition of which to multiply appropriatly…..

There i got wrong….coz u can do that for a small values like 2 polynomials or 3 polynomials for which require as many loops as the polynomials. For an n polynomial condition, i felt it like the requirement of recursive function…..

Here it got messy….i got stuct in n times recursion in a Utopian space-time frame.

Then the Messiah of this problem appeared before me……Jomon chettan

He teared my logic apart and killed it……

He told me to use the temporary structure where you go on multiply with the next.

That was a good start but i did it like a n00b……got stuck n stuck till the sleep invited me to the warmth of her lap.

Morning. I know what to do. I started recoding not debugging  the first stuff.I know now that i am going the right way….logically right path

the right path…..

it took me to this code

i think its right…..still a code is never always 100% working….u can find more conditions where it cant work properly.


Go to this link to see the program file properly

or see here

NOTE : JUST DONT LOOK INTO COMMENTED CODES….

__________________________________________________________

//polynomial mltiplication


#include<stdio.h>

struct polynomial

{

      int degree;

      float  coeff[100];

}pol[100];

//simply output the argument

void out(struct polynomial a)

{

      int k; 

      for(k=a.degree;k>=0;k--)

      {

             if(k)

                   printf("%f(x^%d)+\t",a.coeff[k],k);

             else

                   printf("%f",a.coeff[k]);

      }

      printf("\n-------------------\n"); 

}

//return type is structure polynomial

struct polynomial multiply(struct polynomial pol1,struct polynomial pol2)

{

      int a,i,j;

      //declare t and initialise to zero;

      struct polynomial t;

      //initialising t

             //---------------

                   t.degree=0;

                   for(a=0;a<100;a++)

                         t.coeff[a]=0;

             //--------------- 

      for(i=0;i<=pol1.degree;i++)

      {

             for(j=0;j<=pol2.degree;j++)

             {

                   //printf("~~~~~~~~~%f~~~~~~~~",(pol1.coeff[i]*pol2.coeff[j]));

                   t.coeff[i+j] = t.coeff[i+j] + (pol1.coeff[i]*pol2.coeff[j]);

                   //printf("@@@@@%f@@@@@-%d-",t.coeff[j],j);

             }

      }

      t.degree=i+j-2;

      return(t);

} 

//input whole structure array

void input(int n)

{

      int i,j;

      for(i=0;i<n;i++)

      {

             printf("enter the degree of polynomial %d : ",i+1);

             scanf("%d",&pol[i].degree);

             for(j=0;j<=pol[i].degree;j++)

             {

                   printf("Enter coeff of x for degree %d : ",j);

                   scanf("%f",&pol[i].coeff[j]);

             }

      } 

} 

//main function

int main()

{

      int k,n;

      //declare resultant

      struct polynomial resultant;

      printf("Enter the number of polynomials to be multiplied : ");

      scanf("%d",&n);

      //input the polynomials

      input(n);

      //

      resultant=pol[0]; 

      for(k=1;k<n;k++)

             resultant=multiply(resultant,pol[k]);  

      //output the ultimate resultant

      out(resultant);  

}


_____________________________________________________

November 26, 2009

Google Chrome OS

Filed under: Uncategorized — alanabraham @ 2:27 am
Google Chrome OS – Chromium

Google Chrome OS is an open source operating system designed by Google to work exclusively with web applications. Announced on July 7, 2009, Chrome OS is set to have a publicly available stable release during the second half of 2010. The operating system is based on Linux and targets specifically designed hardware. The user interface takes a minimalist approach, resembling that of the Chrome web browser. Because the browser will be the only application residing on the device, Google Chrome OS is aimed at users who spend most of their computer time on the Internet.
Few days back, I got the Developer build of Google’s new operating system and so tried that on a virtual machine.

Simpler and faster boot up.
Login using google account


Logs in directly to your gmail inbox





It’s focussed on netbooks and i hope the cybercafe’s will also benefit from this OS if it has good LAN networking capabilities.

Note : This is just a Developer build and its not yet time for a review. So now it is nothing more than a browser. Not an OS with file manipulation abilities.

Syshacks rocks.(This is my second home)



October 11, 2009

Windows 7 rocks

Filed under: Uncategorized — alanabraham @ 9:41 pm

Although MS(Microsoft) is currently facing threats from all sides(Google, Symantec etc) , as always, it still comes up with something new, and more importantly, something very valuable. I’m talking about the product of the year “windows 7”.

Some people always dislike “The Mighty” and will always complain about it.This psychological phenomenon is expressed by the so-called Linux Fan Boys when someone says the word WINDOWS or Microsoft.There is no treatment for that. I’m too a Linux fan but not a windows hater. Its like spoon and fork. You need both to eat.Its just choose the best accordingly for your work.

Back to Windows 7.I wont say “its the best and it has no bugs or faults”.Even i had some Hard Disk problems(My two drives crashed due to some reasons and windows 7 restricted access for my parallel Windows XP into that drive.) and downward permission problems(user permission restriction of drives in windows 7 cant be altered in windows XP). These are something perfectly natural for a new OS.

But the point i’m gonna express is different.

My friend Rohan came with a 16 GB Kingston Datatraveler G2 USB flash Drive,corrupted and cannot be accessed or formatted. I tried windows XP disk management utility,windows Diskpart commands and some professional tools like Acronis Disk Management. Same error “Windows cannot complete formatting the following disk”. I tried to enter into Windows 7 after trying again with Acronis. It worked like magic with Windows 7 and windows successfully formatted.Thanks to Microsoft and the minds behind Windows 7. The apparant problems are solved now but i know some may exist because the flash drive has some hardware problems. But on the software side Windows 7 make it maximum available for use.

This is the villain of the story.

This is the villain of the story.

iExperiment

Filed under: Uncategorized — alanabraham @ 9:35 pm

Experiment is a method of investigating causal relationships among variables, or to test a hypothesis.

Here I’m beginning the journey through the variables which are randomly generated in this life. My journey through my life and my experiments will be expressed here. I’m not promising an output but the system will be modified by this effort. And for every action, there is a cause. I bow before the Cause.

Create a free website or blog at WordPress.com.