From ed1dca5509c79034cc8be7292f4368d79c6d5ce8 Mon Sep 17 00:00:00 2001 From: diluculo Date: Tue, 8 Jan 2019 17:26:13 +0900 Subject: [PATCH] Fix Linq.FormatComplexLambda - #68 --- src/Symbolics.Tests/Compilation/Compilation.fs | 3 +++ src/Symbolics/Typed/Linq.fs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symbolics.Tests/Compilation/Compilation.fs b/src/Symbolics.Tests/Compilation/Compilation.fs index 342c01c..4b60037 100644 --- a/src/Symbolics.Tests/Compilation/Compilation.fs +++ b/src/Symbolics.Tests/Compilation/Compilation.fs @@ -67,5 +67,8 @@ let tests = let expr9' = x + 1 (Compile.compileComplexExpression1OrThrow expr9' symX).Invoke(System.Numerics.Complex.One) --> toComplex 2.0 + + let expr10' = y * y + Expression.I * y + (besselk x (Expression.I * y)) / (besselk (negate x) (Expression.I * y)) + (Compile.compileComplexExpression2OrThrow expr10' symX symY).Invoke(toComplex 0.5, System.Numerics.Complex.One) --> complex 2.0 1.0 // 1*1 + I + 1 = 2 + I } ] diff --git a/src/Symbolics/Typed/Linq.fs b/src/Symbolics/Typed/Linq.fs index f7e6df9..cb7f3da 100644 --- a/src/Symbolics/Typed/Linq.fs +++ b/src/Symbolics/Typed/Linq.fs @@ -231,7 +231,7 @@ module Linq = let constant = function | E -> Some (Expression.Constant (complex Constants.E 0.0) :> Expression) | Pi -> Some (Expression.Constant (complex Constants.Pi 0.0) :> Expression) - | _ -> None + | I -> Some (Expression.Constant (complex 0.0 1.0) :> Expression) let valueType = typeof let mathType = typeof let mathCall1 (name : string) (a : Expression) = Expression.Call(mathType.GetMethod(name, [| valueType |]), a) :> Expression