Michael Thomas Flanagan's Java Scientific Library

Deprecated Methods in Fmath Class

     

Return to Fmath class

Main Page of Michael Thomas Flanagan's Java Scientific Library

Several of the conversion methods and one-dimensional array processing and printing methods in the Fmath class have been replaced by corresponding and improved methods in the Conv, ArrayMaths and PrintToScreen classes. These methods have been retained in the Fmath class to ensure compatibility with previous applications. The are no longer documented within the Fmath page. They are documented below.

SUMMARY OF DEPRECATED METHODS

1 D Arrays Recast array type
See ArrayMaths for improved methods
public static double[] floatTOdouble(double[] a)
public static double[] longTOdouble(long[] a)
public static float[] longTOfloat(long[] a)
public static double[] intTOdouble(int[] a)
public static float[] intTOfloat(int[] a)
public static long[] intTOlong(int[] a)
public static double[] shortTOdouble(short[] a)
public static float[] shortTOfloat(short[] a)
public static long[] shortTOlong(short[] a)
public static int[] shortTOint(short[] a)
public static double[] byteTOdouble(byte[] a)
public static float[] byteTOfloat(byte[] a)
public static long[] byteTOlong(byte[] a)
public static int[] byteTOint(byte[] a)
public static short[] byteTOshort(byte[] a)
public static int[] doubleTOint(double[] a)
Reverse an Array Order
See ArrayMaths for improved methods
public static double[] reverseArray(double[] a)
public static float[] reverseArray(float[] a)
public static int[] reverseArray(int[] a)
public static long[] reverseArray(long[] a)
public static char[] reverseArray(char[] a)
Absolute values of array elements
See ArrayMaths for improved methods
public static double[] arrayAbs(double[] a)
public static float[] arrayAbs(float[] a)
public static int[] arrayAbs(int[] a)
public static long[] arrayAbs(long[] a)
Sum of all array elements
See ArrayMaths for improved methods
public static double arraySum(double[] a)
public static float arraySum(float[] a)
public static int arraySum(int[] a)
public static long arraySum(long[] a)
Product of all array elements
See ArrayMaths for improved methods
public static double arrayProduct(double[] a)
public static float arrayProduct(float[] a)
public static int arrayProduct(int[] a)
public static long arrayProduct(long[] a)
Concatenate two arrays
See ArrayMaths for improved methods
public static double concatente(double[] aa, double[] bb)
public static float concatenate(float[] aa, float[] bb)
public static long concatenate(long[] aa, long[] bb)
public static int concatenate(int[] aa, int[] bb)
Take the log to base 10 of each element
See ArrayMaths for improved methods
public static double[] log10Elements(double[] a)
public static float[] log10Elements(float[] a)
Take the log to base e of each element
See ArrayMaths for improved methods
public static double[] lnElements(double[] a)
public static float[] lnElements(float[] a)
Raise each element to a power
See ArrayMaths for improved methods
public static double[] raiseElementsToPower(double[] a, double n)
public static double[] raiseElementsToPower(double[] a, int n)
public static float[] raiseElementsToPower(float[] a, float n)
public static float[] raiseElementsToPower(float[] a, int n)
Invert all array elements
See ArrayMaths for improved methods
public static double[] invertElements(double[] aa)
public static float[] invertElements(float[] aa)
Array Minimum
See ArrayMaths for improved methods
public static double minimum(double[] a)
public static float minimum(float[] a)
public static int minimum(int[] a)
public static long minimum(long[] a)
Array Maximum
See ArrayMaths for improved methods
public static double maximum(double[] a)
public static float maximum(float[] a)
public static int maximum(int[] a)
public static long maximum(long[] a)
Sorting an array
See ArrayMaths for improved methods
public static double[ ] selectionSort(double[] a)
public static float[] selectionSort(float[] a)
public static int[] selectionSort(int[] a)
public static long[] selectionSort(long[] a)
Sorting an array plus return
of the sorted indices
public static void selectionSort(double[] a, double[] b, int[] indices)
public static Vector[] selectSortVector(double[] a)
public static ArrayList[] selectSortArrayList(double[] a)
Sorting an array and ordering an
accompanying array in the same order

See ArrayMaths for improved methods
public static void selectionSort(double[] aa, double[] bb, double[] cc, double[]dd)
public static void selectionSort(float[] aa, float[] bb, float[] cc, float[]dd)
public static void selectionSort(long[] aa, long[] bb, long[] cc, long[]dd)
public static void selectionSort(int[] aa, int[] bb, int[] cc, int[]dd)
public static void selectionSort(double[] aa, long[] bb, double[] cc, long[]dd)
public static void selectionSort(long[] aa, double[] bb, long[] cc, double[]dd)
public static void selectionSort(double[] aa, int[] bb, double[] cc, int[]dd)
public static void selectionSort(int[] aa, double[] bb, int[] cc, double[]dd)
public static void selectionSort(long[] aa, int[] bb, long[] cc, int[]dd)
public static void selectionSort(int[] aa, long[] bb, int[] cc, long[]dd)
Find first index of an element equal to a given value
See ArrayMaths for improved methods
public static int indexOf(double[] array, double value)
public static int indexOf(float[] array, float value)
public static int indexOf(long[] array, long value)
public static int indexOf(int[] array, int value)
public static int indexOf(short[] array, short value)
public static int indexOf(byte[] array, byte value)
public static int indexOf(String[] array, String value)
public static int indexOf(char[] array, char value)
Find all indices of elements equal to a given value
See ArrayMaths for improved methods
public static int[] indicesOf(double[] array, double value)
public static int[] indicesOf(float[] array, float value)
public static int[] indicesOf(long[] array, long value)
public static int[] indicesOf(int[] array, int value)
public static int[] indicesOf(short[] array, short value)
public static int[] indicesOf(byte[] array, byte value)
public static int[] indicesOf(char[] array, char value)
public static int[] indicesOf(String[] array, String value)
public static int[] indicesOf(Object[] array, Object value)
Nearest array element to a given value
See ArrayMaths for improved methods
public static double nearestElementValue(double[] array, double value)
public static int nearestElementIndex(double[] array, double value)
public static double nearestLowerElementValue(double[] array, double value)
public static int nearestLowerElementIndex(double[] array, double value)
public static double nearestHigherElementValue(double[] array, double value)
public static int nearestHigherElementIndex(double[] array, double value)
Minimum difference between elements
See ArrayMaths for improved methods
public static double minimumDifference(double[] a)
public static float minimumDifference(double[] a)
public static long minimumDifference(long[] a)
public static int minimumDifference(int[] a)
Maximum difference between elements
See
ArrayMaths for improved methods
public static double maximumDifference(double[] a)
public static float maximumDifference(double[] a)
public static long maximumDifference(long[] a)
public static int maximumDifference(int[] a)
Write an array to screen
See PrintToScreen for improved methods
public static void println(double[] a)
public static void print(double[] a)
public static void println(float[] a)
public static void print(float[] a)
public static void println(int[] a)
public static void print(int[] a)
public static void println(long[] a)
public static void print(long[] a)
public static void println(char[] a)
public static void print(char[] a)
public static void println(String[] a)
public static void print(String[] a)
Multiply array elements by a constant
See ArrayMaths for improved methods
public static double[] arrayMultByConstant(double[] a, double constant)
public static double[] arrayMultByConstant(double[] a, int constant)
public static double[] arrayMultByConstant(int[] a, double constant)
public static double[] arrayMultByConstant(int[] a, int constant)
Conversion of physical units
See Conv for improved conversion methods
Degrees to radians public static double degToRad(double deg)
Radians to degrees public static double radToDeg(double rad)
Frequency (Hz)
to radial frequency
public static double frequencyToRadialFrequency(double frequency)
Radial frequency
to frequency (Hz)
public static double radialFrequencyToFrequency(double radial)
Electron volts
to wavelength in nanometres
public static double evToNm(double ev)
Wavelength in nanometres to
Electron volts
public static double nmToEv(double nm)
Molar to %w/v public static double molarToPercentWeightByVol(double molar, double molWeight)
%w/v to molar public static double percentWeightByVolToMolar(double percent, double molWeight)
Date and time to milliseconds
since 0 hours 0 minutes 0 seconds
on 1 Jan 1970 (computer time)
public static long dateToJavaMilliS(int year, int month, int day, int hour, int min, int sec)
Height and weight to
body mass index (BMI) [metric]
public static double calcBMImetric(double height, double weight)
Height and weight to
body mass index (BMI) [imperial]
public static double calcBMIimperial(double height, double weight)
BMI and height to
weight [metric]
public static double calcWeightFromBMImetric(double bmi, double height)
BMI and height to
weight [imperial]
public static double calcWeightFromBMIimperial(double bmi, double height)
Celsius to Kelvin public static double celsiusToKelvin(double cels)
Kelvin to Celsius public static double kelvinToCelsius(double kelv)
Celsius to Fahrenheit public static double celsiusToFahren(double cels)
Fahrenheit to Celsius public static double fahrenToCelsius(double fahr)
Calories to Joules public static double calorieToJoule(double cal)
Joules to Calories public static double jouleToCalorie(double joule)
Ounces to grams public static double ounceToGram(double oz)
Grams to ounces public static double gramToOunce(double gm)
Pounds to kilograms public static double poundToKg(double pd)
Kilograms to pounds public static double kgToPound(double kg)
UK tons to kilograms public static double tonToKg(double ton)
Kilograms to UK tons public static double kgToTon(double kg)
Inches to millimetres public static double inchToMillimetre(double in)
Millimetres to inches public static double millimetreToInch(double mm)
Feet to metres public static double footToMetre(double ft)
Metres to feet public static double metreToFoot(double metre)
Yards to metres public static double yardToMetre(double yd)
Metres to yards public static double metreToYard(double metre)
Miles to kilometres public static double mileToKm(double mile)
Kilometres to miles public static double kmToMile(double km)
UK gallons to litres public static double gallonToLitre(double gall)
Litres to UK gallons public static double litreToGallon(double litre)
UK quarts to litres public static double quartToLitre(double quart)
Litres to UK quarts public static double litreToQuart(double litre)
UK pints to litres public static double pintToLitre(double pint)
Litres to UK pints public static double litreToPint(double litre)
UK gallons per mile to
litres per kilometre
public static double gallonPerMileToLitrePerKm(double gallPmile)
Litres per kilometre to
UK gallons per mile
public static double litrePerKmToGallonPerMile(double litrePkm)
Miles per UK gallon to
kilometres per litre
public static double milePergallonToKmPerLitre(double milePgall)
Kilometres per litre to
miles per UK gallon
public static double kmPerLitreToMilePerGallon(double kmPlitre)
UK fluid ounce to American fluid ounce public static double fluidOunceUKtoUS(double flozUK)
American fluid ounce to UK fluid ounce public static double fluidOunceUStoUK(double flozUK)
UK pint to American liquid pint public static double pintUKtoUS(double pintUK)
American liquid pint to UK pint public static double pintUStoUK(double pintUK)
UK quart to American liquid quart public static double quartUKtoUS(double quartUK)
American liquid quart to UK quart public static double quartUStoUK(double quartUK)
UK gallon to American gallon public static double gallonUKtoUS(double gallonUK)
American gallon to UK gallon public static double gallonUStoUK(double gallonUS)
UK pint to American cup public static double pintUKtoCupUS(double pintUK)
American cup to UK pint public static double cupUStoPintUK(double cupUS)
Deep copying of Objects
See Conv for improved conversion methods
Deep copy an Object public static Object copy(Object obj)
public static Object copyObject(Object obj)
Deep copy a 1-D array public static double[] copy(double[] array)
public static float[] copy(float[] array)
public static int[] copy(int[] array)
public static long[] copy(long[] array)
Deep copy a 2-D array public static double[][] copy(double[][] array)
public static float[][] copy(float[][] array)
public static int[][] copy(int[][] array)
public static long[][] copy(long[][] array)
Deep copy a 3-D array public static double[][][] copy(double[][][] array)
public static float[][][] copy(float[][][] array)
public static int[][][] copy(int[][][] array)
public static long[][][] copy(long[][][] array)
Deep copy a 4-D array public static double[][][][] copy(double[][][][] array)
public static float[][][][] copy(float[][][][] array)
public static int[][][][] copy(int[][][][] array)
public static long[][][][] copy(long[][][][] array)




