Package org.nd4j.autodiff.samediff.ops
Class SDLinalg
- java.lang.Object
-
- org.nd4j.autodiff.samediff.ops.SDOps
-
- org.nd4j.autodiff.samediff.ops.SDLinalg
-
public class SDLinalg extends SDOps
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SDVariable
cholesky(String name, SDVariable input)
Computes the Cholesky decomposition of one or more square matrices.SDVariable
cholesky(SDVariable input)
Computes the Cholesky decomposition of one or more square matrices.SDVariable
cross(String name, SDVariable a, SDVariable b)
Computes pairwise cross product.SDVariable
cross(SDVariable a, SDVariable b)
Computes pairwise cross product.SDVariable
diag(String name, SDVariable input)
Calculates diagonal tensor.SDVariable
diag(SDVariable input)
Calculates diagonal tensor.SDVariable
diag_part(String name, SDVariable input)
Calculates diagonal tensor.SDVariable
diag_part(SDVariable input)
Calculates diagonal tensor.SDVariable[]
eig(String[] names, SDVariable input)
Calculates eigen valuesSDVariable[]
eig(SDVariable input)
Calculates eigen valuesSDVariable
logdet(String name, SDVariable input)
Calculates log of determinant.SDVariable
logdet(SDVariable input)
Calculates log of determinant.SDVariable
lstsq(String name, SDVariable matrix, SDVariable rhs, double l2_reguralizer)
Solver for linear squares problems.SDVariable
lstsq(String name, SDVariable matrix, SDVariable rhs, double l2_reguralizer, boolean fast)
Solver for linear squares problems.SDVariable
lstsq(SDVariable matrix, SDVariable rhs, double l2_reguralizer)
Solver for linear squares problems.SDVariable
lstsq(SDVariable matrix, SDVariable rhs, double l2_reguralizer, boolean fast)
Solver for linear squares problems.SDVariable
lu(String name, SDVariable input)
Computes LU decomposition.SDVariable
lu(SDVariable input)
Computes LU decomposition.SDVariable
matmul(String name, SDVariable a, SDVariable b)
Performs matrix mutiplication on input tensors.SDVariable
matmul(SDVariable a, SDVariable b)
Performs matrix mutiplication on input tensors.SDVariable[]
matrixBandPart(String[] names, SDVariable input, int minLower, int maxUpper)
Copy a tensor setting outside a central band in each innermost matrix.SDVariable[]
matrixBandPart(SDVariable input, int minLower, int maxUpper)
Copy a tensor setting outside a central band in each innermost matrix.SDVariable
matrixDeterminant(String name, SDVariable input)
Calculates matrix determinant.SDVariable
matrixDeterminant(SDVariable input)
Calculates matrix determinant.SDVariable
matrixInverse(String name, SDVariable input)
Inverts a matrixSDVariable
matrixInverse(SDVariable input)
Inverts a matrixSDVariable
mmul(String name, SDVariable x, SDVariable y)
Matrix multiplication: out = mmul(x,y)
Supports specifying transpose argument to perform operation such as mmul(a^T, b), etc.SDVariable
mmul(String name, SDVariable x, SDVariable y, boolean transposeX, boolean transposeY, boolean transposeZ)
Matrix multiplication: out = mmul(x,y)
Supports specifying transpose argument to perform operation such as mmul(a^T, b), etc.SDVariable
mmul(SDVariable x, SDVariable y)
Matrix multiplication: out = mmul(x,y)
Supports specifying transpose argument to perform operation such as mmul(a^T, b), etc.SDVariable
mmul(SDVariable x, SDVariable y, boolean transposeX, boolean transposeY, boolean transposeZ)
Matrix multiplication: out = mmul(x,y)
Supports specifying transpose argument to perform operation such as mmul(a^T, b), etc.SDVariable[]
qr(String[] names, SDVariable input)
Computes the QR decompositions of input matrix.SDVariable[]
qr(String[] names, SDVariable input, boolean full)
Computes the QR decompositions of input matrix.SDVariable[]
qr(SDVariable input)
Computes the QR decompositions of input matrix.SDVariable[]
qr(SDVariable input, boolean full)
Computes the QR decompositions of input matrix.SDVariable
solve(String name, SDVariable matrix, SDVariable rhs)
Solver for systems of linear equations.SDVariable
solve(String name, SDVariable matrix, SDVariable rhs, boolean adjoint)
Solver for systems of linear equations.SDVariable
solve(SDVariable matrix, SDVariable rhs)
Solver for systems of linear equations.SDVariable
solve(SDVariable matrix, SDVariable rhs, boolean adjoint)
Solver for systems of linear equations.SDVariable
svd(String name, SDVariable input, boolean fullUV, boolean computeUV)
Calculates singular value decomposition.SDVariable
svd(String name, SDVariable input, boolean fullUV, boolean computeUV, int switchNum)
Calculates singular value decomposition.SDVariable
svd(SDVariable input, boolean fullUV, boolean computeUV)
Calculates singular value decomposition.SDVariable
svd(SDVariable input, boolean fullUV, boolean computeUV, int switchNum)
Calculates singular value decomposition.SDVariable
tri(int row, int column)
An array with ones at and below the given diagonal and zeros elsewhere.SDVariable
tri(String name, int row, int column)
An array with ones at and below the given diagonal and zeros elsewhere.SDVariable
tri(String name, DataType dataType, int row, int column, int diagonal)
An array with ones at and below the given diagonal and zeros elsewhere.SDVariable
tri(DataType dataType, int row, int column, int diagonal)
An array with ones at and below the given diagonal and zeros elsewhere.SDVariable
triangularSolve(String name, SDVariable matrix, SDVariable rhs, boolean lower, boolean adjoint)
Solver for systems of linear questions.SDVariable
triangularSolve(SDVariable matrix, SDVariable rhs, boolean lower, boolean adjoint)
Solver for systems of linear questions.SDVariable
triu(String name, SDVariable input)
Upper triangle of an array.SDVariable
triu(String name, SDVariable input, int diag)
Upper triangle of an array.SDVariable
triu(SDVariable input)
Upper triangle of an array.SDVariable
triu(SDVariable input, int diag)
Upper triangle of an array.
-
-
-
Constructor Detail
-
SDLinalg
public SDLinalg(SameDiff sameDiff)
-
-
Method Detail
-
cholesky
public SDVariable cholesky(SDVariable input)
Computes the Cholesky decomposition of one or more square matrices.- Parameters:
input
- Input tensor with inner-most 2 dimensions forming square matrices (NUMERIC type)- Returns:
- output Transformed tensor (NUMERIC type)
-
cholesky
public SDVariable cholesky(String name, SDVariable input)
Computes the Cholesky decomposition of one or more square matrices.- Parameters:
name
- name May be null. Name for the output variableinput
- Input tensor with inner-most 2 dimensions forming square matrices (NUMERIC type)- Returns:
- output Transformed tensor (NUMERIC type)
-
lstsq
public SDVariable lstsq(SDVariable matrix, SDVariable rhs, double l2_reguralizer, boolean fast)
Solver for linear squares problems.- Parameters:
matrix
- input tensor (NUMERIC type)rhs
- input tensor (NUMERIC type)l2_reguralizer
- regularizerfast
- fast mode, defaults to True- Returns:
- output Transformed tensor (FLOATING_POINT type)
-
lstsq
public SDVariable lstsq(String name, SDVariable matrix, SDVariable rhs, double l2_reguralizer, boolean fast)
Solver for linear squares problems.- Parameters:
name
- name May be null. Name for the output variablematrix
- input tensor (NUMERIC type)rhs
- input tensor (NUMERIC type)l2_reguralizer
- regularizerfast
- fast mode, defaults to True- Returns:
- output Transformed tensor (FLOATING_POINT type)
-
lstsq
public SDVariable lstsq(SDVariable matrix, SDVariable rhs, double l2_reguralizer)
Solver for linear squares problems.- Parameters:
matrix
- input tensor (NUMERIC type)rhs
- input tensor (NUMERIC type)l2_reguralizer
- regularizer- Returns:
- output Transformed tensor (FLOATING_POINT type)
-
lstsq
public SDVariable lstsq(String name, SDVariable matrix, SDVariable rhs, double l2_reguralizer)
Solver for linear squares problems.- Parameters:
name
- name May be null. Name for the output variablematrix
- input tensor (NUMERIC type)rhs
- input tensor (NUMERIC type)l2_reguralizer
- regularizer- Returns:
- output Transformed tensor (FLOATING_POINT type)
-
lu
public SDVariable lu(SDVariable input)
Computes LU decomposition.- Parameters:
input
- input tensor (NUMERIC type)- Returns:
- output (FLOATING_POINT type)
-
lu
public SDVariable lu(String name, SDVariable input)
Computes LU decomposition.- Parameters:
name
- name May be null. Name for the output variableinput
- input tensor (NUMERIC type)- Returns:
- output (FLOATING_POINT type)
-
matmul
public SDVariable matmul(SDVariable a, SDVariable b)
Performs matrix mutiplication on input tensors.- Parameters:
a
- input tensor (NUMERIC type)b
- input tensor (NUMERIC type)- Returns:
- output (FLOATING_POINT type)
-
matmul
public SDVariable matmul(String name, SDVariable a, SDVariable b)
Performs matrix mutiplication on input tensors.- Parameters:
name
- name May be null. Name for the output variablea
- input tensor (NUMERIC type)b
- input tensor (NUMERIC type)- Returns:
- output (FLOATING_POINT type)
-
matrixBandPart
public SDVariable[] matrixBandPart(SDVariable input, int minLower, int maxUpper)
Copy a tensor setting outside a central band in each innermost matrix.- Parameters:
input
- input tensor (NUMERIC type)minLower
- lower diagonal countmaxUpper
- upper diagonal count
-
matrixBandPart
public SDVariable[] matrixBandPart(String[] names, SDVariable input, int minLower, int maxUpper)
Copy a tensor setting outside a central band in each innermost matrix.- Parameters:
names
- names May be null. Arrays of names for the output variables.input
- input tensor (NUMERIC type)minLower
- lower diagonal countmaxUpper
- upper diagonal count
-
qr
public SDVariable[] qr(SDVariable input, boolean full)
Computes the QR decompositions of input matrix.- Parameters:
input
- input tensor (NUMERIC type)full
- full matrices mode
-
qr
public SDVariable[] qr(String[] names, SDVariable input, boolean full)
Computes the QR decompositions of input matrix.- Parameters:
names
- names May be null. Arrays of names for the output variables.input
- input tensor (NUMERIC type)full
- full matrices mode
-
qr
public SDVariable[] qr(SDVariable input)
Computes the QR decompositions of input matrix.- Parameters:
input
- input tensor (NUMERIC type)
-
qr
public SDVariable[] qr(String[] names, SDVariable input)
Computes the QR decompositions of input matrix.- Parameters:
names
- names May be null. Arrays of names for the output variables.input
- input tensor (NUMERIC type)
-
solve
public SDVariable solve(SDVariable matrix, SDVariable rhs, boolean adjoint)
Solver for systems of linear equations.- Parameters:
matrix
- input tensor (NUMERIC type)rhs
- input tensor (NUMERIC type)adjoint
- adjoint mode, defaults to False- Returns:
- output Output tensor (FLOATING_POINT type)
-
solve
public SDVariable solve(String name, SDVariable matrix, SDVariable rhs, boolean adjoint)
Solver for systems of linear equations.- Parameters:
name
- name May be null. Name for the output variablematrix
- input tensor (NUMERIC type)rhs
- input tensor (NUMERIC type)adjoint
- adjoint mode, defaults to False- Returns:
- output Output tensor (FLOATING_POINT type)
-
solve
public SDVariable solve(SDVariable matrix, SDVariable rhs)
Solver for systems of linear equations.- Parameters:
matrix
- input tensor (NUMERIC type)rhs
- input tensor (NUMERIC type)- Returns:
- output Output tensor (FLOATING_POINT type)
-
solve
public SDVariable solve(String name, SDVariable matrix, SDVariable rhs)
Solver for systems of linear equations.- Parameters:
name
- name May be null. Name for the output variablematrix
- input tensor (NUMERIC type)rhs
- input tensor (NUMERIC type)- Returns:
- output Output tensor (FLOATING_POINT type)
-
triangularSolve
public SDVariable triangularSolve(SDVariable matrix, SDVariable rhs, boolean lower, boolean adjoint)
Solver for systems of linear questions.- Parameters:
matrix
- input tensor (NUMERIC type)rhs
- input tensor (NUMERIC type)lower
- defines whether innermost matrices in matrix are lower or upper triangularadjoint
- adjoint mode- Returns:
- output (FLOATING_POINT type)
-
triangularSolve
public SDVariable triangularSolve(String name, SDVariable matrix, SDVariable rhs, boolean lower, boolean adjoint)
Solver for systems of linear questions.- Parameters:
name
- name May be null. Name for the output variablematrix
- input tensor (NUMERIC type)rhs
- input tensor (NUMERIC type)lower
- defines whether innermost matrices in matrix are lower or upper triangularadjoint
- adjoint mode- Returns:
- output (FLOATING_POINT type)
-
cross
public SDVariable cross(SDVariable a, SDVariable b)
Computes pairwise cross product.- Parameters:
a
- (NUMERIC type)b
- (NUMERIC type)- Returns:
- output (FLOATING_POINT type)
-
cross
public SDVariable cross(String name, SDVariable a, SDVariable b)
Computes pairwise cross product.- Parameters:
name
- name May be null. Name for the output variablea
- (NUMERIC type)b
- (NUMERIC type)- Returns:
- output (FLOATING_POINT type)
-
diag
public SDVariable diag(SDVariable input)
Calculates diagonal tensor.- Parameters:
input
- (NUMERIC type)- Returns:
- output (FLOATING_POINT type)
-
diag
public SDVariable diag(String name, SDVariable input)
Calculates diagonal tensor.- Parameters:
name
- name May be null. Name for the output variableinput
- (NUMERIC type)- Returns:
- output (FLOATING_POINT type)
-
diag_part
public SDVariable diag_part(SDVariable input)
Calculates diagonal tensor.- Parameters:
input
- (NUMERIC type)- Returns:
- output (FLOATING_POINT type)
-
diag_part
public SDVariable diag_part(String name, SDVariable input)
Calculates diagonal tensor.- Parameters:
name
- name May be null. Name for the output variableinput
- (NUMERIC type)- Returns:
- output (FLOATING_POINT type)
-
eig
public SDVariable[] eig(SDVariable input)
Calculates eigen values- Parameters:
input
- (NUMERIC type)
-
eig
public SDVariable[] eig(String[] names, SDVariable input)
Calculates eigen values- Parameters:
names
- names May be null. Arrays of names for the output variables.input
- (NUMERIC type)
-
logdet
public SDVariable logdet(SDVariable input)
Calculates log of determinant.- Parameters:
input
- (NUMERIC type)- Returns:
- output (FLOATING_POINT type)
-
logdet
public SDVariable logdet(String name, SDVariable input)
Calculates log of determinant.- Parameters:
name
- name May be null. Name for the output variableinput
- (NUMERIC type)- Returns:
- output (FLOATING_POINT type)
-
matrixDeterminant
public SDVariable matrixDeterminant(SDVariable input)
Calculates matrix determinant.- Parameters:
input
- (NUMERIC type)- Returns:
- output (FLOATING_POINT type)
-
matrixDeterminant
public SDVariable matrixDeterminant(String name, SDVariable input)
Calculates matrix determinant.- Parameters:
name
- name May be null. Name for the output variableinput
- (NUMERIC type)- Returns:
- output (FLOATING_POINT type)
-
matrixInverse
public SDVariable matrixInverse(SDVariable input)
Inverts a matrix- Parameters:
input
- (NUMERIC type)- Returns:
- output (FLOATING_POINT type)
-
matrixInverse
public SDVariable matrixInverse(String name, SDVariable input)
Inverts a matrix- Parameters:
name
- name May be null. Name for the output variableinput
- (NUMERIC type)- Returns:
- output (FLOATING_POINT type)
-
mmul
public SDVariable mmul(SDVariable x, SDVariable y, boolean transposeX, boolean transposeY, boolean transposeZ)
Matrix multiplication: out = mmul(x,y)
Supports specifying transpose argument to perform operation such as mmul(a^T, b), etc.- Parameters:
x
- First input variable (NUMERIC type)y
- Second input variable (NUMERIC type)transposeX
- Transpose x (first argument)transposeY
- Transpose y (second argument)transposeZ
- Transpose result array- Returns:
- output (NUMERIC type)
-
mmul
public SDVariable mmul(String name, SDVariable x, SDVariable y, boolean transposeX, boolean transposeY, boolean transposeZ)
Matrix multiplication: out = mmul(x,y)
Supports specifying transpose argument to perform operation such as mmul(a^T, b), etc.- Parameters:
name
- name May be null. Name for the output variablex
- First input variable (NUMERIC type)y
- Second input variable (NUMERIC type)transposeX
- Transpose x (first argument)transposeY
- Transpose y (second argument)transposeZ
- Transpose result array- Returns:
- output (NUMERIC type)
-
mmul
public SDVariable mmul(SDVariable x, SDVariable y)
Matrix multiplication: out = mmul(x,y)
Supports specifying transpose argument to perform operation such as mmul(a^T, b), etc.- Parameters:
x
- First input variable (NUMERIC type)y
- Second input variable (NUMERIC type)- Returns:
- output (NUMERIC type)
-
mmul
public SDVariable mmul(String name, SDVariable x, SDVariable y)
Matrix multiplication: out = mmul(x,y)
Supports specifying transpose argument to perform operation such as mmul(a^T, b), etc.- Parameters:
name
- name May be null. Name for the output variablex
- First input variable (NUMERIC type)y
- Second input variable (NUMERIC type)- Returns:
- output (NUMERIC type)
-
svd
public SDVariable svd(SDVariable input, boolean fullUV, boolean computeUV, int switchNum)
Calculates singular value decomposition.- Parameters:
input
- (NUMERIC type)fullUV
-computeUV
-switchNum
-- Returns:
- output (FLOATING_POINT type)
-
svd
public SDVariable svd(String name, SDVariable input, boolean fullUV, boolean computeUV, int switchNum)
Calculates singular value decomposition.- Parameters:
name
- name May be null. Name for the output variableinput
- (NUMERIC type)fullUV
-computeUV
-switchNum
-- Returns:
- output (FLOATING_POINT type)
-
svd
public SDVariable svd(SDVariable input, boolean fullUV, boolean computeUV)
Calculates singular value decomposition.- Parameters:
input
- (NUMERIC type)fullUV
-computeUV
-- Returns:
- output (FLOATING_POINT type)
-
svd
public SDVariable svd(String name, SDVariable input, boolean fullUV, boolean computeUV)
Calculates singular value decomposition.- Parameters:
name
- name May be null. Name for the output variableinput
- (NUMERIC type)fullUV
-computeUV
-- Returns:
- output (FLOATING_POINT type)
-
tri
public SDVariable tri(DataType dataType, int row, int column, int diagonal)
An array with ones at and below the given diagonal and zeros elsewhere.- Parameters:
dataType
- Data typerow
-column
-diagonal
-- Returns:
- output (FLOATING_POINT type)
-
tri
public SDVariable tri(String name, DataType dataType, int row, int column, int diagonal)
An array with ones at and below the given diagonal and zeros elsewhere.- Parameters:
name
- name May be null. Name for the output variabledataType
- Data typerow
-column
-diagonal
-- Returns:
- output (FLOATING_POINT type)
-
tri
public SDVariable tri(int row, int column)
An array with ones at and below the given diagonal and zeros elsewhere.- Parameters:
row
-column
-- Returns:
- output (FLOATING_POINT type)
-
tri
public SDVariable tri(String name, int row, int column)
An array with ones at and below the given diagonal and zeros elsewhere.- Parameters:
name
- name May be null. Name for the output variablerow
-column
-- Returns:
- output (FLOATING_POINT type)
-
triu
public SDVariable triu(SDVariable input, int diag)
Upper triangle of an array. Return a copy of a input tensor with the elements below the k-th diagonal zeroed.- Parameters:
input
- (NUMERIC type)diag
-- Returns:
- output (FLOATING_POINT type)
-
triu
public SDVariable triu(String name, SDVariable input, int diag)
Upper triangle of an array. Return a copy of a input tensor with the elements below the k-th diagonal zeroed.- Parameters:
name
- name May be null. Name for the output variableinput
- (NUMERIC type)diag
-- Returns:
- output (FLOATING_POINT type)
-
triu
public SDVariable triu(SDVariable input)
Upper triangle of an array. Return a copy of a input tensor with the elements below the k-th diagonal zeroed.- Parameters:
input
- (NUMERIC type)- Returns:
- output (FLOATING_POINT type)
-
triu
public SDVariable triu(String name, SDVariable input)
Upper triangle of an array. Return a copy of a input tensor with the elements below the k-th diagonal zeroed.- Parameters:
name
- name May be null. Name for the output variableinput
- (NUMERIC type)- Returns:
- output (FLOATING_POINT type)
-
-