Algorithm 9.2 shows the dependencies of the various subroutines on each other. We have grouped the routines together based on four loosely defined roles:

*Objective function.*These are the routines which implement the objective function and its derivatives. This group is the only group that a user interested only in the basic functionality need ever modify to adapt the template. Functions in this group are used by functions in the geometrized objective function and high-level algorithm groups.*Geometric implementation.*These routines implement the geometric features of the Stiefel manifold. This includes the projection of unconstrained vectors onto the constraint (i.e., tangent) space (`tangent`

), line movement (`move`

), and the connection term used for covariant differentiation (`connection`

). These routines are independent of the objective function group, but are essential to the geometrized objective function group.*Geometrized objective function.*This group uses the routines of the geometric implementation to project the differential and second differential of onto the constraint (i.e., tangent) surface producing the geometrically covariant gradient (`grad`

) and Hessian (`dgrad`

). Additionally, two routines for inverting the covariant Hessian (`invdgrad_CG`

and`invdgrad_MINRES`

) are located here. This group provides the raw tools out of which one builds implementations in the high-level algorithm group. Lastly, functions which detect (`partition`

) and remove (`nosym`

) block-diagonal orthogonal symmetries are found in the group.*High-level algorithm.*This group implements the constrained versions of various optimization algorithms. It is here that search directions are selected, line minimizations are performed (using`Fline`

,`dFline`

, and`gradline`

), and convergence criteria are defined.

Lastly, every function reads from a global `SGParameters`

structure whose
fields contain information about the manifold and the computation. In
our examples we have used a separate global `FParameters`

to store
information related to the computation of . The fields of
`SGParameters`

are set in `sg_min`

.