[SOLVED] COMP1011 Lab 7-Matrix Power

25.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

5/5 - (1 vote)

Laboratory Seven: Array
Problem: Matrix Power
Problem description
The power of a square matrix An is defined as follows:

I is an identify matrix (https://en.wikipedia.org/wiki/Identity_matrix).
Design a function as follows to calculate the power of a square matrix under a given module base. void matrix_power(int A[][N], int d, int n, int x, int res[][N])
• Input & output requirements
Input the dimension d, the matrix A, the power n and the module base x.
Note that 2 <= d <= 50, 0 <= n <= 1000, 2 <= x <= 104 and 0 <= A[i][j] <= 100 for any 0 <= i, j < d.
Ouput the An mod x.
• Sample results
Sample Input I:
2
1 1
1 1
0 10
Sample Ouput I:
1 0
0 1
Sample Input II:
5
1 2 3 4 5
6 7 8 9 1
1 2 3 4 5
4 5 6 7 8
6 7 8 9 1
1000 1007
Sample Ouput II:
142 432 722 5 360
889 786 683 580 530
142 432 722 5 360
970 772 574 376 504
889 786 683 580 530

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.