id
stringlengths
36
36
text
stringlengths
1
1.25M
87ac20a4-c2a1-4cca-8c29-dfa113dde4a8
public void Musica(boolean musica) { this.musica = musica; }
01a56e8e-bd16-4def-876d-38f77f954f5e
public Gaussian(int a, int b) { this.a = a; this.b = b; }
1864bae7-0824-4598-96ce-3e5bad5d545e
public int compareTo(Gaussian that) { if(this.equals(that)) return 0; else if(this.norm2() == that.norm2()) return this.argument() > that.argument()? 1: -1; else return this.norm2()-that.norm2(); }
209eb6e0-56be-44f0-9640-bb337fe7b1ed
public Boolean equals(Gaussian that) { return this.a == that.a && this.b == that.b; }
98066839-6ce0-465a-a6a3-6d42c06e0d99
public Gaussian inc() { if(this.equals(ZERO)) return(ONE); if(this.a == 1) return new Gaussian(this.b+2, 0); else return new Gaussian(this.a-1, this.b+1); }
92808822-d7ad-4769-8be9-efb36d26d6c8
public int norm2() { return a*a+b*b; }
085760f3-74da-4fb4-9116-2a34d1cb7dd5
public double argument() { return Math.PI + this.toCoordinate().azimuth(); }
845f7d26-f7b6-45f1-977c-f54fea354d24
public Gaussian neg() { return new Gaussian(-this.a, -this.b); }
71f3a2c8-fd4b-4584-91ed-92a3f9accc9c
public Gaussian conj() { return new Gaussian(this.a, -this.b); }
5a8e8b69-e01d-4460-8135-a9870d21c409
public Gaussian add(Gaussian that) { return new Gaussian(this.a+that.a, this.b+that.b); }
b721de66-ebb5-402e-ad51-bf8fe0f049cf
public Gaussian sub(Gaussian that) { return new Gaussian(this.a-that.a, this.b-that.b); }
144c313c-a4d4-4b6b-95f8-1d5d6445047b
public Gaussian mul(int mul) { return new Gaussian(this.a*mul, this.b*mul); }
1c1ca1bb-d06b-4621-97c5-dc96e3b7a325
public Gaussian mul(Gaussian that) { return new Gaussian(this.a*that.a-this.b*that.b, this.b*that.a+this.a*that.b); }
37d76524-3a09-4c10-8cbb-77c354a16fe9
public Gaussian div(int div) { return new Gaussian(this.a/div, this.b/div); }
35768fd1-b9d3-4e0b-a7c5-b0d6cfe5d18c
public Gaussian div(Gaussian that) { return this.mul(that.conj()).div(that.norm2()); }
5a8195de-e64e-4529-80c1-a50863677e02
public Gaussian mod(int div) { return new Gaussian(this.a%div, this.b%div); }
c5e82067-3dea-4e85-8c6e-b1fbcbc2cb60
public Gaussian mod(Gaussian that) { int norm = that.norm2(); Gaussian prod = this.mul(that.conj()); return new Gaussian(prod.a%norm, prod.b%norm); }
e1cb8a16-dd02-49e1-8ccd-cef1666d5fdb
public String toString() { String format = ""; if(this.a == 0) if(this.b == -1) return "-i"; else if(this.b == 0) return "0"; else if(this.b == 1) return "i"; else return String.format("%di", this.b); else if(this.b == -1) return String.format("%d-i", this.a); else if(this.b == 0) return String.format("%d", this.a); else if(this.b == 1) return String.format("%d+i", this.a); else return String.format(this.b<0? "%d%di": "%d+%di", this.a, this.b); }
85ecf496-fb6c-4b23-860d-4266e9d5564b
public String toComplexString() { if(this.b>=0) return String.format("%.3f +%.3fi", this.a, this.b); else return String.format("%.3f %.3fi", this.a, this.b); }
52feed7e-f6b1-46a5-bc7b-2fc10fe9d855
public Coordinate toCoordinate() { return new Coordinate(this.a, this.b); }
6116c4d7-4005-4982-a0c7-d093355c3261
public boolean isPrime() { return false; }
5d35c84f-2b36-415c-a691-14b9e35accfd
public static void main(String[] args) throws Exception { int maxNorm = Integer.parseInt(args[0]); maxNorm *= maxNorm; for(Eisenstein e=new Eisenstein(0,-3); e.norm2()<maxNorm; e=e.inc()) hopp: { Eisenstein f = e; for(Eisenstein z: primes) { if(f.mod(z).equals(Eisenstein.ZERO) && f.norm2() > z.norm2()) { System.err.printf("%s\t=\t%s\tx\t%s\n", f.toString(), z.toString(), f.div(z).toString()); break hopp; } } System.err.printf("%s\n", f.toString()); primes.add(e); primes.add(e.mul(Eisenstein.OMEGA)); primes.add(e.mul(Eisenstein.OMEG2)); } System.err.println(primes); printPrimes(primes); //printGerber(primes); }
1252ab11-4308-4bfa-b35f-7bd24912207d
private static void printPrimes(ArrayList<Eisenstein> primes) throws Exception { ObjectOutputStream oout = new ObjectOutputStream(System.out); oout.writeObject(primes); oout.close(); }
f6893952-74fe-44de-b262-c44b367c7250
private static void printGerber(ArrayList<Eisenstein> primes) throws Exception { System.out.println(GerberPlottables.GERBER_HEADER); System.out.println("G75*"); int scale = 1000; // double radius = scale/2*2/Math.sqrt(3); double radius = scale/2; for(Eisenstein e: primes) System.out.println(GerberPlottables.circle(e.mul(scale).toCoordinate(), radius)); System.out.println(GerberPlottables.GERBER_FOOTER); }
e642e78e-183d-4fc9-ae13-d07e52379ee8
public Complex(double a, double b) { this.a = a; this.b = b; }
19358dcc-b4fa-4774-813e-56d33bf2080b
public double norm() { return Math.sqrt(this.norm2()); }
dec42457-ad4f-4399-a28b-8f8cb6e7142e
public double norm2() { return a*a+b*b; }
0375d42a-fbf5-465e-95a1-9a067321fbb3
public double argument() { return Math.PI + this.toCoordinate().azimuth(); }
072facf6-b512-4895-b28b-4b814426e992
public Complex neg() { return new Complex(-this.a, -this.b); }
83f4bd5c-6e63-4048-b2d3-92271a08d62c
public Complex conj() { return new Complex(this.a, -this.b); }
7de4e337-f19e-411d-a914-c430cb370a6e
public Complex add(Complex that) { return new Complex(this.a+that.a, this.b+that.b); }
f2f7b9e9-5a44-46c6-9601-4a1779ac9c84
public Complex sub(Complex that) { return new Complex(this.a-that.a, this.b-that.b); }
a01f4cd3-c6b7-4c45-968b-a6c66edb17b1
public Complex mul(double mul) { return new Complex(this.a*mul, this.b*mul); }
2f37587a-c141-4f94-a9db-5411c453e1c9
public Complex mul(Complex that) { return new Complex(this.a*that.a-this.b*that.b, this.b*that.a+this.a*that.b); }
ef768ccd-d7e2-48c0-8a1a-7c3aeeb05f92
public Complex div(double div) { return new Complex(this.a/div, this.b/div); }
be85038e-8491-4193-8180-0e666073bb61
public Complex div(Complex that) { return this.mul(that.conj()).div(that.norm2()); }
18d7cde4-4283-4ea2-adcc-80f61f9834bb
public String toString() { if(this.b>=0) return String.format("%.3f +%.3fi", this.a, this.b); else return String.format("%.3f %.3fi", this.a, this.b); }
4e408db6-970b-4a7d-9152-123748ff627f
public Coordinate toCoordinate() { return new Coordinate(this.a, this.b); }
db052c0f-0d93-40e8-9fe4-7520f697cec0
public boolean isPrime() { return false; }
5e238544-282e-4b34-afd0-5d6b713b62c4
public Polygon(Coordinate[] corners) { this.corners = corners; }
58a82923-e772-4141-a1b3-84725cc4e690
public Polygon translate(Coordinate t) { Coordinate[] res = new Coordinate[this.corners.length]; for(int i=0; i<this.corners.length; i++) res[i] = this.corners[i].add(t); return new Polygon(res); }
dd7af329-e07c-46ef-b82b-50829e92f506
public Polygon scale(double s) { Coordinate[] res = new Coordinate[this.corners.length]; for(int i=0; i<this.corners.length; i++) res[i] = this.corners[i].scale(s); return new Polygon(res); }
ac803eb3-cacc-4e28-8e21-ec2b76d4f12a
public Polygon rotate(double a) { Coordinate[] res = new Coordinate[this.corners.length]; for(int i=0; i<this.corners.length; i++) res[i] = this.corners[i].rotate(a); return new Polygon(res); }
fe2169f5-bb0e-456c-919b-2112a77431dc
public boolean contains(Coordinate p) { double res = 0; for(int i=1; i<this.corners.length; i++) res += this.corners[i-1].sub(p).angle(this.corners[i].sub(p)); return Math.abs(res) > 6; }
03bd28be-ddca-4c63-b2e7-4ae4867f898f
public int orientation() { return this.area()>0? 1: -1; }
6dbfbc43-96ed-46d8-bfcf-138dd7d53a60
public double area() { double area = 0; for(int i=1; i<this.corners.length; i++) area += this.corners[i-1].cross(this.corners[i]); return area; }
ef82b0c7-ae33-4f8d-8054-1af132de0e01
public String toString() { String res = "[Polygon"; for(int i=0; i<corners.length && i<4; i++) res += " " + corners[i].toString(); return res+"]\n"; }
cc7a3205-fba5-4e2e-9e8a-ada4073c0f0e
public static void main(String[] args) throws Exception { int maxNorm = Integer.parseInt(args[0]); maxNorm *= maxNorm; for(Gaussian e=new Gaussian(3,0); e.norm2()<maxNorm; e=e.inc()) hopp: { Gaussian f = e; for(Gaussian z: primes) { if(f.mod(z).equals(Gaussian.ZERO) && f.norm2() > z.norm2()) { System.err.printf("%s\t=\t%s\tx\t%s\n", f.toString(), z.toString(), f.div(z).toString()); break hopp; } } System.err.printf("%s\n", f.toString()); primes.add(e); primes.add(e.mul(Gaussian.UNIT)); primes.add(e.neg()); primes.add(e.neg().mul(Gaussian.UNIT)); } System.err.println(primes); printPrimes(primes); //printGerber(primes); }
98c6731b-f27a-4190-bb4b-c1655984f3b9
private static void printPrimes(ArrayList<Gaussian> primes) throws Exception { ObjectOutputStream oout = new ObjectOutputStream(System.out); oout.writeObject(primes); oout.close(); }
767c6142-92b3-4622-b8d0-469bdc0ff123
private static void printGerber(ArrayList<Gaussian> primes) throws Exception { System.out.println(GerberPlottables.GERBER_HEADER); System.out.println("G75*"); int scale = 1000; // double radius = scale/2*2/Math.sqrt(3); double radius = scale/2; for(Gaussian e: primes) System.out.println(GerberPlottables.circle(e.mul(scale).toCoordinate(), radius)); System.out.println(GerberPlottables.GERBER_FOOTER); }
3fe9d9ed-a5f9-476c-99e9-45dc7c72f488
public Eisenstein(int a, int b) { this.a = a; this.b = b; }
ee8df024-1abc-4565-ba22-d2b78b338983
public int compareTo(Eisenstein that) { if(this.equals(that)) return 0; else if(this.norm2() == that.norm2()) return this.argument() > that.argument()? 1: -1; else return this.norm2()-that.norm2(); }
15491180-2c82-49c4-a320-3a603b89ea4b
public Boolean equals(Eisenstein that) { return this.a == that.a && this.b == that.b; }
9898ac7f-933e-415d-969a-16bd2bf4c681
public Eisenstein inc() { if(this.b >= this.a-1) return new Eisenstein(0, -this.a-1); else if(this.b < 0) return new Eisenstein(this.a+1, this.b+1); else return new Eisenstein(this.a, this.b+1); }
91820c5b-1778-4aa8-afdf-cbb45ed3be72
public int norm2() { return a*a-a*b+b*b; }
11e135ca-0c8c-4a16-b583-86598f553c50
public double argument() { return Math.PI + this.toCoordinate().azimuth(); }
1cb8a2d8-b5a5-4fd1-96fa-7eaf4fa2e341
public Eisenstein neg() { return new Eisenstein(-this.a, -this.b); }
1f02b2c6-a4df-42e2-af7a-a3fe111d7aba
public Eisenstein conj() { return new Eisenstein(this.a-this.b, -this.b); }
5fbdfcbe-5acb-40b1-8011-3c8fed5bfb07
public Eisenstein add(Eisenstein that) { return new Eisenstein(this.a+that.a, this.b+that.b); }
a5df76a3-3dff-48ab-9604-d06390373ebf
public Eisenstein sub(Eisenstein that) { return new Eisenstein(this.a-that.a, this.b-that.b); }
5d785cc7-c08d-4cba-bddc-d337f10ef451
public Eisenstein mul(int mul) { return new Eisenstein(this.a*mul, this.b*mul); }
d29c5207-dad1-4afa-b114-65581a91b898
public Eisenstein mul(Eisenstein that) { return new Eisenstein(this.a*that.a-this.b*that.b, this.b*that.a+this.a*that.b-this.b*that.b); }
7bdf2358-1cff-4dd5-b8c1-60945b371a2f
public Eisenstein div(int div) { return new Eisenstein(this.a/div, this.b/div); }
708c7d1e-2902-4593-b707-45214e27d62c
public Eisenstein div(Eisenstein that) { return this.mul(that.conj()).div(that.norm2()); }
f1f79cb5-5d82-4976-bdb1-b95e2e44ec85
public Eisenstein mod(int div) { return new Eisenstein(this.a%div, this.b%div); }
08b1f720-4720-4236-a5bd-afa9823e0a82
public Eisenstein mod(Eisenstein that) { int norm = that.norm2(); Eisenstein prod = this.mul(that.conj()); return new Eisenstein(prod.a%norm, prod.b%norm); }
b981868e-dcc6-45b1-9832-f9b411dcf771
public String toString() { String res = this.a==0? "": ""+this.a; switch(this.b) { case 0: return res; case 1: return res + "+w"; case -1: return res + "-w"; default: return res + (this.b>0? "+": "") + this.b + "w"; } }
09a668b0-5ced-438f-9c3b-d1d53e79ab60
public String toComplexString() { if(this.b>=0) return String.format("%.3f +%.3fi", this.a+this.b*Math.cos(ALPHA), this.b*Math.sin(ALPHA)); else return String.format("%.3f %.3fi", this.a+this.b*Math.cos(ALPHA), this.b*Math.sin(ALPHA)); }
3681f821-f7e4-404a-bd3d-55831edd13a6
public Coordinate toCoordinate() { return new Coordinate(this.a+this.b*Math.cos(Eisenstein.ALPHA), this.b*Math.sin(Eisenstein.ALPHA)); }
3d5691e3-d35b-4d6b-b9ce-aa4e5762b237
public boolean isPrime() { return false; }
b2e683b2-07de-4827-9d86-1db7e864fd5a
public Coordinate(double x, double y) { this.x = x; this.y = y; }
fd301b08-0ad8-404c-8858-1e7c70409889
public double magnitude() { return Math.sqrt(this.dot(this)); }
51172cad-1215-43a5-aa81-04507094e486
public double azimuth() { return X.angle(this); }
9c9d1eb4-32b2-4e7e-8591-598e1336207c
public Boolean within(Coordinate that, double prec) { return this.distance(that) <= prec; }
f5e61419-57d1-4979-9d01-d0b166af89dc
public double distance(Coordinate that) { return that.sub(this).magnitude(); }
8e9eb71c-df7e-4337-88ad-e25cb10e4cf9
public double bearing(Coordinate that) { return that.sub(this).azimuth(); }
ba2e4118-758f-4010-b177-9d7c7936610a
public double angle(Coordinate that) { double res = Math.acos(this.dot(that)/this.magnitude()/that.magnitude()); return this.cross(that) < 0? res: -res; }
00c2150c-d7eb-4def-9132-bc71e1d326ce
public Coordinate neg() { return new Coordinate(-this.x, -this.y); }
54b92f28-a89d-4f87-baab-a484736169a4
public Coordinate add(Coordinate that) { return new Coordinate(this.x+that.x, this.y+that.y); }
42a1932b-0b4d-4a17-b7aa-9ed1b69a88de
public Coordinate sub(Coordinate that) { return new Coordinate(this.x-that.x, this.y-that.y); }
f4bae85c-c9fe-4fd0-8be6-aa9277b645a7
public Coordinate scale(double scale) { return new Coordinate(scale*this.x, scale*this.y); }
6c7f6426-8c22-42cd-a9a5-6728ce0d016a
public Coordinate rotate(double angle) { return new Coordinate(this.x*Math.cos(angle)-this.y*Math.sin(angle), this.x*Math.sin(angle)+this.y*Math.cos(angle)); }
917f6d93-c357-40e1-92a3-f0b4e5ba7625
public double cross(Coordinate that) { return this.x*that.y - this.y*that.x; }
32c8d799-6b13-4efa-96ed-2cbbfd09e1a7
public double dot(Coordinate that) { return this.x*that.x + this.y*that.y; }
593773fa-42cc-4e27-9122-89cb6d05be81
public String toString() { return String.format("(%.2f,%.2f)", this.x, this.y); }
65253c9c-020e-4a30-9f42-7ea3552e7cb9
public boolean inAny(List<Polygon> polygons) { for(Polygon p: polygons) if(p.contains(this)) return true; return false; }
4c7dbda7-ef69-4483-8922-28a667f4c041
public static String circle(Coordinate center, double radius) { return String.format("G36*\nG01X%07dY%07dD02*\nG03X%07dY%07dI%07dJ%07dD01*\nG37*", (int)(center.x), (int)(center.y), (int)(center.x), (int)(center.y-radius), 0, (int)(radius) ); }
e1d8774c-f94d-4918-af8b-a0a29ddaa5c0
public static String hexagon(Coordinate center, double radius) { Coordinate corner = center.sub(Coordinate.Y.neg().scale(radius)); String res = "G36*\n" + String.format("X%dY%dD02*\n", (int)(corner.x), (int)(corner.y)); // for(int i=1; i<6; i++) { for(int i: new int[] {1,2,3,4,5}) { corner = corner.sub(center).rotate(Math.PI/3).add(center); res += String.format("X%07dY%07dD01*\n", (int)(corner.x), (int)(corner.y)); } res += "G37*"; return res; }
6040fd1f-4492-4ed8-a214-43e6fab254a7
public TableBean() { carsSmall = new ArrayList<Car>(); // ((Car) carsSmall).append(new Car("aa","bb","cc","dd")); carsSmall.add(new Car("aa","bb","cc","dd")); carsSmall.add(new Car("aa","xx","cc","dd")); populateRandomCars(carsSmall, 100); }
937fe7d8-c4f7-4082-88a1-0f79d5f93034
private void populateRandomCars(List<Car> list, int size) { for(int i = 0 ; i < size ; i++) list.add(new Car(getRandomModel(), getRandomYear(), getRandomManufacturer(), getRandomColor())); }
99608064-3666-46e4-aa69-190e0a9680eb
public List<Car> getCarsSmall() { return carsSmall; }
663e5bc9-a3cb-458b-9ae3-f4692e10341c
private String getRandomYear() { return (int) (Math.random() * 50 + 1960)+""; }
6b5b53d7-83d4-40ab-819b-b98a18909557
private String getRandomColor() { return colors[(int) (Math.random() * 10)]; }
f738fdc6-4d52-4cfa-b5b8-b7f23800df4c
private String getRandomManufacturer() { return manufacturers[(int) (Math.random() * 10)]; }
75be59f1-b17f-4d1b-b4b3-2df42ba84120
private String getRandomModel() { return UUID.randomUUID().toString().substring(0, 8); }
db099304-9a50-4f20-aab9-e6eb080c0e8f
public static void main(String args[]){ TableBean tb = new TableBean(); Iterator<Car> it = tb.carsSmall.iterator(); while(it.hasNext()){ System.out.println(it.next().getModel()); System.out.println(it.next().getColor()); System.out.println(it.next().getYear()); } }
950635d0-73a6-4a41-bb14-fd1805370e49
public LoanInfoTable() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException{ loanInfoList = new ArrayList(); Test1.getDataFromLeida(loanInfoList); Test1.getData(loanInfoList); }
a5b7ee75-f5e1-4ae9-be03-d0108d09ba7c
public List<LoanInfoBean> getLoanInfoList() { return loanInfoList; }
52c568be-88b7-4da7-bb19-2516d726cc3a
public void setLoanInfoList(List<LoanInfoBean> loanInfoList) { this.loanInfoList = loanInfoList; }
b964c775-7ad0-4cc5-a0c1-87da74ef4ee7
public Car(String model,String year,String manufacturer,String color){ this.color = color; this.manufacturer = manufacturer; this.model = model; this.year = year; }