/*
*   Class   ArrayMaths
*
*   USAGE:  One dimensional arrays:  mathematical manipulations and inter-conversions
*
*   WRITTEN BY: Dr Michael Thomas Flanagan
*
*   DATE:       April 2008
*   AMENDED:    22-30 May 2008, 4 June 2008, 27-28 June 2007, 2-4 July 2008,
*               8 July 2008, 25 July 2008, 4 September 2008, 13 December 2008
*               29 September 2010, 29 November 2010, 
*               18 January 2011, 30 November 2011, 10 December 2011
*
*   DOCUMENTATION:
*   See Michael Thomas Flanagan's Java library on-line web pages:
*   http://www.ee.ucl.ac.uk/~mflanaga/java/
*   http://www.ee.ucl.ac.uk/~mflanaga/java/ArrayMaths.html
*
*   Copyright (c) 2008 - 2011
*
*   PERMISSION TO COPY:
*
*   Redistributions of this source code, or parts of, must retain the above
*   copyright notice, this list of conditions and the following disclaimer.
*
*   Redistribution in binary form of all or parts of this class, must reproduce
*   the above copyright, this list of conditions and the following disclaimer in
*   the documentation and/or other materials provided with the distribution.
*
*   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, 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.
*   Michael Thomas Flanagan shall not be liable for any damages suffered
*   as a result of using, modifying or distributing this software or its derivatives.
*
***************************************************************************************/

package flanagan.math;


import java.math.*;
import java.util.Vector;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import flanagan.complex.Complex;
import flanagan.complex.ComplexMatrix;
import flanagan.circuits.Phasor;
import flanagan.circuits.PhasorMatrix;
import flanagan.math.Conv;
import flanagan.analysis.Stat;
import flanagan.io.PrintToScreen;
import flanagan.plot.*;

public class ArrayMaths{

    protected ArrayList array = null;    // internal array

    protected int length = 0;       // array length
    protected int type = -1;        // 0 double, 1 Double, 2 float, 3 Float, 4 long, 5 Long, 6 int, 7 Integer, 8 short, 9 Short, 10 byte, 11 Byte
                                    // 12 BigDecimal, 13 BigInteger, 14 Complex, 15 Phasor, 16 char, 17 Character, 18 String
    protected int[] originalTypes = null;     // list of entered types in the array

    protected String[] typeName = {"double", "Double", "float", "Float", "long", "Long", "int", "Integer", "short", "Short", "byte", "Byte", "BigDecimal", "BigInteger", "Complex", "Phasor", "char", "Character", "String"};

    protected ArrayList summ = new ArrayList(1);        // sum of all elements
    protected ArrayList productt = new ArrayList(1);    // product of all elements

    protected int[] sortedIndices = null;                               // sorted indices

    protected ArrayList minmax = new ArrayList(2);      // element at 0 -  maximum value
                                                                        // element at 1 -  minimum value
    protected int maxIndex = -1;                        // index of the maximum value array element
    protected int minIndex = -1;                        // index of the minimum value array element

    protected boolean sumDone = false;                  // = true whem array sum has been found
    protected boolean productDone = false;              // = true whem array product has been found

    protected boolean sumlongToDouble = false;          // = true whem long has been converted to Double to avoid overflow in summation
    protected boolean productlongToDouble = false;      // = true whem long has been converted to Double to avoid overflow in multiplication

    protected boolean suppressMessages = false;         // = true when suppress 'possible loss of precision' messages has been set

    public String[] words = null;                       // words in alphabetic search method
    public String[] sortedWords = null;                 // sorted words in alphabetic search method
    protected char[][] wordChar = null;                 // word characters in alphabetic search method
    protected char[][] holdWordChar = null;             // holding array of word characters in alphabetic search method
    protected int[] wordOrder = null;                   // word order indices in alphabetic search method
    protected int[] holdWordOrder = null;               // holding array of word order indices in alphabetic search method
    protected int nWords = 0;                           // number of words in alphabetic search method
    protected int nLength = 0;                          // length of longest word in alphabetic search method

    // HashMap for 'arithmetic integer' recognition nmethod
    protected static final Map integers = new HashMap();
    static{
        integers.put(Integer.class, BigDecimal.valueOf(Integer.MAX_VALUE));
        integers.put(Long.class, BigDecimal.valueOf(Long.MAX_VALUE));
        integers.put(Byte.class, BigDecimal.valueOf(Byte.MAX_VALUE));
        integers.put(Short.class, BigDecimal.valueOf(Short.MAX_VALUE));
        integers.put(BigInteger.class, BigDecimal.valueOf(-1));
    }

    // CONSTRUCTORS
    protected ArrayMaths(){
        this.array = new ArrayList();
    }

