direct

Contents

direct#

torchsim.direct(linearization, rhs, damping, reference)[source]#

Solve every voxel’s linearized system outright, all of them at once.

Where nothing has mixed the voxels together the problem is a stack of small independent least-squares systems, one per voxel, and a batched factorization over the whole stack is the Levenberg-Marquardt step itself – not a general linear solver, which is why this is here and a conjugate gradient is not.

The damping enters as extra rows rather than as a ridge on the normal equations:

[ J^T ] d = [ rhs ] [ sqrt(a) I ] [ sqrt(a) z ]

which is the same minimizer without squaring the condition number, and which has full column rank for any positive damping – so there is no singular case to detect and none to work around.

A complex contrast is two real measurements, because what is minimized is the squared modulus.

Parameters:
  • linearization (Linearization) – The derivative, which must carry its blocks.

  • rhs (torch.Tensor) – (voxels, contrasts), y - F(x).

  • damping (torch.Tensor) – (voxels, 1) or one number.

  • reference (torch.Tensor) – (voxels, channels), what the damping pulls towards.

Returns:

(voxels, channels).

Return type:

torch.Tensor

Raises:

ValueError – If the linearization carries no blocks, which is what an encoding operator in front of the model leaves.