Code Monkey home page Code Monkey logo

Comments (9)

mrcdr avatar mrcdr commented on July 16, 2024

Thank you for your comment! Currently the interface is not supported, but it should be.
I just started to import it so please wait a while!

from pylanczos.

zhouyou-gu avatar zhouyou-gu commented on July 16, 2024

Hi @mrcdr , Thank you for the reply. Also, could I have some reference papers or books for this algorithm to read? I need to compute the exponential of a sparse matrix (~500x500, ~10 connections per row) as fast as possible (maybe using some randomized approximation, I am not sure?). I am from wireless engineering and do not have much experience in linalg computation (normally, I just call the package function, but they seem not fast enough this time). Thank you so much for your help!

from pylanczos.

mrcdr avatar mrcdr commented on July 16, 2024

I'm not a linear-algebra specialist too (sorry, my background is physics). But my library is based on so called "Krylov subspace method," whose characteristic is summarized in the 10th section of the article https://www.cs.jhu.edu/~misha/ReadingSeminar/Papers/Moler03.pdf . There are a lot of Krylov method related articles in various fields, so I believe some could be found in yours.

By the way, does scipy.sparse.linalg.expm work fast enough in your case? This maybe effective if you desire the matrix exponential itself.

from pylanczos.

zhouyou-gu avatar zhouyou-gu commented on July 16, 2024

@mrcdr I am trying to write the matrix multiplicative weights methods [1] where matrix exponential (expm) is needed for each iteration. As I wish to use this method in some real-time applications, I want to figure out how to design the expm so that maybe I can accelerate it using CUDA or something similar when the matrix is large (I am not sure whether it's possible or not). Nevertheless, I will try to use scipy.sparse.linalg.expm or your codes first, and I will also read the paper you suggest to study. Thank you so much for the help.

[1] Arora, Sanjeev, and Satyen Kale. "A combinatorial, primal-dual approach to semidefinite programs." Proceedings of the thirty-ninth annual ACM symposium on Theory of computing. 2007.

from pylanczos.

mrcdr avatar mrcdr commented on July 16, 2024

@zhouyou-gu Thank you for waiting! I just released the exponentiator-included version pylanczos==2.1.0. Though no samples of the exponentiator interface are available for now, its test code would be helpful.

from pylanczos.

zhouyou-gu avatar zhouyou-gu commented on July 16, 2024

Thank you so much for the update! I will have a try on those test codes.

from pylanczos.

zhouyou-gu avatar zhouyou-gu commented on July 16, 2024

Hi @mrcdr , I was trying to use the Exponentiator class to compute e^A@v. Following the paper you shared, it seems we should be able to configure the number of iterations of the Lanczos method (the "m" in Kyrlov subspace {v, Av A^2 v,...., A^m v}). However, I did not find the interface to set up it. Do you think it can be configured somehow? Also, is the output of the Lanczos iteration available somewhere in the Python interface (orthonormal columns V and a tridiagonal real symmetric T )? Thank you so much!

from pylanczos.

mrcdr avatar mrcdr commented on July 16, 2024

@zhouyou-gu Thank you for your question.

You don't have to configure the $m$ yourself. Lanczos exponention automatically determines it in the following iteration:

  1. Calculate $\lbrace{ v, Av, Av^2, \cdots, A^kv \rbrace}$ and express an approximated vector $u_k \sim \exp(\alpha A)v$ as a linear combination of them.
  2. If the approximation is "good enough", that is, the lastly added Krylov vector $A^kv$ does not change the $u_k$, exit the algorithm (now $m=k$). This can be checked by comparing $u_k$ and $u_{k-1}$, which is obtained in the previous iteration.
  3. If the approximation is not good enough, $k\to k+1$ and continue the iteration.

This approximation is intuitively understood from the fact that the Taylor expansion

$$ v' = \exp(\alpha A) v = \sum_{k=0}^{\infty} \frac{\alpha^k}{k!} A^k v $$

gets more accurate as the $k$ is increased. Note that the Krylov subspace algorithm is much more efficient than direct calculation of the power $A^k$.

Due to this auto-determination, the library does not provide internal data $V$ and $T$ (these are deeply embedded in C++ implementation).

from pylanczos.

zhouyou-gu avatar zhouyou-gu commented on July 16, 2024

Thank you so much for your explanation!

from pylanczos.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.