Skip to content

Commit 07d2bfd

Browse files
author
Daniel Skoog
committed
Revert "Update to use more common option name"
This reverts commit 266e1b4.
1 parent 266e1b4 commit 07d2bfd

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

src/ClusterPlot.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ elif hastype(X, {'rtable', 'DataFrame'}) and cluster = NULL then
5656
ldatasplit := Array(1..numdf);
5757
for i to numdf do
5858
ldatasplit(i) := ldata[i];
59-
p1(i) := MVEE(ldatasplit[i][..,1..2], 'output' = 'plot', 'color' = plots:-setcolors()[i], _rest);
59+
p1(i) := MVEE(ldatasplit[i][..,1..2], 'showplot', 'color' = plots:-setcolors()[i], _rest);
6060
end do;
6161
else
6262
p1 := [NULL];

src/MVEE.mm

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,25 @@
22
MVEE := proc(XY,
33
{tolerance::positive:= 1e-4}, #Convergence Criterion
44
{maxiterations::posint := 100},
5-
{output::{identical(data,plot),list(identical(data,plot))} := data},
5+
{showplot::truefalse := false},
66
{filled::truefalse := false}
77
)
88

9-
local alpha, evalues, evectors, i, l_error, ldata, ldataext, M, maxvalindex, n, ncols, nrows, p1, semiaxes, stepsize, U, U1, x, X, y;
10-
local A, center, l_output; #Output
11-
12-
if hastype(output, 'list') then
13-
l_output := output;
14-
else
15-
l_output := [output];
16-
end if;
9+
local alpha, count, evalues, evectors, i, l_error, ldata, ldataext, M, maxvalindex, n, ncols, nrows, semiaxes, stepsize, U, U1, x, X, y;
10+
local A, center; #Output
1711

1812
kernelopts(opaquemodules=false):
1913

2014
ldata := Statistics:-PreProcessData(XY, 2, 'copy');
2115

2216
nrows, ncols := upperbound(ldata);
23-
ldataext := Matrix([ldata, Vector[column](nrows, ':-fill' = 1)], 'datatype = float');
17+
ldataext := Matrix([ldata, Vector[column](nrows, 'fill' = 1)], 'datatype = float');
2418

2519
if ncols <> 2 then
2620
error "expected 2 columns of data, got %1", ncols;
2721
end if;
2822

23+
count := 1;
2924
l_error := 1;
3025

3126
U := Vector[column](1..nrows, 'fill' = 1/nrows);
@@ -40,28 +35,29 @@
4035
U1 := (1 - stepsize) * U;
4136
U1[maxvalindex] := U1[maxvalindex] + stepsize;
4237
l_error := LinearAlgebra:-Norm(LinearAlgebra:-DiagonalMatrix(U1 - U));
38+
count := count + 1;
4339
U := U1;
4440

4541
end do;
4642

4743
A := (1/ncols) * LinearAlgebra:-MatrixInverse(LinearAlgebra:-Transpose(ldata) . LinearAlgebra:-DiagonalMatrix(U) . ldata - (LinearAlgebra:-Transpose(ldata) . U) . LinearAlgebra:-Transpose((LinearAlgebra:-Transpose(ldata) . U)));
4844
center := LinearAlgebra:-Transpose(ldata) . U;
4945
evalues, evectors := LinearAlgebra:-Eigenvectors(A);
50-
evectors := evectors(.., sort[index](1 /~ (sqrt~(Re~(evalues))), `>`, ':-output' = ':-permutation'));
46+
evectors := evectors(.., sort[index](1 /~ (sqrt~(Re~(evalues))), `>`, 'output' = 'permutation'));
5147
semiaxes := sort(1 /~ (sqrt~(Re~(evalues))), `>`);
5248
alpha := arctan(Re(evectors[2,1]) / Re(evectors[1,1]));
49+
if showplot = true then
5350

54-
if l_output = [':-data'] then
51+
x := t -> center[1] + semiaxes[1] * cos(t) * cos(alpha) - semiaxes[2] * sin(t) * sin(alpha);
52+
y := t -> center[2] + semiaxes[1] * cos(t) * sin(alpha) + semiaxes[2] * sin(t) * cos(alpha);
53+
if filled then
54+
return plots:-display(subs(CURVES=POLYGONS, plot([x(t), y(t), t = 0..2*Pi], 'transparency' = 0.95, _rest)));
55+
else
56+
return plot([x(t), y(t), t = 0..2*Pi], _rest);
57+
58+
end if;
59+
else
5560
return A, center, evectors, evalues;
56-
elif has( l_output, ':-plot' ) then
57-
x := t -> center[1] + semiaxes[1] * cos(t) * cos(alpha) - semiaxes[2] * sin(t) * sin(alpha);
58-
y := t -> center[2] + semiaxes[1] * cos(t) * sin(alpha) + semiaxes[2] * sin(t) * cos(alpha);
59-
if filled then
60-
p1 := plots:-display(subs(CURVES=POLYGONS, plot([x(t), y(t), t = 0..2*Pi], ':-transparency' = 0.95, _rest)));
61-
else
62-
p1 := plot([x(t), y(t), t = 0..2*Pi], _rest);
63-
end if;
64-
return p1, `if`( has(l_output, ':-data'), op([A, center, evectors, evalues]), NULL );
6561
end if;
6662

6763
end proc:

0 commit comments

Comments
 (0)