INDArray.java javadoc (#215)

* javadoc

Signed-off-by: Robert Altena <Rob@Ra-ai.com>

* javadoc

Signed-off-by: Robert Altena <Rob@Ra-ai.com>
master
Robert Altena 2019-09-02 15:06:20 +09:00 committed by Alex Black
parent a35926c6e9
commit 6d04d30c94
5 changed files with 24 additions and 155 deletions

View File

@ -2836,156 +2836,78 @@ public abstract class BaseNDArray implements INDArray, Iterable {
return putScalar(i, element.getDouble(0));
}
/**
* In place addition of a column vector
*
* @param columnVector the column vector to add
* @return the result of the addition
*/
@Override
public INDArray diviColumnVector(INDArray columnVector) {
validateNumericalArray("diviColumnVector", false);
return doColumnWise(columnVector, 'd');
}
/**
* In place addition of a column vector
*
* @param columnVector the column vector to add
* @return the result of the addition
*/
@Override
public INDArray divColumnVector(INDArray columnVector) {
validateNumericalArray("divColumnVector", false);
return dup().diviColumnVector(columnVector);
}
/**
* In place addition of a column vector
*
* @param rowVector the row vector to add
* @return the result of the addition
*/
@Override
public INDArray diviRowVector(INDArray rowVector) {
validateNumericalArray("diviRowVector", false);
return doRowWise(rowVector, 'd');
}
/**
* In place addition of a column vector
*
* @param rowVector the row vector to add
* @return the result of the addition
*/
@Override
public INDArray divRowVector(INDArray rowVector) {
validateNumericalArray("divRowVector", false);
return dup().diviRowVector(rowVector);
}
/**
* In place addition of a column vector
*
* @param columnVector the column vector to add
* @return the result of the addition
*/
@Override
public INDArray muliColumnVector(INDArray columnVector) {
validateNumericalArray("muliColumnVector", false);
return doColumnWise(columnVector, 'm');
}
/**
* In place addition of a column vector
*
* @param columnVector the column vector to add
* @return the result of the addition
*/
@Override
public INDArray mulColumnVector(INDArray columnVector) {
validateNumericalArray("mulColumnVector", false);
return dup().muliColumnVector(columnVector);
}
/**
* In place addition of a column vector
*
* @param rowVector the row vector to add
* @return the result of the addition
*/
@Override
public INDArray muliRowVector(INDArray rowVector) {
validateNumericalArray("muliRowVector", false);
return doRowWise(rowVector, 'm');
}
/**
* In place addition of a column vector
*
* @param rowVector the row vector to add
* @return the result of the addition
*/
@Override
public INDArray mulRowVector(INDArray rowVector) {
validateNumericalArray("mulRowVector", false);
return dup().muliRowVector(rowVector);
}
/**
* In place addition of a column vector
*
* @param columnVector the column vector to add
* @return the result of the addition
*/
@Override
public INDArray subiColumnVector(INDArray columnVector) {
validateNumericalArray("subiColumnVector", false);
return doColumnWise(columnVector, 's');
}
/**
* In place addition of a column vector
*
* @param columnVector the column vector to add
* @return the result of the addition
*/
@Override
public INDArray subColumnVector(INDArray columnVector) {
validateNumericalArray("subColumnVector", false);
return dup().subiColumnVector(columnVector);
}
/**
* In place addition of a column vector
*
* @param rowVector the row vector to add
* @return the result of the addition
*/
@Override
public INDArray subiRowVector(INDArray rowVector) {
validateNumericalArray("subiRowVector", false);
return doRowWise(rowVector, 's');
}
/**
* In place addition of a column vector
*
* @param rowVector the row vector to add
* @return the result of the addition
*/
@Override
public INDArray subRowVector(INDArray rowVector) {
validateNumericalArray("subRowVector", false);
return dup().subiRowVector(rowVector);
}
/**
* In place addition of a column vector
*
* @param columnVector the column vector to add
* @return the result of the addition
*/
@Override
public INDArray addiColumnVector(INDArray columnVector) {
validateNumericalArray("addiColumnVector", false);
@ -2997,24 +2919,12 @@ public abstract class BaseNDArray implements INDArray, Iterable {
return doColumnWise(columnVector, 'p');
}
/**
* In place addition of a column vector
*
* @param columnVector the column vector to add
* @return the result of the addition
*/
@Override
public INDArray addColumnVector(INDArray columnVector) {
validateNumericalArray("addColumnVector", false);
return dup().addiColumnVector(columnVector);
}
/**
* In place addition of a column vector
*
* @param rowVector the row vector to add
* @return the result of the addition
*/
@Override
public INDArray addiRowVector(INDArray rowVector) {
validateNumericalArray("addiRowVector", false);
@ -3027,47 +2937,22 @@ public abstract class BaseNDArray implements INDArray, Iterable {
return doRowWise(rowVector, 'p');
}
/**
* In place addition of a column vector
*
* @param rowVector the row vector to add
* @return the result of the addition
*/
@Override
public INDArray addRowVector(INDArray rowVector) {
validateNumericalArray("addRowVector", false);
return dup().addiRowVector(rowVector);
}
/**
* Perform a copy matrix multiplication
*
* @param other the other matrix to perform matrix multiply with
* @return the result of the matrix multiplication
*/
@Override
public INDArray mmul(INDArray other, INDArray result, MMulTranspose mMulTranspose) {
return mMulTranspose.exec(this, other, result);
}
/**
* Perform a copy matrix multiplication
*
* @param other the other matrix to perform matrix multiply with
* @return the result of the matrix multiplication
*/
@Override
public INDArray mmul(INDArray other, MMulTranspose mMulTranspose) {
return mMulTranspose.exec(this, other, null);
}
/**
* Perform a copy matrix multiplication
*
* @param other the other matrix to perform matrix multiply with
* @return the result of the matrix multiplication
*/
@Override
public INDArray mmul(INDArray other) {
Preconditions.checkState(this.dataType() == other.dataType(), "Matrix multiplication: arrays must have same dtype: %s vs. %s", this.dataType(), other.dataType());
@ -3105,8 +2990,6 @@ public abstract class BaseNDArray implements INDArray, Iterable {
if(!isVectorOrScalar()) {
throw new ND4JIllegalStateException("Unable to create a 1d array from a non vector! Shape: " + Shape.shapeToStringShort(this));
}
return dup().data().asDouble();
}
@ -3115,7 +2998,6 @@ public abstract class BaseNDArray implements INDArray, Iterable {
if(!isVectorOrScalar()) {
throw new ND4JIllegalStateException("Unable to create a 1d array from a non vector! Shape: " + Shape.shapeToStringShort(this));
}
return dup().data().asFloat();
}

View File

@ -1123,14 +1123,6 @@ public class BaseSparseNDArrayCOO extends BaseSparseNDArray {
return null;
}
/**
* Perform an copy matrix multiplication
*
* @param other the other matrix to perform matrix multiply with
* @param result the result ndarray
* @param mMulTranspose the transpose status of each array
* @return the result of the matrix multiplication
*/
@Override
public INDArray mmul(INDArray other, INDArray result, MMulTranspose mMulTranspose) {
return null;

View File

@ -1,4 +1,4 @@
/*******************************************************************************
/* *****************************************************************************
* Copyright (c) 2015-2018 Skymind, Inc.
*
* This program and the accompanying materials are made available under the
@ -16,9 +16,6 @@
package org.nd4j.linalg.api.ndarray;
import static org.nd4j.linalg.factory.Nd4j.compressDebug;
import static org.nd4j.linalg.factory.Nd4j.preventUnpack;
import com.google.flatbuffers.FlatBufferBuilder;
import lombok.NonNull;
import org.nd4j.linalg.api.blas.params.MMulTranspose;
@ -52,6 +49,7 @@ public interface INDArray extends Serializable, AutoCloseable {
*/
DataBuffer shapeInfoDataBuffer();
// TODO: Unused untested method.
/**
* Sparse info
* @return Sparse info.
@ -110,12 +108,13 @@ public interface INDArray extends Serializable, AutoCloseable {
*/
int elementWiseStride();
// TODO: Unused untested method.
/**
* Get a double at the given linear offset unsafe, without checks.
* @param offset the offset to get at
* @return double value at offset
*/
double getDoubleUnsafe(long offset); //TODO: consider deleting.
double getDoubleUnsafe(long offset);
/**
* Get string value at given index.
@ -124,13 +123,14 @@ public interface INDArray extends Serializable, AutoCloseable {
*/
String getString(long index);
// TODO: Unused untested method.
/**
* Insert a scalar at the given linear offset
* @param offset the offset to insert at
* @param value the value to insert
* @return this
*/
INDArray putScalarUnsafe(long offset, double value); //TODO: consider deleting.
INDArray putScalarUnsafe(long offset, double value);
/**
* Returns the number of possible vectors for a given dimension
@ -190,6 +190,7 @@ public interface INDArray extends Serializable, AutoCloseable {
*/
INDArray assign(INDArray arr);
// TODO: Unused untested method.
/**
* Assign all elements from given ndarray that are matching given condition,
* ndarray to this ndarray
@ -553,7 +554,7 @@ public interface INDArray extends Serializable, AutoCloseable {
*
* @param n the number to subtract by
* @param result the result ndarray
* @return
* @return the result ndarray
*/
INDArray rsub(Number n, INDArray result);
@ -1041,7 +1042,6 @@ public interface INDArray extends Serializable, AutoCloseable {
*/
INDArray divRowVector(INDArray rowVector);
/**
* In place reverse divison of a column vector
*
@ -1066,6 +1066,7 @@ public interface INDArray extends Serializable, AutoCloseable {
*/
INDArray rdiviRowVector(INDArray rowVector);
//TODO: unused / untested method.
/**
* Reverse division of a column vector (copy)
*
@ -1074,7 +1075,6 @@ public interface INDArray extends Serializable, AutoCloseable {
*/
INDArray rdivRowVector(INDArray rowVector);
/**
* In place multiplication of a column vector
*
@ -1107,7 +1107,6 @@ public interface INDArray extends Serializable, AutoCloseable {
*/
INDArray mulRowVector(INDArray rowVector);
/**
* In place reverse subtraction of a column vector
*
@ -1132,6 +1131,7 @@ public interface INDArray extends Serializable, AutoCloseable {
*/
INDArray rsubiRowVector(INDArray rowVector);
//TODO: unused / untested method.
/**
* Reverse subtraction of a row vector (copy)
*
@ -1180,7 +1180,6 @@ public interface INDArray extends Serializable, AutoCloseable {
*/
INDArray addiColumnVector(INDArray columnVector);
/**
* In place assignment of a column vector
*
@ -1221,6 +1220,12 @@ public interface INDArray extends Serializable, AutoCloseable {
*/
INDArray addRowVector(INDArray rowVector);
/**
* Perform a copy matrix multiplication
*
* @param other the other matrix to perform matrix multiply with
* @return the result of the matrix multiplication
*/
INDArray mmul(INDArray other, MMulTranspose mMulTranspose);
/**
@ -1231,8 +1236,6 @@ public interface INDArray extends Serializable, AutoCloseable {
*/
INDArray mmul(INDArray other);
/**
* Convert this ndarray to a 2d double matrix.
* Note that THIS SHOULD NOT BE USED FOR SPEED.
@ -1283,6 +1286,14 @@ public interface INDArray extends Serializable, AutoCloseable {
*/
int[] toIntVector();
/**
* Convert this ndarray to a 1d long matrix.
* Note that THIS SHOULD NOT BE USED FOR SPEED.
* This is mainly used for integrations with other libraries.
* Due to nd4j's off heap nature, moving data on heap is very expensive
* and should not be used if possible.
* @return a copy of this array as a 1d long array
*/
long[] toLongVector();
/**

View File

@ -68,14 +68,6 @@ public class JcusparseNDArrayCSR extends BaseSparseNDArrayCSR {
return null;
}
/**
* Perform an copy matrix multiplication
*
* @param other the other matrix to perform matrix multiply with
* @param result the result ndarray
* @param mMulTranspose the transpose status of each array
* @return the result of the matrix multiplication
*/
@Override
public INDArray mmul(INDArray other, INDArray result, MMulTranspose mMulTranspose) {
return null;

View File

@ -79,14 +79,6 @@ public class SparseNDArrayCSR extends BaseSparseNDArrayCSR {
return null;
}
/**
* Perform an copy matrix multiplication
*
* @param other the other matrix to perform matrix multiply with
* @param result the result ndarray
* @param mMulTranspose the transpose status of each array
* @return the result of the matrix multiplication
*/
@Override
public INDArray mmul(INDArray other, INDArray result, MMulTranspose mMulTranspose) {
return null;