Java Array Divide div(float[] nums, int n)

Here you can find the source of div(float[] nums, int n)

Description

div

License

Apache License

Declaration

public static float[] div(float[] nums, int n) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Arrays;

public class Main {
    public static float[] div(float[] nums, int n) {
        for (int i = 0; i < nums.length; i++)
            nums[i] /= n;/*from  www. j a  va  2s  .c o  m*/
        return nums;
    }

    public static float[] div(float[] nums, float n) {
        assert !Float.isInfinite(n) : "Trying to divide "
                + Arrays.toString(nums) + " by  " + n; // Almost surely not what you want
        for (int i = 0; i < nums.length; i++)
            nums[i] /= n;
        return nums;
    }

    public static double[] div(double[] nums, double n) {
        assert !Double.isInfinite(n) : "Trying to divide "
                + Arrays.toString(nums) + " by  " + n; // Almost surely not what you want
        for (int i = 0; i < nums.length; i++)
            nums[i] /= n;
        return nums;
    }

    public static double[][] div(double[][] ds, long[] n) {
        for (int i = 0; i < ds.length; i++)
            div(ds[i], n[i]);
        return ds;
    }

    public static double[] div(double[] ds, long[] n) {
        for (int i = 0; i < ds.length; i++)
            ds[i] /= n[i];
        return ds;
    }

    public static String[] toString(long[] dom) {
        String[] result = new String[dom.length];
        for (int i = 0; i < dom.length; i++)
            result[i] = String.valueOf(dom[i]);
        return result;
    }

    public static String[] toString(int[] dom) {
        String[] result = new String[dom.length];
        for (int i = 0; i < dom.length; i++)
            result[i] = String.valueOf(dom[i]);
        return result;
    }

    public static String[] toString(Object[] ary) {
        String[] result = new String[ary.length];
        for (int i = 0; i < ary.length; i++) {
            Object o = ary[i];
            if (o != null && o.getClass().isArray()) {
                Class klazz = ary[i].getClass();
                result[i] = byte[].class.equals(klazz) ? Arrays
                        .toString((byte[]) o)
                        : short[].class.equals(klazz) ? Arrays
                                .toString((short[]) o)
                                : int[].class.equals(klazz) ? Arrays
                                        .toString((int[]) o)
                                        : long[].class.equals(klazz) ? Arrays
                                                .toString((long[]) o)
                                                : boolean[].class
                                                        .equals(klazz) ? Arrays
                                                        .toString((boolean[]) o)
                                                        : float[].class
                                                                .equals(klazz) ? Arrays
                                                                .toString((float[]) o)
                                                                : double[].class
                                                                        .equals(klazz) ? Arrays
                                                                        .toString((double[]) o)
                                                                        : Arrays.toString((Object[]) o);

            } else {
                result[i] = String.valueOf(o);
            }
        }
        return result;
    }
}

Related

  1. div(final int[] result, final int[] vector, final int[] scale)
  2. div(float[] items, int offset, int length, float divisor)
  3. div(float[] items, int offset, int length, float divisorX, float divisorY)
  4. div(float[] nums, float n)
  5. div(float[] nums, int n)
  6. div(float[] values, float divisor)
  7. div(int[]... vectors)
  8. div(String[] X)
  9. div_one(double[][] A)