Hello,
Part of the message printed by checkgradient is:
> # The cost function appears to return complex values.
> # Please ensure real outputs.
The cost function must return real values only (even if the variables are complex). This is because it does not make sense to minimize a complex-valued function.
Is $B \otimes C$ Hermitian? If not, the cost function may not be real valued.
If it is, and if your notation $d^*$ stands for conj(d) (that is, conjugate of d) and your notations $d^T$, $x^H$ stand for d.' (transpose) and x' (conjugate-transpose), then I agree that your cost function is mathematically real-valued. But it is still possible that small numerical errors lead to complex values in the cost function.
In that last case (if the function should be real but numerical errors create very small imaginary parts), then the solution is simply to return real(f(x)) instead of f(x), that is, discard the complex part.
Please let us know if this fixes the issue.
Best,
Nicolas