[ot][spam][random][crazy][random][crazy]

Undescribed Horrific Abuse, One Victim & Survivor of Many gmkarl at gmail.com
Wed Nov 16 06:11:54 PST 2022


(Pdb) p np.fft.fft(randvec2irfft).real
array([0.5488135 , 0.71518937, 0.60276338, 0.54488318, 0.4236548 ,
       0.64589411, 0.43758721, 0.891773  , 0.96366276, 0.38344152,
       0.79172504, 0.52889492, 0.56804456, 0.92559664, 0.07103606,
       0.92559664, 0.56804456, 0.52889492, 0.79172504, 0.38344152,
       0.96366276, 0.891773  , 0.43758721, 0.64589411, 0.4236548 ,
       0.54488318, 0.60276338, 0.71518937])
(Pdb) p np.concatenate([randvec[:15-1], randvec[15-1:15], randvec[15-2:0:-1]])
array([0.5488135 , 0.71518937, 0.60276338, 0.54488318, 0.4236548 ,
       0.64589411, 0.43758721, 0.891773  , 0.96366276, 0.38344152,
       0.79172504, 0.52889492, 0.56804456, 0.92559664, 0.07103606,
       0.92559664, 0.56804456, 0.52889492, 0.79172504, 0.38344152,
       0.96366276, 0.891773  , 0.43758721, 0.64589411, 0.4236548 ,
       0.54488318, 0.60276338, 0.71518937])

so the full complex frequencies are the positive reflection of the real ones.

(Pdb) doublerandvec = np.concatenate([randvec[:15-1],
randvec[15-1:15], randvec[15-2:0:-1]], axis=0)
(Pdb) p np.fft.ifft(doublerandvec).real
array([ 6.23788233e-01, -1.10813893e-02, -2.20954659e-02,  3.42088940e-02,
        3.90241536e-02, -5.46560429e-03, -4.05515245e-02,  2.58696585e-02,
       -2.15808106e-03, -1.95104618e-02, -6.35896998e-02,  9.52535278e-02,
       -4.83357438e-02,  1.69736668e-04, -3.84507295e-02,  1.69736668e-04,
       -4.83357438e-02,  9.52535278e-02, -6.35896998e-02, -1.95104618e-02,
       -2.15808106e-03,  2.58696585e-02, -4.05515245e-02, -5.46560429e-03,
        3.90241536e-02,  3.42088940e-02, -2.20954659e-02, -1.10813893e-02])
(Pdb) p randvec2irfft
array([ 6.23788233e-01, -1.10813893e-02, -2.20954659e-02,  3.42088940e-02,
        3.90241536e-02, -5.46560429e-03, -4.05515245e-02,  2.58696585e-02,
       -2.15808106e-03, -1.95104618e-02, -6.35896998e-02,  9.52535278e-02,
       -4.83357438e-02,  1.69736668e-04, -3.84507295e-02,  1.69736668e-04,
       -4.83357438e-02,  9.52535278e-02, -6.35896998e-02, -1.95104618e-02,
       -2.15808106e-03,  2.58696585e-02, -4.05515245e-02, -5.46560429e-03,
        3.90241536e-02,  3.42088940e-02, -2.20954659e-02, -1.10813893e-02])

doublerandvec is the frequencies, and i'm trying to debug the inverse
fourier transform, which is easy to put into a matrix.

(Pdb) freqs15f = fftfreq(len(doublerandvec), complex=True)
(Pdb) p rfreqs15f
array([0.        , 0.03571429, 0.07142857, 0.10714286, 0.14285714,
       0.17857143, 0.21428571, 0.25      , 0.28571429, 0.32142857,
       0.35714286, 0.39285714, 0.42857143, 0.46428571, 0.5       ])
(Pdb) p np.fft.rfftfreq(len(doublerandvec))
array([0.        , 0.03571429, 0.07142857, 0.10714286, 0.14285714,
       0.17857143, 0.21428571, 0.25      , 0.28571429, 0.32142857,
       0.35714286, 0.39285714, 0.42857143, 0.46428571, 0.5       ])

rfreqs15f is the real space frequencies for randvec. doublerandvec has
the complex space frequencies.

