toqito icon indicating copy to clipboard operation
toqito copied to clipboard

Feature: Check if set of vectors constitute a tight frame

Open vprusso opened this issue 1 year ago • 4 comments

Provide a function that takes in as input a matrix (as a numpy array) and returns True if the matrix constitutes an equilangular tight frame and False otherwise.

A function like the following could be written:

import numpy as np


def is_etf(mat: np.ndarray) -> bool:
    """Determine if matrix forms an equilangular tight frame (ETF).
    
    Definition taken from the condition of:
    http://users.cms.caltech.edu/~jtropp/conf/Tro05-Complex-Equiangular-SPIE-preprint.pdf
    """
    # Each column has unit norm.
    nrows, ncols = mat.shape[0], mat.shape[1]
    for col in range(ncols):
        if not np.isclose(np.linalg.norm(mat[:][col]), 1):
            return False
    
    # Columns are equilangular.
    vals = []
    for i in range(ncols):
        for j in range(ncols):
            if i != j:                
                vals.append(np.abs(inner_product(mat[:][i], mat[:][j])))
    if len(set(vals)) > 1:
        return False
    
    # Matrix forms a tight frame.
    return np.allclose(mat @ mat.conj().T, (ncols / nrows) * np.identity(nrows * ncols))

One would also need to provide proper documentation, examples, and unit tests for this function.

Additional Option

Provide a function that takes in as input a matrix (as a numpy array) and returns True if the set of vectors constitute as a tight frame and False otherwise.

A function like the following could be written:

import numpy as np


def is_tight_frame(vectors: list[np.ndarray]) -> bool:
    """Check if list of vectors constitutes a tight frame."""
    n, d = len(vectors), vectors[0].shape[0]
    col_sum = 0
    for i in range(n):
        col_sum += np.linalg.norm(vectors[i])
    return np.isclose(sum(overlaps(vectors)), 1/np.sqrt(d) * col_sum**2)

One would also need to provide proper documentation, examples, and unit tests for this function.

Note that this requires the overlaps function to be defined from: https://github.com/vprusso/toqito/issues/556

vprusso avatar Apr 20 '24 17:04 vprusso

@vprusso Do we want to combine this issue and #562 into 1 issue?

purva-thakre avatar Aug 07 '24 13:08 purva-thakre

Yeah, I think combining these two makes sense.

vprusso avatar Aug 07 '24 13:08 vprusso

Hi @purva-thakre @vprusso ,

Can I be assigned to this issue?

Qubit1718 avatar Mar 06 '25 18:03 Qubit1718

PR #999 solves this issue. Please take a look at your convenience @vprusso @purva-thakre

Qubit1718 avatar Mar 07 '25 21:03 Qubit1718