Implement a GPU program that raises a square matrix \(A\) of size \(N \times N\) to an integer power \(P\).
The solve function receives a flattened input matrix input (row-major order), an empty output matrix output of the same size, the dimension N, and the exponent P.
You must compute \(\text{output} = A^{P}\) where matrix multiplication is standard dense multiplication over 32-bit floating point numbers.
solve function signature must remain unchanged.output array in row-major order.
Input:
input = [[1.0, 2.0],
[3.0, 4.0]]
N = 2
P = 3
Output:
output = [[37.0, 54.0],
[81.0, 118.0]]
Input:
input = [[1.0, 0.0, 2.0],
[0.0, 1.0, 0.0],
[3.0, 0.0, 0.0]]
N = 3
P = 2
Output:
output = [[7.0, 0.0, 2.0],
[0.0, 1.0, 0.0],
[3.0, 0.0, 6.0]]
input satisfy \(-10.0 \le A_{ij} \le 10.0\)N = 512