Search in sources :

Example 1 with IComplexNDArray

use of org.nd4j.linalg.api.complex.IComplexNDArray in project nd4j by deeplearning4j.

the class BaseNDArrayFactory method complexValueOf.

/**
 * Creates an shape ndarray with the specified value
 *
 * @param shape the shape of the ndarray
 * @param value the value to assign
 * @return a complex ndarray of the specified size
 * and value
 */
@Override
public IComplexNDArray complexValueOf(int[] shape, double value) {
    IComplexNDArray ones = complexOnes(shape);
    ones.assign(Nd4j.scalar(value));
    return ones;
}
Also used : IComplexNDArray(org.nd4j.linalg.api.complex.IComplexNDArray)

Example 2 with IComplexNDArray

use of org.nd4j.linalg.api.complex.IComplexNDArray in project nd4j by deeplearning4j.

the class BaseNDArrayFactory method concat.

/**
 * concatenate ndarrays along a dimension
 *
 * @param dimension the dimension to concatenate along
 * @param toConcat  the ndarrays to concatenate
 * @return the concatenate ndarrays
 */
@Override
public IComplexNDArray concat(int dimension, IComplexNDArray... toConcat) {
    if (toConcat.length == 1)
        return toConcat[0];
    validateConcat(dimension, toConcat);
    int sumAlongDim = 0;
    for (int i = 0; i < toConcat.length; i++) sumAlongDim += toConcat[i].shape()[dimension];
    int[] outputShape = ArrayUtil.copy(toConcat[0].shape());
    outputShape[dimension] = sumAlongDim;
    IComplexNDArray ret = Nd4j.createComplex(outputShape);
    IComplexNDArray linear = ret.linearView();
    int count = 0;
    for (int i = 0; i < toConcat.length; i++) {
        IComplexNDArray flattened = toConcat[i].linearView();
        for (int j = 0; j < flattened.length(); j++) {
            linear.putScalar(count++, flattened.getComplex(j));
        }
    }
    return ret;
}
Also used : IComplexNDArray(org.nd4j.linalg.api.complex.IComplexNDArray)

Example 3 with IComplexNDArray

use of org.nd4j.linalg.api.complex.IComplexNDArray in project nd4j by deeplearning4j.

the class BaseNDArrayFactory method complexValueOf.

/**
 * Creates an shape ndarray with the specified value
 *
 * @param shape the shape of the ndarray
 * @param value the value to assign
 * @return a complex ndarray of the specified size
 * and value
 */
@Override
public IComplexNDArray complexValueOf(int[] shape, IComplexNumber value) {
    IComplexNDArray ones = complexOnes(shape);
    ones.assign(Nd4j.scalar(value));
    return ones;
}
Also used : IComplexNDArray(org.nd4j.linalg.api.complex.IComplexNDArray)

Example 4 with IComplexNDArray

use of org.nd4j.linalg.api.complex.IComplexNDArray in project nd4j by deeplearning4j.

the class BaseNDArrayFactory method complexValueOf.

/**
 * Creates an 1 x num ndarray with the specified value
 *
 * @param num   the number of columns
 * @param value the value to assign
 * @return a complex ndarray of the specified size
 * and value
 */
@Override
public IComplexNDArray complexValueOf(int num, IComplexNumber value) {
    IComplexNDArray ones = complexOnes(num);
    ones.assign(Nd4j.scalar(value));
    return ones;
}
Also used : IComplexNDArray(org.nd4j.linalg.api.complex.IComplexNDArray)

Example 5 with IComplexNDArray

use of org.nd4j.linalg.api.complex.IComplexNDArray in project nd4j by deeplearning4j.

the class BaseNDArrayFactory method complexOnes.

/**
 * 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;
}
Also used : IComplexNDArray(org.nd4j.linalg.api.complex.IComplexNDArray)

Aggregations

IComplexNDArray (org.nd4j.linalg.api.complex.IComplexNDArray)74 ND4JIllegalStateException (org.nd4j.linalg.exception.ND4JIllegalStateException)6 INDArray (org.nd4j.linalg.api.ndarray.INDArray)5 IComplexNumber (org.nd4j.linalg.api.complex.IComplexNumber)3 DecimalFormat (java.text.DecimalFormat)2 INDArrayIndex (org.nd4j.linalg.indexing.INDArrayIndex)2 AllocationPoint (org.nd4j.jita.allocator.impl.AllocationPoint)1 DataBuffer (org.nd4j.linalg.api.buffer.DataBuffer)1 IComplexDouble (org.nd4j.linalg.api.complex.IComplexDouble)1