int main()
{
  /* Chan, Joey, JMCSC, ync12 */
  int m = 0;
  int should_stop = 0;
  clock_t start, end;
  printf("   m         N      Result as expected   Time taken\n");
  printf("------- ---------- -------------------- ------------\n");
  while(!should_stop)
  {
    int i, result;
    for (i = 4; i <= 6; i++)
    { 
      double time_taken;
      int N = i*(int)pow(2, 3+m);
      double** M = MakeSN(N);
      start = clock();
      double** MM = mymatmul(M, M, N-1, N-1, N-1);
      end = clock();
      time_taken = (double) (end - start) / CLOCKS_PER_SEC;
      result = check_symmetric_matrix_correctness(MM, N);
      printf("%7d %10d %20s %12.4f\n", m, N, result == 1 ? "True" : "False", time_taken);
      free_matrix(M);
      free_matrix(MM);
      if (time_taken > 300)
      {
        should_stop = 1;
        break;
      }
    }
    m++;
  }

}
Esempio n. 2
0
int main(void){
    int N;
    double **A,**B,**C,t,f,g;
    printf("Size of N:\n");
    scanf("%d",&N);
    A=make_random_matrix(N,N);
    print_matrix(A,N,N);
    
    
    B=make_random_matrix(N,N);
    print_matrix(B,N,N);
    
    
    clock_t start = clock();
    clock_t end;
    
    C=mymatmul(A,B,N,N,N);
    print_matrix(C,N,N);
    
    
    free_matrix(A);free_matrix(B);free_matrix(C);
    end = clock();
    t=(double)(end - start);
    f=N*N*(N+(N-1));
    g=(double)f/(double)(t*1000000000);
    printf("f= %f, t= %f\n", f,t);
    printf("%e \n \n",g);
    exit(0);
    
}