Skip to content

Instantly share code, notes, and snippets.

@sbugrov
Last active July 6, 2017 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbugrov/cc03c9cb120043069cdae061fdd24017 to your computer and use it in GitHub Desktop.
Save sbugrov/cc03c9cb120043069cdae061fdd24017 to your computer and use it in GitHub Desktop.
vector <float> transpose (float *m, const int C, const int R) {
/* Returns a transpose matrix of input matrix.
Inputs:
m: vector, input matrix
C: int, number of columns in the input matrix
R: int, number of rows in the input matrix
Output: vector, transpose matrix mT of input matrix m
*/
vector <float> mT (C*R);
for(int n = 0; n!=C*R; n++) {
int i = n/C;
int j = n%C;
mT[n] = m[R*j + i];
}
return mT;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment