/** * Check that two arrays are conformable. * * @param a operand * @param b operand * @return true if conformable */ public static boolean conformable(Array a, Array b) { return conformable(a.getShape(), b.getShape()); }
/** * Check that two arrays are conformable. * * @param a operand * @param b operand * @return true if conformable */ public static boolean conformable(Array a, Array b) { return conformable(a.getShape(), b.getShape()); }
/** * Check that two arrays are conformable. * * @param a operand * @param b operand * @return true if conformable */ public static boolean conformable(Array a, Array b) { return conformable(a.getShape(), b.getShape()); }
/** * Add elements of two arrays together as doubles, place sum in the result array. * The values from the arrays a and b are converted to double (if needed), * and the sum is converted to the type of result (if needed). * * @param result result array * @param a operand * @param b operand * @throws IllegalArgumentException a,b,and result are not conformable */ public static void addDouble(Array result, Array a, Array b) throws IllegalArgumentException { if (!conformable(result, a) || !conformable(a, b)) throw new IllegalArgumentException(); IndexIterator iterR = result.getIndexIterator(); IndexIterator iterA = a.getIndexIterator(); IndexIterator iterB = b.getIndexIterator(); while (iterA.hasNext()) iterR.setDoubleNext(iterA.getDoubleNext() + iterB.getDoubleNext()); }
/** * Add elements of two arrays together as doubles, place sum in the result array. * The values from the arrays a and b are converted to double (if needed), * and the sum is converted to the type of result (if needed). * * @param result result array * @param a operand * @param b operand * @throws IllegalArgumentException a,b,and result are not conformable */ public static void addDouble(Array result, Array a, Array b) throws IllegalArgumentException { if (!conformable(result, a) || !conformable(a, b)) throw new IllegalArgumentException(); IndexIterator iterR = result.getIndexIterator(); IndexIterator iterA = a.getIndexIterator(); IndexIterator iterB = b.getIndexIterator(); while (iterA.hasNext()) iterR.setDoubleNext(iterA.getDoubleNext() + iterB.getDoubleNext()); }
/** * copy array a to array result as shorts * The values from the array a are converted to short (if needed), * and then converted to the type of result (if needed). * * @param result copy to here * @param a copy from here * * @throws IllegalArgumentException a and result are not conformable */ public static void copyShort(Array result, Array a) throws IllegalArgumentException { if (!conformable(a, result)) throw new IllegalArgumentException("copy arrays are not conformable"); IndexIterator iterA = a.getIndexIterator(); IndexIterator iterR = result.getIndexIterator(); while (iterA.hasNext()) iterR.setShortNext(iterA.getShortNext()); }
/** * copy array a to array result as shorts * The values from the array a are converted to short (if needed), * and then converted to the type of result (if needed). * * @param result copy to here * @param a copy from here * * @throws IllegalArgumentException a and result are not conformable */ public static void copyShort(Array result, Array a) throws IllegalArgumentException { if (!conformable(a, result)) throw new IllegalArgumentException("copy arrays are not conformable"); IndexIterator iterA = a.getIndexIterator(); IndexIterator iterR = result.getIndexIterator(); while (iterA.hasNext()) iterR.setShortNext(iterA.getShortNext()); }
/** * copy array a to array result as integers * The values from the arrays a are converted to integer (if needed), * and then converted to the type of result (if needed). * * @param result copy to here * @param a copy from here * * @throws IllegalArgumentException a and result are not conformable */ public static void copyInt(Array result, Array a) throws IllegalArgumentException { if (!conformable(a, result)) throw new IllegalArgumentException("copy arrays are not conformable"); IndexIterator iterA = a.getIndexIterator(); IndexIterator iterR = result.getIndexIterator(); while (iterA.hasNext()) iterR.setIntNext(iterA.getIntNext()); }
/** * copy array a to array result as bytes * The array a and result must be type boolean * * @param result copy to here * @param a copy from here * * @throws IllegalArgumentException a and result are not conformable */ public static void copyBoolean(Array result, Array a) throws IllegalArgumentException { if (!conformable(a, result)) throw new IllegalArgumentException("copy arrays are not conformable"); IndexIterator iterA = a.getIndexIterator(); IndexIterator iterR = result.getIndexIterator(); while (iterA.hasNext()) iterR.setBooleanNext(iterA.getBooleanNext()); }
/** * copy array a to array result as bytes * The array a and result must be type boolean * * @param result copy to here * @param a copy from here * * @throws IllegalArgumentException a and result are not conformable */ public static void copyBoolean(Array result, Array a) throws IllegalArgumentException { if (!conformable(a, result)) throw new IllegalArgumentException("copy arrays are not conformable"); IndexIterator iterA = a.getIndexIterator(); IndexIterator iterR = result.getIndexIterator(); while (iterA.hasNext()) iterR.setBooleanNext(iterA.getBooleanNext()); }
/** * copy array a to array result as an Object * The array a and result must be type object * * @param result copy to here * @param a copy from here * * @throws IllegalArgumentException a and result are not conformable */ public static void copyObject(Array result, Array a) throws IllegalArgumentException { if (!conformable(a, result)) throw new IllegalArgumentException("copy arrays are not conformable"); IndexIterator iterA = a.getIndexIterator(); IndexIterator iterR = result.getIndexIterator(); while (iterA.hasNext()) iterR.setObjectNext(iterA.getObjectNext()); }
/** * copy array a to array result as bytes * The array a and result must be type boolean * * @param result copy to here * @param a copy from here * * @throws IllegalArgumentException a and result are not conformable */ public static void copyBoolean(Array result, Array a) throws IllegalArgumentException { if (!conformable(a, result)) throw new IllegalArgumentException("copy arrays are not conformable"); IndexIterator iterA = a.getIndexIterator(); IndexIterator iterR = result.getIndexIterator(); while (iterA.hasNext()) iterR.setBooleanNext(iterA.getBooleanNext()); }
/** * copy array a to array result as floats * The values from the arrays a are converted to float (if needed), * and then converted to the type of result (if needed). * * @param result copy to here * @param a copy from here * * @throws IllegalArgumentException a and result are not conformable */ public static void copyFloat(Array result, Array a) throws IllegalArgumentException { if (!conformable(a, result)) throw new IllegalArgumentException("copy arrays are not conformable"); IndexIterator iterA = a.getIndexIterator(); IndexIterator iterR = result.getIndexIterator(); while (iterA.hasNext()) iterR.setFloatNext(iterA.getFloatNext()); }
/** * copy array a to array result as bytes * The values from the array a are converted to byte (if needed), * and then converted to the type of result (if needed). * * @param result copy to here * @param a copy from here * * @throws IllegalArgumentException a and result are not conformable */ public static void copyByte(Array result, Array a) throws IllegalArgumentException { if (!conformable(a, result)) throw new IllegalArgumentException("copy arrays are not conformable"); IndexIterator iterA = a.getIndexIterator(); IndexIterator iterR = result.getIndexIterator(); while (iterA.hasNext()) iterR.setByteNext(iterA.getByteNext()); }
/** * copy array a to array result as doubles * The values from the arrays a are converted to double (if needed), * and then converted to the type of result (if needed). * * @param result copy to here * @param a copy from here * * @throws IllegalArgumentException a and result are not conformable */ public static void copyDouble(Array result, Array a) throws IllegalArgumentException { if (!conformable(a, result)) throw new IllegalArgumentException("copy arrays are not conformable"); IndexIterator iterA = a.getIndexIterator(); IndexIterator iterR = result.getIndexIterator(); while (iterA.hasNext()) iterR.setDoubleNext(iterA.getDoubleNext()); }
/** * copy array a to array result as longs * The values from the array a are converted to long (if needed), * and then converted to the type of result (if needed). * @param result copy to here * @param a copy from here * * * @throws IllegalArgumentException a and result are not conformable */ public static void copyLong(Array result, Array a) throws IllegalArgumentException { if (!conformable(a, result)) throw new IllegalArgumentException("copy arrays are not conformable"); IndexIterator iterA = a.getIndexIterator(); IndexIterator iterR = result.getIndexIterator(); while (iterA.hasNext()) iterR.setLongNext(iterA.getLongNext()); }
/** * copy array a to array result as integers * The values from the arrays a are converted to integer (if needed), * and then converted to the type of result (if needed). * * @param result copy to here * @param a copy from here * * @throws IllegalArgumentException a and result are not conformable */ public static void copyInt(Array result, Array a) throws IllegalArgumentException { if (!conformable(a, result)) throw new IllegalArgumentException("copy arrays are not conformable"); IndexIterator iterA = a.getIndexIterator(); IndexIterator iterR = result.getIndexIterator(); while (iterA.hasNext()) iterR.setIntNext(iterA.getIntNext()); }
/** * copy array a to array result as char * The values from the array a are converted to char (if needed), * and then converted to the type of result (if needed). * * @param result copy to here * @param a copy from here * * @throws IllegalArgumentException a and result are not conformable */ public static void copyChar(Array result, Array a) throws IllegalArgumentException { if (!conformable(a, result)) throw new IllegalArgumentException("copy arrays are not conformable"); IndexIterator iterA = a.getIndexIterator(); IndexIterator iterR = result.getIndexIterator(); while (iterA.hasNext()) iterR.setCharNext(iterA.getCharNext()); }
/** * copy array a to array result as an Object * The array a and result must be type object * * @param result copy to here * @param a copy from here * * @throws IllegalArgumentException a and result are not conformable */ public static void copyObject(Array result, Array a) throws IllegalArgumentException { if (!conformable(a, result)) throw new IllegalArgumentException("copy arrays are not conformable"); IndexIterator iterA = a.getIndexIterator(); IndexIterator iterR = result.getIndexIterator(); while (iterA.hasNext()) { iterR.setObjectNext( iterA.getObjectNext()); } }
/** * copy array a to array result as an Object * The array a and result must be type object * * @param result copy to here * @param a copy from here * * @throws IllegalArgumentException a and result are not conformable */ public static void copyObject(Array result, Array a) throws IllegalArgumentException { if (!conformable(a, result)) throw new IllegalArgumentException("copy arrays are not conformable"); IndexIterator iterA = a.getIndexIterator(); IndexIterator iterR = result.getIndexIterator(); while (iterA.hasNext()) iterR.setObjectNext(iterA.getObjectNext()); }