Click here to Skip to main content
13,864,078 members
Click here to Skip to main content

Tagged as

Stats

84K views
2.4K downloads
92 bookmarked
Posted 19 Sep 2012
Licenced CPOL

Yet Another Math Parser (YAMP)

, 30 Sep 2012
Constructing a fast math parser using Reflection to do numerics like Matlab.
YAMP
YAMPCompare
LLMathParser
MathFormula
MathParser
MathParserNet
Exceptions
MathParserTK
YAMPCompare.pidb
YAMPConsole
YAMPConsole.pidb
Exceptions
Expressions
Functions
ArgumentFunctions
LinearAlgebra
LogicFunctions
Spectroscopy
StandardFunctions
Trigonometric
Interfaces
Numerics
Decompositions
Integration
Interpolations
ODE
Optimization
Others
Solvers
Operators
AssigmentOperators
BinaryOperators
DotOperators
LogicOperators
UnaryOperators
Values
YAMP.csproj.user
YAMP.pidb
YAMP.csproj.user
YAMP.pidb
using System;
using System.Collections.Generic;
using System.Text;

namespace MathParserDataStructures
{
    /// <summary>
    /// MathParser tree node class.
    /// </summary>
    public class MathParserTreeNode  
    {

        private double _value;
        private Operation _operation;
        private Nonterminal _nodeName;

        private MathParserTreeNode _right;
        private MathParserTreeNode _left;


        #region Constructors
        public MathParserTreeNode()
            : base()
        {
            this._operation = Operation.NoOperation;
            this._nodeName = Nonterminal.NoValue;
        }
        /// <summary>
        /// Create a node with specified name.
        /// </summary>
        /// <param name="nodeName">Node's name</param>
        public MathParserTreeNode(Nonterminal nodeName)
            : this()
        {
            _nodeName = nodeName;
        }
        /// <summary>
        /// Craete a node with specified name and operation to perform.
        /// </summary>
        /// <param name="name">Node's name</param>
        /// <param name="operation">Node's operation</param>
        public MathParserTreeNode(Nonterminal nodeName, Operation operation)
            : this(nodeName)
        {
            _operation = operation;

        }
        #endregion

        #region Properties
        /// <summary>
        /// Right child
        /// </summary>
        public MathParserTreeNode Right
        {
            get
            {
                return _right;
            }
            set
            {
                _right = value;
            }
        }
        /// <summary>
        /// Left child
        /// </summary>
        public MathParserTreeNode Left
        {
            get
            {
                return _left;
            }
            set
            {
                _left = value;
            }
        }
        /// <summary>
        /// Value
        /// </summary>
        public double Value
        {
            get
            {
                return _value;
            }
            set
            {
                _value = value;
            }
        }

        /// <summary>
        /// Node's operation
        /// </summary>
        public Operation Operation
        {
            get
            {
                return _operation;
            }
            set
            {
                _operation = value;
            }
        }
        /// <summary>
        /// Node's name
        /// </summary>
        public Nonterminal Name
        {
            get
            {
                return _nodeName;
            }
            set
            {
                _nodeName = value;
            }
        }
        #endregion

        /// <summary>
        /// Add children to the current node
        /// </summary>
        /// <param name="right">Right node</param>
        /// <param name="left">Left node</param>
        public void AddChildren(MathParserTreeNode left, MathParserTreeNode right)
        {
            this._right = right;
            this._left = left;
        }
        /// <summary>
        /// Add right child.
        /// </summary>
        /// <param name="right">Child to be added</param>
        public void AddRightChild(MathParserTreeNode right)
        {
            this._right = right;
        }
        /// <summary>
        /// Add left child.
        /// </summary>
        /// <param name="left">Child to be added</param>
        public void AddLeftChild(MathParserTreeNode left)
        {
            this._left = left;
        }
       
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Florian Rappl
Architect
Germany Germany
Florian lives in Munich, Germany. He started his programming career with Perl. After programming C/C++ for some years he discovered his favorite programming language C#. He did work at Siemens as a programmer until he decided to study Physics.

During his studies he worked as an IT consultant for various companies. After graduating with a PhD in theoretical particle Physics he is working as a senior technical consultant in the field of home automation and IoT.

Florian has been giving lectures in C#, HTML5 with CSS3 and JavaScript, software design, and other topics. He is regularly giving talks at user groups, conferences, and companies. He is actively contributing to open-source projects. Florian is the maintainer of AngleSharp, a completely managed browser engine.

You may also be interested in...

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190214.1 | Last Updated 30 Sep 2012
Article Copyright 2012 by Florian Rappl
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid