BIDData / BIDMat

A CPU and GPU-accelerated matrix library for data mining
BSD 3-Clause "New" or "Revised" License
265 stars 73 forks source link

Question about matrix power algo #70

Open amedeedaboville opened 8 years ago

amedeedaboville commented 8 years ago

I am implementing randomized SVD in BidMach/BidMat, which I would love to contribute to BidMach later if possible :-). One of the steps of my algorithm involves, for a large dense matrix A, computing (AA')qA

I was wondering if there was an operator or function in BidMat for the exponentiation part (a fast Mq)? I checked the wiki pages Scientific Functions and Matrix Algebra and could not find anything. There is a pow function but that seems to be an element-wise power between two matrices. It might already exist in BidMat but I couldn't find it in the documentation.

I thought there could be some method to this with exponentiation by squaring, or even just a pre-written method that would remove the need to write a for loop every time. I can implement this if you would like. Cheers, Amédée

jcanny commented 7 years ago

I'm not clear on what you want from A^q. The element-wise operator is exposed as A ^ q.

But if you want a matrix power, you have to compute an eigendecomposition of A (assuming it exists) and then power the diagonal eigenvalues element-wise by q. Normally this requires A to be positive definite.