uses MtxVec,
MtxExpr,
Math387;
procedure TForm84.Button2Click(Sender: TObject);
var am, bm, cm, cmRef: Matrix;
jit: TSmallMatrixMultiply;
a,b,c: TDoubleArray;
begin
jit := TSmallMatrixMultiply.Create;
try
am := [ [1 , 2], [2 , 3] ];
bm := [ [0.5, 1.5], [2.5, 3.5] ];
// Compute with TMtx
cmRef.Mul(am, bm);
//standard method optimized for large matrices
jit.Init(am, bm, cm, opNone, opNone, 1, 0);
// Option 1:
jit.Mul;
//reuse memory allocation by am, cm and bm
if not cmRef.Equal(cm)
then ERaise('Problem');
// Option 2:
jit.Mul(am, bm, cm);
// am, cm, bm can use different memory on each call, but a bit slower
if not cmRef.Equal(cm)
then ERaise('Problem');
// Option 3:
a := [1 , 2, 2 , 3];
b := [ 0.5, 1.5, 2.5, 3.5 ];
jit.Init(2, 2, 2, 2, mvDouble, opNone, opNone, 1, 0);
SetLength(c, 4);
//allocate storage to hold the result
jit.MulKernelDouble(jit.Jitter, a, b, c);
if not cmRef.Equal(cm)
then ERaise('Problem');
//alternative
finally
jit.Free;
end;
end;