39math::fibonacci_sum::matrix multiply(
const math::fibonacci_sum::matrix &T,
40 const math::fibonacci_sum::matrix &A) {
41 math::fibonacci_sum::matrix
result(2, std::vector<uint64_t>(2, 0));
44 result[0][0] = T[0][0] * A[0][0] + T[0][1] * A[1][0];
45 result[0][1] = T[0][0] * A[0][1] + T[0][1] * A[1][1];
46 result[1][0] = T[1][0] * A[0][0] + T[1][1] * A[1][0];
47 result[1][1] = T[1][0] * A[0][1] + T[1][1] * A[1][1];
58math::fibonacci_sum::matrix
power(math::fibonacci_sum::matrix T, uint64_t ex) {
59 math::fibonacci_sum::matrix A{{1, 1}, {1, 0}};
60 if (ex == 0 || ex == 1) {
103 uint64_t n = 0, m = 3;
104 uint64_t
test_1 = math::fibonacci_sum::fiboSum(n, m);
106 std::cout <<
"Passed Test 1!" << std::endl;
110 uint64_t
test_2 = math::fibonacci_sum::fiboSum(n, m);
112 std::cout <<
"Passed Test 2!" << std::endl;
116 uint64_t
test_3 = math::fibonacci_sum::fiboSum(n, m);
118 std::cout <<
"Passed Test 3!" << std::endl;
122 uint64_t test_4 = math::fibonacci_sum::fiboSum(n, m);
123 assert(test_4 == 123);
124 std::cout <<
"Passed Test 4!" << std::endl;
128 uint64_t test_5 = math::fibonacci_sum::fiboSum(n, m);
129 assert(test_5 == 322);
130 std::cout <<
"Passed Test 5!" << std::endl;