transpose

C++ Function Reference

1 Signature

matrix BigDataStatMeth::transpose(const matrix &M)

2 Description

Transposes a 2D matrix.

3 Parameters

  • M (const matrix &): Input matrix to be transposed

4 Returns

matrix Transposed matrix where rows become columns and vice versa

5 Details

MInput matrix to be transposed matrix Transposed matrix where rows become columns and vice versaTime complexity: O(rows * cols) Space complexity: O(rows * cols) for the new matrix

6 Call Graph

Function dependencies

7 Source Code

File: inst/include/hdf5Utilities/hdf5ImportFiles.hppLines 42-55

inline matrix transpose( const matrix &M )
    {
        int rows = M.size();
        int cols = M[0].size();
        
        matrix T( cols, std::vector<double>( rows ) );
        
        for ( int i = 0; i < rows; i++ )
        {
            for ( int j = 0; j < cols; j++ ) T[j][i] = M[i][j];
        }
        
        return T;
    }

8 Usage Example

#include "BigDataStatMeth.hpp"

// Example usage
auto result = transpose(...);