(Pdb) p freqs15f
array([ 0.        ,  0.03571429,  0.07142857,  0.10714286,  0.14285714,
        0.17857143,  0.21428571,  0.25      ,  0.28571429,  0.32142857,
        0.35714286,  0.39285714,  0.42857143,  0.46428571, -0.5       ,
       -0.46428571, -0.42857143, -0.39285714, -0.35714286, -0.32142857,
       -0.28571429, -0.25      , -0.21428571, -0.17857143, -0.14285714,
       -0.10714286, -0.07142857, -0.03571429])
(Pdb) p np.fft.fftfreq(len(doublerandvec))
array([ 0.        ,  0.03571429,  0.07142857,  0.10714286,  0.14285714,
        0.17857143,  0.21428571,  0.25      ,  0.28571429,  0.32142857,
        0.35714286,  0.39285714,  0.42857143,  0.46428571, -0.5       ,
       -0.46428571, -0.42857143, -0.39285714, -0.35714286, -0.32142857,
       -0.28571429, -0.25      , -0.21428571, -0.17857143, -0.14285714,
       -0.10714286, -0.07142857, -0.03571429])

i made freqs15f to hold the full frequencies

so now i can make a normal complex matrix, and compare it to the
faulty real-valued ones

(Pdb) ift15 = create_freq2time(freqs=freqs15f)

i'm poking at it, and it looks like my analysis of rows and columns
has been wrong in spots.
the first dimension is the row. the second is the column.

(Pdb) p ift15[:,6]
array([ 0.03571429+0.00000000e+00j,  0.00794718+3.48188540e-02j,
       -0.03217746+1.54958478e-02j, -0.02226749-2.79225529e-02j,
        0.02226749-2.79225529e-02j,  0.03217746+1.54958478e-02j,
       -0.00794718+3.48188540e-02j, -0.03571429+1.31212157e-17j,
       -0.00794718-3.48188540e-02j,  0.03217746-1.54958478e-02j,
        0.02226749+2.79225529e-02j, -0.02226749+2.79225529e-02j,
       -0.03217746-1.54958478e-02j,  0.00794718-3.48188540e-02j,
        0.03571429+2.62424314e-17j,  0.00794718+3.48188540e-02j,
       -0.03217746+1.54958478e-02j, -0.02226749-2.79225529e-02j,
        0.02226749-2.79225529e-02j,  0.03217746+1.54958478e-02j,
       -0.00794718+3.48188540e-02j, -0.03571429-1.31212157e-17j,
       -0.00794718-3.48188540e-02j,  0.03217746-1.54958478e-02j,
        0.02226749+2.79225529e-02j, -0.02226749+2.79225529e-02j,
       -0.03217746-1.54958478e-02j,  0.00794718-3.48188540e-02j])
(Pdb) p irft15[:,6]
array([ 0.06666667+0.00000000e+00j,  0.01483473+6.49951941e-02j,
       -0.06006459+2.89255826e-02j, -0.04156599-5.21220988e-02j,
        0.04156599-5.21220988e-02j,  0.06006459+2.89255826e-02j,
       -0.01483473+6.49951941e-02j, -0.06666667+2.44929360e-17j,
       -0.01483473-6.49951941e-02j,  0.06006459-2.89255826e-02j,
        0.04156599+5.21220988e-02j, -0.04156599+5.21220988e-02j,
       -0.06006459-2.89255826e-02j,  0.01483473-6.49951941e-02j,
        0.06666667-4.89858720e-17j])

The matrices differ by a factor of approximately but not exactly 2.0 .

I can now troubleshoot a problem cause to the scaling by freq_count in
create_freq2time . This freq_count is wrong for real-valued data.
[celebration]

0829

0842 I changed create_freq2time to keep track of freq_count and things
look somewhat better. the assertion still fails.

