LazStats: Remove Cancel btn from FactorUnit, improved usability of arrow btns, write report to StringList, not to OutputFrm directly. Add pdf to help file. Add Exchange() procedure to Utils.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7364 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
c222b83196
commit
e67df71726
Binary file not shown.
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
object CannonFrm: TCannonFrm
|
||||
Left = 261
|
||||
Left = 350
|
||||
Height = 379
|
||||
Top = 157
|
||||
Top = 137
|
||||
Width = 401
|
||||
AutoSize = True
|
||||
Caption = 'Canonical Correlation Analysis'
|
||||
|
@ -13,83 +13,65 @@ object FactorFrm: TFactorFrm
|
||||
Position = poMainFormCenter
|
||||
LCLVersion = '2.1.0.0'
|
||||
object ResetBtn: TButton
|
||||
AnchorSideRight.Control = CancelBtn
|
||||
AnchorSideRight.Control = ComputeBtn
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 326
|
||||
Left = 418
|
||||
Height = 25
|
||||
Top = 489
|
||||
Width = 54
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 12
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 12
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Reset'
|
||||
OnClick = ResetBtnClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object CancelBtn: TButton
|
||||
AnchorSideRight.Control = ComputeBtn
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 392
|
||||
Height = 25
|
||||
Top = 489
|
||||
Width = 62
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 12
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 12
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Cancel'
|
||||
ModalResult = 2
|
||||
TabOrder = 3
|
||||
end
|
||||
object ComputeBtn: TButton
|
||||
AnchorSideRight.Control = ReturnBtn
|
||||
AnchorSideRight.Control = CloseBtn
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 466
|
||||
Left = 480
|
||||
Height = 25
|
||||
Top = 489
|
||||
Width = 76
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 12
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 12
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Compute'
|
||||
OnClick = ComputeBtnClick
|
||||
TabOrder = 4
|
||||
TabOrder = 3
|
||||
end
|
||||
object ReturnBtn: TButton
|
||||
object CloseBtn: TButton
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = Owner
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 554
|
||||
Left = 564
|
||||
Height = 25
|
||||
Top = 489
|
||||
Width = 61
|
||||
Width = 55
|
||||
Anchors = [akRight, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 12
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 8
|
||||
BorderSpacing.Right = 12
|
||||
BorderSpacing.Right = 8
|
||||
BorderSpacing.Bottom = 8
|
||||
Caption = 'Return'
|
||||
ModalResult = 1
|
||||
TabOrder = 5
|
||||
Caption = 'Close'
|
||||
ModalResult = 11
|
||||
TabOrder = 4
|
||||
end
|
||||
object Bevel2: TBevel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = ReturnBtn
|
||||
AnchorSideBottom.Control = CloseBtn
|
||||
Left = 0
|
||||
Height = 8
|
||||
Top = 473
|
||||
@ -293,7 +275,7 @@ object FactorFrm: TFactorFrm
|
||||
BorderSpacing.Top = 4
|
||||
BorderSpacing.Right = 8
|
||||
TabOrder = 2
|
||||
Text = 'Edit1'
|
||||
Text = 'MaxItersEdit'
|
||||
end
|
||||
object MaxFactorsEdit: TEdit
|
||||
AnchorSideLeft.Control = Label5
|
||||
@ -310,7 +292,7 @@ object FactorFrm: TFactorFrm
|
||||
BorderSpacing.Top = 4
|
||||
BorderSpacing.Right = 8
|
||||
TabOrder = 3
|
||||
Text = 'Edit1'
|
||||
Text = 'MaxFactorsEdit'
|
||||
end
|
||||
end
|
||||
object Panel3: TPanel
|
||||
@ -383,6 +365,7 @@ object FactorFrm: TFactorFrm
|
||||
BorderSpacing.Right = 8
|
||||
ItemHeight = 0
|
||||
MultiSelect = True
|
||||
OnSelectionChange = VarListSelectionChange
|
||||
TabOrder = 0
|
||||
end
|
||||
object InBtn: TBitBtn
|
||||
@ -417,6 +400,8 @@ object FactorFrm: TFactorFrm
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 2
|
||||
ItemHeight = 0
|
||||
MultiSelect = True
|
||||
OnSelectionChange = VarListSelectionChange
|
||||
TabOrder = 3
|
||||
end
|
||||
object OutBtn: TBitBtn
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,7 +9,7 @@ uses
|
||||
StdCtrls, ExtCtrls, Clipbrd,
|
||||
Globals, OptionsUnit, DictionaryUnit, OutputUnit;
|
||||
|
||||
Function GoodRecord(Row, NoVars : integer; VAR GridPos : IntDyneVec): boolean;
|
||||
Function GoodRecord(Row, NoVars: integer; const GridPos: IntDyneVec): boolean;
|
||||
procedure FormatCell(Col, Row : integer);
|
||||
procedure FormatGrid;
|
||||
function IsNumeric(s : string) : boolean;
|
||||
@ -31,9 +31,9 @@ procedure OpenTabFile;
|
||||
procedure SaveTabFile;
|
||||
function ValidValue(row, col : integer) : boolean;
|
||||
function IsFiltered(GridRow : integer) : boolean;
|
||||
procedure MatRead(var a: DblDyneMat; out NoRows, NoCols: integer;
|
||||
var Means, StdDevs: DblDyneVec; out NCases: integer;
|
||||
var RowLabels, ColLabels: StrDyneVec; const filename: string);
|
||||
procedure MatRead(const a: DblDyneMat; out NoRows, NoCols: integer;
|
||||
const Means, StdDevs: DblDyneVec; out NCases: integer;
|
||||
const RowLabels, ColLabels: StrDyneVec; const filename: string);
|
||||
procedure MATSAVE(VAR a : DblDyneMat;
|
||||
norows : integer;
|
||||
nocols : integer;
|
||||
@ -62,19 +62,18 @@ implementation
|
||||
|
||||
uses MainUnit;
|
||||
|
||||
Function GoodRecord(Row, NoVars : integer; VAR GridPos : IntDyneVec): boolean;
|
||||
Function GoodRecord(Row, NoVars: integer; const GridPos: IntDyneVec): boolean;
|
||||
var
|
||||
i, j : integer;
|
||||
isgood : boolean;
|
||||
|
||||
i, j: integer;
|
||||
isgood: boolean;
|
||||
begin
|
||||
isgood := true;
|
||||
for i := 1 to NoVars do
|
||||
begin
|
||||
j := GridPos[i-1];
|
||||
if NOT ValidValue(Row,j) then isgood := false;
|
||||
end;
|
||||
Result := isgood;
|
||||
Result := true;
|
||||
for i := 1 to NoVars do
|
||||
begin
|
||||
j := GridPos[i-1];
|
||||
if not ValidValue(Row,j) then
|
||||
Result := false;
|
||||
end;
|
||||
end;
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@ -826,11 +825,11 @@ begin
|
||||
end;
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
procedure MATREAD(var a: DblDyneMat;
|
||||
procedure MATREAD(const a: DblDyneMat;
|
||||
out NoRows, NoCols: integer;
|
||||
var means, stddevs: DblDyneVec;
|
||||
const means, stddevs: DblDyneVec;
|
||||
out NCases: integer;
|
||||
var RowLabels, ColLabels: StrDyneVec;
|
||||
const RowLabels, ColLabels: StrDyneVec;
|
||||
const filename: string);
|
||||
var i, j : integer;
|
||||
mat_file : TextFile;
|
||||
|
@ -34,8 +34,8 @@ procedure Correlations(NoSelected : integer;
|
||||
VAR errorcode : boolean;
|
||||
VAR Ngood : integer);
|
||||
|
||||
procedure MatAxB(var A, B, C: DblDyneMat; BRows, BCols, CRows, CCols: Integer;
|
||||
var ErrorCode: boolean);
|
||||
procedure MatAxB(const A, B, C: DblDyneMat; BRows, BCols, CRows, CCols: Integer;
|
||||
out ErrorCode: boolean);
|
||||
|
||||
procedure MatTrn(var A, B: DblDyneMat; BRows, BCols: Integer);
|
||||
|
||||
@ -175,21 +175,17 @@ function SCPF(VAR x,y : DblDyneMat; kx,ky,n,nd : integer) : double;
|
||||
|
||||
procedure Mat_Print(var xmat: DblDyneMat; Rows,Cols: Integer; var Title: String;
|
||||
var RowLabels, ColLabels: StrDyneVec; NCases: Integer);
|
||||
procedure MatPrint(var xmat: DblDyneMat; Rows,Cols: Integer; var Title: String;
|
||||
var RowLabels, ColLabels: StrDyneVec; NCases: Integer; AReport: TStrings);
|
||||
procedure MatPrint(const xmat: DblDyneMat; Rows,Cols: Integer; const Title: String;
|
||||
const RowLabels, ColLabels: StrDyneVec; NCases: Integer; AReport: TStrings);
|
||||
|
||||
procedure DynVectorPrint(var AVector: DblDyneVec; NoVars: integer;
|
||||
Title: string; var Labels: StrDyneVec; NCases: integer); overload;
|
||||
procedure DynVectorPrint(var AVector: DblDyneVec; NoVars: integer;
|
||||
Title: string; var Labels: StrDyneVec; NCases: integer; AReport: TStrings); overload;
|
||||
|
||||
procedure scatplot(var x : DblDyneVec;
|
||||
var y : DblDyneVec;
|
||||
nocases : integer;
|
||||
titlestr : string;
|
||||
x_axis, y_axis : string;
|
||||
x_min, x_max, y_min, y_max : double;
|
||||
VAR VarLabels : StrDyneVec);
|
||||
procedure scatplot(const x, y: DblDyneVec; NoCases: integer;
|
||||
const TitleStr, x_axis, y_axis: string; x_min, x_max, y_min, y_max: double;
|
||||
const VarLabels: StrDyneVec; AReport: TStrings);
|
||||
|
||||
procedure DynIntMatPrint(Mat: IntDyneMat; Rows, Cols: integer; YTitle: string;
|
||||
RowLabels, ColLabels: StrDyneVec; Title: string); overload;
|
||||
@ -203,7 +199,7 @@ procedure matinv(a, vtimesw, v, w: DblDyneMat; n: integer);
|
||||
implementation
|
||||
|
||||
uses
|
||||
StrUtils;
|
||||
StrUtils, Utils;
|
||||
|
||||
procedure GridDotProd(col1, col2: integer; out Product: double; var Ngood: integer);
|
||||
// Get the cross-product of two vectors
|
||||
@ -416,8 +412,8 @@ end;
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
// Product of matrix b times c with results returned in a
|
||||
procedure MatAxB(var A, B, C: DblDyneMat; BRows, BCols, CRows, CCols: Integer;
|
||||
var ErrorCode: boolean);
|
||||
procedure MatAxB(const A, B, C: DblDyneMat; BRows, BCols, CRows, CCols: Integer;
|
||||
out ErrorCode: boolean);
|
||||
var
|
||||
i, j, k: integer;
|
||||
begin
|
||||
@ -1846,8 +1842,8 @@ begin
|
||||
MatPrint(xmat, Rows, Cols, Title, RowLabels, ColLabels, NCases, OutputFrm.RichEdit.Lines);
|
||||
end;
|
||||
|
||||
procedure MatPrint(var xmat: DblDyneMat; Rows, Cols: integer; var Title: string;
|
||||
var RowLabels, ColLabels: StrDyneVec; NCases: integer; AReport: TStrings);
|
||||
procedure MatPrint(const xmat: DblDyneMat; Rows, Cols: integer; const Title: string;
|
||||
const RowLabels, ColLabels: StrDyneVec; NCases: integer; AReport: TStrings);
|
||||
var
|
||||
i, j, first, last, nflds: integer;
|
||||
done: boolean;
|
||||
@ -1950,27 +1946,20 @@ begin
|
||||
end;
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
procedure scatplot(var x : DblDyneVec;
|
||||
var y : DblDyneVec;
|
||||
nocases : integer;
|
||||
titlestr : string;
|
||||
x_axis, y_axis : string;
|
||||
x_min, x_max, y_min, y_max : double;
|
||||
VAR VarLabels : StrDyneVec);
|
||||
|
||||
procedure scatplot(const x, y: DblDyneVec; NoCases: integer;
|
||||
const TitleStr, x_axis, y_axis: string; x_min, x_max, y_min, y_max: double;
|
||||
const VarLabels: StrDyneVec; AReport: TStrings);
|
||||
var
|
||||
i, j, l, row, xslot : integer;
|
||||
//xdelta: Double;
|
||||
maxy: double;
|
||||
incrementx, incrementy, rangex, rangey, swap : double;
|
||||
plotstring : array[0..51,0..61] of char;
|
||||
//ymed, xmed : double;
|
||||
height : integer;
|
||||
overlap : boolean;
|
||||
valuestring : string[2];
|
||||
howlong : integer;
|
||||
outline : string;
|
||||
Labels : StrDyneVec;
|
||||
i, j, l, row, xslot : integer;
|
||||
maxy: double;
|
||||
incrementx, incrementy, rangex, rangey, swap : double;
|
||||
plotstring : array[0..51,0..61] of char;
|
||||
height : integer;
|
||||
overlap : boolean;
|
||||
valuestring : string[2];
|
||||
howlong : integer;
|
||||
outline : string;
|
||||
Labels : StrDyneVec;
|
||||
begin
|
||||
Assert(OutputFrm <> nil);
|
||||
|
||||
@ -1986,28 +1975,37 @@ begin
|
||||
// ymed := rangey / 2;
|
||||
|
||||
{ sort in descending order }
|
||||
for i := 1 to (nocases - 1) do
|
||||
for i := 1 to (NoCases - 1) do
|
||||
begin
|
||||
for j := (i + 1) to nocases do
|
||||
for j := (i + 1) to NoCases do
|
||||
begin
|
||||
if y[i-1] < y[j-1] then
|
||||
begin
|
||||
Exchange(y[i-1], y[j-1]);
|
||||
{
|
||||
swap := y[i-1];
|
||||
y[i-1] := y[j-1];
|
||||
y[j-1] := swap;
|
||||
}
|
||||
Exchange(x[i-1], x[j-1]);
|
||||
{
|
||||
swap := x[i-1];
|
||||
x[i-1] := x[j-1];
|
||||
x[j-1] := swap;
|
||||
}
|
||||
Exchange(Labels[i-1], Labels[j-1]);
|
||||
{
|
||||
outline := Labels[i-1];
|
||||
Labels[i-1] := Labels[j-1];
|
||||
Labels[j-1] := outline;
|
||||
}
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
outline := ' SCATTERPLOT - ' + titlestr;
|
||||
OutputFrm.RichEdit.Lines.Add(outline);
|
||||
OutputFrm.RichEdit.Lines.Add('');
|
||||
OutputFrm.RichEdit.Lines.Add(y_axis);
|
||||
|
||||
AReport.Add(' SCATTERPLOT - ' + TitleStr);
|
||||
AReport.Add('');
|
||||
AReport.Add(y_axis);
|
||||
maxy := y_max;
|
||||
for i := 1 to 60 do
|
||||
for j := 1 to height+1 do plotstring[j,i] := ' ';
|
||||
@ -2019,9 +2017,7 @@ begin
|
||||
row := row + 1;
|
||||
plotstring[row,30] := '|';
|
||||
if (row = (height / 2)) then
|
||||
begin
|
||||
for i := 1 to 60 do plotstring[row,i] := '-';
|
||||
end;
|
||||
for i := 1 to nocases do
|
||||
begin
|
||||
if ((maxy >= y[i-1]) and (y[i-1] > (maxy - incrementy))) then
|
||||
@ -2041,40 +2037,40 @@ begin
|
||||
if (howlong < 2) then
|
||||
plotstring[row,xslot] := valuestring[2]
|
||||
else for l := 1 to 2 do
|
||||
plotstring[row,xslot + l - 1] := valuestring[l];
|
||||
plotstring[row,xslot + l - 1] := valuestring[l];
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
maxy := maxy - incrementy;
|
||||
end;
|
||||
|
||||
{ print the plot }
|
||||
for i := 1 to row do
|
||||
begin
|
||||
outline := ' |';
|
||||
for j := 1 to 60 do outline := outline + format('%1s',[plotstring[i,j]]);
|
||||
outline := outline + format('|-%6.2f-%6.2f',
|
||||
for j := 1 to 60 do outline := outline + Format('%1s', [plotstring[i,j]]);
|
||||
outline := outline + Format('|-%6.2f-%6.2f',
|
||||
[(y_max - i * incrementy),(y_max - i * incrementy + incrementy)]);
|
||||
OutputFrm.RichEdit.Lines.Add(outline);
|
||||
AReport.Add(outline);
|
||||
end;
|
||||
|
||||
outline := '';
|
||||
for i := 1 to 63 do outline := outline + '-';
|
||||
OutputFrm.RichEdit.Lines.Add(outline);
|
||||
AReport.Add(outline);
|
||||
|
||||
outline := '';
|
||||
for i := 1 to 16 do outline := outline + ' | ';
|
||||
outline := outline + x_axis;
|
||||
OutputFrm.RichEdit.Lines.Add(outline);
|
||||
AReport.Add(outline);
|
||||
|
||||
outline := '';
|
||||
for i := 1 to 16 do outline := outline + format('%4.1f',[(x_min + i * incrementx - incrementx)]);
|
||||
OutputFrm.RichEdit.Lines.Add(outline);
|
||||
OutputFrm.RichEdit.Lines.Add('');
|
||||
OutputFrm.RichEdit.Lines.Add('Labels:');
|
||||
for i := 1 to 16 do outline := outline + Format('%4.1f', [(x_min + i * incrementx - incrementx)]);
|
||||
AReport.Add(outline);
|
||||
AReport.Add('');
|
||||
AReport.Add('Labels:');
|
||||
for i := 1 to nocases do
|
||||
begin
|
||||
outline := format('%2d = %s',[i,Labels[i-1]]);
|
||||
OutputFrm.RichEdit.Lines.Add(outline);
|
||||
end;
|
||||
OutputFrm.ShowModal;
|
||||
OutputFrm.RichEdit.Clear;
|
||||
AReport.Add('%2d = %s', [i, Labels[i-1]]);
|
||||
|
||||
Labels := nil;
|
||||
end; { of scatplot procedure }
|
||||
//-------------------------------------------------------------------
|
||||
|
@ -9,6 +9,10 @@ uses
|
||||
|
||||
function AnySelected(AListbox: TListBox): Boolean;
|
||||
|
||||
procedure Exchange(var a, b: Double); overload;
|
||||
procedure Exchange(var a, b: Integer); overload;
|
||||
procedure Exchange(var a, b: String); overload;
|
||||
|
||||
implementation
|
||||
|
||||
function AnySelected(AListBox: TListBox): Boolean;
|
||||
@ -24,5 +28,32 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Exchange(var a, b: Double);
|
||||
var
|
||||
tmp: Double;
|
||||
begin
|
||||
tmp := a;
|
||||
a := b;
|
||||
b := tmp;
|
||||
end;
|
||||
|
||||
procedure Exchange(var a, b: Integer);
|
||||
var
|
||||
tmp: Integer;
|
||||
begin
|
||||
tmp := a;
|
||||
a := b;
|
||||
b := tmp;
|
||||
end;
|
||||
|
||||
procedure Exchange(var a, b: String);
|
||||
var
|
||||
tmp: String;
|
||||
begin
|
||||
tmp := a;
|
||||
a := b;
|
||||
b := tmp;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user