Coder Social home page Coder Social logo

lubgr / tsym Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 2.0 1.21 MB

Tiny symbolic library

License: GNU General Public License v3.0

Vim Script 0.23% Shell 1.72% C++ 96.58% C 0.03% Python 0.27% CMake 0.89% Vim Snippet 0.27%
computer-algebra cpp library

tsym's People

Contributors

lubgr avatar rath3t avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tsym's Issues

generalize printing to different output schemes

The logic could be implemented in a Printer class, that is instantiated with an implementation of the interface PrintEngine. A PrintEngine has thus only one task: transforming the instructions given by Printer into some (markup) language.

Printer:

  • Numbers >= 0, Symbols, Functions, Constants, Powers are treated as 'scalars'
  • Sums, Products, Numbers < 0 are treated as 'composites'

PrintEngine methods:

  • openParentheses()
  • closeParentheses()
  • addPositiveNumber(Number)
  • addSymbol(Symbol)
  • addFunctionName(Name)
  • addPlus()
  • addMinus()
  • addUnaryMinus()
  • addTimes()
  • open/closeScalarNumerator()
  • open/closeScalarDenominator()
  • open/closeCompositeNumerator()
  • open/closeCompositeDenominator()
  • open/closeScalarExponent()
  • open/closeCompositeExponent()
  • openMultiline(int)
  • nextLine()
  • closeMultiline()
  • openMultiColumn(int)
  • nextColumn()
  • closeMultiColumn()
  • open/closeVector()
  • open/closeMatrix()
  • open/closeSquareRoot()

Implementations of PrintEngine:

  • LatexEngine
  • PlainTextEngine

add complexity measure as pure virtual Base method

  • can be used to decide whether the result of a transformation is worth storing in the cache (e.g. normalization) and maybe later on for a simplify() method
  • pure virtual and const method complexity(), returning an unsignend in Base
  • the implemented methods in Base-derived classes can e.g. return
    • Undefined 0
    • Numeric: integer 1, fraction 2, double 3
    • Constant 4
    • Symbol 5 (for both positive and non-positive)
    • Sum 5 + operands
    • Product 5 + operands
    • Power 5 + base + 2*exp
    • Function 6 + operands
  • unit tests should all be in a new test/testcomplexity.cpp

pay attention to positive symbols in order functions

When comparing two symbols with equal names, one created with a positive flag and one without, doPermute must return an appropiate order. currently, order::doPermute(aPositive, a) and order::doPermute(a, aPositive) will probably both return false, which is inconsistent.

Move PLU solution into implementation unit

The main reason for having it in a header was the intent to allow for arbitrary matrix and vector types provided by client code. While this principle should be kept, it's reasonable to copy all matrix/vector entries of the system of equations via a standard type (likely std::vector) into a Pimpl-hidden backend. This could implement the current homebrewn or more optimized, third-party functionality, without exposing the details publicly. The copying of matrix/vector entries should't hurt performance, as the expression simplifications during the solution are much more costly.

turn all *Simpl classes into free functions

These classes have no member variables and thus no state. it doesn't make sense to have them as classes. the sub-functions can be in an anonymous namespace or declared static inside of the implementation file.

refactor the Number class to a RAII wrapper

  • interface AbstractNumber with subclasses Fraction, Int, None (= undefined, but that class is already there), Double
  • possibly an infinity class
  • even a templated class is possible to allow different integer implementations?

replace SymbolRegistry by a new TmpSymbol subclass of Symbol

Probably, only the isEqual method must be overridden. The static variables for the symbol registry (even if construct-on-first-use) are unnecessary then. It's simpler, too, because the mechanism is only involved when a temporary variable is created, and not each time a symbol is instantiated. also makes the BasePtr ctors and dtor simpler.

add < and > operators to Var class

There is no consistent boolean return value, because e.g. comparing two symbols will yield an unclear result. Using the order relation of these two symbols could be a choice, but obscures the difference between comparisons of e.g. numbers (or operands which can be compared with a definite result) and symbols (or operators that can't). A new Comparison object should instead be returned.

Implementation of the actual comparison can be achieved by a lessThan method that subtracts the right hand side from the left hand side and comparing to zero. This way, automatic simplification does the work, e.g. 3ab < 4ab results into -a*b < 0, which is unclear if a and b aren't symbols with a positive flag, and true otherwise.

Public methods of the Comparison class could be isTrue(), isFalse(), isUnclear(), isTrueByOrderRelation() etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.