Search in sources :

Example 66 with IComplexNDArray

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

the class Nd4j method createComplex.

/**
 * @param dim
 * @return
 */
public static IComplexNDArray createComplex(double[] dim) {
    IComplexNDArray ret = INSTANCE.createComplex(dim, new int[] { 1, dim.length / 2 });
    logCreationIfNecessary(ret);
    return ret;
}
Also used : IComplexNDArray(org.nd4j.linalg.api.complex.IComplexNDArray)

Example 67 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, double value) {
    IComplexNDArray ones = complexOnes(num);
    ones.assign(Nd4j.createDouble(value, 0.0));
    return ones;
}
Also used : IComplexNDArray(org.nd4j.linalg.api.complex.IComplexNDArray)

Example 68 with IComplexNDArray

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

the class BaseNDArrayFactory method complexFlatten.

@Override
public IComplexNDArray complexFlatten(List<IComplexNDArray> flatten) {
    int length = 0;
    for (IComplexNDArray m : flatten) length += m.length();
    IComplexNDArray ret = Nd4j.createComplex(length);
    int linearIndex = 0;
    for (IComplexNDArray d : flatten) {
        IComplexNDArray flattened = d.linearView();
        for (int i = 0; i < d.length(); i++) {
            ret.putScalar(linearIndex++, flattened.getComplex(i));
        }
    }
    return ret;
}
Also used : IComplexNDArray(org.nd4j.linalg.api.complex.IComplexNDArray)

Example 69 with IComplexNDArray

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

the class BaseNDArrayFactory method complexOnes.

/**
 * Creates an ndarray
 *
 * @param columns the number of columns in the row vector
 * @return ndarray
 */
@Override
public IComplexNDArray complexOnes(int columns) {
    IComplexNDArray base = createComplex(new int[] { 1, columns });
    base.assign(1);
    return base;
}
Also used : IComplexNDArray(org.nd4j.linalg.api.complex.IComplexNDArray)

Example 70 with IComplexNDArray

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

the class BaseNDArrayFactory method complexFlatten.

@Override
public IComplexNDArray complexFlatten(IComplexNDArray[] flatten) {
    int length = 0;
    for (IComplexNDArray m : flatten) length += m.length();
    IComplexNDArray ret = Nd4j.createComplex(length);
    int linearIndex = 0;
    for (IComplexNDArray d : flatten) {
        IComplexNDArray flattened = d.linearView();
        for (int i = 0; i < d.length(); i++) {
            ret.putScalar(linearIndex++, flattened.getComplex(i));
        }
    }
    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