(Pdb) ift15[:,6]
array([ 0.03571429+0.00000000e+00j,  0.00794718+3.48188540e-02j,
       -0.03217746+1.54958478e-02j, -0.02226749-2.79225529e-02j,
        0.02226749-2.79225529e-02j,  0.03217746+1.54958478e-02j,
       -0.00794718+3.48188540e-02j, -0.03571429+1.31212157e-17j,
       -0.00794718-3.48188540e-02j,  0.03217746-1.54958478e-02j,
        0.02226749+2.79225529e-02j, -0.02226749+2.79225529e-02j,
       -0.03217746-1.54958478e-02j,  0.00794718-3.48188540e-02j,
        0.03571429+2.62424314e-17j,  0.00794718+3.48188540e-02j,
       -0.03217746+1.54958478e-02j, -0.02226749-2.79225529e-02j,
        0.02226749-2.79225529e-02j,  0.03217746+1.54958478e-02j,
       -0.00794718+3.48188540e-02j, -0.03571429-1.31212157e-17j,
       -0.00794718-3.48188540e-02j,  0.03217746-1.54958478e-02j,
        0.02226749+2.79225529e-02j, -0.02226749+2.79225529e-02j,
       -0.03217746-1.54958478e-02j,  0.00794718-3.48188540e-02j])
(Pdb) irft15[:,6]
array([ 0.03571429+0.00000000e+00j,  0.00794718+3.48188540e-02j,
       -0.03217746+1.54958478e-02j, -0.02226749-2.79225529e-02j,
        0.02226749-2.79225529e-02j,  0.03217746+1.54958478e-02j,
       -0.00794718+3.48188540e-02j, -0.03571429+1.31212157e-17j,
       -0.00794718-3.48188540e-02j,  0.03217746-1.54958478e-02j,
        0.02226749+2.79225529e-02j, -0.02226749+2.79225529e-02j,
       -0.03217746-1.54958478e-02j,  0.00794718-3.48188540e-02j,
        0.03571429-2.62424314e-17j])

So, now the action of double the repeated range should make the right result.
And I'm thinking I could undo that, when taking the inverse, by
halving and mirroring them.

0849
Looks like the concatenation does now work:
(Pdb) p randvec2irfft
array([ 6.23788233e-01, -1.10813893e-02, -2.20954659e-02,  3.42088940e-02,
        3.90241536e-02, -5.46560429e-03, -4.05515245e-02,  2.58696585e-02,
       -2.15808106e-03, -1.95104618e-02, -6.35896998e-02,  9.52535278e-02,
       -4.83357438e-02,  1.69736668e-04, -3.84507295e-02,  1.69736668e-04,
       -4.83357438e-02,  9.52535278e-02, -6.35896998e-02, -1.95104618e-02,
       -2.15808106e-03,  2.58696585e-02, -4.05515245e-02, -5.46560429e-03,
        3.90241536e-02,  3.42088940e-02, -2.20954659e-02, -1.10813893e-02])
(Pdb) p (doublerandvec @ np.concatenate([irft15[:-1],
irft15[-1:].conj(), irft15[-2:0:-1].conj()], axis=0)).real
array([ 6.23788233e-01, -1.10813893e-02, -2.20954659e-02,  3.42088940e-02,
        3.90241536e-02, -5.46560429e-03, -4.05515245e-02,  2.58696585e-02,
       -2.15808106e-03, -1.95104618e-02, -6.35896998e-02,  9.52535278e-02,
       -4.83357438e-02,  1.69736668e-04, -3.84507295e-02,  1.69736668e-04,
       -4.83357438e-02,  9.52535278e-02, -6.35896998e-02, -1.95104618e-02,
       -2.15808106e-03,  2.58696585e-02, -4.05515245e-02, -5.46560429e-03,
        3.90241536e-02,  3.42088940e-02, -2.20954659e-02, -1.10813893e-02])

so for those middle values, I can pass likely both the negative and
the positive frequencies to the wavelet function and sum them.

0857

I added the summation and the assertion around the easier inverse
transform is now passing. next is the forward matrix. i have some
interest in, later, spending time organising some of these conditional
cases; there's redundancy and special-casing.

it's cool that it makes working real-valued inverse transform matrices
now; they're half the size.

0900

0903

this has a clear inverse, which needs a square matrix. i was thinking
i could make it square before inverting it. the matrix has only real
components, rather than the imaginary components present in the full
complex matrix. can i still turn it into a working square matrix? if
not, the code that generates it does have access to the full
frequencies.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fourier.py
Type: text/x-python
Size: 11423 bytes
Desc: not available
URL: <https://lists.cpunks.org/pipermail/cypherpunks/attachments/20221116/9eb069d6/attachment-0001.py>


More information about the cypherpunks mailing list