GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add `matrix.power` to compute e.g. `A @ A @ A @ ...` by eriknw · Pull Request #483 · python-graphblas/python-graphblas

Conversation

@eriknw

@eriknw eriknw commented Jul 16, 2023

Copy link
Copy Markdown
Member

This uses #481 (and is actually why I made #481).

I still need to write the docstring.

I tried to make this efficient by performing repeated squaring. For example, for A.power(8), this will compute:

cur = op(A @ A).new()
cur << op(cur @ cur)
updater << op(cur @ cur)

This makes the implementation a little... uh... not obvious, but it works well.

A.power(n) returns an expression so mask can be applied. Even if a mask is used, an intermediate result A.power(n // 2) can still be pretty large--we only apply the mask on the very last matrix multiply.

I decided to require n to be a positive integer. n == 0 could return "the" identity, but what would be the identity for different semirings?

This method will let us easily and efficiently implement number_of_walks in graphblas_algorithms.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
eriknw added 2 commits July 14, 2023 11:38
@eriknw
Allow __index__ only for integral dtypes on Scalars
aba6999
@eriknw
Add matrix.power to compute e.g. A @ A @ A
39a4451
@eriknw eriknw added the feature Something is missing label Jul 16, 2023
@coveralls

coveralls commented Jul 16, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Coverage Status

coverage: 99.414% (+0.2%) from 99.206% when pulling 60a1d44 on eriknw:power into 3476731 on python-graphblas:main.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

eriknw added 2 commits July 17, 2023 23:43
@eriknw
Add Matrix.power docstring
cd609cd
@eriknw
Bump flake8-bugbear
8cc1cdc
jim22k
jim22k approved these changes Jul 26, 2023
View reviewed changes
eriknw added 4 commits July 26, 2023 11:40
@eriknw
Merge branch 'main' into power
b703e3e
@eriknw
Bump ruff
1d7c2ae
@eriknw
Code comments for power implementation
941d95f
@eriknw
sheesh! coveralls.io is not happy
60a1d44
@eriknw
eriknw merged commit 8e42ded into python-graphblas:main Jul 26, 2023
@eriknw eriknw mentioned this pull request Nov 4, 2023
Support A.power(0) #518
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jim22k jim22k jim22k approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

feature Something is missing

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@eriknw @coveralls @jim22k
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.