1 | /*
|
---|
2 | * Class Conv
|
---|
3 | *
|
---|
4 | * USAGE: Methods for:
|
---|
5 | * Recasting variable type with exception throwing not present in standard java recasts
|
---|
6 | * Conversion of physical entities from one set of units to another
|
---|
7 | * Copying of an object
|
---|
8 | *
|
---|
9 | * WRITTEN BY: Dr Michael Thomas Flanagan
|
---|
10 | *
|
---|
11 | * DATE: April 2008
|
---|
12 | * AMENDED: September 2009, 9-20 January 2011
|
---|
13 | *
|
---|
14 | * DOCUMENTATION:
|
---|
15 | * See Michael Thomas Flanagan's Java library on-line web pages:
|
---|
16 | * http://www.ee.ucl.ac.uk/~mflanaga/java/
|
---|
17 | * http://www.ee.ucl.ac.uk/~mflanaga/java/Conv.html
|
---|
18 | *
|
---|
19 | * Copyright (c) 2011
|
---|
20 | *
|
---|
21 | * PERMISSION TO COPY:
|
---|
22 | * Permission to use, copy and modify this software and its documentation for
|
---|
23 | * NON-COMMERCIAL purposes is granted, without fee, provided that an acknowledgement
|
---|
24 | * to the author, Michael Thomas Flanagan at www.ee.ucl.ac.uk/~mflanaga, appears in all copies.
|
---|
25 | *
|
---|
26 | * Dr Michael Thomas Flanagan makes no representations about the suitability
|
---|
27 | * or fitness of the software for any or for a particular purpose.
|
---|
28 | * Michael Thomas Flanagan shall not be liable for any damages suffered
|
---|
29 | * as a result of using, modifying or distributing this software or its derivatives.
|
---|
30 | *
|
---|
31 | ***************************************************************************************/
|
---|
32 |
|
---|
33 | package agents.anac.y2015.agentBuyogV2.flanagan.math;
|
---|
34 |
|
---|
35 | import java.math.*;
|
---|
36 |
|
---|
37 | import agents.anac.y2015.agentBuyogV2.flanagan.analysis.ErrorProp;
|
---|
38 | import agents.anac.y2015.agentBuyogV2.flanagan.circuits.Phasor;
|
---|
39 | import agents.anac.y2015.agentBuyogV2.flanagan.complex.Complex;
|
---|
40 | import agents.anac.y2015.agentBuyogV2.flanagan.complex.ComplexErrorProp;
|
---|
41 | import agents.anac.y2015.agentBuyogV2.flanagan.complex.ComplexPoly;
|
---|
42 | import agents.anac.y2015.agentBuyogV2.flanagan.math.Fmath;
|
---|
43 | import agents.anac.y2015.agentBuyogV2.flanagan.math.Polynomial;
|
---|
44 |
|
---|
45 | import java.io.IOException;
|
---|
46 | import java.io.ByteArrayInputStream;
|
---|
47 | import java.io.ByteArrayOutputStream;
|
---|
48 | import java.io.ObjectOutputStream;
|
---|
49 | import java.io.ObjectInputStream;
|
---|
50 |
|
---|
51 |
|
---|
52 | public class Conv{
|
---|
53 |
|
---|
54 | private static int type = -1; // 0 double, 1 Double, 2 long, 3 Long, 4 float, 5 Float, 6 int, 7 Integer, 8 short, 9 Short, 10 byte, 11 Byte
|
---|
55 | // 12 BigDecimal, 13 BigInteger, 14 Complex, 15 Phasor, 16 char, 17 Character, 18 String
|
---|
56 | private static String[] typeName = {"double", "Double", "long", "Long", "float", "Float", "int", "Integer", "short", "Short", "byte", "Byte", "BigDecimal", "BigInteger", "Complex", "Phasor", "char", "Character", "String"};
|
---|
57 |
|
---|
58 | private static double max_float_as_double = (double)Float.MAX_VALUE;
|
---|
59 | private static double max_long_as_double = (double)Long.MAX_VALUE;
|
---|
60 | private static double max_long_as_float = (float)Long.MAX_VALUE;
|
---|
61 | private static double max_int_as_double = (double)Integer.MAX_VALUE;
|
---|
62 | private static double max_int_as_float = (float)Integer.MAX_VALUE;
|
---|
63 | private static double max_int_as_long = (long)Integer.MAX_VALUE;
|
---|
64 | private static double max_short_as_double = (double)Short.MAX_VALUE;
|
---|
65 | private static double max_short_as_long = (long)Short.MAX_VALUE;
|
---|
66 | private static double max_short_as_float = (float)Short.MAX_VALUE;
|
---|
67 | private static double max_short_as_int = (int)Short.MAX_VALUE;
|
---|
68 | private static double max_byte_as_double = (double)Byte.MAX_VALUE;
|
---|
69 | private static double max_byte_as_float = (float)Byte.MAX_VALUE;
|
---|
70 | private static double max_byte_as_long = (long)Byte.MAX_VALUE;
|
---|
71 | private static double max_byte_as_int = (int)Byte.MAX_VALUE;
|
---|
72 | private static double max_byte_as_short = (short)Byte.MAX_VALUE;
|
---|
73 |
|
---|
74 | private static boolean suppressMessage = false; // if true lack of precision messages are suppressed
|
---|
75 | private static boolean suppressMessageAM = false; // for use with ArrayMaths - allows suppression for all instances of ArrayMaths
|
---|
76 |
|
---|
77 | // CONSTRUCTORS
|
---|
78 | public Conv(){
|
---|
79 | }
|
---|
80 |
|
---|
81 | // LOSS OF PRECISION MESSAGE
|
---|
82 | // Suppress loss of precision messages
|
---|
83 | public static void suppressMessages(){
|
---|
84 | Conv.suppressMessage = true;
|
---|
85 | }
|
---|
86 |
|
---|
87 | // Restore loss of precision messages
|
---|
88 | public static void restoreMessages(){
|
---|
89 | if(!Conv.suppressMessageAM)Conv.suppressMessage = false;
|
---|
90 | }
|
---|
91 |
|
---|
92 | // For use of ArrayMaths - suppression for all ArrayMaths instances
|
---|
93 | public static void suppressMessagesAM(){
|
---|
94 | Conv.suppressMessageAM = true;
|
---|
95 | }
|
---|
96 |
|
---|
97 | // For use of ArrayMaths - restore total loss of precision messages
|
---|
98 | public static void restoreMessagesAM(){
|
---|
99 | Conv.suppressMessageAM = false;
|
---|
100 | }
|
---|
101 |
|
---|
102 | // RECAST
|
---|
103 | // double and Double -> . . .
|
---|
104 | public static float convert_double_to_float(double x){
|
---|
105 | if(x>max_float_as_double)throw new IllegalArgumentException("double is too large to be recast as float");
|
---|
106 | if(!suppressMessage)System.out.println("Class Conv: method convert_double_to_float: possible loss of precision");
|
---|
107 | return (new Double(x)).floatValue();
|
---|
108 | }
|
---|
109 |
|
---|
110 | public static Float convert_double_to_Float(double x){
|
---|
111 | if(x>max_float_as_double)throw new IllegalArgumentException("double is too large to be recast as float");
|
---|
112 | if(!suppressMessage)System.out.println("Class Conv: method convert_double_to_Float: possible loss of precision");
|
---|
113 | return new Float((new Double(x)).floatValue());
|
---|
114 | }
|
---|
115 |
|
---|
116 | public static float convert_Double_to_float(Double xx){
|
---|
117 | double x = xx.doubleValue();
|
---|
118 | if(x>max_float_as_double)throw new IllegalArgumentException("Double is too large to be recast as float");
|
---|
119 | if(!suppressMessage)System.out.println("Class Conv: method convert_Double_to_float: possible loss of precision");
|
---|
120 | return xx.floatValue();
|
---|
121 | }
|
---|
122 |
|
---|
123 | public static Float convert_Double_to_Float(Double xx){
|
---|
124 | double x = xx.doubleValue();
|
---|
125 | if(x>max_float_as_double)throw new IllegalArgumentException("Double is too large to be recast as Float");
|
---|
126 | if(!suppressMessage)System.out.println("Class Conv: method convert_Double_to_Float: possible loss of precision");
|
---|
127 | return new Float(x);
|
---|
128 | }
|
---|
129 |
|
---|
130 | public static long convert_double_to_long(double x){
|
---|
131 | if(x>max_long_as_double)throw new IllegalArgumentException("double is too large to be recast as long");
|
---|
132 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("double is not, arithmetically, an integer");
|
---|
133 | return (new Double(x)).longValue();
|
---|
134 | }
|
---|
135 |
|
---|
136 | public static Long convert_double_to_Long(double x){
|
---|
137 | if(x>max_long_as_double)throw new IllegalArgumentException("double is too large to be recast as long");
|
---|
138 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("double is not, arithmetically, an integer");
|
---|
139 | return new Long((new Double(x)).longValue());
|
---|
140 | }
|
---|
141 |
|
---|
142 | public static long convert_Double_to_long(Double xx){
|
---|
143 | double x = xx.doubleValue();
|
---|
144 | if(x>max_long_as_double)throw new IllegalArgumentException("Double is too large to be recast as long");
|
---|
145 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("Double is not, arithmetically, an integer");
|
---|
146 | return xx.longValue();
|
---|
147 | }
|
---|
148 |
|
---|
149 | public static Long convert_Double_to_Long(Double xx){
|
---|
150 | double x = xx.doubleValue();
|
---|
151 | if(x>max_long_as_double)throw new IllegalArgumentException("Double is too large to be recast as Long");
|
---|
152 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("Double is not, arithmetically, an integer");
|
---|
153 | return new Long(xx.longValue());
|
---|
154 | }
|
---|
155 |
|
---|
156 | public static int convert_double_to_int(double x){
|
---|
157 | if(x>max_int_as_double)throw new IllegalArgumentException("double is too large to be recast as int");
|
---|
158 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("double is not, arithmetically, an integer");
|
---|
159 | return (new Double(x)).intValue();
|
---|
160 | }
|
---|
161 |
|
---|
162 | public static Integer convert_double_to_Integer(double x){
|
---|
163 | if(x>max_int_as_double)throw new IllegalArgumentException("double is too large to be recast as int");
|
---|
164 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("double is not, arithmetically, an integer");
|
---|
165 | return new Integer((new Double(x)).intValue());
|
---|
166 | }
|
---|
167 |
|
---|
168 | public static int convert_Double_to_int(Double xx){
|
---|
169 | double x = xx.doubleValue();
|
---|
170 | if(x>max_int_as_double)throw new IllegalArgumentException("Double is too large to be recast as int");
|
---|
171 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("Double is not, arithmetically, an integer");
|
---|
172 | return xx.intValue();
|
---|
173 | }
|
---|
174 |
|
---|
175 | public static Integer convert_Double_to_Integer(Double xx){
|
---|
176 | double x = xx.doubleValue();
|
---|
177 | if(x>max_int_as_double)throw new IllegalArgumentException("Double is too large to be recast as Integer");
|
---|
178 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("Double is not, arithmetically, an integer");
|
---|
179 | return new Integer(xx.intValue());
|
---|
180 | }
|
---|
181 |
|
---|
182 | public static short convert_double_to_short(double x){
|
---|
183 | if(x>max_short_as_double)throw new IllegalArgumentException("double is too large to be recast as short");
|
---|
184 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("double is not, arithmetically, an integer");
|
---|
185 | return (new Double(x)).shortValue();
|
---|
186 | }
|
---|
187 |
|
---|
188 | public static Short convert_double_to_Short(double x){
|
---|
189 | if(x>max_short_as_double)throw new IllegalArgumentException("double is too large to be recast as short");
|
---|
190 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("double is not, arithmetically, an integer");
|
---|
191 | return new Short((new Double(x)).shortValue());
|
---|
192 | }
|
---|
193 |
|
---|
194 | public static short convert_Double_to_short(Double xx){
|
---|
195 | double x = xx.doubleValue();
|
---|
196 | if(x>max_short_as_double)throw new IllegalArgumentException("Double is too large to be recast as short");
|
---|
197 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("Double is not, arithmetically, an integer");
|
---|
198 | return xx.shortValue();
|
---|
199 | }
|
---|
200 |
|
---|
201 | public static Short convert_Double_to_Short(Double xx){
|
---|
202 | double x = xx.doubleValue();
|
---|
203 | if(x>max_short_as_double)throw new IllegalArgumentException("Double is too large to be recast as Short");
|
---|
204 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("Double is not, arithmetically, an integer");
|
---|
205 | return new Short(xx.shortValue());
|
---|
206 | }
|
---|
207 |
|
---|
208 | public static byte convert_double_to_byte(double x){
|
---|
209 | if(x>max_byte_as_double)throw new IllegalArgumentException("double is too large to be recast as byte");
|
---|
210 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("double is not, arithmetically, an integer");
|
---|
211 | return (new Double(x)).byteValue();
|
---|
212 | }
|
---|
213 |
|
---|
214 | public static Byte convert_double_to_Byte(double x){
|
---|
215 | if(x>max_byte_as_double)throw new IllegalArgumentException("double is too large to be recast as byte");
|
---|
216 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("double is not, arithmetically, an integer");
|
---|
217 | return new Byte((new Double(x)).byteValue());
|
---|
218 | }
|
---|
219 |
|
---|
220 | public static byte convert_Double_to_byte(Double xx){
|
---|
221 | double x = xx.doubleValue();
|
---|
222 | if(x>max_byte_as_double)throw new IllegalArgumentException("Double is too large to be recast as byte");
|
---|
223 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("Double is not, arithmetically, an integer");
|
---|
224 | return xx.byteValue();
|
---|
225 | }
|
---|
226 |
|
---|
227 | public static Byte convert_Double_to_Byte(Double xx){
|
---|
228 | double x = xx.doubleValue();
|
---|
229 | if(x>max_byte_as_double)throw new IllegalArgumentException("Double is too large to be recast as Byte");
|
---|
230 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("Double is not, arithmetically, an integer");
|
---|
231 | return new Byte(xx.byteValue());
|
---|
232 | }
|
---|
233 |
|
---|
234 | public static BigDecimal convert_double_to_BigDecimal(double x){
|
---|
235 | return new BigDecimal(x);
|
---|
236 | }
|
---|
237 |
|
---|
238 | public static BigDecimal convert_Double_to_BigDecimal(Double xx){
|
---|
239 | return new BigDecimal(xx.doubleValue());
|
---|
240 | }
|
---|
241 |
|
---|
242 | public static BigInteger convert_double_to_BigInteger(double x){
|
---|
243 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("double is not, arithmetically, an integer");
|
---|
244 | return new BigInteger(Double.toString(x));
|
---|
245 | }
|
---|
246 |
|
---|
247 | public static BigInteger convert_Double_to_BigInteger(Double xx){
|
---|
248 | double x = xx.doubleValue();
|
---|
249 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("double is not, arithmetically, an integer");
|
---|
250 | return new BigInteger(Double.toString(x));
|
---|
251 | }
|
---|
252 |
|
---|
253 | // float and Float -> . . .
|
---|
254 | public static double convert_float_to_double(float x){
|
---|
255 | return (new Float(x)).doubleValue();
|
---|
256 | }
|
---|
257 |
|
---|
258 | public static Double convert_float_to_Double(float x){
|
---|
259 | return new Double((new Float(x)).doubleValue());
|
---|
260 | }
|
---|
261 |
|
---|
262 | public static double convert_Float_to_double(Float xx){
|
---|
263 | return xx.doubleValue();
|
---|
264 | }
|
---|
265 |
|
---|
266 | public static Double convert_Float_to_Double(Float xx){
|
---|
267 | return new Double(xx.doubleValue());
|
---|
268 | }
|
---|
269 |
|
---|
270 | public static long convert_float_to_long(float x){
|
---|
271 | if(x>max_long_as_float)throw new IllegalArgumentException("float is too large to be recast as long");
|
---|
272 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("float is not, arithmetically, an integer");
|
---|
273 | return (new Float(x)).longValue();
|
---|
274 | }
|
---|
275 |
|
---|
276 | public static Long convert_float_to_Long(float x){
|
---|
277 | if(x>max_long_as_float)throw new IllegalArgumentException("float is too large to be recast as long");
|
---|
278 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("float is not, arithmetically, an integer");
|
---|
279 | return new Long((new Float(x)).longValue());
|
---|
280 | }
|
---|
281 |
|
---|
282 | public static long convert_Float_to_long(Float xx){
|
---|
283 | float x = xx.floatValue();
|
---|
284 | if(x>max_long_as_float)throw new IllegalArgumentException("Float is too large to be recast as long");
|
---|
285 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("Float is not, arithmetically, an integer");
|
---|
286 | return xx.longValue();
|
---|
287 | }
|
---|
288 |
|
---|
289 | public static Long convert_Float_to_Long(Float xx){
|
---|
290 | float x = xx.floatValue();
|
---|
291 | if(x>max_long_as_float)throw new IllegalArgumentException("Float is too large to be recast as Long");
|
---|
292 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("Float is not, arithmetically, an integer");
|
---|
293 | return new Long(xx.longValue());
|
---|
294 | }
|
---|
295 |
|
---|
296 | public static int convert_float_to_int(float x){
|
---|
297 | if(x>max_int_as_float)throw new IllegalArgumentException("double is too large to be recast as int");
|
---|
298 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("double is not, arithmetically, an integer");
|
---|
299 | return (new Float(x)).intValue();
|
---|
300 | }
|
---|
301 |
|
---|
302 | public static Integer convert_float_to_Integer(float x){
|
---|
303 | if(x>max_int_as_float)throw new IllegalArgumentException("float is too large to be recast as int");
|
---|
304 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("float is not, arithmetically, an integer");
|
---|
305 | return new Integer((new Float(x)).intValue());
|
---|
306 | }
|
---|
307 |
|
---|
308 | public static int convert_Float_to_int(Float xx){
|
---|
309 | float x = xx.floatValue();
|
---|
310 | if(x>max_int_as_float)throw new IllegalArgumentException("Float is too large to be recast as int");
|
---|
311 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("Float is not, arithmetically, an integer");
|
---|
312 | return xx.intValue();
|
---|
313 | }
|
---|
314 |
|
---|
315 | public static Integer convert_Float_to_Integer(Float xx){
|
---|
316 | float x = xx.floatValue();
|
---|
317 | if(x>max_int_as_float)throw new IllegalArgumentException("Float is too large to be recast as Integer");
|
---|
318 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("Float is not, arithmetically, an integer");
|
---|
319 | return new Integer(xx.intValue());
|
---|
320 | }
|
---|
321 |
|
---|
322 | public static short convert_float_to_short(float x){
|
---|
323 | if(x>max_short_as_float)throw new IllegalArgumentException("float is too large to be recast as short");
|
---|
324 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("float is not, arithmetically, an integer");
|
---|
325 | return (new Float(x)).shortValue();
|
---|
326 | }
|
---|
327 |
|
---|
328 | public static Short convert_float_to_Short(float x){
|
---|
329 | if(x>max_short_as_float)throw new IllegalArgumentException("float is too large to be recast as short");
|
---|
330 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("float is not, arithmetically, an integer");
|
---|
331 | return new Short((new Float(x)).shortValue());
|
---|
332 | }
|
---|
333 |
|
---|
334 | public static short convert_Float_to_short(Float xx){
|
---|
335 | float x = xx.floatValue();
|
---|
336 | if(x>max_short_as_float)throw new IllegalArgumentException("Float is too large to be recast as short");
|
---|
337 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("Float is not, arithmetically, an integer");
|
---|
338 | return xx.shortValue();
|
---|
339 | }
|
---|
340 |
|
---|
341 | public static Short convert_Float_to_Short(Float xx){
|
---|
342 | float x = xx.floatValue();
|
---|
343 | if(x>max_short_as_float)throw new IllegalArgumentException("Float is too large to be recast as Short");
|
---|
344 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("Float is not, arithmetically, an integer");
|
---|
345 | return new Short(xx.shortValue());
|
---|
346 | }
|
---|
347 |
|
---|
348 | public static byte convert_float_to_byte(float x){
|
---|
349 | if(x>max_byte_as_float)throw new IllegalArgumentException("float is too large to be recast as byte");
|
---|
350 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("float is not, arithmetically, an integer");
|
---|
351 | return (new Float(x)).byteValue();
|
---|
352 | }
|
---|
353 |
|
---|
354 | public static Byte convert_float_to_Byte(float x){
|
---|
355 | if(x>max_byte_as_float)throw new IllegalArgumentException("float is too large to be recast as byte");
|
---|
356 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("float is not, arithmetically, an integer");
|
---|
357 | return new Byte((new Float(x)).byteValue());
|
---|
358 | }
|
---|
359 |
|
---|
360 | public static byte convert_Float_to_byte(Float xx){
|
---|
361 | float x = xx.floatValue();
|
---|
362 | if(x>max_byte_as_float)throw new IllegalArgumentException("Float is too large to be recast as byte");
|
---|
363 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("Float is not, arithmetically, an integer");
|
---|
364 | return xx.byteValue();
|
---|
365 | }
|
---|
366 |
|
---|
367 | public static Byte convert_Float_to_Byte(Float xx){
|
---|
368 | float x = xx.floatValue();
|
---|
369 | if(x>max_byte_as_float)throw new IllegalArgumentException("Float is too large to be recast as Byte");
|
---|
370 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("Float is not, arithmetically, an integer");
|
---|
371 | return new Byte(xx.byteValue());
|
---|
372 | }
|
---|
373 |
|
---|
374 | public static BigDecimal convert_float_to_BigDecimal(float x){
|
---|
375 | return new BigDecimal((double)x);
|
---|
376 | }
|
---|
377 |
|
---|
378 | public static BigDecimal convert_Float_to_BigDecimal(Float xx){
|
---|
379 | return new BigDecimal(xx.doubleValue());
|
---|
380 | }
|
---|
381 |
|
---|
382 | public static BigInteger convert_double_to_BigInteger(float x){
|
---|
383 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("float is not, arithmetically, an integer");
|
---|
384 | return new BigInteger(Float.toString(x));
|
---|
385 | }
|
---|
386 |
|
---|
387 | public static BigInteger convert_Float_to_BigInteger(Float xx){
|
---|
388 | double x = xx.doubleValue();
|
---|
389 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("Float is not, arithmetically, an integer");
|
---|
390 | return new BigInteger(Double.toString(x));
|
---|
391 | }
|
---|
392 |
|
---|
393 |
|
---|
394 | // long and Long -> . . .
|
---|
395 | public static double convert_long_to_double(long x){
|
---|
396 | if(!suppressMessage)System.out.println("Class Conv: method convert_long_to_double: possible loss of precision");
|
---|
397 | return (new Long(x)).doubleValue();
|
---|
398 | }
|
---|
399 |
|
---|
400 | public static Double convert_long_to_Double(long x){
|
---|
401 | if(!suppressMessage)System.out.println("Class Conv: method convert_long_to_Double: possible loss of precision");
|
---|
402 | return new Double((new Long(x)).doubleValue());
|
---|
403 | }
|
---|
404 |
|
---|
405 | public static double convert_Long_to_double(Long xx){
|
---|
406 | if(!suppressMessage)System.out.println("Class Conv: method convert_Long_to_double: possible loss of precision");
|
---|
407 | return xx.doubleValue();
|
---|
408 | }
|
---|
409 |
|
---|
410 | public static Double convert_Long_to_Double(Long xx){
|
---|
411 | if(!suppressMessage)System.out.println("Class Conv: method convert_Long_to_Double: possible loss of precision");
|
---|
412 | return new Double(xx.doubleValue());
|
---|
413 | }
|
---|
414 |
|
---|
415 | public static float convert_long_to_float(long x){
|
---|
416 | if(!suppressMessage)System.out.println("Class Conv: method convert_long_to_float: possible loss of precision");
|
---|
417 | return (new Long(x)).floatValue();
|
---|
418 | }
|
---|
419 |
|
---|
420 | public static Float convert_long_to_Float(long x){
|
---|
421 | if(!suppressMessage)System.out.println("Class Conv: method convert_long_to_Float: possible loss of precision");
|
---|
422 | return new Float((new Long(x)).floatValue());
|
---|
423 | }
|
---|
424 |
|
---|
425 | public static float convert_Long_to_float(Long xx){
|
---|
426 | if(!suppressMessage)System.out.println("Class Conv: method convert_Long_to_float: possible loss of precision");
|
---|
427 | return xx.floatValue();
|
---|
428 | }
|
---|
429 |
|
---|
430 | public static Float convert_Long_to_Float(Long xx){
|
---|
431 | if(!suppressMessage)System.out.println("Class Conv: method convert_Long_to_Float: possible loss of precision");
|
---|
432 | return new Float(xx.floatValue());
|
---|
433 | }
|
---|
434 |
|
---|
435 | public static int convert_long_to_int(long x){
|
---|
436 | if(x>max_int_as_long)throw new IllegalArgumentException("long is too large to be recast as int");
|
---|
437 | return (new Float(x)).intValue();
|
---|
438 | }
|
---|
439 |
|
---|
440 | public static Integer convert_long_to_Integer(long x){
|
---|
441 | if(x>max_int_as_long)throw new IllegalArgumentException("long is too large to be recast as Integer");
|
---|
442 | return new Integer((new Long(x)).intValue());
|
---|
443 | }
|
---|
444 |
|
---|
445 | public static int convert_Long_to_int(Long xx){
|
---|
446 | long x = xx.longValue();
|
---|
447 | if(x>max_int_as_long)throw new IllegalArgumentException("Long is too large to be recast as int");
|
---|
448 | return xx.intValue();
|
---|
449 | }
|
---|
450 |
|
---|
451 | public static Integer convert_Long_to_Integer(Long xx){
|
---|
452 | long x = xx.longValue();
|
---|
453 | if(x>max_int_as_long)throw new IllegalArgumentException("Long is too large to be recast as Integer");
|
---|
454 | return new Integer(xx.intValue());
|
---|
455 | }
|
---|
456 |
|
---|
457 | public static short convert_long_to_short(long x){
|
---|
458 | if(x>max_short_as_long)throw new IllegalArgumentException("long is too large to be recast as short");
|
---|
459 | return (new Long(x)).shortValue();
|
---|
460 | }
|
---|
461 |
|
---|
462 | public static Short convert_long_to_Short(long x){
|
---|
463 | if(x>max_short_as_long)throw new IllegalArgumentException("long is too large to be recast as Short");
|
---|
464 | return new Short((new Long(x)).shortValue());
|
---|
465 | }
|
---|
466 |
|
---|
467 | public static short convert_Long_to_short(Long xx){
|
---|
468 | long x = xx.longValue();
|
---|
469 | if(x>max_short_as_long)throw new IllegalArgumentException("Long is too large to be recast as short");
|
---|
470 | return xx.shortValue();
|
---|
471 | }
|
---|
472 |
|
---|
473 | public static Short convert_Long_to_Short(Long xx){
|
---|
474 | long x = xx.longValue();
|
---|
475 | if(x>max_short_as_long)throw new IllegalArgumentException("Long is too large to be recast as Short");
|
---|
476 | return new Short(xx.shortValue());
|
---|
477 | }
|
---|
478 |
|
---|
479 | public static byte convert_long_to_byte(long x){
|
---|
480 | if(x>max_byte_as_long)throw new IllegalArgumentException("long is too large to be recast as byte");
|
---|
481 | return (new Long(x)).byteValue();
|
---|
482 | }
|
---|
483 |
|
---|
484 | public static Byte convert_long_to_Byte(long x){
|
---|
485 | if(x>max_byte_as_long)throw new IllegalArgumentException("long is too large to be recast as Byte");
|
---|
486 | return new Byte((new Long(x)).byteValue());
|
---|
487 | }
|
---|
488 |
|
---|
489 | public static byte convert_Long_to_byte(Long xx){
|
---|
490 | long x = xx.longValue();
|
---|
491 | if(x>max_byte_as_long)throw new IllegalArgumentException("Long is too large to be recast as byte");
|
---|
492 | return xx.byteValue();
|
---|
493 | }
|
---|
494 |
|
---|
495 | public static Byte convert_Long_to_Byte(Long xx){
|
---|
496 | long x = xx.longValue();
|
---|
497 | if(x>max_byte_as_long)throw new IllegalArgumentException("Long is too large to be recast as Byte");
|
---|
498 | return new Byte(xx.byteValue());
|
---|
499 | }
|
---|
500 |
|
---|
501 | public static BigDecimal convert_long_to_BigDecimal(long x){
|
---|
502 | return new BigDecimal((new Long(x)).toString());
|
---|
503 | }
|
---|
504 |
|
---|
505 | public static BigDecimal convert_Long_to_BigDecimal(Long xx){
|
---|
506 | return new BigDecimal(xx.toString());
|
---|
507 | }
|
---|
508 |
|
---|
509 | public static BigInteger convert_long_to_BigInteger(long x){
|
---|
510 | return new BigInteger(Long.toString(x));
|
---|
511 | }
|
---|
512 |
|
---|
513 | public static BigInteger convert_Long_to_BigInteger(Long xx){
|
---|
514 | double x = xx.doubleValue();
|
---|
515 | return new BigInteger(xx.toString());
|
---|
516 | }
|
---|
517 |
|
---|
518 | // int and Integer -> . . .
|
---|
519 | public static double convert_int_to_double(int x){
|
---|
520 | return (new Integer(x)).doubleValue();
|
---|
521 | }
|
---|
522 |
|
---|
523 | public static Double convert_int_to_Double(int x){
|
---|
524 | return new Double((new Integer(x)).doubleValue());
|
---|
525 | }
|
---|
526 |
|
---|
527 | public static double convert_Integer_to_double(Integer xx){
|
---|
528 | return xx.doubleValue();
|
---|
529 | }
|
---|
530 |
|
---|
531 | public static Double convert_Integer_to_Double(Integer xx){
|
---|
532 | return new Double(xx.doubleValue());
|
---|
533 | }
|
---|
534 |
|
---|
535 | public static float convert_int_to_float(int x){
|
---|
536 | if(!suppressMessage)System.out.println("Class Conv: method convert_int_to_float: possible loss of precision");
|
---|
537 | return (new Integer(x)).floatValue();
|
---|
538 | }
|
---|
539 |
|
---|
540 | public static Float convert_int_to_Float(int x){
|
---|
541 | if(!suppressMessage)System.out.println("Class Conv: method convert_int_to_Float: possible loss of precision");
|
---|
542 | return new Float((new Integer(x)).floatValue());
|
---|
543 | }
|
---|
544 |
|
---|
545 | public static float convert_Integer_to_float(Integer xx){
|
---|
546 | if(!suppressMessage)System.out.println("Class Conv: method convert_Integer_to_float: possible loss of precision");
|
---|
547 | return xx.floatValue();
|
---|
548 | }
|
---|
549 |
|
---|
550 | public static Float convert_Integer_to_Float(Integer xx){
|
---|
551 | if(!suppressMessage)System.out.println("Class Conv: method convert_Integer_to_Float: possible loss of precision");
|
---|
552 | return new Float(xx.floatValue());
|
---|
553 | }
|
---|
554 |
|
---|
555 | public static long convert_int_to_long(int x){
|
---|
556 | return (new Integer(x)).longValue();
|
---|
557 | }
|
---|
558 |
|
---|
559 | public static Long convert_int_to_Long(int x){
|
---|
560 | return new Long((new Integer(x)).longValue());
|
---|
561 | }
|
---|
562 |
|
---|
563 | public static long convert_Integer_to_long(Integer xx){
|
---|
564 | return xx.longValue();
|
---|
565 | }
|
---|
566 |
|
---|
567 | public static Long convert_Integer_to_Long(Integer xx){
|
---|
568 | return new Long(xx.longValue());
|
---|
569 | }
|
---|
570 |
|
---|
571 | public static short convert_int_to_short(int x){
|
---|
572 | if(x>max_short_as_int)throw new IllegalArgumentException("int is too large to be recast as short");
|
---|
573 | return (new Integer(x)).shortValue();
|
---|
574 | }
|
---|
575 |
|
---|
576 | public static Short convert_int_to_Short(int x){
|
---|
577 | if(x>max_short_as_int)throw new IllegalArgumentException("int is too large to be recast as Short");
|
---|
578 | return new Short((new Integer(x)).shortValue());
|
---|
579 | }
|
---|
580 |
|
---|
581 | public static short convert_Integer_to_short(Integer xx){
|
---|
582 | int x = xx.intValue();
|
---|
583 | if(x>max_short_as_int)throw new IllegalArgumentException("Integer is too large to be recast as short");
|
---|
584 | return xx.shortValue();
|
---|
585 | }
|
---|
586 |
|
---|
587 | public static Short convert_Integer_to_Short(Integer xx){
|
---|
588 | int x = xx.intValue();
|
---|
589 | if(x>max_short_as_int)throw new IllegalArgumentException("Integer is too large to be recast as Short");
|
---|
590 | return new Short(xx.shortValue());
|
---|
591 | }
|
---|
592 |
|
---|
593 | public static byte convert_int_to_byte(int x){
|
---|
594 | if(x>max_byte_as_int)throw new IllegalArgumentException("int is too large to be recast as byte");
|
---|
595 | return (new Integer(x)).byteValue();
|
---|
596 | }
|
---|
597 |
|
---|
598 | public static Byte convert_int_to_Byte(int x){
|
---|
599 | if(x>max_byte_as_int)throw new IllegalArgumentException("int is too large to be recast as Byte");
|
---|
600 | return new Byte((new Integer(x)).byteValue());
|
---|
601 | }
|
---|
602 |
|
---|
603 | public static byte convert_Integer_to_byte(Integer xx){
|
---|
604 | int x = xx.intValue();
|
---|
605 | if(x>max_byte_as_int)throw new IllegalArgumentException("Integer is too large to be recast as byte");
|
---|
606 | return xx.byteValue();
|
---|
607 | }
|
---|
608 |
|
---|
609 | public static Byte convert_Integer_to_Byte(Integer xx){
|
---|
610 | int x = xx.intValue();
|
---|
611 | if(x>max_byte_as_int)throw new IllegalArgumentException("Integer is too large to be recast as Byte");
|
---|
612 | return new Byte(xx.byteValue());
|
---|
613 | }
|
---|
614 |
|
---|
615 | public static BigDecimal convert_int_to_BigDecimal(int x){
|
---|
616 | return new BigDecimal((new Integer(x)).toString());
|
---|
617 | }
|
---|
618 |
|
---|
619 | public static BigDecimal convert_Integer_to_BigDecimal(Integer xx){
|
---|
620 | return new BigDecimal(xx.toString());
|
---|
621 | }
|
---|
622 |
|
---|
623 | public static BigInteger convert_int_to_BigInteger(int x){
|
---|
624 | return new BigInteger(Long.toString(x));
|
---|
625 | }
|
---|
626 |
|
---|
627 | public static BigInteger convert_Integer_to_BigInteger(Integer xx){
|
---|
628 | return new BigInteger(xx.toString());
|
---|
629 | }
|
---|
630 |
|
---|
631 | // short and Short -> . . .
|
---|
632 | public static double convert_short_to_double(short x){
|
---|
633 | return (new Short(x)).doubleValue();
|
---|
634 | }
|
---|
635 |
|
---|
636 | public static Double convert_short_to_Double(short x){
|
---|
637 | return new Double((new Short(x)).doubleValue());
|
---|
638 | }
|
---|
639 |
|
---|
640 | public static double convert_Short_to_double(Short xx){
|
---|
641 | return xx.doubleValue();
|
---|
642 | }
|
---|
643 |
|
---|
644 | public static Double convert_Short_to_Double(Short xx){
|
---|
645 | return new Double(xx.doubleValue());
|
---|
646 | }
|
---|
647 |
|
---|
648 | public static float convert_short_to_float(short x){
|
---|
649 | return (new Short(x)).floatValue();
|
---|
650 | }
|
---|
651 |
|
---|
652 | public static Float convert_short_to_Float(short x){
|
---|
653 | return new Float((new Short(x)).floatValue());
|
---|
654 | }
|
---|
655 |
|
---|
656 | public static float convert_Short_to_float(Short xx){
|
---|
657 | return xx.floatValue();
|
---|
658 | }
|
---|
659 |
|
---|
660 | public static Float convert_Short_to_Float(Short xx){
|
---|
661 | return new Float(xx.floatValue());
|
---|
662 | }
|
---|
663 |
|
---|
664 | public static long convert_short_to_long(short x){
|
---|
665 | return (new Short(x)).longValue();
|
---|
666 | }
|
---|
667 |
|
---|
668 | public static Long convert_short_to_Long(short x){
|
---|
669 | return new Long((new Short(x)).longValue());
|
---|
670 | }
|
---|
671 |
|
---|
672 | public static long convert_Short_to_long(Short xx){
|
---|
673 | return xx.longValue();
|
---|
674 | }
|
---|
675 |
|
---|
676 | public static Long convert_Short_to_Long(Short xx){
|
---|
677 | return new Long(xx.longValue());
|
---|
678 | }
|
---|
679 |
|
---|
680 | public static int convert_short_to_int(short x){
|
---|
681 | return (new Short(x)).intValue();
|
---|
682 | }
|
---|
683 |
|
---|
684 | public static Integer convert_short_to_Integer(short x){
|
---|
685 | return new Integer((new Short(x)).intValue());
|
---|
686 | }
|
---|
687 |
|
---|
688 | public static int convert_Short_to_int(Short xx){
|
---|
689 | return xx.intValue();
|
---|
690 | }
|
---|
691 |
|
---|
692 | public static Integer convert_Short_to_Integer(Short xx){
|
---|
693 | return new Integer(xx.intValue());
|
---|
694 | }
|
---|
695 |
|
---|
696 | public static byte convert_short_to_byte(short x){
|
---|
697 | if(x>max_byte_as_short)throw new IllegalArgumentException("short is too large to be recast as byte");
|
---|
698 | return (new Short(x)).byteValue();
|
---|
699 | }
|
---|
700 |
|
---|
701 | public static Byte convert_short_to_Byte(short x){
|
---|
702 | if(x>max_byte_as_short)throw new IllegalArgumentException("short is too large to be recast as Byte");
|
---|
703 | return new Byte((new Short(x)).byteValue());
|
---|
704 | }
|
---|
705 |
|
---|
706 | public static byte convert_Short_to_byte(Short xx){
|
---|
707 | int x = xx.shortValue();
|
---|
708 | if(x>max_byte_as_short)throw new IllegalArgumentException("Short is too large to be recast as byte");
|
---|
709 | return xx.byteValue();
|
---|
710 | }
|
---|
711 |
|
---|
712 | public static Byte convert_Short_to_Byte(Short xx){
|
---|
713 | int x = xx.shortValue();
|
---|
714 | if(x>max_byte_as_short)throw new IllegalArgumentException("Short is too large to be recast as Byte");
|
---|
715 | return new Byte(xx.byteValue());
|
---|
716 | }
|
---|
717 |
|
---|
718 | public static BigDecimal convert_short_to_BigDecimal(short x){
|
---|
719 | return new BigDecimal((new Short(x)).toString());
|
---|
720 | }
|
---|
721 |
|
---|
722 | public static BigDecimal convert_Short_to_BigDecimal(Short xx){
|
---|
723 | return new BigDecimal(xx.toString());
|
---|
724 | }
|
---|
725 |
|
---|
726 | public static BigInteger convert_short_to_BigInteger(short x){
|
---|
727 | return new BigInteger(Short.toString(x));
|
---|
728 | }
|
---|
729 |
|
---|
730 | public static BigInteger convert_Short_to_BigInteger(Short xx){
|
---|
731 | return new BigInteger(xx.toString());
|
---|
732 | }
|
---|
733 |
|
---|
734 | // byte and Byte -> . . .
|
---|
735 | public static double convert_byte_to_double(byte x){
|
---|
736 | return (new Byte(x)).doubleValue();
|
---|
737 | }
|
---|
738 |
|
---|
739 | public static Double convert_byte_to_Double(byte x){
|
---|
740 | return new Double((new Byte(x)).doubleValue());
|
---|
741 | }
|
---|
742 |
|
---|
743 | public static double convert_Byte_to_double(Byte xx){
|
---|
744 | return xx.doubleValue();
|
---|
745 | }
|
---|
746 |
|
---|
747 | public static Double convert_Byte_to_Double(Byte xx){
|
---|
748 | return new Double(xx.doubleValue());
|
---|
749 | }
|
---|
750 |
|
---|
751 | public static float convert_byte_to_float(byte x){
|
---|
752 | return (new Byte(x)).floatValue();
|
---|
753 | }
|
---|
754 |
|
---|
755 | public static Float convert_byte_to_Float(byte x){
|
---|
756 | return new Float((new Byte(x)).floatValue());
|
---|
757 | }
|
---|
758 |
|
---|
759 | public static float convert_Byte_to_float(Byte xx){
|
---|
760 | return xx.floatValue();
|
---|
761 | }
|
---|
762 |
|
---|
763 | public static Float convert_Byte_to_Float(Byte xx){
|
---|
764 | return new Float(xx.floatValue());
|
---|
765 | }
|
---|
766 |
|
---|
767 | public static long convert_byte_to_long(byte x){
|
---|
768 | return (new Byte(x)).longValue();
|
---|
769 | }
|
---|
770 |
|
---|
771 | public static Long convert_byte_to_Long(byte x){
|
---|
772 | return new Long((new Byte(x)).longValue());
|
---|
773 | }
|
---|
774 |
|
---|
775 | public static long convert_Byte_to_long(Byte xx){
|
---|
776 | return xx.longValue();
|
---|
777 | }
|
---|
778 |
|
---|
779 | public static Long convert_Byte_to_Long(Byte xx){
|
---|
780 | return new Long(xx.longValue());
|
---|
781 | }
|
---|
782 |
|
---|
783 | public static int convert_byte_to_int(byte x){
|
---|
784 | return (new Byte(x)).intValue();
|
---|
785 | }
|
---|
786 |
|
---|
787 | public static Integer convert_byte_to_Integer(byte x){
|
---|
788 | return new Integer((new Byte(x)).intValue());
|
---|
789 | }
|
---|
790 |
|
---|
791 | public static int convert_Byte_to_int(Byte xx){
|
---|
792 | return xx.intValue();
|
---|
793 | }
|
---|
794 |
|
---|
795 | public static Integer convert_Byte_to_Integer(Byte xx){
|
---|
796 | return new Integer(xx.intValue());
|
---|
797 | }
|
---|
798 |
|
---|
799 | public static short convert_byte_to_short(byte x){
|
---|
800 | return (new Byte(x)).shortValue();
|
---|
801 | }
|
---|
802 |
|
---|
803 | public static Short convert_byte_to_Short(byte x){
|
---|
804 | return new Short((new Byte(x)).shortValue());
|
---|
805 | }
|
---|
806 |
|
---|
807 | public static short convert_Byte_to_short(Byte xx){
|
---|
808 | return xx.shortValue();
|
---|
809 | }
|
---|
810 |
|
---|
811 | public static Short convert_Byte_to_Short(Byte xx){
|
---|
812 | return new Short(xx.shortValue());
|
---|
813 | }
|
---|
814 |
|
---|
815 | public static BigDecimal convert_byte_to_BigDecimal(byte x){
|
---|
816 | return new BigDecimal((new Byte(x)).toString());
|
---|
817 | }
|
---|
818 |
|
---|
819 | public static BigDecimal convert_Byte_to_BigDecimal(Byte xx){
|
---|
820 | return new BigDecimal(xx.toString());
|
---|
821 | }
|
---|
822 |
|
---|
823 | public static BigInteger convert_byte_to_BigInteger(byte x){
|
---|
824 | return new BigInteger(Byte.toString(x));
|
---|
825 | }
|
---|
826 |
|
---|
827 | public static BigInteger convert_Byte_to_BigInteger(Byte xx){
|
---|
828 | return new BigInteger(xx.toString());
|
---|
829 | }
|
---|
830 |
|
---|
831 |
|
---|
832 | // BigDecimal -> . . .
|
---|
833 | public static double convert_BigDecimal_to_double(BigDecimal xx){
|
---|
834 | double x = xx.doubleValue();
|
---|
835 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigDecimal is too large to be recast as double");
|
---|
836 | if(!suppressMessage)System.out.println("Class Conv: method convert_BigDecimal_to_double: possible loss of precision");
|
---|
837 | return x;
|
---|
838 | }
|
---|
839 |
|
---|
840 | public static Double convert_BigDecimal_to_Double(BigDecimal xx){
|
---|
841 | double x = xx.doubleValue();
|
---|
842 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigDecimal is too large to be recast as double");
|
---|
843 | if(!suppressMessage)System.out.println("Class Conv: method convert_BigDecimal_to_double: possible loss of precision");
|
---|
844 | return new Double(x);
|
---|
845 | }
|
---|
846 |
|
---|
847 | public static float convert_BigDecimal_to_float(BigDecimal xx){
|
---|
848 | float x = xx.floatValue();
|
---|
849 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigDecimal is too large to be recast as float");
|
---|
850 | if(!suppressMessage)System.out.println("Class Conv: method convert_BigDecimal_to_float: possible loss of precision");
|
---|
851 | return x;
|
---|
852 | }
|
---|
853 |
|
---|
854 | public static Float convert_BigDecimal_to_Float(BigDecimal xx){
|
---|
855 | float x = xx.floatValue();
|
---|
856 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigDecimal is too large to be recast as float");
|
---|
857 | if(!suppressMessage)System.out.println("Class Conv: method convert_BigDecimal_to_float: possible loss of precision");
|
---|
858 | return new Float(x);
|
---|
859 | }
|
---|
860 |
|
---|
861 | public static long convert_BigDecimal_to_long(BigDecimal xx){
|
---|
862 | double x = xx.doubleValue();
|
---|
863 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigDecimal is too large to be recast as long");
|
---|
864 | if(x>max_long_as_double)throw new IllegalArgumentException("BigDecimal is too large to be recast as long");
|
---|
865 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("BigDecimal is not, arithmetically, an integer");
|
---|
866 | return xx.longValue();
|
---|
867 | }
|
---|
868 |
|
---|
869 | public static Long convert_BigDecimal_to_Long(BigDecimal xx){
|
---|
870 | double x = xx.doubleValue();
|
---|
871 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigDecimal is too large to be recast as Long");
|
---|
872 | if(x>max_long_as_double)throw new IllegalArgumentException("BigDecimal is too large to be recast as Long");
|
---|
873 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("BigDecimal is not, arithmetically, an integer");
|
---|
874 | return new Long(xx.longValue());
|
---|
875 | }
|
---|
876 |
|
---|
877 | public static int convert_BigDecimal_to_int(BigDecimal xx){
|
---|
878 | double x = xx.doubleValue();
|
---|
879 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigDecimal is too large to be recast as int");
|
---|
880 | if(x>max_int_as_double)throw new IllegalArgumentException("BigDecimal is too large to be recast as int");
|
---|
881 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("BigDecimal is not, arithmetically, an integer");
|
---|
882 | return xx.intValue();
|
---|
883 | }
|
---|
884 |
|
---|
885 | public static Integer convert_BigDecimal_to_Integer(BigDecimal xx){
|
---|
886 | double x = xx.doubleValue();
|
---|
887 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigDecimal is too large to be recast as Integer");
|
---|
888 | if(x>max_int_as_double)throw new IllegalArgumentException("BigDecimal is too large to be recast as Integer");
|
---|
889 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("BigDecimal is not, arithmetically, an integer");
|
---|
890 | return new Integer(xx.intValue());
|
---|
891 | }
|
---|
892 |
|
---|
893 | public static short convert_BigDecimal_to_short(BigDecimal xx){
|
---|
894 | double x = xx.doubleValue();
|
---|
895 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigDecimal is too large to be recast as short");
|
---|
896 | if(x>max_short_as_double)throw new IllegalArgumentException("BigDecimal is too large to be recast as short");
|
---|
897 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("BigDecimal is not, arithmetically, an integer");
|
---|
898 | return xx.shortValue();
|
---|
899 | }
|
---|
900 |
|
---|
901 | public static Short convert_BigDecimal_to_Short(BigDecimal xx){
|
---|
902 | double x = xx.doubleValue();
|
---|
903 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigDecimal is too large to be recast as Short");
|
---|
904 | if(x>max_short_as_double)throw new IllegalArgumentException("BigDecimal is too large to be recast as Short");
|
---|
905 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("BigDecimal is not, arithmetically, an integer");
|
---|
906 | return new Short(xx.shortValue());
|
---|
907 | }
|
---|
908 |
|
---|
909 | public static byte convert_BigDecimal_to_byte(BigDecimal xx){
|
---|
910 | double x = xx.doubleValue();
|
---|
911 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigDecimal is too large to be recast as byte");
|
---|
912 | if(x>max_byte_as_double)throw new IllegalArgumentException("BigDecimal is too large to be recast as byte");
|
---|
913 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("BigDecimal is not, arithmetically, an integer");
|
---|
914 | return xx.byteValue();
|
---|
915 | }
|
---|
916 |
|
---|
917 | public static Byte convert_BigDecimal_to_Byte(BigDecimal xx){
|
---|
918 | double x = xx.doubleValue();
|
---|
919 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigDecimal is too large to be recast as Byte");
|
---|
920 | if(x>max_byte_as_double)throw new IllegalArgumentException("BigDecimal is too large to be recast as Byte");
|
---|
921 | if(!Fmath.isInteger(x))throw new IllegalArgumentException("BigDecimal is not, arithmetically, an integer");
|
---|
922 | return new Byte(xx.byteValue());
|
---|
923 | }
|
---|
924 |
|
---|
925 | public static BigInteger convert_BigDecimal_to_BigInteger(BigDecimal xx){
|
---|
926 | String ss = xx.toString();
|
---|
927 | int posDot = ss.indexOf('.');
|
---|
928 | int posExp = ss.indexOf('E');
|
---|
929 | String tt = null;
|
---|
930 |
|
---|
931 | if(posDot==-1){
|
---|
932 | return xx.toBigInteger();
|
---|
933 | }
|
---|
934 | else{
|
---|
935 | if(posExp==-1){
|
---|
936 | tt = ss.substring(posDot+1);
|
---|
937 | }
|
---|
938 | else{
|
---|
939 | tt = ss.substring(posDot+1, posExp);
|
---|
940 | }
|
---|
941 | int n = tt.length();
|
---|
942 | boolean test1 = true;
|
---|
943 | boolean test2 = true;
|
---|
944 | int ii=0;
|
---|
945 | while(test1){
|
---|
946 | if(tt.charAt(ii)!='0'){
|
---|
947 | test1 = false;
|
---|
948 | test2 = false;
|
---|
949 | }
|
---|
950 | else{
|
---|
951 | ii++;
|
---|
952 | if(ii==n)test1 = false;
|
---|
953 | }
|
---|
954 | }
|
---|
955 | if(test2){
|
---|
956 | return xx.toBigInteger();
|
---|
957 | }
|
---|
958 | else{
|
---|
959 | throw new IllegalArgumentException("BigDecimal is not, arithmetically, an integer");
|
---|
960 | }
|
---|
961 | }
|
---|
962 | }
|
---|
963 |
|
---|
964 |
|
---|
965 |
|
---|
966 | // BigInteger -> . . .
|
---|
967 | public static double convert_BigInteger_to_double(BigInteger xx){
|
---|
968 | double x = xx.doubleValue();
|
---|
969 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigInteger is too large to be recast as double");
|
---|
970 | if(!suppressMessage)System.out.println("Class Conv: method convert_BigInteger_to_double: possible loss of precision");
|
---|
971 | return x;
|
---|
972 | }
|
---|
973 |
|
---|
974 | public static Double convert_BigInteger_to_Double(BigInteger xx){
|
---|
975 | double x = xx.doubleValue();
|
---|
976 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigInteger is too large to be recast as double");
|
---|
977 | if(!suppressMessage)System.out.println("Class Conv: method convert_BigInteger_to_double: possible loss of precision");
|
---|
978 | return new Double(x);
|
---|
979 | }
|
---|
980 |
|
---|
981 | public static float convert_BigInteger_to_float(BigInteger xx){
|
---|
982 | float x = xx.floatValue();
|
---|
983 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigInteger is too large to be recast as float");
|
---|
984 | if(!suppressMessage)System.out.println("Class Conv: method convert_BigInteger_to_float: possible loss of precision");
|
---|
985 | return x;
|
---|
986 | }
|
---|
987 |
|
---|
988 | public static Float convert_BigInteger_to_Float(BigInteger xx){
|
---|
989 | float x = xx.floatValue();
|
---|
990 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigInteger is too large to be recast as float");
|
---|
991 | if(!suppressMessage)System.out.println("Class Conv: method convert_BigInteger_to_float: possible loss of precision");
|
---|
992 | return new Float(x);
|
---|
993 | }
|
---|
994 |
|
---|
995 | public static long convert_BigInteger_to_long(BigInteger xx){
|
---|
996 | double x = xx.doubleValue();
|
---|
997 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigInteger is too large to be recast as long");
|
---|
998 | if(x>max_long_as_double)throw new IllegalArgumentException("BigInteger is too large to be recast as long");
|
---|
999 | return xx.longValue();
|
---|
1000 | }
|
---|
1001 |
|
---|
1002 | public static Long convert_BigInteger_to_Long(BigInteger xx){
|
---|
1003 | double x = xx.doubleValue();
|
---|
1004 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigInteger is too large to be recast as Long");
|
---|
1005 | if(x>max_long_as_double)throw new IllegalArgumentException("BigInteger is too large to be recast as Long");
|
---|
1006 | return new Long(xx.longValue());
|
---|
1007 | }
|
---|
1008 |
|
---|
1009 | public static int convert_BigInteger_to_int(BigInteger xx){
|
---|
1010 | double x = xx.doubleValue();
|
---|
1011 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigInteger is too large to be recast as int");
|
---|
1012 | if(x>max_int_as_double)throw new IllegalArgumentException("BigInteger is too large to be recast as int");
|
---|
1013 | return xx.intValue();
|
---|
1014 | }
|
---|
1015 |
|
---|
1016 | public static Integer convert_BigInteger_to_Integer(BigInteger xx){
|
---|
1017 | double x = xx.doubleValue();
|
---|
1018 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigInteger is too large to be recast as Integer");
|
---|
1019 | if(x>max_int_as_double)throw new IllegalArgumentException("BigInteger is too large to be recast as Integer");
|
---|
1020 | return new Integer(xx.intValue());
|
---|
1021 | }
|
---|
1022 |
|
---|
1023 | public static short convert_BigInteger_to_short(BigInteger xx){
|
---|
1024 | double x = xx.doubleValue();
|
---|
1025 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigInteger is too large to be recast as short");
|
---|
1026 | if(x>max_short_as_double)throw new IllegalArgumentException("BigInteger is too large to be recast as short");
|
---|
1027 | return xx.shortValue();
|
---|
1028 | }
|
---|
1029 |
|
---|
1030 | public static Short convert_BigInteger_to_Short(BigInteger xx){
|
---|
1031 | double x = xx.doubleValue();
|
---|
1032 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigInteger is too large to be recast as Short");
|
---|
1033 | if(x>max_short_as_double)throw new IllegalArgumentException("BigInteger is too large to be recast as Short");
|
---|
1034 | return new Short(xx.shortValue());
|
---|
1035 | }
|
---|
1036 |
|
---|
1037 | public static byte convert_BigInteger_to_byte(BigInteger xx){
|
---|
1038 | double x = xx.doubleValue();
|
---|
1039 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigInteger is too large to be recast as byte");
|
---|
1040 | if(x>max_byte_as_double)throw new IllegalArgumentException("BigInteger is too large to be recast as byte");
|
---|
1041 | return xx.byteValue();
|
---|
1042 | }
|
---|
1043 |
|
---|
1044 | public static Byte convert_BigInteger_to_Byte(BigInteger xx){
|
---|
1045 | double x = xx.doubleValue();
|
---|
1046 | if(Fmath.isInfinity(x))throw new IllegalArgumentException("BigInteger is too large to be recast as Byte");
|
---|
1047 | if(x>max_byte_as_double)throw new IllegalArgumentException("BigInteger is too large to be recast as Byte");
|
---|
1048 | return new Byte(xx.byteValue());
|
---|
1049 | }
|
---|
1050 |
|
---|
1051 | public static BigDecimal convert_BigInteger_to_BigDecimal(BigInteger xx){
|
---|
1052 | return new BigDecimal(xx);
|
---|
1053 | }
|
---|
1054 |
|
---|
1055 | // Complex -> Phasor
|
---|
1056 | public static Phasor convert_Complex_to_Phasor(Complex xx){
|
---|
1057 | double mag = xx.abs();
|
---|
1058 | double phase = xx.argDeg();
|
---|
1059 | return new Phasor(mag, phase);
|
---|
1060 | }
|
---|
1061 |
|
---|
1062 | // Phasor -> Complex
|
---|
1063 | public static Complex convert_Phasor_to_Complex(Phasor xx){
|
---|
1064 | return xx.toComplex();
|
---|
1065 | }
|
---|
1066 |
|
---|
1067 | // COPY
|
---|
1068 |
|
---|
1069 | // COPY A ONE DIMENSIONAL ARRAY OF double
|
---|
1070 | public static double[] copy(double[] array){
|
---|
1071 | if(array==null)return null;
|
---|
1072 | int n = array.length;
|
---|
1073 | double[] copy = new double[n];
|
---|
1074 | for(int i=0; i<n; i++){
|
---|
1075 | copy[i] = array[i];
|
---|
1076 | }
|
---|
1077 | return copy;
|
---|
1078 | }
|
---|
1079 |
|
---|
1080 | // COPY A ONE DIMENSIONAL ARRAY OF float
|
---|
1081 | public static float[] copy(float[] array){
|
---|
1082 | if(array==null)return null;
|
---|
1083 | int n = array.length;
|
---|
1084 | float[] copy = new float[n];
|
---|
1085 | for(int i=0; i<n; i++){
|
---|
1086 | copy[i] = array[i];
|
---|
1087 | }
|
---|
1088 | return copy;
|
---|
1089 | }
|
---|
1090 |
|
---|
1091 | // COPY A ONE DIMENSIONAL ARRAY OF int
|
---|
1092 | public static int[] copy(int[] array){
|
---|
1093 | if(array==null)return null;
|
---|
1094 | int n = array.length;
|
---|
1095 | int[] copy = new int[n];
|
---|
1096 | for(int i=0; i<n; i++){
|
---|
1097 | copy[i] = array[i];
|
---|
1098 | }
|
---|
1099 | return copy;
|
---|
1100 | }
|
---|
1101 |
|
---|
1102 | // COPY A ONE DIMENSIONAL ARRAY OF long
|
---|
1103 | public static long[] copy(long[] array){
|
---|
1104 | if(array==null)return null;
|
---|
1105 | int n = array.length;
|
---|
1106 | long[] copy = new long[n];
|
---|
1107 | for(int i=0; i<n; i++){
|
---|
1108 | copy[i] = array[i];
|
---|
1109 | }
|
---|
1110 | return copy;
|
---|
1111 | }
|
---|
1112 |
|
---|
1113 | // COPY A TWO DIMENSIONAL ARRAY OF double
|
---|
1114 | public static double[][] copy(double[][] array){
|
---|
1115 | if(array==null)return null;
|
---|
1116 | int n = array.length;
|
---|
1117 | double[][] copy = new double[n][];
|
---|
1118 | for(int i=0; i<n; i++){
|
---|
1119 | int m = array[i].length;
|
---|
1120 | copy[i] = new double[m];
|
---|
1121 | for(int j=0; j<m; j++){
|
---|
1122 | copy[i][j] = array[i][j];
|
---|
1123 | }
|
---|
1124 | }
|
---|
1125 | return copy;
|
---|
1126 | }
|
---|
1127 |
|
---|
1128 | // COPY A TWO DIMENSIONAL ARRAY OF float
|
---|
1129 | public static float[][] copy(float[][] array){
|
---|
1130 | if(array==null)return null;
|
---|
1131 | int n = array.length;
|
---|
1132 | float[][] copy = new float[n][];
|
---|
1133 | for(int i=0; i<n; i++){
|
---|
1134 | int m = array[i].length;
|
---|
1135 | copy[i] = new float[m];
|
---|
1136 | for(int j=0; j<m; j++){
|
---|
1137 | copy[i][j] = array[i][j];
|
---|
1138 | }
|
---|
1139 | }
|
---|
1140 | return copy;
|
---|
1141 | }
|
---|
1142 |
|
---|
1143 | // COPY A TWO DIMENSIONAL ARRAY OF int
|
---|
1144 | public static int[][] copy(int[][] array){
|
---|
1145 | if(array==null)return null;
|
---|
1146 | int n = array.length;
|
---|
1147 | int[][] copy = new int[n][];
|
---|
1148 | for(int i=0; i<n; i++){
|
---|
1149 | int m = array[i].length;
|
---|
1150 | copy[i] = new int[m];
|
---|
1151 | for(int j=0; j<m; j++){
|
---|
1152 | copy[i][j] = array[i][j];
|
---|
1153 | }
|
---|
1154 | }
|
---|
1155 | return copy;
|
---|
1156 | }
|
---|
1157 |
|
---|
1158 | // COPY A TWO DIMENSIONAL ARRAY OF long
|
---|
1159 | public static long[][] copy(long[][] array){
|
---|
1160 | if(array==null)return null;
|
---|
1161 | int n = array.length;
|
---|
1162 | long[][] copy = new long[n][];
|
---|
1163 | for(int i=0; i<n; i++){
|
---|
1164 | int m = array[i].length;
|
---|
1165 | copy[i] = new long[m];
|
---|
1166 | for(int j=0; j<m; j++){
|
---|
1167 | copy[i][j] = array[i][j];
|
---|
1168 | }
|
---|
1169 | }
|
---|
1170 | return copy;
|
---|
1171 | }
|
---|
1172 |
|
---|
1173 | // COPY A THREE DIMENSIONAL ARRAY OF double
|
---|
1174 | public static double[][][] copy(double[][][] array){
|
---|
1175 | if(array==null)return null;
|
---|
1176 | int n = array.length;
|
---|
1177 | double[][][] copy = new double[n][][];
|
---|
1178 | for(int i=0; i<n; i++){
|
---|
1179 | int m = array[i].length;
|
---|
1180 | copy[i] = new double[m][];
|
---|
1181 | for(int j=0; j<m; j++){
|
---|
1182 | int l = array[i][j].length;
|
---|
1183 | copy[i][j] = new double[l];
|
---|
1184 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k];
|
---|
1185 | }
|
---|
1186 | }
|
---|
1187 | return copy;
|
---|
1188 | }
|
---|
1189 |
|
---|
1190 |
|
---|
1191 | // COPY A THREE DIMENSIONAL ARRAY OF float
|
---|
1192 | public static float[][][] copy(float[][][] array){
|
---|
1193 | if(array==null)return null;
|
---|
1194 | int n = array.length;
|
---|
1195 | float[][][] copy = new float[n][][];
|
---|
1196 | for(int i=0; i<n; i++){
|
---|
1197 | int m = array[i].length;
|
---|
1198 | copy[i] = new float[m][];
|
---|
1199 | for(int j=0; j<m; j++){
|
---|
1200 | int l = array[i][j].length;
|
---|
1201 | copy[i][j] = new float[l];
|
---|
1202 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k];
|
---|
1203 | }
|
---|
1204 | }
|
---|
1205 | return copy;
|
---|
1206 | }
|
---|
1207 |
|
---|
1208 | // COPY A THREE DIMENSIONAL ARRAY OF int
|
---|
1209 | public static int[][][] copy(int[][][] array){
|
---|
1210 | if(array==null)return null;
|
---|
1211 | int n = array.length;
|
---|
1212 | int[][][] copy = new int[n][][];
|
---|
1213 | for(int i=0; i<n; i++){
|
---|
1214 | int m = array[i].length;
|
---|
1215 | copy[i] = new int[m][];
|
---|
1216 | for(int j=0; j<m; j++){
|
---|
1217 | int l = array[i][j].length;
|
---|
1218 | copy[i][j] = new int[l];
|
---|
1219 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k];
|
---|
1220 | }
|
---|
1221 | }
|
---|
1222 | return copy;
|
---|
1223 | }
|
---|
1224 |
|
---|
1225 | // COPY A THREE DIMENSIONAL ARRAY OF long
|
---|
1226 | public static long[][][] copy(long[][][] array){
|
---|
1227 | if(array==null)return null;
|
---|
1228 | int n = array.length;
|
---|
1229 | long[][][] copy = new long[n][][];
|
---|
1230 | for(int i=0; i<n; i++){
|
---|
1231 | int m = array[i].length;
|
---|
1232 | copy[i] = new long[m][];
|
---|
1233 | for(int j=0; j<m; j++){
|
---|
1234 | int l = array[i][j].length;
|
---|
1235 | copy[i][j] = new long[l];
|
---|
1236 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k];
|
---|
1237 | }
|
---|
1238 | }
|
---|
1239 | return copy;
|
---|
1240 | }
|
---|
1241 |
|
---|
1242 | // COPY A FOUR DIMENSIONAL ARRAY OF double
|
---|
1243 | public static double[][][][] copy(double[][][][] array){
|
---|
1244 | if(array==null)return null;
|
---|
1245 | int n = array.length;
|
---|
1246 | double[][][][] copy = new double[n][][][];
|
---|
1247 | for(int i=0; i<n; i++){
|
---|
1248 | int m = array[i].length;
|
---|
1249 | copy[i] = new double[m][][];
|
---|
1250 | for(int j=0; j<m; j++){
|
---|
1251 | int l = array[i][j].length;
|
---|
1252 | copy[i][j] = new double[l][];
|
---|
1253 | for(int k=0; k<l;k++){
|
---|
1254 | int ll = array[i][j][k].length;
|
---|
1255 | copy[i][j][k] = new double[ll];
|
---|
1256 | for(int kk=0; kk<ll;kk++){
|
---|
1257 | copy[i][j][k][kk] = array[i][j][k][kk];
|
---|
1258 | }
|
---|
1259 | }
|
---|
1260 | }
|
---|
1261 | }
|
---|
1262 | return copy;
|
---|
1263 | }
|
---|
1264 |
|
---|
1265 | // COPY A FOUR DIMENSIONAL ARRAY OF float
|
---|
1266 | public static float[][][][] copy(float[][][][] array){
|
---|
1267 | if(array==null)return null;
|
---|
1268 | int n = array.length;
|
---|
1269 | float[][][][] copy = new float[n][][][];
|
---|
1270 | for(int i=0; i<n; i++){
|
---|
1271 | int m = array[i].length;
|
---|
1272 | copy[i] = new float[m][][];
|
---|
1273 | for(int j=0; j<m; j++){
|
---|
1274 | int l = array[i][j].length;
|
---|
1275 | copy[i][j] = new float[l][];
|
---|
1276 | for(int k=0; k<l;k++){
|
---|
1277 | int ll = array[i][j][k].length;
|
---|
1278 | copy[i][j][k] = new float[ll];
|
---|
1279 | for(int kk=0; kk<ll;kk++){
|
---|
1280 | copy[i][j][k][kk] = array[i][j][k][kk];
|
---|
1281 | }
|
---|
1282 | }
|
---|
1283 | }
|
---|
1284 | }
|
---|
1285 | return copy;
|
---|
1286 | }
|
---|
1287 |
|
---|
1288 | // COPY A FOUR DIMENSIONAL ARRAY OF int
|
---|
1289 | public static int[][][][] copy(int[][][][] array){
|
---|
1290 | if(array==null)return null;
|
---|
1291 | int n = array.length;
|
---|
1292 | int[][][][] copy = new int[n][][][];
|
---|
1293 | for(int i=0; i<n; i++){
|
---|
1294 | int m = array[i].length;
|
---|
1295 | copy[i] = new int[m][][];
|
---|
1296 | for(int j=0; j<m; j++){
|
---|
1297 | int l = array[i][j].length;
|
---|
1298 | copy[i][j] = new int[l][];
|
---|
1299 | for(int k=0; k<l;k++){
|
---|
1300 | int ll = array[i][j][k].length;
|
---|
1301 | copy[i][j][k] = new int[ll];
|
---|
1302 | for(int kk=0; kk<ll;kk++){
|
---|
1303 | copy[i][j][k][kk] = array[i][j][k][kk];
|
---|
1304 | }
|
---|
1305 | }
|
---|
1306 | }
|
---|
1307 | }
|
---|
1308 | return copy;
|
---|
1309 | }
|
---|
1310 |
|
---|
1311 | // COPY A FOUR DIMENSIONAL ARRAY OF long
|
---|
1312 | public static long[][][][] copy(long[][][][] array){
|
---|
1313 | if(array==null)return null;
|
---|
1314 | int n = array.length;
|
---|
1315 | long[][][][] copy = new long[n][][][];
|
---|
1316 | for(int i=0; i<n; i++){
|
---|
1317 | int m = array[i].length;
|
---|
1318 | copy[i] = new long[m][][];
|
---|
1319 | for(int j=0; j<m; j++){
|
---|
1320 | int l = array[i][j].length;
|
---|
1321 | copy[i][j] = new long[l][];
|
---|
1322 | for(int k=0; k<l;k++){
|
---|
1323 | int ll = array[i][j][k].length;
|
---|
1324 | copy[i][j][k] = new long[ll];
|
---|
1325 | for(int kk=0; kk<ll;kk++){
|
---|
1326 | copy[i][j][k][kk] = array[i][j][k][kk];
|
---|
1327 | }
|
---|
1328 | }
|
---|
1329 | }
|
---|
1330 | }
|
---|
1331 | return copy;
|
---|
1332 | }
|
---|
1333 |
|
---|
1334 | // COPY A ONE DIMENSIONAL ARRAY OF String
|
---|
1335 | public static String[] copy(String[] array){
|
---|
1336 | if(array==null)return null;
|
---|
1337 | int n = array.length;
|
---|
1338 | String[] copy = new String[n];
|
---|
1339 | for(int i=0; i<n; i++){
|
---|
1340 | copy[i] = array[i];
|
---|
1341 | }
|
---|
1342 | return copy;
|
---|
1343 | }
|
---|
1344 |
|
---|
1345 | // COPY A TWO DIMENSIONAL ARRAY OF String
|
---|
1346 | public static String[][] copy(String[][] array){
|
---|
1347 | if(array==null)return null;
|
---|
1348 | int n = array.length;
|
---|
1349 | String[][] copy = new String[n][];
|
---|
1350 | for(int i=0; i<n; i++){
|
---|
1351 | int m = array[i].length;
|
---|
1352 | copy[i] = new String[m];
|
---|
1353 | for(int j=0; j<m; j++){
|
---|
1354 | copy[i][j] = array[i][j];
|
---|
1355 | }
|
---|
1356 | }
|
---|
1357 | return copy;
|
---|
1358 | }
|
---|
1359 |
|
---|
1360 | // COPY A THREE DIMENSIONAL ARRAY OF String
|
---|
1361 | public static String[][][] copy(String[][][] array){
|
---|
1362 | if(array==null)return null;
|
---|
1363 | int n = array.length;
|
---|
1364 | String[][][] copy = new String[n][][];
|
---|
1365 | for(int i=0; i<n; i++){
|
---|
1366 | int m = array[i].length;
|
---|
1367 | copy[i] = new String[m][];
|
---|
1368 | for(int j=0; j<m; j++){
|
---|
1369 | int l = array[i][j].length;
|
---|
1370 | copy[i][j] = new String[l];
|
---|
1371 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k];
|
---|
1372 | }
|
---|
1373 | }
|
---|
1374 | return copy;
|
---|
1375 | }
|
---|
1376 |
|
---|
1377 | // COPY A FOUR DIMENSIONAL ARRAY OF String
|
---|
1378 | public static String[][][][] copy(String[][][][] array){
|
---|
1379 | if(array==null)return null;
|
---|
1380 | int n = array.length;
|
---|
1381 | String[][][][] copy = new String[n][][][];
|
---|
1382 | for(int i=0; i<n; i++){
|
---|
1383 | int m = array[i].length;
|
---|
1384 | copy[i] = new String[m][][];
|
---|
1385 | for(int j=0; j<m; j++){
|
---|
1386 | int l = array[i][j].length;
|
---|
1387 | copy[i][j] = new String[l][];
|
---|
1388 | for(int k=0; k<l;k++){
|
---|
1389 | int ll = array[i][j][k].length;
|
---|
1390 | copy[i][j][k] = new String[ll];
|
---|
1391 | for(int kk=0; kk<ll;kk++){
|
---|
1392 | copy[i][j][k][kk] = array[i][j][k][kk];
|
---|
1393 | }
|
---|
1394 | }
|
---|
1395 | }
|
---|
1396 | }
|
---|
1397 | return copy;
|
---|
1398 | }
|
---|
1399 |
|
---|
1400 |
|
---|
1401 |
|
---|
1402 |
|
---|
1403 | // COPY A ONE DIMENSIONAL ARRAY OF boolean
|
---|
1404 | public static boolean[] copy(boolean[] array){
|
---|
1405 | if(array==null)return null;
|
---|
1406 | int n = array.length;
|
---|
1407 | boolean[] copy = new boolean[n];
|
---|
1408 | for(int i=0; i<n; i++){
|
---|
1409 | copy[i] = array[i];
|
---|
1410 | }
|
---|
1411 | return copy;
|
---|
1412 | }
|
---|
1413 |
|
---|
1414 | // COPY A TWO DIMENSIONAL ARRAY OF boolean
|
---|
1415 | public static boolean[][] copy(boolean[][] array){
|
---|
1416 | if(array==null)return null;
|
---|
1417 | int n = array.length;
|
---|
1418 | boolean[][] copy = new boolean[n][];
|
---|
1419 | for(int i=0; i<n; i++){
|
---|
1420 | int m = array[i].length;
|
---|
1421 | copy[i] = new boolean[m];
|
---|
1422 | for(int j=0; j<m; j++){
|
---|
1423 | copy[i][j] = array[i][j];
|
---|
1424 | }
|
---|
1425 | }
|
---|
1426 | return copy;
|
---|
1427 | }
|
---|
1428 |
|
---|
1429 | // COPY A THREE DIMENSIONAL ARRAY OF boolean
|
---|
1430 | public static boolean[][][] copy(boolean[][][] array){
|
---|
1431 | if(array==null)return null;
|
---|
1432 | int n = array.length;
|
---|
1433 | boolean[][][] copy = new boolean[n][][];
|
---|
1434 | for(int i=0; i<n; i++){
|
---|
1435 | int m = array[i].length;
|
---|
1436 | copy[i] = new boolean[m][];
|
---|
1437 | for(int j=0; j<m; j++){
|
---|
1438 | int l = array[i][j].length;
|
---|
1439 | copy[i][j] = new boolean[l];
|
---|
1440 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k];
|
---|
1441 | }
|
---|
1442 | }
|
---|
1443 | return copy;
|
---|
1444 | }
|
---|
1445 |
|
---|
1446 | // COPY A FOUR DIMENSIONAL ARRAY OF boolean
|
---|
1447 | public static boolean[][][][] copy(boolean[][][][] array){
|
---|
1448 | if(array==null)return null;
|
---|
1449 | int n = array.length;
|
---|
1450 | boolean[][][][] copy = new boolean[n][][][];
|
---|
1451 | for(int i=0; i<n; i++){
|
---|
1452 | int m = array[i].length;
|
---|
1453 | copy[i] = new boolean[m][][];
|
---|
1454 | for(int j=0; j<m; j++){
|
---|
1455 | int l = array[i][j].length;
|
---|
1456 | copy[i][j] = new boolean[l][];
|
---|
1457 | for(int k=0; k<l;k++){
|
---|
1458 | int ll = array[i][j][k].length;
|
---|
1459 | copy[i][j][k] = new boolean[ll];
|
---|
1460 | for(int kk=0; kk<ll;kk++){
|
---|
1461 | copy[i][j][k][kk] = array[i][j][k][kk];
|
---|
1462 | }
|
---|
1463 | }
|
---|
1464 | }
|
---|
1465 | }
|
---|
1466 | return copy;
|
---|
1467 | }
|
---|
1468 |
|
---|
1469 |
|
---|
1470 |
|
---|
1471 | // COPY A ONE DIMENSIONAL ARRAY OF char
|
---|
1472 | public static char[] copy(char[] array){
|
---|
1473 | if(array==null)return null;
|
---|
1474 | int n = array.length;
|
---|
1475 | char[] copy = new char[n];
|
---|
1476 | for(int i=0; i<n; i++){
|
---|
1477 | copy[i] = array[i];
|
---|
1478 | }
|
---|
1479 | return copy;
|
---|
1480 | }
|
---|
1481 |
|
---|
1482 | // COPY A TWO DIMENSIONAL ARRAY OF char
|
---|
1483 | public static char[][] copy(char[][] array){
|
---|
1484 | if(array==null)return null;
|
---|
1485 | int n = array.length;
|
---|
1486 | char[][] copy = new char[n][];
|
---|
1487 | for(int i=0; i<n; i++){
|
---|
1488 | int m = array[i].length;
|
---|
1489 | copy[i] = new char[m];
|
---|
1490 | for(int j=0; j<m; j++){
|
---|
1491 | copy[i][j] = array[i][j];
|
---|
1492 | }
|
---|
1493 | }
|
---|
1494 | return copy;
|
---|
1495 | }
|
---|
1496 |
|
---|
1497 | // COPY A THREE DIMENSIONAL ARRAY OF char
|
---|
1498 | public static char[][][] copy(char[][][] array){
|
---|
1499 | if(array==null)return null;
|
---|
1500 | int n = array.length;
|
---|
1501 | char[][][] copy = new char[n][][];
|
---|
1502 | for(int i=0; i<n; i++){
|
---|
1503 | int m = array[i].length;
|
---|
1504 | copy[i] = new char[m][];
|
---|
1505 | for(int j=0; j<m; j++){
|
---|
1506 | int l = array[i][j].length;
|
---|
1507 | copy[i][j] = new char[l];
|
---|
1508 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k];
|
---|
1509 | }
|
---|
1510 | }
|
---|
1511 | return copy;
|
---|
1512 | }
|
---|
1513 |
|
---|
1514 | // COPY A FOUR DIMENSIONAL ARRAY OF char
|
---|
1515 | public static char[][][][] copy(char[][][][] array){
|
---|
1516 | if(array==null)return null;
|
---|
1517 | int n = array.length;
|
---|
1518 | char[][][][] copy = new char[n][][][];
|
---|
1519 | for(int i=0; i<n; i++){
|
---|
1520 | int m = array[i].length;
|
---|
1521 | copy[i] = new char[m][][];
|
---|
1522 | for(int j=0; j<m; j++){
|
---|
1523 | int l = array[i][j].length;
|
---|
1524 | copy[i][j] = new char[l][];
|
---|
1525 | for(int k=0; k<l;k++){
|
---|
1526 | int ll = array[i][j][k].length;
|
---|
1527 | copy[i][j][k] = new char[ll];
|
---|
1528 | for(int kk=0; kk<ll;kk++){
|
---|
1529 | copy[i][j][k][kk] = array[i][j][k][kk];
|
---|
1530 | }
|
---|
1531 | }
|
---|
1532 | }
|
---|
1533 | }
|
---|
1534 | return copy;
|
---|
1535 | }
|
---|
1536 |
|
---|
1537 | // COPY A ONE DIMENSIONAL ARRAY OF Complex
|
---|
1538 | public static Complex[] copy(Complex[] array){
|
---|
1539 | if(array==null)return null;
|
---|
1540 | int n = array.length;
|
---|
1541 | Complex[] copy = new Complex[n];
|
---|
1542 | for(int i=0; i<n; i++){
|
---|
1543 | copy[i] = array[i].copy();
|
---|
1544 | }
|
---|
1545 | return copy;
|
---|
1546 | }
|
---|
1547 |
|
---|
1548 | // COPY A TWO DIMENSIONAL ARRAY OF Complex
|
---|
1549 | public static Complex[][] copy(Complex[][] array){
|
---|
1550 | if(array==null)return null;
|
---|
1551 | int n = array.length;
|
---|
1552 | Complex[][] copy = new Complex[n][];
|
---|
1553 | for(int i=0; i<n; i++){
|
---|
1554 | int m = array[i].length;
|
---|
1555 | copy[i] = new Complex[m];
|
---|
1556 | for(int j=0; j<m; j++){
|
---|
1557 | copy[i][j] = array[i][j].copy();
|
---|
1558 | }
|
---|
1559 | }
|
---|
1560 | return copy;
|
---|
1561 | }
|
---|
1562 |
|
---|
1563 | // COPY A THREE DIMENSIONAL ARRAY OF Complex
|
---|
1564 | public static Complex[][][] copy(Complex[][][] array){
|
---|
1565 | if(array==null)return null;
|
---|
1566 | int n = array.length;
|
---|
1567 | Complex[][][] copy = new Complex[n][][];
|
---|
1568 | for(int i=0; i<n; i++){
|
---|
1569 | int m = array[i].length;
|
---|
1570 | copy[i] = new Complex[m][];
|
---|
1571 | for(int j=0; j<m; j++){
|
---|
1572 | int l = array[i][j].length;
|
---|
1573 | copy[i][j] = new Complex[l];
|
---|
1574 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k].copy();
|
---|
1575 | }
|
---|
1576 | }
|
---|
1577 | return copy;
|
---|
1578 | }
|
---|
1579 |
|
---|
1580 | // COPY A FOUR DIMENSIONAL ARRAY OF Complex
|
---|
1581 | public static Complex[][][][] copy(Complex[][][][] array){
|
---|
1582 | if(array==null)return null;
|
---|
1583 | int n = array.length;
|
---|
1584 | Complex[][][][] copy = new Complex[n][][][];
|
---|
1585 | for(int i=0; i<n; i++){
|
---|
1586 | int m = array[i].length;
|
---|
1587 | copy[i] = new Complex[m][][];
|
---|
1588 | for(int j=0; j<m; j++){
|
---|
1589 | int l = array[i][j].length;
|
---|
1590 | copy[i][j] = new Complex[l][];
|
---|
1591 | for(int k=0; k<l;k++){
|
---|
1592 | int ll = array[i][j][k].length;
|
---|
1593 | copy[i][j][k] = new Complex[ll];
|
---|
1594 | for(int kk=0; kk<ll;kk++){
|
---|
1595 | copy[i][j][k][kk] = array[i][j][k][kk].copy();
|
---|
1596 | }
|
---|
1597 | }
|
---|
1598 | }
|
---|
1599 | }
|
---|
1600 | return copy;
|
---|
1601 | }
|
---|
1602 |
|
---|
1603 |
|
---|
1604 | // COPY A ONE DIMENSIONAL ARRAY OF ComplexPoly
|
---|
1605 | public static ComplexPoly[] copy(ComplexPoly[] array){
|
---|
1606 | if(array==null)return null;
|
---|
1607 | int n = array.length;
|
---|
1608 | ComplexPoly[] copy = new ComplexPoly[n];
|
---|
1609 | for(int i=0; i<n; i++){
|
---|
1610 | copy[i] = array[i].copy();
|
---|
1611 | }
|
---|
1612 | return copy;
|
---|
1613 | }
|
---|
1614 |
|
---|
1615 | // COPY A TWO DIMENSIONAL ARRAY OF ComplexPoly
|
---|
1616 | public static ComplexPoly[][] copy(ComplexPoly[][] array){
|
---|
1617 | if(array==null)return null;
|
---|
1618 | int n = array.length;
|
---|
1619 | ComplexPoly[][] copy = new ComplexPoly[n][];
|
---|
1620 | for(int i=0; i<n; i++){
|
---|
1621 | int m = array[i].length;
|
---|
1622 | copy[i] = new ComplexPoly[m];
|
---|
1623 | for(int j=0; j<m; j++){
|
---|
1624 | copy[i][j] = array[i][j].copy();
|
---|
1625 | }
|
---|
1626 | }
|
---|
1627 | return copy;
|
---|
1628 | }
|
---|
1629 |
|
---|
1630 | // COPY A THREE DIMENSIONAL ARRAY OF ComplexPoly
|
---|
1631 | public static ComplexPoly[][][] copy(ComplexPoly[][][] array){
|
---|
1632 | if(array==null)return null;
|
---|
1633 | int n = array.length;
|
---|
1634 | ComplexPoly[][][] copy = new ComplexPoly[n][][];
|
---|
1635 | for(int i=0; i<n; i++){
|
---|
1636 | int m = array[i].length;
|
---|
1637 | copy[i] = new ComplexPoly[m][];
|
---|
1638 | for(int j=0; j<m; j++){
|
---|
1639 | int l = array[i][j].length;
|
---|
1640 | copy[i][j] = new ComplexPoly[l];
|
---|
1641 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k].copy();
|
---|
1642 | }
|
---|
1643 | }
|
---|
1644 | return copy;
|
---|
1645 | }
|
---|
1646 |
|
---|
1647 | // COPY A FOUR DIMENSIONAL ARRAY OF ComplexPoly
|
---|
1648 | public static ComplexPoly[][][][] copy(ComplexPoly[][][][] array){
|
---|
1649 | if(array==null)return null;
|
---|
1650 | int n = array.length;
|
---|
1651 | ComplexPoly[][][][] copy = new ComplexPoly[n][][][];
|
---|
1652 | for(int i=0; i<n; i++){
|
---|
1653 | int m = array[i].length;
|
---|
1654 | copy[i] = new ComplexPoly[m][][];
|
---|
1655 | for(int j=0; j<m; j++){
|
---|
1656 | int l = array[i][j].length;
|
---|
1657 | copy[i][j] = new ComplexPoly[l][];
|
---|
1658 | for(int k=0; k<l;k++){
|
---|
1659 | int ll = array[i][j][k].length;
|
---|
1660 | copy[i][j][k] = new ComplexPoly[ll];
|
---|
1661 | for(int kk=0; kk<ll;kk++){
|
---|
1662 | copy[i][j][k][kk] = array[i][j][k][kk].copy();
|
---|
1663 | }
|
---|
1664 | }
|
---|
1665 | }
|
---|
1666 | }
|
---|
1667 | return copy;
|
---|
1668 | }
|
---|
1669 |
|
---|
1670 | // COPY A ONE DIMENSIONAL ARRAY OF Polynomial
|
---|
1671 | public static Polynomial[] copy(Polynomial[] array){
|
---|
1672 | if(array==null)return null;
|
---|
1673 | int n = array.length;
|
---|
1674 | Polynomial[] copy = new Polynomial[n];
|
---|
1675 | for(int i=0; i<n; i++){
|
---|
1676 | copy[i] = array[i].copy();
|
---|
1677 | }
|
---|
1678 | return copy;
|
---|
1679 | }
|
---|
1680 |
|
---|
1681 | // COPY A TWO DIMENSIONAL ARRAY OF Polynomial
|
---|
1682 | public static Polynomial[][] copy(Polynomial[][] array){
|
---|
1683 | if(array==null)return null;
|
---|
1684 | int n = array.length;
|
---|
1685 | Polynomial[][] copy = new Polynomial[n][];
|
---|
1686 | for(int i=0; i<n; i++){
|
---|
1687 | int m = array[i].length;
|
---|
1688 | copy[i] = new Polynomial[m];
|
---|
1689 | for(int j=0; j<m; j++){
|
---|
1690 | copy[i][j] = array[i][j].copy();
|
---|
1691 | }
|
---|
1692 | }
|
---|
1693 | return copy;
|
---|
1694 | }
|
---|
1695 |
|
---|
1696 | // COPY A THREE DIMENSIONAL ARRAY OF Polynomial
|
---|
1697 | public static Polynomial[][][] copy(Polynomial[][][] array){
|
---|
1698 | if(array==null)return null;
|
---|
1699 | int n = array.length;
|
---|
1700 | Polynomial[][][] copy = new Polynomial[n][][];
|
---|
1701 | for(int i=0; i<n; i++){
|
---|
1702 | int m = array[i].length;
|
---|
1703 | copy[i] = new Polynomial[m][];
|
---|
1704 | for(int j=0; j<m; j++){
|
---|
1705 | int l = array[i][j].length;
|
---|
1706 | copy[i][j] = new Polynomial[l];
|
---|
1707 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k].copy();
|
---|
1708 | }
|
---|
1709 | }
|
---|
1710 | return copy;
|
---|
1711 | }
|
---|
1712 |
|
---|
1713 | // COPY A FOUR DIMENSIONAL ARRAY OF Polynomial
|
---|
1714 | public static Polynomial[][][][] copy(Polynomial[][][][] array){
|
---|
1715 | if(array==null)return null;
|
---|
1716 | int n = array.length;
|
---|
1717 | Polynomial[][][][] copy = new Polynomial[n][][][];
|
---|
1718 | for(int i=0; i<n; i++){
|
---|
1719 | int m = array[i].length;
|
---|
1720 | copy[i] = new Polynomial[m][][];
|
---|
1721 | for(int j=0; j<m; j++){
|
---|
1722 | int l = array[i][j].length;
|
---|
1723 | copy[i][j] = new Polynomial[l][];
|
---|
1724 | for(int k=0; k<l;k++){
|
---|
1725 | int ll = array[i][j][k].length;
|
---|
1726 | copy[i][j][k] = new Polynomial[ll];
|
---|
1727 | for(int kk=0; kk<ll;kk++){
|
---|
1728 | copy[i][j][k][kk] = array[i][j][k][kk].copy();
|
---|
1729 | }
|
---|
1730 | }
|
---|
1731 | }
|
---|
1732 | }
|
---|
1733 | return copy;
|
---|
1734 | }
|
---|
1735 |
|
---|
1736 | // COPY A ONE DIMENSIONAL ARRAY OF BigDecimal
|
---|
1737 | public static BigDecimal[] copy(BigDecimal[] array){
|
---|
1738 | if(array==null)return null;
|
---|
1739 | int n = array.length;
|
---|
1740 | BigDecimal[] copy = new BigDecimal[n];
|
---|
1741 | for(int i=0; i<n; i++){
|
---|
1742 | copy[i] = array[i];
|
---|
1743 | }
|
---|
1744 | return copy;
|
---|
1745 | }
|
---|
1746 |
|
---|
1747 | // COPY A TWO DIMENSIONAL ARRAY OF BigDecimal
|
---|
1748 | public static BigDecimal[][] copy(BigDecimal[][] array){
|
---|
1749 | if(array==null)return null;
|
---|
1750 | int n = array.length;
|
---|
1751 | BigDecimal[][] copy = new BigDecimal[n][];
|
---|
1752 | for(int i=0; i<n; i++){
|
---|
1753 | int m = array[i].length;
|
---|
1754 | copy[i] = new BigDecimal[m];
|
---|
1755 | for(int j=0; j<m; j++){
|
---|
1756 | copy[i][j] = array[i][j];
|
---|
1757 | }
|
---|
1758 | }
|
---|
1759 | return copy;
|
---|
1760 | }
|
---|
1761 |
|
---|
1762 | // COPY A THREE DIMENSIONAL ARRAY OF BigDecimal
|
---|
1763 | public static BigDecimal[][][] copy(BigDecimal[][][] array){
|
---|
1764 | if(array==null)return null;
|
---|
1765 | int n = array.length;
|
---|
1766 | BigDecimal[][][] copy = new BigDecimal[n][][];
|
---|
1767 | for(int i=0; i<n; i++){
|
---|
1768 | int m = array[i].length;
|
---|
1769 | copy[i] = new BigDecimal[m][];
|
---|
1770 | for(int j=0; j<m; j++){
|
---|
1771 | int l = array[i][j].length;
|
---|
1772 | copy[i][j] = new BigDecimal[l];
|
---|
1773 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k];
|
---|
1774 | }
|
---|
1775 | }
|
---|
1776 | return copy;
|
---|
1777 | }
|
---|
1778 |
|
---|
1779 | // COPY A FOUR DIMENSIONAL ARRAY OF BigDecimal
|
---|
1780 | public static BigDecimal[][][][] copy(BigDecimal[][][][] array){
|
---|
1781 | if(array==null)return null;
|
---|
1782 | int n = array.length;
|
---|
1783 | BigDecimal[][][][] copy = new BigDecimal[n][][][];
|
---|
1784 | for(int i=0; i<n; i++){
|
---|
1785 | int m = array[i].length;
|
---|
1786 | copy[i] = new BigDecimal[m][][];
|
---|
1787 | for(int j=0; j<m; j++){
|
---|
1788 | int l = array[i][j].length;
|
---|
1789 | copy[i][j] = new BigDecimal[l][];
|
---|
1790 | for(int k=0; k<l;k++){
|
---|
1791 | int ll = array[i][j][k].length;
|
---|
1792 | copy[i][j][k] = new BigDecimal[ll];
|
---|
1793 | for(int kk=0; kk<ll;kk++){
|
---|
1794 | copy[i][j][k][kk] = array[i][j][k][kk];
|
---|
1795 | }
|
---|
1796 | }
|
---|
1797 | }
|
---|
1798 | }
|
---|
1799 | return copy;
|
---|
1800 | }
|
---|
1801 |
|
---|
1802 |
|
---|
1803 |
|
---|
1804 |
|
---|
1805 | // COPY A ONE DIMENSIONAL ARRAY OF BigInteger
|
---|
1806 | public static BigInteger[] copy(BigInteger[] array){
|
---|
1807 | if(array==null)return null;
|
---|
1808 | int n = array.length;
|
---|
1809 | BigInteger[] copy = new BigInteger[n];
|
---|
1810 | for(int i=0; i<n; i++){
|
---|
1811 | copy[i] = array[i];
|
---|
1812 | }
|
---|
1813 | return copy;
|
---|
1814 | }
|
---|
1815 |
|
---|
1816 | // COPY A TWO DIMENSIONAL ARRAY OF BigInteger
|
---|
1817 | public static BigInteger[][] copy(BigInteger[][] array){
|
---|
1818 | if(array==null)return null;
|
---|
1819 | int n = array.length;
|
---|
1820 | BigInteger[][] copy = new BigInteger[n][];
|
---|
1821 | for(int i=0; i<n; i++){
|
---|
1822 | int m = array[i].length;
|
---|
1823 | copy[i] = new BigInteger[m];
|
---|
1824 | for(int j=0; j<m; j++){
|
---|
1825 | copy[i][j] = array[i][j];
|
---|
1826 | }
|
---|
1827 | }
|
---|
1828 | return copy;
|
---|
1829 | }
|
---|
1830 |
|
---|
1831 | // COPY A THREE DIMENSIONAL ARRAY OF BigInteger
|
---|
1832 | public static BigInteger[][][] copy(BigInteger[][][] array){
|
---|
1833 | if(array==null)return null;
|
---|
1834 | int n = array.length;
|
---|
1835 | BigInteger[][][] copy = new BigInteger[n][][];
|
---|
1836 | for(int i=0; i<n; i++){
|
---|
1837 | int m = array[i].length;
|
---|
1838 | copy[i] = new BigInteger[m][];
|
---|
1839 | for(int j=0; j<m; j++){
|
---|
1840 | int l = array[i][j].length;
|
---|
1841 | copy[i][j] = new BigInteger[l];
|
---|
1842 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k];
|
---|
1843 | }
|
---|
1844 | }
|
---|
1845 | return copy;
|
---|
1846 | }
|
---|
1847 |
|
---|
1848 | // COPY A FOUR DIMENSIONAL ARRAY OF BigInteger
|
---|
1849 | public static BigInteger[][][][] copy(BigInteger[][][][] array){
|
---|
1850 | if(array==null)return null;
|
---|
1851 | int n = array.length;
|
---|
1852 | BigInteger[][][][] copy = new BigInteger[n][][][];
|
---|
1853 | for(int i=0; i<n; i++){
|
---|
1854 | int m = array[i].length;
|
---|
1855 | copy[i] = new BigInteger[m][][];
|
---|
1856 | for(int j=0; j<m; j++){
|
---|
1857 | int l = array[i][j].length;
|
---|
1858 | copy[i][j] = new BigInteger[l][];
|
---|
1859 | for(int k=0; k<l;k++){
|
---|
1860 | int ll = array[i][j][k].length;
|
---|
1861 | copy[i][j][k] = new BigInteger[ll];
|
---|
1862 | for(int kk=0; kk<ll;kk++){
|
---|
1863 | copy[i][j][k][kk] = array[i][j][k][kk];
|
---|
1864 | }
|
---|
1865 | }
|
---|
1866 | }
|
---|
1867 | }
|
---|
1868 | return copy;
|
---|
1869 | }
|
---|
1870 |
|
---|
1871 | // COPY A ONE DIMENSIONAL ARRAY OF ErrorProp
|
---|
1872 | public static ErrorProp[] copy(ErrorProp[] array){
|
---|
1873 | if(array==null)return null;
|
---|
1874 | int n = array.length;
|
---|
1875 | ErrorProp[] copy = new ErrorProp[n];
|
---|
1876 | for(int i=0; i<n; i++){
|
---|
1877 | copy[i] = array[i].copy();
|
---|
1878 | }
|
---|
1879 | return copy;
|
---|
1880 | }
|
---|
1881 |
|
---|
1882 | // COPY A TWO DIMENSIONAL ARRAY OF ErrorProp
|
---|
1883 | public static ErrorProp[][] copy(ErrorProp[][] array){
|
---|
1884 | if(array==null)return null;
|
---|
1885 | int n = array.length;
|
---|
1886 | ErrorProp[][] copy = new ErrorProp[n][];
|
---|
1887 | for(int i=0; i<n; i++){
|
---|
1888 | int m = array[i].length;
|
---|
1889 | copy[i] = new ErrorProp[m];
|
---|
1890 | for(int j=0; j<m; j++){
|
---|
1891 | copy[i][j] = array[i][j].copy();
|
---|
1892 | }
|
---|
1893 | }
|
---|
1894 | return copy;
|
---|
1895 | }
|
---|
1896 |
|
---|
1897 | // COPY A THREE DIMENSIONAL ARRAY OF ErrorProp
|
---|
1898 | public static ErrorProp[][][] copy(ErrorProp[][][] array){
|
---|
1899 | if(array==null)return null;
|
---|
1900 | int n = array.length;
|
---|
1901 | ErrorProp[][][] copy = new ErrorProp[n][][];
|
---|
1902 | for(int i=0; i<n; i++){
|
---|
1903 | int m = array[i].length;
|
---|
1904 | copy[i] = new ErrorProp[m][];
|
---|
1905 | for(int j=0; j<m; j++){
|
---|
1906 | int l = array[i][j].length;
|
---|
1907 | copy[i][j] = new ErrorProp[l];
|
---|
1908 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k].copy();
|
---|
1909 | }
|
---|
1910 | }
|
---|
1911 | return copy;
|
---|
1912 | }
|
---|
1913 |
|
---|
1914 | // COPY A FOUR DIMENSIONAL ARRAY OF ErrorProp
|
---|
1915 | public static ErrorProp[][][][] copy(ErrorProp[][][][] array){
|
---|
1916 | if(array==null)return null;
|
---|
1917 | int n = array.length;
|
---|
1918 | ErrorProp[][][][] copy = new ErrorProp[n][][][];
|
---|
1919 | for(int i=0; i<n; i++){
|
---|
1920 | int m = array[i].length;
|
---|
1921 | copy[i] = new ErrorProp[m][][];
|
---|
1922 | for(int j=0; j<m; j++){
|
---|
1923 | int l = array[i][j].length;
|
---|
1924 | copy[i][j] = new ErrorProp[l][];
|
---|
1925 | for(int k=0; k<l;k++){
|
---|
1926 | int ll = array[i][j][k].length;
|
---|
1927 | copy[i][j][k] = new ErrorProp[ll];
|
---|
1928 | for(int kk=0; kk<ll;kk++){
|
---|
1929 | copy[i][j][k][kk] = array[i][j][k][kk].copy();
|
---|
1930 | }
|
---|
1931 | }
|
---|
1932 | }
|
---|
1933 | }
|
---|
1934 | return copy;
|
---|
1935 | }
|
---|
1936 |
|
---|
1937 |
|
---|
1938 | // COPY A ONE DIMENSIONAL ARRAY OF ComplexErrorProp
|
---|
1939 | public static ComplexErrorProp[] copy(ComplexErrorProp[] array){
|
---|
1940 | if(array==null)return null;
|
---|
1941 | int n = array.length;
|
---|
1942 | ComplexErrorProp[] copy = new ComplexErrorProp[n];
|
---|
1943 | for(int i=0; i<n; i++){
|
---|
1944 | copy[i] = array[i].copy();
|
---|
1945 | }
|
---|
1946 | return copy;
|
---|
1947 | }
|
---|
1948 |
|
---|
1949 | // COPY A TWO DIMENSIONAL ARRAY OF ComplexErrorProp
|
---|
1950 | public static ComplexErrorProp[][] copy(ComplexErrorProp[][] array){
|
---|
1951 | if(array==null)return null;
|
---|
1952 | int n = array.length;
|
---|
1953 | ComplexErrorProp[][] copy = new ComplexErrorProp[n][];
|
---|
1954 | for(int i=0; i<n; i++){
|
---|
1955 | int m = array[i].length;
|
---|
1956 | copy[i] = new ComplexErrorProp[m];
|
---|
1957 | for(int j=0; j<m; j++){
|
---|
1958 | copy[i][j] = array[i][j].copy();
|
---|
1959 | }
|
---|
1960 | }
|
---|
1961 | return copy;
|
---|
1962 | }
|
---|
1963 |
|
---|
1964 | // COPY A THREE DIMENSIONAL ARRAY OF ComplexErrorProp
|
---|
1965 | public static ComplexErrorProp[][][] copy(ComplexErrorProp[][][] array){
|
---|
1966 | if(array==null)return null;
|
---|
1967 | int n = array.length;
|
---|
1968 | ComplexErrorProp[][][] copy = new ComplexErrorProp[n][][];
|
---|
1969 | for(int i=0; i<n; i++){
|
---|
1970 | int m = array[i].length;
|
---|
1971 | copy[i] = new ComplexErrorProp[m][];
|
---|
1972 | for(int j=0; j<m; j++){
|
---|
1973 | int l = array[i][j].length;
|
---|
1974 | copy[i][j] = new ComplexErrorProp[l];
|
---|
1975 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k].copy();
|
---|
1976 | }
|
---|
1977 | }
|
---|
1978 | return copy;
|
---|
1979 | }
|
---|
1980 |
|
---|
1981 | // COPY A FOUR DIMENSIONAL ARRAY OF ComplexErrorProp
|
---|
1982 | public static ComplexErrorProp[][][][] copy(ComplexErrorProp[][][][] array){
|
---|
1983 | if(array==null)return null;
|
---|
1984 | int n = array.length;
|
---|
1985 | ComplexErrorProp[][][][] copy = new ComplexErrorProp[n][][][];
|
---|
1986 | for(int i=0; i<n; i++){
|
---|
1987 | int m = array[i].length;
|
---|
1988 | copy[i] = new ComplexErrorProp[m][][];
|
---|
1989 | for(int j=0; j<m; j++){
|
---|
1990 | int l = array[i][j].length;
|
---|
1991 | copy[i][j] = new ComplexErrorProp[l][];
|
---|
1992 | for(int k=0; k<l;k++){
|
---|
1993 | int ll = array[i][j][k].length;
|
---|
1994 | copy[i][j][k] = new ComplexErrorProp[ll];
|
---|
1995 | for(int kk=0; kk<ll;kk++){
|
---|
1996 | copy[i][j][k][kk] = array[i][j][k][kk].copy();
|
---|
1997 | }
|
---|
1998 | }
|
---|
1999 | }
|
---|
2000 | }
|
---|
2001 | return copy;
|
---|
2002 | }
|
---|
2003 |
|
---|
2004 |
|
---|
2005 |
|
---|
2006 | // COPY A ONE DIMENSIONAL ARRAY OF Phasor
|
---|
2007 | public static Phasor[] copy(Phasor[] array){
|
---|
2008 | if(array==null)return null;
|
---|
2009 | int n = array.length;
|
---|
2010 | Phasor[] copy = new Phasor[n];
|
---|
2011 | for(int i=0; i<n; i++){
|
---|
2012 | copy[i] = array[i].copy();
|
---|
2013 | }
|
---|
2014 | return copy;
|
---|
2015 | }
|
---|
2016 |
|
---|
2017 | // COPY A TWO DIMENSIONAL ARRAY OF Phasor
|
---|
2018 | public static Phasor[][] copy(Phasor[][] array){
|
---|
2019 | if(array==null)return null;
|
---|
2020 | int n = array.length;
|
---|
2021 | Phasor[][] copy = new Phasor[n][];
|
---|
2022 | for(int i=0; i<n; i++){
|
---|
2023 | int m = array[i].length;
|
---|
2024 | copy[i] = new Phasor[m];
|
---|
2025 | for(int j=0; j<m; j++){
|
---|
2026 | copy[i][j] = array[i][j].copy();
|
---|
2027 | }
|
---|
2028 | }
|
---|
2029 | return copy;
|
---|
2030 | }
|
---|
2031 |
|
---|
2032 | // COPY A THREE DIMENSIONAL ARRAY OF Phasor
|
---|
2033 | public static Phasor[][][] copy(Phasor[][][] array){
|
---|
2034 | if(array==null)return null;
|
---|
2035 | int n = array.length;
|
---|
2036 | Phasor[][][] copy = new Phasor[n][][];
|
---|
2037 | for(int i=0; i<n; i++){
|
---|
2038 | int m = array[i].length;
|
---|
2039 | copy[i] = new Phasor[m][];
|
---|
2040 | for(int j=0; j<m; j++){
|
---|
2041 | int l = array[i][j].length;
|
---|
2042 | copy[i][j] = new Phasor[l];
|
---|
2043 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k].copy();
|
---|
2044 | }
|
---|
2045 | }
|
---|
2046 | return copy;
|
---|
2047 | }
|
---|
2048 |
|
---|
2049 | // COPY A FOUR DIMENSIONAL ARRAY OF Phasor
|
---|
2050 | public static Phasor[][][][] copy(Phasor[][][][] array){
|
---|
2051 | if(array==null)return null;
|
---|
2052 | int n = array.length;
|
---|
2053 | Phasor[][][][] copy = new Phasor[n][][][];
|
---|
2054 | for(int i=0; i<n; i++){
|
---|
2055 | int m = array[i].length;
|
---|
2056 | copy[i] = new Phasor[m][][];
|
---|
2057 | for(int j=0; j<m; j++){
|
---|
2058 | int l = array[i][j].length;
|
---|
2059 | copy[i][j] = new Phasor[l][];
|
---|
2060 | for(int k=0; k<l;k++){
|
---|
2061 | int ll = array[i][j][k].length;
|
---|
2062 | copy[i][j][k] = new Phasor[ll];
|
---|
2063 | for(int kk=0; kk<ll;kk++){
|
---|
2064 | copy[i][j][k][kk] = array[i][j][k][kk].copy();
|
---|
2065 | }
|
---|
2066 | }
|
---|
2067 | }
|
---|
2068 | }
|
---|
2069 | return copy;
|
---|
2070 | }
|
---|
2071 |
|
---|
2072 | // COPY A ONE DIMENSIONAL ARRAY OF short
|
---|
2073 | public static short[] copy(short[] array){
|
---|
2074 | if(array==null)return null;
|
---|
2075 | int n = array.length;
|
---|
2076 | short[] copy = new short[n];
|
---|
2077 | for(int i=0; i<n; i++){
|
---|
2078 | copy[i] = array[i];
|
---|
2079 | }
|
---|
2080 | return copy;
|
---|
2081 | }
|
---|
2082 |
|
---|
2083 | // COPY A TWO DIMENSIONAL ARRAY OF short
|
---|
2084 | public static short[][] copy(short[][] array){
|
---|
2085 | if(array==null)return null;
|
---|
2086 | int n = array.length;
|
---|
2087 | short[][] copy = new short[n][];
|
---|
2088 | for(int i=0; i<n; i++){
|
---|
2089 | int m = array[i].length;
|
---|
2090 | copy[i] = new short[m];
|
---|
2091 | for(int j=0; j<m; j++){
|
---|
2092 | copy[i][j] = array[i][j];
|
---|
2093 | }
|
---|
2094 | }
|
---|
2095 | return copy;
|
---|
2096 | }
|
---|
2097 |
|
---|
2098 | // COPY A THREE DIMENSIONAL ARRAY OF short
|
---|
2099 | public static short[][][] copy(short[][][] array){
|
---|
2100 | if(array==null)return null;
|
---|
2101 | int n = array.length;
|
---|
2102 | short[][][] copy = new short[n][][];
|
---|
2103 | for(int i=0; i<n; i++){
|
---|
2104 | int m = array[i].length;
|
---|
2105 | copy[i] = new short[m][];
|
---|
2106 | for(int j=0; j<m; j++){
|
---|
2107 | int l = array[i][j].length;
|
---|
2108 | copy[i][j] = new short[l];
|
---|
2109 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k];
|
---|
2110 | }
|
---|
2111 | }
|
---|
2112 | return copy;
|
---|
2113 | }
|
---|
2114 |
|
---|
2115 | // COPY A FOUR DIMENSIONAL ARRAY OF short
|
---|
2116 | public static short[][][][] copy(short[][][][] array){
|
---|
2117 | if(array==null)return null;
|
---|
2118 | int n = array.length;
|
---|
2119 | short[][][][] copy = new short[n][][][];
|
---|
2120 | for(int i=0; i<n; i++){
|
---|
2121 | int m = array[i].length;
|
---|
2122 | copy[i] = new short[m][][];
|
---|
2123 | for(int j=0; j<m; j++){
|
---|
2124 | int l = array[i][j].length;
|
---|
2125 | copy[i][j] = new short[l][];
|
---|
2126 | for(int k=0; k<l;k++){
|
---|
2127 | int ll = array[i][j][k].length;
|
---|
2128 | copy[i][j][k] = new short[ll];
|
---|
2129 | for(int kk=0; kk<ll;kk++){
|
---|
2130 | copy[i][j][k][kk] = array[i][j][k][kk];
|
---|
2131 | }
|
---|
2132 | }
|
---|
2133 | }
|
---|
2134 | }
|
---|
2135 | return copy;
|
---|
2136 | }
|
---|
2137 |
|
---|
2138 |
|
---|
2139 |
|
---|
2140 |
|
---|
2141 | // COPY A ONE DIMENSIONAL ARRAY OF byte
|
---|
2142 | public static byte[] copy(byte[] array){
|
---|
2143 | if(array==null)return null;
|
---|
2144 | int n = array.length;
|
---|
2145 | byte[] copy = new byte[n];
|
---|
2146 | for(int i=0; i<n; i++){
|
---|
2147 | copy[i] = array[i];
|
---|
2148 | }
|
---|
2149 | return copy;
|
---|
2150 | }
|
---|
2151 |
|
---|
2152 | // COPY A TWO DIMENSIONAL ARRAY OF byte
|
---|
2153 | public static byte[][] copy(byte[][] array){
|
---|
2154 | if(array==null)return null;
|
---|
2155 | int n = array.length;
|
---|
2156 | byte[][] copy = new byte[n][];
|
---|
2157 | for(int i=0; i<n; i++){
|
---|
2158 | int m = array[i].length;
|
---|
2159 | copy[i] = new byte[m];
|
---|
2160 | for(int j=0; j<m; j++){
|
---|
2161 | copy[i][j] = array[i][j];
|
---|
2162 | }
|
---|
2163 | }
|
---|
2164 | return copy;
|
---|
2165 | }
|
---|
2166 |
|
---|
2167 | // COPY A THREE DIMENSIONAL ARRAY OF byte
|
---|
2168 | public static byte[][][] copy(byte[][][] array){
|
---|
2169 | if(array==null)return null;
|
---|
2170 | int n = array.length;
|
---|
2171 | byte[][][] copy = new byte[n][][];
|
---|
2172 | for(int i=0; i<n; i++){
|
---|
2173 | int m = array[i].length;
|
---|
2174 | copy[i] = new byte[m][];
|
---|
2175 | for(int j=0; j<m; j++){
|
---|
2176 | int l = array[i][j].length;
|
---|
2177 | copy[i][j] = new byte[l];
|
---|
2178 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k];
|
---|
2179 | }
|
---|
2180 | }
|
---|
2181 | return copy;
|
---|
2182 | }
|
---|
2183 |
|
---|
2184 | // COPY A FOUR DIMENSIONAL ARRAY OF byte
|
---|
2185 | public static byte[][][][] copy(byte[][][][] array){
|
---|
2186 | if(array==null)return null;
|
---|
2187 | int n = array.length;
|
---|
2188 | byte[][][][] copy = new byte[n][][][];
|
---|
2189 | for(int i=0; i<n; i++){
|
---|
2190 | int m = array[i].length;
|
---|
2191 | copy[i] = new byte[m][][];
|
---|
2192 | for(int j=0; j<m; j++){
|
---|
2193 | int l = array[i][j].length;
|
---|
2194 | copy[i][j] = new byte[l][];
|
---|
2195 | for(int k=0; k<l;k++){
|
---|
2196 | int ll = array[i][j][k].length;
|
---|
2197 | copy[i][j][k] = new byte[ll];
|
---|
2198 | for(int kk=0; kk<ll;kk++){
|
---|
2199 | copy[i][j][k][kk] = array[i][j][k][kk];
|
---|
2200 | }
|
---|
2201 | }
|
---|
2202 | }
|
---|
2203 | }
|
---|
2204 | return copy;
|
---|
2205 | }
|
---|
2206 |
|
---|
2207 |
|
---|
2208 | // COPY A ONE DIMENSIONAL ARRAY OF Double
|
---|
2209 | public static Double[] copy(Double[] array){
|
---|
2210 | if(array==null)return null;
|
---|
2211 | int n = array.length;
|
---|
2212 | Double[] copy = new Double[n];
|
---|
2213 | for(int i=0; i<n; i++){
|
---|
2214 | copy[i] = array[i];
|
---|
2215 | }
|
---|
2216 | return copy;
|
---|
2217 | }
|
---|
2218 |
|
---|
2219 | // COPY A TWO DIMENSIONAL ARRAY OF Double
|
---|
2220 | public static Double[][] copy(Double[][] array){
|
---|
2221 | if(array==null)return null;
|
---|
2222 | int n = array.length;
|
---|
2223 | Double[][] copy = new Double[n][];
|
---|
2224 | for(int i=0; i<n; i++){
|
---|
2225 | int m = array[i].length;
|
---|
2226 | copy[i] = new Double[m];
|
---|
2227 | for(int j=0; j<m; j++){
|
---|
2228 | copy[i][j] = array[i][j];
|
---|
2229 | }
|
---|
2230 | }
|
---|
2231 | return copy;
|
---|
2232 | }
|
---|
2233 |
|
---|
2234 | // COPY A THREE DIMENSIONAL ARRAY OF Double
|
---|
2235 | public static Double[][][] copy(Double[][][] array){
|
---|
2236 | if(array==null)return null;
|
---|
2237 | int n = array.length;
|
---|
2238 | Double[][][] copy = new Double[n][][];
|
---|
2239 | for(int i=0; i<n; i++){
|
---|
2240 | int m = array[i].length;
|
---|
2241 | copy[i] = new Double[m][];
|
---|
2242 | for(int j=0; j<m; j++){
|
---|
2243 | int l = array[i][j].length;
|
---|
2244 | copy[i][j] = new Double[l];
|
---|
2245 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k];
|
---|
2246 | }
|
---|
2247 | }
|
---|
2248 | return copy;
|
---|
2249 | }
|
---|
2250 |
|
---|
2251 | // COPY A FOUR DIMENSIONAL ARRAY OF Double
|
---|
2252 | public static Double[][][][] copy(Double[][][][] array){
|
---|
2253 | if(array==null)return null;
|
---|
2254 | int n = array.length;
|
---|
2255 | Double[][][][] copy = new Double[n][][][];
|
---|
2256 | for(int i=0; i<n; i++){
|
---|
2257 | int m = array[i].length;
|
---|
2258 | copy[i] = new Double[m][][];
|
---|
2259 | for(int j=0; j<m; j++){
|
---|
2260 | int l = array[i][j].length;
|
---|
2261 | copy[i][j] = new Double[l][];
|
---|
2262 | for(int k=0; k<l;k++){
|
---|
2263 | int ll = array[i][j][k].length;
|
---|
2264 | copy[i][j][k] = new Double[ll];
|
---|
2265 | for(int kk=0; kk<ll;kk++){
|
---|
2266 | copy[i][j][k][kk] = array[i][j][k][kk];
|
---|
2267 | }
|
---|
2268 | }
|
---|
2269 | }
|
---|
2270 | }
|
---|
2271 | return copy;
|
---|
2272 | }
|
---|
2273 |
|
---|
2274 | // COPY A ONE DIMENSIONAL ARRAY OF Float
|
---|
2275 | public static Float[] copy(Float[] array){
|
---|
2276 | if(array==null)return null;
|
---|
2277 | int n = array.length;
|
---|
2278 | Float[] copy = new Float[n];
|
---|
2279 | for(int i=0; i<n; i++){
|
---|
2280 | copy[i] = array[i];
|
---|
2281 | }
|
---|
2282 | return copy;
|
---|
2283 | }
|
---|
2284 |
|
---|
2285 | // COPY A TWO DIMENSIONAL ARRAY OF Float
|
---|
2286 | public static Float[][] copy(Float[][] array){
|
---|
2287 | if(array==null)return null;
|
---|
2288 | int n = array.length;
|
---|
2289 | Float[][] copy = new Float[n][];
|
---|
2290 | for(int i=0; i<n; i++){
|
---|
2291 | int m = array[i].length;
|
---|
2292 | copy[i] = new Float[m];
|
---|
2293 | for(int j=0; j<m; j++){
|
---|
2294 | copy[i][j] = array[i][j];
|
---|
2295 | }
|
---|
2296 | }
|
---|
2297 | return copy;
|
---|
2298 | }
|
---|
2299 |
|
---|
2300 | // COPY A THREE DIMENSIONAL ARRAY OF Float
|
---|
2301 | public static Float[][][] copy(Float[][][] array){
|
---|
2302 | if(array==null)return null;
|
---|
2303 | int n = array.length;
|
---|
2304 | Float[][][] copy = new Float[n][][];
|
---|
2305 | for(int i=0; i<n; i++){
|
---|
2306 | int m = array[i].length;
|
---|
2307 | copy[i] = new Float[m][];
|
---|
2308 | for(int j=0; j<m; j++){
|
---|
2309 | int l = array[i][j].length;
|
---|
2310 | copy[i][j] = new Float[l];
|
---|
2311 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k];
|
---|
2312 | }
|
---|
2313 | }
|
---|
2314 | return copy;
|
---|
2315 | }
|
---|
2316 |
|
---|
2317 | // COPY A FOUR DIMENSIONAL ARRAY OF Float
|
---|
2318 | public static Float[][][][] copy(Float[][][][] array){
|
---|
2319 | if(array==null)return null;
|
---|
2320 | int n = array.length;
|
---|
2321 | Float[][][][] copy = new Float[n][][][];
|
---|
2322 | for(int i=0; i<n; i++){
|
---|
2323 | int m = array[i].length;
|
---|
2324 | copy[i] = new Float[m][][];
|
---|
2325 | for(int j=0; j<m; j++){
|
---|
2326 | int l = array[i][j].length;
|
---|
2327 | copy[i][j] = new Float[l][];
|
---|
2328 | for(int k=0; k<l;k++){
|
---|
2329 | int ll = array[i][j][k].length;
|
---|
2330 | copy[i][j][k] = new Float[ll];
|
---|
2331 | for(int kk=0; kk<ll;kk++){
|
---|
2332 | copy[i][j][k][kk] = array[i][j][k][kk];
|
---|
2333 | }
|
---|
2334 | }
|
---|
2335 | }
|
---|
2336 | }
|
---|
2337 | return copy;
|
---|
2338 | }
|
---|
2339 |
|
---|
2340 | // COPY A ONE DIMENSIONAL ARRAY OF Long
|
---|
2341 | public static Long[] copy(Long[] array){
|
---|
2342 | if(array==null)return null;
|
---|
2343 | int n = array.length;
|
---|
2344 | Long[] copy = new Long[n];
|
---|
2345 | for(int i=0; i<n; i++){
|
---|
2346 | copy[i] = array[i];
|
---|
2347 | }
|
---|
2348 | return copy;
|
---|
2349 | }
|
---|
2350 |
|
---|
2351 | // COPY A TWO DIMENSIONAL ARRAY OF Long
|
---|
2352 | public static Long[][] copy(Long[][] array){
|
---|
2353 | if(array==null)return null;
|
---|
2354 | int n = array.length;
|
---|
2355 | Long[][] copy = new Long[n][];
|
---|
2356 | for(int i=0; i<n; i++){
|
---|
2357 | int m = array[i].length;
|
---|
2358 | copy[i] = new Long[m];
|
---|
2359 | for(int j=0; j<m; j++){
|
---|
2360 | copy[i][j] = array[i][j];
|
---|
2361 | }
|
---|
2362 | }
|
---|
2363 | return copy;
|
---|
2364 | }
|
---|
2365 |
|
---|
2366 | // COPY A THREE DIMENSIONAL ARRAY OF Long
|
---|
2367 | public static Long[][][] copy(Long[][][] array){
|
---|
2368 | if(array==null)return null;
|
---|
2369 | int n = array.length;
|
---|
2370 | Long[][][] copy = new Long[n][][];
|
---|
2371 | for(int i=0; i<n; i++){
|
---|
2372 | int m = array[i].length;
|
---|
2373 | copy[i] = new Long[m][];
|
---|
2374 | for(int j=0; j<m; j++){
|
---|
2375 | int l = array[i][j].length;
|
---|
2376 | copy[i][j] = new Long[l];
|
---|
2377 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k];
|
---|
2378 | }
|
---|
2379 | }
|
---|
2380 | return copy;
|
---|
2381 | }
|
---|
2382 |
|
---|
2383 | // COPY A FOUR DIMENSIONAL ARRAY OF Long
|
---|
2384 | public static Long[][][][] copy(Long[][][][] array){
|
---|
2385 | if(array==null)return null;
|
---|
2386 | int n = array.length;
|
---|
2387 | Long[][][][] copy = new Long[n][][][];
|
---|
2388 | for(int i=0; i<n; i++){
|
---|
2389 | int m = array[i].length;
|
---|
2390 | copy[i] = new Long[m][][];
|
---|
2391 | for(int j=0; j<m; j++){
|
---|
2392 | int l = array[i][j].length;
|
---|
2393 | copy[i][j] = new Long[l][];
|
---|
2394 | for(int k=0; k<l;k++){
|
---|
2395 | int ll = array[i][j][k].length;
|
---|
2396 | copy[i][j][k] = new Long[ll];
|
---|
2397 | for(int kk=0; kk<ll;kk++){
|
---|
2398 | copy[i][j][k][kk] = array[i][j][k][kk];
|
---|
2399 | }
|
---|
2400 | }
|
---|
2401 | }
|
---|
2402 | }
|
---|
2403 | return copy;
|
---|
2404 | }
|
---|
2405 |
|
---|
2406 | // COPY A ONE DIMENSIONAL ARRAY OF Integer
|
---|
2407 | public static Integer[] copy(Integer[] array){
|
---|
2408 | if(array==null)return null;
|
---|
2409 | int n = array.length;
|
---|
2410 | Integer[] copy = new Integer[n];
|
---|
2411 | for(int i=0; i<n; i++){
|
---|
2412 | copy[i] = array[i];
|
---|
2413 | }
|
---|
2414 | return copy;
|
---|
2415 | }
|
---|
2416 |
|
---|
2417 | // COPY A TWO DIMENSIONAL ARRAY OF Integer
|
---|
2418 | public static Integer[][] copy(Integer[][] array){
|
---|
2419 | if(array==null)return null;
|
---|
2420 | int n = array.length;
|
---|
2421 | Integer[][] copy = new Integer[n][];
|
---|
2422 | for(int i=0; i<n; i++){
|
---|
2423 | int m = array[i].length;
|
---|
2424 | copy[i] = new Integer[m];
|
---|
2425 | for(int j=0; j<m; j++){
|
---|
2426 | copy[i][j] = array[i][j];
|
---|
2427 | }
|
---|
2428 | }
|
---|
2429 | return copy;
|
---|
2430 | }
|
---|
2431 |
|
---|
2432 | // COPY A THREE DIMENSIONAL ARRAY OF Integer
|
---|
2433 | public static Integer[][][] copy(Integer[][][] array){
|
---|
2434 | if(array==null)return null;
|
---|
2435 | int n = array.length;
|
---|
2436 | Integer[][][] copy = new Integer[n][][];
|
---|
2437 | for(int i=0; i<n; i++){
|
---|
2438 | int m = array[i].length;
|
---|
2439 | copy[i] = new Integer[m][];
|
---|
2440 | for(int j=0; j<m; j++){
|
---|
2441 | int l = array[i][j].length;
|
---|
2442 | copy[i][j] = new Integer[l];
|
---|
2443 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k];
|
---|
2444 | }
|
---|
2445 | }
|
---|
2446 | return copy;
|
---|
2447 | }
|
---|
2448 |
|
---|
2449 | // COPY A FOUR DIMENSIONAL ARRAY OF Integer
|
---|
2450 | public static Integer[][][][] copy(Integer[][][][] array){
|
---|
2451 | if(array==null)return null;
|
---|
2452 | int n = array.length;
|
---|
2453 | Integer[][][][] copy = new Integer[n][][][];
|
---|
2454 | for(int i=0; i<n; i++){
|
---|
2455 | int m = array[i].length;
|
---|
2456 | copy[i] = new Integer[m][][];
|
---|
2457 | for(int j=0; j<m; j++){
|
---|
2458 | int l = array[i][j].length;
|
---|
2459 | copy[i][j] = new Integer[l][];
|
---|
2460 | for(int k=0; k<l;k++){
|
---|
2461 | int ll = array[i][j][k].length;
|
---|
2462 | copy[i][j][k] = new Integer[ll];
|
---|
2463 | for(int kk=0; kk<ll;kk++){
|
---|
2464 | copy[i][j][k][kk] = array[i][j][k][kk];
|
---|
2465 | }
|
---|
2466 | }
|
---|
2467 | }
|
---|
2468 | }
|
---|
2469 | return copy;
|
---|
2470 | }
|
---|
2471 |
|
---|
2472 |
|
---|
2473 | // COPY A ONE DIMENSIONAL ARRAY OF Short
|
---|
2474 | public static Short[] copy(Short[] array){
|
---|
2475 | if(array==null)return null;
|
---|
2476 | int n = array.length;
|
---|
2477 | Short[] copy = new Short[n];
|
---|
2478 | for(int i=0; i<n; i++){
|
---|
2479 | copy[i] = array[i];
|
---|
2480 | }
|
---|
2481 | return copy;
|
---|
2482 | }
|
---|
2483 |
|
---|
2484 | // COPY A TWO DIMENSIONAL ARRAY OF Short
|
---|
2485 | public static Short[][] copy(Short[][] array){
|
---|
2486 | if(array==null)return null;
|
---|
2487 | int n = array.length;
|
---|
2488 | Short[][] copy = new Short[n][];
|
---|
2489 | for(int i=0; i<n; i++){
|
---|
2490 | int m = array[i].length;
|
---|
2491 | copy[i] = new Short[m];
|
---|
2492 | for(int j=0; j<m; j++){
|
---|
2493 | copy[i][j] = array[i][j];
|
---|
2494 | }
|
---|
2495 | }
|
---|
2496 | return copy;
|
---|
2497 | }
|
---|
2498 |
|
---|
2499 | // COPY A THREE DIMENSIONAL ARRAY OF Short
|
---|
2500 | public static Short[][][] copy(Short[][][] array){
|
---|
2501 | if(array==null)return null;
|
---|
2502 | int n = array.length;
|
---|
2503 | Short[][][] copy = new Short[n][][];
|
---|
2504 | for(int i=0; i<n; i++){
|
---|
2505 | int m = array[i].length;
|
---|
2506 | copy[i] = new Short[m][];
|
---|
2507 | for(int j=0; j<m; j++){
|
---|
2508 | int l = array[i][j].length;
|
---|
2509 | copy[i][j] = new Short[l];
|
---|
2510 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k];
|
---|
2511 | }
|
---|
2512 | }
|
---|
2513 | return copy;
|
---|
2514 | }
|
---|
2515 |
|
---|
2516 | // COPY A FOUR DIMENSIONAL ARRAY OF Short
|
---|
2517 | public static Short[][][][] copy(Short[][][][] array){
|
---|
2518 | if(array==null)return null;
|
---|
2519 | int n = array.length;
|
---|
2520 | Short[][][][] copy = new Short[n][][][];
|
---|
2521 | for(int i=0; i<n; i++){
|
---|
2522 | int m = array[i].length;
|
---|
2523 | copy[i] = new Short[m][][];
|
---|
2524 | for(int j=0; j<m; j++){
|
---|
2525 | int l = array[i][j].length;
|
---|
2526 | copy[i][j] = new Short[l][];
|
---|
2527 | for(int k=0; k<l;k++){
|
---|
2528 | int ll = array[i][j][k].length;
|
---|
2529 | copy[i][j][k] = new Short[ll];
|
---|
2530 | for(int kk=0; kk<ll;kk++){
|
---|
2531 | copy[i][j][k][kk] = array[i][j][k][kk];
|
---|
2532 | }
|
---|
2533 | }
|
---|
2534 | }
|
---|
2535 | }
|
---|
2536 | return copy;
|
---|
2537 | }
|
---|
2538 |
|
---|
2539 | // COPY A ONE DIMENSIONAL ARRAY OF Byte
|
---|
2540 | public static Byte[] copy(Byte[] array){
|
---|
2541 | if(array==null)return null;
|
---|
2542 | int n = array.length;
|
---|
2543 | Byte[] copy = new Byte[n];
|
---|
2544 | for(int i=0; i<n; i++){
|
---|
2545 | copy[i] = array[i];
|
---|
2546 | }
|
---|
2547 | return copy;
|
---|
2548 | }
|
---|
2549 |
|
---|
2550 | // COPY A TWO DIMENSIONAL ARRAY OF Byte
|
---|
2551 | public static Byte[][] copy(Byte[][] array){
|
---|
2552 | if(array==null)return null;
|
---|
2553 | int n = array.length;
|
---|
2554 | Byte[][] copy = new Byte[n][];
|
---|
2555 | for(int i=0; i<n; i++){
|
---|
2556 | int m = array[i].length;
|
---|
2557 | copy[i] = new Byte[m];
|
---|
2558 | for(int j=0; j<m; j++){
|
---|
2559 | copy[i][j] = array[i][j];
|
---|
2560 | }
|
---|
2561 | }
|
---|
2562 | return copy;
|
---|
2563 | }
|
---|
2564 |
|
---|
2565 | // COPY A THREE DIMENSIONAL ARRAY OF Byte
|
---|
2566 | public static Byte[][][] copy(Byte[][][] array){
|
---|
2567 | if(array==null)return null;
|
---|
2568 | int n = array.length;
|
---|
2569 | Byte[][][] copy = new Byte[n][][];
|
---|
2570 | for(int i=0; i<n; i++){
|
---|
2571 | int m = array[i].length;
|
---|
2572 | copy[i] = new Byte[m][];
|
---|
2573 | for(int j=0; j<m; j++){
|
---|
2574 | int l = array[i][j].length;
|
---|
2575 | copy[i][j] = new Byte[l];
|
---|
2576 | for(int k=0; k<l;k++)copy[i][j][k] = array[i][j][k];
|
---|
2577 | }
|
---|
2578 | }
|
---|
2579 | return copy;
|
---|
2580 | }
|
---|
2581 |
|
---|
2582 | // COPY A FOUR DIMENSIONAL ARRAY OF Byte
|
---|
2583 | public static Byte[][][][] copy(Byte[][][][] array){
|
---|
2584 | if(array==null)return null;
|
---|
2585 | int n = array.length;
|
---|
2586 | Byte[][][][] copy = new Byte[n][][][];
|
---|
2587 | for(int i=0; i<n; i++){
|
---|
2588 | int m = array[i].length;
|
---|
2589 | copy[i] = new Byte[m][][];
|
---|
2590 | for(int j=0; j<m; j++){
|
---|
2591 | int l = array[i][j].length;
|
---|
2592 | copy[i][j] = new Byte[l][];
|
---|
2593 | for(int k=0; k<l;k++){
|
---|
2594 | int ll = array[i][j][k].length;
|
---|
2595 | copy[i][j][k] = new Byte[ll];
|
---|
2596 | for(int kk=0; kk<ll;kk++){
|
---|
2597 | copy[i][j][k][kk] = array[i][j][k][kk];
|
---|
2598 | }
|
---|
2599 | }
|
---|
2600 | }
|
---|
2601 | }
|
---|
2602 | return copy;
|
---|
2603 | }
|
---|
2604 |
|
---|
2605 |
|
---|
2606 |
|
---|
2607 |
|
---|
2608 | // COPY OF AN OBJECT
|
---|
2609 | // An exception will be thrown if an attempt to copy a non-serialisable object is made.
|
---|
2610 | // Taken, with minor changes, from { Java Techniques }
|
---|
2611 | // http://javatechniques.com/blog/
|
---|
2612 | public static Object copy(Object obj){
|
---|
2613 | if(obj==null)return null;
|
---|
2614 | return Conv.copyObject(obj);
|
---|
2615 | }
|
---|
2616 |
|
---|
2617 | // COPY OF AN OBJECT
|
---|
2618 | // An exception will be thrown if an attempt to copy a non-serialisable object is made.
|
---|
2619 | // Taken, with minor changes, from { Java Techniques }
|
---|
2620 | // http://javatechniques.com/blog/
|
---|
2621 | public static Object copyObject(Object obj){
|
---|
2622 | if(obj==null)return null;
|
---|
2623 | Object objCopy = null;
|
---|
2624 | try {
|
---|
2625 | // Write the object out to a byte array
|
---|
2626 | ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
---|
2627 | ObjectOutputStream oos = new ObjectOutputStream(bos);
|
---|
2628 | oos.writeObject(obj);
|
---|
2629 | oos.flush();
|
---|
2630 | oos.close();
|
---|
2631 | // Make an input stream from the byte array and
|
---|
2632 | // read a copy of the object back in.
|
---|
2633 | ObjectInputStream ois = new ObjectInputStream(
|
---|
2634 | new ByteArrayInputStream(bos.toByteArray()));
|
---|
2635 | objCopy = ois.readObject();
|
---|
2636 | }
|
---|
2637 | catch(IOException e) {
|
---|
2638 | e.printStackTrace();
|
---|
2639 | }
|
---|
2640 | catch(ClassNotFoundException cnfe) {
|
---|
2641 | cnfe.printStackTrace();
|
---|
2642 | }
|
---|
2643 | return objCopy;
|
---|
2644 | }
|
---|
2645 |
|
---|
2646 | // UNIT CONVERSIONS
|
---|
2647 |
|
---|
2648 | // Converts radians to degrees
|
---|
2649 | public static double radToDeg(double rad){
|
---|
2650 | return rad*180.0D/Math.PI;
|
---|
2651 | }
|
---|
2652 |
|
---|
2653 | // Converts degrees to radians
|
---|
2654 | public static double degToRad(double deg){
|
---|
2655 | return deg*Math.PI/180.0D;
|
---|
2656 | }
|
---|
2657 |
|
---|
2658 | // Converts frequency (Hz) to radial frequency
|
---|
2659 | public static double frequencyToRadialFrequency(double frequency){
|
---|
2660 | return 2.0D*Math.PI*frequency;
|
---|
2661 | }
|
---|
2662 |
|
---|
2663 | // Converts radial frequency to frequency (Hz)
|
---|
2664 | public static double radialFrequencyToFrequency(double radial){
|
---|
2665 | return radial/(2.0D*Math.PI);
|
---|
2666 | }
|
---|
2667 |
|
---|
2668 | // Converts electron volts(eV) to corresponding wavelength in nm
|
---|
2669 | public static double evToNm(double ev){
|
---|
2670 | return 1e+9*Fmath.C_LIGHT/(-ev*Fmath.Q_ELECTRON/Fmath.H_PLANCK);
|
---|
2671 | }
|
---|
2672 |
|
---|
2673 | // Converts wavelength in nm to matching energy in eV
|
---|
2674 | public static double nmToEv(double nm)
|
---|
2675 | {
|
---|
2676 | return Fmath.C_LIGHT/(-nm*1e-9)*Fmath.H_PLANCK/Fmath.Q_ELECTRON;
|
---|
2677 | }
|
---|
2678 |
|
---|
2679 | // Converts moles per litre to percentage weight by volume
|
---|
2680 | public static double molarToPercentWeightByVol(double molar, double molWeight){
|
---|
2681 | return molar*molWeight/10.0D;
|
---|
2682 | }
|
---|
2683 |
|
---|
2684 | // Converts percentage weight by volume to moles per litre
|
---|
2685 | public static double percentWeightByVolToMolar(double perCent, double molWeight){
|
---|
2686 | return perCent*10.0D/molWeight;
|
---|
2687 | }
|
---|
2688 |
|
---|
2689 | // Converts Celsius to Kelvin
|
---|
2690 | public static double celsiusToKelvin(double cels){
|
---|
2691 | return cels-Fmath.T_ABS;
|
---|
2692 | }
|
---|
2693 |
|
---|
2694 | // Converts Kelvin to Celsius
|
---|
2695 | public static double kelvinToCelsius(double kelv){
|
---|
2696 | return kelv+Fmath.T_ABS;
|
---|
2697 | }
|
---|
2698 |
|
---|
2699 | // Converts Celsius to Fahrenheit
|
---|
2700 | public static double celsiusToFahren(double cels){
|
---|
2701 | return cels*(9.0/5.0)+32.0;
|
---|
2702 | }
|
---|
2703 |
|
---|
2704 | // Converts Fahrenheit to Celsius
|
---|
2705 | public static double fahrenToCelsius(double fahr){
|
---|
2706 | return (fahr-32.0)*5.0/9.0;
|
---|
2707 | }
|
---|
2708 |
|
---|
2709 | // Converts calories to Joules
|
---|
2710 | public static double calorieToJoule(double cal){
|
---|
2711 | return cal*4.1868;
|
---|
2712 | }
|
---|
2713 |
|
---|
2714 | // Converts Joules to calories
|
---|
2715 | public static double jouleToCalorie(double joule){
|
---|
2716 | return joule*0.23884;
|
---|
2717 | }
|
---|
2718 |
|
---|
2719 | // Converts grams to ounces
|
---|
2720 | public static double gramToOunce(double gm){
|
---|
2721 | return gm/28.3459;
|
---|
2722 | }
|
---|
2723 |
|
---|
2724 | // Converts ounces to grams
|
---|
2725 | public static double ounceToGram(double oz){
|
---|
2726 | return oz*28.3459;
|
---|
2727 | }
|
---|
2728 |
|
---|
2729 | // Converts kilograms to pounds
|
---|
2730 | public static double kgToPound(double kg){
|
---|
2731 | return kg/0.4536;
|
---|
2732 | }
|
---|
2733 |
|
---|
2734 | // Converts pounds to kilograms
|
---|
2735 | public static double poundToKg(double pds){
|
---|
2736 | return pds*0.4536;
|
---|
2737 | }
|
---|
2738 |
|
---|
2739 | // Converts kilograms to tons
|
---|
2740 | public static double kgToTon(double kg){
|
---|
2741 | return kg/1016.05;
|
---|
2742 | }
|
---|
2743 |
|
---|
2744 | // Converts tons to kilograms
|
---|
2745 | public static double tonToKg(double tons){
|
---|
2746 | return tons*1016.05;
|
---|
2747 | }
|
---|
2748 |
|
---|
2749 | // Converts millimetres to inches
|
---|
2750 | public static double millimetreToInch(double mm){
|
---|
2751 | return mm/25.4;
|
---|
2752 | }
|
---|
2753 |
|
---|
2754 | // Converts inches to millimetres
|
---|
2755 | public static double inchToMillimetre(double in){
|
---|
2756 | return in*25.4;
|
---|
2757 | }
|
---|
2758 |
|
---|
2759 | // Converts feet to metres
|
---|
2760 | public static double footToMetre(double ft){
|
---|
2761 | return ft*0.3048;
|
---|
2762 | }
|
---|
2763 |
|
---|
2764 | // Converts metres to feet
|
---|
2765 | public static double metreToFoot(double metre){
|
---|
2766 | return metre/0.3048;
|
---|
2767 | }
|
---|
2768 |
|
---|
2769 | // Converts yards to metres
|
---|
2770 | public static double yardToMetre(double yd){
|
---|
2771 | return yd*0.9144;
|
---|
2772 | }
|
---|
2773 |
|
---|
2774 | // Converts metres to yards
|
---|
2775 | public static double metreToYard(double metre){
|
---|
2776 | return metre/0.9144;
|
---|
2777 | }
|
---|
2778 |
|
---|
2779 | // Converts miles to kilometres
|
---|
2780 | public static double mileToKm(double mile){
|
---|
2781 | return mile*1.6093;
|
---|
2782 | }
|
---|
2783 |
|
---|
2784 | // Converts kilometres to miles
|
---|
2785 | public static double kmToMile(double km){
|
---|
2786 | return km/1.6093;
|
---|
2787 | }
|
---|
2788 |
|
---|
2789 | // Converts UK gallons to litres
|
---|
2790 | public static double gallonToLitre(double gall){
|
---|
2791 | return gall*4.546;
|
---|
2792 | }
|
---|
2793 |
|
---|
2794 | // Converts litres to UK gallons
|
---|
2795 | public static double litreToGallon(double litre){
|
---|
2796 | return litre/4.546;
|
---|
2797 | }
|
---|
2798 |
|
---|
2799 | // Converts UK quarts to litres
|
---|
2800 | public static double quartToLitre(double quart){
|
---|
2801 | return quart*1.137;
|
---|
2802 | }
|
---|
2803 |
|
---|
2804 | // Converts litres to UK quarts
|
---|
2805 | public static double litreToQuart(double litre){
|
---|
2806 | return litre/1.137;
|
---|
2807 | }
|
---|
2808 |
|
---|
2809 | // Converts UK pints to litres
|
---|
2810 | public static double pintToLitre(double pint){
|
---|
2811 | return pint*0.568;
|
---|
2812 | }
|
---|
2813 |
|
---|
2814 | // Converts litres to UK pints
|
---|
2815 | public static double litreToPint(double litre){
|
---|
2816 | return litre/0.568;
|
---|
2817 | }
|
---|
2818 |
|
---|
2819 | // Converts UK gallons per mile to litres per kilometre
|
---|
2820 | public static double gallonPerMileToLitrePerKm(double gallPmile){
|
---|
2821 | return gallPmile*2.825;
|
---|
2822 | }
|
---|
2823 |
|
---|
2824 | // Converts litres per kilometre to UK gallons per mile
|
---|
2825 | public static double litrePerKmToGallonPerMile(double litrePkm){
|
---|
2826 | return litrePkm/2.825;
|
---|
2827 | }
|
---|
2828 |
|
---|
2829 | // Converts miles per UK gallons to kilometres per litre
|
---|
2830 | public static double milePerGallonToKmPerLitre(double milePgall){
|
---|
2831 | return milePgall*0.354;
|
---|
2832 | }
|
---|
2833 |
|
---|
2834 | // Converts kilometres per litre to miles per UK gallons
|
---|
2835 | public static double kmPerLitreToMilePerGallon(double kmPlitre){
|
---|
2836 | return kmPlitre/0.354;
|
---|
2837 | }
|
---|
2838 |
|
---|
2839 | // Converts UK fluid ounce to American fluid ounce
|
---|
2840 | public static double fluidOunceUKtoUS(double flOzUK){
|
---|
2841 | return flOzUK*0.961;
|
---|
2842 | }
|
---|
2843 |
|
---|
2844 | // Converts American fluid ounce to UK fluid ounce
|
---|
2845 | public static double fluidOunceUStoUK(double flOzUS){
|
---|
2846 | return flOzUS*1.041;
|
---|
2847 | }
|
---|
2848 |
|
---|
2849 | // Converts UK pint to American liquid pint
|
---|
2850 | public static double pintUKtoUS(double pintUK){
|
---|
2851 | return pintUK*1.201;
|
---|
2852 | }
|
---|
2853 |
|
---|
2854 | // Converts American liquid pint to UK pint
|
---|
2855 | public static double pintUStoUK(double pintUS){
|
---|
2856 | return pintUS*0.833;
|
---|
2857 | }
|
---|
2858 |
|
---|
2859 | // Converts UK quart to American liquid quart
|
---|
2860 | public static double quartUKtoUS(double quartUK){
|
---|
2861 | return quartUK*1.201;
|
---|
2862 | }
|
---|
2863 |
|
---|
2864 | // Converts American liquid quart to UK quart
|
---|
2865 | public static double quartUStoUK(double quartUS){
|
---|
2866 | return quartUS*0.833;
|
---|
2867 | }
|
---|
2868 |
|
---|
2869 | // Converts UK gallon to American gallon
|
---|
2870 | public static double gallonUKtoUS(double gallonUK){
|
---|
2871 | return gallonUK*1.201;
|
---|
2872 | }
|
---|
2873 |
|
---|
2874 | // Converts American gallon to UK gallon
|
---|
2875 | public static double gallonUStoUK(double gallonUS){
|
---|
2876 | return gallonUS*0.833;
|
---|
2877 | }
|
---|
2878 |
|
---|
2879 | // Converts UK pint to American cup
|
---|
2880 | public static double pintUKtoCupUS(double pintUK){
|
---|
2881 | return pintUK/0.417;
|
---|
2882 | }
|
---|
2883 |
|
---|
2884 | // Converts American cup to UK pint
|
---|
2885 | public static double cupUStoPintUK(double cupUS){
|
---|
2886 | return cupUS*0.417;
|
---|
2887 | }
|
---|
2888 |
|
---|
2889 | // Calculates body mass index (BMI) from height (m) and weight (kg)
|
---|
2890 | public static double calcBMImetric(double height, double weight){
|
---|
2891 | return weight/(height*height);
|
---|
2892 | }
|
---|
2893 |
|
---|
2894 | // Calculates body mass index (BMI) from height (ft) and weight (lbs)
|
---|
2895 | public static double calcBMIimperial(double height, double weight){
|
---|
2896 | height = Fmath.footToMetre(height);
|
---|
2897 | weight = Fmath.poundToKg(weight);
|
---|
2898 | return weight/(height*height);
|
---|
2899 | }
|
---|
2900 |
|
---|
2901 | // Calculates weight (kg) to give a specified BMI for a given height (m)
|
---|
2902 | public static double calcWeightFromBMImetric(double bmi, double height){
|
---|
2903 | return bmi*height*height;
|
---|
2904 | }
|
---|
2905 |
|
---|
2906 | // Calculates weight (lbs) to give a specified BMI for a given height (ft)
|
---|
2907 | public static double calcWeightFromBMIimperial(double bmi, double height){
|
---|
2908 | height = Fmath.footToMetre(height);
|
---|
2909 | double weight = bmi*height*height;
|
---|
2910 | weight = Fmath.kgToPound(weight);
|
---|
2911 | return weight;
|
---|
2912 | }
|
---|
2913 |
|
---|
2914 | // Returns milliseconds since 0 hours 0 minutes 0 seconds on 1 Jan 1970
|
---|
2915 | public static long dateToJavaMilliSecondsUK(int year, int month, int day, String dayOfTheWeek, int hour, int min, int sec, int millisec){
|
---|
2916 |
|
---|
2917 | TimeAndDate tad = new TimeAndDate();
|
---|
2918 | long ms = tad.dateToJavaMilliSecondsUK(year, month, day, dayOfTheWeek, hour, min, sec, millisec);
|
---|
2919 |
|
---|
2920 | return ms;
|
---|
2921 | }
|
---|
2922 |
|
---|
2923 | }
|
---|