Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Sources/AngouriMath/Convenience/MathS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,26 @@ public static Integer GreatestCommonDivisor(Integer a, Integer b)
[MethodImpl(MethodImplOptions.AggressiveInlining), NativeExport]
public static Entity Pow(Entity @base, Entity power) => new Powf(@base, power);

/// <summary>
/// The remainder after dividing one expression by another, that is, the node
/// <paramref name="dividend"/> % <paramref name="divisor"/>.
/// </summary>
/// <remarks>
/// The remainder takes the sign of the divisor -- the floored convention,
/// <c>a - b * floor(a / b)</c>, under which <c>(-7) mod 3</c> is 2 and <c>7 mod (-3)</c>
/// is -2. This is what a mathematician means by mod: it is the convention under which
/// the residues modulo n are the numbers from 0 to n - 1, and it is what SymPy,
/// Mathematica and Maxima all answer. C# truncates instead and so its <c>%</c> on two
/// <see cref="int"/>s gives -1 there, but that is an operation on machine integers and
/// not this one.
/// <para/>
/// Written <c>mod</c> when parsed from a string. <c>%</c> is left to mean percent.
/// </remarks>
/// <param name="dividend">The expression whose remainder is taken</param>
/// <param name="divisor">The expression divided by; the result is undefined where it is zero</param>
/// <returns>The node of the remainder</returns>
public static Entity Mod(Entity dividend, Entity divisor) => new Modf(dividend, divisor);

/// <summary>Special case of <a href="https://en.wikipedia.org/wiki/Power_function"/></summary>
/// <param name="a">The argument of which square root will be taken</param>
/// <returns>Power node with (1/2) as the power</returns>
Expand Down
3 changes: 2 additions & 1 deletion Sources/AngouriMath/Core/Antlr/AngouriMath.g
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ unary_expression returns[Entity value]
mult_expression returns[Entity value]
: u1 = unary_expression { $value = $u1.value; }
('*' u2 = unary_expression { $value = $value * $u2.value; } |
'/' u2 = unary_expression { $value = $value / $u2.value; })*
'/' u2 = unary_expression { $value = $value / $u2.value; } |
'mod' u2 = unary_expression { $value = $value % $u2.value; })*
;

sum_expression returns[Entity value]
Expand Down
4 changes: 3 additions & 1 deletion Sources/AngouriMath/Core/Antlr/AngouriMath.interp

Large diffs are not rendered by default.

258 changes: 130 additions & 128 deletions Sources/AngouriMath/Core/Antlr/AngouriMath.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -125,137 +125,139 @@ T__123=124
T__124=125
T__125=126
T__126=127
NEWLINE=128
NUMBER=129
SPECIALSET=130
BOOLEAN=131
VARIABLE=132
COMMENT=133
WS=134
T__127=128
NEWLINE=129
NUMBER=130
SPECIALSET=131
BOOLEAN=132
VARIABLE=133
COMMENT=134
WS=135
'!'=1
'^'=2
'-'=3
'+'=4
'*'=5
'/'=6
'intersect'=7
'/\\'=8
'unite'=9
'\\/'=10
'setsubtract'=11
'\\'=12
'in'=13
'>='=14
'<='=15
'>'=16
'<'=17
'='=18
'<>'=19
'not'=20
'and'=21
'&'=22
'xor'=23
'or'=24
'|'=25
'implies'=26
'->'=27
'provided'=28
','=29
';'=30
':'=31
'+oo'=32
'-oo'=33
'(|'=34
'|)'=35
'['=36
']T'=37
']'=38
'('=39
')'=40
'{'=41
'}'=42
'log('=43
'pow('=44
'sqrt('=45
'cbrt('=46
'sqr('=47
'ln('=48
'sin('=49
'cos('=50
'tan('=51
'cotan('=52
'cot('=53
'sec('=54
'cosec('=55
'csc('=56
'arcsin('=57
'arccos('=58
'arctan('=59
'arccotan('=60
'arcsec('=61
'arccosec('=62
'arccsc('=63
'acsc('=64
'asin('=65
'acos('=66
'atan('=67
'acotan('=68
'asec('=69
'acosec('=70
'acot('=71
'arccot('=72
'sinh('=73
'sh('=74
'cosh('=75
'ch('=76
'tanh('=77
'th('=78
'cotanh('=79
'coth('=80
'cth('=81
'sech('=82
'sch('=83
'cosech('=84
'csch('=85
'asinh('=86
'arsinh('=87
'arsh('=88
'arcsinh('=89
'acosh('=90
'arcosh('=91
'arch('=92
'arccosh('=93
'atanh('=94
'artanh('=95
'arth('=96
'arctanh('=97
'acoth('=98
'arcoth('=99
'acotanh('=100
'arcotanh('=101
'arcth('=102
'arccotanh('=103
'asech('=104
'arsech('=105
'arsch('=106
'arcsech('=107
'acosech('=108
'arcosech('=109
'arcsch('=110
'arccosech('=111
'acsch('=112
'gamma('=113
'derivative('=114
'integral('=115
'limit('=116
'limitleft('=117
'limitright('=118
'signum('=119
'sgn('=120
'sign('=121
'abs('=122
'phi('=123
'domain('=124
'piecewise('=125
'apply('=126
'lambda('=127
'mod'=7
'intersect'=8
'/\\'=9
'unite'=10
'\\/'=11
'setsubtract'=12
'\\'=13
'in'=14
'>='=15
'<='=16
'>'=17
'<'=18
'='=19
'<>'=20
'not'=21
'and'=22
'&'=23
'xor'=24
'or'=25
'|'=26
'implies'=27
'->'=28
'provided'=29
','=30
';'=31
':'=32
'+oo'=33
'-oo'=34
'(|'=35
'|)'=36
'['=37
']T'=38
']'=39
'('=40
')'=41
'{'=42
'}'=43
'log('=44
'pow('=45
'sqrt('=46
'cbrt('=47
'sqr('=48
'ln('=49
'sin('=50
'cos('=51
'tan('=52
'cotan('=53
'cot('=54
'sec('=55
'cosec('=56
'csc('=57
'arcsin('=58
'arccos('=59
'arctan('=60
'arccotan('=61
'arcsec('=62
'arccosec('=63
'arccsc('=64
'acsc('=65
'asin('=66
'acos('=67
'atan('=68
'acotan('=69
'asec('=70
'acosec('=71
'acot('=72
'arccot('=73
'sinh('=74
'sh('=75
'cosh('=76
'ch('=77
'tanh('=78
'th('=79
'cotanh('=80
'coth('=81
'cth('=82
'sech('=83
'sch('=84
'cosech('=85
'csch('=86
'asinh('=87
'arsinh('=88
'arsh('=89
'arcsinh('=90
'acosh('=91
'arcosh('=92
'arch('=93
'arccosh('=94
'atanh('=95
'artanh('=96
'arth('=97
'arctanh('=98
'acoth('=99
'arcoth('=100
'acotanh('=101
'arcotanh('=102
'arcth('=103
'arccotanh('=104
'asech('=105
'arsech('=106
'arsch('=107
'arcsech('=108
'acosech('=109
'arcosech('=110
'arcsch('=111
'arccosech('=112
'acsch('=113
'gamma('=114
'derivative('=115
'integral('=116
'limit('=117
'limitleft('=118
'limitright('=119
'signum('=120
'sgn('=121
'sign('=122
'abs('=123
'phi('=124
'domain('=125
'piecewise('=126
'apply('=127
'lambda('=128
Loading
Loading