Example usage for org.apache.commons.math3.complex Complex pow

List of usage examples for org.apache.commons.math3.complex Complex pow

Introduction

In this page you can find the example usage for org.apache.commons.math3.complex Complex pow.

Prototype

public Complex pow(double x) 

Source Link

Document

Returns of value of this complex number raised to the power of x .

Usage

From source file:org.eclipse.dataset.FloatDataset.java

@Override
public FloatDataset ipower(final Object b) {
    Dataset bds = b instanceof Dataset ? (Dataset) b : DatasetFactory.createFromObject(b);
    if (bds.getSize() == 1) {
        final double vr = bds.getElementDoubleAbs(0);
        final IndexIterator it = getIterator();
        if (bds.isComplex()) {
            final double vi = bds.getElementDoubleAbs(1);
            if (vi == 0) {
                while (it.hasNext()) {
                    final double v = Math.pow(data[it.index], vr);
                    // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    //    data[it.index] = 0; // INT_USE
                    // } else { // INT_USE
                    data[it.index] = (float) v; // PRIM_TYPE_LONG // ADD_CAST
                    // } // INT_USE
                }//from  w  w  w  . ja va 2s  .com
            } else {
                final Complex zv = new Complex(vr, vi);
                while (it.hasNext()) {
                    Complex zd = new Complex(data[it.index], 0);
                    final double v = zd.pow(zv).getReal();
                    // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    //    data[it.index] = 0; // INT_USE
                    // } else { // INT_USE
                    data[it.index] = (float) v; // PRIM_TYPE_LONG // ADD_CAST
                    // } // INT_USE
                }
            }
        } else {// NAN_OMIT
            while (it.hasNext()) {
                final double v = Math.pow(data[it.index], vr);
                // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                //    data[it.index] = 0; // INT_USE
                // } else { // INT_USE
                data[it.index] = (float) v; // PRIM_TYPE_LONG // ADD_CAST
                // } // INT_USE
            }
        }
    } else {
        final BroadcastIterator it = BroadcastIterator.createIterator(this, bds);
        it.setOutputDouble(true);
        if (bds.isComplex()) {
            while (it.hasNext()) {
                final Complex zv = new Complex(it.bDouble, bds.getElementDoubleAbs(it.bIndex + 1));
                final double v = new Complex(it.aDouble, 0).pow(zv).getReal();
                // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                //    data[it.aIndex] = 0; // INT_USE
                // } else { // INT_USE
                data[it.aIndex] = (float) v; // PRIM_TYPE_LONG // ADD_CAST
                // } // INT_USE
            }
        } else {// NAN_OMIT
            while (it.hasNext()) {
                final double v = Math.pow(it.aDouble, it.bDouble);
                // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                //    data[it.aIndex] = 0; // INT_USE
                // } else { // INT_USE
                data[it.aIndex] = (float) v; // PRIM_TYPE_LONG // ADD_CAST
                // } // INT_USE
            }
        }
    }
    setDirty();
    return this;
}

From source file:org.eclipse.dataset.IntegerDataset.java

@Override
public IntegerDataset ipower(final Object b) {
    Dataset bds = b instanceof Dataset ? (Dataset) b : DatasetFactory.createFromObject(b);
    if (bds.getSize() == 1) {
        final double vr = bds.getElementDoubleAbs(0);
        final IndexIterator it = getIterator();
        if (bds.isComplex()) {
            final double vi = bds.getElementDoubleAbs(1);
            if (vi == 0) {
                while (it.hasNext()) {
                    final double v = Math.pow(data[it.index], vr);
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.index] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.index] = (int) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }//from  ww w. jav  a2s  .  c o  m
            } else {
                final Complex zv = new Complex(vr, vi);
                while (it.hasNext()) {
                    Complex zd = new Complex(data[it.index], 0);
                    final double v = zd.pow(zv).getReal();
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.index] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.index] = (int) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }
            }
        } else {// NAN_OMIT
            while (it.hasNext()) {
                final double v = Math.pow(data[it.index], vr);
                if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    data[it.index] = 0; // INT_USE
                } else { // INT_USE
                    data[it.index] = (int) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                } // INT_USE
            }
        }
    } else {
        final BroadcastIterator it = BroadcastIterator.createIterator(this, bds);
        it.setOutputDouble(true);
        if (bds.isComplex()) {
            while (it.hasNext()) {
                final Complex zv = new Complex(it.bDouble, bds.getElementDoubleAbs(it.bIndex + 1));
                final double v = new Complex(it.aDouble, 0).pow(zv).getReal();
                if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    data[it.aIndex] = 0; // INT_USE
                } else { // INT_USE
                    data[it.aIndex] = (int) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                } // INT_USE
            }
        } else {// NAN_OMIT
            while (it.hasNext()) {
                final double v = Math.pow(it.aDouble, it.bDouble);
                if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    data[it.aIndex] = 0; // INT_USE
                } else { // INT_USE
                    data[it.aIndex] = (int) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                } // INT_USE
            }
        }
    }
    setDirty();
    return this;
}

From source file:org.eclipse.dataset.LongDataset.java

@Override
public LongDataset ipower(final Object b) {
    Dataset bds = b instanceof Dataset ? (Dataset) b : DatasetFactory.createFromObject(b);
    if (bds.getSize() == 1) {
        final double vr = bds.getElementDoubleAbs(0);
        final IndexIterator it = getIterator();
        if (bds.isComplex()) {
            final double vi = bds.getElementDoubleAbs(1);
            if (vi == 0) {
                while (it.hasNext()) {
                    final double v = Math.pow(data[it.index], vr);
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.index] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.index] = (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }/*www .  ja va 2s .co m*/
            } else {
                final Complex zv = new Complex(vr, vi);
                while (it.hasNext()) {
                    Complex zd = new Complex(data[it.index], 0);
                    final double v = zd.pow(zv).getReal();
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.index] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.index] = (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }
            }
        } else {// NAN_OMIT
            while (it.hasNext()) {
                final double v = Math.pow(data[it.index], vr);
                if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    data[it.index] = 0; // INT_USE
                } else { // INT_USE
                    data[it.index] = (long) v; // PRIM_TYPE_LONG // ADD_CAST
                } // INT_USE
            }
        }
    } else {
        final BroadcastIterator it = BroadcastIterator.createIterator(this, bds);
        it.setOutputDouble(true);
        if (bds.isComplex()) {
            while (it.hasNext()) {
                final Complex zv = new Complex(it.bDouble, bds.getElementDoubleAbs(it.bIndex + 1));
                final double v = new Complex(it.aDouble, 0).pow(zv).getReal();
                if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    data[it.aIndex] = 0; // INT_USE
                } else { // INT_USE
                    data[it.aIndex] = (long) v; // PRIM_TYPE_LONG // ADD_CAST
                } // INT_USE
            }
        } else {// NAN_OMIT
            while (it.hasNext()) {
                final double v = Math.pow(it.aDouble, it.bDouble);
                if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    data[it.aIndex] = 0; // INT_USE
                } else { // INT_USE
                    data[it.aIndex] = (long) v; // PRIM_TYPE_LONG // ADD_CAST
                } // INT_USE
            }
        }
    }
    setDirty();
    return this;
}

From source file:org.eclipse.dataset.ShortDataset.java

@Override
public ShortDataset ipower(final Object b) {
    Dataset bds = b instanceof Dataset ? (Dataset) b : DatasetFactory.createFromObject(b);
    if (bds.getSize() == 1) {
        final double vr = bds.getElementDoubleAbs(0);
        final IndexIterator it = getIterator();
        if (bds.isComplex()) {
            final double vi = bds.getElementDoubleAbs(1);
            if (vi == 0) {
                while (it.hasNext()) {
                    final double v = Math.pow(data[it.index], vr);
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.index] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.index] = (short) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }/* w  ww .j av  a  2 s . c  o m*/
            } else {
                final Complex zv = new Complex(vr, vi);
                while (it.hasNext()) {
                    Complex zd = new Complex(data[it.index], 0);
                    final double v = zd.pow(zv).getReal();
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.index] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.index] = (short) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }
            }
        } else {// NAN_OMIT
            while (it.hasNext()) {
                final double v = Math.pow(data[it.index], vr);
                if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    data[it.index] = 0; // INT_USE
                } else { // INT_USE
                    data[it.index] = (short) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                } // INT_USE
            }
        }
    } else {
        final BroadcastIterator it = BroadcastIterator.createIterator(this, bds);
        it.setOutputDouble(true);
        if (bds.isComplex()) {
            while (it.hasNext()) {
                final Complex zv = new Complex(it.bDouble, bds.getElementDoubleAbs(it.bIndex + 1));
                final double v = new Complex(it.aDouble, 0).pow(zv).getReal();
                if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    data[it.aIndex] = 0; // INT_USE
                } else { // INT_USE
                    data[it.aIndex] = (short) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                } // INT_USE
            }
        } else {// NAN_OMIT
            while (it.hasNext()) {
                final double v = Math.pow(it.aDouble, it.bDouble);
                if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    data[it.aIndex] = 0; // INT_USE
                } else { // INT_USE
                    data[it.aIndex] = (short) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                } // INT_USE
            }
        }
    }
    setDirty();
    return this;
}

From source file:org.eclipse.january.dataset.ByteDataset.java

@Override
public ByteDataset ipower(final Object b) {
    setDirty();//from  www  .  j  a v a2s  . c  o  m
    Dataset bds = b instanceof Dataset ? (Dataset) b : DatasetFactory.createFromObject(b);
    if (bds.getSize() == 1) {
        final double vr = bds.getElementDoubleAbs(0);
        final IndexIterator it = getIterator();
        if (bds.isComplex()) {
            final double vi = bds.getElementDoubleAbs(1);
            if (vi == 0) {
                while (it.hasNext()) {
                    final double v = Math.pow(data[it.index], vr);
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.index] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.index] = (byte) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }
            } else {
                final Complex zv = new Complex(vr, vi);
                while (it.hasNext()) {
                    Complex zd = new Complex(data[it.index], 0);
                    final double v = zd.pow(zv).getReal();
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.index] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.index] = (byte) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }
            }
        } else {// NAN_OMIT
            while (it.hasNext()) {
                final double v = Math.pow(data[it.index], vr);
                if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    data[it.index] = 0; // INT_USE
                } else { // INT_USE
                    data[it.index] = (byte) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                } // INT_USE
            }
        }
    } else {
        final BroadcastIterator it = BroadcastIterator.createIterator(this, bds);
        it.setOutputDouble(true);
        if (bds.isComplex()) {
            while (it.hasNext()) {
                final Complex zv = new Complex(it.bDouble, bds.getElementDoubleAbs(it.bIndex + 1));
                final double v = new Complex(it.aDouble, 0).pow(zv).getReal();
                if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    data[it.aIndex] = 0; // INT_USE
                } else { // INT_USE
                    data[it.aIndex] = (byte) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                } // INT_USE
            }
        } else {// NAN_OMIT
            while (it.hasNext()) {
                final double v = Math.pow(it.aDouble, it.bDouble);
                if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    data[it.aIndex] = 0; // INT_USE
                } else { // INT_USE
                    data[it.aIndex] = (byte) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                } // INT_USE
            }
        }
    }
    return this;
}

From source file:org.eclipse.january.dataset.CompoundByteDataset.java

@Override
public CompoundByteDataset ipower(final Object b) {
    setDirty();//from ww  w .j  a  va2  s. c om
    Dataset bds = b instanceof Dataset ? (Dataset) b : DatasetFactory.createFromObject(b);
    final int is = bds.getElementsPerItem();
    if (bds.getSize() == 1) {
        final double vr = bds.getElementDoubleAbs(0);
        final IndexIterator it = getIterator();
        if (bds.isComplex()) {
            final double vi = bds.getElementDoubleAbs(1);
            if (vi == 0) {
                while (it.hasNext()) {
                    for (int i = 0; i < isize; i++) {
                        final double v = Math.pow(data[it.index + i], vr);
                        if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                            data[it.index + i] = 0; // INT_USE
                        } else { // INT_USE
                            data[it.index + i] = (byte) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                        } // INT_USE
                    }
                }
            } else {
                final Complex zv = new Complex(vr, vi);
                while (it.hasNext()) {
                    for (int i = 0; i < isize; i++) {
                        Complex zd = new Complex(data[it.index + i], 0);
                        final double v = zd.pow(zv).getReal();
                        if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                            data[it.index + i] = 0; // INT_USE
                        } else { // INT_USE
                            data[it.index + i] = (byte) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                        } // INT_USE
                    }
                }
            }
        } else if (is == 1) {
            while (it.hasNext()) {
                for (int i = 0; i < isize; i++) {
                    final double v = Math.pow(data[it.index + i], vr);
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.index + i] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.index + i] = (byte) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }
            }
        } else if (is == isize) {
            while (it.hasNext()) {
                for (int i = 0; i < isize; i++) {
                    final double v = Math.pow(data[it.index + i], bds.getElementDoubleAbs(i));
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.index + i] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.index + i] = (byte) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }
            }
        }
    } else {
        final BroadcastIterator it = BroadcastIterator.createIterator(this, bds);
        it.setOutputDouble(true);
        if (bds.isComplex()) {
            while (it.hasNext()) {
                final Complex zv = new Complex(it.bDouble, bds.getElementDoubleAbs(it.bIndex + 1));
                double v = new Complex(it.aDouble, 0).pow(zv).getReal();
                if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    data[it.aIndex] = 0; // INT_USE
                } else { // INT_USE
                    data[it.aIndex] = (byte) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                } // INT_USE
                for (int i = 1; i < isize; i++) {
                    v = new Complex(data[it.aIndex + i], 0).pow(zv).getReal();
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.aIndex + i] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.aIndex + i] = (byte) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }
            }
        } else {
            while (it.hasNext()) {
                double v = Math.pow(it.aDouble, it.bDouble);
                if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    data[it.aIndex] = 0; // INT_USE
                } else { // INT_USE
                    data[it.aIndex] = (byte) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                } // INT_USE
                for (int i = 1; i < isize; i++) {
                    v = Math.pow(data[it.aIndex + i], bds.getElementDoubleAbs(it.bIndex + i));
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.aIndex + i] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.aIndex + i] = (byte) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }
            }
        }
    }
    return this;
}

From source file:org.eclipse.january.dataset.CompoundDoubleDataset.java

@Override
public CompoundDoubleDataset ipower(final Object b) {
    setDirty();/*from  w w  w. jav a 2 s. c o m*/
    Dataset bds = b instanceof Dataset ? (Dataset) b : DatasetFactory.createFromObject(b);
    final int is = bds.getElementsPerItem();
    if (bds.getSize() == 1) {
        final double vr = bds.getElementDoubleAbs(0);
        final IndexIterator it = getIterator();
        if (bds.isComplex()) {
            final double vi = bds.getElementDoubleAbs(1);
            if (vi == 0) {
                while (it.hasNext()) {
                    for (int i = 0; i < isize; i++) {
                        final double v = Math.pow(data[it.index + i], vr);
                        // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        //    data[it.index + i] = 0; // INT_USE
                        // } else { // INT_USE
                        data[it.index + i] = v; // PRIM_TYPE_LONG // ADD_CAST
                        // } // INT_USE
                    }
                }
            } else {
                final Complex zv = new Complex(vr, vi);
                while (it.hasNext()) {
                    for (int i = 0; i < isize; i++) {
                        Complex zd = new Complex(data[it.index + i], 0);
                        final double v = zd.pow(zv).getReal();
                        // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        //    data[it.index + i] = 0; // INT_USE
                        // } else { // INT_USE
                        data[it.index + i] = v; // PRIM_TYPE_LONG // ADD_CAST
                        // } // INT_USE
                    }
                }
            }
        } else if (is == 1) {
            while (it.hasNext()) {
                for (int i = 0; i < isize; i++) {
                    final double v = Math.pow(data[it.index + i], vr);
                    // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    //    data[it.index + i] = 0; // INT_USE
                    // } else { // INT_USE
                    data[it.index + i] = v; // PRIM_TYPE_LONG // ADD_CAST
                    // } // INT_USE
                }
            }
        } else if (is == isize) {
            while (it.hasNext()) {
                for (int i = 0; i < isize; i++) {
                    final double v = Math.pow(data[it.index + i], bds.getElementDoubleAbs(i));
                    // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    //    data[it.index + i] = 0; // INT_USE
                    // } else { // INT_USE
                    data[it.index + i] = v; // PRIM_TYPE_LONG // ADD_CAST
                    // } // INT_USE
                }
            }
        }
    } else {
        final BroadcastIterator it = BroadcastIterator.createIterator(this, bds);
        it.setOutputDouble(true);
        if (bds.isComplex()) {
            while (it.hasNext()) {
                final Complex zv = new Complex(it.bDouble, bds.getElementDoubleAbs(it.bIndex + 1));
                double v = new Complex(it.aDouble, 0).pow(zv).getReal();
                // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                //    data[it.aIndex] = 0; // INT_USE
                // } else { // INT_USE
                data[it.aIndex] = v; // PRIM_TYPE_LONG // ADD_CAST
                // } // INT_USE
                for (int i = 1; i < isize; i++) {
                    v = new Complex(data[it.aIndex + i], 0).pow(zv).getReal();
                    // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    //    data[it.aIndex + i] = 0; // INT_USE
                    // } else { // INT_USE
                    data[it.aIndex + i] = v; // PRIM_TYPE_LONG // ADD_CAST
                    // } // INT_USE
                }
            }
        } else {
            while (it.hasNext()) {
                double v = Math.pow(it.aDouble, it.bDouble);
                // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                //    data[it.aIndex] = 0; // INT_USE
                // } else { // INT_USE
                data[it.aIndex] = v; // PRIM_TYPE_LONG // ADD_CAST
                // } // INT_USE
                for (int i = 1; i < isize; i++) {
                    v = Math.pow(data[it.aIndex + i], bds.getElementDoubleAbs(it.bIndex + i));
                    // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    //    data[it.aIndex + i] = 0; // INT_USE
                    // } else { // INT_USE
                    data[it.aIndex + i] = v; // PRIM_TYPE_LONG // ADD_CAST
                    // } // INT_USE
                }
            }
        }
    }
    return this;
}

From source file:org.eclipse.january.dataset.CompoundFloatDataset.java

@Override
public CompoundFloatDataset ipower(final Object b) {
    setDirty();//from   w  w  w  . j  ava 2s.c  om
    Dataset bds = b instanceof Dataset ? (Dataset) b : DatasetFactory.createFromObject(b);
    final int is = bds.getElementsPerItem();
    if (bds.getSize() == 1) {
        final double vr = bds.getElementDoubleAbs(0);
        final IndexIterator it = getIterator();
        if (bds.isComplex()) {
            final double vi = bds.getElementDoubleAbs(1);
            if (vi == 0) {
                while (it.hasNext()) {
                    for (int i = 0; i < isize; i++) {
                        final double v = Math.pow(data[it.index + i], vr);
                        // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        //    data[it.index + i] = 0; // INT_USE
                        // } else { // INT_USE
                        data[it.index + i] = (float) v; // PRIM_TYPE_LONG // ADD_CAST
                        // } // INT_USE
                    }
                }
            } else {
                final Complex zv = new Complex(vr, vi);
                while (it.hasNext()) {
                    for (int i = 0; i < isize; i++) {
                        Complex zd = new Complex(data[it.index + i], 0);
                        final double v = zd.pow(zv).getReal();
                        // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        //    data[it.index + i] = 0; // INT_USE
                        // } else { // INT_USE
                        data[it.index + i] = (float) v; // PRIM_TYPE_LONG // ADD_CAST
                        // } // INT_USE
                    }
                }
            }
        } else if (is == 1) {
            while (it.hasNext()) {
                for (int i = 0; i < isize; i++) {
                    final double v = Math.pow(data[it.index + i], vr);
                    // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    //    data[it.index + i] = 0; // INT_USE
                    // } else { // INT_USE
                    data[it.index + i] = (float) v; // PRIM_TYPE_LONG // ADD_CAST
                    // } // INT_USE
                }
            }
        } else if (is == isize) {
            while (it.hasNext()) {
                for (int i = 0; i < isize; i++) {
                    final double v = Math.pow(data[it.index + i], bds.getElementDoubleAbs(i));
                    // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    //    data[it.index + i] = 0; // INT_USE
                    // } else { // INT_USE
                    data[it.index + i] = (float) v; // PRIM_TYPE_LONG // ADD_CAST
                    // } // INT_USE
                }
            }
        }
    } else {
        final BroadcastIterator it = BroadcastIterator.createIterator(this, bds);
        it.setOutputDouble(true);
        if (bds.isComplex()) {
            while (it.hasNext()) {
                final Complex zv = new Complex(it.bDouble, bds.getElementDoubleAbs(it.bIndex + 1));
                double v = new Complex(it.aDouble, 0).pow(zv).getReal();
                // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                //    data[it.aIndex] = 0; // INT_USE
                // } else { // INT_USE
                data[it.aIndex] = (float) v; // PRIM_TYPE_LONG // ADD_CAST
                // } // INT_USE
                for (int i = 1; i < isize; i++) {
                    v = new Complex(data[it.aIndex + i], 0).pow(zv).getReal();
                    // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    //    data[it.aIndex + i] = 0; // INT_USE
                    // } else { // INT_USE
                    data[it.aIndex + i] = (float) v; // PRIM_TYPE_LONG // ADD_CAST
                    // } // INT_USE
                }
            }
        } else {
            while (it.hasNext()) {
                double v = Math.pow(it.aDouble, it.bDouble);
                // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                //    data[it.aIndex] = 0; // INT_USE
                // } else { // INT_USE
                data[it.aIndex] = (float) v; // PRIM_TYPE_LONG // ADD_CAST
                // } // INT_USE
                for (int i = 1; i < isize; i++) {
                    v = Math.pow(data[it.aIndex + i], bds.getElementDoubleAbs(it.bIndex + i));
                    // if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    //    data[it.aIndex + i] = 0; // INT_USE
                    // } else { // INT_USE
                    data[it.aIndex + i] = (float) v; // PRIM_TYPE_LONG // ADD_CAST
                    // } // INT_USE
                }
            }
        }
    }
    return this;
}

From source file:org.eclipse.january.dataset.CompoundIntegerDataset.java

@Override
public CompoundIntegerDataset ipower(final Object b) {
    setDirty();// w  w  w.  j  a  v a2s  . co m
    Dataset bds = b instanceof Dataset ? (Dataset) b : DatasetFactory.createFromObject(b);
    final int is = bds.getElementsPerItem();
    if (bds.getSize() == 1) {
        final double vr = bds.getElementDoubleAbs(0);
        final IndexIterator it = getIterator();
        if (bds.isComplex()) {
            final double vi = bds.getElementDoubleAbs(1);
            if (vi == 0) {
                while (it.hasNext()) {
                    for (int i = 0; i < isize; i++) {
                        final double v = Math.pow(data[it.index + i], vr);
                        if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                            data[it.index + i] = 0; // INT_USE
                        } else { // INT_USE
                            data[it.index + i] = (int) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                        } // INT_USE
                    }
                }
            } else {
                final Complex zv = new Complex(vr, vi);
                while (it.hasNext()) {
                    for (int i = 0; i < isize; i++) {
                        Complex zd = new Complex(data[it.index + i], 0);
                        final double v = zd.pow(zv).getReal();
                        if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                            data[it.index + i] = 0; // INT_USE
                        } else { // INT_USE
                            data[it.index + i] = (int) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                        } // INT_USE
                    }
                }
            }
        } else if (is == 1) {
            while (it.hasNext()) {
                for (int i = 0; i < isize; i++) {
                    final double v = Math.pow(data[it.index + i], vr);
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.index + i] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.index + i] = (int) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }
            }
        } else if (is == isize) {
            while (it.hasNext()) {
                for (int i = 0; i < isize; i++) {
                    final double v = Math.pow(data[it.index + i], bds.getElementDoubleAbs(i));
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.index + i] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.index + i] = (int) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }
            }
        }
    } else {
        final BroadcastIterator it = BroadcastIterator.createIterator(this, bds);
        it.setOutputDouble(true);
        if (bds.isComplex()) {
            while (it.hasNext()) {
                final Complex zv = new Complex(it.bDouble, bds.getElementDoubleAbs(it.bIndex + 1));
                double v = new Complex(it.aDouble, 0).pow(zv).getReal();
                if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    data[it.aIndex] = 0; // INT_USE
                } else { // INT_USE
                    data[it.aIndex] = (int) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                } // INT_USE
                for (int i = 1; i < isize; i++) {
                    v = new Complex(data[it.aIndex + i], 0).pow(zv).getReal();
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.aIndex + i] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.aIndex + i] = (int) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }
            }
        } else {
            while (it.hasNext()) {
                double v = Math.pow(it.aDouble, it.bDouble);
                if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    data[it.aIndex] = 0; // INT_USE
                } else { // INT_USE
                    data[it.aIndex] = (int) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                } // INT_USE
                for (int i = 1; i < isize; i++) {
                    v = Math.pow(data[it.aIndex + i], bds.getElementDoubleAbs(it.bIndex + i));
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.aIndex + i] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.aIndex + i] = (int) (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }
            }
        }
    }
    return this;
}

From source file:org.eclipse.january.dataset.CompoundLongDataset.java

@Override
public CompoundLongDataset ipower(final Object b) {
    setDirty();/*  w  ww  . j a va 2 s .  com*/
    Dataset bds = b instanceof Dataset ? (Dataset) b : DatasetFactory.createFromObject(b);
    final int is = bds.getElementsPerItem();
    if (bds.getSize() == 1) {
        final double vr = bds.getElementDoubleAbs(0);
        final IndexIterator it = getIterator();
        if (bds.isComplex()) {
            final double vi = bds.getElementDoubleAbs(1);
            if (vi == 0) {
                while (it.hasNext()) {
                    for (int i = 0; i < isize; i++) {
                        final double v = Math.pow(data[it.index + i], vr);
                        if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                            data[it.index + i] = 0; // INT_USE
                        } else { // INT_USE
                            data[it.index + i] = (long) v; // PRIM_TYPE_LONG // ADD_CAST
                        } // INT_USE
                    }
                }
            } else {
                final Complex zv = new Complex(vr, vi);
                while (it.hasNext()) {
                    for (int i = 0; i < isize; i++) {
                        Complex zd = new Complex(data[it.index + i], 0);
                        final double v = zd.pow(zv).getReal();
                        if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                            data[it.index + i] = 0; // INT_USE
                        } else { // INT_USE
                            data[it.index + i] = (long) v; // PRIM_TYPE_LONG // ADD_CAST
                        } // INT_USE
                    }
                }
            }
        } else if (is == 1) {
            while (it.hasNext()) {
                for (int i = 0; i < isize; i++) {
                    final double v = Math.pow(data[it.index + i], vr);
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.index + i] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.index + i] = (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }
            }
        } else if (is == isize) {
            while (it.hasNext()) {
                for (int i = 0; i < isize; i++) {
                    final double v = Math.pow(data[it.index + i], bds.getElementDoubleAbs(i));
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.index + i] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.index + i] = (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }
            }
        }
    } else {
        final BroadcastIterator it = BroadcastIterator.createIterator(this, bds);
        it.setOutputDouble(true);
        if (bds.isComplex()) {
            while (it.hasNext()) {
                final Complex zv = new Complex(it.bDouble, bds.getElementDoubleAbs(it.bIndex + 1));
                double v = new Complex(it.aDouble, 0).pow(zv).getReal();
                if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    data[it.aIndex] = 0; // INT_USE
                } else { // INT_USE
                    data[it.aIndex] = (long) v; // PRIM_TYPE_LONG // ADD_CAST
                } // INT_USE
                for (int i = 1; i < isize; i++) {
                    v = new Complex(data[it.aIndex + i], 0).pow(zv).getReal();
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.aIndex + i] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.aIndex + i] = (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }
            }
        } else {
            while (it.hasNext()) {
                double v = Math.pow(it.aDouble, it.bDouble);
                if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                    data[it.aIndex] = 0; // INT_USE
                } else { // INT_USE
                    data[it.aIndex] = (long) v; // PRIM_TYPE_LONG // ADD_CAST
                } // INT_USE
                for (int i = 1; i < isize; i++) {
                    v = Math.pow(data[it.aIndex + i], bds.getElementDoubleAbs(it.bIndex + i));
                    if (Double.isInfinite(v) || Double.isNaN(v)) { // INT_USE
                        data[it.aIndex + i] = 0; // INT_USE
                    } else { // INT_USE
                        data[it.aIndex + i] = (long) v; // PRIM_TYPE_LONG // ADD_CAST
                    } // INT_USE
                }
            }
        }
    }
    return this;
}