Merge pull request #331 from mipt-npm/commandertvis/q

Special rendering of Quaternion
This commit is contained in:
Alexander Nozik 2021-05-13 19:49:51 +03:00 committed by GitHub
commit ed5e94f580
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 9 deletions

View File

@ -12,11 +12,12 @@ import space.kscience.kmath.ast.rendering.FeaturedMathRendererWithPostProcess
import space.kscience.kmath.ast.rendering.MathMLSyntaxRenderer
import space.kscience.kmath.ast.rendering.renderWithStringBuilder
import space.kscience.kmath.complex.Complex
import space.kscience.kmath.complex.Quaternion
import space.kscience.kmath.expressions.MST
import space.kscience.kmath.expressions.MstRing
import space.kscience.kmath.misc.PerformancePitfall
import space.kscience.kmath.nd.Structure2D
import space.kscience.kmath.operations.GroupOperations
import space.kscience.kmath.operations.RingOperations
import space.kscience.kmath.operations.invoke
import space.kscience.kmath.structures.Buffer
import space.kscience.kmath.structures.asSequence
@ -121,11 +122,18 @@ internal class KMathJupyter : JupyterIntegration() {
}
render<Complex> {
MST.Binary(
operation = GroupOperations.PLUS_OPERATION,
left = MST.Numeric(it.re),
right = MST.Binary(RingOperations.TIMES_OPERATION, MST.Numeric(it.im), MST.Symbolic("i")),
).toDisplayResult()
MstRing {
number(it.re) + number(it.im) * bindSymbol("i")
}.toDisplayResult()
}
render<Quaternion> {
MstRing {
number(it.w) +
number(it.x) * bindSymbol("i") +
number(it.x) * bindSymbol("j") +
number(it.x) * bindSymbol("k")
}.toDisplayResult()
}
}
}