Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MathNET Symbolics
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Severin Delhey
MathNET Symbolics
Commits
cbcd4423
Commit
cbcd4423
authored
7 years ago
by
Christoph Ruegg
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
c83bbd60
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Symbolics/Convert/Infix.fs
+5
-5
5 additions, 5 deletions
src/Symbolics/Convert/Infix.fs
src/Symbolics/Convert/VisualExpression.fs
+65
-0
65 additions, 0 deletions
src/Symbolics/Convert/VisualExpression.fs
src/Symbolics/Symbols.fs
+1
-1
1 addition, 1 deletion
src/Symbolics/Symbols.fs
with
71 additions
and
6 deletions
src/Symbolics/Convert/Infix.fs
+
5
−
5
View file @
cbcd4423
...
...
@@ -30,12 +30,12 @@ module private InfixParser =
let
abs
p
=
between
(
str_ws
"|"
)
(
str_ws
"|"
)
p
|>>
Expression
.
Abs
let
number
:
Expression
parser
=
let
options
=
NumberLiteralOptions
.
AllowFraction
|||
NumberLiteralOptions
.
AllowFractionWOIntegerPart
let
options
=
NumberLiteralOptions
.
AllowFraction
|||
NumberLiteralOptions
.
AllowFractionWOIntegerPart
|||
NumberLiteralOptions
.
AllowInfinity
|||
NumberLiteralOptions
.
AllowExponent
numberLiteral
options
"number"
.>>
ws
|>>
fun
num
->
if
num
.
IsInfinity
then
Expression
.
PositiveInfinity
...
...
@@ -45,7 +45,7 @@ module private InfixParser =
let
identifier
:
Expression
parser
=
let
isMathChar
=
function
|
'
\
u03C0'
|
'
\
u221E'
|
'
\
u29DD'
->
true
|
_
->
false
let
isIdentifierFirstChar
c
=
isLetter
c
||
isMathChar
c
let
isIdentifierChar
c
=
isLetter
c
||
isDigit
c
||
isMathChar
c
||
c
=
'
_
'
let
isIdentifierChar
c
=
isLetter
c
||
isDigit
c
||
isMathChar
c
||
c
=
'
_
'
many1Satisfy2L
isIdentifierFirstChar
isIdentifierChar
"identifier"
.>>
ws
|>>
function
// differentating between constants and identifiers
|
"pi"
|
"
\
u03C0"
->
Expression
.
Constant
Pi
...
...
This diff is collapsed.
Click to expand it.
src/Symbolics/Convert/VisualExpression.fs
0 → 100644
+
65
−
0
View file @
cbcd4423
namespace
MathNet
.
Symbolics
open
System
open
System
.
Numerics
open
MathNet
.
Numerics
open
MathNet
.
Symbolics
open
System
.
Linq
.
Expressions
[<
StructuralEquality
;
NoComparison
;
RequireQualifiedAccess
>]
type
VisualExpression
=
|
Identifier
of
Symbol
|
Constant
of
Constant
|
PositiveInteger
of
BigInteger
|
PositiveFloatingPoint
of
double
|
Parenthesis
of
VisualExpression
|
Prodct
of
VisualExpression
list
|
Fraction
of
VisualExpression
*
VisualExpression
|
Negative
of
VisualExpression
|
Sum
of
VisualExpression
list
|
Power
of
VisualExpression
*
VisualExpression
|
Function
of
string
*
VisualExpression
|
FunctionN
of
string
*
(
VisualExpression
list
)
|
ComplexInfinity
|
Infinity
|
Undefined
module
VisualExpression
=
let
fromExpression
expression
=
let
parenthesis
priority
threshold
ve
=
if
priority
>
threshold
then
VisualExpression
.
Parenthesis
ve
else
ve
let
rec
convert
priority
=
function
|
Number
n
when
n
.
IsNegative
&&
n
.
IsInteger
->
VisualExpression
.
Negative
(
VisualExpression
.
PositiveInteger
(-
n
.
Numerator
))
|>
parenthesis
priority
0
|
Number
n
when
n
.
IsNegative
->
VisualExpression
.
Negative
(
VisualExpression
.
Fraction
(
VisualExpression
.
PositiveInteger
(-
n
.
Numerator
),
VisualExpression
.
PositiveInteger
n
.
Denominator
))
|>
parenthesis
priority
1
|
Number
n
when
n
.
IsInteger
->
VisualExpression
.
PositiveInteger
n
.
Numerator
|
Number
n
->
VisualExpression
.
Fraction
(
VisualExpression
.
PositiveInteger
n
.
Numerator
,
VisualExpression
.
PositiveInteger
n
.
Denominator
)
|>
parenthesis
priority
1
|
Approximation
(
Approximation
.
Real
fp
)
when
fp
<
0
.
0
->
VisualExpression
.
Negative
(
VisualExpression
.
PositiveFloatingPoint
(-
fp
))
|>
parenthesis
priority
0
|
Approximation
(
Approximation
.
Real
fp
)
->
VisualExpression
.
PositiveFloatingPoint
fp
|
Approximation
(
Approximation
.
Complex
fp
)
when
fp
.
IsRealNonNegative
()
->
VisualExpression
.
PositiveFloatingPoint
fp
.
Real
|
Approximation
(
Approximation
.
Complex
fp
)
when
fp
.
IsReal
()
->
VisualExpression
.
Negative
(
VisualExpression
.
PositiveFloatingPoint
(-
fp
.
Real
))
|>
parenthesis
priority
0
|
Approximation
(
Approximation
.
Complex
fp
)
->
//when fp.Real = 0.0 && fp.Imaginary < 0.0 ->
failwith
"TODO"
|
Sum
(
x
::
xs
)
->
|
Identifier
s
->
VisualExpression
.
Identifier
s
|
Constant
c
->
VisualExpression
.
Constant
c
|
ComplexInfinity
->
VisualExpression
.
ComplexInfinity
|
PositiveInfinity
->
VisualExpression
.
Infinity
|
NegativeInfinity
->
VisualExpression
.
Negative
VisualExpression
.
Infinity
|>
parenthesis
priority
0
|
Undefined
->
VisualExpression
.
Undefined
convert
1
expression
This diff is collapsed.
Click to expand it.
src/Symbolics/Symbols.fs
+
1
−
1
View file @
cbcd4423
...
...
@@ -6,7 +6,7 @@ type Function =
|
Abs
|
Ln
|
Exp
|
Sin
|
Cos
|
Tan
|
Cot
|
Sec
|
Csc
|
Cot
|
Sec
|
Csc
|
Cosh
|
Sinh
|
Tanh
|
Asin
|
Acos
|
Atan
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment