diff options
author | Norbert Preining <norbert@preining.info> | 2023-01-24 03:02:57 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2023-01-24 03:02:57 +0000 |
commit | b06c6695162b493aeec3b594c6beb518c15c98ba (patch) | |
tree | 0c1dc3cfc73ea789d6bdc4673d776f3ef652d6d8 /graphics/asymptote/base | |
parent | 4451a2090261307c963209bc65fea9fde4eceeea (diff) |
CTAN sync 202301240302
Diffstat (limited to 'graphics/asymptote/base')
-rw-r--r-- | graphics/asymptote/base/geometry.asy | 12 | ||||
-rw-r--r-- | graphics/asymptote/base/graph.asy | 8 | ||||
-rw-r--r-- | graphics/asymptote/base/plain_arrows.asy | 2 | ||||
-rw-r--r-- | graphics/asymptote/base/plain_pens.asy | 4 | ||||
-rw-r--r-- | graphics/asymptote/base/rationalSimplex.asy | 74 | ||||
-rw-r--r-- | graphics/asymptote/base/simplex.asy | 47 | ||||
-rw-r--r-- | graphics/asymptote/base/three.asy | 5 | ||||
-rw-r--r-- | graphics/asymptote/base/v3dheadertypes.asy | 2 | ||||
-rw-r--r-- | graphics/asymptote/base/v3dtypes.asy | 2 |
9 files changed, 80 insertions, 76 deletions
diff --git a/graphics/asymptote/base/geometry.asy b/graphics/asymptote/base/geometry.asy index 9f0631f447..37d085cb1c 100644 --- a/graphics/asymptote/base/geometry.asy +++ b/graphics/asymptote/base/geometry.asy @@ -6418,13 +6418,13 @@ inversion inversion(circle c1, circle c2, real sgn = 1) point O = radicalcenter(c1, c2); return inversion(O^c1, O); } - real a = abs(c1.r/c2.r); - if(sgn > 0) { - point O = c1.C + a/abs(1 - a) * (c2.C - c1.C); - return inversion(a * abs(abs(O - c2.C)^2 - c2.r^2), O); + else { + point C1 = c1.C, C2 = c2.C; + real r1 = c1.r, r2 = sgn(sgn) * c2.r; + return inversion( + r1 * r2 * (1 - (length(C2 - C1) / (r1 + r2))^2), + (r2 * C1 + r1 * C2) / (r1 + r2)); } - point O = c1.C + a/abs(1 + a) * (c2.C - c1.C); - return inversion(-a * abs(abs(O - c2.C)^2 - c2.r^2), O); } /*<asyxml><function type="inversion" signature="inversion(circle,circle,circle)"><code></asyxml>*/ diff --git a/graphics/asymptote/base/graph.asy b/graphics/asymptote/base/graph.asy index 18821b456d..433aa2fc20 100644 --- a/graphics/asymptote/base/graph.asy +++ b/graphics/asymptote/base/graph.asy @@ -2213,7 +2213,13 @@ picture vectorfield(path vector(pair), pair a, pair b, max=maxbound(max,size((x,y))); } } - scale=min(dx/max.x,dy/max.y); + + if(max.x == 0) + scale=max.y == 0 ? 1.0 : dy/max.y; + else if(max.y == 0) + scale=dx/max.x; + else + scale=min(dx/max.x,dy/max.y); for(int i=0; i < nx; ++i) { real x=a.x+i*dx; diff --git a/graphics/asymptote/base/plain_arrows.asy b/graphics/asymptote/base/plain_arrows.asy index a172a0d07f..d9c08636fc 100644 --- a/graphics/asymptote/base/plain_arrows.asy +++ b/graphics/asymptote/base/plain_arrows.asy @@ -157,7 +157,7 @@ TeXHead.head=new path(path g, position position=EndPoint, pen p=currentpen, if(relative) position=reltime(g,position); path r=subpath(g,position,0); pair y=point(r,arctime(r,size)); - return shift(y)*rotate(degrees(-dir(r,arctime(r,0.5*size))))*gp; + return shift(y)*rotate(degrees(-dir(r,arctime(r,0.5*size)),false))*gp; }; TeXHead.defaultfilltype=new filltype(pen p) {return Fill(p);}; diff --git a/graphics/asymptote/base/plain_pens.asy b/graphics/asymptote/base/plain_pens.asy index 2e3a4449a3..2f47855a9f 100644 --- a/graphics/asymptote/base/plain_pens.asy +++ b/graphics/asymptote/base/plain_pens.asy @@ -1,4 +1,4 @@ -real labelmargin=0.3; +real labelmargin=0.28; real dotfactor=6; pen solid=linetype(new real[]); @@ -173,7 +173,7 @@ pen fontsize(real size) real labelmargin(pen p=currentpen) { - return labelmargin*fontsize(p); + return labelmargin*fontsize(p)+0.5*linewidth(p); } void write(file file=stdout, string s="", pen[] p) diff --git a/graphics/asymptote/base/rationalSimplex.asy b/graphics/asymptote/base/rationalSimplex.asy index 3a376ba2dd..b6ce98c4ae 100644 --- a/graphics/asymptote/base/rationalSimplex.asy +++ b/graphics/asymptote/base/rationalSimplex.asy @@ -1,9 +1,14 @@ // Rational simplex solver written by John C. Bowman and Pouria Ramazi, 2018. import rational; +bool optimizeTableau=true; + +int[] artificialColumn; + void simplexInit(rational[] c, rational[][] A, int[] s=new int[], rational[] b, int count) {} -void simplexTableau(rational[][] E, int[] Bindices, int I=-1, int J=-1) {} +void simplexTableau(rational[][] E, int[] Bindices, int I=-1, int J=-1, + int n=E[0].length-1) {} void simplexPhase1(rational[] c, rational[][] A, rational[] b, int[] Bindices) {} void simplexPhase2() {} @@ -71,7 +76,7 @@ struct simplex { } } - int iterate(rational[][] E, int N, int[] Bindices) { + int iterate(rational[][] E, int N, int[] Bindices, bool phase1=false) { while(true) { // Bland's rule: first negative entry in reduced cost (bottom) row enters rational[] Em=E[m]; @@ -108,11 +113,13 @@ struct simplex { // Generate new tableau Bindices[I]=J; rowreduce(E,N,I,J); + + if(phase1 && Em[0] == 0) break; } return OPTIMAL; } - int iterateDual(rational[][] E, int N, int[] Bindices) { + int iterateDual(rational[][] E, int N, int[] Bindices, bool phase1=false) { while(true) { // Bland's rule: negative variable with smallest subscript exits int I; @@ -211,30 +218,31 @@ struct simplex { if(phase1) { Bindices=new int[m]; - int p=0; + int k=0; + artificialColumn.delete(); // Check for redundant basis vectors. - bool checkBasis(int j) { - for(int i=0; i < m; ++i) { - rational[] Ei=E[i]; - if(i != p ? Ei[j] != 0 : Ei[j] <= 0) return false; + for(int p=0; p < m; ++p) { + bool checkBasis(int j) { + for(int i=0; i < m; ++i) { + rational[] Ei=E[i]; + if(i != p ? Ei[j] != 0 : Ei[j] <= 0) + return false; + } + return true; } - return true; - } - int checkTableau() { - for(int j=1; j <= n; ++j) - if(checkBasis(j)) return j; - return 0; - } + int checkTableau() { + if(optimizeTableau) + for(int j=1; j <= n; ++j) + if(checkBasis(j)) return j; + return 0; + } - int k=0; - while(p < m) { int j=checkTableau(); - if(j > 0) - Bindices[p]=j; - else { // Add an artificial variable - Bindices[p]=n+1+k; + Bindices[p]=n+1+p; + if(j == 0) { // Add an artificial variable + artificialColumn.push(p+1); for(int i=0; i < p; ++i) E[i].push(0); E[p].push(1); @@ -243,14 +251,13 @@ struct simplex { E[m].push(0); ++k; } - ++p; } basicValues(); simplexPhase1(c,A,b,Bindices); - iterate(E,n+k,Bindices); + iterate(E,n+k,Bindices,true); if(Em[0] != 0) { simplexTableau(E,Bindices); @@ -265,23 +272,22 @@ struct simplex { rational[] cB=phase1 ? new rational[m] : c[n-m:n]; rational[][] D=phase1 ? new rational[m+1][n+1] : E; if(phase1) { - bool output=true; + write("n=",n); + write(Bindices); // Drive artificial variables out of basis. for(int i=0; i < m; ++i) { - int k=Bindices[i]; - if(k > n) { + if(Bindices[i] > n) { rational[] Ei=E[i]; int j; for(j=1; j <= n; ++j) if(Ei[j] != 0) break; if(j > n) continue; - output=false; - simplexTableau(E,Bindices,i,j); + simplexTableau(E,Bindices,i,j,n); Bindices[i]=j; rowreduce(E,n,i,j); } } - if(output) simplexTableau(E,Bindices); + simplexTableau(E,Bindices,-1,-1,n); int ip=0; // reduced i for(int i=0; i < m; ++i) { int k=Bindices[i]; @@ -307,7 +313,6 @@ struct simplex { D.delete(ip,m-1); m=ip; } - if(!output) simplexTableau(D,Bindices); } rational[] Dm=D[m]; @@ -335,6 +340,8 @@ struct simplex { for(int k=0; k < m; ++k) x[Bindices[k]-1]=D[k][0]; + + xStandard=copy(x); } if(case == UNBOUNDED) { @@ -414,10 +421,7 @@ struct simplex { simplexInit(C,a,b,count); operator init(C,a,b,phase1); - if(case != INFEASIBLE) { - xStandard=copy(x); - if(count > 0) - x.delete(n,n+count-1); - } + if(case != INFEASIBLE && count > 0) + x.delete(n,n+count-1); } } diff --git a/graphics/asymptote/base/simplex.asy b/graphics/asymptote/base/simplex.asy index 3bc74635db..8b53ede6eb 100644 --- a/graphics/asymptote/base/simplex.asy +++ b/graphics/asymptote/base/simplex.asy @@ -42,7 +42,7 @@ struct simplex { } } - int iterate(real[][] E, int N, int[] Bindices) { + int iterate(real[][] E, int N, int[] Bindices, bool phase1=false) { while(true) { // Bland's rule: first negative entry in reduced cost (bottom) row enters real[] Em=E[m]; @@ -77,11 +77,13 @@ struct simplex { // Generate new tableau Bindices[I]=J; rowreduce(E,N,I,J); + + if(phase1 && abs(Em[0]) <= EpsilonA) break; } return OPTIMAL; } - int iterateDual(real[][] E, int N, int[] Bindices) { + int iterateDual(real[][] E, int N, int[] Bindices, bool phase1=false) { while(true) { // Bland's rule: negative variable with smallest subscript exits int I; @@ -182,30 +184,28 @@ struct simplex { if(phase1) { Bindices=new int[m]; - int p=0; + int k=0; // Check for redundant basis vectors. - bool checkBasis(int j) { - for(int i=0; i < m; ++i) { - real[] Ei=E[i]; - if(i != p ? abs(Ei[j]) >= epsilonA : Ei[j] <= epsilonA) return false; + for(int p=0; p < m; ++p) { + bool checkBasis(int j) { + for(int i=0; i < m; ++i) { + real[] Ei=E[i]; + if(i != p ? abs(Ei[j]) >= epsilonA : Ei[j] <= epsilonA) + return false; + } + return true; } - return true; - } - int checkTableau() { - for(int j=1; j <= n; ++j) - if(checkBasis(j)) return j; - return 0; - } + int checkTableau() { + for(int j=1; j <= n; ++j) + if(checkBasis(j)) return j; + return 0; + } - int k=0; - while(p < m) { int j=checkTableau(); - if(j > 0) - Bindices[p]=j; - else { // Add an artificial variable - Bindices[p]=n+1+k; + Bindices[p]=n+1+p; + if(j == 0) { // Add an artificial variable for(int i=0; i < p; ++i) E[i].push(0.0); E[p].push(1.0); @@ -214,11 +214,11 @@ struct simplex { E[m].push(0.0); ++k; } - ++p; } basicValues(); - iterate(E,n+k,Bindices); + + iterate(E,n+k,Bindices,true); if(abs(Em[0]) > EpsilonA) { case=INFEASIBLE; @@ -234,8 +234,7 @@ struct simplex { if(phase1) { // Drive artificial variables out of basis. for(int i=0; i < m; ++i) { - int k=Bindices[i]; - if(k > n) { + if(Bindices[i] > n) { real[] Ei=E[i]; int j; for(j=1; j <= n; ++j) diff --git a/graphics/asymptote/base/three.asy b/graphics/asymptote/base/three.asy index c208f59df8..9dfad6ce79 100644 --- a/graphics/asymptote/base/three.asy +++ b/graphics/asymptote/base/three.asy @@ -2907,11 +2907,6 @@ object embed(string prefix=outprefix(), string label=prefix, if((preview || (prc && settings.render == 0)) && settings.embed) { image=prefix; if(settings.inlinetex) image += "_0"; - if(!preview && !S.pic2.empty2()) { - transform T=S.pic2.scaling(S.width,S.height); - _shipout(image,S.pic2.fit(T),newframe,nativeformat(),false,false); - } - image += "."+nativeformat(); if(!settings.inlinetex) file3.push(image); image=graphic(image,"hiresbb"); diff --git a/graphics/asymptote/base/v3dheadertypes.asy b/graphics/asymptote/base/v3dheadertypes.asy index 9c966a47cb..653a8ba2d9 100644 --- a/graphics/asymptote/base/v3dheadertypes.asy +++ b/graphics/asymptote/base/v3dheadertypes.asy @@ -1,6 +1,6 @@ // Enum class for v3dheadertypes // AUTO-GENERATED from v3dheadertypes.csv -// Generated at 2022-09-17 12:47:07.633830 +// Generated at 2023-01-23 00:17:44 struct v3dheadertypes { diff --git a/graphics/asymptote/base/v3dtypes.asy b/graphics/asymptote/base/v3dtypes.asy index 7de241a2d0..c101488827 100644 --- a/graphics/asymptote/base/v3dtypes.asy +++ b/graphics/asymptote/base/v3dtypes.asy @@ -1,6 +1,6 @@ // Enum class for v3dtypes // AUTO-GENERATED from v3dtypes.csv -// Generated at 2022-09-17 12:47:07.568303 +// Generated at 2023-01-23 00:17:44 struct v3dtypes { |