File tree Expand file tree Collapse file tree 1 file changed +74
-0
lines changed Expand file tree Collapse file tree 1 file changed +74
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,80 @@ julia> weval(sinx; x=2.0)
58
58
0.9092974268256817
59
59
```
60
60
61
+ ## The algebraic operators
62
+
63
+ MathLink also overloads the ` + ` , ` - ` , ` * ` , ` / ` operations
64
+
65
+ ``` julia
66
+ julia> using MathLink
67
+
68
+ julia> W " a" + W " b"
69
+ W " Plus" (W " a" ,W " b" )
70
+
71
+ julia> W " a" + W " a"
72
+ W " Plus" (W " a" ,W " a" )
73
+
74
+ julia> W " a" - W " a"
75
+ W " Plus" (W " a" ,W " Minus" (W " a" ))
76
+ ```
77
+
78
+ One can toggle automatic use of ` weval ` on-and-off using ` set_GreedyEval(x::Bool) `
79
+
80
+ ``` julia
81
+ julia> set_GreedyEval (true )
82
+ julia> W " a" + W " b"
83
+ W " Plus" (W " a" ,W " b" )
84
+
85
+ julia> W " a" + W " a"
86
+ W " Times" (2 ,W " a" )
87
+
88
+ julia> W " a" - W " a"
89
+ 0
90
+ ```
91
+
92
+
93
+ ## Fractions and Complex numbers
94
+
95
+ The package also contains extentions to handle fractions
96
+
97
+ ``` julia
98
+ julia> weval (1 // 2 )
99
+ W " Rational" (1 , 2 )
100
+
101
+ julia> (4 // 5 )* W " a"
102
+ W " Times" (W " Rational" (4 , 5 ), W " a" )
103
+
104
+ julia> W " a" / (4 // 5 )
105
+ W " Times" (W " Rational" (5 , 4 ), W " a" )
106
+ ```
107
+
108
+ and complex numbers
109
+
110
+ ``` julia
111
+ julia> im* W " a"
112
+ W " Times" (W " Complex" (0 , 1 ), W " a" )
113
+
114
+ julia> im* (im* W " c" )
115
+ W " Times" (- 1 , W " c" )
116
+ ```
117
+
118
+
119
+ ## Matrix Multiplication
120
+ Since the arithematic operators are overloaded, operations such as matrix multiplication are also possible by default
121
+
122
+ ``` julia
123
+ julia> P12 = [ 0 1 ; 1 0 ]
124
+ 2 × 2 Matrix{Int64}:
125
+ 0 1
126
+ 1 0
127
+
128
+ julia> set_GreedyEval (true )
129
+ true
130
+
131
+ julia> P12 * [W " a" W " b" ; W ` a+b` 2 ] == [ W " b" 2 - W " b" ; W " a" W " b" ]
132
+ true
133
+ ```
134
+
61
135
## Notes
62
136
63
137
- Mathematica, Wolfram, MathLink are all trademarks of Wolfram Research.
You can’t perform that action at this time.
0 commit comments