📄 ap.pas
字号:
end;
function C_Sub(const Z1 : Complex; const Z2 : Complex):Complex;
begin
Result.X := Z1.X-Z2.X;
Result.Y := Z1.Y-Z2.Y;
end;
function C_SubR(const Z1 : Complex; const R : Double):Complex;
begin
Result.X := Z1.X-R;
Result.Y := Z1.Y;
end;
function C_RSub(const R : Double; const Z1 : Complex):Complex;
begin
Result.X := R-Z1.X;
Result.Y := -Z1.Y;
end;
function C_Div(const Z1 : Complex; const Z2 : Complex):Complex;
var
A : Double;
B : Double;
C : Double;
D : Double;
E : Double;
F : Double;
begin
A := Z1.X;
B := Z1.Y;
C := Z2.X;
D := Z2.Y;
if AbsReal(D)<AbsReal(C) then
begin
E := D/C;
F := C+D*E;
Result.X := (A+B*E)/F;
Result.Y := (B-A*E)/F;
end
else
begin
E := C/D;
F := D+C*E;
Result.X := (B+A*E)/F;
Result.Y := (-A+B*E)/F;
end;
end;
function C_DivR(const Z1 : Complex; const R : Double):Complex;
begin
Result.X := Z1.X/R;
Result.Y := Z1.Y/R;
end;
function C_RDiv(const R : Double; const Z2 : Complex):Complex;
var
A : Double;
C : Double;
D : Double;
E : Double;
F : Double;
begin
A := R;
C := Z2.X;
D := Z2.Y;
if AbsReal(D)<AbsReal(C) then
begin
E := D/C;
F := C+D*E;
Result.X := A/F;
Result.Y := -A*E/F;
end
else
begin
E := C/D;
F := D+C*E;
Result.X := A*E/F;
Result.Y := -A/F;
end;
end;
function C_Equal(const Z1 : Complex; const Z2 : Complex):Boolean;
begin
Result := (Z1.X=Z2.X) and (Z1.Y=Z2.Y);
end;
function C_NotEqual(const Z1 : Complex; const Z2 : Complex):Boolean;
begin
Result := (Z1.X<>Z2.X) or (Z1.Y<>Z2.Y);
end;
function C_EqualR(const Z1 : Complex; const R : Double):Boolean;
begin
Result := (Z1.X=R) and (Z1.Y=0);
end;
function C_NotEqualR(const Z1 : Complex; const R : Double):Boolean;
begin
Result := (Z1.X<>R) or (Z1.Y<>0);
end;
/////////////////////////////////////////////////////////////////////////
// AP BLAS generic interface
/////////////////////////////////////////////////////////////////////////
{procedure UseAPBLAS(Flag: Boolean);
begin
UseAPBLASFlag:=Flag;
end;}
function APVDotProduct(
V1: PDouble; I11, I12: Integer;
V2: PDouble; I21, I22: Integer):Double;
var
I, C: LongInt;
begin
Assert(I12-I11=I22-I21, 'APVDotProduct: arrays of different size!');
Inc(V1, I11);
Inc(V2, I21);
//
// Generic pascal code
//
C:=I12-I11;
Result:=0;
for I:=0 to C do
begin
Result:=Result+V1^*V2^;
Inc(V1);
Inc(V2);
end;
end;
procedure APVMove(
VDst: PDouble; I11, I12: Integer;
VSrc: PDouble; I21, I22: Integer);overload;
var
I, C: LongInt;
begin
Assert(I12-I11=I22-I21, 'APVMove: arrays of different size!');
Inc(VDst, I11);
Inc(VSrc, I21);
//
// Generic pascal code
//
C:=I12-I11;
for I:=0 to C do
begin
VDst^:=VSrc^;
Inc(VDst);
Inc(VSrc);
end;
end;
procedure APVMove(
VDst: PDouble; I11, I12: Integer;
VSrc: PDouble; I21, I22: Integer;
S: Double);overload;
var
I, C: LongInt;
begin
Assert(I12-I11=I22-I21, 'APVMove: arrays of different size!');
Inc(VDst, I11);
Inc(VSrc, I21);
//
// Generic pascal code
//
C:=I12-I11;
for I:=0 to C do
begin
VDst^:=S*VSrc^;
Inc(VDst);
Inc(VSrc);
end;
end;
procedure APVMoveNeg(
VDst: PDouble; I11, I12: Integer;
VSrc: PDouble; I21, I22: Integer);
var
I, C: LongInt;
begin
Assert(I12-I11=I22-I21, 'APVMoveNeg: arrays of different size!');
Inc(VDst, I11);
Inc(VSrc, I21);
//
// Generic pascal code
//
C:=I12-I11;
for I:=0 to C do
begin
VDst^:=-VSrc^;
Inc(VDst);
Inc(VSrc);
end;
end;
procedure APVAdd(
VDst: PDouble; I11, I12: Integer;
VSrc: PDouble; I21, I22: Integer);overload;
var
I, C: LongInt;
begin
Assert(I12-I11=I22-I21, 'APVAdd: arrays of different size!');
Inc(VDst, I11);
Inc(VSrc, I21);
//
// Generic pascal code
//
C:=I12-I11;
for I:=0 to C do
begin
VDst^:=VDst^+VSrc^;
Inc(VDst);
Inc(VSrc);
end;
end;
procedure APVAdd(
VDst: PDouble; I11, I12: Integer;
VSrc: PDouble; I21, I22: Integer;
S: Real);overload;
var
I, C: LongInt;
begin
Assert(I12-I11=I22-I21, 'APVAdd: arrays of different size!');
Inc(VDst, I11);
Inc(VSrc, I21);
//
// Generic pascal code
//
C:=I12-I11;
for I:=0 to C do
begin
VDst^:=VDst^+S*VSrc^;
Inc(VDst);
Inc(VSrc);
end;
end;
procedure APVSub(
VDst: PDouble; I11, I12: Integer;
VSrc: PDouble; I21, I22: Integer);overload;
var
I, C: LongInt;
begin
Assert(I12-I11=I22-I21, 'APVSub arrays of different size!');
Inc(VDst, I11);
Inc(VSrc, I21);
//
// Generic pascal code
//
C:=I12-I11;
for I:=0 to C do
begin
VDst^:=VDst^-VSrc^;
Inc(VDst);
Inc(VSrc);
end;
end;
procedure APVSub(
VDst: PDouble; I11, I12: Integer;
VSrc: PDouble; I21, I22: Integer;
S: Real);overload;
begin
Assert(I12-I11=I22-I21, 'APVSub: arrays of different size!');
APVAdd(VDst, I11, I12, VSrc, I21, I22, -S);
end;
procedure APVMul(
VOp: PDouble; I1, I2: Integer;
S: Real);
var
I, C: LongInt;
begin
Inc(VOp, I1);
C:=I2-I1;
for I:=0 to C do
begin
VOp^:=S*VOp^;
Inc(VOp);
end;
end;
(*
{$IFNDEF NOABLAS}
//
// ABLAS initialization/finalization code
//
var
ABLAS: THandle;
initialization
ABLAS:=LoadLibrary('ablas.dll');
if ABLAS=0 then
begin
//
// no ablas.dll
//
@ASMDotProduct1:=nil;
@ASMMove1:=nil;
@ASMMoveS1:=nil;
@ASMMoveNeg1:=nil;
@ASMAdd1:=nil;
@ASMAddS1:=nil;
@ASMSub1:=nil;
end
else
begin
@ASMDotProduct1:=GetProcAddress(ABLAS, 'ASMDotProduct1');
@ASMMove1:=GetProcAddress(ABLAS, 'ASMMove1');
@ASMMoveS1:=GetProcAddress(ABLAS, 'ASMMoveS1');
@ASMMoveNeg1:=GetProcAddress(ABLAS, 'ASMMoveNeg1');
@ASMAdd1:=GetProcAddress(ABLAS, 'ASMAdd1');
@ASMAddS1:=GetProcAddress(ABLAS, 'ASMAddS1');
@ASMSub1:=GetProcAddress(ABLAS, 'ASMSub1');
end;
finalization
if ABLAS<>0 then
begin
@ASMDotProduct1:=nil;
@ASMMove1:=nil;
@ASMMoveS1:=nil;
@ASMMoveNeg1:=nil;
@ASMAdd1:=nil;
@ASMAddS1:=nil;
@ASMSub1:=nil;
FreeLibrary(ABLAS);
end;
{$ENDIF}
*)
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -