Here’s a complicated bit of matrix math that I wrote as part of OOOT to calculate the BroydenFletcherGoldfarbShanno approach to approximating the Newton approach. This is shown to illustrate some of the basic add and multiply functions of StarMath.

var diffX =
x.subtract(xLast);


var diffGradF =
gradf.subtract(gradFLast);


T =
StarMath.multiplyVectorsIntoAMatrix(diffX, diffGradF);
T =
T.divide(diffX.multiplyDot(diffGradF));


u =
StarMath.multiplyVectorsIntoAMatrix(diffX, diffX);
u =
u.multiply(diffX.multiplyDot(diffGradF));


IMinusT =
StarMath.makeIdentity(T.GetLength(0)).subtract(T);
invH =
IMinusT.multiply(invHLast.multiply(IMinusT)).add(u);


dir =
invH.multiply(gradf);
