Matrix Transpose
2026/3/9小于 1 分钟
Matrix Transpose
题面
Write a program that transposes a matrix of 32-bit floating point numbers on a GPU. The transpose of a matrix switches its rows and columns. Given a matrix
𝐴
of dimensions
𝑟
𝑜
𝑤
𝑠
×
𝑐
𝑜
𝑙
𝑠
, the transpose
𝐴
𝑇
will have dimensions
𝑐
𝑜
𝑙
𝑠
×
𝑟
𝑜
𝑤
𝑠
. All matrices are stored in row-major format.
A
1
2
3
4
5
6
3 × 2
rows → cols
Aᵀ
1
3
5
2
4
6
2 × 3
Implementation Requirements
- Use only native features (external libraries are not permitted)
- The solve function signature must remain unchanged
- The final result must be stored in the matrix output
Examples
Example 1:
Input: 2×3 matrix
[
1.0
2.0
3.0
4.0
5.0
6.0
]
Output: 3×2 matrix
[
1.0
4.0
2.0
5.0
3.0
6.0
]Example 2:
Input: 3×1 matrix
[
1.0
2.0
3.0
]
Output: 1×3 matrix
[
1.0
2.0
3.0
]Constraints
- 1 ≤ rows, cols ≤ 8192
- Input matrix dimensions: rows × cols
- Output matrix dimensions: cols × rows
- Performance is measured with cols = 6,000, rows = 7,000