FFT리스


14

가정 우리는 주어진 다른 정수 1 , 2 , ... , N ,되도록 0 ≤ I ≤ K N 일부에 대한 상수 (K) > 0 , 및 모든 I .na1,a2,…,an0≤ai≤knk>0i

우리는 가능한 모든 페어 와이즈 합계 의 개수를 찾는 데 관심이 있습니다 . ( 나는 = JSij=ai+aji=j 가 허용됨).

한 알고리즘은 다항식 구성하는 정도 ≤ K , N , 및 푸리에 변환 방법 및 생성 다항식들은 계수들을 갖는 힘을 판독하여 그 사각형을 계산한다. 이것은 O ( n log n ) 시간 알고리즘입니다.P(x)=∑j=1nxaj≤knO(nlog⁡n)

두 가지 질문이 있습니다.

  • O ( n log n ) 가 있습니까O(nlog⁡n) FFT를 사용하지 않는 알고리즘은?

  • 더 나은 알고리즘 (예 알려져있다 )? (FFT 허용).o(nlog⁡n)


FFT를 사용하지 않는 것이 왜 중요합니까? 이미 문제에 대한 좋은 해결책이있는 것 같습니다. FFT를 사용하지 않는 요구 사항은 어디에서 왔습니까? 그것은 제게 부과하는 다소 부 자연스러운 요구처럼 들립니다.
— DW

@DW : 질문이 없으니까? :-) 다른 접근법이 있는지 궁금합니다.
— Aryabhata

알았어! 나도 궁금하다는 것을 인정한다. :-) 흥미로운 질문에 감사드립니다.
— DW

@DW : 천만에요 :-)
— Aryabhata

답변:


8

이 문제는 정수 / 다항식 제곱과 같습니다.

1. 다항식 곱셈 정수 곱셈에 해당하는 것으로 알려져있다 .

2. 당신은 이미 다항식 / 정수 제곱 법으로 문제를 줄였습니다. 그러므로이 문제는 거의 제곱만큼 어렵습니다.

이제이 문제에 대한 정수 제곱을 줄입니다.

알고리즘이 있다고 가정하십시오.

F(a→)→P2(x),where P(x)=∑ai∈a→xai

이 알고리즘은 본질적으로 질문에 요청한 알고리즘입니다. 따라서이 작업을 수행 할 수있는 마법 알고리즘이 있다면 정수 y 를 제곱 하는 함수 를 만들 수 있습니다 ( 오, 예, mathjax : P ).SQUARE(y)y

Algorithm 1 Squaring1.:procedure SQUARE(y):2.:a→←()▹ a→ starts as empty polynomial sequence3.:i←04.:while y≠0 do▹ break y down into a polynomial of base 25.:if y & 1 then▹ if lsb of y is set6.:a→←a→i▹ append i to a→ (appending xi)7.:end if8.:i←i+19.:y←y≫1▹ shift y right by one10.:end while11.:P2(x)←F(a→)▹ obtain the squared polynomial via F(a→)12.:return P2(2)▹ simply sum up the polynomial13.:end procedure

Python (test with codepad):

#/cs//q/11418/2755

def F(a):
    n = len(a)
    for i in range(n):
        assert a[i] >= 0

    # (r) => coefficient
    # coefficient \cdot x^{r}
    S = {}
    for ai in a:
        for aj in a:
            r = ai + aj

            if r not in S:
                S[r] = 0

            S[r] += 1

    return list(S.items())

def SQUARE(x):
    x = int(x)

    a = []
    i = 0
    while x != 0:
        if x & 1 == 1:
            a += [i]
        x >>= 1
        i += 1

    print 'a:',a
    P2 = F(a)

    print 'P^2:',P2

    s = 0
    for e,c in P2:
        s += (1 << e)*c
    return s

3. Thus, squaring is at most as hard as this problem.

4. Therefore, integer squaring is equivalent to this problem. (they are each at most as hard as each-other, due to (2,3,1))

Now it is unknown if integer/polynomial multiplication admits bounds better than O(nlog⁡n); in fact the best multiplication algorithms currently all use FFT and have run-times like O(nlog⁡nlog⁡log⁡n) (Schönhage-Strassen algorithm) and O(nlog⁡n2O(log∗⁡n)) (Fürer's algorithm). Arnold Schönhage and Volker Strassen conjectured a lower bound of Ω(nlog⁡n), and so far this seems to be holding.

This doesn't mean your use of FFT is quicker; O(nlog⁡n) for FFT is the number of operations (I think), not the bit complexity; hence it ignores some factors of smaller multiplications; when used recursively, it would become closer to the FFT multiplication algorithms listed above (see Where is the mistake in this apparently-O(n lg n) multiplication algorithm?).

5. Now, your problem is not exactly multiplication, it is squaring. So is squaring easier? Well, it is an open problem (no for now): squaring is not known to have a faster algorithm than multiplication. If you could find a better algorithm for your problem than using multiplication; then this would likely be a breakthrough.

So as of now, the answer to both your questions is: no, as of now, all the ~O(nlog⁡n) multiplication algorithms use FFT; and as of now squaring is as hard as multiplication. And no, unless a faster algorithm for squaring is found, or multiplication breaks the O(nlog⁡n) barrier, your problem cannot be solved faster than O(nlog⁡n); in fact, it cannot currently be solved in O(nlog⁡n) either, as the best multiplication algorithm only approaches that complexity.

당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.