Advertisement
Sri27119

Chain Matrix Multi

Sep 12th, 2024
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <ctime>
  4. #include <cstdlib>
  5. #include <iomanip>
  6. #include <chrono>
  7.  
  8. using namespace std;
  9. using namespace std::chrono;
  10.  
  11. template <typename Func>
  12. // using template function to measure time for sorting algorithms
  13. void measureSortTime(Func sortFunc, vector<int> &arr, const string &sortName)
  14. {
  15.     vector<int> arr_copy = arr; // Copy for sorting
  16.  
  17.     cout << "Starting " << sortName << "..." << endl;
  18.  
  19.     auto start = high_resolution_clock::now();
  20.     sortFunc(arr_copy);
  21.     auto end = high_resolution_clock::now();
  22.  
  23.     auto duration = duration_cast<nanoseconds>(end - start).count();
  24.     cout << "Time Taken:\t" << duration << " ns" << endl;
  25.     cout << "----------------------------------------" << endl;
  26. }
  27.  
  28. // Function to generate a vector of random integers
  29. vector<int> generateRandomArray(int size)
  30. {
  31.     vector<int> arr(size);
  32.     for (int i = 0; i < size; ++i)
  33.     {
  34.         arr[i] = rand() % size;
  35.     }
  36.     return arr;
  37. }
  38.  
  39.  
  40. void MatrixChainMulti(vector<int> p , int n ){
  41.  
  42.     int C [n][n];
  43.  
  44.     for(int i =0;i<n;i++){
  45.         C[i][i]=0;
  46.     }
  47.  
  48.    
  49. }
  50.  
  51. int main()
  52. {
  53.     vector<int> sizes = {100, 500, 1000, 1500, 2000};
  54.  
  55.     for (int size : sizes)
  56.     {
  57.         vector<int> d = generateRandomArray(size);
  58.         int n  = d.size();
  59.     }
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement