Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "cuda_runtime.h"
- #include "device_launch_parameters.h"
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- #include <iomanip>
- using namespace std;
- int* generate_random_matrix(void);
- int* transpose_function(int* matrix);
- int main()
- {
- int *generated_matrix = generate_random_matrix();
- cout << generated_matrix[1] << endl;
- int *transposed_matrix = transpose_function(generated_matrix);
- cout << transposed_matrix[10000] << endl;
- system("PAUSE");
- return 0;
- }
- int *transpose_function(int* matrix)
- {
- int temp;
- for (int i = 0; i < 10000; i++)
- {
- for (int j = 0; j + i < 10000; j++)
- {
- if (j - i > 0)
- {
- temp = matrix[10000*i + j];
- matrix[10000*j + i] = temp;
- }
- }
- }
- return matrix;
- }
- int* generate_random_matrix(void)
- {
- int min = 0;
- int max = 9;
- int *matrix = new int[10000*10000];
- srand(time(NULL));
- for (int i = 0; i < 10000*10000; i++)
- {
- matrix[i] = min + (rand() % static_cast<int>(max - min + 1));
- }
- return matrix;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement