1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need Of Dev C++ Editor Asap! :(

Discussion in 'C#' started by care89, Feb 17, 2013.

  1. #1
    I am using Windows 8 right now... installed Dev-C++ ver. 5.4.0
    I am doing a program (machine problem (MP)) but I cannot compile it. Honestly, it is my first contact with programming, so basically I don't have any idea about it. I don't know codes and whatever it stands for... I am very frustrated right now..
    If there is anybody here who can help me with my problem.. I would really appreciate it..
    I don't know what to do with it... the codes or algorithm (or whatever it is called) was just copied from past MP of my schoolmates, hence values are being change. Theirs' was properly running, but I don't know with mine, it just don't...
    here is the one I am doing...

    #include <iostream>
    #include <stdio.h>
    #include <math.h>
    using namespace std;
    /* Routine for generating the A matrix and the b vector for the homework */
    /* n = number of interior points (equations) */
    #define n 5500
    FILE *foutput;
    /* Defining variables and constants */
    double tol=0.000001;
    double a[n+5],b[n+5],h,x[n+5],y[n+5],c[n+5],d[n+5],e[n+5],f[n+5],L2;
    int i,j,k;
    main()
    {
    /* h = spacing between points */
    h=1.0/(float)(n+1);

    /* Initialize the A matrix */
    for(i=1;i<=n+1;i++)
    for(j=1;j<=n+1;j++)
    a[j]=0.0;

    /* The matrix generating routine: c[], d[], and e[] are vector of non-zero diagonals for tri-diagonal matrices */
    a[1][1]=-(2.0+4.0*h*h); d[1]=a[1][1];
    a[1][2]=1.0; e[1][2];

    /* Generate the main body */
    for(i=2;i<=n-1;i++)
    {
    a[i-1]=1.0; c=a[i-1];
    a=-(2.0+4.0*h*h); d=a;
    a[i+1]=1.0; e=a[i+1];
    }
    a[n][n-1]=1.0; c[n]=a[n][n-1];
    a[n][n]=-(2.0+4.0*h*h); d[n]=a[n][n];

    /* Generate the right hand side vector of values */
    for(i-1;i<=n-1;i++)
    b=h*h;
    b[n]=h*h-1.0;

    /* initial guess of vector x = 1 */
    for(i=1;i<=n;i++)
    x=1.0;

    /* Performing Iteration: initialize count number of iterations, k */
    k=0;

    /* Main body of Iteration */
    do
    {

    /* Count up "k" */
    k++;

    /* using Jacobi Iteration */
    y=(b[1]=e[1]*x[2]/d[1];
    for(i=2;i<=n-1;i++)
    y=(b-c*x[i-1]-e*x[i+1]/d;
    y[n]=(b[n]-d[n]*x[n-1]/d[n];

    /* Testing for convergence test */
    L2=0.0;
    for(i=1;i<=n.i++)
    {

    /* Applying the L2 exit criterion */
    f[i]=(fabs(fabs(y[i])=fabs(x[i])))*(fabs(fabs(y[i])-fabs(x[i])));
    L2=L2+f[i];
    }
    L2-sqrt(L2);
    printf("# of iteration %d tolerance - %.61f|n",k,L2);

    /* Putting y=x */
    for(i=1;i<=n;i++)
    x[i]=y[i];
    }
    while(l2>tol);

    /* Print output */
    foutput=fopen("MP1 - Jacobi.txt","w");
    printf("# of Iteration = %d\n",k);
    fprintf(foutput,"# of iteration = %d\n",k);
    for(i=5200;i<=5210;i++)
    {
    printf("x[%d]=%.61f\n",i,x[i]);
    fprintf(foutput,"x[%d]=%0.61f\n",i,x[i]);
    }
    fclose(foutput);
    system("pause");
    return 0;
    }[/i][/i][/i][/i][/i][/i][/i][/i][/i][/i]
     
    care89, Feb 17, 2013 IP