Java Code Examples for org.nd4j.linalg.factory.Nd4j#order()

The following examples show how to use org.nd4j.linalg.factory.Nd4j#order() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Shape.java    From nd4j with Apache License 2.0 6 votes vote down vote up
private static INDArray toOffsetZeroCopyHelper(final INDArray arr, char order, boolean anyOrder) {
    if (arr instanceof IComplexNDArray) {
        /*
        if (arr.isRowVector()) {
            IComplexNDArray ret = Nd4j.createComplex(arr.shape(), order);
            for (int i = 0; i < ret.length(); i++)
                ret.putScalar(i, ((IComplexNDArray) arr).getComplex(i));
            return ret;
        }
        IComplexNDArray ret = Nd4j.createComplex(arr.shape(), order);
        for (int i = 0; i < ret.slices(); i++)
            ret.putSlice(i, arr.slice(i));
        return ret;
        */
        throw new UnsupportedOperationException();
    } else {
        //Use CopyOp:
        char outOrder = (anyOrder ? arr.ordering() : order);
        if (outOrder == 'a')
            outOrder = Nd4j.order();
        INDArray z = Nd4j.createUninitialized(arr.shape(), outOrder);
        z.assign(arr);
        return z;
    }
}
 
Example 2
Source File: CpuNDArrayFactory.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
@Override
public INDArray create(long[] data, long[] shape, long[] stride, DataType dataType, MemoryWorkspace workspace) {
    return new NDArray(Nd4j.createTypedBuffer(data, dataType), shape, stride,  Nd4j.order(), dataType);
}
 
Example 3
Source File: BaseNDArray.java    From nd4j with Apache License 2.0 4 votes vote down vote up
public BaseNDArray(long newRows, long newColumns) {
    this(newRows, newColumns, Nd4j.order());
}
 
Example 4
Source File: JCublasNDArrayFactory.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
@Override
public INDArray create(int[] data, long[] shape, long[] stride, DataType dataType, MemoryWorkspace workspace) {
    return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType), shape, stride,  Nd4j.order(), dataType);
}
 
Example 5
Source File: BaseNDArray.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
public BaseNDArray(double[] data, long[] shape, long[] stride, long offset) {
    this(data, shape, stride, offset, Nd4j.order());
}
 
Example 6
Source File: BaseNDArray.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
public BaseNDArray(List<INDArray> slices, long[] shape) {
    this(slices, shape, Nd4j.order());
}
 
Example 7
Source File: BaseComplexNDArray.java    From nd4j with Apache License 2.0 4 votes vote down vote up
/**
 * Construct a complex matrix from a realComponent matrix.
 */
public BaseComplexNDArray(INDArray m) {
    this(m, Nd4j.order());
}
 
Example 8
Source File: CpuNDArrayFactory.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
@Override
public INDArray create(double[] data, long[] shape, long[] stride, long offset) {
    return new NDArray(data, shape, stride, offset, Nd4j.order());
}
 
Example 9
Source File: BaseNDArray.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
public BaseNDArray(float[] data, long[] shape, long[] stride, long offset) {
    this(data, shape, stride, offset, Nd4j.order());
}
 
Example 10
Source File: JCublasNDArrayFactory.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
@Override
public INDArray create(double[] data, long[] shape, long[] stride, long offset) {
    return new JCublasNDArray(data, shape, stride, offset, Nd4j.order());
}
 
Example 11
Source File: CpuNDArrayFactory.java    From nd4j with Apache License 2.0 4 votes vote down vote up
@Override
public INDArray create(DataBuffer data, int[] shape, int[] stride, long offset) {
    return new NDArray(data, shape, stride, offset, Nd4j.order());
}
 
Example 12
Source File: JCublasNDArrayFactory.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
@Override
public INDArray create(boolean[] data, long[] shape, long[] stride, DataType dataType, MemoryWorkspace workspace) {
    return new JCublasNDArray(Nd4j.createTypedBuffer(data, dataType), shape, stride,  Nd4j.order(), dataType);
}
 
Example 13
Source File: JCublasNDArrayFactory.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
@Override
public INDArray create(DataBuffer data, long rows, long columns, int[] stride, long offset) {
    // FIXME: int cast
    return new JCublasNDArray(data, new long[] {rows, columns}, ArrayUtil.toLongArray(stride), Nd4j.order(), data.dataType());
}
 
Example 14
Source File: CpuNDArrayFactory.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
@Override
public INDArray create(float[] data, long[] shape, long[] stride, long offset) {
    return new NDArray(data, shape, stride, offset, Nd4j.order());
}
 
Example 15
Source File: BaseNDArray.java    From deeplearning4j with Apache License 2.0 2 votes vote down vote up
/**
 *
 * @param data
 * @param shape
 */
public BaseNDArray(DataBuffer data, int[] shape) {
    this(data, shape, Nd4j.getStrides(shape, Nd4j.order()), 0, Nd4j.order());
}
 
Example 16
Source File: BaseNDArray.java    From deeplearning4j with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new <i>n</i> times <i>m</i> <tt>DoubleMatrix</tt>.
 *
 * @param newRows    the number of rows (<i>n</i>) of the new matrix.
 * @param newColumns the number of columns (<i>m</i>) of the new matrix.
 */
public BaseNDArray(int newRows, int newColumns) {
    this(newRows, newColumns, Nd4j.order());
}
 
Example 17
Source File: BaseComplexNDArray.java    From nd4j with Apache License 2.0 2 votes vote down vote up
/**
 *
 * @param buffer
 * @param shape
 * @param offset
 */
public BaseComplexNDArray(DataBuffer buffer, int[] shape, long offset) {
    this(buffer, shape, Nd4j.getComplexStrides(shape), offset, Nd4j.order());
}
 
Example 18
Source File: BaseNDArray.java    From nd4j with Apache License 2.0 2 votes vote down vote up
/**
 *
 * @param buffer
 * @param shape
 * @param offset
 */
public BaseNDArray(DataBuffer buffer, int[] shape, long offset) {
    this(Nd4j.createBuffer(buffer, offset, ArrayUtil.prodLong(shape)), shape, Nd4j.getStrides(shape), offset,
            Nd4j.order());
}
 
Example 19
Source File: BaseComplexNDArray.java    From nd4j with Apache License 2.0 2 votes vote down vote up
/**
 *
 * @param data
 * @param shape
 * @param stride
 * @param offset
 */
public BaseComplexNDArray(IComplexNumber[] data, int[] shape, int[] stride, long offset) {
    this(data, shape, stride, offset, Nd4j.order());
}
 
Example 20
Source File: BaseNDArray.java    From nd4j with Apache License 2.0 2 votes vote down vote up
/**
 *
 * @param data
 * @param shape
 * @param offset
 */
public BaseNDArray(float[] data, int[] shape, long offset) {
    this(data, shape, offset, Nd4j.order());

}