Java Number Power Pow2(Object in, double val)

Here you can find the source of Pow2(Object in, double val)

Description

Pow

License

Open Source License

Declaration

public static final void Pow2(Object in, double val) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static final void Pow2(Object in, double val) {
        if (in == null)
            return;
        if (in instanceof double[]) {
            double[] inn = (double[]) in;
            for (int i = 0, s = inn.length; i < s; i++)
                inn[i] = (Sign(inn[i]) * Math.pow(inn[i], val));
        } else {/*from   w ww. jav  a2 s. c o  m*/
            for (int i = 0, s = ((Object[]) in).length; i < s; i++)
                Pow2(((Object[]) in)[i], val);
        }
    }

    public static final double Sign(double in) {
        return in < 0 ? -1.0 : 1.0;
    }

    public static final void Pow(double val, Object in) {
        if (in == null)
            return;
        if (in instanceof double[]) {
            double[] inn = (double[]) in;
            for (int i = 0, s = inn.length; i < s; i++)
                inn[i] = Math.pow(val, inn[i]);
        } else {
            for (int i = 0, s = ((Object[]) in).length; i < s; i++)
                Pow(((Object[]) in)[i], val);
        }
    }

    public static final void Pow(Object in, double val) {
        if (in == null)
            return;
        if (in instanceof double[]) {
            double[] inn = (double[]) in;
            for (int i = 0, s = inn.length; i < s; i++)
                inn[i] = Math.pow(inn[i], val);
        } else {
            for (int i = 0, s = ((Object[]) in).length; i < s; i++)
                Pow(((Object[]) in)[i], val);
        }
    }
}

Related

  1. pow2(final int n)
  2. pow2(final int x)
  3. pow2(int c)
  4. pow2(int i)
  5. pow2(long x)
  6. pow2ByteIndex(final int x)
  7. pow3_strict(final float a)
  8. pow4(double val)
  9. pow9(final double x)