    public ArrayMaths(double[] array){
        this.length = array.length;
        this.array = new ArrayList(this.length);
        this.type = 0;
        for(int i=0; i(this.length);
        this.type = 1;
        for(int i=0; i(this.length);
        this.type = 4;
        for(int i=0; i(this.length);
        this.type = 5;
        for(int i=0; i(this.length);
        this.type = 2;
        for(int i=0; i(this.length);
        this.type = 3;
        for(int i=0; i(this.length);
        this.type = 6;
        for(int i=0; i(this.length);
        this.type = 7;
        for(int i=0; i(this.length);
        this.type = 8;
        for(int i=0; i(this.length);
        this.type = 9;
        for(int i=0; i(this.length);
        this.type = 10;
        for(int i=0; i(this.length);
        this.type = 11;
        for(int i=0; i(this.length);
        this.type = 12;
        for(int i=0; i(this.length);
        this.type = 13;
        for(int i=0; i(this.length);
        this.type = 14;
        for(int i=0; i(this.length);
        this.type = 15;
        for(int i=0; i(this.length);
        this.type = 16;
        for(int i=0; i(this.length);
        this.type = 17;
        for(int i=0; i(this.length);
        this.type = 18;
        for(int i=0; i arrayl = new ArrayList(this.length);
        for(int i=0; i arrayv){
        this.length = arrayv.size();
        this.originalTypes = new int[this.length];
        this.array = new ArrayList(this.length);

        for(int i=0; i3 && this.originalTypes[i]<12)testType = 6;
        if(testType==-1)for(int i=0; i arrayl){
        this.length = arrayl.size();
        this.originalTypes = new int[this.length];
        this.array = new ArrayList(this.length);

        for(int i=0; i3 && this.originalTypes[i]<12)testType = 6;
        if(testType==-1)for(int i=0; i();
        if(this.minmax.size()!=0){
            switch(this.type){
            case 0:
            case 1: double dd = ((Double)this.minmax.get(0)).doubleValue();
                    am.minmax.add(new Double(dd));
                    dd = ((Double)this.minmax.get(1)).doubleValue();
                    am.minmax.add(new Double(dd));
                    break;
            case 4:
            case 5: long ll= ((Long)this.minmax.get(0)).longValue();
                    am.minmax.add(new Double(ll));
                    ll = ((Long)this.minmax.get(1)).longValue();
                    am.minmax.add(new Long(ll));
                    break;
            case 2:
            case 3: float ff = ((Float)this.minmax.get(0)).floatValue();
                    am.minmax.add(new Double(ff));
                    ff = ((Float)this.minmax.get(1)).floatValue();
                    am.minmax.add(new Double(ff));
                    break;
            case 6:
            case 7: int ii = ((Integer)this.minmax.get(0)).intValue();
                    am.minmax.add(new Integer(ii));
                    ii = ((Double)this.minmax.get(1)).intValue();
                    am.minmax.add(new Integer(ii));
                    break;
            case 8:
            case 9: short ss = ((Short)this.minmax.get(0)).shortValue();
                    am.minmax.add(new Short(ss));
                    ss = ((Double)this.minmax.get(1)).shortValue();
                    am.minmax.add(new Short((ss)));
                    break;
            case 10:
            case 11: byte bb = ((Byte)this.minmax.get(0)).byteValue();
                    am.minmax.add(new Byte(bb));
                    ss = ((Byte)this.minmax.get(1)).byteValue();
                    am.minmax.add(new Byte((bb)));
                    break;
            case 12: BigDecimal bd = (BigDecimal)this.minmax.get(0);
                    am.minmax.add(bd);
                    bd = (BigDecimal)this.minmax.get(1);
                    am.minmax.add(bd);
                    bd = null;
                    break;
            case 13: BigInteger bi = (BigInteger)this.minmax.get(0);
                    am.minmax.add(bi);
                    bi = (BigInteger)this.minmax.get(1);
                    am.minmax.add(bi);
                    bi = null;
                    break;
            case 16:
            case 17: int iii = ((Integer)this.minmax.get(0)).intValue();
                    am.minmax.add(new Integer(iii));
                    iii = ((Double)this.minmax.get(1)).intValue();
                    am.minmax.add(new Integer(iii));
                    break;
            }
        }

        am.summ = new ArrayList();
        if(this.summ.size()!=0){
            switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 18: double dd = ((Double)summ.get(0)).doubleValue();
                    am.summ.add(new Double(dd));
                    break;
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 16:
            case 17: if(this.sumlongToDouble){
                        double dd2 = ((Double)summ.get(0)).doubleValue();
                        am.summ.add(new Double(dd2));
                    }
                    else{
                        long ll = ((Long)summ.get(0)).longValue();
                        am.summ.add(new Long(ll));
                    }
                    break;
            case 12: BigDecimal bd = (BigDecimal)summ.get(0);
                    am.summ.add(bd);
                    break;
            case 13:  BigInteger bi = (BigInteger)summ.get(0);
                    am.summ.add(bi);
                    break;
            case 14:  Complex cc = (Complex)summ.get(0);
                    am.summ.add(cc);
                    break;
            case 15:  Phasor pp = (Phasor)summ.get(0);
                    am.summ.add(pp);
                    break;
            default: throw new IllegalArgumentException("Data type not identified by this method");
            }
        }

        am.productt = new ArrayList();
        if(this.productt.size()!=0){
            switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 18: double dd = ((Double)productt.get(0)).doubleValue();
                    am.productt.add(new Double(dd));
                    break;
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 16:
            case 17: if(this.sumlongToDouble){
                        double dd2 = ((Double)productt.get(0)).doubleValue();
                        am.productt.add(new Double(dd2));
                    }
                    else{
                        long ll = ((Long)productt.get(0)).longValue();
                        am.productt.add(new Long(ll));
                    }
                    break;
            case 12: BigDecimal bd = (BigDecimal)productt.get(0);
                    am.productt.add(bd);
                    break;
            case 13:  BigInteger bi = (BigInteger)productt.get(0);
                    am.productt.add(bi);
                    break;
            case 14:  Complex cc = (Complex)productt.get(0);
                    am.productt.add(cc);
                    break;
            case 15:  Phasor pp = (Phasor)productt.get(0);
                    am.productt.add(pp);
                    break;
            default: throw new IllegalArgumentException("Data type not identified by this method");
            }
        }


        switch(this.type){
            case 0:
            case 1: double[] dd = Conv.copy(this.getArray_as_double());
                    for(int i=0; i1){
                            test=false;
                            break;
                        }
                    }
                    if(test){
                        for(int i=0; i1){
                            test=false;
                            break;
                        }
                    }
                    if(test){
                        for(int i=0; i getArray_as_Vector(){
        Vector vec = new Vector(this.length);
        for(int i=0; i getArray_as_ArrayList(){
        ArrayList arrayl = new ArrayList(this.length);
        for(int i=0; i=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        double[] retArray = new double[end-start+1];
        switch(this.type){
            case 0:
            case 1: for(int i=start; i<=end; i++)retArray[i-start] = ((Double)this.array.get(i)).doubleValue();
                    break;
            case 2:
            case 3: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Float_to_double((Float)this.array.get(i));
                    break;
            case 4:
            case 5: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Long_to_double((Long)this.array.get(i));
                    break;
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Integer_to_double((Integer)this.array.get(i));
                    break;
            case 8:
            case 9: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Short_to_double((Short)this.array.get(i));
                    break;
            case 10:
            case 11: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Byte_to_double((Byte)this.array.get(i));
                    break;
            case 12: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigDecimal_to_double((BigDecimal)this.array.get(i));
                    break;
            case 13: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigInteger_to_double((BigInteger)this.array.get(i));
                    break;
            case 18: for(int i=start; i<=end; i++)retArray[i-start] = Double.valueOf(((String)this.array.get(i)));
                    break;
            case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_int_to_double((int)((Character)this.array.get(i)).charValue());
                    break;
            case 14:
            case 15: throw new IllegalArgumentException("The " + this.typeName[this.type] + " is not a numerical type for which a conversion to double is meaningful/supported");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }

    // return sub-array as Double
    public Double[] subarray_as_Double(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        Double[] retArray = new Double[end-start+1];
        switch(this.type){
            case 0:
            case 1: for(int i=start; i<=end; i++)retArray[i-start] = (Double)this.array.get(i);
                    break;
            case 2:
            case 3: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Float_to_Double((Float)this.array.get(i));
                    break;
            case 4:
            case 5: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Long_to_Double((Long)this.array.get(i));
                    break;
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Integer_to_Double((Integer)this.array.get(i));
                    break;
            case 8:
            case 9: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Short_to_Double((Short)this.array.get(i));
                    break;
            case 10:
            case 11: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Byte_to_Double((Byte)this.array.get(i));
                    break;
            case 12: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigDecimal_to_Double((BigDecimal)this.array.get(i));
                    break;
            case 13: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigInteger_to_Double((BigInteger)this.array.get(i));
                    break;
            case 18: for(int i=start; i<=end; i++)retArray[i-start] = new Double((String)this.array.get(i));
                    break;
            case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_int_to_Double((int)((Character)this.array.get(i)).charValue());
                    break;
            case 14:
            case 15: throw new IllegalArgumentException("The " + this.typeName[this.type] + " is not a numerical type for which a conversion to Double is meaningful/supported");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }

    // return sub-array as Float
    public Float[] subarray_as_Float(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        Float[] retArray = new Float[end-start+1];
        switch(this.type){
            case 0:
            case 1: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Double_to_Float((Double)this.array.get(i));
                    break;
            case 2:
            case 3: for(int i=start; i<=end; i++)retArray[i-start] = (Float)this.array.get(i);
                    break;
            case 4:
            case 5: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Long_to_Float((Long)this.array.get(i));
                    break;
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Integer_to_Float((Integer)this.array.get(i));
                    break;
            case 8:
            case 9: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Short_to_Float((Short)this.array.get(i));
                    break;
            case 10:
            case 11: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Byte_to_Float((Byte)this.array.get(i));
                    break;
            case 12: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigDecimal_to_Float((BigDecimal)this.array.get(i));
                    break;
            case 13: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigInteger_to_Float((BigInteger)this.array.get(i));
                    break;
            case 18: for(int i=start; i<=end; i++)retArray[i-start] = new Float((String)this.array.get(i));
                    break;
            case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_int_to_Float((int)((Character)this.array.get(i)).charValue());
                    break;
            case 14:
            case 15:  throw new IllegalArgumentException("The " + this.typeName[this.type] + " is not a numerical type for which a conversion to Float is meaningful/supported");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }

    // return sub-array as float
    public float[] subarray_as_float(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        float[] retArray = new float[end-start+1];
        switch(this.type){
            case 0:
            case 1: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Double_to_float((Double)this.array.get(i));
                    break;
            case 2:
            case 3: for(int i=start; i<=end; i++)retArray[i-start] = ((Float)this.array.get(i)).floatValue();
                    break;
            case 4:
            case 5: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Long_to_float((Long)this.array.get(i));
                    break;
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Integer_to_float((Integer)this.array.get(i));
                    break;
            case 8:
            case 9: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Short_to_float((Short)this.array.get(i));
                    break;
            case 10:
            case 11: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Byte_to_float((Byte)this.array.get(i));
                    break;
            case 12: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigDecimal_to_float((BigDecimal)this.array.get(i));
                    break;
            case 13: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigInteger_to_float((BigInteger)this.array.get(i));
                    break;
            case 18: for(int i=start; i<=end; i++)retArray[i-start] = (new Float((String)this.array.get(i))).floatValue();
                    break;
            case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_int_to_float((int)((Character)this.array.get(i)).charValue());
                    break;
            case 14:
            case 15: throw new IllegalArgumentException("The " + this.typeName[this.type] + " is not a numerical type for which a conversion to float is meaningful/supported");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }

    // return sub-array as long
    public long[] subarray_as_long(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        long[] retArray = new long[end-start+1];
        switch(this.type){
            case 0:
            case 1: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Double_to_long((Double)this.array.get(i));
                    break;
            case 2:
            case 3: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Float_to_long((Float)this.array.get(i));
                    break;
            case 4:
            case 5: for(int i=start; i<=end; i++)retArray[i-start] = ((Long)this.array.get(i)).longValue();
                    break;
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Integer_to_long((Integer)this.array.get(i));
                    break;
            case 8:
            case 9: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Short_to_long((Short)this.array.get(i));
                    break;
            case 10:
            case 11: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Byte_to_long((Byte)this.array.get(i));
                    break;
            case 12: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigDecimal_to_long((BigDecimal)this.array.get(i));
                    break;
            case 13: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigInteger_to_long((BigInteger)this.array.get(i));
                    break;
            case 18: for(int i=start; i<=end; i++)retArray[i-start] = (new Long((String)this.array.get(i))).longValue();
                    break;
            case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_int_to_long((int)((Character)this.array.get(i)).charValue());
                    break;
            case 14:
            case 15:  throw new IllegalArgumentException("The " + this.typeName[this.type] + " is not a numerical type for which a conversion to long is meaningful/supported");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }

    // return sub-array as Long
    public Long[] subarray_as_Long(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        Long[] retArray = new Long[end-start+1];
        switch(this.type){
            case 0:
            case 1: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Double_to_Long((Double)this.array.get(i));
                    break;
            case 2:
            case 3: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Float_to_Long((Float)this.array.get(i));
                    break;
            case 4:
            case 5: for(int i=start; i<=end; i++)retArray[i-start] = (Long)this.array.get(i);
                    break;
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Integer_to_Long((Integer)this.array.get(i));
                    break;
            case 8:
            case 9: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Short_to_Long((Short)this.array.get(i));
                    break;
            case 10:
            case 11: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Byte_to_Long((Byte)this.array.get(i));
                    break;
            case 12: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigDecimal_to_Long((BigDecimal)this.array.get(i));
                    break;
            case 13: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigInteger_to_Long((BigInteger)this.array.get(i));
                    break;
            case 18: for(int i=start; i<=end; i++)retArray[i-start] = new Long((String)this.array.get(i));
                    break;
            case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_int_to_Long((int)((Character)this.array.get(i)).charValue());
                    break;
            case 14:
            case 15: throw new IllegalArgumentException("The " + this.typeName[this.type] + " is not a numerical type for which a conversion to Long is meaningful/supported");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }


    // return sub-array as Integer
    public Integer[] subarray_as_Integer(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        Integer[] retArray = new Integer[end-start+1];
        switch(this.type){
            case 0:
            case 1: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Double_to_Integer((Double)this.array.get(i));
                    break;
            case 2:
            case 3: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Float_to_Integer((Float)this.array.get(i));
                    break;
            case 4:
            case 5: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Long_to_Integer((Long)this.array.get(i));
                    break;
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = (Integer)this.array.get(i);
                    break;
            case 8:
            case 9: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Short_to_Integer((Short)this.array.get(i));
                    break;
            case 10:
            case 11: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Byte_to_Integer((Byte)this.array.get(i));
                    break;
            case 12: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigDecimal_to_Integer((BigDecimal)this.array.get(i));
                    break;
            case 13: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigInteger_to_Integer((BigInteger)this.array.get(i));
                    break;
            case 18: for(int i=start; i<=end; i++)retArray[i-start] = new Integer((String)this.array.get(i));
                    break;
             case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = new Integer((int)((Character)this.array.get(i)).charValue());
                    break;
            case 14:
            case 15: throw new IllegalArgumentException("The " + this.typeName[this.type] + " is not a numerical type for which a conversion to Integer is meaningful/supported");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }

    // return sub-array as int
    public int[] subarray_as_int(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        int[] retArray = new int[end-start+1];
        switch(this.type){
            case 0:
            case 1: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Double_to_int((Double)this.array.get(i));
                    break;
            case 2:
            case 3: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Float_to_int((Float)this.array.get(i));
                    break;
            case 4:
            case 5: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Long_to_int((Long)this.array.get(i));
                    break;
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = ((Integer)this.array.get(i)).intValue();
                    break;
            case 8:
            case 9: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Short_to_int((Short)this.array.get(i));
                    break;
            case 10:
            case 11: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Byte_to_int((Byte)this.array.get(i));
                    break;
            case 12: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigDecimal_to_int((BigDecimal)this.array.get(i));
                    break;
            case 13: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigInteger_to_int((BigInteger)this.array.get(i));
                    break;
            case 18: for(int i=start; i<=end; i++)retArray[i-start] = (new Integer((String)this.array.get(i))).intValue();
                    break;
            case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = (int)((Character)this.array.get(i)).charValue();
                    break;
            case 14:
            case 15: throw new IllegalArgumentException("The " + this.typeName[this.type] + " is not a numerical type for which a conversion to int is meaningful/supported");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }

    // return sub-array as short
    public short[] subarray_as_short(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        short[] retArray = new short[end-start+1];
        switch(this.type){
            case 0:
            case 1: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Double_to_short((Double)this.array.get(i));
                    break;
            case 2:
            case 3: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Float_to_short((Float)this.array.get(i));
                    break;
            case 4:
            case 5: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Long_to_short((Long)this.array.get(i));
                    break;
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Integer_to_short((Integer)this.array.get(i));
                    break;
            case 8:
            case 9: for(int i=start; i<=end; i++)retArray[i-start] = ((Short)this.array.get(i)).shortValue();
                    break;
            case 10:
            case 11: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Byte_to_short((Byte)this.array.get(i));
                    break;
            case 12: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigDecimal_to_short((BigDecimal)this.array.get(i));
                    break;
            case 13: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigInteger_to_short((BigInteger)this.array.get(i));
                    break;
            case 18: for(int i=start; i<=end; i++)retArray[i-start] = (new Short((String)this.array.get(i))).shortValue();
                    break;
            case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_int_to_short((int)((Character)this.array.get(i)).charValue());
                    break;
            case 14:
            case 15: throw new IllegalArgumentException("The " + this.typeName[this.type] + " is not a numerical type for which a conversion to short is meaningful/supported");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }


    // return sub-array as Short
    public Short[] subarray_as_Short(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        Short[] retArray = new Short[end-start+1];
        switch(this.type){
            case 0:
            case 1: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Double_to_Short((Double)this.array.get(i));
                    break;
            case 2:
            case 3: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Float_to_Short((Float)this.array.get(i));
                    break;
            case 4:
            case 5: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Long_to_Short((Long)this.array.get(i));
                    break;
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Integer_to_Short((Integer)this.array.get(i));
                    break;
            case 8:
            case 9: for(int i=start; i<=end; i++)retArray[i-start] = (Short)this.array.get(i);
                    break;
            case 10:
            case 11: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Byte_to_Short((Byte)this.array.get(i));
                    break;
            case 12: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigDecimal_to_Short((BigDecimal)this.array.get(i));
                    break;
            case 13: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigInteger_to_Short((BigInteger)this.array.get(i));
                    break;
            case 18: for(int i=start; i<=end; i++)retArray[i-start] = new Short((String)this.array.get(i));
                    break;
            case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_int_to_Short((int)((Character)this.array.get(i)).charValue());
                    break;
            case 14:
            case 15: throw new IllegalArgumentException("The " + this.typeName[this.type] + " is not a numerical type for which a conversion to Short is meaningful/supported");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }

    // return sub-array as byte
    public byte[] subarray_as_byte(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        byte[] retArray = new byte[end-start+1];
        switch(this.type){
            case 0:
            case 1: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Double_to_byte((Double)this.array.get(i));
                    break;
            case 2:
            case 3: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Float_to_byte((Float)this.array.get(i));
                    break;
            case 4:
            case 5: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Long_to_byte((Long)this.array.get(i));
                    break;
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Integer_to_byte((Integer)this.array.get(i));
                    break;
            case 8:
            case 9: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Short_to_byte((Short)this.array.get(i));
                    break;
            case 10:
            case 11: for(int i=start; i<=end; i++)retArray[i-start] = ((Byte)this.array.get(i)).byteValue();
                    break;
            case 12: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigDecimal_to_byte((BigDecimal)this.array.get(i));
                    break;
            case 13: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigInteger_to_byte((BigInteger)this.array.get(i));
                    break;
            case 18: for(int i=start; i<=end; i++)retArray[i-start] = (new Byte((String)this.array.get(i))).byteValue();
                    break;
            case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_int_to_byte((int)((Character)this.array.get(i)).charValue());
                    break;
            case 14:
            case 15: throw new IllegalArgumentException("The " + this.typeName[this.type] + " is not a numerical type for which a conversion to byte is meaningful/supported");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }

    // return sub-array as Byte
    public Byte[] subarray_as_Byte(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        Byte[] retArray = new Byte[end-start+1];
        switch(this.type){
            case 0:
            case 1: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Double_to_Byte((Double)this.array.get(i));
                    break;
            case 2:
            case 3: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Float_to_Byte((Float)this.array.get(i));
                    break;
            case 4:
            case 5: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Long_to_Byte((Long)this.array.get(i));
                    break;
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Integer_to_Byte((Integer)this.array.get(i));
                    break;
            case 8:
            case 9: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Short_to_Byte((Short)this.array.get(i));
                    break;
            case 10:
            case 11: for(int i=start; i<=end; i++)retArray[i-start] = (Byte)this.array.get(i);
                    break;
            case 12: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigDecimal_to_Byte((BigDecimal)this.array.get(i));
                    break;
            case 13: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigInteger_to_Byte((BigInteger)this.array.get(i));
                    break;
            case 18: for(int i=start; i<=end; i++)retArray[i-start] = new Byte((String)this.array.get(i));
                    break;
            case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_int_to_Byte((int)((Character)this.array.get(i)).charValue());
                    break;
            case 14:
            case 15: throw new IllegalArgumentException("The " + this.typeName[this.type] + " is not a numerical type for which a conversion to Byte is meaningful/supported");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }

    // return sub-array as BigDecimal
    public BigDecimal[] subarray_as_BigDecimal(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        BigDecimal[] retArray = new BigDecimal[end-start+1];
        switch(this.type){
            case 0:
            case 1: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Double_to_BigDecimal((Double)this.array.get(i));
                    break;
            case 2:
            case 3: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Float_to_BigDecimal((Float)this.array.get(i));
                    break;
            case 4:
            case 5: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Long_to_BigDecimal((Long)this.array.get(i));
                    break;
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Integer_to_BigDecimal((Integer)this.array.get(i));
                    break;
            case 8:
            case 9: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Short_to_BigDecimal((Short)this.array.get(i));
                    break;
            case 10:
            case 11: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Byte_to_BigDecimal((Byte)this.array.get(i));
                    break;
            case 12: for(int i=start; i<=end; i++)retArray[i-start] = (BigDecimal)this.array.get(i);
                    break;
            case 13: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigInteger_to_BigDecimal((BigInteger)this.array.get(i));
                    break;
            case 18: for(int i=start; i<=end; i++)retArray[i-start] = new BigDecimal((String)this.array.get(i));
                    break;
            case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_int_to_BigDecimal((int)((Character)this.array.get(i)).charValue());
                    break;
            case 14:
            case 15: throw new IllegalArgumentException("The " + this.typeName[this.type] + " is not a numerical type for which a conversion to BigDecimal is meaningful/supported");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }

    // return sub-array as BigInteger
    public BigInteger[] subarray_as_BigInteger(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        BigInteger[] retArray = new BigInteger[end-start+1];
        switch(this.type){
            case 0:
            case 1: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Double_to_BigInteger((Double)this.array.get(i));
                    break;
            case 2:
            case 3: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Float_to_BigInteger((Float)this.array.get(i));
                    break;
            case 4:
            case 5: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Long_to_BigInteger((Long)this.array.get(i));
                    break;
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Integer_to_BigInteger((Integer)this.array.get(i));
                    break;
            case 8:
            case 9: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Short_to_BigInteger((Short)this.array.get(i));
                    break;
            case 10:
            case 11: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Byte_to_BigInteger((Byte)this.array.get(i));
                    break;
            case 12: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_BigDecimal_to_BigInteger((BigDecimal)this.array.get(i));
                    break;
            case 13: for(int i=start; i<=end; i++)retArray[i-start] = (BigInteger)this.array.get(i);
                    break;
            case 18: for(int i=start; i<=end; i++)retArray[i-start] = new BigInteger((String)this.array.get(i));
                    break;
            case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_int_to_BigInteger((int)((Character)this.array.get(i)).charValue());
                    break;
            case 14:
            case 15: throw new IllegalArgumentException("The " + this.typeName[this.type] + " is not a numerical type for which a conversion to BigInteger is meaningful/supported");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }

    // return sub-array as Complex
    public Complex[] subarray_as_Complex(int start, int end){

        if(this.suppressMessages)Conv.suppressMessages();
        Complex[] retArray = Complex.oneDarray(this.length);
        switch(this.type){
            case 0:
            case 1: for(int i=start; i<=end; i++)retArray[i-start] = new Complex(((Double)this.array.get(i)).doubleValue());
                    break;
            case 2:
            case 3: for(int i=start; i<=end; i++)retArray[i-start] = new Complex(((Float)this.array.get(i)).doubleValue());
                    break;
            case 4:
            case 5: for(int i=start; i<=end; i++)retArray[i-start] = new Complex(Conv.convert_Long_to_double((Long)this.array.get(i)));
                    break;
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = new Complex(Conv.convert_Integer_to_double((Integer)this.array.get(i)));
                    break;
            case 8:
            case 9: for(int i=start; i<=end; i++)retArray[i-start] = new Complex(Conv.convert_Short_to_double((Short)this.array.get(i)));
                    break;
            case 10:
            case 11: for(int i=start; i<=end; i++)retArray[i-start] = new Complex(Conv.convert_Byte_to_double((Byte)this.array.get(i)));
                    break;
            case 12: for(int i=start; i<=end; i++)retArray[i-start] = new Complex(Conv.convert_BigDecimal_to_double((BigDecimal)this.array.get(i)));
                    break;
            case 13: for(int i=start; i<=end; i++)retArray[i-start] = new Complex(Conv.convert_BigInteger_to_double((BigInteger)this.array.get(i)));
                    break;
            case 14: for(int i=start; i<=end; i++)retArray[i-start] = (Complex)this.array.get(i);
                    break;
            case 15: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Phasor_to_Complex((Phasor)this.array.get(i));
                    break;
            case 18: for(int i=start; i<=end; i++){
                        String ss = (String)this.array.get(i);
                        if(ss.indexOf('i')!=-1 || ss.indexOf('j')!=-1){
                            retArray[i-start] = Complex.valueOf(ss);
                        }
                        else{
                            retArray[i-start] = new Complex(Double.valueOf(ss));
                        }
                    }
                    break;
            case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = new Complex(Conv.convert_int_to_double((int)((Character)this.array.get(i)).charValue()));
                    break;
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }

    // return sub-array as Phasor
    public Phasor[] subarray_as_Phasor(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        Phasor[] retArray = Phasor.oneDarray(this.length);
        switch(this.type){
            case 0:
            case 1: for(int i=start; i<=end; i++)retArray[i-start] = new Phasor(((Double)this.array.get(i)).doubleValue());
                    break;
            case 2:
            case 3: for(int i=start; i<=end; i++)retArray[i-start] = new Phasor(((Float)this.array.get(i)).doubleValue());
                    break;
            case 4:
            case 5: for(int i=start; i<=end; i++)retArray[i-start] = new Phasor(Conv.convert_Long_to_double((Long)this.array.get(i)));
                    break;
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = new Phasor(Conv.convert_Integer_to_double((Integer)this.array.get(i)));
                    break;
            case 8:
            case 9: for(int i=start; i<=end; i++)retArray[i-start] = new Phasor(Conv.convert_Short_to_double((Short)this.array.get(i)));
                    break;
            case 10:
            case 11: for(int i=start; i<=end; i++)retArray[i-start] = new Phasor(Conv.convert_Byte_to_double((Byte)this.array.get(i)));
                    break;
            case 12: for(int i=start; i<=end; i++)retArray[i-start] = new Phasor(Conv.convert_BigDecimal_to_double((BigDecimal)this.array.get(i)));
                    break;
            case 13: for(int i=start; i<=end; i++)retArray[i-start] = new Phasor(Conv.convert_BigInteger_to_double((BigInteger)this.array.get(i)));
                    break;
            case 14: for(int i=start; i<=end; i++)retArray[i-start] = Conv.convert_Complex_to_Phasor((Complex)this.array.get(i));
                    break;
            case 15: for(int i=start; i<=end; i++)retArray[i-start] = (Phasor)this.array.get(i);
                    break;
            case 18: for(int i=start; i<=end; i++){
                        String ss = ((String)this.array.get(i)).trim();
                        if(ss.indexOf('<')!=-1 || ss.indexOf('L')!=-1){
                            retArray[i-start] = Phasor.valueOf(ss);
                        }
                        else{
                            retArray[i-start] = new Phasor(Double.valueOf(ss));
                        }
                    }
                    break;
            case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = new Phasor(Conv.convert_int_to_double((int)((Character)this.array.get(i)).charValue()));
                    break;
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }

    // return sub-array as Character
    public Character[] subarray_as_Character(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        Character[] retArray = new Character[end-start+1];
        switch(this.type){
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = new Character((char)(((Integer)this.array.get(i)).intValue()));
                    break;
            case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = (Character)this.array.get(i);
                    break;
            case 18: boolean test = true;
                    String[] ss = new String[end-start+1];
                    for(int i=start; i<=end; i++){
                        ss[i-start] = ((String)this.array.get(i)).trim();
                        if(ss[i-start].length()>1){
                            test=false;
                            break;
                        }
                    }
                    if(test){
                        for(int i=start; i<=end; i++)retArray[i-start] = new Character(ss[i-start].charAt(0));
                    }
                    else{
                        throw new IllegalArgumentException("The String array elements are too long to be converted to Character");
                    }
                    break;
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15: throw new IllegalArgumentException("The " + this.typeName[this.type] + " is not a numerical type for which a conversion to char is meaningful/supported");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }


    // return sub-array as char
    public char[] subarray_as_char(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        char[] retArray = new char[end-start+1];
        switch(this.type){
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = (char)(((Integer)this.array.get(i)).intValue());
                    break;
            case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = (((Character)this.array.get(i)).charValue());
                    break;
            case 18: boolean test = true;
                    String[] ss = new String[end-start+1];
                    for(int i=start; i<=end; i++){
                        ss[i-start] = ((String)this.array.get(i)).trim();
                        if(ss[i-start].length()>1){
                            test=false;
                            break;
                        }
                    }
                    if(test){
                        for(int i=start; i<=end; i++)retArray[i-start] = (ss[i-start].charAt(0));
                    }
                    else{
                        throw new IllegalArgumentException("The String array elements are too long to be converted to char");
                    }
                    break;
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15: throw new IllegalArgumentException("The " + this.typeName[this.type] + " is not a numerical type for which a conversion to char is meaningful/supported");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }

    // return sub-array as String
    public String[] subarray_as_String(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        String[] retArray = new String[end-start+1];
        switch(this.type){
            case 0:
            case 1: for(int i=start; i<=end; i++)retArray[i-start] = ((Double)this.array.get(i)).toString();
                    break;
            case 2:
            case 3: for(int i=start; i<=end; i++)retArray[i-start] = ((Float)this.array.get(i)).toString();
                    break;
            case 4:
            case 5: for(int i=start; i<=end; i++)retArray[i-start] = ((Long)this.array.get(i)).toString();
                    break;
            case 6:
            case 7: for(int i=start; i<=end; i++)retArray[i-start] = ((Integer)this.array.get(i)).toString();
                    break;
            case 8:
            case 9: for(int i=start; i<=end; i++)retArray[i-start] = ((Short)this.array.get(i)).toString();
                    break;
            case 10:
            case 11: for(int i=start; i<=end; i++)retArray[i-start] = ((Byte)this.array.get(i)).toString();
                    break;
            case 12: for(int i=start; i<=end; i++)retArray[i-start] = ((BigDecimal)this.array.get(i)).toString();
                    break;
            case 13: for(int i=start; i<=end; i++)retArray[i-start] = ((BigInteger)this.array.get(i)).toString();
                    break;
            case 14: for(int i=start; i<=end; i++)retArray[i-start] = ((Complex)this.array.get(i)).toString();
                    break;
            case 15: for(int i=start; i<=end; i++)retArray[i-start] = ((Phasor)this.array.get(i)).toString();
                    break;
            case 16:
            case 17: for(int i=start; i<=end; i++)retArray[i-start] = ((Character)this.array.get(i)).toString();
                    break;
            case 18: for(int i=start; i<=end; i++)retArray[i-start] = (String)this.array.get(i);
                    break;
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return retArray;
    }

    // return sub-array as Object
    public Object[] subarray_as_Object(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        Object[] arrayo= new Object[end-start+1];
        for(int i=start; i<=end; i++)arrayo[i-start] = this.array.get(i);
        return arrayo;
    }

    // return sub-array as Vector
    public Vector subarray_as_Vector(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        Vector vec = new Vector(end-start+1);
        for(int i=start; i<=end; i++)vec.addElement(array.get(i));
        return vec;
    }

    // return sub-array as ArrayList
    public ArrayList subarray_as_ArrayList(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        ArrayList arrayl = new ArrayList(end-start+1);
        for(int i=start; i<=end; i++)arrayl.add(array.get(i));
        return arrayl;
    }

    // return sub-array as a Row Matrix, Matrix.rowMatrix
    public Matrix subarray_as_Matrix_rowMatrix(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        Matrix mat = null;
        double[] retArray = new double[end-start+1];
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 16:
            case 18:
            case 17: double[] dd = getArray_as_double();
                    for(int i=start; i<=end; i++)retArray[i-start] = dd[i];
                    mat = Matrix.rowMatrix(retArray);
                    break;
            case 14: throw new IllegalArgumentException("Complex array cannot be converted to Matrix.rowMatrix - use method subarray_as_Complex_rowMatrix");
            case 15: throw new IllegalArgumentException("Phasor array cannot be converted to Matrix.rowMatrix - use method subarray_as_Phasor_rowMatrix");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return mat;
    }

    // return sub-array as a Column Matrix, Matrix.columnMatrix
    public Matrix subarray_as_Matrix_columnMatrix(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        if(this.suppressMessages)Conv.suppressMessages();
        Matrix mat = null;
        double[] retArray = new double[end-start+1];
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 16:
            case 18:
            case 17: double[] dd = getArray_as_double();
                    for(int i=start; i<=end; i++)retArray[i-start] = dd[i];
                    mat = Matrix.columnMatrix(retArray);
                    break;
            case 14: throw new IllegalArgumentException("Complex array cannot be converted to Matrix.columnMatrix - use method subarray_as_Complex_columnMatrix");
            case 15: throw new IllegalArgumentException("Phasor array cannot be converted to Matrix.columnMatrix - use method subarray_as_Phasor_columnMatrix");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        Conv.restoreMessages();
        return mat;
    }

    // return sub-array as a Complex Row Matix, Complex.rowMatrix
    public ComplexMatrix subarray_as_Complex_rowMatrix(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        Complex[] cc = this.getArray_as_Complex();
        Complex[] retArray = new Complex[end-start+1];
        for(int i=start; i<=end; i++)retArray[i-start] = cc[i];
        ComplexMatrix mat = ComplexMatrix.rowMatrix(retArray);
        return mat;
    }

    // return sub-array as a Complex Column Matrix, Complex.columnMatrix
    public ComplexMatrix subarray_as_Complex_columnMatrix(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        Complex[] cc = this.getArray_as_Complex();
        Complex[] retArray = new Complex[end-start+1];
        for(int i=start; i<=end; i++)retArray[i-start] = cc[i];
        ComplexMatrix mat = ComplexMatrix.columnMatrix(retArray);
        return mat;
    }

    // return sub-array as a Phasor Row Matix, Phasor.rowMatrix
    public PhasorMatrix subarray_as_Phasor_rowMatrix(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        Phasor[] pp = this.getArray_as_Phasor();
        Phasor[] retArray = new Phasor[end-start+1];
        for(int i=start; i<=end; i++)retArray[i-start] = pp[i];
        PhasorMatrix mat = PhasorMatrix.rowMatrix(retArray);
        return mat;
    }

    // return sub-array as a Phasor Column Matrix, Phasor.columnMatrix
    public PhasorMatrix subarray_as_Phasor_columnMatrix(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        Phasor[] pp = this.getArray_as_Phasor();
        Phasor[] retArray = new Phasor[end-start+1];
        for(int i=start; i<=end; i++)retArray[i-start] = pp[i];
        PhasorMatrix mat = PhasorMatrix.columnMatrix(retArray);
        return mat;
    }

    // return array of the moduli of a Complex sub-array
    public double[] subarray_as_modulus_of_Complex(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        Complex[] cc = this.getArray_as_Complex();
        double[] real = new double[end-start+1];
        for(int i=start; i<=end; i++)real[i-start] = cc[i].abs();
        return real;
    }

    // return array of real parts of a Complex sub-array
    public double[] subarray_as_real_part_of_Complex(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        Complex[] cc = this.getArray_as_Complex();
        double[] real = new double[end-start+1];
        for(int i=start; i<=end; i++)real[i-start] = cc[i].getReal();
        return real;
    }

    // return array of imaginary parts of a Complex sub-array
    public double[] subarray_as_imaginay_part_of_Complex(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        Complex[] cc = this.getArray_as_Complex();
        double[] imag = new double[end-start+1];
        for(int i=start; i<=end; i++)imag[i-start] = cc[i].getImag();
        return imag;
    }

    // return array of magnitudes of a Phasor sub-array
    public double[] subarray_as_magnitude_of_Phasor(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        Phasor[] pp = this.getArray_as_Phasor();
        double[] magn = new double[end-start+1];
        for(int i=start; i<=end; i++)magn[i-start] = pp[i].getMagnitude();
        return magn;
    }

    // return array of phases (in degrees) of a Phasor sub-array
    public double[] subarray_as_degrees_phase_of_Phasor(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        Phasor[] pp = this.getArray_as_Phasor();
        double[] phased = new double[end-start+1];
        for(int i=start; i<=end; i++)phased[i-start] = pp[i].getPhaseInDegrees();
        return phased;
    }

    // return array of phases (in radians) of a Phasor sub-array
    public double[] subarray_as_radians_phase_of_Phasor(int start, int end){
        if(end>=this.length)throw new IllegalArgumentException("end, " + end + ", is greater than the highest index, " + (this.length-1));
        Phasor[] pp = this.getArray_as_Phasor();
        double[] phaser = new double[end-start+1];
        for(int i=start; i<=end; i++)phaser[i-start] = pp[i].getPhaseInRadians();
        return phaser;
    }



    // MAXIMUM AND MINIMUM
    // protected method to call search method for maximum and minimum values
    // called by public methods
    protected void minmax(){
        int[] maxminIndices = new int[2];
        ArrayMaths.findMinMax(this.getArray_as_Object(), this.minmax, maxminIndices, this.typeName, this.type);
        this.maxIndex = maxminIndices[0];
        this.minIndex = maxminIndices[1];
    }

    // protected method that finds the maximum and minimum values
    // called by protected method minmax which is called by public methods
    protected static void findMinMax(Object[] arrayo, ArrayList minmaxx, int[] maxminIndices, String[] aTypeName, int aType){
        int maxIndexx = 0;
        int minIndexx = 0;
        int arraylength = arrayo.length;
        switch(aType){
            case 0:
            case 1: double[] arrayD = new double[arraylength];
                    for(int i=0; iamaxD){
                            amaxD = arrayD[i];
                            maxIndexx = i;
                        }
                        if(arrayD[i]amaxL){
                            amaxL = arrayL[i];
                            maxIndexx = i;
                        }
                        if(arrayL[i]amaxF){
                            amaxF = arrayF[i];
                            maxIndexx = i;
                        }
                        if(arrayF[i]amaxI){
                            amaxI = arrayI[i];
                            maxIndexx = i;
                        }
                        if(arrayI[i]amaxS){
                            amaxS = arrayS[i];
                            maxIndexx = i;
                        }
                        if(arrayS[i]amaxB){
                            amaxB = arrayB[i];
                            maxIndexx = i;
                        }
                        if(arrayB[i]amaxInt){
                            amaxInt = arrayInt[i];
                            maxIndexx = i;
                        }
                        if(arrayInt[i]();
        am.length = this.length;
        String constantS = Double.toString(constant);

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11: double[] dd = this.getArray_as_double();
                    for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11: double[] dd = this.getArray_as_double();
                    for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=constant){
                        for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=max2){
                        for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=constant){
                        for(int i=0; i=constant){
                        for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=max2){
                        for(int i=0; i=maxi2){
                        for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=constant){
                        for(int i=0; i=constant){
                        for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=max2){
                        for(int i=0; i=maxi2){
                        for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:BigDecimal[] bd = this.getArray_as_BigDecimal();
                    for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=constant){
                        for(int i=0; i=constant){
                        for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=max2){
                        for(int i=0; i=maxi2){
                        for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13: BigDecimal[] bd = this.getArray_as_BigDecimal();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 12: BigDecimal constantBD = Conv.convert_BigInteger_to_BigDecimal(constant);
                    BigDecimal[] bd = this.getArray_as_BigDecimal();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 12: BigDecimal[] bd = this.getArray_as_BigDecimal();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14: Complex[] cc = this.getArray_as_Complex();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14: Complex[] cc = this.getArray_as_Complex();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 15: Phasor[] pp = this.getArray_as_Phasor();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 15: Phasor[] pp = this.getArray_as_Phasor();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
            case 17:
            case 18: String[] ss = this.getArray_as_String();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
            case 17:
            case 18: String[] ss = this.getArray_as_String();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
            case 17:
            case 18: String[] ss = this.getArray_as_String();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
            case 17:
            case 18: String[] ss = this.getArray_as_String();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
            case 17:
            case 18: String[] ss = this.getArray_as_String();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
            case 17:
            case 18: String[] ss = this.getArray_as_String();
                    for(int i=0; i vec){
        if(this.suppressMessages)Conv.suppressMessages();
        ArrayMaths am1 = new ArrayMaths();
        ArrayMaths am2 = new ArrayMaths(vec);

        switch(am2.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = am2.getArray_as_double();
                    am1 = this.plus(dd);
                    break;
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11: long[] ll = am2.getArray_as_long();
                    am1 = this.plus(ll);
                    break;
            case 12: BigDecimal[] bd = am2.getArray_as_BigDecimal();
                    am1 = this.plus(bd);
                    break;
            case 13: BigInteger[] bi = am2.getArray_as_BigInteger();
                    am1 = this.plus(bi);
                    break;
            case 14: Complex[] cc = am2.getArray_as_Complex();
                    am1 = this.plus(cc);
                    break;
            case 15: Phasor[] pp = am2.getArray_as_Phasor();
                    am1 = this.plus(pp);
                    break;
            case 16:
            case 17: Character[] ct = am2.getArray_as_Character();
                    am1 = this.plus(ct);
                    break;
            case 18: String[] st = am2.getArray_as_String();
                    am1 = this.plus(st);
                    break;
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        int[] maxminIndices = new int[2];
        ArrayMaths.findMinMax(am1.getArray_as_Object(), am1.minmax, maxminIndices, am1.typeName, am1.type);
        am1.maxIndex = maxminIndices[0];
        am1.minIndex = maxminIndices[1];

        Conv.restoreMessages();
        return am1;
    }

    // add the elements of an array to the elements of the internal array
    public ArrayMaths plus(ArrayList list){
        if(this.suppressMessages)Conv.suppressMessages();
        ArrayMaths am1 = new ArrayMaths();
        ArrayMaths am2 = new ArrayMaths(list);

        switch(am2.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = am2.getArray_as_double();
                    am1 = this.plus(dd);
                    break;
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11: long[] ll = am2.getArray_as_long();
                    am1 = this.plus(ll);
                    break;
            case 12: BigDecimal[] bd = am2.getArray_as_BigDecimal();
                    am1 = this.plus(bd);
                    break;
            case 13: BigInteger[] bi = am2.getArray_as_BigInteger();
                    am1 = this.plus(bi);
                    break;
            case 14: Complex[] cc = am2.getArray_as_Complex();
                    am1 = this.plus(cc);
                    break;
            case 15: Phasor[] pp = am2.getArray_as_Phasor();
                    am1 = this.plus(pp);
                    break;
            case 16:
            case 17: Character[] ct = am2.getArray_as_Character();
                    am1 = this.plus(ct);
                    break;
            case 18: String[] st = am2.getArray_as_String();
                    am1 = this.plus(st);
                    break;
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        int[] maxminIndices = new int[2];
        ArrayMaths.findMinMax(am1.getArray_as_Object(), am1.minmax, maxminIndices, am1.typeName, am1.type);
        am1.maxIndex = maxminIndices[0];
        am1.minIndex = maxminIndices[1];

        Conv.restoreMessages();
        return am1;
    }

    // add the elements of an array to the elements of the internal array
    public ArrayMaths plus(ArrayMaths arrayM){
        ArrayList arrayl = arrayM.getArray_as_ArrayList();
        return this.plus(arrayl);
    }

    // add the elements of an array to the elements of the internal array
    public ArrayMaths plus(Stat arrayS){
        ArrayList arrayl = arrayS.getArray_as_ArrayList();
        return this.plus(arrayl);
    }

    // SUBTRACTION
    // subtract a constant from the elements of the internal array
    public ArrayMaths minus(double constant){
        if(this.suppressMessages)Conv.suppressMessages();
        ArrayMaths am = new ArrayMaths();
        am.array = new ArrayList();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11: double[] dd = this.getArray_as_double();
                    for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11: double[] dd = this.getArray_as_double();
                    for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=constant){
                        for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=max2){
                        for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=constant){
                        for(int i=0; i=constant){
                        for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=max2){
                        for(int i=0; i=maxi2){
                        for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=constant){
                        for(int i=0; i=constant){
                        for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=max2){
                        for(int i=0; i=maxi2){
                        for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:BigDecimal[] bd = this.getArray_as_BigDecimal();
                    for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=constant){
                        for(int i=0; i=constant){
                        for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=max2){
                        for(int i=0; i=maxi2){
                        for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13: BigDecimal[] bd = this.getArray_as_BigDecimal();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 12: BigDecimal constantBD = Conv.convert_BigInteger_to_BigDecimal(constant);
                    BigDecimal[] bd = this.getArray_as_BigDecimal();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 12: BigDecimal[] bd = this.getArray_as_BigDecimal();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14: Complex[] cc = this.getArray_as_Complex();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14: Complex[] cc = this.getArray_as_Complex();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 15: Phasor[] pp = this.getArray_as_Phasor();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 15: Phasor[] pp = this.getArray_as_Phasor();
                    for(int i=0; i vec){
        if(this.suppressMessages)Conv.suppressMessages();
        ArrayMaths am1 = new ArrayMaths();
        ArrayMaths am2 = new ArrayMaths(vec);

        switch(am2.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = am2.getArray_as_double();
                    am1 = this.minus(dd);
                    break;
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11: long[] ll = am2.getArray_as_long();
                    am1 = this.minus(ll);
                    break;
            case 12: BigDecimal[] bd = am2.getArray_as_BigDecimal();
                    am1 = this.minus(bd);
                    break;
            case 13: BigInteger[] bi = am2.getArray_as_BigInteger();
                    am1 = this.minus(bi);
                    break;
            case 14: Complex[] cc = am2.getArray_as_Complex();
                    am1 = this.minus(cc);
                    break;
            case 15: Phasor[] pp = am2.getArray_as_Phasor();
                    am1 = this.minus(pp);
                    break;
            case 16: throw new IllegalArgumentException("ArrayList/char subtraction not allowed");
            case 17: throw new IllegalArgumentException("ArrayList/Character subtraction not allowed");
            case 18: throw new IllegalArgumentException("ArrayList/String subtraction not allowed");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        int[] maxminIndices = new int[2];
        ArrayMaths.findMinMax(am1.getArray_as_Object(), am1.minmax, maxminIndices, am1.typeName, am1.type);
        am1.maxIndex = maxminIndices[0];
        am1.minIndex = maxminIndices[1];

        Conv.restoreMessages();
        return am1;
    }

    // Subtract the elements of an array from the elements of the internal array
    public ArrayMaths minus(ArrayList list){
        if(this.suppressMessages)Conv.suppressMessages();
        ArrayMaths am1 = new ArrayMaths();
        ArrayMaths am2 = new ArrayMaths(list);

        switch(am2.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = am2.getArray_as_double();
                    am1 = this.minus(dd);
                    break;
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11: long[] ll = am2.getArray_as_long();
                    am1 = this.minus(ll);
                    break;
            case 12: BigDecimal[] bd = am2.getArray_as_BigDecimal();
                    am1 = this.minus(bd);
                    break;
            case 13: BigInteger[] bi = am2.getArray_as_BigInteger();
                    am1 = this.minus(bi);
                    break;
            case 14: Complex[] cc = am2.getArray_as_Complex();
                    am1 = this.minus(cc);
                    break;
            case 15: Phasor[] pp = am2.getArray_as_Phasor();
                    am1 = this.minus(pp);
                    break;
            case 16: throw new IllegalArgumentException("ArrayList/char subtraction not allowed");
            case 17: throw new IllegalArgumentException("ArrayList/Character subtraction not allowed");
            case 18: throw new IllegalArgumentException("ArrayList/String subtraction not allowed");
            default: throw new IllegalArgumentException("Data type not identified by this method");
        }
        int[] maxminIndices = new int[2];
        ArrayMaths.findMinMax(am1.getArray_as_Object(), am1.minmax, maxminIndices, am1.typeName, am1.type);
        am1.maxIndex = maxminIndices[0];
        am1.minIndex = maxminIndices[1];

        Conv.restoreMessages();
        return am1;
    }

    // Subtract the elements of an array from the elements of the internal array
    public ArrayMaths minus(ArrayMaths arrayM){
        ArrayList arrayl = arrayM.getArray_as_ArrayList();
        return this.minus(arrayl);
    }

    // Subtract the elements of an array from the elements of the internal array
    public ArrayMaths minus(Stat arrayS){
        ArrayList arrayl = arrayS.getArray_as_ArrayList();
        return this.minus(arrayl);
    }

    // MULTIPLICATION
    // multiply the elements of the internal array by a constant
    public ArrayMaths times(double constant){
        if(this.suppressMessages)Conv.suppressMessages();
        ArrayMaths am = new ArrayMaths();
        am.array = new ArrayList();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11: double[] dd = this.getArray_as_double();
                    for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=constant){
                        for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=constant){
                        for(int i=0; i=constant){
                        for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=constant){
                        for(int i=0; i=constant){
                        for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:BigDecimal[] bd = this.getArray_as_BigDecimal();
                    for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=constant){
                        for(int i=0; i=constant){
                        for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 12: BigDecimal constantBD = Conv.convert_BigInteger_to_BigDecimal(constant);
                    BigDecimal[] bd = this.getArray_as_BigDecimal();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14: Complex[] cc = this.getArray_as_Complex();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 15: Phasor[] pp = this.getArray_as_Phasor();
                    for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11: double[] dd = this.getArray_as_double();
                    for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i=constant){
                        for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:BigDecimal[] bd = this.getArray_as_BigDecimal();
                    for(int i=0; i();
        am.length = this.length;

        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3: double[] dd = this.getArray_as_double();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 12: BigDecimal constantBD = Conv.convert_BigInteger_to_BigDecimal(constant);
                    BigDecimal[] bd = this.getArray_as_BigDecimal();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14: Complex[] cc = this.getArray_as_Complex();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 15: Phasor[] pp = this.getArray_as_Phasor();
                    for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:double[] dd = this.getArray_as_double();
                   for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:double[] dd = this.getArray_as_double();
                   for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:double[] dd = this.getArray_as_double();
                   for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:double[] dd = this.getArray_as_double();
                   for(int i=0; i();
        am.length = this.length;
        am.type = this.type;
        am.sortedIndices = new int[this.length];

        for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 16:
            case 17:
            case 18: double[] dd = this.getArray_as_double();
                     for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 16:
            case 17:
            case 18: double[] dd = this.getArray_as_double();
                     for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 16:
            case 17:
            case 18: double[] dd = this.getArray_as_double();
                     for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 16:
            case 17:
            case 18: double[] dd = this.getArray_as_double();
                     for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 16:
            case 17:
            case 18: double[] dd = this.getArray_as_double();
                     for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 16:
            case 17:
            case 18: double[] dd = this.getArray_as_double();
                     for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 16:
            case 17:
            case 18: double[] dd = this.getArray_as_double();
                     for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 16:
            case 17:
            case 18: double[] dd = this.getArray_as_double();
                     for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 16:
            case 17:
            case 18: double[] dd = this.getArray_as_double();
                     for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1: double[] dd = this.getArray_as_double();
                     for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 16:
            case 17:
            case 18: double[] dd = this.getArray_as_double();
                     for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 16:
            case 17:
            case 18: double[] dd = this.getArray_as_double();
                     for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 16:
            case 17:
            case 18: double[] dd = this.getArray_as_double();
                     for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 16:
            case 17:
            case 18: double[] dd = this.getArray_as_double();
                     for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 16:
            case 17:
            case 18: double[] dd = this.getArray_as_double();
                     for(int i=0; i();
        am.length = this.length;
        switch(this.type){
            case 0:
            case 1:
            case 16:
            case 17:
            case 18:double[] dd = this.getArray_as_double();
                    for(int i=0; i();
        am.length = this.length;
        am.type = this.type;
        PsRandom ran = new PsRandom();
        am.sortedIndices = ran.uniqueIntegerArray(this.length-1);

        switch(this.type){
            case 0:
            case 1: for(int i=0; i();
        am.length = this.length;
        am.type = this.type;
        am.sortedIndices = new int[this.length];

        switch(this.type){
            case 0:
            case 1: double[] dd1 = this.getArray_as_double();
                    am.sortedIndices = this.sortWithIndices(dd1);
                    for(int i=0; i al = this.alphabeticSort(ww);
                     String[] www = (String[])al.get(0);
                     for(int i=0; i alphabeticSort(String[] words){

        this.words = words;
        this.nWords = words.length;

        this.sortedWords = new String[this.nWords];
        for(int i=0; i ret = new ArrayList();
        ret.add(sortedWords);
        ret.add(wordOrder);

        return ret;
    }

    // get sorted indices
    public void alphabeticSortIndices(String[] words){

        // copy and pad to longest word
        String[] copy = new String[this.nWords];
        this.nLength = 0;
        int nn = 0;
        for(int i=0; ithis.nLength)this.nLength = nn;
            copy[i] = words[i].toLowerCase();
        }

        // convert to character arrays
        this.wordChar = new char[this.nWords][this.nLength];
        this.holdWordChar = new char[this.nWords][this.nLength];
        for(int i=0; i1)this.indexSort(0, 0, this.nWords-1);
    }

    public void indexSort(int ii, int iStart, int iEnd){

        int n = iEnd - iStart + 1;
        char[] colChar = new char[n];
        int[] colInt = new int[n];
        for(int i=0; i al = null;
        if(ii();
            jj = iStart;
            al.add(new Integer(jj));
            for(int i=1; i<=n; i++){
                jj++;
                if(test[i]!=test[i-1]){
                    al.add(new Integer(jj-1));
                    al.add(new Integer(jj));
                }
            }
            al.add(new Integer(iEnd));

            int nSub = al.size();
            for(int i=0; i1)this.indexSort(ii+1, vs, ve);
            }
        }
    }

    // sort by initial letter
    public int[] sortByColumnInitial(char[] initials){
        int n = initials.length;
        int[] intChar = new int[n];
        for(int i=0; i();
        am.length = this.length;
        am.type = this.type;
        am.sortedIndices = indices;
        switch(this.type){
            case 0:
            case 1: for(int i=0; i();
        am.length = xx.length + this.length;
        ArrayMaths am2 = null;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 16:
            case 17: double[] yy = this.getArray_as_double();
                     double[] zz = new double[am.length];
                     for(int i=0; i();
        am.length = xx.length + this.length;
        ArrayMaths am2 = null;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:double[] yy = this.getArray_as_double();
                   double[] zz = new double[am.length];
                   for(int i=0; i();
        am.length = xx.length + this.length;
        ArrayMaths am2 = null;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:double[] yy = this.getArray_as_double();
                   double[] zz = new double[am.length];
                   for(int i=0; i();
        am.length = xx.length + this.length;
        ArrayMaths am2 = null;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 16:
            case 17: BigDecimal[] bd1 = this.getArray_as_BigDecimal();
                     am2 = new ArrayMaths(xx);
                     BigDecimal[] bd2 = am2.getArray_as_BigDecimal();
                     BigDecimal[] bda = new BigDecimal[am.length];
                     for(int i=0; i();
        am.length = xx.length + this.length;
        ArrayMaths am2 = null;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 12: BigDecimal[] bd1 = this.getArray_as_BigDecimal();
                     am2 = new ArrayMaths(xx);
                     BigDecimal[] bd2 = am2.getArray_as_BigDecimal();
                     BigDecimal[] bda = new BigDecimal[am.length];
                     for(int i=0; i();
        am.length = xx.length + this.length;
        ArrayMaths am2 = null;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
            case 17:  Complex[] cc1 = this.getArray_as_Complex();
                     am2 = new ArrayMaths(xx);
                     Complex[] cc2 = am2.getArray_as_Complex();
                     Complex[] cca = new Complex[am.length];
                     for(int i=0; i();
        am.length = xx.length + this.length;
        ArrayMaths am2 = null;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
            case 17:  Phasor[] pp1 = this.getArray_as_Phasor();
                     am2 = new ArrayMaths(xx);
                     Phasor[] pp2 = am2.getArray_as_Phasor();
                     Phasor[] ppa = new Phasor[am.length];
                     for(int i=0; i();
        am.length = xx.length + this.length;
        ArrayMaths am2 = null;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
            case 17:
            case 18: String[] ss1 = this.getArray_as_String();
                     am2 = new ArrayMaths(xx);
                     String[] ss2 = am2.getArray_as_String();
                     String[] ssa = new String[am.length];
                     for(int i=0; i();
        am.length = xx.length + this.length;
        ArrayMaths am2 = null;
        switch(this.type){
            case 0:
            case 1:
            case 2:
            case 3:double[] yy = this.getArray_as_double();
                   double[] zz = new double[am.length];
                   for(int i=0; i=arrayc.length)test = false;
                }
            }
        }
        else{
            throw new IllegalArgumentException("Only comparisons between the same data types are supported - you are attempting to compare double or Double with " + this.typeName[this.type]);
        }
        Conv.restoreMessages();
        return index;
    }

    // finds the index of the first occurence of the element equal to a given value in an array
    // returns -1 if none found
    public int indexOf(Double value){
        double val = value.doubleValue();
        return this.indexOf(val);
    }

    // finds the index of the first occurence of the element equal to a given value in an array
    // returns -1 if none found
    public int indexOf(float value){
        if(this.suppressMessages)Conv.suppressMessages();
        int index = -1;
        if(this.type==2 || this.type==3){
            float[] arrayc = this.getArray_as_float();
            boolean test = true;
            int counter = 0;
            while(test){
                if(arrayc[counter]==value){
                    index = counter;
                    test = false;
                }
                else{
                    counter++;
                    if(counter>=arrayc.length)test = false;
                }
            }
        }
        else{
            throw new IllegalArgumentException("Only comparisons between the same data types are supported - you are attempting to compare float or Float with " + this.typeName[this.type]);
        }
        Conv.restoreMessages();
        return index;
    }

    // finds the index of the first occurence of the element equal to a given value in an array
    // returns -1 if none found
    public int indexOf(Float value){
        float val = value.floatValue();
        return this.indexOf(val);
    }


    // finds the index of the first occurence of the element equal to a given value in an array
    // returns -1 if none found
    public int indexOf(long value){
        if(this.suppressMessages)Conv.suppressMessages();
        int index = -1;
        if(this.type==4 || this.type==5){
            long[] arrayc = this.getArray_as_long();
            boolean test = true;
            int counter = 0;
            while(test){
                if(arrayc[counter]==value){
                    index = counter;
                    test = false;
                }
                else{
                    counter++;
                    if(counter>=arrayc.length)test = false;
                }
            }
        }
        else{
            throw new IllegalArgumentException("Only comparisons between the same data types are supported - you are attempting to compare long or Long with " + this.typeName[this.type]);
        }
        Conv.restoreMessages();
        return index;
    }

    // finds the index of the first occurence of the element equal to a given value in an array
    // returns -1 if none found
    public int indexOf(Long value){
        long val = value.longValue();
        return this.indexOf(val);
    }

    // finds the index of the first occurence of the element equal to a given value in an array
    // returns -1 if none found
    public int indexOf(int value){
        if(this.suppressMessages)Conv.suppressMessages();
        int index = -1;
        if(this.type==6 || this.type==7){
            int[] arrayc = this.getArray_as_int();
            boolean test = true;
            int counter = 0;
            while(test){
                if(arrayc[counter]==value){
                    index = counter;
                    test = false;
                }
                else{
                    counter++;
                    if(counter>=arrayc.length)test = false;
                }
            }
        }
        else{
            throw new IllegalArgumentException("Only comparisons between the same data types are supported - you are attempting to compare int or Integer with " + this.typeName[this.type]);
        }
        Conv.restoreMessages();
        return index;
    }

    // finds the index of the first occurence of the element equal to a given value in an array
    // returns -1 if none found
    public int indexOf(Integer value){
        int val = value.intValue();
        return this.indexOf(val);
    }

    // finds the index of the first occurence of the element equal to a given value in an array
    // returns -1 if none found
    public int indexOf(short value){
        if(this.suppressMessages)Conv.suppressMessages();
        int index = -1;
        if(this.type==8 || this.type==9){
            short[] arrayc = this.getArray_as_short();
            boolean test = true;
            int counter = 0;
            while(test){
                if(arrayc[counter]==value){
                    index = counter;
                    test = false;
                }
                else{
                    counter++;
                    if(counter>=arrayc.length)test = false;
                }
            }
        }
        else{
            throw new IllegalArgumentException("Only comparisons between the same data types are supported - you are attempting to compare short or Short with " + this.typeName[this.type]);
        }
        Conv.restoreMessages();
        return index;
    }

    // finds the index of the first occurence of the element equal to a given value in an array
    // returns -1 if none found
    public int indexOf(Short value){
        short val = value.shortValue();
        return this.indexOf(val);
    }

    // finds the index of the first occurence of the element equal to a given value in an array
    // returns -1 if none found
    public int indexOf(byte value){
        if(this.suppressMessages)Conv.suppressMessages();
        int index = -1;
        if(this.type==10 || this.type==11){
            byte[] arrayc = this.getArray_as_byte();
            boolean test = true;
            int counter = 0;
            while(test){
                if(arrayc[counter]==value){
                    index = counter;
                    test = false;
                }
                else{
                    counter++;
                    if(counter>=arrayc.length)test = false;
                }
            }
        }
        else{
            throw new IllegalArgumentException("Only comparisons between the same data types are supported - you are attempting to compare byte or Byte with " + this.typeName[this.type]);
        }
        Conv.restoreMessages();
        return index;
    }

    // finds the index of the first occurence of the element equal to a given value in an array
    // returns -1 if none found
    public int indexOf(Byte value){
        byte val = value.byteValue();
        return this.indexOf(val);
    }


    // finds the index of the first occurence of the element equal to a given value in an array
    // returns -1 if none found
    public int indexOf(char value){
        if(this.suppressMessages)Conv.suppressMessages();
        int index = -1;
        if(this.type==16 || this.type==17){
            char[] arrayc = this.getArray_as_char();
            boolean test = true;
            int counter = 0;
            while(test){
                if(arrayc[counter]==value){
                    index = counter;
                    test = false;
                }
                else{
                    counter++;
                    if(counter>=arrayc.length)test = false;
                }
            }
        }
        else{
            throw new IllegalArgumentException("Only comparisons between the same data types are supported - you are attempting to compare char or Character with " + this.typeName[this.type]);
        }
        Conv.restoreMessages();
        return index;
    }

    // finds the index of the first occurence of the element equal to a given value in an array
    // returns -1 if none found
    public int indexOf(Character value){
        char val = value.charValue();
        return this.indexOf(val);
    }

    // finds the index of the first occurence of the element equal to a given value in an array
    // returns -1 if none found
    public int indexOf(String value){
        if(this.suppressMessages)Conv.suppressMessages();
        int index = -1;
        if(this.type==18){
            String[] arrayc = this.getArray_as_String();
            boolean test = true;
            int counter = 0;
            while(test){
                if(arrayc[counter].equals(value)){
                    index = counter;
                    test = false;
                }
                else{
                    counter++;
                    if(counter>=arrayc.length)test = false;
                }
            }
        }
        else{
            throw new IllegalArgumentException("Only comparisons between the same data types are supported - you are attempting to compare String with " + this.typeName[this.type]);
        }
        Conv.restoreMessages();
        return index;
    }

    // finds the index of the first occurence of the element equal to a given value in an array
    // returns -1 if none found
    public int indexOf(Complex value){
        if(this.suppressMessages)Conv.suppressMessages();
        int index = -1;
        if(this.type==14){
            Complex[] arrayc = this.getArray_as_Complex();
            boolean test = true;
            int counter = 0;
            while(test){
                if(arrayc[counter].equals(value)){
                    index = counter;
                    test = false;
                }
                else{
                    counter++;
                    if(counter>=arrayc.length)test = false;
                }
            }
        }
        else{
            throw new IllegalArgumentException("Only comparisons between the same data types are supported - you are attempting to compare Complex with " + this.typeName[this.type]);
        }
        Conv.restoreMessages();
        return index;
    }

    // finds the index of the first occurence of the element equal to a given value in an array
    // returns -1 if none found
    public int indexOf(Phasor value){
        if(this.suppressMessages)Conv.suppressMessages();
        int index = -1;
        if(this.type==15){
            Phasor[] arrayc = this.getArray_as_Phasor();
            boolean test = true;
            int counter = 0;
            while(test){
                if(arrayc[counter].equals(value)){
                    index = counter;
                    test = false;
                }
                else{
                    counter++;
                    if(counter>=arrayc.length)test = false;
                }
            }
        }
        else{
            throw new IllegalArgumentException("Only comparisons between the same data types are supported - you are attempting to compare Phasor with " + this.typeName[this.type]);
        }
        Conv.restoreMessages();
        return index;
    }

    // finds the index of the first occurence of the element equal to a given value in an array
    // returns -1 if none found
    public int indexOf(BigDecimal value){
        if(this.suppressMessages)Conv.suppressMessages();
        int index = -1;
        if(this.type==12){
            BigDecimal[] arrayc = this.getArray_as_BigDecimal();
            boolean test = true;
            int counter = 0;
            while(test){
                if(arrayc[counter].compareTo(value)==0){
                    index = counter;
                    test = false;
                }
                else{
                    counter++;
                    if(counter>=arrayc.length)test = false;
                }
            }
        }
        else{
            throw new IllegalArgumentException("Only comparisons between the same data types are supported - you are attempting to compare BigDecimal with " + this.typeName[this.type]);
        }
        Conv.restoreMessages();
        return index;
    }

    // finds the index of the first occurence of the element equal to a given value in an array
    // returns -1 if none found
    public int indexOf(BigInteger value){
        if(this.suppressMessages)Conv.suppressMessages();
        int index = -1;
        if(this.type==13){
            BigInteger[] arrayc = this.getArray_as_BigInteger();
            boolean test = true;
            int counter = 0;
            while(test){
                if(arrayc[counter].compareTo(value)==0){
                    index = counter;
                    test = false;
                }
                else{
                    counter++;
                    if(counter>=arrayc.length)test = false;
                }
            }
        }
        else{
            throw new IllegalArgumentException("Only comparisons between the same data types are supported - you are attempting to compare BigInteger with " + this.typeName[this.type]);
        }
        Conv.restoreMessages();
        return index;
    }


    // finds all indices of the occurences of the element equal to a given value in an array
    // returns null if none found
    public int[] indicesOf(double value){
        if(this.suppressMessages)Conv.suppressMessages();
        int[] indices = null;
        int numberOfIndices = 0;
        if(this.type==0 || this.type==1){
            double[] arrayc = this.getArray_as_double();
            ArrayList arrayl = new ArrayList();
            for(int i=0; i arrayl = new ArrayList();
            for(int i=0; i arrayl = new ArrayList();
            for(int i=0; i arrayl = new ArrayList();
            for(int i=0; i arrayl = new ArrayList();
            for(int i=0; i arrayl = new ArrayList();
            for(int i=0; i arrayl = new ArrayList();
            for(int i=0; i arrayl = new ArrayList();
            for(int i=0; i arrayl = new ArrayList();
            for(int i=0; i arrayl = new ArrayList();
            for(int i=0; i arrayl = new ArrayList();
            for(int i=0; i arrayl = new ArrayList();
            for(int i=0; i2)throw new IllegalArgumentException("Argument n, " + n +", must be less than 3");

        double[] xAxis = new double[this.length];
        for(int i=0; i 
 

Ads help maintain this website.