Advertisement
Trainlover08

Transpose function

Apr 10th, 2024 (edited)
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. vector<vector<float>> transpose(vector<vector<float>> input){
  2.     float input_rows = input.size();
  3.     float input_cols = input[0].size();
  4.     vector<vector<float>> output (input_cols, vector<float>(input_rows));
  5.     for(short i = 0; i < input_rows;){
  6.         for(short k = 0; k < input_cols;){
  7.             output[k][i] = input[i][k];
  8.             ++k;
  9.         }
  10.         ++i;
  11.     }
  12.     return output;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement