/** * Creates an ndarray with the specified data * * @param data the number of columns in the row vector * @return ndarray */ @Override public IComplexNDArray createComplex(double[] data) { assert data.length % 2 == 0 : "Length of data must be even. A complex ndarray is made up of pairs of real and imaginary components"; return createComplex(data, new int[] {1, data.length / 2}); }
/** * Create an ndrray with the specified shape * * @param data the data to use with tne ndarray * @param shape the shape of the ndarray * @param stride the stride for the ndarray * @return the created ndarray */ @Override public IComplexNDArray createComplex(float[] data, int[] shape, int[] stride) { return createComplex(data, shape, stride, 0); }
/** * Create an ndarray of ones * * @param shape the shape of the ndarray * @return an ndarray with ones filled in */ @Override public IComplexNDArray complexZeros(int[] shape) { IComplexNDArray ret = createComplex(shape); return ret; }
/** * Creates a complex ndarray with the specified shape * * @param shape the shape of the ndarray * @param stride the stride for the ndarray * @return the instance */ @Override public IComplexNDArray createComplex(int[] shape, int[] stride) { return createComplex(shape, stride, 0); }
/** * Create an ndrray with the specified shape * * @param data the data to use with tne ndarray * @param shape the shape of the ndarray * @param stride the stride for the ndarray * @return the created ndarray */ @Override public IComplexNDArray createComplex(double[] data, int[] shape, int[] stride) { //ensure shapes that wind up being scalar end up with the write shape if (shape.length == 1 && shape[0] == 0) { shape = new int[] {1, 1}; } return createComplex(data, shape, stride, 0); }
/** * Creates a complex ndarray with the specified shape * * @param shape the shape of the ndarray * @return the instance */ @Override public IComplexNDArray createComplex(int[] shape) { return createComplex(shape, Nd4j.getComplexStrides(shape), 0); }
/** * Create an ndarray of ones * * @param shape the shape of the ndarray * @return an ndarray with ones filled in */ @Override public IComplexNDArray complexOnes(int[] shape) { IComplexNDArray ret = createComplex(shape); ret.assign(1); return ret; }
/** * @param data * @param shape * @param offset * @return */ @Override public IComplexNDArray createComplex(double[] data, int[] shape, long offset) { return createComplex(Nd4j.createBuffer(data), shape, offset); }
/** * @param data * @param shape * @param offset * @param ordering * @return */ @Override public IComplexNDArray createComplex(double[] data, int[] shape, long offset, char ordering) { return createComplex(Nd4j.createBuffer(data), shape, offset, ordering); }
@Override public IComplexNDArray createComplex(int[] ints, int[] ints1, int[] stride, long offset) { return createComplex(Nd4j.createBuffer(ints), ints1, stride, offset); }
/** * Create an ndrray with the specified shape * * @param data the data to use with tne ndarray * @param shape the shape of the ndarray * @return the created ndarray */ @Override public IComplexNDArray createComplex(double[] data, int[] shape) { //ensure shapes that wind up being scalar end up with the write shape if (shape.length == 1 && shape[0] == 0) { shape = new int[] {1, 1}; } return createComplex(data, shape, Nd4j.getComplexStrides(shape), 0); }
/** * Create an ndrray with the specified shape * * @param data the data to use with tne ndarray * @param shape the shape of the ndarray * @return the created ndarray */ @Override public IComplexNDArray createComplex(float[] data, int[] shape) { //ensure shapes that wind up being scalar end up with the write shape if (shape.length == 1 && shape[0] == 0) { shape = new int[] {1, 1}; } return createComplex(data, shape, Nd4j.getComplexStrides(shape), 0); }
/** * Create a scalar nd array with the specified value and offset * * @param value the value of the scalar * @param offset the offset of the ndarray * @return the scalar nd array */ @Override public IComplexNDArray scalar(IComplexFloat value, long offset) { return createComplex(new float[] {value.realComponent(), value.imaginaryComponent()}, new int[] {1}, new int[] {1}, offset); }
/** * Create a scalar nd array with the specified value and offset * * @param value the value of the scalar * @param offset the offset of the ndarray * @return the scalar nd array */ @Override public IComplexNDArray scalar(IComplexDouble value, long offset) { return createComplex(new double[] {value.realComponent(), value.imaginaryComponent()}, new int[] {1}, new int[] {1}, offset); }
/** * Create a scalar nd array with the specified value and offset * * @param value the value of the scalar * @return the scalar nd array */ @Override public IComplexNDArray scalar(IComplexFloat value) { return createComplex(new float[] {value.realComponent(), value.imaginaryComponent()}, new int[] {1}, new int[] {1}, 0); }
@Override public IComplexNDArray createComplex(int[] shape, int[] complexStrides, long offset, char ordering) { //ensure shapes that wind up being scalar end up with the write shape if (shape.length == 1 && shape[0] == 0) { shape = new int[] {1, 1}; } return createComplex(Nd4j.createBuffer(ArrayUtil.prodLong(shape) * 2), shape, complexStrides, offset, ordering); }
/** * Create a scalar nd array with the specified value and offset * * @param value the value of the scalar * @return the scalar nd array */ @Override public IComplexNDArray scalar(IComplexDouble value) { return createComplex(new double[] {value.realComponent(), value.imaginaryComponent()}, new int[] {1}, new int[] {1}, 0); }
/** * Creates a complex ndarray with the specified shape * * @param data the data to use with the ndarray * @param shape the shape of the ndarray * @param stride the stride for the ndarray * @param offset the offset of the ndarray * @return the instance */ public IComplexNDArray createComplex(float[] data, int[] shape, int[] stride, long offset) { //ensure shapes that wind up being scalar end up with the write shape if (shape.length == 1 && shape[0] == 0) { shape = new int[] {1, 1}; } return createComplex(Nd4j.createBuffer(data), shape, stride, offset, Nd4j.order()); }
/** * Creates a complex ndarray with the specified shape * * @param shape the shape of the ndarray * @param stride the stride for the ndarray * @param offset the offset of the ndarray * @return the instance */ public IComplexNDArray createComplex(int[] shape, int[] stride, long offset) { if (Nd4j.dataType() == DataBuffer.Type.DOUBLE) return createComplex(new double[ArrayUtil.prod(shape) * 2], shape, stride, offset); if (Nd4j.dataType() == DataBuffer.Type.FLOAT || Nd4j.dataType() == DataBuffer.Type.HALF) return createComplex(new float[ArrayUtil.prod(shape) * 2], shape, stride, offset); throw new IllegalStateException("Illegal data opType " + Nd4j.dataType()); }
/** * Creates a complex ndarray with the specified shape * * @param shape the shape of the ndarray * @return the instance */ @Override public IComplexNDArray createComplex(int[] shape) { return createComplex(shape, Nd4j.getComplexStrides(shape), 0); }