Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove complex number classes/methods #6031

Merged
merged 8 commits into from Aug 1, 2018
@@ -40,7 +40,6 @@
import org.deeplearning4j.optimize.stepfunctions.NegativeDefaultStepFunction;
import org.junit.Test;
import org.nd4j.linalg.activations.Activation;
import org.nd4j.linalg.api.complex.IComplexNumber;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.api.ops.impl.transforms.Cos;
import org.nd4j.linalg.api.ops.impl.transforms.Sin;
@@ -520,11 +519,6 @@ public double epsThreshold() {
public Boolean apply(Number input) {
return Math.abs(input.doubleValue()) > 5.12;
}

@Override
public Boolean apply(IComplexNumber input) {
throw new UnsupportedOperationException();
}
});

int nExceeds512 = paramExceeds512.sum(Integer.MAX_VALUE).getInt(0);
@@ -723,11 +717,6 @@ public double epsThreshold() {
public Boolean apply(Number input) {
return Math.abs(input.doubleValue()) > 5.0;
}

@Override
public Boolean apply(IComplexNumber input) {
throw new UnsupportedOperationException();
}
});

int nExceeds5 = paramExceeds5.sum(Integer.MAX_VALUE).getInt(0);
@@ -231,7 +231,6 @@ public static Cloner newCloner() {
//cloner.registerFastCloner(INDArray.class, new INDArrayFastCloner()); //Does not work due to interface
IFastCloner fc = new INDArrayFastCloner();
cloner.registerFastCloner(Nd4j.getBackend().getNDArrayClass(), fc);
cloner.registerFastCloner(Nd4j.getBackend().getComplexNDArrayClass(), fc);

//Same thing with DataBuffers: off heap -> cloner library chokes on them, but need to know the concrete
// buffer classes, not just the interface
@@ -17,7 +17,6 @@
package org.nd4j.linalg.api.blas;

import org.nd4j.linalg.api.buffer.DataBuffer;
import org.nd4j.linalg.api.complex.IComplexNDArray;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.factory.NDArrayFactory;

@@ -46,9 +45,6 @@ public static int getBlasOffset(INDArray arr) {
* @return the blas stride
*/
public static int getBlasStride(INDArray arr) {
if (arr instanceof IComplexNDArray)
return arr.elementWiseStride() / 2;

return arr.elementWiseStride();
}

@@ -127,8 +123,6 @@ public static int getStrideForOrdering(INDArray arr) {
if (arr.ordering() == NDArrayFactory.FORTRAN) {
return getBlasStride(arr);
} else {
if (arr instanceof IComplexNDArray)
return arr.stride(1) / 2;
return arr.stride(1);
}
}
@@ -17,8 +17,6 @@
package org.nd4j.linalg.api.blas;

import org.nd4j.linalg.api.buffer.DataBuffer;
import org.nd4j.linalg.api.complex.IComplexNDArray;
import org.nd4j.linalg.api.complex.IComplexNumber;
import org.nd4j.linalg.api.ndarray.INDArray;

/**
@@ -54,30 +52,13 @@
/** Vector-vector dot product */
double dot(long N, DataBuffer dx, int offsetX, int incrX, DataBuffer y, int offsetY, int incrY);

/**
* computes a vector-vector dot product.
* @param n
* @param alpha
* @param X
* @param Y
* @return
*/
IComplexNumber dot(long N, IComplexNumber alpha, IComplexNDArray X, IComplexNDArray Y);

/**
* computes the Euclidean norm of a vector.
* @param arr
* @return
*/
double nrm2(INDArray arr);

/**
* computes the Euclidean norm of a vector.
* @param arr
* @return
*/
IComplexNumber nrm2(IComplexNDArray arr);

/**
* computes the sum of magnitudes of all vector elements or, for a complex vector x, the sum
* @param arr
@@ -88,14 +69,6 @@
/** sum of magnitudes of all elements */
double asum(long N, DataBuffer x, int offsetX, int incrX);

/**
* computes the sum of magnitudes
* of all vector elements or, for a complex vector x, the sum
* @param arr
* @return
*/
IComplexNumber asum(IComplexNDArray arr);

/**
* finds the element of a
* vector that has the largest absolute value.
@@ -118,36 +91,20 @@
/** Index of largest absolute value */
int iamax(long N, DataBuffer x, int offsetX, int incrX);

/**
* finds the element of a vector that has the largest absolute value.
* @param arr
* @return
*/
int iamax(IComplexNDArray arr);

/**
* finds the element of a vector that has the minimum absolute value.
* @param arr
* @return
*/
int iamin(INDArray arr);

/**
* finds the element of a vector that has the minimum absolute value.
* @param arr
* @return
*/
int iamin(IComplexNDArray arr);

/**
* swaps a vector with another vector.
* @param x
* @param y
*/
void swap(INDArray x, INDArray y);

void swap(IComplexNDArray x, IComplexNDArray y);

/**
* copy a vector to another vector.
* @param x
@@ -161,8 +118,6 @@
*/
void copy(long N, DataBuffer x, int offsetX, int incrX, DataBuffer y, int offsetY, int incrY);

void copy(IComplexNDArray x, IComplexNDArray y);

/**
* computes a vector-scalar product and adds the result to a vector.
* @param n
@@ -186,15 +141,6 @@
*/
void axpy(long N, double alpha, DataBuffer x, int offsetX, int incrX, DataBuffer y, int offsetY, int incrY);

/**
* computes a vector-scalar product and adds the result to a vector.
* @param n
* @param alpha
* @param x
* @param y
*/
void axpy(long N, IComplexNumber alpha, IComplexNDArray x, IComplexNDArray y);

/**
* computes parameters for a Givens rotation.
* @param a
@@ -214,16 +160,6 @@
*/
void rot(long N, INDArray X, INDArray Y, double c, double s);

/**
* performs rotation of points in the plane.
* @param N
* @param X
* @param Y
* @param c
* @param s
*/
void rot(long N, IComplexNDArray X, IComplexNDArray Y, IComplexNumber c, IComplexNumber s);

/**
* computes the modified parameters for a Givens rotation.
* @param d1
@@ -234,16 +170,6 @@
*/
void rotmg(INDArray d1, INDArray d2, INDArray b1, double b2, INDArray P);

/**
* computes the modified parameters for a Givens rotation.
* @param d1
* @param d2
* @param b1
* @param b2
* @param P
*/
void rotmg(IComplexNDArray d1, IComplexNDArray d2, IComplexNDArray b1, IComplexNumber b2, IComplexNDArray P);

/**
* computes a vector by a scalar product.
* @param N
@@ -252,14 +178,6 @@
*/
void scal(long N, double alpha, INDArray X);

/**
* computes a vector by a scalar product.
* @param N
* @param alpha
* @param X
*/
void scal(long N, IComplexNumber alpha, IComplexNDArray X);


/** Can we use the axpy and copy methods that take a DataBuffer instead of an INDArray with this backend? */
boolean supportsDataBufferL1Ops();
@@ -16,8 +16,6 @@

package org.nd4j.linalg.api.blas;

import org.nd4j.linalg.api.complex.IComplexNDArray;
import org.nd4j.linalg.api.complex.IComplexNumber;
import org.nd4j.linalg.api.ndarray.INDArray;

/**
@@ -56,23 +54,6 @@
*/
void gemv(char order, char transA, double alpha, INDArray A, INDArray X, double beta, INDArray Y);

/**
* gemv computes a matrix-vector product using a general matrix and performs one of the following matrix-vector operations:
y := alpha*a*x + beta*y for trans = 'N'or'n';
y := alpha*a'*x + beta*y for trans = 'T'or't';
y := alpha*conjg(a')*x + beta*y for trans = 'C'or'c'.
Here a is an m-by-n band matrix, x and y are vectors, alpha and beta are scalars.
* @param order
* @param transA
* @param alpha
* @param A
* @param X
* @param beta
* @param Y
*/
void gemv(char order, char transA, IComplexNumber alpha, IComplexNDArray A, IComplexNDArray X, IComplexNumber beta,
IComplexNDArray Y);

/**
* gbmv computes a matrix-vector product using a general band matrix and performs one of the following matrix-vector operations:
y := alpha*a*x + beta*y for trans = 'N'or'n';
@@ -91,25 +72,6 @@ void gemv(char order, char transA, IComplexNumber alpha, IComplexNDArray A, ICom
*/
void gbmv(char order, char TransA, int KL, int KU, double alpha, INDArray A, INDArray X, double beta, INDArray Y);

/**
* gbmv computes a matrix-vector product using a general band matrix and performs one of the following matrix-vector operations:
y := alpha*a*x + beta*y for trans = 'N'or'n';
y := alpha*a'*x + beta*y for trans = 'T'or't';
y := alpha*conjg(a')*x + beta*y for trans = 'C'or'c'.
Here a is an m-by-n band matrix with ku superdiagonals and kl subdiagonals, x and y are vectors, alpha and beta are scalars.
* @param order
* @param TransA
* @param KL
* @param KU
* @param alpha
* @param A
* @param X
* @param beta
* @param Y
*/
void gbmv(char order, char TransA, int KL, int KU, IComplexNumber alpha, IComplexNDArray A, IComplexNDArray X,
IComplexNumber beta, IComplexNDArray Y);


/**
* performs a rank-1 update of a general m-by-n matrix a:
@@ -122,88 +84,6 @@ void gbmv(char order, char TransA, int KL, int KU, IComplexNumber alpha, IComple
*/
void ger(char order, double alpha, INDArray X, INDArray Y, INDArray A);



/**
* performs a rank-1 update of a general m-by-n matrix a, without conjugation:
a := alpha*x*y' + a.
* @param order
* @param alpha
* @param X
* @param Y
* @param A
*/
void geru(char order, IComplexNumber alpha, IComplexNDArray X, IComplexNDArray Y, IComplexNDArray A);



/**
* performs a rank-1 update of a general m-by-n matrix a, without conjugation:
a := alpha*x*y' + a.
* @param order
* @param alpha
* @param X
* @param Y
* @param A
*/
void hbmv(char order, char Uplo, IComplexNumber alpha, IComplexNDArray A, IComplexNDArray X, IComplexNumber beta,
IComplexNDArray Y);

/**
* hemv computes a matrix-vector product using a Hermitian matrix:
y := alpha*a*x + beta*y.
Here a is an n-by-n Hermitian band matrix with k superdiagonals, x and y are n-element vectors, alpha and beta are scalars.
* @param order
* @param Uplo
* @param alpha
* @param A
* @param X
* @param beta
* @param Y
*/
void hemv(char order, char Uplo, IComplexNumber alpha, IComplexNDArray A, IComplexNDArray X, IComplexNumber beta,
IComplexNDArray Y);

/**
* ?her2 performs a rank-2 update of an n-by-n Hermitian matrix a:
a := alpha*x*conjg(y') + conjg(alpha)*y*conjg(x') + a.
* @param order
* @param Uplo
* @param alpha
* @param X
* @param Y
* @param A
*/
void her2(char order, char Uplo, IComplexNumber alpha, IComplexNDArray X, IComplexNDArray Y, IComplexNDArray A);

/**
* ?hpmv computes a matrix-vector product using a Hermitian packed matrix:
y := alpha*a*x + beta*y.
Here a is an n-by-n packed Hermitian matrix, x and y are n-element vectors, alpha and beta are scalars.
* @param order
* @param Uplo
* @param N
* @param alpha
* @param Ap
* @param X
* @param beta
* @param Y
*/
void hpmv(char order, char Uplo, int N, IComplexNumber alpha, IComplexNDArray Ap, IComplexNDArray X,
IComplexNumber beta, IComplexNDArray Y);

/**
* hpr2 performs a rank-2 update of an n-by-n packed Hermitian matrix a:
a := alpha*x*conjg(y') + conjg(alpha)*y*conjg(x') + a.
* @param order
* @param Uplo
* @param alpha
* @param X
* @param Y
* @param Ap
*/
void hpr2(char order, char Uplo, IComplexNumber alpha, IComplexNDArray X, IComplexNDArray Y, IComplexNDArray Ap);

/**
* sbmv computes a matrix-vector product using a symmetric band matrix:
y := alpha*a*x + beta*y.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.