diff --git a/kmath-tensors/README.md b/kmath-tensors/README.md index 3b82829f0..24d46cd16 100644 --- a/kmath-tensors/README.md +++ b/kmath-tensors/README.md @@ -1,12 +1,15 @@ # Module kmath-tensors -Common linear algebra operations on tensors. - - - [tensor algebra](src/commonMain/kotlin/space/kscience/kmath/tensors/api/TensorAlgebra.kt) : Basic linear algebra operations on tensors (plus, dot, etc.) - - [tensor algebra with broadcasting](src/commonMain/kotlin/space/kscience/kmath/tensors/core/algebras/BroadcastDoubleTensorAlgebra.kt) : Basic linear algebra operations implemented with broadcasting. - - [linear algebra operations](src/commonMain/kotlin/space/kscience/kmath/tensors/api/LinearOpsTensorAlgebra.kt) : Advanced linear algebra operations like LU decomposition, SVD, etc. +Common operations on tensors, the API consists of: + - [TensorAlgebra](src/commonMain/kotlin/space/kscience/kmath/tensors/api/TensorAlgebra.kt) : Basic algebra operations on tensors (plus, dot, etc.) + - [TensorPartialDivisionAlgebra](src/commonMain/kotlin/space/kscience/kmath/tensors/api/TensorPartialDivisionAlgebra.kt) : Emulates an algebra over a field + - [LinearOpsTensorAlgebra](src/commonMain/kotlin/space/kscience/kmath/tensors/api/LinearOpsTensorAlgebra.kt) : Linear algebra operations including LU, QR, Cholesky LL and SVD decompositions + - [AnalyticTensorAlgebra](src/commonMain/kotlin/space/kscience/kmath/tensors/api/AnalyticTensorAlgebra.kt) : Element-wise analytic operations +The library offers a multiplatform implementation for this interface over the `Double`'s. As the highlight, the user can find: + - [BroadcastDoubleTensorAlgebra](src/commonMain/kotlin/space/kscience/kmath/tensors/core/algebras/BroadcastDoubleTensorAlgebra.kt) : Basic algebra operations implemented with broadcasting. + - [DoubleLinearOpsTensorAlgebra](src/commonMain/kotlin/space/kscience/kmath/tensors/core/algebras/DoubleLinearOpsTensorAlgebra.kt) : Includes the power method for SVD and the spectrum of symmetric matrices. ## Artifact: The Maven coordinates of this project are `space.kscience:kmath-tensors:0.3.0-dev-7`. diff --git a/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/AnalyticTensorAlgebra.kt b/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/AnalyticTensorAlgebra.kt index 315f39027..5c92c56c4 100644 --- a/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/AnalyticTensorAlgebra.kt +++ b/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/AnalyticTensorAlgebra.kt @@ -5,59 +5,63 @@ package space.kscience.kmath.tensors.api - +/** + * Element-wise analytic operations on [TensorStructure]. + * + * @param T the type of items closed under analytic functions in the tensors. + */ public interface AnalyticTensorAlgebra : TensorPartialDivisionAlgebra { - //https://pytorch.org/docs/stable/generated/torch.exp.html + //For information: https://pytorch.org/docs/stable/generated/torch.exp.html public fun TensorStructure.exp(): TensorStructure - //https://pytorch.org/docs/stable/generated/torch.log.html + //For information: https://pytorch.org/docs/stable/generated/torch.log.html public fun TensorStructure.log(): TensorStructure - //https://pytorch.org/docs/stable/generated/torch.sqrt.html + //For information: https://pytorch.org/docs/stable/generated/torch.sqrt.html public fun TensorStructure.sqrt(): TensorStructure - //https://pytorch.org/docs/stable/generated/torch.acos.html#torch.cos + //For information: https://pytorch.org/docs/stable/generated/torch.acos.html#torch.cos public fun TensorStructure.cos(): TensorStructure - //https://pytorch.org/docs/stable/generated/torch.acos.html#torch.acos + //For information: https://pytorch.org/docs/stable/generated/torch.acos.html#torch.acos public fun TensorStructure.acos(): TensorStructure - //https://pytorch.org/docs/stable/generated/torch.acosh.html#torch.cosh + //For information: https://pytorch.org/docs/stable/generated/torch.acosh.html#torch.cosh public fun TensorStructure.cosh(): TensorStructure - //https://pytorch.org/docs/stable/generated/torch.acosh.html#torch.acosh + //For information: https://pytorch.org/docs/stable/generated/torch.acosh.html#torch.acosh public fun TensorStructure.acosh(): TensorStructure - //https://pytorch.org/docs/stable/generated/torch.asin.html#torch.sin + //For information: https://pytorch.org/docs/stable/generated/torch.asin.html#torch.sin public fun TensorStructure.sin(): TensorStructure - //https://pytorch.org/docs/stable/generated/torch.asin.html#torch.asin + //For information: https://pytorch.org/docs/stable/generated/torch.asin.html#torch.asin public fun TensorStructure.asin(): TensorStructure - //https://pytorch.org/docs/stable/generated/torch.asin.html#torch.sinh + //For information: https://pytorch.org/docs/stable/generated/torch.asin.html#torch.sinh public fun TensorStructure.sinh(): TensorStructure - //https://pytorch.org/docs/stable/generated/torch.asin.html#torch.asinh + //For information: https://pytorch.org/docs/stable/generated/torch.asin.html#torch.asinh public fun TensorStructure.asinh(): TensorStructure - //https://pytorch.org/docs/stable/generated/torch.atan.html#torch.tan + //For information: https://pytorch.org/docs/stable/generated/torch.atan.html#torch.tan public fun TensorStructure.tan(): TensorStructure //https://pytorch.org/docs/stable/generated/torch.atan.html#torch.atan public fun TensorStructure.atan(): TensorStructure - //https://pytorch.org/docs/stable/generated/torch.atanh.html#torch.tanh + //For information: https://pytorch.org/docs/stable/generated/torch.atanh.html#torch.tanh public fun TensorStructure.tanh(): TensorStructure - //https://pytorch.org/docs/stable/generated/torch.atanh.html#torch.atanh + //For information: https://pytorch.org/docs/stable/generated/torch.atanh.html#torch.atanh public fun TensorStructure.atanh(): TensorStructure - //https://pytorch.org/docs/stable/generated/torch.ceil.html#torch.ceil + //For information: https://pytorch.org/docs/stable/generated/torch.ceil.html#torch.ceil public fun TensorStructure.ceil(): TensorStructure - //https://pytorch.org/docs/stable/generated/torch.floor.html#torch.floor + //For information: https://pytorch.org/docs/stable/generated/torch.floor.html#torch.floor public fun TensorStructure.floor(): TensorStructure } \ No newline at end of file diff --git a/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/LinearOpsTensorAlgebra.kt b/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/LinearOpsTensorAlgebra.kt index aa10ae49b..7a19c5d5a 100644 --- a/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/LinearOpsTensorAlgebra.kt +++ b/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/LinearOpsTensorAlgebra.kt @@ -8,7 +8,7 @@ package space.kscience.kmath.tensors.api /** * Common linear algebra operations. Operates on [TensorStructure]. * - * @param T the type of items in the tensors. + * @param T the type of items closed under division in the tensors. */ public interface LinearOpsTensorAlgebra : TensorPartialDivisionAlgebra { diff --git a/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/TensorAlgebra.kt b/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/TensorAlgebra.kt index 62d4a1b89..338064231 100644 --- a/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/TensorAlgebra.kt +++ b/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/TensorAlgebra.kt @@ -6,7 +6,7 @@ package space.kscience.kmath.tensors.api /** - * Basic linear algebra operations on [TensorStructure]. + * Algebra over a ring on [TensorStructure]. * For more information: https://proofwiki.org/wiki/Definition:Algebra_over_Ring * * @param T the type of items in the tensors. diff --git a/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/TensorPartialDivisionAlgebra.kt b/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/TensorPartialDivisionAlgebra.kt index 4dab3dd07..eccc6fa0d 100644 --- a/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/TensorPartialDivisionAlgebra.kt +++ b/kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/TensorPartialDivisionAlgebra.kt @@ -5,12 +5,52 @@ package space.kscience.kmath.tensors.api -// https://proofwiki.org/wiki/Definition:Division_Algebra +/** + * Algebra over a field with partial division on [TensorStructure]. + * For more information: https://proofwiki.org/wiki/Definition:Division_Algebra + * + * @param T the type of items closed under division in the tensors. + */ public interface TensorPartialDivisionAlgebra : TensorAlgebra { + + /** + * Each element of the tensor [other] is divided by this value. + * The resulting tensor is returned. + * + * @param other tensor to divide by. + * @return the division of this value by the tensor [other]. + */ public operator fun T.div(other: TensorStructure): TensorStructure + + /** + * Divide by the scalar [value] each element of this tensor returns a new resulting tensor. + * + * @param value the number to divide by each element of this tensor. + * @return the division of this tensor by the [value]. + */ public operator fun TensorStructure.div(value: T): TensorStructure + + /** + * Each element of the tensor [other] is divided by each element of this tensor. + * The resulting tensor is returned. + * + * @param other tensor to be divided by. + * @return the division of this tensor by [other]. + */ public operator fun TensorStructure.div(other: TensorStructure): TensorStructure + + /** + * Divides by the scalar [value] each element of this tensor. + * + * @param value the number to divide by each element of this tensor. + */ public operator fun TensorStructure.divAssign(value: T) + + /** + * Each element of this tensor is divided by each element of the [other] tensor. + * + * @param other tensor to be divide by. + */ public operator fun TensorStructure.divAssign(other: TensorStructure) }