The minimization problem can be formulated and solved as a convex Linear Semidefinite Programming problem, for which many solvers are available, such as Mosek, and the freely available SeDuMi and SDPT3, among many others.
Minimize $x^TB^{-1}x$ subject to $B \succ0$, Diag(B) = 1
which can be reformulated via Schir Complement as a standard Linear Semidefinite Programming (SDP) problem:
Minimize $t$ subject to {B x;x' t] $\succeq 0$, Diag(B) = 1, where ;
spearates the block rows of the matrix, as in MATLAB.
This can be formulated (and solved) "as is" in CVX, or you can let CVX handle the above reformulation internally using its matrix_frac
function:
cvx_begin
variable B(n,n)
minimize(matrix_frac(x,B))
diag(B) == 1
cvx_end
help matrix_frac
matrix_frac Matrix fractional function.
matrix_frac(x,Y), where Y is a square matrix and x is a vector of the
same size, computes x'*(inv(Y)*x) if Y is Hermitian positive definite, and
+Inf otherwise.
An error results if Y is not a square matrix, or the size of
the vector x does not match the size of matrix Y.
Disciplined convex programming information:
matrix_frac is convex and nonmonotonic (at least with respect to
elementwise comparison), so its argument must be affine.
In YALMIP (the "as is" formulation):
B = sdpvar(n,n); % this is symmetric by YALMIP default
t = sdpvar;
optimize([[B x;x' t]>= 0, diag(B)==1],t) % 1st argument is constraints, 2nd is objective
The maximization problem is a difficult to solve non-convex (actually, concave) Nonlinear Semidefinite Programming (SDP) problem. It can in principle (but might fail) be solved to local optimality with solvers such as PENNON or PENLAB. Alternatively, it could be formulated, at the risk of introducing some spurious stationary points, as
Maximize $x'Hx$ with respect to $H$, $B$, and $C$ subject to $BH = I_{n,n}$, $B = CC^T$, diag(B) = 1, and can be solved using a "standard" (i.e., not an SDP solver) global nonlinear optimization solver, but is likely going to be very difficult to solve unless $n$ is rather small.