# Norm constraint in CVXPY

I'm trying to implement the algorithm outlined in https://arxiv.org/abs/1211.5608 on a small scale. I have a linear operator $$\mathcal{A}$$ which is defined as $$\text{trace}(A^*_l(hm^*))$$ where $$A_l = \hat{b}_l\hat{c}_l^*$$, where $$\hat{b}_l$$ and $$\hat{c}_l^*$$ are columns and vectors of different matrices.

I've used this as a constraint to solve the problem

$$\min \|X\|_*$$ subject to $$\hat{y} = \mathcal{A}(X)$$

In CVXPY, I made the constraint:

constraints = [cp.trace(np.transpose((B_hat_star[:,col][:,np.newaxis]*np.sqrt(L)*C_hat[col,:])) @ X) == y_hat[col] for col in range(L)]

and this works. However, now I'm trying to make the constraint: $$\|\hat{y} - \mathcal{A}(X)\|_2 \leq \delta$$. I'm not sure how to enforce a norm constraint on a matrix that is defined with a for loop (as above). I've tried doing

constraints = [cp.norm([y_hat[col] - cp.trace(np.transpose((B_hat_star[:,col][:,np.newaxis]*np.sqrt(L)*C_hat[col,:])) @ X) for col in range(L)], 2) <= delta], but I get an error that says ValueError: setting an array element with a sequence.

constraints = [cp.norm(