Skip to content

Added Matrix Exponentiation #1203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 25, 2019
Merged

Added Matrix Exponentiation #1203

merged 3 commits into from
Sep 25, 2019

Conversation

anirudnits
Copy link
Contributor

@anirudnits anirudnits commented Sep 25, 2019

Fixes #1180 Added the matrix_exponentiation.py file in maths directory

@cclauss cclauss changed the title Added Matrix Exponentiation #1180 Added Matrix Exponentiation Sep 25, 2019
Copy link
Member

@cclauss cclauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking cool! A doctest or two would help https://docs.python.org/3/library/doctest.html



fibonacci_with_matrix_exponentiation(n, f1, f2)
'''
Copy link
Member

@cclauss cclauss Sep 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readability, simplify this to:
code = "fibonacci_with_matrix_exponentiation(randint(1,70000), 1, 1)"

'''
exec_time = timeit.timeit(setup = setup,
stmt = code,
number = 100)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might reformat your code with https://github.com/python/black

stmt = code,
number = 100)

print ("Without matrix exponentiation the average execution time is ", exec_time/100)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No space between print and (. print() is a function call just like randint() is.



if __name__ == "__main__":
main()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 GitHub editor is telling you to add a single carriage return at the end of your file.

@anirudnits
Copy link
Contributor Author

Implemented the changes and re-submitted the PR, have a look.

@cclauss cclauss merged commit e40d4a2 into TheAlgorithms:master Sep 25, 2019
stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
* Added the matrix_exponentiation.py file in maths directory

* Implemented the requested changes

* Update matrix_exponentiation.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding Matrix Exponentiation
2 participants