mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Math (https://www.mersenneforum.org/forumdisplay.php?f=8)
-   -   trying to implement block lanczos on GF2... (https://www.mersenneforum.org/showthread.php?t=26044)

paul0 2020-10-04 17:33

trying to implement block lanczos on GF2...
 
1 Attachment(s)
Hi, I'm currently trying to implement Block Lanczos, but I'm having some trouble understanding the notation on calculating S[SUB]i[/SUB] and W[SUB]inv[/SUB]. I'm reading Montgomery's paper and Yang et. al.'s pseudocode (attached).

On line 13 of the attached file, the algorithm seems to create a set S of row & col where a 1 is found. Eventually I need to compute S[SUB]i[/SUB]*S[SUB]i[/SUB][SUP]T[/SUP] based on S. I think to form S[SUB]i[/SUB]*S[SUB]i[/SUB][SUP]T[/SUP] I just need to set M[x,x] = 1 for each x ∈ S. M is a square matrix with side size of machine word (as defined by the paper) rows and cols. Is this correct?

Also, S[SUB]i-1[/SUB] is an input to this function, but I don't see it was used there. What am I missing?

paul0 2020-10-04 19:12

I tried implementing M[x,x] = 1 as I mentioned above. It worked! V[SUB]i[/SUB][SUP]T[/SUP]*A*V[SUB]i[/SUB] becomes zero. However, it seems that not all X - Y are nullspaces of B. I got 10 out of 32 valid nullspace, then 6 out of 32 on a matrix with more dependencies. The paper says I need to combine these vectors. How do I do that? gaussian elimination?

I'd like to mention that I'm avoiding optimizations for now, like the ANDing of S[SUB]i[/SUB]*S[SUB]i[/SUB][SUP]T[/SUP].

paul0 2020-10-05 02:07

It seems that I missed an entire paragraph about the last step with gaussian elmination. will try to implement that first. also, RIP Peter Montgomery.

jasonp 2020-10-05 15:06

You figured it out, but yes the block Lanczos algorithm finds the nullspace of A^T*A and not of A, since the algorithm only works for symmetric matrices.To get the answers you need, Gauss elimination of the nullspace vectors you have is necessary.

I remember how great it felt when I managed to get the code running on a real problem, BL is [i]hard[/i] to figure out from papers, or even from other people's code.

henryzz 2020-10-06 05:20

It looks like Yang's paper is an improvement to clarity. I have tried and failed with other references in the past. Time for another go at some point. Congratulations on getting this working.

paul0 2020-10-06 05:52

[QUOTE=jasonp;558955]You figured it out, but yes the block Lanczos algorithm finds the nullspace of A^T*A and not of A, since the algorithm only works for symmetric matrices.To get the answers you need, Gauss elimination of the nullspace vectors you have is necessary.

I remember how great it felt when I managed to get the code running on a real problem, BL is [i]hard[/i] to figure out from papers, or even from other people's code.[/QUOTE]

[QUOTE=henryzz;559007]It looks like Yang's paper is an improvement to clarity. I have tried and failed with other references in the past. Time for another go at some point. Congratulations on getting this working.[/QUOTE]

I agree with you both. I kept trying sporadically since 2015. Aside from Yang's paper, this recent C++ implementation also helped me ([url]https://github.com/SebWouters/blanczos[/url]). It is well commented and seemed to written as teaching tool, though there are a few optimizations which may confuse beginners.

Here are the rest of the pseudocode from Yang's paper (full paper behind paywall): [url]https://www.sparrho.com/item/an-improved-parallel-block-lanczos-algorithm-over-gf2-for-integer-factorization/9c93ad/[/url]

I got the last step working and got it to work with my toy NFS implementation. The terms Montgomery used for the last step (page 114) were unfamiliar to me, so I'm a bit suspicious that by running gaussian elimination, I may have bypassed the entire Block Lanczos process. Also, I don't know yet how to not compute [B]U[/B] explicitly.

I have 2 questions:
1. Is it normal for the first dependency to be always trivial?
2. The very last output is "a basis for ZU". This just means the nullspaces of B are the columns of ZU?

EDIT: it seems that i'm in the wrong subforum, feel free to move this thread mods.

paul0 2020-10-06 07:10

I'd like to add a third question:
3. In Montgomery's paper p. 115, he writes: "Afterwards I check whether all nonzero columns of V[SUB]i+1[/SUB] were chosen in S[SUB]i[/SUB] and/or S[SUB]i-1[/SUB]". This assertion is implemented in the c++ implementation I linked above. What would happen if I do not implement this assertion? Will my implementation silently fail for some inputs?

Chris Card 2020-10-06 08:12

For what it's worth, here's my C++ implementation of block lanczos that I wrote a few years ago, based on Montgomery's paper:
[url]https://github.com/ChrisCGH/factor-by-gnfs/blob/master/gnfs/blockLanczos.cpp[/url]

paul0 2020-10-08 04:09

[QUOTE=Chris Card;559019]For what it's worth, here's my C++ implementation of block lanczos that I wrote a few years ago, based on Montgomery's paper:
[URL]https://github.com/ChrisCGH/factor-by-gnfs/blob/master/gnfs/blockLanczos.cpp[/URL][/QUOTE]


appreciate it, thanks


All times are UTC. The time now is 00:52.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.