本文整理了Java中org.nd4j.linalg.factory.Nd4j.createComplexNumber()
方法的一些代码示例,展示了Nd4j.createComplexNumber()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Nd4j.createComplexNumber()
方法的具体详情如下:
包路径:org.nd4j.linalg.factory.Nd4j
类名称:Nd4j
方法名:createComplexNumber
[英]Create double based on real and imaginary
[中]根据真实和想象创造双重形象
代码示例来源:origin: deeplearning4j/nd4j
/**
* Create complex number where the
* @param realComponents the real components for the complex
* @return the complex numbers based on the given real components
*/
public static IComplexNumber[] complexNumbersFor(float[] realComponents) {
IComplexNumber[] ret = new IComplexNumber[realComponents.length];
for (int i = 0; i < realComponents.length; i++)
ret[i] = Nd4j.createComplexNumber(realComponents[i], 0);
return ret;
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Create complex number where the
* @param realComponents the real components for the complex
* @return the complex numbers based on the given real components
*/
public static IComplexNumber[][] complexNumbersFor(double[][] realComponents) {
IComplexNumber[][] ret = new IComplexNumber[realComponents.length][realComponents[0].length];
for (int i = 0; i < realComponents.length; i++)
for (int j = 0; j < realComponents[i].length; j++)
ret[i][j] = Nd4j.createComplexNumber(realComponents[i][j], 0);
return ret;
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Create complex number where the
* @param realComponents the real components for the complex
* @return the complex numbers based on the given real components
*/
public static IComplexNumber[][] complexNumbersFor(float[][] realComponents) {
IComplexNumber[][] ret = new IComplexNumber[realComponents.length][realComponents[0].length];
for (int i = 0; i < realComponents.length; i++)
for (int j = 0; j < realComponents[i].length; j++)
ret[i][j] = Nd4j.createComplexNumber(realComponents[i][j], 0);
return ret;
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Create complex number where the
* @param realComponents the real components for the complex
* @return the complex numbers based on the given real components
*/
public static IComplexNumber[] complexNumbersFor(double[] realComponents) {
IComplexNumber[] ret = new IComplexNumber[realComponents.length];
for (int i = 0; i < realComponents.length; i++)
ret[i] = Nd4j.createComplexNumber(realComponents[i], 0);
return ret;
}
代码示例来源:origin: deeplearning4j/nd4j
public BaseCondition(Number value) {
this.value = value;
this.complexNumber = Nd4j.createComplexNumber(value, 0);
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public IComplexNumber zeroComplex() {
return Nd4j.createComplexNumber(Double.MAX_VALUE, 0);
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public IComplexNumber zeroComplex() {
return Nd4j.createComplexNumber(-Double.MAX_VALUE, 0);
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public IComplexNumber zeroComplex() {
return Nd4j.createComplexNumber(0, 0);
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public IComplexNumber zeroComplex() {
return Nd4j.createComplexNumber(0, 0);
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public IComplexNumber zeroComplex() {
return Nd4j.createComplexNumber(-Double.MAX_VALUE, 0);
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public IComplexNumber zeroComplex() {
return Nd4j.createComplexNumber(0.0, 0.0);
}
代码示例来源:origin: deeplearning4j/nd4j
/**
* Parse a complex number
* @param val the string to parse
* @return the parsed complex number
*/
public static IComplexNumber parseComplexNumber(String val) {
// real + " - " + (-imag) + "i"
String[] split = val.split(" ");
double real = Double.valueOf(split[0]);
char op = split[1].charAt(0);
//grab all but the i
double imag = Double.valueOf(split[2].substring(0, split[2].length() - 1));
return Nd4j.createComplexNumber(real, op == '-' ? -imag : imag);
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public IComplexNDArray putScalar(int[] indexes, IComplexNumber complexNumber) {
/* int ix = offset;
for (int i = 0; i < shape.length; i++) {
if(indexes[i] >= size(i))
throw new IllegalArgumentException("Illegal index " + i + " size at this index is " + size(i));
ix += indexes[i] * stride[i];
}
data.put(ix, complexNumber.asFloat().realComponent().doubleValue());
data.put(ix + 1, complexNumber.asFloat().imaginaryComponent().doubleValue());
return this;*/
throw new UnsupportedOperationException();
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public IComplexNDArray neqi(Number other) {
IComplexNDArray linear = linearView();
double otherVal = other.doubleValue();
for (int i = 0; i < linear.length(); i++) {
linear.putScalar(i, linear.getComplex(i).absoluteValue().doubleValue() != otherVal
? Nd4j.createComplexNumber(1, 0) : Nd4j.createComplexNumber(0, 0));
}
return this;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public IComplexNDArray gti(Number other) {
IComplexNDArray linear = linearView();
double val = other.doubleValue();
for (int i = 0; i < linear.length(); i++) {
linear.putScalar(i, linear.getComplex(i).absoluteValue().doubleValue() > val
? Nd4j.createComplexNumber(1, 0) : Nd4j.createComplexNumber(0, 0));
}
return this;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public IComplexNDArray lti(Number other) {
IComplexNDArray linear = linearView();
double val = other.doubleValue();
for (int i = 0; i < linear.length(); i++) {
linear.putScalar(i, linear.getComplex(i).absoluteValue().doubleValue() < val
? Nd4j.createComplexNumber(1, 0) : Nd4j.createComplexNumber(0, 0));
}
return this;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public IComplexNDArray eqi(Number other) {
IComplexNDArray linear = linearView();
double val = other.doubleValue();
for (int i = 0; i < linear.length(); i++) {
linear.putScalar(i, linear.getComplex(i).absoluteValue().doubleValue() == val
? Nd4j.createComplexNumber(1, 0) : Nd4j.createComplexNumber(0, 0));
}
return this;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public IComplexNDArray lti(INDArray other) {
if (other instanceof IComplexNDArray) {
IComplexNDArray linear = linearView();
IComplexNDArray otherLinear = (IComplexNDArray) other.linearView();
for (int i = 0; i < linear.length(); i++) {
linear.putScalar(i,
linear.getComplex(i).absoluteValue().doubleValue() < otherLinear.getComplex(i)
.absoluteValue().doubleValue() ? Nd4j.createComplexNumber(1, 0)
: Nd4j.createComplexNumber(0, 0));
}
} else {
IComplexNDArray linear = linearView();
INDArray otherLinear = other.linearView();
for (int i = 0; i < linear.length(); i++) {
linear.putScalar(i, linear.getComplex(i).absoluteValue().doubleValue() < otherLinear.getDouble(i)
? Nd4j.createComplexNumber(1, 0) : Nd4j.createComplexNumber(0, 0));
}
}
return this;
}
代码示例来源:origin: deeplearning4j/nd4j
@Override
public IComplexNDArray condi(Condition condition) {
IComplexNDArray linear = linearView();
for (int i = 0; i < length(); i++) {
boolean met = condition.apply(linear.getComplex(i));
IComplexNumber put = Nd4j.createComplexNumber(met ? 1 : 0, 0);
linear.putScalar(i, put);
}
return this;
}
代码示例来源:origin: deeplearning4j/nd4j
/**
*
* @param real
*/
protected void copyFromReal(INDArray real) {
if (!Shape.shapeEquals(shape(), real.shape()))
throw new IllegalStateException("Unable to copy array. Not the same shape");
INDArray linear = real.linearView();
IComplexNDArray thisLinear = linearView();
for (int i = 0; i < linear.length(); i++) {
thisLinear.putScalar(i, Nd4j.createComplexNumber(linear.getDouble(i), 0.0));
}
}
内容来源于网络,如有侵权,请联系作者删除!