All pastes #2098153 Raw Edit

plupptest

public text v1 · immutable
#2098153 ·published 2012-01-02 12:38 UTC
rendered paste body
#include<stdio.h>
#include<math.h>

void main(){
    int i,j,N;
    N = 10;
    
    double *A,*B,*C;
    double i2,invi;

    FILE *out;

    /* Create vectors A and B */
    for(i=0; i<N; i++){
        i2 = i*i;
        A[i] = i2 - 20;

        invi = 1/i;
        B[i] = i2*invi;
    }

    /* Formulate matrix C */
    for(i=0; i<N; i++){
        for(j=0; j<N; j++){
            C[i,j] = A[i]*B[j];
        }
    }

    /* Save the output */
    out = fopen("out.dat", "w");
/*    fprintf(out, "\nOutput from ctest.c\n\n"); */
    for(i=0; i<N; i++){
        for(j=0; j<N; j++){
            fprintf(out, "%.2f" ,C[i,j]);
        }
        fprintf(out,"\n");
    }
    fclose(out);
}