1-D ARRAYS

See ArrayMaths for improved 1D array conversion methods

RECAST ARRAY TYPE
public static double[] floatTOdouble(double[] a)
public static double[] longTOdouble(long[] a)
public static float[] longTOfloat(long[] a)
public static double[] intTOdouble(int[] a)
public static float[] intTOfloat(int[] a)
public static long[] intTOlong(int[] a)
public static double[] shortTOdouble(short[] a)
public static float[] shortTOfloat(short[] a)
public static long[] shortTOlong(short[] a)
public static int[] shortTOint(short[] a)
public static double[] byteTOdouble(byte[] a)
public static float[] byteTOfloat(byte[] a)
public static long[] byteTOlong(byte[] a)
public static int[] byteTOint(byte[] a)
public static short[] byteTOshort(byte[] a)
public static int[] doubleTOint(double[] a)
Usage:                      bb = Fmath.floatTOdouble(aa);
Returns, as a double[] array, the elements of the float[] array, aa, recast as double.
Usage:                      bb = Fmath.longTOdouble(aa);
Returns, as a double[] array, the elements of the long[] array, aa, recast as double.
BEWARE OF POSSIBLE LOSS OF PRECISION IN A long TO double RECAST
Usage:                      bb = Fmath.longTOfloat(aa);
Returns, as a float[] array, the elements of the long[] array, aa, recast as float.
BEWARE OF POSSIBLE LOSS OF PRECISION IN A long TO float RECAST
Usage:                      bb = Fmath.intTOdouble(aa);
Returns, as a double[] array, the elements of the int[] array, aa, recast as double.
Usage:                      bb = Fmath.intTOfloat(aa);
Returns, as a float[] array, the elements of the int[] array, aa, recast as float.
Usage:                      bb = Fmath.intTOlong(aa);
Returns, as a long[] array, the elements of the int[] array, aa, recast as long.
Usage:                      bb = Fmath.shortTOdouble(aa);
Returns, as a double[] array, the elements of the short[] array, aa, recast as double.
Usage:                      bb = Fmath.shortTOfloat(aa);
Returns, as a float[] array, the elements of the short[] array, aa, recast as float.
Usage:                      bb = Fmath.shortTOlong(aa);
Returns, as a long[] array, the elements of the short[] array, aa, recast as long.
Usage:                      bb = Fmath.shortTOint(aa);
Returns, as a int[] array, the elements of the short[] array, aa, recast as int.
Usage:                      bb = Fmath.byteTOdouble(aa);
Returns, as a double[] array, the elements of the byte[] array, aa, recast as double.
Usage:                      bb = Fmath.byteTOfloat(aa);
Returns, as a float[] array, the elements of the byte[] array, aa, recast as float.
Usage:                      bb = Fmath.byteTOlong(aa);
Returns, as a long[] array, the elements of the byte[] array, aa, recast as long.
Usage:                      bb = Fmath.byteTOint(aa);
Returns, as a int[] array, the elements of the byte[] array, aa, recast as int.
Usage:                      bb = Fmath.byteTOshort(aa);
Returns, as a short[] array, the elements of the byte[] array, aa, recast as short.
Usage:                      bb = Fmath.doubleTOint(aa);
Returns, as an int[] array, the elements of the double[] array, aa, recast as int.
BEWARE OF POSSIBLE LOSS OF PRECISION IN A double TO int RECAST

CONCATENATE TWO ARRAYS
public static double[] concatenate(double[] aa, double[] bb)
public static float[] concatenate(float[] aa, float[] bb)
public static long[] concatenate(long[] aa, long[] bb)
public static int[] concatenate(int[] aa, int[] bb)
Usage:                     cc = Fmath.concatenate(aa, bbconstant);
Returns the array, cc, which contains the elements of array aa followed by the elements of array bb. The arrays aa and bb must be of the same type and may be double, float, long or int. The array cc will be of the same type as aa and bb.

