CS205 S22 Assignment 1
|
Functions that you need to implement for SUSTech CS205 (s22) assignment 1. More...
Go to the source code of this file.
Functions | |
int | quick_power (int x, int n) |
int | matrix_addition (matrix mat_a, matrix mat_b, matrix mat_res) |
int | matrix_multiplication (matrix mat_a, matrix mat_b, matrix mat_res) |
int | naive_matrix_exp (matrix mat_a, int exp, matrix mat_res) |
int | fast_matrix_exp (matrix mat_a, long long exp, matrix mat_res) |
int | fast_cal_fib (long long n) |
Variables | |
const int | MODULO |
Instead of using the magic number 1e9 + 7 everywhere in your program, you should use this constant when you need to take a module. | |
Functions that you need to implement for SUSTech CS205 (s22) assignment 1.
EVERY functions should be defined in your source file, even if you could not implement it (in this case, leave a blank function body is okay). You NEED NOT modify this file, and DON'T submit this to Blackboard
int fast_cal_fib | ( | long long | n | ) |
Calculate the nth number in Fibonacci Sequence using Fast Matrix Exponentiation
n | the index of the result in Fibonacci Sequence |
Calculate the result the of matrix exponentiation in a fast way
mat_res | the matrix used to store the result of mat_a ^ exp |
mat_res
does not match required size or mat_a
is not square; 0 otherwise mat_res
is different from mat_a
Calculate the result the of matrix addition When returning 1, do not modify the entities in mat_res
mat_res | the matrix used to store the result of A + B |
mat_res
does not match required size or mat_a
and mat_b
cannot do the addition; 0 otherwise mat_res
is different from mat_a
or mat_b
Calculate the result the of matrix multiplication
mat_res | the matrix used to store the result of A * B |
mat_res
does not match required size or mat_a
and mat_b
cannot do the multiplication; 0 otherwise mat_res
is different from mat_a
or mat_b
Calculate the result the of matrix exponentiation in a naive way
mat_res | the matrix used to store the result of mat_a ^ exp |
mat_res
does not match required size or mat_a
is not square; 0 otherwise mat_res
is different from mat_a
int quick_power | ( | int | x, |
int | n | ||
) |
Calculate power of x^n in O(log n)
x | the base number |
n | the exponent number |