forked from kscience/kmath
remove cov from tensors API
This commit is contained in:
parent
ed5e94f580
commit
e110253d8f
@ -67,16 +67,6 @@ public interface AnalyticTensorAlgebra<T> : TensorPartialDivisionAlgebra<T> {
|
|||||||
*/
|
*/
|
||||||
public fun Tensor<T>.variance(dim: Int, keepDim: Boolean): Tensor<T>
|
public fun Tensor<T>.variance(dim: Int, keepDim: Boolean): Tensor<T>
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the covariance matrix M of given vectors.
|
|
||||||
*
|
|
||||||
* M[i, j] contains covariance of i-th and j-th given vectors
|
|
||||||
*
|
|
||||||
* @param tensors the [List] of 1-dimensional tensors with same shape
|
|
||||||
* @return the covariance matrix
|
|
||||||
*/
|
|
||||||
public fun cov(tensors: List<Tensor<T>>): Tensor<T>
|
|
||||||
|
|
||||||
//For information: https://pytorch.org/docs/stable/generated/torch.exp.html
|
//For information: https://pytorch.org/docs/stable/generated/torch.exp.html
|
||||||
public fun Tensor<T>.exp(): Tensor<T>
|
public fun Tensor<T>.exp(): Tensor<T>
|
||||||
|
|
||||||
|
@ -629,7 +629,15 @@ public open class DoubleTensorAlgebra :
|
|||||||
return ((x - x.mean()) * (y - y.mean())).mean() * n / (n - 1)
|
return ((x - x.mean()) * (y - y.mean())).mean() * n / (n - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun cov(tensors: List<Tensor<Double>>): DoubleTensor {
|
/**
|
||||||
|
* Returns the covariance matrix M of given vectors.
|
||||||
|
*
|
||||||
|
* M[i, j] contains covariance of i-th and j-th given vectors
|
||||||
|
*
|
||||||
|
* @param tensors the [List] of 1-dimensional tensors with same shape
|
||||||
|
* @return the covariance matrix
|
||||||
|
*/
|
||||||
|
public fun cov(tensors: List<Tensor<Double>>): DoubleTensor {
|
||||||
check(tensors.isNotEmpty()) { "List must have at least 1 element" }
|
check(tensors.isNotEmpty()) { "List must have at least 1 element" }
|
||||||
val n = tensors.size
|
val n = tensors.size
|
||||||
val m = tensors[0].shape[0]
|
val m = tensors[0].shape[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user