ARRAY MINIMUM
public static double minimum(double[] aa)
public static float minimum(float[] aa)
public static int minimum(int[] aa)
public static long minimum(long[] aa)
Usage:                      mi = Fmath.minimum(aa);
Returns the minimum value of the variables in the array of doubles, floats, ints or longs, aa.

ARRAY MAXIMUM
public static double maximum(double[] aa)
public static float maximum(float[] aa)
public static int maximum(int[] aa)
public static long maximum(long[] aa)
Usage:                      ma = Fmath.maximum(aa);
Returns the maximum value of the variables in the array of doubles, floats, ints or longs, aa. REVERSE AN ARRAY ORDER
public static double[] reverseArray(double[] aa)
public static float[] reverseArray(float[] aa)
public static int[] reverseArray(int[] aa)
public static long[] reverseArray(long[] aa)
public static char[] reverseArray(char[] aa)
Usage:                      bb = Fmath.reverseArray(aa);
Returns an array of doubles, floats, ints, longs or chars, in reverse order of elements of the argument array, i.e. in the above usage: bb[0] = aa[n-1], bb[1] = aa[n-2], bb[2] = aa[n-3], etc. where n is the length of the array.



OBTAIN THE SUM OF ALL THE ARRAY ELEMENTS
public static double arraySum(double[] aa)
public static float arraySum(float[] aa)
public static int arraySum(int[] aa)
public static long arraySum(long[] aa)
Usage:                      sum = Fmath.arraySum(aa);
Returns the sum of all of the elements of array aa:
.


OBTAIN THE PRODUCT OF ALL THE ARRAY ELEMENTS
public static double arrayProduct(double[] aa)
public static float arrayProduct(float[] aa)
public static int arrayProduct(int[] aa)
public static long arrayProduct(long[] aa)
Usage:                      product = Fmath.arrayProduct(aa);
Returns the product of all of the elements of array aa:
.
OBTAIN ABSOLUTE VALUES OF THE ARRAY ELEMENTS
public static double[] arrayAbs(double[] aa)
public static float[] arrayAbs(float[] aa)
public static int[] arrayAbs(int[] aa)
public static long[] arrayAbs(long[] aa)
Usage:                      bb = Fmath.arrayAbs(aa);
Returns, in the array bb, the absolute values of the elements of array aa.

TAKING THE LOG TO BASE 10 OF EACH ARRAY ELEMENT
public static double[] log10Elements(double[] aa)
public static float[] log10Elements(float[] aa)
Usage:                      bb = Fmath.log10Elements(aa);
Returns, in the array bb, the log to base 10 of the elements of array aa.

TAKING THE LOG TO BASE e OF EACH ARRAY ELEMENT
public static double[] lnElements(double[] aa)
public static float[] lnElements(float[] aa)
Usage:                      bb = Fmath.lnElements(aa);
Returns, in the array bb, the log to base e of the elements of array aa.

TAKING THE SQUARE ROOT OF EACH ARRAY ELEMENT
public static double[] squareRootElements(double[] aa)
public static float[] squareRootElements(float[] aa)
Usage:                      bb = Fmath.squareRootElements(aa);
Returns, in the array bb, the square roots of the elements of array aa.

RAISE OF EACH ARRAY ELEMENT TO A POWER
public static double[] raiseElementsToPower(double[] aa, double[] n)
public static double[] raiseElementsToPower(double[] aa, int[] n)
public static float[] raiseElementsToPower(float[] aa, float[] n)
public static float[] raiseElementsToPower(float[] aa, int[] n)
Usage:                      bb = Fmath.raiseElementsToPower(aa, n);
Returns, in the array bb, the elements of array aa raised to the power n.



INVERT ALL ARRAY ELEMENTS
public static double[] invertElement(double[] aa)
public static float[] invertElements(float[] aa)
Usage:                     bb = Fmath.invertElements(aa);
Returns the array, bb, which contains the elements of array aa inverted, i.e. 1.0/aa[0], 1.0/aa[1], 1.0/aa[2] ... etc. The array aa must be double[] or float[]. The returned array bb is of the same type as aa.


SORTING

See the Java sort method for simple sorting (http://java.sun.com/j2se/1.4.2/docs/api/java/util/Arrays.html)

SORT A SINGLE ARRAY
These methods uses the straight selection sort procedure. It is inefficient for large arrays - see Russell Winder and Graham Roberts, Developing Java Software, John Wiley and Sons, 2000, Chapter 20, for a discussion of more sophsticated sorting procedures.
public static double[] selectionSort(double[] aa)
public static float[] selectionSort(float[] aa)
public static int[] selectionSort(int[] aa)
public static long[] selectionSort(long[] aa)
public static Vector[] selectSortVector(double[] a)
Usage:                      bb = Fmath.selectionSort(aa);
Returns an array, bb in the above usage, containing the elements of the array passed to the method as the argument, aa in the above usage, arranged in increasing order of size. The original array, aa above, remains unsorted. The array may be doubles, floats, ints or longs.

SORT A SINGLE ARRAY AND, ADDITIONALLY, RETURN THE SORTED INDICES
These methods uses the straight selection sort procedure. It is inefficient for large arrays - see Russell Winder and Graham Roberts, Developing Java Software, John Wiley and Sons, 2000, Chapter 20, for a discussion of more sophsticated sorting procedures.
public static void selectionSort(double[] a, double[] b, int[] indices)
public static Vector[] selectSort(double[] a)


Usage:                      Fmath.selectionSort(aa, bb, indices);
Sorts the array of doubles, the first argument, aa, returns the sorted array, in increasing order of size, as the second argument array, bb, and returns the indices of the sorted element as the third argument array, indices. The array, aa, remains unsorted.



Usage:                      vec = Fmath.selectSortVector(aa);
Returns a Vector, vec in the above usage. The first element [element 0] of vec contains the original double array, aa in the above usage, unsorted. The second element [element 1] of vec contains the sorted array, as doubles, arranged in increasing order of size and the third element of vec [element 2] contains an array of the indices of the original elements of the array aa arranged in the order of the sorted elements. The array, aa, must be double[] and the original array, aa above, remains unsorted.

SORT A SINGLE ARRAY AND, ADDITIONALLY, ORDER AN ACCOMPANYING ARRAY IN THE SAME ORDER
These methods uses the straight selection sort procedure. It is inefficient for large arrays - see Russell Winder and Graham Roberts, Developing Java Software, John Wiley and Sons, 2000, Chapter 20, for a discussion of more sophsticated sorting procedures.
public static void selectionSort(double[] aa, double[] bb, double[] cc, double[]dd)
public static void selectionSort(float[] aa, float[] bb, float[] cc, float[]dd)
public static void selectionSort(long[] aa, long[] bb, long[] cc, long[]dd)
public static void selectionSort(int[] aa, int[] bb, int[] cc, int[]dd)
public static void selectionSort(double[] aa, long[] bb, double[] cc, long[]dd)
public static void selectionSort(long[] aa, double[] bb, long[] cc, double[]dd)
public static void selectionSort(double[] aa, int[] bb, double[] cc, int[]dd)
public static void selectionSort(int[] aa, double[] bb, int[] cc, double[]dd)
public static void selectionSort(long[] aa, int[] bb, long[] cc, int[]dd)
public static void selectionSort(int[] aa, long[] bb, int[] cc, long[]dd)
Usage:                      Fmath.selectionSort(aa, bb, cc, dd);
Accepts two arrays, aa and bb in the above usage, sorts the array aa and returns the sorted array as cc with the elements in order of increasing size. The array aa is returned unchanged. The array bb is also rearranged so that its elements are ordered in the same order as the indices of the sorted array bb. The rearranged array is returned as dd. The array bb is returned unchanged. The array cc must be of the same type as the array aa and the array dd must be of the same type as the array bb. The aa - bb combinations allowed are double - double, float - float, long - long, int - int, double - long, long - double, double - int, int - double, long - int and int - long.

FIND THE INDEX OF THE FIRST ARRAY ELEMENT EQUAL TO A GIVEN VALUE
See also the Java language method binarySearch for a binary search procedure on ordered arrays (ascending order) [http://java.sun.com/j2se/1.4.2/docs/api/java/util/Arrays.html]

public static int indexOf(double[] array, double value)
public static int indexOf(float[] array, float value)
public static int indexOf(long[] array, long value)
public static int indexOf(int[] array, int value)
public static int indexOf(short[] array, short value)
public static int indexOf(byte[] array, byte value)
public static int indexOf(char[] array, char value)
public static int indexOf(String[] array, String value)
public static int indexOf(Object[] array, Object value)
Usage:                     index = Fmath.indexOf(aa, value);
Returns the index of the first element in the array aa that is equal to the value value. -1 is returned if no element equal to value is found. The elements of array aa and the value, value, must be of the same type which may be double, float, long, int, short, byte, char, String or Object.

FIND THE INDICES OF ALL ARRAY ELEMENTS EQUAL TO A GIVEN VALUE
public static int[] indicesOf(double[] array, double value)
public static int[] indicesOf(float[] array, float value)
public static int[] indicesOf(long[] array, long value)
public static int[] indicesOf(int[] array, int value)
public static int[] indicesOf(short[] array, short value)
public static int[] indicesOf(byte[] array, byte value)
public static int[] indicesOf(char[] array, char value)
public static int[] indicesOf(String[] array, String value)
public static int[] indicesOf(Object[] array, Object value)
Usage:                     indices[] = Fmath.indicesOf(aa, value);
Returns the indices of all element in the array aa that are equal to the value value. null is returned if no element equal to value is found. The elements of array aa and the value, value, must be of the same type which may be double, float, long, int, short, byte, char, String or Object.

FIND THE NEAREST ARRAY ELEMENT TO A GIVEN VALUE
public static double nearestElementValue(double[] array, double value)
public static int nearestElementIndex(double[] array, double value)
public static double nearestLowerElementValue(double[] array, double value)
public static int nearestLowerElementIndex(double[] array, double value)
public static double nearestHigherElementValue(double[] array, double value)
public static int nearestHigherElementIndex(double[] array, double value)
Usage:                      nearestV = Fmath.nearestElementValue(aa, val);
Returns the value of the element in the array, aa, nearest in value to the value of the variable, val.

Usage:                      nearestI= Fmath.nearestElementIndex(aa, val);
Returns the index of the element in the array, aa, nearest in value to the value of the variable, val.

Usage:                      nearestV = Fmath.nearestLowerElementValue(aa, val);
Returns the value of the element in the array, aa, of the nearest lower value to the value of the variable, val.

Usage:                      nearestI = Fmath.nearestLowerElementIndex(aa, val);
Returns the index of the element in the array, aa, of the nearest lower value to the value of the variable, val.

Usage:                      nearestV = Fmath.nearestHigherElementValue(aa, val);
Returns the value of the element in the array, aa, of the nearest higher value to the value of the variable, val.

Usage:                      nearestI = Fmath.nearestHigherElementIndex(aa, val);
Returns the index of the element in the array, aa, of the nearest higher value to the value of the variable, val.

FIND THE MINIMUM DIFFERENCE BETWEEN THE ARRAY ELEMENTS
public static double minimumDiffrence(double[] aa)
public static float minimumDiffrence(float[] aa)
public static long minimumDiffrence(long[] aa)
public static int minimumDiffrence(int[] aa)
Usage:                      minDiff = Fmath.minimumDiffrence(aa);
Returns the value of the minimum distance between the elements in the array aa. The array aa may be double[], float[], long[] or int[].

FIND THE MAXIMUM DIFFERENCE BETWEEN THE ARRAY ELEMENTS
public static double maximumDiffrence(double[] aa)
public static float maximumDiffrence(float[] aa)
public static long maximumDiffrence(long[] aa)
public static int maximumDiffrence(int[] aa)
Usage:                      maxDiff = Fmath.maximumDiffrence(aa);
Returns the value of the minimum distance between the elements in the array aa. The array aa may be double[], float[], long[] or int[].



WRITE AN ARRAY TO SCREEN
See PrintToScreen for a more extensive write to screen methods

public static void println(double[]aa)
public static void print(double[] aa)
public static void println(float[] aa)
public static void print(float[] aa)
public static void println(int[] aa)
public static void print(int[] aa)
public static void println(long[] aa)
public static void print(long[] aa)
public static void println(char[] aa)
public static void print(char[] aa)
public static void println(String[] aa)
public static void print(String[] aa)
Usage:                      Fmath.println(aa);
Prints the array, aa, to the screen. Each element of the array is followed by a line return. The array may be an array of doubles, floats, ints, longs, chars or Strings.
Usage:                      Fmath.print(aa);
Prints the array, aa, to the screen. Each element of the array is followed by a space. The last element to be written is followed by a line return. The array may be an array of doubles, floats, ints, longs, chars or Strings.

MULTIPLY THE ARRAY ELEMENTS BY A CONSTANT

See ArrayMaths for improved methods

public static double[] arrayMultByConstant(double[] aa, double constant)
public static double[] arrayMultByConstant(double[] aa, int constant)
public static double[] arrayMultByConstant(int[] aa, double constant)
public static double[] arrayMultByConstant(int[] aa, int constant)
Usage:                      bb = Fmath.arrayMultByConstant(aa, constant);
Returns the array bb, in which all the elements of array aa have been multiplied by the constant constant. The array aa and the constant constant may be either double or int but the array returned, bb, is always of type double.


PHYSICAL UNIT CONVERSION FUNCTIONS

See Conv for improved conversion methods

Radians to degrees
public static double radToDeg(double rad)
Usage:                      deg = Fmath.radToDeg(rad);
Converts the argument, rad in radians, to degrees and returns that value in degrees. Performs the same function as the java.lang.Math Math.toDegrees(rad)

Degrees to radians
public static double degToRad(double deg)
Usage:                      rad = Fmath.degToRad(deg);
Converts the argument, deg in degrees, to radians and returns that value in radians. Performs the same function as the java.lang.Math Math.toRadians(deg)

Frequency (Hz) to radial frequency
public static double frequencyToRadialFrequency(double freq)
Usage:                      radial = Fmath.frequencyToRadialFrequency(freq);
Converts the argument, freq, a frequency in Hz, to the corresponding radial frequency and returns that value in radians per second.

Radial frequency to frequency
public static double radialfrequencyToFrequency(double rad)
Usage:                      freq = Fmath.radialFrequencyToFrequency(rad);
Converts the argument, rad, a radial frequency in radians per second, to the corresponding frequency and returns that value in Hz.

Electron volts to wavelength
public static double evToNm(double v)
Usage:                      lambda = Fmath.evToNm(volt);
Returns the wavelength, in nanometres, of a photon corresponding, in energy, to the equivalent electron volt energy.

Wavelength to electron volts
public static double nmToEv(double v)
Usage:                      volt = Fmath.nmToEv(lambda);
Returns the value, in electron volts, of the energy of a photon with a wavelength, in nanometres, of lambda.

Molar to %w/v
public static double molarToPercentWeightByVol(double molar, double molWeight)
Usage:                      percent = Fmath.molarToPercentWeightByVol(molar, molWeight);
Returns the percentage weight by volume concentration, i.e. grams of solute per 100 ml of solution, for a given molar concentration (argument molar in the above usage) of a solute of molecular weight, molWeight, in the above usage.

%w/v to molar
public static double percentWeightByVolToMolar(double percent, double molWeight)
Usage:                      molar = Fmath.percentWeightByVolToMolar(percent, molWeight);
Returns the molar concentration, i.e. moles per litre, for a given percentage weight by volume concentration, i.e. grams of solute per 100 ml of solution, (argument percent in the above usage) of a solute of molecular weight, molWeight, in the above usage.

Date and time to milliseconds since 0 hours 0 minutes 0 seconds on 1 Jan 1970 (computer time)
public static long dateToJavaMilliS(int year, int month, int day, int hour, int min, int sec)
Usage:                      compTime = Fmath.dateToJavaMilliS(2004, 3, 12, 15, 32, 7);
Converts the date (15.32.7, i.e. 3.32 pm and 7 seconds, on 12th March 2004 in the above example) to the Java time scale, i.e. millisecond since 0 hours 0 minutes 0 seconds on 1 Jan 1970.

Height and weight to Body Mass Index (BMI) [metric]
public static double calcBMImetric(double height, double weight)
Usage:                      bmi = Fmath.calcBMImetric(height, weight);
Returns the Body Mass Index (BMI) for a height in metres and a weight in kilograms.

Height and weight to Body Mass Index (BMI) [imperial]
public static double calcBMIimperial(double height, double weight)
Usage:                      bmi = Fmath.calcBMIimperial(height, weight);
Returns the Body Mass Index (BMI) for a height in feet and a weight in pounds.

Body Mass Index (BMI) and height to weight [metric]
public static double calcWeightFromBMImetric(double bmi, double height)
Usage:                      bmi = Fmath.calcWeightFromBMImetric(bmi, height);
Returns the weight in kilograms for a height in metres and Body Mass Index (BMI).

Body Mass Index (BMI) and height to weight [imperial]
public static double calcWeightFromBMIimperial(double bmi, double height)
Usage:                      bmi = Fmath.calcWeightFromBMImetric(bmi, height);
Returns the weight in pounds for a height in ft and Body Mass Index (BMI).

Degrees Celsius to degrees Kelvin
public static double celciusToKelvin(double cels)
Usage:                      deg = Fmath.celsiusToKelvin(cels);

Degrees Kelvin to degrees Celsius
public static double kelvinToCelsius(double kelv)
Usage:                      deg = Fmath.kelvinToCelsius(kelv);

Degrees Celsius to degrees Fahrenheit
public static double celciusToFahren(double cels)
Usage:                      deg = Fmath.celsiusToFahren(cels);

Degrees Fahrenheit to degrees Celsius
public static double fahrenToCelsius(double kelv)
Usage:                      deg = Fmath.fahrenToCelsius(fahr);

Calories to joules
public static double calorieToJoule(double cal)
Usage:                      en = Fmath.calorieToJoule(cal);

Joules to calories
public static double jouleToCalorie(double joule)
Usage:                      en = Fmath.jouleToCalorie(joule);

Grams to ounces
public static double gramToOunce(double gm)
Usage:                      oz = Fmath.gramToOunce(gm);

Ounces to grams
public static double ounceToGram(double oz)
Usage:                      gm = Fmath.ounceToGram(oz);

Kilograms to pounds
public static double kgToPound(double kg)
Usage:                      pd = Fmath.kgToPound(kg);

Pounds to kilograms
public static double poundToKg(double pd)
Usage:                      kg = Fmath.poundToKg(oz);

Kilograms to tons (UK)
public static double kgToTon(double kg)
Usage:                      tons = Fmath.kgToTon(kg);

Tons (UK) to kilograms
public static double tonToKg(double ton)
Usage:                      kg = Fmath.tonToKg(ton);

Millimetres to inches
public static double millimetreToInch(double mm)
Usage:                      in = Fmath.millimetreToInch(mm);

Inches to millimetres
public static double inchToMillimetre(double in)
Usage:                      mm = Fmath.inchToMillimetre(in);

Metres to feet
public static double metreToFoot(double metre)
Usage:                      ft = Fmath.metreToFoot(metre);

Feet to metres
public static double footToMetre(double ft)
Usage:                      metre = Fmath.footToMetre(ft);

Metres to yards
public static double metreToYard(double metre)
Usage:                      yd = Fmath.metreToYard(metre);

Yards to metres
public static double yardToMetre(double yd)
Usage:                      metre = Fmath.yardToMetre(yd);

Kilometres to miles
public static double kmToMile(double km)
Usage:                      mile = Fmath.kmToMile(km);

Miles to kilometres
public static double mileToKm(double mile)
Usage:                      km = Fmath.mileToKm(mile);

UK gallons to litres
public static double gallonToLitre(double gall)
Usage:                      litre = Fmath.gallonToLitre(gall);

Litres to UK gallons
public static double litreToGallon(double litre)
Usage:                      gall = Fmath.litreToGallon(litre);

UK quarts to litres
public static double quartToLitre(double quart)
Usage:                      litre = Fmath.quartToLitre(quart);

Litres to UK quarts
public static double litreToQuart(double litre)
Usage:                      quart = Fmath.litreToQuart(litre);

UK pints to litres
public static double pintToLitre(double pint)
Usage:                      litre = Fmath.pintToLitre(pint);

Litres to UK pints
public static double litreToPint(double litre)
Usage:                      pint = Fmath.litreToPint(litre);

Fuel Consumption: UK Gallons per mile to litres per kilometre
public static double gallonPerMileToLitrePerKm(double gallPmile)
Usage:                      litrePkm = Fmath.gallonPerMileToLitrePerKm(gallPmile);

Fuel Consumption: Litres per kilometre to UK gallons per mile
public static double litrePerKmToGallonPerMile(double litrePkm)
Usage:                      gallPmile = Fmath.litrePerKmToGallonPerMile(litrePkm);

Fuel Consumption: miles per UK Gallon to kilometres per litre
public static double MilePerGallonToKmPerLitre(double milePgall)
Usage:                      kmPlitreP = Fmath.milePerGallonToKmPerLitre(milePgall);

Fuel Consumption: Kilometres per litres to miles per UK gallon
public static double kmPerLitreToMilePerGallon(double kmPlitre)
Usage:                      milePgall = Fmath.kmPerLitreToMilePerGallon(kmPlitre);

UK fluid ounce to American fluid ounce
public static double fluidOunceUKtoUS(double flozUK)
Usage:                      flozUS = Fmath.fluidOunceUKtoUS(flozUK);

American fluid ounce to UK fluid ounce
public static double fluidOunceUStoUK(double flozUK)
Usage:                      flozUK = Fmath.fluidOunceUStoUK(flozUS);

UK pint to American liquid pint
public static double pintUKtoUS(double pintUK)
Usage:                      pintUS = Fmath.pintUKtoUS(pintUK);

American liquid pint to UK pint
public static double pintUStoUK(double pintUK)
Usage:                      pintUK = Fmath.pintUStoUK(pintUS);

UK quart to American liquid quart
public static double quartUKtoUS(double quartUK)
Usage:                      quartUS = Fmath.quartUKtoUS(quartUK);

American liquid quart to UK quart
public static double quartUStoUK(double quartUK)
Usage:                      quartUK = Fmath.quartUStoUK(quartUS);

UK gallon to American gallon
public static double gallonUKtoUS(double gallonUK)
Usage:                      gallonUS = Fmath.gallonUKtoUS(gallonUK);

American gallon to UK gallon
public static double gallonUStoUK(double gallonUS)
Usage:                      gallonUK = Fmath.gallonUStoUK(gallonUS);

UK pint to American cup
public static double pintUKtoCupUS(double pintUK)
Usage:                      cupUS = Fmath.pintUKtoCupUS(pintUK);

American cup to UK pint
public static double cupUStoPintUK(double cupUS)
Usage:                      pintUK = Fmath.cupUStoPintUK(cupUS);


DEEP COPYING OF OBJECTS

See also
ArrayMaths, Complex, ComplexErrorProp, ComplexMatrix, ComplexPoly, ErrorProp, Matrix, Phasor, PhasorMatrix, BlackBox and all BlackBox subclasses for object specific deep copy methods.

Deep copying an Object
public static Object copy(Object obj)
public static Object copyObject(Object obj)
Usage:                      obj2 = Fmath.copy(obj1);
A deep copy of the object, obj1, is returned as obj2 in the above usage.
An exception will be thrown if an attempt to copy a non-serialisable object is made. Included as required by other classes in this library. Adapted from Philip Isenhour's { Java Techniques } which should be consulted for a full discussion on copying objects.
The method copyObject(Object) is identical to copy(Object)

Deep copying of a one dimensional array
public static double[] copy(double[] array)
public static float[] copy(float[] array)
public static int[] copy(int[] array)
public static long[] copy(long[] array)
Usage:                      arrayCopy = Fmath.copy(array);
Returns a deep copy [arrayCopy] of a one dimensional array [array]. The array may be an array of doubles, floats, ints or longs.

Deep copying of a two dimensional array
public static double[][] copy(double[][] array)
public static float[][] copy(float[][] array)
public static int[][] copy(int[][] array)
public static long[][] copy(long[][] array)
Usage:                      arrayCopy = Fmath.copy(array);
Returns a deep copy [arrayCopy] of a two dimensional array [array]. The array may be an array of doubles, floats, ints or longs.

Deep copying of a three dimensional array
public static double[][][] copy(double[][][] array)
public static float[][][] copy(float[][][] array)
public static int[][][] copy(int[][][] array)
public static long[][][] copy(long[][][] array)
Usage:                      arrayCopy = Fmath.copy(array);
Returns a deep copy [arrayCopy] of a three dimensional array [array]. The array may be an array of doubles, floats, ints or longs.

Deep copying of a four dimensional array
public static double[][][][] copy(double[][][][] array)
public static float[][][][] copy(float[][][][] array)
public static int[][][][] copy(int[][][][] array)
public static long[][][][] copy(long[][][][] array)
Usage:                      arrayCopy = Fmath.copy(array);
Returns a deep copy [arrayCopy] of a four dimensional array [array]. The array may be an array of doubles, floats, ints or longs.


PERMISSION TO COPY

Permission to use, copy and modify this software and its documentation for NON-COMMERCIAL purposes is granted, without fee, provided that an acknowledgement to the author, Dr Michael Thomas Flanagan at www.ee.ucl.ac.uk/~mflanaga, appears in all copies and associated documentation or publications. Dr Michael Thomas Flanagan makes no representations about the suitability or fitness of the software for any or for a particular purpose. Dr Michael Thomas Flanagan shall not be liable for any damages suffered as a result of using, modifying or distributing this software or its derivatives.

Redistributions of the source code of this class, or parts of the source codes, must retain the copyright notice, this list of conditions and the following disclaimer (all at the top of the source code) and requires written permission from the Michael Thomas Flanagan:

Redistribution in binary form of all or parts of this class must reproduce the copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution and requires written permission from the Michael Thomas Flanagan:
.



This page was prepared by Dr Michael Thomas Flanagan