org.nd4j.linalg.api.ops.random.impl.Linspace Maven / Gradle / Ivy
package org.nd4j.linalg.api.ops.random.impl;
import lombok.NonNull;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.api.ops.random.BaseRandomOp;
import org.nd4j.linalg.factory.Nd4j;
/**
* Linspace/arange Op implementation, generates from..to distribution within Z
*
* @author [email protected]
*/
public class Linspace extends BaseRandomOp {
private double from;
private double to;
public Linspace() {
// no-op
}
public Linspace(double from, double to, int length) {
this(Nd4j.createUninitialized(new int[] {1, length}, Nd4j.order()), from, to);
}
public Linspace(@NonNull INDArray z, double from, double to) {
this.from = from;
this.to = to;
init(null, null, z, z.lengthLong());
this.extraArgs = new Object[] {from, to};
}
@Override
public int opNum() {
return 4;
}
@Override
public String name() {
return "linspace";
}
}