Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. int main()
  2. {
  3. int* buffer =(int *)malloc(267289 * sizeof(int));
  4. FILE* ptr;
  5.  
  6. int n = 517;
  7.  
  8. double w[25];
  9. for (int i = 0; i < 5; i++)
  10. {
  11. for (int j = 0; j < 5; j++)
  12. {
  13. if (abs(eucD(i, 2, j, 2) - 8) == 0)
  14. w[5 * i + j] = 0.004;
  15. else if (abs(eucD(i, 2, j, 2) - 5) == 0)
  16. w[5 * i + j] = 0.016;
  17. else if (abs(eucD(i, 2, j, 2) - 4) == 0)
  18. w[5 * i + j] = 0.026;
  19. else if (abs(eucD(i, 2, j, 2) - 2) == 0)
  20. w[5 * i + j] = 0.071;
  21. else if (abs(eucD(i, 2, j, 2) - 1) == 0)
  22. w[5 * i + j] = 0.117;
  23. else
  24. w[5 * i + j] = 0.0;
  25.  
  26.  
  27. }
  28.  
  29. }
  30.  
  31.  
  32.  
  33. ptr = fopen("conf-init.bin", "rb"); // r for read, b for binary
  34.  
  35. fread(buffer, sizeof(buffer), 1, ptr); // read 10 bytes to our buffer
  36. fclose(ptr);
  37.  
  38. ising(buffer, w, 1, 517);
  39.  
  40. int * test=(int *)malloc(267289 * sizeof(int));
  41.  
  42. ptr = fopen("conf-1.bin", "rb"); // r for read, b for binary
  43.  
  44. fread(test, sizeof(test), 1, ptr); // read 10 bytes to our buffer
  45. fclose(ptr);
  46. int a = 0;
  47. for (int i = 0; i < 267289; i++) {
  48. if (test[i] != buffer[i]) {
  49. a++;
  50. }
  51. }
  52. printf("Errors=%d\n", a);
  53.  
  54.  
  55.  
  56.  
  57.  
  58. return 0;
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement