Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate random circulant Gram matrix of specified dimension. #379

Closed
vprusso opened this issue Dec 17, 2023 · 2 comments · Fixed by #389
Closed

Generate random circulant Gram matrix of specified dimension. #379

vprusso opened this issue Dec 17, 2023 · 2 comments · Fixed by #389
Assignees
Labels
Milestone

Comments

@vprusso
Copy link
Owner

vprusso commented Dec 17, 2023

Task: Function that allows one to generate a random circulant Gram matrix of a requested dimension.

In toqito/rand, adding the following function:

import numpy as np

def random_circulant_gram(dim: int) -> np.ndarray:
    # Step 1: Generate a random diagonal matrix with non-negative entries
    diag_mat = np.diag(np.random.rand(dim))
    
    # Step 2: Construct the normalized DFT matrix
    dft_mat = np.fft.fft(np.eye(dim)) / np.sqrt(dim)
    
    # Step 3: Compute the circulant matrix. Since circ_mat is formed from the DFT of a real 
    # diagonal matrix, it should be real
    return np.real(np.conj(dft_mat.T) @ diag_mat @ dft_mat)

Would also need to add appropriate tests in rand/tests as well adding a link in the .rst docs.

@vprusso vprusso added this to the Release 1.0.7 milestone Dec 17, 2023
@vprusso vprusso added good first issue Good for newcomers python Pull requests that update Python code feature request and removed python Pull requests that update Python code labels Dec 17, 2023
@ankit-pn
Copy link
Contributor

I would like to work on this, if no one is working on this then pls it to me!
Thanks

@vprusso
Copy link
Owner Author

vprusso commented Dec 21, 2023

Thanks for the interest, @ankit-pn. Assigned!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants