Skip to content

Commit

Permalink
Minor update: Changed all PAnsiChars to TASMNativeUINT
Browse files Browse the repository at this point in the history
  • Loading branch information
mikerabat committed Nov 6, 2017
1 parent 4aa04a6 commit 1d602f6
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion ASMMatrixMultOperations.pas
Expand Up @@ -1298,7 +1298,7 @@ procedure ASMMtxMultTria2T1(dest : PDouble; LineWidthDest : TASMNativeInt; mt1 :
// write back result

// pDest^ := tmp[0];
// PDouble(PAnsiChar(pDest) + sizeof(double))^ := tmp[1];
// PDouble(TASMNativeUInt(pDest) + sizeof(double))^ := tmp[1];

movupd [edx], xmm0;

Expand Down
2 changes: 1 addition & 1 deletion ASMMatrixMultOperationsx64.pas
Expand Up @@ -1999,7 +1999,7 @@ procedure ASMMtxMultTria2T1(dest : PDouble; LineWidthDest : TASMNativeInt; mt1 :
// write back result

// pDest^ := tmp[0];
// PDouble(PAnsiChar(pDest) + sizeof(double))^ := tmp[1];
// PDouble(TASMNativeUInt(pDest) + sizeof(double))^ := tmp[1];

movupd [r13], xmm0;

Expand Down
16 changes: 8 additions & 8 deletions ASMMatrixOperations.pas
Expand Up @@ -1385,9 +1385,9 @@ procedure BlockedMatrixMultiplication(dest : PDouble; const destLineWidth : TASM
actBlk := mem;
if not Assigned(mem) then
GetMem(actBlk, BlockMultMemSize(blockSize));
multBlk := PDouble(PAnsiChar(actBlk) + blockByteSize);
transBlk := PDouble(PAnsiChar(actBlk) + 2*blockByteSize);
copyBlk := PDouble(PAnsiChar(actBlk) + 3*blockByteSize);
multBlk := PDouble(TASMNativeUInt(actBlk) + blockByteSize);
transBlk := PDouble(TASMNativeUInt(actBlk) + 2*blockByteSize);
copyBlk := PDouble(TASMNativeUInt(actBlk) + 3*blockByteSize);

blockLineSize := blockSize*sizeof(double);

Expand Down Expand Up @@ -1504,9 +1504,9 @@ procedure BlockedMatrixMultiplicationT1(dest : PDouble; const destLineWidth : TA
actBlk := mem;
if not Assigned(mem) then
GetMem(actBlk, BlockMultMemSize(blockSize));
multBlk := PDouble(PAnsiChar(actBlk) + blockByteSize);
transBlk1 := PDouble(PAnsiChar(actBlk) + 2*blockByteSize);
transBlk2 := PDouble(PAnsiChar(actBlk) + 3*blockByteSize);
multBlk := PDouble(TASMNativeUInt(actBlk) + blockByteSize);
transBlk1 := PDouble(TASMNativeUInt(actBlk) + 2*blockByteSize);
transBlk2 := PDouble(TASMNativeUInt(actBlk) + 3*blockByteSize);

blockLineSize := blockSize*sizeof(double);

Expand Down Expand Up @@ -1620,8 +1620,8 @@ procedure BlockedMatrixMultiplicationT2(dest : PDouble; const destLineWidth : TA
actBlk := mem;
if not Assigned(mem) then
GetMem(actBlk, BlockMultMemSize(blockSize));
multBlk := PDouble(PAnsiChar(actBlk) + blockByteSize);
copyBlk := PDouble(PAnsiChar(actBlk) + 2*blockByteSize);
multBlk := PDouble(TASMNativeUInt(actBlk) + blockByteSize);
copyBlk := PDouble(TASMNativeUInt(actBlk) + 2*blockByteSize);

blockLineSize := blockSize*sizeof(double);

Expand Down
2 changes: 1 addition & 1 deletion Eigensystems.pas
Expand Up @@ -399,7 +399,7 @@ function MatrixTridiagonalQLImplicitInPlace(Z : PDouble; const LineWidthZ : TASM
if iter = cMaxTridiagIter then
exit;

g := (PDouble(PAnsiChar(pDl) + LineWidthD)^ - pDl^)/(2*pEl^);
g := (PDouble(TASMNativeUInt(pDl) + TASMNativeUInt(LineWidthD))^ - pDl^)/(2*pEl^);
r := pythag(g, 1);
pD := D;
inc(PByte(pD), m*LineWidthD);
Expand Down
6 changes: 3 additions & 3 deletions LinAlgCholesky.pas
Expand Up @@ -297,7 +297,7 @@ function MatrixCholeskyInPlace(A : PDouble; const LineWidthA : TASMNativeInt; wi

for j := i to width - 1 do
begin
sum := PDouble(PAnsiChar(pA) + j*sizeof(double))^;
sum := PDouble(TASMNativeUInt(pA) + TASMNativeUInt(j*sizeof(double)))^;

pAj1 := pAj;
pA1 := pA;
Expand All @@ -320,13 +320,13 @@ function MatrixCholeskyInPlace(A : PDouble; const LineWidthA : TASMNativeInt; wi
if sum <= 0 then
exit;

PDouble(PAnsiChar(P) + i*LineWidthP)^ := sqrt(sum);
PDouble(TASMNativeUInt(P) + TASMNativeUInt(i*LineWidthP))^ := sqrt(sum);
end
else
begin
pAj1 := pAj;
inc(pAj1, i);
pAj1^ := sum/PDouble(PAnsiChar(P) + i*LineWidthP)^;
pAj1^ := sum/PDouble(TASMNativeUInt(P) + TASMNativeUInt(i*LineWidthP))^;
end;

inc(PByte(pAj), LineWidthA);
Expand Down
4 changes: 2 additions & 2 deletions LinAlgLU.pas
Expand Up @@ -338,7 +338,7 @@ procedure MatrixLUBackSubst(LUDecomp : PDouble; const LineWidthLU : TASMNativeIn

if ii >= 0 then
begin
pVal := PDouble(PAnsiChar(LUDecomp) + i*LineWidthLU);
pVal := PDouble(TASMNativeUInt(LUDecomp) + TASMNativeUInt(i*LineWidthLU));
inc(pVal, ii);
pB := B;
inc(PByte(pB), LineWidthB*ii);
Expand All @@ -362,7 +362,7 @@ procedure MatrixLUBackSubst(LUDecomp : PDouble; const LineWidthLU : TASMNativeIn

pB := B;
inc(PByte(pB), LineWidthB*(width - 1));
pVal := PDouble(PAnsiChar(LUDecomp) + (width - 1)*LineWidthLU);
pVal := PDouble(TASMNativeUInt(LUDecomp) + TASMNativeUInt((width - 1)*LineWidthLU));
inc(pVal, width - 1);
for i := width - 1 downto 0 do
begin
Expand Down
20 changes: 10 additions & 10 deletions LinAlgSVD.pas
Expand Up @@ -526,7 +526,7 @@ function MatrixSVDInPlace(A : PDouble; const LineWidthA : TASMNativeInt; width :
break;
end;

if abs(PDouble(PAnsiChar(W) + nm*LineWidthW)^) + anorm = anorm then
if abs(PDouble(TASMNativeUInt(W) + TASMNativeUInt(nm*LineWidthW))^) + anorm = anorm then
break;
end;

Expand All @@ -541,9 +541,9 @@ function MatrixSVDInPlace(A : PDouble; const LineWidthA : TASMNativeInt; width :
rv1[i] := c*rv1[i];
if abs(f) + anorm <> anorm then // check if the value is lower than the precission in contrast to anorm
begin
g := PDouble(PAnsiChar(W) + i*LineWidthW)^;
g := PDouble(TASMNativeUInt(W) + TASMNativeUInt(i*LineWidthW))^;
h := pythag(f, g);
PDouble(PAnsiChar(W) + i*LineWidthW)^ := h;
PDouble(TASMNativeUInt(W) + TASMNativeUInt(i*LineWidthW))^ := h;
h := 1/h;
c := g*h;
s := -f*h;
Expand All @@ -566,13 +566,13 @@ function MatrixSVDInPlace(A : PDouble; const LineWidthA : TASMNativeInt; width :
end;
end;

z := PDouble(PAnsiChar(W) + k*LineWidthW)^;
z := PDouble(TASMNativeUInt(W) + TASMNativeUInt(k*LineWidthW))^;
// convergence
if l = k then
begin
if z < 0 then
begin
PDouble(PAnsiChar(W) + k*LineWidthW)^ := -z;
PDouble(TASMNativeUInt(W) + TASMNativeUInt(k*LineWidthW))^ := -z;

pV := V;
inc(pV, k);
Expand All @@ -590,9 +590,9 @@ function MatrixSVDInPlace(A : PDouble; const LineWidthA : TASMNativeInt; width :
if its = cMaxNumSVDIter - 1 then
exit;

x := PDouble(PAnsiChar(W) + l*LineWidthW)^;
x := PDouble(TASMNativeUInt(W) + TASMNativeUInt(l*LineWidthW))^;
nm := k - 1;
y := PDouble(PAnsiChar(W) + nm*LineWidthW)^;
y := PDouble(TASMNativeUInt(W) + TASMNativeUInt(nm*LineWidthW))^;
g := rv1[nm];
h := rv1[k];
f := ((y - z)*(y + z) + (g - h)*(g + h))/(2*h*y);
Expand All @@ -609,7 +609,7 @@ function MatrixSVDInPlace(A : PDouble; const LineWidthA : TASMNativeInt; width :
begin
i := j + 1;
g := rv1[i];
y := PDouble(PAnsiChar(W) + i*LineWidthW)^;
y := PDouble(TASMNativeUInt(W) + TASMNativeUInt(i*LineWidthW))^;
h := s*g;
g := c*g;
z := pythag(f, h);
Expand Down Expand Up @@ -637,7 +637,7 @@ function MatrixSVDInPlace(A : PDouble; const LineWidthA : TASMNativeInt; width :
end;

z := pythag(f, h);
PDouble(PAnsiChar(W) + j*LineWidthW)^ := z;
PDouble(TASMNativeUInt(W) + TASMNativeUInt(j*LineWidthW))^ := z;
// rotation can be arbitrary if z = 0
if z <> 0 then
begin
Expand Down Expand Up @@ -666,7 +666,7 @@ function MatrixSVDInPlace(A : PDouble; const LineWidthA : TASMNativeInt; width :

rv1[l] := 0;
rv1[k] := f;
PDouble(PAnsiChar(W) + k*LineWidthW)^ := x;
PDouble(TASMNativeUInt(W) + TASMNativeUInt(k*LineWidthW))^ := x;
end;
end;

Expand Down
28 changes: 14 additions & 14 deletions LinearAlgebraicEquations.pas
Expand Up @@ -103,7 +103,7 @@ function MatrixGaussJordanInPlace(A : PDouble; const LineWidthA : TASMNativeInt;
begin
if ipiv[k] = 0 then
begin
pVal1 := PDouble(PAnsiChar(A) + j*LineWidthA);
pVal1 := PDouble(TASMNativeUInt(A) + TASMNativeUInt(j*LineWidthA));
inc(pVal1, k);

if abs(pVal1^) >= big then
Expand All @@ -129,8 +129,8 @@ function MatrixGaussJordanInPlace(A : PDouble; const LineWidthA : TASMNativeInt;

if irow <> icol then
begin
pVal1 := PDouble(PAnsiChar(A) + irow*LineWidthA);
pVal2 := PDouble(PAnsiChar(A) + icol*LineWidthA);
pVal1 := PDouble(TASMNativeUInt(A) + TASMNativeUInt(irow*LineWidthA));
pVal2 := PDouble(TASMNativeUInt(A) + TASMNativeUInt(icol*LineWidthA));
for l := 0 to width - 1 do
begin

Expand All @@ -139,8 +139,8 @@ function MatrixGaussJordanInPlace(A : PDouble; const LineWidthA : TASMNativeInt;
inc(pVal2);
end;

pVal1 := PDouble(PAnsiChar(B) + irow*LineWidthB);
pVal2 := PDouble(PAnsiChar(B) + icol*LineWidthB);
pVal1 := PDouble(TASMNativeUInt(B) + TASMNativeUInt(irow*LineWidthB));
pVal2 := PDouble(TASMNativeUInt(B) + TASMNativeUInt(icol*LineWidthB));
for l := 0 to m - 1 do
begin
DoubleSwap(pVal1^, pVal2^);
Expand All @@ -153,7 +153,7 @@ function MatrixGaussJordanInPlace(A : PDouble; const LineWidthA : TASMNativeInt;
indxr[i] := irow;
indxc[i] := icol;

pVal1 := PDouble(PAnsiChar(A) + icol*LineWidthA);
pVal1 := PDouble(TASMNativeUInt(A) + TASMNativeUInt(icol*LineWidthA));
inc(pVal1, icol);

if abs(pVal1^) < epsilon then
Expand All @@ -165,14 +165,14 @@ function MatrixGaussJordanInPlace(A : PDouble; const LineWidthA : TASMNativeInt;
pivinv := 1/pVal1^;

pVal1^ := 1;
pVal1 := PDouble(PAnsiChar(A) + icol*LineWidthA);
pVal1 := PDouble(TASMNativeUInt(A) + TASMNativeUInt(icol*LineWidthA));
for l := 0 to width - 1 do
begin
pVal1^ := pVal1^*pivinv;
inc(pVal1);
end;

pVal1 := PDouble(PAnsiChar(B) + icol*LineWidthB);
pVal1 := PDouble(TASMNativeUInt(B) + TASMNativeUInt(icol*LineWidthB));
for l := 0 to m - 1 do
begin
pVal1^ := Pivinv*pVal1^;
Expand All @@ -183,22 +183,22 @@ function MatrixGaussJordanInPlace(A : PDouble; const LineWidthA : TASMNativeInt;
begin
if ll <> icol then
begin
pVal1 := PDouble(PAnsiChar(A) + ll*LineWidthA);
pVal1 := PDouble(TASMNativeUInt(A) + TASMNativeUInt(ll*LineWidthA));
inc(pVal1, icol);
dum := pVal1^;
pVal1^ := 0;

pVal1 := PDouble(PAnsiChar(A) + ll*LineWidthA);
pVal2 := PDouble(PAnsiChar(A) + icol*LineWidthA);
pVal1 := PDouble(TASMNativeUInt(A) + TASMNativeUInt(ll*LineWidthA));
pVal2 := PDouble(TASMNativeUInt(A) + TASMNativeUInt(icol*LineWidthA));
for l := 0 to width - 1 do
begin
pVal1^ := pVal1^ - pVal2^*dum;
inc(pVal1);
inc(pVal2);
end;

pVal1 := PDouble(PAnsiChar(B) + ll*LineWidthB);
pVal2 := PDouble(PAnsiChar(B) + icol*LineWidthB);
pVal1 := PDouble(TASMNativeUInt(B) + TASMNativeUInt(ll*LineWidthB));
pVal2 := PDouble(TASMNativeUInt(B) + TASMNativeUInt(icol*LineWidthB));
for l := 0 to m - 1 do
begin
pVal1^ := pVal1^ - pVal2^*dum;
Expand All @@ -218,7 +218,7 @@ function MatrixGaussJordanInPlace(A : PDouble; const LineWidthA : TASMNativeInt;
begin
for k := 0 to width - 1 do
begin
pVal1 := PDouble(PAnsiChar(A) + k*LineWidthA);
pVal1 := PDouble(TASMNativeUInt(A) + TASMNativeUInt(k*LineWidthA));
pVal2 := pVal1;
inc(pval1, indxr[l]);
inc(pval2, indxc[l]);
Expand Down
8 changes: 4 additions & 4 deletions SimpleMatrixOperations.pas
Expand Up @@ -2052,8 +2052,8 @@ procedure GenericBlockedMatrixMultiplicationT1(dest : PDouble; const destLineWid
actBlk := mem;
if not Assigned(mem) then
GetMem(actBlk, BlockMultMemSize(blockSize));
multBlk := PDouble(PAnsiChar(actBlk) + blockByteSize);
transBlk1 := PDouble(PAnsiChar(actBlk) + 2*blockByteSize);
multBlk := PDouble(TASMNativeUInt(actBlk) + blockByteSize);
transBlk1 := PDouble(TASMNativeUInt(actBlk) + 2*blockByteSize);

blockLineSize := blockSize*sizeof(double);

Expand Down Expand Up @@ -2152,7 +2152,7 @@ procedure GenericBlockedMatrixMultiplicationT2(dest : PDouble; const destLineWid
actBlk := mem;
if not Assigned(mem) then
GetMem(actBlk, BlockMultMemSize(blockSize));
multBlk := PDouble(PAnsiChar(actBlk) + blockByteSize);
multBlk := PDouble(TASMNativeUInt(actBlk) + blockByteSize);

blockLineSize := blockSize*sizeof(double);

Expand Down Expand Up @@ -2375,7 +2375,7 @@ procedure GenericMtxMultTria2T1_2(dest : PDouble; LineWidthDest : TASMNativeInt;
end;

pDest^ := tmp[0];
PDouble(PAnsiChar(pDest) + sizeof(double))^ := tmp[1];
PDouble(TASMNativeUInt(pDest) + sizeof(double))^ := tmp[1];
inc(pDest, 2);
inc(pMT2, 2);
end;
Expand Down

0 comments on commit 1d602f6

Please sign in to comment.