_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q174000
DistributedVectorMessage.processMessage
test
@Override public void processMessage() { VectorAggregation aggregation = new VectorAggregation(rowIndex, (short) voidConfiguration.getNumberOfShards(), shardIndex, storage.getArray(key).getRow(rowIndex).dup()); aggregation.setOriginatorId(this.getOriginatorId()); tran...
java
{ "resource": "" }
q174001
BigDecimalMath.gamma
test
static public BigDecimal gamma(MathContext mc) { /* look it up if possible */ if (mc.getPrecision() < GAMMA.precision()) { return GAMMA.round(mc); } else { double eps = prec2err(0.577, mc.getPrecision()); /* Euler-Stieltjes as shown in Dilcher, Aequat Math 48 ...
java
{ "resource": "" }
q174002
BigDecimalMath.sqrt
test
static public BigDecimal sqrt(final BigDecimal x) { if (x.compareTo(BigDecimal.ZERO) < 0) { throw new ArithmeticException("negative argument " + x.toString() + " of square root"); } return root(2, x); }
java
{ "resource": "" }
q174003
BigDecimalMath.cbrt
test
static public BigDecimal cbrt(final BigDecimal x) { if (x.compareTo(BigDecimal.ZERO) < 0) { return root(3, x.negate()).negate(); } else { return root(3, x); } }
java
{ "resource": "" }
q174004
BigDecimalMath.root
test
static public BigDecimal root(final int n, final BigDecimal x) { if (x.compareTo(BigDecimal.ZERO) < 0) { throw new ArithmeticException("negative argument " + x.toString() + " of root"); } if (n <= 0) { throw new ArithmeticException("negative power " + n + " of root"); ...
java
{ "resource": "" }
q174005
BigDecimalMath.exp
test
static public BigDecimal exp(BigDecimal x) { /* To calculate the value if x is negative, use exp(-x) = 1/exp(x) */ if (x.compareTo(BigDecimal.ZERO) < 0) { final BigDecimal invx = exp(x.negate()); /* Relative error in inverse of invx is the same as the relative errror in ...
java
{ "resource": "" }
q174006
BigDecimalMath.exp
test
static public BigDecimal exp(final MathContext mc) { /* look it up if possible */ if (mc.getPrecision() < E.precision()) { return E.round(mc); } else { /* Instantiate a 1.0 with the requested pseudo-accuracy * and delegate the computation to the public method...
java
{ "resource": "" }
q174007
BigDecimalMath.pow
test
static public BigDecimal pow(final BigDecimal x, final BigDecimal y) { if (x.compareTo(BigDecimal.ZERO) < 0) { throw new ArithmeticException("Cannot power negative " + x.toString()); } else if (x.compareTo(BigDecimal.ZERO) == 0) { return BigDecimal.ZERO; } else { ...
java
{ "resource": "" }
q174008
BigDecimalMath.powRound
test
static public BigDecimal powRound(final BigDecimal x, final int n) { /* The relative error in the result is n times the relative error in the input. * The estimation is slightly optimistic due to the integer rounding of the logarithm. */ MathContext mc = new MathContext(x.precision() -...
java
{ "resource": "" }
q174009
BigDecimalMath.sin
test
static public BigDecimal sin(final BigDecimal x) { if (x.compareTo(BigDecimal.ZERO) < 0) { return sin(x.negate()).negate(); } else if (x.compareTo(BigDecimal.ZERO) == 0) { return BigDecimal.ZERO; } else { /* reduce modulo 2pi */ BigDec...
java
{ "resource": "" }
q174010
BigDecimalMath.tan
test
static public BigDecimal tan(final BigDecimal x) { if (x.compareTo(BigDecimal.ZERO) == 0) { return BigDecimal.ZERO; } else if (x.compareTo(BigDecimal.ZERO) < 0) { return tan(x.negate()).negate(); } else { /* reduce modulo pi */ BigDeci...
java
{ "resource": "" }
q174011
BigDecimalMath.cosh
test
static public BigDecimal cosh(final BigDecimal x) { if (x.compareTo(BigDecimal.ZERO) < 0) { return cos(x.negate()); } else if (x.compareTo(BigDecimal.ZERO) == 0) { return BigDecimal.ONE; } else { if (x.doubleValue() > 1.5) { /* cosh^2(x) = 1+ s...
java
{ "resource": "" }
q174012
BigDecimalMath.sinh
test
static public BigDecimal sinh(final BigDecimal x) { if (x.compareTo(BigDecimal.ZERO) < 0) { return sinh(x.negate()).negate(); } else if (x.compareTo(BigDecimal.ZERO) == 0) { return BigDecimal.ZERO; } else { if (x.doubleValue() > 2.4) { /* Move ...
java
{ "resource": "" }
q174013
BigDecimalMath.tanh
test
static public BigDecimal tanh(final BigDecimal x) { if (x.compareTo(BigDecimal.ZERO) < 0) { return tanh(x.negate()).negate(); } else if (x.compareTo(BigDecimal.ZERO) == 0) { return BigDecimal.ZERO; } else { BigDecimal xhighpr = scalePrec(x, 2); /* ...
java
{ "resource": "" }
q174014
BigDecimalMath.asinh
test
static public BigDecimal asinh(final BigDecimal x) { if (x.compareTo(BigDecimal.ZERO) == 0) { return BigDecimal.ZERO; } else { BigDecimal xhighpr = scalePrec(x, 2); /* arcsinh(x) = log(x+hypot(1,x)) */ BigDecimal logx = log(hypot(1, xhighpr).a...
java
{ "resource": "" }
q174015
BigDecimalMath.acosh
test
static public BigDecimal acosh(final BigDecimal x) { if (x.compareTo(BigDecimal.ONE) < 0) { throw new ArithmeticException("Out of range argument cosh " + x.toString()); } else if (x.compareTo(BigDecimal.ONE) == 0) { return BigDecimal.ZERO; } else { BigDecimal ...
java
{ "resource": "" }
q174016
BigDecimalMath.Gamma
test
static public BigDecimal Gamma(final BigDecimal x) { /* reduce to interval near 1.0 with the functional relation, Abramowitz-Stegun 6.1.33 */ if (x.compareTo(BigDecimal.ZERO) < 0) { return divideRound(Gamma(x.add(BigDecimal.ONE)), x); } else if (x.doubleValue() > 1.5) { ...
java
{ "resource": "" }
q174017
BigDecimalMath.broadhurstBBP
test
static protected BigDecimal broadhurstBBP(final int n, final int p, final int a[], MathContext mc) { /* Explore the actual magnitude of the result first with a quick estimate. */ double x = 0.0; for (int k = 1; k < 10; k++) { x += a[(k - 1) % 8] / Math.pow(2., p * (k + 1) /...
java
{ "resource": "" }
q174018
BigDecimalMath.scalePrec
test
static public BigDecimal scalePrec(final BigDecimal x, int d) { return x.setScale(d + x.scale()); }
java
{ "resource": "" }
q174019
BigDecimalMath.scalePrec
test
static public BigDecimal scalePrec(final BigDecimal x, final MathContext mc) { final int diffPr = mc.getPrecision() - x.precision(); if (diffPr > 0) { return scalePrec(x, diffPr); } else { return x; } }
java
{ "resource": "" }
q174020
BigDecimalMath.err2prec
test
static public int err2prec(BigDecimal x, BigDecimal xerr) { return err2prec(xerr.divide(x, MathContext.DECIMAL64).doubleValue()); }
java
{ "resource": "" }
q174021
SameDiff.putFunctionForId
test
public void putFunctionForId(String id, DifferentialFunction function) { if (functionInstancesById.containsKey(id)) { throw new ND4JIllegalStateException("Function by id already exists!"); } else if (function instanceof SDVariable) { throw new ND4JIllegalStateException("Function ...
java
{ "resource": "" }
q174022
SameDiff.getInputsForFunction
test
public String[] getInputsForFunction(DifferentialFunction function) { if (!incomingArgsReverse.containsKey(function.getOwnName())) throw new ND4JIllegalStateException("Illegal function instance id found " + function.getOwnName()); return incomingArgsReverse.get(function.getOwnName()); }
java
{ "resource": "" }
q174023
SameDiff.updateArrayForVarName
test
public void updateArrayForVarName(String varName, INDArray arr) { if (!variableNameToArr.containsKey(varName)) { throw new ND4JIllegalStateException("Array for " + varName + " does not exist. Please use putArrayForVertexId instead."); } variableNameToArr.put(varName, arr); r...
java
{ "resource": "" }
q174024
SameDiff.putShapeForVarName
test
public void putShapeForVarName(String varName, long[] shape) { if (shape == null) { throw new ND4JIllegalStateException("Shape must not be null!"); } if (variableNameToShape.containsKey(varName)) { throw new ND4JIllegalStateException("Shape for " + varName + " already ex...
java
{ "resource": "" }
q174025
SameDiff.associateArrayWithVariable
test
public void associateArrayWithVariable(INDArray arr, SDVariable variable) { if (variable == null) { throw new ND4JIllegalArgumentException("Variable must not be null!"); } if (arr == null) { throw new ND4JIllegalArgumentException("Array must not be null"); } ...
java
{ "resource": "" }
q174026
SameDiff.getPropertyForFunction
test
public <T> T getPropertyForFunction(DifferentialFunction functionInstance, String propertyName) { if (!propertiesForFunction.containsKey(functionInstance.getOwnName())) { return null; } else { val map = propertiesForFunction.get(functionInstance.getOwnName()); return ...
java
{ "resource": "" }
q174027
SameDiff.addPropertyForFunction
test
public void addPropertyForFunction(DifferentialFunction functionFor, String propertyName, INDArray property) { addPropertyForFunction(functionFor, propertyName, (Object) property); }
java
{ "resource": "" }
q174028
SameDiff.addOutgoingFor
test
public void addOutgoingFor(String[] varNames, DifferentialFunction function) { if (function.getOwnName() == null) throw new ND4JIllegalStateException("Instance id can not be null. Function not initialized properly"); if (outgoingArgsReverse.containsKey(function.getOwnName())) { ...
java
{ "resource": "" }
q174029
SameDiff.addArgsFor
test
public void addArgsFor(String[] variables, DifferentialFunction function) { if (function.getOwnName() == null) throw new ND4JIllegalStateException("Instance id can not be null. Function not initialized properly"); //double check if function contains placeholder args for (val varName...
java
{ "resource": "" }
q174030
SameDiff.hasArgs
test
public boolean hasArgs(DifferentialFunction function) { val vertexIdArgs = incomingArgsReverse.get(function.getOwnName()); if (vertexIdArgs != null) { val args = incomingArgs.get(vertexIdArgs); if (args != null) return true; } return false; }
java
{ "resource": "" }
q174031
SameDiff.eval
test
public INDArray[] eval(Map<String, INDArray> inputs) { SameDiff execPipeline = dup(); List<DifferentialFunction> opExecAction = execPipeline.exec().getRight(); if (opExecAction.isEmpty()) throw new IllegalStateException("No ops found to execute."); INDArray[] ret = new INDA...
java
{ "resource": "" }
q174032
SameDiff.one
test
public SDVariable one(String name, int[] shape) { return var(name, ArrayUtil.toLongArray(shape), new ConstantInitScheme('f', 1.0)); }
java
{ "resource": "" }
q174033
SameDiff.onesLike
test
public SDVariable onesLike(String name, SDVariable input) { return f().onesLike(name, input); }
java
{ "resource": "" }
q174034
SameDiff.zerosLike
test
public SDVariable zerosLike(String name, SDVariable input) { return f().zerosLike(name, input); }
java
{ "resource": "" }
q174035
SameDiff.removeArgFromFunction
test
public void removeArgFromFunction(String varName, DifferentialFunction function) { val args = function.args(); for (int i = 0; i < args.length; i++) { if (args[i].getVarName().equals(varName)) { /** * Since we are removing the variable reference ...
java
{ "resource": "" }
q174036
SameDiff.setGradientForVariableName
test
public void setGradientForVariableName(String variableName, SDVariable variable) { if (variable == null) { throw new ND4JIllegalStateException("Unable to set null gradient for variable name " + variableName); } gradients.put(variableName, variable); }
java
{ "resource": "" }
q174037
SameDiff.avgPooling3d
test
public SDVariable avgPooling3d(SDVariable[] inputs, Pooling3DConfig pooling3DConfig) { return avgPooling3d(null, inputs, pooling3DConfig); }
java
{ "resource": "" }
q174038
SameDiff.gru
test
public SDVariable gru(String baseName, GRUCellConfiguration configuration) { return new GRUCell(this, configuration).outputVariables(baseName)[0]; }
java
{ "resource": "" }
q174039
SameDiff.exec
test
public List<DifferentialFunction> exec(List<DifferentialFunction> ops) { for (int i = 0; i < ops.size(); i++) { Op op = (Op) ops.get(i); Nd4j.getExecutioner().exec(op); } return ops; }
java
{ "resource": "" }
q174040
SameDiff.whileStatement
test
public While whileStatement(SameDiffConditional sameDiffConditional, SameDiffFunctionDefinition conditionBody, SameDiff.SameDiffFunctionDefinition loopBody , SDVariable[] inputVars) { return While.builder() .inputVars(in...
java
{ "resource": "" }
q174041
SameDiff.exec
test
public Pair<Map<SDVariable, DifferentialFunction>, List<DifferentialFunction>> exec(String functionName) { if (debugMode) { return sameDiffFunctionInstances.get(functionName).enableDebugMode().exec(); } else return sameDiffFunctionInstances.get(functionName).exec(); }
java
{ "resource": "" }
q174042
SameDiff.exec
test
public List<DifferentialFunction> exec(String functionName, List<DifferentialFunction> cachedOps) { return sameDiffFunctionInstances.get(functionName).exec(cachedOps); }
java
{ "resource": "" }
q174043
SameDiff.execBackwardAndEndResult
test
public INDArray execBackwardAndEndResult() { List<DifferentialFunction> backwards = execBackwards().getRight(); DifferentialFunction df = backwards.get(backwards.size() - 1); if (df instanceof Op) { return ((Op) df).z(); } else if (df instanceof DynamicCustomOp) { ...
java
{ "resource": "" }
q174044
SameDiff.addAsPlaceHolder
test
public void addAsPlaceHolder(String varName) { placeHolderVarNames.add(varName); if (getVariable(varName) != null && getVariable(varName).getShape() != null) { placeHolderOriginalShapes.put(varName, getVariable(varName).getShape()); } }
java
{ "resource": "" }
q174045
CudaMemoryManager.allocate
test
@Override public Pointer allocate(long bytes, MemoryKind kind, boolean initialize) { AtomicAllocator allocator = AtomicAllocator.getInstance(); //log.info("Allocating {} bytes in {} memory...", bytes, kind); if (kind == MemoryKind.HOST) { Pointer ptr = NativeOpsHolder.getInstan...
java
{ "resource": "" }
q174046
DataTypeUtil.lengthForDtype
test
public static int lengthForDtype(DataBuffer.Type type) { switch (type) { case DOUBLE: return 8; case FLOAT: return 4; case INT: return 4; case HALF: return 2; case LONG: re...
java
{ "resource": "" }
q174047
DataTypeUtil.getDTypeForName
test
public static String getDTypeForName(DataBuffer.Type allocationMode) { switch (allocationMode) { case DOUBLE: return "double"; case FLOAT: return "float"; case INT: return "int"; case HALF: return "ha...
java
{ "resource": "" }
q174048
DataTypeUtil.getDtypeFromContext
test
public static DataBuffer.Type getDtypeFromContext() { try { lock.readLock().lock(); if (dtype == null) { lock.readLock().unlock(); lock.writeLock().lock(); if (dtype == null) dtype = getDtypeFromContext(Nd4jContext.get...
java
{ "resource": "" }
q174049
DefaultOpFactory.getOpNumByName
test
@Override public int getOpNumByName(String opName) { try { DifferentialFunction op = DifferentialFunctionClassHolder.getInstance().getInstance(opName); return op.opNum(); } catch (Exception e) { throw new RuntimeException("OpName failed: [" + opName + "]",e); ...
java
{ "resource": "" }
q174050
BasicWorkspaceManager.destroyAllWorkspacesForCurrentThread
test
@Override public void destroyAllWorkspacesForCurrentThread() { ensureThreadExistense(); List<MemoryWorkspace> workspaces = new ArrayList<>(); workspaces.addAll(backingMap.get().values()); for (MemoryWorkspace workspace : workspaces) { destroyWorkspace(workspace); ...
java
{ "resource": "" }
q174051
BasicWorkspaceManager.printAllocationStatisticsForCurrentThread
test
public synchronized void printAllocationStatisticsForCurrentThread() { ensureThreadExistense(); Map<String, MemoryWorkspace> map = backingMap.get(); log.info("Workspace statistics: ---------------------------------"); log.info("Number of workspaces in current thread: {}", map.size()); ...
java
{ "resource": "" }
q174052
BaseLevel2.trmv
test
@Override public void trmv(char order, char Uplo, char TransA, char Diag, INDArray A, INDArray X) { if (Nd4j.getExecutioner().getProfilingMode() == OpExecutioner.ProfilingMode.ALL) OpProfiler.getInstance().processBlasCall(false, A, X); // FIXME: int cast if (A.data().dataType()...
java
{ "resource": "" }
q174053
Nd4jKafkaConsumer.receive
test
public INDArray receive() { if (consumerTemplate == null) consumerTemplate = camelContext.createConsumerTemplate(); return consumerTemplate.receiveBody("direct:receive", INDArray.class); }
java
{ "resource": "" }
q174054
SameDiffOpExecutioner.exec
test
@Override public INDArray exec(Variance accumulation, boolean biasCorrected, int... dimension) { return processOp(accumulation).z(); }
java
{ "resource": "" }
q174055
SameDiffOpExecutioner.thresholdDecode
test
@Override public INDArray thresholdDecode(INDArray encoded, INDArray target) { return backendExecutioner.thresholdDecode(encoded,target); }
java
{ "resource": "" }
q174056
TFGraphMapper.getNodeName
test
public String getNodeName(String name) { //tensorflow adds colons to the end of variables representing input index, this strips those off String ret = name; if(ret.startsWith("^")) ret = ret.substring(1); if(ret.endsWith("/read")) { ret = ret.replace("/read",""); ...
java
{ "resource": "" }
q174057
NativeOpExecutioner.invoke
test
private void invoke(ScalarOp op, int[] dimension) { dimension = Shape.normalizeAxis(op.x().rank(), dimension); // do tad magic /** * Returns the {@link Shape#createShapeInformation(int[], int[], int, int, char)} * and the associated offsets for each {@link INDArray#tensorAlongD...
java
{ "resource": "" }
q174058
WorkspaceUtils.assertNoWorkspacesOpen
test
public static void assertNoWorkspacesOpen(String msg) throws ND4JWorkspaceException { if (Nd4j.getWorkspaceManager().anyWorkspaceActiveForCurrentThread()) { List<MemoryWorkspace> l = Nd4j.getWorkspaceManager().getAllWorkspacesForCurrentThread(); List<String> workspaces = new ArrayList<>(...
java
{ "resource": "" }
q174059
LossMixtureDensity.negativeLogLikelihood
test
private INDArray negativeLogLikelihood(INDArray labels, INDArray alpha, INDArray mu, INDArray sigma) { INDArray labelsMinusMu = labelsMinusMu(labels, mu); INDArray diffsquared = labelsMinusMu.mul(labelsMinusMu).sum(2); INDArray phitimesalphasum = phi(diffsquared, sigma).muli(alpha).sum(1); ...
java
{ "resource": "" }
q174060
AtomicState.requestTick
test
public void requestTick(long time, TimeUnit timeUnit) { long timeframeMs = TimeUnit.MILLISECONDS.convert(time, timeUnit); long currentTime = System.currentTimeMillis(); boolean isWaiting = false; // if we have Toe request queued - we' have to wait till it finishes. try { ...
java
{ "resource": "" }
q174061
AtomicState.tryRequestToe
test
public boolean tryRequestToe() { scheduleToe(); if (isToeWaiting.get() || getCurrentState() == AccessState.TOE) { //System.out.println("discarding TOE"); discardScheduledToe(); return false; } else { //System.out.println("requesting TOE"); ...
java
{ "resource": "" }
q174062
AtomicState.releaseToe
test
public void releaseToe() { if (getCurrentState() == AccessState.TOE) { if (1 > 0) { //if (toeThread.get() == Thread.currentThread().getId()) { if (toeRequests.decrementAndGet() == 0) { tickRequests.set(0); tackRequests.set(0); ...
java
{ "resource": "" }
q174063
AtomicState.getCurrentState
test
public AccessState getCurrentState() { if (AccessState.values()[currentState.get()] == AccessState.TOE) { return AccessState.TOE; } else { if (tickRequests.get() <= tackRequests.get()) { // TODO: looks like this piece of code should be locked :/ t...
java
{ "resource": "" }
q174064
EnvironmentUtils.buildEnvironment
test
public static Environment buildEnvironment() { Environment environment = new Environment(); environment.setJavaVersion(System.getProperty("java.specification.version")); environment.setNumCores(Runtime.getRuntime().availableProcessors()); environment.setAvailableMemory(Runtime.getRuntim...
java
{ "resource": "" }
q174065
VectorAggregation.processMessage
test
@Override public void processMessage() { if (clipboard.isTracking(this.originatorId, this.getTaskId())) { clipboard.pin(this); if (clipboard.isReady(this.originatorId, taskId)) { VoidAggregation aggregation = clipboard.unpin(this.originatorId, taskId); ...
java
{ "resource": "" }
q174066
BaseDataFetcher.initializeCurrFromList
test
protected void initializeCurrFromList(List<DataSet> examples) { if (examples.isEmpty()) log.warn("Warning: empty dataset from the fetcher"); INDArray inputs = createInputMatrix(examples.size()); INDArray labels = createOutputMatrix(examples.size()); for (int i = 0; i < exam...
java
{ "resource": "" }
q174067
AtomicAllocator.initHostCollectors
test
protected void initHostCollectors() { for (int i = 0; i < configuration.getNumberOfGcThreads(); i++) { ReferenceQueue<BaseDataBuffer> queue = new ReferenceQueue<>(); UnifiedGarbageCollectorThread uThread = new UnifiedGarbageCollectorThread(i, queue); // all GC threads shoul...
java
{ "resource": "" }
q174068
AtomicAllocator.getPointer
test
@Override public Pointer getPointer(DataBuffer buffer, CudaContext context) { return memoryHandler.getDevicePointer(buffer, context); }
java
{ "resource": "" }
q174069
AtomicAllocator.synchronizeHostData
test
@Override public void synchronizeHostData(DataBuffer buffer) { // we don't want non-committed ops left behind //Nd4j.getExecutioner().push(); // we don't synchronize constant buffers, since we assume they are always valid on host side if (buffer.isConstant()) { return; ...
java
{ "resource": "" }
q174070
AdaGradUpdater.applyUpdater
test
@Override public void applyUpdater(INDArray gradient, int iteration, int epoch) { if (historicalGradient == null) throw new IllegalStateException("Updater has not been initialized with view state"); double learningRate = config.getLearningRate(iteration, epoch); double epsilon =...
java
{ "resource": "" }
q174071
GridFlowController.synchronizeToHost
test
@Override public void synchronizeToHost(AllocationPoint point) { if (!point.isConstant() && point.isEnqueued()) { waitTillFinished(point); } super.synchronizeToHost(point); }
java
{ "resource": "" }
q174072
NDArrayIndex.create
test
public static INDArrayIndex[] create(INDArray index) { if (index.isMatrix()) { if (index.rows() > Integer.MAX_VALUE) throw new ND4JArraySizeException(); NDArrayIndex[] ret = new NDArrayIndex[(int) index.rows()]; for (int i = 0; i < index.rows(); i++) { ...
java
{ "resource": "" }
q174073
DifferentialFunction.propertiesForFunction
test
public Map<String,Object> propertiesForFunction() { val fields = DifferentialFunctionClassHolder.getInstance().getFieldsForFunction(this); Map<String,Object> ret = new LinkedHashMap<>(); for(val entry : fields.entrySet()) { try { ret.put(entry.getKey(),fields.get(ent...
java
{ "resource": "" }
q174074
DifferentialFunction.hasPlaceHolderInputs
test
public boolean hasPlaceHolderInputs() { val args = args(); for(val arg : args) if(sameDiff.hasPlaceHolderVariables(arg().getVarName())) return true; return false; }
java
{ "resource": "" }
q174075
DifferentialFunction.diff
test
public List<SDVariable> diff(List<SDVariable> i_v1) { List<SDVariable> vals = doDiff(i_v1); if(vals == null){ throw new IllegalStateException("Error executing diff operation: doDiff returned null for op: " + this.opName()); } val outputVars = args(); for(int i = 0; i...
java
{ "resource": "" }
q174076
NDArrayStrings.format
test
public String format(INDArray arr, boolean summarize) { this.scientificFormat = "0."; int addPrecision = this.precision; while (addPrecision > 0) { this.scientificFormat += "#"; addPrecision -= 1; } this.scientificFormat = this.scientificFormat + "E0"; ...
java
{ "resource": "" }
q174077
BaseGraphMapper.importGraph
test
@Override public SameDiff importGraph(GRAPH_TYPE tfGraph) { SameDiff diff = SameDiff.create(); ImportState<GRAPH_TYPE,TENSOR_TYPE> importState = new ImportState<>(); importState.setSameDiff(diff); importState.setGraph(tfGraph); val variablesForGraph = variablesForGraph(tfGra...
java
{ "resource": "" }
q174078
BaseLoader.convert
test
@Override public Blob convert(IComplexNDArray toConvert) throws IOException, SQLException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); Nd4j.writeComplex(toConvert, dos); byte[] bytes = bos.toByteArray(); Connec...
java
{ "resource": "" }
q174079
BaseLoader.loadComplex
test
@Override public IComplexNDArray loadComplex(Blob blob) throws SQLException, IOException { DataInputStream dis = new DataInputStream(blob.getBinaryStream()); return Nd4j.readComplex(dis); }
java
{ "resource": "" }
q174080
BaseLoader.save
test
@Override public void save(IComplexNDArray save, String id) throws IOException, SQLException { doSave(save, id); }
java
{ "resource": "" }
q174081
BaseComplexNDArray.copyRealTo
test
protected void copyRealTo(INDArray arr) { INDArray linear = arr.linearView(); IComplexNDArray thisLinear = linearView(); if (arr.isScalar()) arr.putScalar(0, getReal(0)); else for (int i = 0; i < linear.length(); i++) { arr.putScalar(i, thisLinear....
java
{ "resource": "" }
q174082
BaseComplexNDArray.copyImagTo
test
protected void copyImagTo(INDArray arr) { INDArray linear = arr.linearView(); IComplexNDArray thisLinear = linearView(); if (arr.isScalar()) arr.putScalar(0, getReal(0)); else for (int i = 0; i < linear.length(); i++) { arr.putScalar(i, thisLinear....
java
{ "resource": "" }
q174083
BaseComplexNDArray.epsi
test
@Override public IComplexNDArray epsi(Number other) { IComplexNDArray linear = linearView(); double otherVal = other.doubleValue(); for (int i = 0; i < linearView().length(); i++) { IComplexNumber n = linear.getComplex(i); double real = n.realComponent().doubleValue()...
java
{ "resource": "" }
q174084
BaseComplexNDArray.assign
test
@Override public IComplexNDArray assign(IComplexNDArray arr) { if (!arr.isScalar()) LinAlgExceptions.assertSameLength(this, arr); IComplexNDArray linear = linearView(); IComplexNDArray otherLinear = arr.linearView(); for (int i = 0; i < linear.length(); i++) { ...
java
{ "resource": "" }
q174085
BaseComplexNDArray.getRows
test
@Override public IComplexNDArray getRows(int[] rindices) { INDArray rows = Nd4j.create(rindices.length, columns()); for (int i = 0; i < rindices.length; i++) { rows.putRow(i, getRow(rindices[i])); } return (IComplexNDArray) rows; }
java
{ "resource": "" }
q174086
BaseComplexNDArray.putRow
test
@Override public IComplexNDArray putRow(long row, INDArray toPut) { return (IComplexNDArray) super.putRow(row, toPut); }
java
{ "resource": "" }
q174087
BaseComplexNDArray.putColumn
test
@Override public IComplexNDArray putColumn(int column, INDArray toPut) { assert toPut.isVector() && toPut.length() == rows() : "Illegal length for row " + toPut.length() + " should have been " + columns(); IComplexNDArray r = getColumn(column); if (toPut instanceof IC...
java
{ "resource": "" }
q174088
BaseComplexNDArray.sub
test
@Override public IComplexNDArray sub(INDArray other, INDArray result) { return dup().subi(other, result); }
java
{ "resource": "" }
q174089
BaseComplexNDArray.add
test
@Override public IComplexNDArray add(INDArray other, INDArray result) { return dup().addi(other, result); }
java
{ "resource": "" }
q174090
BaseComplexNDArray.subi
test
@Override public IComplexNDArray subi(INDArray other, INDArray result) { IComplexNDArray cOther = (IComplexNDArray) other; IComplexNDArray cResult = (IComplexNDArray) result; if (other.isScalar()) return subi(cOther.getComplex(0), result); if (result == this) ...
java
{ "resource": "" }
q174091
BaseComplexNDArray.addi
test
@Override public IComplexNDArray addi(INDArray other, INDArray result) { IComplexNDArray cOther = (IComplexNDArray) other; IComplexNDArray cResult = (IComplexNDArray) result; if (cOther.isScalar()) { return cResult.addi(cOther.getComplex(0), result); } if (isScal...
java
{ "resource": "" }
q174092
BaseComplexNDArray.assign
test
@Override public IComplexNDArray assign(Number value) { IComplexNDArray one = linearView(); for (int i = 0; i < one.length(); i++) one.putScalar(i, Nd4j.createDouble(value.doubleValue(), 0)); return this; }
java
{ "resource": "" }
q174093
BaseComplexNDArray.ravel
test
@Override public IComplexNDArray ravel() { if (length() >= Integer.MAX_VALUE) throw new IllegalArgumentException("length() can not be >= Integer.MAX_VALUE"); IComplexNDArray ret = Nd4j.createComplex((int) length(), ordering()); IComplexNDArray linear = linearView(); for ...
java
{ "resource": "" }
q174094
Eigen.eigenvalues
test
public static IComplexNDArray eigenvalues(INDArray A) { assert A.rows() == A.columns(); INDArray WR = Nd4j.create(A.rows(), A.rows()); INDArray WI = WR.dup(); Nd4j.getBlasWrapper().geev('N', 'N', A.dup(), WR, WI, dummy, dummy); return Nd4j.createComplex(WR, WI); }
java
{ "resource": "" }
q174095
Eigen.symmetricGeneralizedEigenvalues
test
public static INDArray symmetricGeneralizedEigenvalues(INDArray A, INDArray B) { assert A.rows() == A.columns(); assert B.rows() == B.columns(); INDArray W = Nd4j.create(A.rows()); A = InvertMatrix.invert(B, false).mmuli(A); Nd4j.getBlasWrapper().syev('V', 'L', A, W); re...
java
{ "resource": "" }
q174096
BaseLevel1.iamax
test
@Override public int iamax(IComplexNDArray arr) { if (arr.data().dataType() == DataBuffer.Type.DOUBLE) return izamax(arr.length(), arr, BlasBufferUtil.getBlasStride(arr)); return icamax(arr.length(), arr, BlasBufferUtil.getBlasStride(arr)); }
java
{ "resource": "" }
q174097
BaseLevel1.copy
test
@Override public void copy(IComplexNDArray x, IComplexNDArray y) { if (x.data().dataType() == DataBuffer.Type.DOUBLE) zcopy(x.length(), x, BlasBufferUtil.getBlasStride(x), y, BlasBufferUtil.getBlasStride(y)); else ccopy(x.length(), x, BlasBufferUtil.getBlasStride(x), y, BlasB...
java
{ "resource": "" }
q174098
BaseLevel1.scal
test
@Override public void scal(long N, IComplexNumber alpha, IComplexNDArray X) { if (X.data().dataType() == DataBuffer.Type.DOUBLE) zscal(N, alpha.asDouble(), X, BlasBufferUtil.getBlasStride(X)); else cscal(N, alpha.asFloat(), X, BlasBufferUtil.getBlasStride(X)); }
java
{ "resource": "" }
q174099
DistributedSgDotMessage.processMessage
test
@Override public void processMessage() { // this only picks up new training round //log.info("sI_{} Processing DistributedSgDotMessage taskId: {}", transport.getShardIndex(), getTaskId()); SkipGramRequestMessage sgrm = new SkipGramRequestMessage(w1, w2, rowsB, codes, negSamples, alpha, 119)...
java
{ "resource": "" }