Package flanagan.math

Examples of flanagan.math.ArrayMaths


        }

        // print an array of Floats to screen
        // No line returns except at the end
        public static void print(Float[] aa, int trunc){
            ArrayMaths am = new ArrayMaths(aa);
            am = am.truncate(trunc);
            Float[] aaa = am.array_as_Float();
            for(int i=0; i<aa.length; i++){
                System.out.print(aaa[i]+"   ");
            }
            System.out.println();
        }
View Full Code Here


        }

        // print an array of Floats to screen with truncation
        // with line returns
        public static void println(Float[] aa, int trunc){
            ArrayMaths am = new ArrayMaths(aa);
            am = am.truncate(trunc);
            Float[] aaa = am.array_as_Float();
            for(int i=0; i<aa.length; i++){
                System.out.println(aaa[i]+"   ");
            }
        }
View Full Code Here

    // Creation of a data file facilitating a full analysis of the data minus the least consitent item
    private void deletedItemDataFile(double[] newRawAlpha, double[] newRawRho, double[] newStandardizedAlpha, double[] newStandardizedRho){

        // Find maximum alpha and minimum correlation with totals
        ArrayMaths am = new ArrayMaths(newRawAlpha);
        int index1 =  am.maximumIndex();
        am = new ArrayMaths(newStandardizedAlpha);
        int index2 =  am.maximumIndex();
        am = new ArrayMaths(newRawRho);
        int index3 =  am.minimumIndex();
        am = new ArrayMaths(newStandardizedRho);
        int index4 =  am.minimumIndex();


        // majority voting on least consistent item
        this.deletedItemIndex = index3;
        if(index1==index2 && index1==index3 && index1==index4){
View Full Code Here

        double[] visc20 = {1.000, 1.013, 1.026, 1.039, 1.053, 1.067, 1.082, 1.097, 1.112, 1.128, 1.144, 1.160, 1.177, 1.195, 1.213, 1.232, 1.251, 1.271, 1.291, 1.312, 1.333, 1.378, 1.426, 1.477, 1.531, 1.589, 1.650, 1.716, 1.786, 1.861, 1.941, 2.120, 2.326, 2.568, 2.849, 3.181, 3.754, 4.044, 4.612, 5.304, 6.150, 7.220, 8.579, 10.28, 12.49, 15.40, 19.30, 24.63, 32.06, 42.69, 58.37, 82.26, 119.9, 181.7, 287.9, 480.6, 853.2, 1628};
        int viscLength = visc20.length;
        for(int i=0; i<viscLength; i++)visc20[i] *= 1.005;
        double[] concnWA = {0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84};
      double[] concnGA = {0, 5, 10, 15.1, 20.1, 25.2, 30.3, 35.4, 40.6, 45.7, 50.9, 56.1, 61.3, 66.5, 71.8, 77.1, 82.4, 87.7, 93.1, 98.4, 103.8, 114.7, 125.6, 136.6, 147.7, 158.9, 170.2, 181.5, 193, 204.5, 216.2, 239.8, 263.8, 288.1, 312.9, 338.1, 363.7, 389.8, 416.2, 443.2, 470.6, 498.4, 526.8, 555.6, 584.9, 614.8, 645.1, 676, 707.4, 739.3, 771.9, 804.9, 838.6, 872.8, 907.6, 943.1, 979.1, 1015.7, 1053, 1090.9, 1129.4, 1168.5, 1208.2};
        ArrayMaths amC = new ArrayMaths(concnGA);
        double[] zero = {1.7921, 1.5188, 1.3077, 1.1404, 1.0050, 0.8937, 0.8007, 0.7225, 0.6560, 0.5988, 0.5454, 0.5064, 0.4688, 0.4355, 0.4061, 0.3799, 0.3565, 0.3355, 0.3165, 0.29940.2838};
        int length0 = zero.length;

        double[] twenty = {3.804, 3.154, 2.652, 2.267, 1.960, 1.704, 1.504, 1.331, 1.193, 1.070, 0.970, 0.884, 0.808, 0.742, 0.685, 0.635, 0.590, 0.550};
        int length20 = twenty.length;
        double[] forty = {14.77, 11.56, 9.794, 7.468, 6.200, 5.187, 4.382, 3.762, 3.249, 2.847, 2.497, 2.219, 1.982, 1.778, 1.608, 1.462, 1.334, 1.221, 1.123, 1.037, 0.960};
        int length40 = forty.length;
        double[] sixty = {238, 156, 109.8, 74.6, 56.5, 43.86, 33.78, 26.52, 21.28, 17.18, 14.01, 11.67, 9.83, 8.34, 7.15, 6.20, 5.40, 4.73, 4.15, 3.72, 3.34};
        int length60 = sixty.length;
        double[] temp = new double[length0];
        temp[0] = 0;
        for(int i=1; i<length60; i++)temp[i] = temp[i-1] + 5.0;
        ArrayMaths am0 = new ArrayMaths(zero);
        ArrayMaths am20 = new ArrayMaths(twenty);
        ArrayMaths am40 = new ArrayMaths(forty);
        ArrayMaths am60 = new ArrayMaths(sixty);
        ArrayMaths amT = new ArrayMaths(temp);

        double[] concn85 = {0.0, 216.2, 470.6, 771.9};
        double[] concn100 = {0.0, 470.6, 771.9};

        double ret = Double.NaN;

        if(gPerL<=771.9){
            if(temperature<=85){

                int lengthT85 = length20;
                int lengthC85 =  amC.indexOf(771.9);
                double[] temp85 = amT.subarray_as_double(0, length20-1);
                double[] conc85 = amC.subarray_as_double(0, lengthC85);

                lengthC85++;
                double[][] array = new double[lengthT85][lengthC85];
                for(int i=0; i<lengthT85; i++){
                    double[] lvisc = {Math.log(zero[i]), Math.log(twenty[i]), Math.log(forty[i]), Math.log(sixty[i])};
                    CubicSpline cs = new CubicSpline(concn85, lvisc);
                    for(int j=0; j<lengthC85; j++){
                        array[i][j] = cs.interpolate(conc85[j]);
                    }
                }
                BiCubicSpline bcs = new BiCubicSpline(temp85, conc85, array);
                ret = Math.exp(bcs.interpolate(temperature, gPerL));
            }
            else{
                if(temperature>100.0){
                    throw new IllegalArgumentException("Temperature, " + temperature + ", out of range");
                }
                else{
                    int lengthT100 = length60;
                    int lengthC100 =  amC.indexOf(771.9);
                    double[] temp100 = amT.subarray_as_double(0, lengthT100-1);
                    double[] conc100 = amC.subarray_as_double(0, lengthC100);
                    lengthC100++;

                    double[][] array = new double[lengthT100][lengthC100];
                    for(int i=0; i<lengthT100; i++){
View Full Code Here

                          for(int i=0; i<nticks; i++)tickval[i] = ttickval[i];
                          break;
             }

            // ensure a zero value is truly zero and not a zero with rounding errors, e.g. 1e-17
             ArrayMaths am = new ArrayMaths(tickval);
            double max = am.maximum();
            double min = Math.abs(am.minimum());
            boolean testZero = true;
            int counter = 0;
            while(testZero){
                if(Math.abs(tickval[counter])<max*1e-4 || Math.abs(tickval[counter])<min*1e-4){
                    tickval[counter] = 0.0;
View Full Code Here

         // Construct matrix with a copy of an existing numberOfRows 1-D array of ArrayLists<Object>
        public Matrix(ArrayList<Object>[] twoDal){
            this.numberOfRows = twoDal.length;
            ArrayMaths[] twoD = new ArrayMaths[this.numberOfRows];
            for(int i=0; i<this.numberOfRows; i++){
                twoD[i] = new ArrayMaths(twoDal[i]);
            }

        this.numberOfColumns = twoD[0].length();
        this.matrix = new double[this.numberOfRows][this.numberOfColumns];
        for(int i=0; i<numberOfRows; i++){
View Full Code Here

        // Construct matrix with a copy of an existing numberOfRows 1-D array of Vector<Object>
        public Matrix(Vector<Object>[] twoDv){
            this.numberOfRows = twoDv.length;
            ArrayMaths[] twoD = new ArrayMaths[this.numberOfRows];
            for(int i=0; i<this.numberOfRows; i++){
                twoD[i] = new ArrayMaths(twoDv[i]);
            }

        this.numberOfColumns = twoD[0].length();
        this.matrix = new double[this.numberOfRows][this.numberOfColumns];
        for(int i=0; i<numberOfRows; i++){
View Full Code Here

      // MAXIMUM ELEMENT
      // Returns the value, row index and column index of the maximum element
      public double[] maximumElement(){
          double[] ret = new double[3];
          double[] holdD = new double[this.numberOfRows];
          ArrayMaths am = null;
          int[] holdI = new int [this.numberOfRows];
          for(int i=0; i<this.numberOfRows; i++){
              am = new ArrayMaths(this.matrix[i]);
              holdD[i] = am.maximum();
              holdI[i] = am.maximumIndex();
          }
          am = new ArrayMaths(holdD);
          ret[0] = am.maximum();
          int maxI = am.maximumIndex();
          ret[1] = (double)maxI;
          ret[2] = (double)holdI[maxI];

          return ret;
      }
View Full Code Here

      // MINIMUM ELEMENT
      // Returns the value, row index and column index of the minimum element
      public double[] minimumElement(){
          double[] ret = new double[3];
          double[] holdD = new double[this.numberOfRows];
          ArrayMaths am = null;
          int[] holdI = new int [this.numberOfRows];
          for(int i=0; i<this.numberOfRows; i++){
              am = new ArrayMaths(this.matrix[i]);
              holdD[i] = am.minimum();
              holdI[i] = am.minimumIndex();
          }
          am = new ArrayMaths(holdD);
          ret[0] = am.minimum();
          int minI = am.minimumIndex();
          ret[1] = (double)minI;
          ret[2] = (double)holdI[minI];

          return ret;
      }
View Full Code Here

          if(nPoints!=y.length)throw new IllegalArgumentException("Arrays x1 and y-row are of different length " + nPoints + " " + y.length);
          if(mPoints!=y[0].length)throw new IllegalArgumentException("Arrays x2 and y-column are of different length "+ mPoints + " " + y[0].length);
            if(nPoints<2 || mPoints<2)throw new IllegalArgumentException("The data matrix must have a minimum size of 2 X 2");

            // order data
            ArrayMaths am = new ArrayMaths(x1);
            am = am.sort();
            this.x1indices = am.originalIndices();
            x1 = am.array();
            double[][] hold = new double[nPoints][mPoints];
            double[][] hold1 = null;
            double[][] hold2 = null;
            double[][] hold12 = null;

            for(int i=0; i<nPoints; i++){
              for(int j=0; j<mPoints; j++){
                  hold[i][j] = y[this.x1indices[i]][j];
              }
          }
            for(int i=0; i<nPoints; i++){
              for(int j=0; j<mPoints; j++){
                  y[i][j] = hold[i][j];
              }
          }

          if(flag){
                hold1 = new double[nPoints][mPoints];
                hold2 = new double[nPoints][mPoints];
                hold12 = new double[nPoints][mPoints];
                for(int i=0; i<nPoints; i++){
                  for(int j=0; j<mPoints; j++){
                      hold1[i][j] = dydx1[this.x1indices[i]][j];
                      hold2[i][j] = dydx2[this.x1indices[i]][j];
                      hold12[i][j] = d2ydx1dx2[this.x1indices[i]][j];
                  }
              }
                for(int i=0; i<nPoints; i++){
                  for(int j=0; j<mPoints; j++){
                      dydx1[i][j] = hold1[i][j];
                      dydx2[i][j] = hold2[i][j];
                      d2ydx1dx2[i][j] = hold12[i][j];
                  }
              }
            }

          am = new ArrayMaths(x2);
            am = am.sort();
            this.x2indices = am.originalIndices();
            double[] xh = am.array();
            for(int i=0; i<mPoints; i++)x2[i] = xh[mPoints-1-i];
            for(int i=0; i<mPoints; i++){
              for(int j=0; j<nPoints; j++){
                  hold[j][i] = y[j][this.x2indices[i]];
              }
View Full Code Here

TOP

Related Classes of flanagan.math.ArrayMaths

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.