-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathAddingNode.cs
More file actions
69 lines (67 loc) · 4.87 KB
/
Copy pathAddingNode.cs
File metadata and controls
69 lines (67 loc) · 4.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// Copyright (c) 2019-2022 Angouri.
// AngouriMath is licensed under MIT.
// Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.
// Website: https://am.angouri.org.
//
#pragma warning disable CS1587 // XML comment is not placed on a valid language element
/// To add a new node (function, operator) follow this guide. It covers all the methods you can
/// implement for your nodes.
///
/// 0. When choosing a file to add to between *.Continuous.Classes.cs and *.Discrete.Classes.cs, choose in the following
/// way: if your node is of the boolean type (so that can be simplified to one), it should go to
/// *.Discrete.Classes.cs, while if it's a numerical node (i. e. can be simplified to a number), it should be
/// added to *.Continuous.Classes.cs. If there's no *.*.Classes.cs, then add it to *.Classes.cs or to the
/// file you need to add.
///
/// 1. Numerical evaluation (if appropriate)
/// a. Implement real number evaluation (<see cref="AngouriMath.InternalAMExtensions.Sin"/>)
/// b. then complex number evaluation (<see cref="AngouriMath.Entity.Number.Sin"/>)
///
/// 2. Next, Add a new node representing the function as a nested type in <see cref="AngouriMath.Entity"/>
/// a. Copy record class (Press F12 -> Longest result of <see cref="AngouriMath.Entity.Sinf"/> <see cref="AngouriMath.Entity.Impliesf"/> <see cref="AngouriMath.Entity.Set.Unionf"/>)
/// b. Add instance method to Entity (Press F12 -> <see cref="AngouriMath.Entity.Sin"/>).
/// c. Add <see cref="AngouriMath.Entity.Boolean.Replace"/> to your node
/// d. Add <see cref="AngouriMath.Entity.Boolean.Priority"/> to your node
/// e. Add <see cref="AngouriMath.Entity.Boolean.InitDirectChildren"/> to your node
/// f. Add `public override string ToString() => Stringize();`. Every one of the 69 node types
/// carries this line and nothing enforces it, because the failure is not a compiler error:
/// Entity is a record, so C# synthesises ToString from PrintMembers, which prints every
/// public property -- and Evaled and InnerSimplified are public and Entity-valued, so each
/// calls ToString again. A node without the override does not print wrongly; it exhausts
/// the stack.
///
///
/// 3. A few essential methods
/// a. InnerEval and InnerSimplify (<see cref="AngouriMath.Entity.Sinf.InnerEval"/> for numerical and <see cref="AngouriMath.Entity.Andf.InnerEval"/> for boolean)
/// b. StringizeNode (<see cref="AngouriMath.Entity.Sinf.StringizeNode"/>) (and tests to CircleTest.cs).
/// It renders this node only; Entity.Stringize wraps the result in `domain(..., SET)`
/// where the codomain is not the type's default, so that is not yours to do.
/// c. LatexizeNode (<see cref="AngouriMath.Entity.Sinf.LatexizeNode"/>) (and tests to LatexTest.cs)
/// d. Limit computation (<see cref="AngouriMath.Entity.Sinf.ComputeLimitDivideEtImpera"/>) (and tests to LimitTest.cs)
/// e. Hash for sorting (<see cref="AngouriMath.Entity.Sinf.SortHashName"/>)
/// f. Default domain <see cref="AngouriMath.Entity.Sinf.Codomain"/>, and
/// <see cref="AngouriMath.Entity.Sinf.DefaultCodomain"/> beside it naming the same one.
/// Both are abstract, so a node that declares one and forgets the other does not compile.
/// g. Substitute <see cref="AngouriMath.Entity.Sinf.Substitute"/> (and tests to SubstituteTest.cs)
///
/// 4. Pattern replacer (<see cref="AngouriMath.Functions.Patterns.CommonRules"/> and <see cref="AngouriMath.Functions.Simplificator.Alternate"/>)
/// (and tests to SimplifyTest.cs or PatternTest.cs)
/// 5. Expose to the user (add it to MathS, like <see cref="AngouriMath.MathS.Sin">this</see>)
///
/// Now, you might be required to complete the following steps as well:
///
/// 6. Derivation (if applicable) (<see cref="AngouriMath.Entity.Sinf.InnerDifferentiate"/>)
/// (and tests to DerivativeTest.cs)
/// 7. Compilation (if applicable) (<see cref="AngouriMath.Entity.Sinf.CompileNode"/> and <see cref="AngouriMath.Core.FastExpression.Substitute"/>)
/// (and tests to CompilationTest.cs)
/// 8. Parser (if applicable) (See ImproveParser.md in the same folder as this file)
/// (and tests to FromStringTest.cs)
/// 9. Analytical Solver (if applicable) (<see cref="AngouriMath.Entity.Sinf.InvertNode"/>)
/// (and tests to SolveOneEquation.cs)
/// 10. ToSympy (if applicable) (<see cref="AngouriMath.Entity.Sinf.ToSymPy"/>) (Tip: Enter 'import sympy' into https://live.sympy.org/ then test)
/// (and tests to ToSymPyTest.cs)
/// 11. Name it in Core/Serialization/Entity.Serialization.cs, which is what tells System.Text.Json
/// that the node is written as its printed form. Nothing else about serialization changes -- see
/// Serialization.md in the same folder as this file. EntitySerializationTest fails if it is missed.
#pragma warning restore CS1587 // XML comment is not placed on a valid language element