libmath++-0.0.4/0000777000177600001440000000000010114643646013756 5ustar trapniusers00000000000000libmath++-0.0.4/doc/0000777000177600001440000000000010114643646014523 5ustar trapniusers00000000000000libmath++-0.0.4/doc/doxygen.conf.in0000644000177600001440000010737707447002276017472 0ustar trapniusers00000000000000# Doxyfile 1.2.14 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # General configuration options #--------------------------------------------------------------------------- # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = Math Type Library (libmath++) # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = @VERSION@ # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = . # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Brazilian, Chinese, Croatian, Czech, Danish, Dutch, Finnish, French, # German, Greek, Hungarian, Italian, Japanese, Korean, Norwegian, Polish, # Portuguese, Romanian, Russian, Slovak, Slovene, Spanish and Swedish. OUTPUT_LANGUAGE = English # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these class will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited # members of a class in the documentation of that class as if those members were # ordinary class members. Constructors, destructors and assignment operators of # the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = NO # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. It is allowed to use relative paths in the argument list. STRIP_FROM_PATH = # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower case letters. If set to YES upper case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # users are adviced to set this option to NO. CASE_SENSE_NAMES = YES # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like the Qt-style comments (thus requiring an # explict @brief command for a brief description. JAVADOC_AUTOBRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # reimplements. INHERIT_DOCS = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 4 # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consist of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. # For instance some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = @top_srcdir@/math++ # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp # *.h++ *.idl *.odl FILE_PATTERNS = *.h # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories # that are symbolic links (a Unix filesystem feature) are excluded from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. EXCLUDE_PATTERNS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. INPUT_FILTER = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse. FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = YES # If the REFERENCED_BY_RELATION tag is set to YES (the default) # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES (the default) # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = T #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = user-api # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compressed HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the Html help documentation and to the tree view. TOC_EXPAND = NO # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be # generated containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript and frames is required (for instance Mozilla, Netscape 4.0+, # or Internet explorer 4.0+). Note that for large projects the tree generation # can take a very long time. In such cases it is better to disable this feature. # Windows users are probably better off using the HTML help feature. GENERATE_TREEVIEW = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimised for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assigments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_XML = NO #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_PREDEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line and do not end with a semicolon. Such function macros are typically # used for boiler-plate code, and will confuse the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::addtions related to external references #--------------------------------------------------------------------------- # The TAGFILES tag can be used to specify one or more tagfiles. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in Html, RTF and LaTeX) for classes with base or # super classes. Setting the tag to NO turns the diagrams off. Note that this # option is superceded by the HAVE_DOT option below. This is only a fallback. It is # recommended to install and use dot, since it yield more powerful graphs. CLASS_DIAGRAMS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = YES # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are gif, jpg, and png # If left blank gif will be used. DOT_IMAGE_FORMAT = gif # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found on the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_WIDTH = 1024 # The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_HEIGHT = 1024 # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermedate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::addtions related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO # The CGI_NAME tag should be the name of the CGI script that # starts the search engine (doxysearch) with the correct parameters. # A script with this name will be generated by doxygen. CGI_NAME = search.cgi # The CGI_URL tag should be the absolute URL to the directory where the # cgi binaries are located. See the documentation of your http daemon for # details. CGI_URL = # The DOC_URL tag should be the absolute URL to the directory where the # documentation is located. If left blank the absolute path to the # documentation, with file:// prepended to it, will be used. DOC_URL = # The DOC_ABSPATH tag should be the absolute path to the directory where the # documentation is located. If left blank the directory on the local machine # will be used. DOC_ABSPATH = # The BIN_ABSPATH tag must point to the directory where the doxysearch binary # is installed. BIN_ABSPATH = /usr/local/bin/ # The EXT_DOC_PATHS tag can be used to specify one or more paths to # documentation generated for other projects. This allows doxysearch to search # the documentation for these projects as well. EXT_DOC_PATHS = libmath++-0.0.4/doc/Makefile.am0000644000177600001440000000007707447002276016562 0ustar trapniusers00000000000000 api-doc: doxygen doxygen.conf clean-local: rm -rf user-api libmath++-0.0.4/AUTHORS0000644000177600001440000000006707447002276015030 0ustar trapniusers00000000000000Christian Parpart (SurakWare) libmath++-0.0.4/NEWS0000644000177600001440000000004707454401503014447 0ustar trapniusers00000000000000 May the NEWS here be with you ;) libmath++-0.0.4/TODO0000644000177600001440000000344007460343201014435 0ustar trapniusers00000000000000( sorry, but my english is neither as good as my math nor as my c++ ;) Bugs and Implementation Todos: * Improve EReadError exception handling (move to integer for error status and a list of error-specific data e.g. the expected token, or the remaining expression string) * Improve the TReader<>::readNumber() method to prevent wrong input and parse exponential notations, too. * Design/implementation of an expression matching module will may be used for manipulating expressions (e.g. for simplifying/derivations/...) * design of an scripting system for solving and visualization(!) of mathematical problems (think about its file format (.mp/.math/...?) (and design for its KPart Viewer implementation) * simplifier: + and * gets a help method for matching left and right: // pseudo example: if (TSMatch *m = sMatch(, )) { // m->left and m->right gets auto assigned by sMatch // according to the match functions above return new TAnother(m->left->clone(), m->right->clone()); } Feature ToDos: Folgende Module _muessen_ noch designed/implementiert werden: * symbolische Errechnung von Definitions-/ Wertebereichen und Definitionsluecken. (numeric_set<>???) * symbolische Grenzwertberechnung an Definitionsluecken und im Unendlichen * symbolischen Differenziale Generation (derive) * symbolischen Integrale Generation (integral) * Vereinfachung von mathematischen Ausdruecken (simplify) * Expandierung von mathematischen Ausdruecken (d.h. Reduzierung auf den Grad 1, soweit moeglich) * Scripting System zur Loesung und Visualisierung mathematischer Probleme * WishList: * Kaesetorte ;-P (*hehe*, cheese cake?) * libmath++-0.0.4/COPYING0000644000177600001440000004312707447002276015017 0ustar trapniusers00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. libmath++-0.0.4/examples/0000777000177600001440000000000010114643646015574 5ustar trapniusers00000000000000libmath++-0.0.4/examples/i2.cpp0000644000177600001440000000223307465720252016612 0ustar trapniusers00000000000000// Operand Iterator Example (/src/examples/i2.cpp) #include #include #include #include #include #include int main(int argc, char *argv[]) { std::cout << "Operand Iterator example program (i1)" << std::endl; try { std::string exprStr(argc == 2 ? argv[1] : "1*2 + (3 + 4) + 5*1 + 6 + 1*7"); std::auto_ptr >expr(math::TReader::parse(exprStr)); std::cout << "input string: " << exprStr << std::endl << "reproduction: " << math::TPrinter::print(expr.get()) << std::endl; std::cout << "iterating expression tree by operands:" << std::endl; for (math::TNode::operand_iterator i(expr.get()); i != i.end(); ++i) { std::cout << "current node: " << math::TPrinter::print(i.get()) << std::endl; } } catch (const math::EMath& e) { std::cout << "exception caught: " << e.reason() << std::endl; return 1; } catch (...) { return 1; } return 0; } libmath++-0.0.4/examples/d2.cpp0000644000177600001440000000216307464253620016606 0ustar trapniusers00000000000000 #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { std::cout << "Expression Simplifier example program (i1)" << std::endl; try { std::string exprStr(argc == 2 ? argv[1] : "x^x"); std::auto_ptr >expr(math::TReader::parse(exprStr)); std::cout << "original : " << math::TPrinter::print(expr.get()) << std::endl; for (int n = 1; n <= 4; ++n) { std::auto_ptr >den(math::derive(expr.get(), n)); std::cout << n << ". derivation : " << math::TPrinter::print(den.get()) << std::endl; } } catch (const math::EMath& e) { std::cout << "exception caught: " << e.reason() << std::endl; return 1; } catch (...) { std::cout << "further exception caught." << std::endl; return 1; } return 0; } libmath++-0.0.4/examples/e1.cpp0000644000177600001440000000117707460205125016603 0ustar trapniusers00000000000000 #include #include #include #include int main() { std::cout << "Expression Manipulation example program (e1)" << std::endl; // 2 + 3 * 4 std::auto_ptr > e( new math::TPlusNode( new math::TNumberNode(2), new math::TMulNode( new math::TNumberNode(3), new math::TNumberNode(4) ) ) ); std::cout << "reproduction : "; math::TPrinter::printOn(std::cout, e.get()); std::cout << std::endl; return 0; } libmath++-0.0.4/examples/i1.cpp0000644000177600001440000000200507453640203016600 0ustar trapniusers00000000000000 #include #include #include #include #include #include int main(int argc, char *argv[]) { std::cout << "Expression Tree Iterator example program (i1)" << std::endl; try { std::string exprStr(argc == 2 ? argv[1] : "2 + 3 + 4 + 5 + 6"); std::auto_ptr >expr(math::TReader::parse(exprStr)); std::cout << "reproduction: "; math::TPrinter::printOn(std::cout, expr.get()); std::cout << std::endl; // now the iteration test for (math::TNode::iterator i = expr->begin(); i != expr->end(); ++i) { std::cout << "current node: " << math::TPrinter::print(i.get()) << std::endl; } } catch (const math::EReadError& e) { std::cout << "exception caught: " << e.reason() << std::endl; return 1; } catch (...) { return 1; } return 0; } libmath++-0.0.4/examples/s1.cpp0000644000177600001440000000203007460205125016606 0ustar trapniusers00000000000000 #include #include #include #include #include #include int main(int argc, char *argv[]) { std::cout << "Expression Simplifier example program (i1)" << std::endl; try { std::string exprStr(argc == 2 ? argv[1] : "2 + 3 + 4 + 5 + 6"); std::auto_ptr >expr(math::TReader::parse(exprStr)); std::cout << "original : " << math::TPrinter::print(expr.get()) << std::endl; std::auto_ptr >se(math::TSimplifier::simplify(expr.get())); std::cout << "simplified : " << math::TPrinter::print(se.get()) << std::endl; } catch (const math::EMath& e) { std::cout << "exception caught: " << e.reason() << std::endl; return 1; } catch (...) { std::cout << "further exception caught." << std::endl; return 1; } return 0; } libmath++-0.0.4/examples/d1.cpp0000644000177600001440000000240407463031100016565 0ustar trapniusers00000000000000 #include #include #include #include #include #include #include int main(int argc, char *argv[]) { std::cout << "Expression Simplifier example program (i1)" << std::endl; try { std::string exprStr(argc == 2 ? argv[1] : "x^x"); std::auto_ptr >expr(math::TReader::parse(exprStr)); std::cout << "original : " << math::TPrinter::print(expr.get()) << std::endl; std::auto_ptr >de(math::TDeriver::derive(expr.get())); std::cout << "derivation : " << math::TPrinter::print(de.get()) << std::endl; std::auto_ptr >sde(math::TSimplifier::simplify(de.get())); std::cout << "simplified : " << math::TPrinter::print(sde.get()) << std::endl; } catch (const math::EMath& e) { std::cout << "exception caught: " << e.reason() << std::endl; return 1; } catch (...) { std::cout << "further exception caught." << std::endl; return 1; } return 0; } libmath++-0.0.4/examples/r1.cpp0000644000177600001440000000131307460205125016610 0ustar trapniusers00000000000000 #include #include #include #include #include int main(int argc, char *argv[]) { std::cout << "Expression Reader example program (r1)" << std::endl; try { std::string exprStr(argc == 2 ? argv[1] : "2 + 3 * 4"); std::auto_ptr >expr(math::TReader::parse(exprStr)); std::cout << "reproduction: " << math::TPrinter::print(expr.get()) << std::endl; } catch (const math::EMath& e) { std::cout << "exception caught: " << e.reason() << std::endl; return 1; } catch (...) { return 1; } return 0; } libmath++-0.0.4/examples/Makefile.am0000644000177600001440000000050410114643621017614 0ustar trapniusers00000000000000#include $(top_srcdir)/niceprint.mak AM_CXXFLAGS = -pedantic -ansi -Wall -Wno-long-long LIBS = ../math++/libmath++.la noinst_PROGRAMS = e1 r1 d1 d2 i1 i2 s1 f1 e1_SOURCES = e1.cpp r1_SOURCES = r1.cpp d1_SOURCES = d1.cpp d2_SOURCES = d2.cpp i1_SOURCES = i1.cpp i2_SOURCES = i2.cpp s1_SOURCES = s1.cpp f1_SOURCES = f1.cpp libmath++-0.0.4/examples/f1.cpp0000644000177600001440000000436707464265431016622 0ustar trapniusers00000000000000 #include #include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { std::cout << "Function Library example program (l1)" << std::endl; try { math::TLibrary library; library.insert(math::TConstant("e", 2.1718));// M_E)); library.insert(math::TConstant("pi", 3.1415));// M_PI)); library.insert(math::TFunction("sig", "IF(x < 0, -1, 1)")); library.insert(math::TFunction("fib", "IF(x <= 1, 1, x + fib(x - 1))")); std::cout << library.function("sig") << std::endl << library.function("fib") << std::endl; math::TFunction f("f", "sig(x)"); std::cout << f << std::endl << "\tf(-pi)=" << f.call(-library.value("pi"), library) << std::endl << "\tf(+pi)=" << f.call(+library.value("pi"), library) << std::endl; math::TFunction g("g", "fib(x)"); std::cout << g << std::endl; for (int n = 1; n <= 5; ++n) std::cout << "\tg(" << n << ")=" << g.call(n, library) << std::endl; math::TFunction h("h", "pi^sin(x/e)"); std::cout << h << std::endl << "\th(3)=" << h.call(3, library) << std::endl; if (argc == 3) { math::TFunction u("u", argv[1]); std::cout << u << std::endl << "\tu(" << argv[2] << ")=" << u.call(math::calculate(argv[2]), library) << std::endl; } else std::cout << "You may also try your own function if you enter" << std::endl << "an EXPRESSION followed by an test argument as parameter to f1." << std::endl; } catch (const math::EMath& e) { std::cout << "exception caught: " << e.reason() << std::endl; return 1; } catch (const char *AMsg) { std::cout << "exception caught: " << AMsg << std::endl; return 2; } catch (...) { std::cout << "further exception caught." << std::endl; return 3; } return 0; } libmath++-0.0.4/INSTALL0000644000177600001440000001722707447002276015017 0ustar trapniusers00000000000000Basic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.in' is used to create `configure' by a program called `autoconf'. You only need `configure.in' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not supports the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the `--host=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name with three fields: CPU-COMPANY-SYSTEM See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are building compiler tools for cross-compiling, you can also use the `--target=TYPE' option to select the type of system they will produce code for and the `--build=TYPE' option to select the type of system on which you are compiling the package. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options. libmath++-0.0.4/configure.in0000644000177600001440000000151607510220561016257 0ustar trapniusers00000000000000AC_INIT(math++/reader.tcc) MATH_MAJOR_VERSION=0 MATH_MINOR_VERSION=0 MATH_MICRO_VERSION=3 MATH_VERSION=$MATH_MAJOR_VERSION.$MATH_MINOR_VERSION.$MATH_MICRO_VERSION MATH_VERSION_INFO=`expr $MATH_MAJOR_VERSION + $MATH_MINOR_VERSION`:$MATH_MICRO_VERSION:$MATH_MINOR_VERSION MATH_VERSION_NUMBER=`expr $MATH_MAJOR_VERSION \* 10000 + $MATH_MINOR_VERSION \* 100 + $MATH_MICRO_VERSION` AC_SUBST(MATH_MAJOR_VERSION) AC_SUBST(MATH_MINOR_VERSION) AC_SUBST(MATH_MICRO_VERSION) AC_SUBST(MATH_VERSION) AC_SUBST(MATH_VERSION_INFO) AC_SUBST(MATH_VERSION_NUMBER) VERSION=${MATH_VERSION} AM_INIT_AUTOMAKE(libmath++, $VERSION) AM_CONFIG_HEADER(config.h) AC_LANG_CPLUSPLUS AC_PROG_CXX AM_PROG_LIBTOOL AC_STDC_HEADERS AC_CHECK_HEADERS(string cstring) AC_OUTPUT([ Makefile math++/Makefile examples/Makefile doc/Makefile doc/doxygen.conf ]) libmath++-0.0.4/README0000644000177600001440000000151307463436733014644 0ustar trapniusers00000000000000 Hi reader, This is my Math Type Library (MTL) and is part of the SurakWare Projects. If you believe that this package is out of date have a look at http://www.surakware.net/downloads/index.xml I am using GCC/3.0.3 with automake/1.5 and autoconf/2.50 (and doxygen 1.2.14). You'll perhaps need these things too if you wanna get the same results as me;) GCC/3.x is a must since it is really more standard compliant than its prio versions. However, I'll try to code it backward compatible (using #ifdefs). For building that package the first time you may execute the script bootstrap. However, you shall read that script before you do execute it. To create the user API-documentation, call make using parameter api-doc at top source dir or in the doc directory itself. > make api-doc Thanks, Christian Parpart http://www.surakware.net libmath++-0.0.4/niceprint.mak0000644000177600001440000000176207447002276016450 0ustar trapniusers00000000000000########################################################################## ### modified print look for gmake output (generic) ### written by Christian Parpart (SurakWare) ########################################################################## LTCXXCOMPILE = $(LIBTOOL) --quiet --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) CXXLINK = \ @echo "creating $@:"; \ $(LIBTOOL) --quiet --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ .cpp.o: @echo "compiling $<:" @source='$<' object='$@' libtool=no \ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' \ $(CXXDEPMODE) $(depcomp) \ $(CXXCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< .cpp.lo: @echo "compiling $<:" @source='$<' object='$@' libtool=yes \ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' \ $(CXXDEPMODE) $(depcomp) \ $(LTCXXCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< libmath++-0.0.4/math++/0000777000177600001440000000000010114643646015035 5ustar trapniusers00000000000000libmath++-0.0.4/math++/utils.h0000644000177600001440000000722207461145606016351 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: utils.h,v 1.5 2002/04/23 02:48:38 cparpart Exp $ // (This file contains the interface to some utility methods) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_utils_h #define libmath_utils_h #include #include #include namespace math { template class TNode; template class TLibrary; /** * isPrime returns true if ANumber is a prime number, otherwise false */ bool isPrime(unsigned ANumber); /** * primeCount returns the number of primes (APrime) in ANumber. * If APrime isn't any prime number then it's returns 0 otherwise the count. */ unsigned primeCount(unsigned long long ANumber, unsigned long long APrime); /** * calculates the prim factors for given number (ANumber). * as result it is returns the number of prim factors in the * given numbers and stored in the AResult vector. * * The result structure is designed as follows: * first value of a pair is the prim factor. * second value of a pair is the number of occurence. */ unsigned factorize(unsigned long long ANumber, std::vector >& AResult); /** * Factorizes the given number (ANumber) and returns its result * as a well formatted string. */ std::string factorize(unsigned long long ANumber); /** * Simply returns calculates expression (AExpression) without usage of * any library. */ template T calculate(const std::string& AExpression); /** * Simply returns calculates expression (AExpression). */ template T calculate(const std::string& AExpression, const TLibrary&); /** * This method derivates given expression, AExpression, ACount times. * and returns its result. */ template TNode *derive(const TNode *AExpression, unsigned ACount = 1); /** * simplifies given expression * example: x*x + 2*pi + x*pi = x^2 + pi * (x + 2) */ template TNode *simplify(const TNode *AExpression); /** * expands an expression. * example: 3x^4-2x^2+1 = x*x*x*x + x*x*x*x + x*x*x*x - x*x - x*x + 1 */ template TNode *expand(const TNode *AExpression); /** * clones given expression by calling its clone routine */ template TNode *copyOf(const TNode *AExpression); /** * Creates an expression tree equivalent to given input. */ template TNode *createTree(const std::string& AExprStr); /** * Creates the "umkehrfunktion" of given input tree. */ template TNode *umkehrfunktion(const TNode *ATree); /** * Creates the integral of given input tree. */ template TNode *integral(const TNode *ATree); } // namespace math #include #endif libmath++-0.0.4/math++/printer.h0000644000177600001440000000577407460205471016702 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: printer.h,v 1.5 2002/04/20 06:31:21 cparpart Exp $ // (This file contains the expression stream printer specific interface) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_printer_h #define libmath_printer_h #include #include namespace math { /** * The TPrinter<> visitor class implements stream printing for * for the expression tree. Use the static printOn method to print. */ template class TPrinter : public TNodeVisitor { private: std::ostream& FStream; TPrinter(std::ostream& AOutput); /// save print takes additionally care about brackets to be printed void savePrint(const TNode *ANode, const TNode *AParent); virtual void visit(TNumberNode *); virtual void visit(TSymbolNode *); virtual void visit(TParamNode *); virtual void visit(TPlusNode *); virtual void visit(TNegNode *); virtual void visit(TMulNode *); virtual void visit(TDivNode *); virtual void visit(TPowNode *); virtual void visit(TSqrtNode *); virtual void visit(TSinNode *); virtual void visit(TCosNode *); virtual void visit(TTanNode *); virtual void visit(TLnNode *); virtual void visit(TFuncNode *); virtual void visit(TIfNode *); virtual void visit(TEquNode *); virtual void visit(TUnEquNode *); virtual void visit(TGreaterNode *); virtual void visit(TLessNode *); virtual void visit(TGreaterEquNode *); virtual void visit(TLessEquNode *); public: /** * printOn prints given expression, AExpr, to the given output stream AOutput. */ static void printOn(std::ostream& AOutput, const TNode *AExpr); /** * print prints given expression, AExpr, into a std::string and returns * its value.
* This is just a wrapper method to printon with std::ostringstream, * but often used. */ static std::string print(const TNode *AExpr); }; } // namespace math #include #endif libmath++-0.0.4/math++/simplifier.tcc0000644000177600001440000004445007465207045017702 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: simplifier.tcc,v 1.9 2002/05/05 10:49:09 cparpart Exp $ // (This file contains the expression simplifier template members) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_simplifier_h #error You may not include math++/simplify.tcc directly; include math++/simplify.h instead. #endif #include #include #include namespace math { template bool isConst(const TNode *ANode) { // note, that symbols may not be interpreted as const here, even if they're return !ANode || (ANode->nodeType() != TNode::PARAM_NODE && ANode->nodeType() != TNode::SYMBOL_NODE && ANode->nodeType() < TNode::FUNC_NODE && isConst(ANode->left()) && isConst(ANode->right())); } template TNode *TSimplifier::simplify(const TNode *AExpression) { TNode *oldResult = 0; TNode *newResult = AExpression->clone(); do { delete oldResult; oldResult = newResult; TSimplifier simplifier; oldResult->accept(simplifier); newResult = simplifier.FResult; } while (*newResult != *oldResult); delete oldResult; return newResult; } template TSimplifier::TSimplifier() : FResult(0) { } template T TSimplifier::calculate(const TNode *AExpr) const { static TLibrary library; if (!library.constants()) { library.insert(TConstant("pi", 3.1415));// M_PI)); // just in case they're used. :) library.insert(TConstant("e", 2.1718));// M_E)); } return TCalculator::calculate(TFunction("tmp", AExpr), T(), library); } template void TSimplifier::visit(TNumberNode *ANode) { // (-number) = -(number) T value(ANode->number()); if (value < 0) { FResult = new TNegNode( new TNumberNode(-value) ); return; } FResult = ANode->clone(); } template void TSimplifier::visit(TSymbolNode *ANode) { FResult = ANode->clone(); } template void TSimplifier::visit(TParamNode *ANode) { FResult = ANode->clone(); } template void TSimplifier::visit(TPlusNode *ANode) { std::auto_ptr > left(simplify(ANode->left())); std::auto_ptr > right(simplify(ANode->right())); // check constness if (isConst(left.get()) && isConst(right.get())) { // Do not use simple calculate(ANode): FResult = new TNumberNode(calculate(left.get()) + calculate(right.get())); return; } // 0+a = a if (left->nodeType() == TNode::NUMBER_NODE && calculate(left.get()) == T(0)) { FResult = right->clone(); return; } // a+0 = a if (right->nodeType() == TNode::NUMBER_NODE && calculate(right.get()) == T(0)) { FResult = left->clone(); return; } // a+(-0) = a if (right->nodeType() == TNode::NEG_NODE && right->right()->nodeType() == TNode::NUMBER_NODE && calculate(right->right()) == T(0)) { FResult = left->clone(); return; } // a + a = 2a if (*left == *right) { FResult = new TMulNode( new TNumberNode(T(2)), right->clone() ); return; } // a + (-a) = 0 if (right->nodeType() == TNode::NEG_NODE && *left == *right->right()) { FResult = new TNumberNode(T(0)); return; } // (a + b) + (-b) = b if (left->nodeType() == TNode::PLUS_NODE && right->nodeType() == TNode::NEG_NODE && *left->right() == *right->right()) { FResult = left->left()->clone(); return; } // a + -(a + b) = -b if (right->nodeType() == TNode::NEG_NODE && right->right()->nodeType() == TNode::PLUS_NODE && *left == *right->right()->left()) { FResult = new TNegNode( right->right()->right()->clone() ); return; } // (-a) + (-b) = -(a + b) if (left->nodeType() == TNode::NEG_NODE) { if (right->nodeType() == TNode::NEG_NODE) { FResult = new TNegNode( new TPlusNode( left->right()->clone(), right->right()->clone() ) ); } else { // (-a) + b = b + (-a) FORM TRANSFORMATION FResult = new TPlusNode( right->clone(), left->clone() ); } return; } // n * a + a = a(n + 1) if (left->nodeType() == TNode::MUL_NODE && *left->right() == *right) { FResult = new TMulNode( right->clone(), new TPlusNode( left->left()->clone(), new TNumberNode(T(1)) ) ); return; } // a*b + a*c = a(b + c) if (left->nodeType() == TNode::MUL_NODE && right->nodeType() == TNode::MUL_NODE && *left->left() == *right->left()) { FResult = new TMulNode( left->left()->clone(), new TPlusNode( left->right()->clone(), right->right()->clone() ) ); return; } // a*b + a*c = a*b + c*a = b*a + a*c = b*a + c*a = a(b + c) // WE MUST FIND AN ALGORITHM FOR GENERIC PATTERN MATCHING SOON !!! // (f * g) + (f / h) = f * (g + 1/h) if (left->nodeType() == TNode::MUL_NODE && right->nodeType() == TNode::DIV_NODE && *left->left() == *right->left()) { FResult = new TMulNode( left->left()->clone(), new TPlusNode( left->right()->clone(), new TDivNode( new TNumberNode(T(1)), right->right()->clone() ) ) ); return; } // nothing special found, just optimized left and right child nodes FResult = new TPlusNode(left->clone(), right->clone()); } template void TSimplifier::visit(TNegNode *ANode) { std::auto_ptr > node(simplify(ANode->node())); // -(-a) = a if (node->nodeType() == TNode::NEG_NODE) { FResult = node->right()->clone(); return; } // nothing special found, just optimized left and right child nodes FResult = new TNegNode(node->clone()); } template void TSimplifier::visit(TMulNode *ANode) { std::auto_ptr > left(simplify(ANode->left())); std::auto_ptr > right(simplify(ANode->right())); // check constness if (isConst(left.get()) && isConst(right.get())) { FResult = new TNumberNode(calculate(ANode)); return; } // 0*a = 0 if (left->nodeType() == TNode::NUMBER_NODE && calculate(left.get()) == T(0)) { FResult = new TNumberNode(T(0)); return; } // a*0 = 0 if (right->nodeType() == TNode::NUMBER_NODE && calculate(right.get()) == T()) { FResult = new TNumberNode(T(0)); return; } // 1*a = a, a if (left->nodeType() == TNode::NUMBER_NODE && calculate(left.get()) == T(1)) { FResult = right->clone(); return; } // a*1 = a, a if (right->nodeType() == TNode::NUMBER_NODE && calculate(right.get()) == T(1)) { FResult = left->clone(); return; } // a*a = a^2 if (*left == *right) { FResult = new TPowNode(left->clone(), new TNumberNode(T(2))); return; } // (-a) * b = -(a * b) if (left->nodeType() == TNode::NEG_NODE) { FResult = new TNegNode( new TMulNode( left->right()->clone(), right->clone() ) ); return; } // a * (-b) = -(a * b) if (right->nodeType() == TNode::NEG_NODE) { FResult = new TNegNode( new TMulNode( left->clone(), right->right()->clone() ) ); return; } // a^n*a = a^(n+1) if (left->nodeType() == TNode::POW_NODE && *left->left() == *right) { FResult = new TPowNode( right->clone(), new TPlusNode( left->right()->clone(), new TNumberNode(T(1)) ) ); return; } // (C*a)*D = (C*D)*a; C, D const. if (left->nodeType() == TNode::MUL_NODE && isConst(left->left()) && isConst(right.get())) { FResult = new TMulNode( new TNumberNode( T(calculate(left->left()) * calculate(right.get())) ), left->right()->clone() ); return; } // (a*b)*b = a*b^2 if (left->nodeType() == TNode::MUL_NODE && *left->right() == *right.get()) { FResult = new TMulNode( left->left()->clone(), new TPowNode( right->clone(), new TNumberNode(T(2)) ) ); return; } // (a*b)*a = b*a^2 if (left->nodeType() == TNode::MUL_NODE && *left->left() == *right.get()) { FResult = new TMulNode( left->right()->clone(), new TPowNode( right->clone(), new TNumberNode(T(2)) ) ); return; } // (a * b) * b^c = a * b^(c + 1) if (left->nodeType() == TNode::MUL_NODE && right->nodeType() == TNode::POW_NODE && *left->right() == *right->left()) { FResult = new TMulNode( left->left()->clone(), new TPowNode( left->right()->clone(), new TPlusNode( right->right()->clone(), new TNumberNode(T(1)) ) ) ); return; } // a^b*c/a = c*a^(b - 1) if (left->nodeType() == TNode::POW_NODE && right->nodeType() == TNode::DIV_NODE && *left->left() == *right->right()) { FResult = new TMulNode( right->left()->clone(), new TPowNode( left->left()->clone(), new TPlusNode( left->right()->clone(), new TNegNode(new TNumberNode(T(1))) ) ) ); return; } // (a/b)*c = (a*c)/b if (left->nodeType() == TNode::DIV_NODE) { FResult = new TDivNode( new TMulNode( left->left()->clone(), right->clone() ), left->right()->clone() ); return; } // a * a^b = a^(b+1) if (right->nodeType() == TNode::POW_NODE && *left == *right->left()) { FResult = new TPowNode( left->clone(), new TPlusNode( right->right()->clone(), new TNumberNode(T(1)) ) ); return; } // nothing special found, just optimized left and right child nodes FResult = new TMulNode(left->clone(), right->clone()); } template void TSimplifier::visit(TDivNode *ANode) { std::auto_ptr > left(simplify(ANode->left())); std::auto_ptr > right(simplify(ANode->right())); // check constness if (isConst(left.get()) && isConst(right.get())) { T divisor(calculate(right.get())); if (divisor == T(0)) // prevent division by zero, by no simplifying FResult = new TDivNode(left->clone(), right->clone()); else FResult = new TNumberNode(calculate(left.get()) / divisor); return; } // 0/a = 0 if (left->nodeType() == TNode::NUMBER_NODE && calculate(left.get()) == T(0)) { FResult = new TNumberNode(T(0)); return; } // a / a = 1 if (*left == *right) { FResult = new TNumberNode(T(1)); return; } // (-a) / b = -(a / b) FORM TRANSFORMATION if (left->nodeType() == TNode::NEG_NODE) { FResult = new TNegNode( new TDivNode( left->right()->clone(), right->clone() ) ); return; } // (a * b) / c = a * (b / c) FORM TRANSFORMATION if (left->nodeType() == TNode::MUL_NODE) { FResult = new TMulNode( left->left()->clone(), new TDivNode( left->right()->clone(), right->clone() ) ); return; } // a / (-b) = -(a / b) FORM TRANSFORMATION if (right->nodeType() == TNode::NEG_NODE) { FResult = new TNegNode( new TDivNode( left->clone(), right->right()->clone() ) ); return; } // a / b^c = a * b^(-c) if (right->nodeType() == TNode::POW_NODE) { FResult = new TMulNode( left->clone(), new TPowNode( right->left()->clone(), new TNegNode( right->right()->clone() ) ) ); return; } // (a^b)/a = a^(b-1) if (left->nodeType() == TNode::POW_NODE && *left->left() == *right.get()) { FResult = new TPowNode( right->clone(), new TPlusNode( left->right()->clone(), new TNegNode(new TNumberNode(T(1))) ) ); return; } // a^b / a^c = a^(b-c) if (left->nodeType() == TNode::POW_NODE && right->nodeType() == TNode::POW_NODE && *left->left() == *right->left()) { FResult = new TPowNode( left->left()->clone(), new TPlusNode( left->right()->clone(), new TNegNode(right->right()->clone()) ) ); return; } // nothing special found, just optimized left and right child nodes FResult = new TDivNode(left->clone(), right->clone()); } template void TSimplifier::visit(TPowNode *ANode) { std::auto_ptr > left(simplify(ANode->left())); std::auto_ptr > right(simplify(ANode->right())); // check constness if (isConst(left.get()) && isConst(right.get())) { FResult = new TNumberNode(calculate(ANode)); return; } // a^0 = 1 if (right->nodeType() == TNode::NUMBER_NODE && calculate(right.get()) == 0) { FResult = new TNumberNode(1); return; } // a^1 = a if (right->nodeType() == TNode::NUMBER_NODE && calculate(right.get()) == 1) { FResult = left->clone(); return; } // f^g^h = f^(g * h) if (left->nodeType() == TNode::POW_NODE) { FResult = new TPowNode( left->left()->clone(), new TMulNode( left->right()->clone(), right->clone() ) ); return; } // nothing special found, just optimized left and right child nodes FResult = new TPowNode(left->clone(), right->clone()); } template void TSimplifier::visit(TSqrtNode *ANode) { FResult = ANode->clone(); } template void TSimplifier::visit(TSinNode *ANode) { FResult = new TSinNode(simplify(ANode->right())); } template void TSimplifier::visit(TCosNode *ANode) { FResult = new TCosNode(simplify(ANode->right())); } template void TSimplifier::visit(TTanNode *ANode) { FResult = new TTanNode(simplify(ANode->right())); } template void TSimplifier::visit(TLnNode *ANode) { std::auto_ptr > node(simplify(ANode->node())); // ln(e) = 1 if (node->nodeType() == TNode::SYMBOL_NODE && static_cast *>(node.get())->symbol() == "e") { FResult = new TNumberNode(T(1)); return; } FResult = new TLnNode(node->clone()); } template void TSimplifier::visit(TFuncNode *ANode) { FResult = new TFuncNode(ANode->name(), simplify(ANode->node())); } template void TSimplifier::visit(TIfNode *ANode) { FResult = new TIfNode(simplify(ANode->condition()), simplify(ANode->trueExpr()), simplify(ANode->falseExpr())); } template void TSimplifier::visit(TEquNode *ANode) { FResult = new TEquNode(simplify(ANode->left()), simplify(ANode->right())); } template void TSimplifier::visit(TUnEquNode *ANode) { FResult = new TUnEquNode(simplify(ANode->left()), simplify(ANode->right())); } template void TSimplifier::visit(TGreaterNode *ANode) { FResult = new TGreaterNode(simplify(ANode->left()), simplify(ANode->right())); } template void TSimplifier::visit(TLessNode *ANode) { FResult = new TLessNode(simplify(ANode->left()), simplify(ANode->right())); } template void TSimplifier::visit(TGreaterEquNode *ANode) { FResult = new TGreaterEquNode(simplify(ANode->left()), simplify(ANode->right())); } template void TSimplifier::visit(TLessEquNode *ANode) { FResult = new TLessEquNode(simplify(ANode->left()), simplify(ANode->right())); } } // namespace math libmath++-0.0.4/math++/t1.cpp0000644000177600001440000000577107465721125016077 0ustar trapniusers00000000000000 #include #include #include #include #include #include #include #include //#include #include #include #include int main(int argc, char *argv[]) { try { #if 0 #if 0 math::TBigInteger a(1); math::TBigInteger b(2); math::TBigInteger c("3"); math::TBigInteger d("3.1415"); math::TBigInteger r(a + b); std::cout << a << std::endl << b << std::endl << c << std::endl << d << std::endl << r << std::endl << "--------------------" << std::endl << std::endl; #endif math::TLibrary library; library.insert(math::TConstant("e", 2.1718));//M_E)); library.insert(math::TConstant("pi", 3.1415));//M_PI)); library.insert(math::TFunction("sig", "IF(x < 0, -1, 1)")); library.insert(math::TFunction("fib", "IF(x <= 1, 1, x + fib(x - 1))")); std::cout << library.function("sig") << std::endl << library.function("fib") << std::endl; math::TFunction f("f", "sig(x)"); std::cout << f << std::endl << "\tf(-pi)=" << f.call(-library.value("pi"), library) << std::endl << "\tf(+pi)=" << f.call(+library.value("pi"), library) << std::endl; math::TFunction g("g", "fib(x)"); std::cout << g << std::endl; for (int n = 1; n <= 5; ++n) std::cout << "\tg(" << n << ")=" << g.call(n, library) << std::endl; math::TFunction h("h", "pi^sin(x/e)"); std::cout << h << std::endl << "\th(3)=" << h.call(3, library) << std::endl; #else #if 1 math::TMatchRegistry FMatchReg; // "a^2 + 2ab + b^2 + $0" = "(a + b)^2 + $0" math::TMatch *match = new math::TPlusMatch( new math::TPowMatch( new math::TAnyMatch("a"), new math::TNumMatch(2) ), new math::TMulMatch( new math::TNumMatch(2), new math::TAnyMatch("a"), new math::TAnyMatch("b"), 0 /* mark end of list */ ), new math::TPowMatch( new math::TAnyMatch("b"), new math::TNumMatch(2) ), 0 /* mark end of list */ ); delete match; #endif #endif } catch (const math::EMath& e) { std::cout << "exception caught: " << e.reason() << std::endl; return 1; } catch (const char *AMsg) { std::cout << "exception caught: " << AMsg << std::endl; return 2; } catch (...) { std::cout << "further exception caught." << std::endl; return 3; } return 0; } libmath++-0.0.4/math++/error.h0000644000177600001440000000305307510216353016331 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: error.h,v 1.2 2002/07/02 03:24:27 cparpart Exp $ // (This file contains the error specific interface for libmath) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_error_h #define libmath_error_h #include namespace math { /** * EMath is the base class for all libmath++ error classes. * The derivations of EMath may be found in its corresponding modules. */ class EMath { private: std::string FReason; public: EMath(const std::string& AReason) : FReason(AReason) {} std::string reason() const { return FReason; } }; } // namespace math #endif libmath++-0.0.4/math++/library.tcc0000644000177600001440000002043207463320106017165 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: library.tcc,v 1.5 2002/04/29 19:34:30 cparpart Exp $ // (module info here) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #include #include #include #include #include namespace math { /////////////////////////////////////////////////////////////////////// // TFunction<> // /////////////////////////////////////////////////////////////////////// template TFunction::TFunction() : FName("f"), FExpression(0) { } template TFunction::TFunction(const TFunction& ACopy) : FName(ACopy.FName), FExpression(ACopy.FExpression->clone()) { } template TFunction::TFunction(const std::string& AName, const std::string& AExprStr) : FName(AName), FExpression(0) { expression(AExprStr); } template TFunction::TFunction(const std::string& AName, const TNode *ACopyOf) : FName(AName), FExpression(ACopyOf->clone()) { } template TFunction::~TFunction() { // FExpression is either 0 or contains valid allocated data // so we may delete it without any check. delete FExpression; } template T TFunction::call(const T& AParam, const TLibrary& ALibrary, unsigned ALimit) const { return TCalculator::calculate(*this, AParam, ALibrary, ALimit); } template void TFunction::name(const std::string& AName) { FName = AName; } template std::string TFunction::name() const { return FName; } template void TFunction::expression(const TNode *ACopyOf) { delete FExpression; FExpression = ACopyOf->clone(); } template void TFunction::expression(const std::string& AExprStr) { delete FExpression; try { FExpression = math::TReader::parse(AExprStr); } catch (...) { // set FExpression to zero if parser has thrown... FExpression = 0; throw; } } template TNode *TFunction::expression() const { return FExpression; } /////////////////////////////////////////////////////////////////////// // TConstant<> // /////////////////////////////////////////////////////////////////////// template TConstant::TConstant() : FName("c"), FValue(1) { } template TConstant::TConstant(const TConstant& ACopyOf) : FName(ACopyOf.FName), FValue(ACopyOf.FValue) { } template TConstant::TConstant(const std::string& AName, const T& AValue) : FName(AName), FValue(AValue) { } template void TConstant::name(const std::string& AName) { FName = AName; } template std::string TConstant::name() const { return FName; } template void TConstant::value(const T& AValue) { FValue = AValue; } template T TConstant::value() const { return FValue; } /////////////////////////////////////////////////////////////////////// // TLibrary<> // /////////////////////////////////////////////////////////////////////// template TLibrary::TLibrary() { } template TLibrary::TLibrary(const TLibrary& ACopyOf) : FFunctions(ACopyOf.FFunctions), FConstants(ACopyOf.FConstants) { } template void TLibrary::removeIf(const std::string& AName, bool AReplaceIfExists) { for (typename TFunctionList::iterator i = FFunctions.begin(); i != FFunctions.end(); ++i) { if (i->name() == AName) { if (AReplaceIfExists) { FFunctions.erase(i); break; } else throw ELibraryLookup("Can't insert multiple elements with same name: " + AName + "."); } } for (typename TConstantList::iterator i = FConstants.begin(); i != FConstants.end(); ++i) { if (i->name() == AName) { if (AReplaceIfExists) { FConstants.erase(i); break; } else throw ELibraryLookup("Can't insert multiple elements with same name: " + AName + "."); } } } template void TLibrary::insert(const TFunction& AFunc, bool AReplaceIfExists) { removeIf(AFunc.name(), AReplaceIfExists); FFunctions.push_back(AFunc); } template void TLibrary::insert(const TConstant& AConst, bool AReplaceIfExists) { removeIf(AConst.name(), AReplaceIfExists); FConstants.push_back(AConst); } template void TLibrary::remove(const std::string& AName) { for (typename TFunctionList::iterator i = FFunctions.begin(); i != FFunctions.end(); ++i) if (i->name() == AName) { FFunctions.erase(i); return; } for (typename TConstantList::iterator i = FConstants.begin(); i != FConstants.end(); ++i) if (i->name() == AName) { FConstants.erase(i); return; } throw ELibraryLookup("No element found in library called: " + AName + "."); } template TFunction TLibrary::function(const std::string& AName) const { for (typename TFunctionList::const_iterator i = FFunctions.begin(); i != FFunctions.end(); ++i) if (i->name() == AName) return *i; throw ELibraryLookup("No function found in library called: " + AName + "."); } template TConstant TLibrary::constant(const std::string& AName) const { for (typename TConstantList::const_iterator i = FConstants.begin(); i != FConstants.end(); ++i) if (i->name() == AName) return *i; throw ELibraryLookup("No constant found in library called: " + AName + "."); } template bool TLibrary::hasFunction(const std::string& AName) const { for (typename TFunctionList::const_iterator i = FFunctions.begin(); i != FFunctions.end(); ++i) if (i->name() == AName) return true; return false; } template bool TLibrary::hasConstant(const std::string& AName) const { for (typename TConstantList::const_iterator i = FConstants.begin(); i != FConstants.end(); ++i) if (i->name() == AName) return true; return false; } template T TLibrary::call(const std::string& AName, const T& AParam) const { for (typename TFunctionList::const_iterator i = FFunctions.begin(); i != FFunctions.end(); ++i) if (i->name() == AName) return i->call(AParam, *this); throw ELibraryLookup("No function found in library called: " + AName + "."); } template T TLibrary::value(const std::string& AName) const { for (typename TConstantList::const_iterator i = FConstants.begin(); i != FConstants.end(); ++i) if (i->name() == AName) return i->value(); throw ELibraryLookup("No constant found in library called: " + AName + "."); } template unsigned TLibrary::functions() const { return FFunctions.size(); } template unsigned TLibrary::constants() const { return FConstants.size(); } } // namespace math template std::ostream& operator<<(std::ostream& AOut, const math::TFunction& AFunc) { AOut << AFunc.name() << "(x)=" << math::TPrinter::print(AFunc.expression()); return AOut; } libmath++-0.0.4/math++/utils.tcc0000644000177600001440000000471307464474716016707 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: utils.tcc,v 1.6 2002/05/03 11:51:42 cparpart Exp $ // (This file contains the template method implementations of the utility methods) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_utils_h #error You may not include math++/utils.tcc directly; use math++/utils.h instead. #endif #include #include #include #include #include #include #include namespace math { template T calculate(const std::string& AExprStr, const TLibrary& ALib) { return TCalculator::calculate(TFunction("f", AExprStr), T(), ALib); } template T calculate(const std::string& AExpression) { TLibrary library; return calculate(AExpression, library); } template TNode *derive(const TNode *AExpression, unsigned ACount) { TNode *result = AExpression->clone(); while (--ACount != unsigned(-1)) { TNode *r1 = TDeriver::derive(result); delete result; TNode *r2 = TSimplifier::simplify(r1); delete r1; result = r2; } return result; } template TNode *createTree(const std::string& AExprStr) { return TReader::parse(AExprStr); } template TNode *umkehrfunktion(const TNode *AExprTree) { // TODO return AExprTree->clone(); } template TNode *integral(const TNode *AExprTree) { // TODO return AExprTree->clone(); } } libmath++-0.0.4/math++/expander.h0000644000177600001440000000471507460205371017016 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: expander.h,v 1.4 2002/04/20 06:30:17 cparpart Exp $ // (This file contains the expander specific interface) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_expander_h #define libmath_expander_h #include namespace math { /** * This class impelents the expander extension. It intents to be the opposite * of the simplify implementation. * \todo: implementation. */ template class TExpander : public TNodeVisitor { public: /** * expands given expression (AExpression). */ static TNode *expand(TNode *AExpression); private: virtual void visit(TNumberNode *); virtual void visit(TSymbolNode *); virtual void visit(TParamNode *); virtual void visit(TPlusNode *); virtual void visit(TNegNode *); virtual void visit(TMulNode *); virtual void visit(TDivNode *); virtual void visit(TPowNode *); virtual void visit(TSqrtNode *); virtual void visit(TFuncNode *); virtual void visit(TIfNode *); virtual void visit(TSinNode *); virtual void visit(TCosNode *); virtual void visit(TTanNode *); virtual void visit(TLnNode *); virtual void visit(TEquNode *); virtual void visit(TUnEquNode *); virtual void visit(TGreaterNode *); virtual void visit(TLessNode *); virtual void visit(TGreaterEquNode *); virtual void visit(TLessEquNode *); }; } // namespace math #include #endif libmath++-0.0.4/math++/printer.tcc0000644000177600001440000001423707465206770017226 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: printer.tcc,v 1.7 2002/05/05 10:48:24 cparpart Exp $ // (This file contains the expression stream printer specific template members) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_printer_h #error You may not include math++/printer.tcc directly; include math++/printer.h instead. #endif #include namespace math { template TPrinter::TPrinter(std::ostream& AOutput) : FStream(AOutput) { } template void TPrinter::printOn(std::ostream& AOutput, const TNode *ANode) { TPrinter printer(AOutput); const_cast *>(ANode)->accept(printer); } template std::string TPrinter::print(const TNode *ANode) { std::stringstream sstr; TPrinter printer(sstr); const_cast *>(ANode)->accept(printer); sstr << std::ends; return sstr.str(); } template void TPrinter::savePrint(const TNode *ANode, const TNode *AParent) { #if 1 // ifndef __ENABLE_DEBUG // just disabled for debugging to see reproduce the node order bool less = ANode->priority() < AParent->priority() || (AParent->nodeType() == TNode::NEG_NODE && (ANode->nodeType() == TNode::PLUS_NODE || ANode->nodeType() == TNode::NEG_NODE)); #else bool less = true;//ANode->priority() < AParent->priority(); #endif if (less) FStream << "("; const_cast *>(ANode)->accept(*this); if (less) FStream << ")"; } template void TPrinter::visit(TNumberNode *ANode) { FStream << ANode->number(); } template void TPrinter::visit(TSymbolNode *ANode) { FStream << ANode->symbol(); } template void TPrinter::visit(TParamNode *ANode) { FStream << "x"; // the parameter is usually x, // so keep this symbol reserved, or override me;) } template void TPrinter::visit(TPlusNode *ANode) { savePrint(ANode->left(), ANode); if (ANode->right()->nodeType() != TNode::NEG_NODE) FStream << "+"; savePrint(ANode->right(), ANode); } template void TPrinter::visit(TNegNode *ANode) { FStream << "-"; savePrint(ANode->node(), ANode); } template void TPrinter::visit(TMulNode *ANode) { savePrint(ANode->left(), ANode); // print 2x isteat of 2*x // print 2(x+y) instead of 2*(x+y) // print (a+b)(c+d) instead of (a+b)*(c+d) //if (!(ANode->left()->nodeType() == TNode::NUMBER_NODE && // (ANode->right()->nodeType() == TNode::SYMBOL_NODE || // ANode->right()->nodeType() == TNode::PARAM_NODE))) FStream << "*"; savePrint(ANode->right(), ANode); } template void TPrinter::visit(TDivNode *ANode) { savePrint(ANode->left(), ANode); FStream << "/"; savePrint(ANode->right(), ANode); } template void TPrinter::visit(TPowNode *ANode) { savePrint(ANode->left(), ANode); FStream << "^"; savePrint(ANode->right(), ANode); } template void TPrinter::visit(TSqrtNode *ANode) { FStream << "sqrt("; ANode->node()->accept(*this); FStream << ")"; } template void TPrinter::visit(TSinNode *ANode) { FStream << "sin("; ANode->node()->accept(*this); FStream << ")"; } template void TPrinter::visit(TCosNode *ANode) { FStream << "cos("; ANode->node()->accept(*this); FStream << ")"; } template void TPrinter::visit(TTanNode *ANode) { FStream << "tan("; ANode->node()->accept(*this); FStream << ")"; } template void TPrinter::visit(TLnNode *ANode) { FStream << "ln("; ANode->node()->accept(*this); FStream << ")"; } template void TPrinter::visit(TFuncNode *ANode) { FStream << ANode->name() << "("; ANode->node()->accept(*this); FStream << ")"; } template void TPrinter::visit(TIfNode *ANode) { FStream << "IF("; ANode->condition()->accept(*this); FStream << ", "; ANode->trueExpr()->accept(*this); FStream << ", "; ANode->falseExpr()->accept(*this); FStream << ")"; } template void TPrinter::visit(TEquNode *ANode) { ANode->left()->accept(*this); FStream << "="; ANode->right()->accept(*this); } template void TPrinter::visit(TUnEquNode *ANode) { ANode->left()->accept(*this); FStream << "<>"; ANode->right()->accept(*this); } template void TPrinter::visit(TGreaterNode *ANode) { ANode->left()->accept(*this); FStream << ">"; ANode->right()->accept(*this); } template void TPrinter::visit(TLessNode *ANode) { ANode->left()->accept(*this); FStream << "<"; ANode->right()->accept(*this); } template void TPrinter::visit(TGreaterEquNode *ANode) { ANode->left()->accept(*this); FStream << ">="; ANode->right()->accept(*this); } template void TPrinter::visit(TLessEquNode *ANode) { ANode->left()->accept(*this); FStream << "<="; ANode->right()->accept(*this); } /*template std::ostream& operator<< (std::ostream& os, const TNode& ANode) { TPrinter::print(os, &ANode); return os; }*/ } // namespace math libmath++-0.0.4/math++/utils.cpp0000644000177600001440000000622107454403370016677 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: utils.cpp,v 1.2 2002/04/08 21:09:12 cparpart Exp $ // (This file contains the methods to some utility methods) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #include #include #include namespace math { inline unsigned long long pow(unsigned long long ABase, unsigned long long AExp) { unsigned long long result = 1; while (AExp--) result *= ABase; return result; } bool isPrime(unsigned long long ANumber) { if (ANumber == 1) return false; if (!(ANumber & 1)) return ANumber == 2; if (ANumber == 3) return true; unsigned long long n = 3; while (ANumber % n) { n += 2; if ((n * n) > ANumber) return true; } return false; } unsigned primeCount(unsigned long long ANumber, unsigned long long APrime) { if ((!(ANumber & 1) && ANumber != 2) || !isPrime(ANumber)) return 0; unsigned long long exp = 0; while (!(ANumber % pow(APrime, exp++))); return exp - 2; } unsigned factorize(unsigned long long ANumber, std::vector >& AResult) { AResult.erase(AResult.begin(), AResult.end()); for (unsigned long long b = 2; b < ANumber; ++b) if (unsigned long long e = primeCount(ANumber, b)) AResult.push_back(std::make_pair(b, e)); if (AResult.empty()) AResult.push_back(std::make_pair(ANumber, 1)); return AResult.size(); } // converts given number to string inline std::string strcnv(unsigned long long ANumber) { std::stringstream s; s << ANumber; return s.str(); } std::string factorize(unsigned long long ANumber) { std::string result; for (unsigned long long b = 2; b < ANumber; ++b) { if (unsigned long long e = primeCount(ANumber, b)) { if (result.size()) result += "*"; result += std::string(strcnv(b)) + std::string("^") + std::string(strcnv(e)); } } if (result.empty()) result = std::string(strcnv(ANumber)) + std::string("^1"); return result; } } // namespace math libmath++-0.0.4/math++/reader.h0000644000177600001440000001044507460206031016441 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: reader.h,v 1.6 2002/04/20 06:35:05 cparpart Exp $ // (This file contains the reader (parser) specific interface) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_reader_h #define libmath_reader_h #include #include namespace math { template class TNode; /** * EReadError is thrown while parsing the input expression string * whenever an error occurs. */ class EReadError : public EMath { public: EReadError(const std::string& AReason) : EMath(AReason) {} }; /** * TReader<> represents the expression reader (aka. parser) wich generates * on given input (usually of type std::string) the equivalent output * of type TNode<>. */ template class TReader { private: /// TToken represents the id of an atom of an expression to be parsed. enum TToken { /* TAKE CARE : THE VALUES ARE HARD CODED */ tkInvalid, tkEnd, tkNumber = 1000, tkSymbol, tkUnEqu, tkLess, tkGreater, tkLessEqu, tkGreaterEqu, tkVeryLess, tkVeryGreat, tkEqu = '=', tkComma = ',', tkPlus = '+', tkMinus = '-', tkMul = '*', tkDiv = '/', tkPow = '^', tkRndOpen = '(', tkRndClose = ')', tkBrOpen = '[', tkBrClose = ']', tkAngOpen = '<', tkAngClose = '>', tkSetOpen = '{', tkSetClose = '}' }; std::string FExprStr; // holds the current parsed expression std::string::size_type FPos;// holds the current read index TToken FToken; // holds current parsed token id T FNumber; // holds last read number std::string FSymbol; // holds last read symbol private: TReader(const std::string& AInput); /// parses an expression on equation level (=,<>, <=, >=, <, >, <<, >>) TNode *equation(bool get); // parses an expression (really any expression, even sub equations) TNode *expr(bool get); /// parses whole expressions (+,-)... TNode *simpleExpr(bool get); /// parses terms (*,/)... TNode *term(bool get); /// parses facotrs (^)... TNode *factor(bool get); /// parses that thing with the highest priority (e.g. numbers, idents, ...) TNode *prim(bool get); /// creates a symbol node according to the current parsed symbol name TNode *createSymbol(); /// parses the parameter of a function (including the brackets) TNode *param(); /// returns true if parser reached end of input bool eof() const; /// reads next token, stores its values and returns its token-id TToken nextToken(); /// reads any math operator stores it to FToken and returns true on success bool readOperator(); /// reads a number and returns true on success, result is stored in FNumber bool readNumber(); /// reads a symbol and returns true on success, result is stored in FSymbol bool readSymbol(); /// returns the string according to the given token. static std::string tok2str(TToken AToken); /// expects current token as given and throws on fail, otherwise reads next token. void consume(TToken AToken); public: /** * Parses given expression string (AInput) and returns its result. * Equation parsing is enabled if AEquation is !false. */ static TNode *parse(const std::string& AInput, bool AEquation = false); }; } // namespace math #include #endif libmath++-0.0.4/math++/simplifier.h0000644000177600001440000000512707463320106017346 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: simplifier.h,v 1.6 2002/04/29 19:34:30 cparpart Exp $ // (This file contains the expression simplifier interface) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_simplifier_h #define libmath_simplifier_h #include namespace math { /** * \todo: complete the simplifier implementation (using expr pattern matching). */ template class TSimplifier : public TNodeVisitor { public: /// Simplifies given expression and returns its result. static TNode *simplify(const TNode *AExpression); private: TNode *FResult; private: TSimplifier(); /// calculate() is used to calculate partial expressions to check its static value. T calculate(const TNode *) const; virtual void visit(TNumberNode *); virtual void visit(TSymbolNode *); virtual void visit(TParamNode *); virtual void visit(TPlusNode *); virtual void visit(TNegNode *); virtual void visit(TMulNode *); virtual void visit(TDivNode *); virtual void visit(TPowNode *); virtual void visit(TSqrtNode *); virtual void visit(TSinNode *); virtual void visit(TCosNode *); virtual void visit(TTanNode *); virtual void visit(TLnNode *); virtual void visit(TFuncNode *); virtual void visit(TIfNode *); virtual void visit(TEquNode *); virtual void visit(TUnEquNode *); virtual void visit(TGreaterNode *); virtual void visit(TLessNode *); virtual void visit(TGreaterEquNode *); virtual void visit(TLessEquNode *); }; } // namespace math #include #endif libmath++-0.0.4/math++/.matcher.tcc.swp0000644000177600001440000006000010114642022020014 0ustar trapniusers00000000000000b0VIM 6.3D3A—a.brootbattousai~root/src/libmath++-0.0.3.gcc3.4/math++/matcher.tcc3210#"! Utpÿj7kC£cåadÀj¸¢dÕÒPÊ Ç ƒ @ ú Å Á s * å Å } | b   ñ ð ß Þ – „ < ; )   î © n l k Y ïíìÚšB%  ù÷öäE(  éçæÔž~|{i)ѱ˜—9 ôòñ©’JI9'èæåÓ‚/ÞÃqûâØÒÀ return false; } } return true; AReg->mark(i.get()); static_cast *>(i.get())->number() == FNumber) { if (i->nodeType() == TNode::NUMBER_NODE && !AReg->contains(i.get()) && // by another one. // find a number equal to the one we want to match and isn't yet matched for (typename TNode::const_operand_iterator i = AExpr; i != i.end(); ++i) {bool TNumMatch::match(const TNode *AExpr, TMatchRegistry *AReg) const {template}TNumMatch::TNumMatch(const T& ANumber) : FNumber(ANumber) {template/* TNumMatch *////////////////////////////////////////////////////////////////////////// Match Template Tree///////////////////////////////////////////////////////////////////////} return false; return true; if (*i == ANode) for (typename TNodeList::const_iterator i = FNodeList.begin(); i != FNodeList.end(); ++i) return true; if (i->second == ANode) for (typename TAnyMap::const_iterator i = FAnyMap.begin(); i != FAnyMap.end(); ++i)bool TMatchRegistry::contains(const TNode *ANode) const {template} FNodeList.push_back(ANode);void TMatchRegistry::mark(const TNode *ANode) {template} return 0; // should throw ! return i->second; if (i->first == AId) for (typename TAnyMap::const_iterator i = FAnyMap.begin(); i != FAnyMap.end(); ++i)const TNode *TMatchRegistry::get(const std::string& AId) const {template} return false; return true; if (i->first == AId) for (typename TAnyMap::const_iterator i = FAnyMap.begin(); i != FAnyMap.end(); ++i)bool TMatchRegistry::defined(const std::string& AId) const {template} FAnyMap[AId] = ANode;void TMatchRegistry::define(const std::string& AId, const TNode *ANode) {template} FAnyMap(AProto.FAnyMap), FNodeList(AProto.FNodeList) {TMatchRegistry::TMatchRegistry(const TMatchRegistry& AProto) :template}TMatchRegistry::TMatchRegistry() {template///////////////////////////////////////////////////////////////////////// TMatchRegistry///////////////////////////////////////////////////////////////////////namespace math {#include #endif#error You may not include math/matcher.tcc directly; include math/matcher.h instead.#ifndef libmath_matcher_h///////////////////////////////////////////////////////////////////////// Boston, MA 02111-1307, USA.// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,// along with this library; see the file COPYING.LIB. If not, write to// You should have received a copy of the GNU Library General Public License// // Library General Public License for more details.// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU// but WITHOUT ANY WARRANTY; without even the implied warranty of// This library is distributed in the hope that it will be useful,//// version 2 of the License, or (at your option) any later version.// License as published by the Free Software Foundation; either// modify it under the terms of the GNU Library General Public// This library is free software; you can redistribute it and/or//// Copyright (c) 2002 by Christian Parpart //// (This file contains the expression tree specific template members)// $Id: matcher.tcc,v 1.4 2002/07/02 00:56:12 cparpart Exp $// Math Type Library///////////////////////////////////////////////////////////////////////adAác¸™kW1/.Ö¶“‘~MKJ8ò  À ¿ ­ ~ | { i ; 9 8 & ø ö õ ã µ ³ ²   r p o ] . , +  ë é è Ö ¨ ¦ ¥ “ e c b P # !  ß Ý Ü Ê › š ˆ Z X W E    Î Ì Ë ¹ Š ˆ ‡ u @ > = + ù÷öâáà} // namespace math}void TMatcher::visit(TLessEquNode *ANode) {template}void TMatcher::visit(TGreaterEquNode *ANode) {template}void TMatcher::visit(TLessNode *ANode) {template}void TMatcher::visit(TGreaterNode *ANode) {template}void TMatcher::visit(TUnEquNode *ANode) {template}void TMatcher::visit(TEquNode *ANode) {template}void TMatcher::visit(TIfNode *ANode) {template}void TMatcher::visit(TFuncNode *ANode) {template}void TMatcher::visit(TLnNode *ANode) {template}void TMatcher::visit(TTanNode *ANode) {template}void TMatcher::visit(TCosNode *ANode) {template}void TMatcher::visit(TSinNode *ANode) {template}void TMatcher::visit(TSqrtNode *ANode) {template}void TMatcher::visit(TPowNode *ANode) {template}void TMatcher::visit(TDivNode *ANode) {template}void TMatcher::visit(TMulNode *ANode) {template}void TMatcher::visit(TNegNode *ANode) {template}void TMatcher::visit(TPlusNode *ANode) {template}void TMatcher::visit(TParamNode *ANode) {template}void TMatcher::visit(TSymbolNode *ANode) {template}void TMatcher::visit(TNumberNode *ANode) {template} FMatch(AMatch), FExpr(ANode) { TMatchRegistry *AReg) : TMatcher::TMatcher(const TMatch *AMatch, const TNode *ANode,template} return false;//matcher.success(); // TODO + FIXME TMatcher matcher(AMatch, ANode, AReg); TMatchRegistry *AReg) {bool TMatcher::match(const TMatch *AMatch, const TNode *ANode,add„CÿïíìÚˆ_í»¡ Œ|j&õ Û Ú § € p n m [ ø ö õ å Ó – w u t b  ¾ m  Û ” o R D : 4 "  × Ë ƒ ‚ p #  Ö™—–„template} return false;//!matcher.hasUnused(); // TODO + FIXME TMatcher matcher(AMatch, ANode, AReg); TMatchRegistry *AReg) {bool TMatcher::matchExact(const TMatch *AMatch, const TNode *ANode,template///////////////////////////////////////////////////////////////////////// TMatcher///////////////////////////////////////////////////////////////////////} return false; } } } return true; AReg->mark(i.get()); TMatcher::matchExact(FExp.get(), i->right())) { if (TMatcher::matchExact(FBase.get(), i->left()) && if (!AReg->contains(i.get()) && i->nodeType() == TNode::POW_NODE) { // look for a power node matching exactly our base and exponent template for (typename TNode::const_operand_iterator i = AExpr; i != i.end(); ++i) {bool TPowMatch::match(const TNode *AExpr, TMatchRegistry *AReg) const {template} FBase(ABase), FExp(AExp) {TPowMatch::TPowMatch(TMatch *ABase, TMatch *AExp) :template/* TPowMatch */} return false;bool TMulMatch::match(const TNode *AExpr, TMatchRegistry *AReg) const {template} va_end(ap); this->FPatterns.push_back(p); while (TMatch *p = va_arg(ap, TMatch *)) va_start(ap, ARight); va_list ap; T2Match(ALeft, ARight) {TMulMatch::TMulMatch(TMatch *ALeft, TMatch *ARight, ...) :template/* TMulMatch */} return true; return false; if (!TMatcher::match(*p, AExpr, AReg)) for (typename T2Match::TList::const_iterator p = this->FPatterns.begin(); p != this->FPatterns.end(); ++p) // yet a primitive sequencial searchbool TPlusMatch::match(const TNode *AExpr, TMatchRegistry *AReg) const {template} va_end(ap);adqa 7þýíÛ›™˜†5Ç•>· v Y K A 4 ó œ p # ô × É ¿ ¹ § ¥ ¤ – „ I )    ó Ú … r p o ^ L  æ å Õ » º ‡ a D U S R @ îÅ_-ÿþîܘxwgMLùøèæåÓ‚pnm]KïíìÚ‰6å–S çʼ²¬š˜—OCûúè›|N:ütemplate} return false;//!matcher.hasUnused(); // TODO + FIXME TMatcher matcher(AMatch, ANode, AReg); TMatchRegistry *AReg) {bool TMatcher::matchExact(const TMatch *AMatch, const TNode *ANode,template///////////////////////////////////////////////////////////////////////// TMatcher///////////////////////////////////////////////////////////////////////} return false; } } } return true; AReg->mark(i.get()); TMatcher::matchExact(FExp.get(), i->right())) { if (TMatcher::matchExact(FBase.get(), i->left()) && if (!AReg->contains(i.get()) && i->nodeType() == TNode::POW_NODE) { // look for a power node matching exactly our base and exponent template for (typename TNode::const_operand_iterator i = AExpr; i != i.end(); ++i) {bool TPowMatch::match(const TNode *AExpr, TMatchRegistry *AReg) const {template} FBase(ABase), FExp(AExp) {TPowMatch::TPowMatch(TMatch *ABase, TMatch *AExp) :template/* TPowMatch */} return false;bool TMulMatch::match(const TNode *AExpr, TMatchRegistry *AReg) const {template} va_end(ap); FPatterns.push_back(p); while (TMatch *p = va_arg(ap, TMatch *)) va_start(ap, ARight); va_list ap; T2Match(ALeft, ARight) {TMulMatch::TMulMatch(TMatch *ALeft, TMatch *ARight, ...) :template/* TMulMatch */} return true; return false; if (!TMatcher::match(*p, AExpr, AReg)) for (typename T2Match::TList::const_iterator p = FPatterns.begin(); p != FPatterns.end(); ++p) // yet a primitive sequencial searchbool TPlusMatch::match(const TNode *AExpr, TMatchRegistry *AReg) const {temp thFPatterns.push_back this->FPatterns.push_back(p); while (TMatch *p = va_arg(ap, TMatch *)) va_start(ap, ARight); va_list ap; T2Match(ALeft, ARight) {TPlusMatch::TPlusMatch(TMatch *ALeft, TMatch *ARight, ...) :template/* TPlusMatch */} delete *i; for (typename TList::iterator i = FPatterns.begin(); i != FPatterns.end(); ++i) T2Match::~T2Match() {template} FPatterns.push_back(ARight); FPatterns.push_back(ALeft);T2Match::T2Match(TMatch *ALeft, TMatch *ARight) {template/* T2Match */} return false; } } } return true; AReg->define(FIdent, i.get()); // if operand not yet in registry, define and return success if (!AReg->contains(i.get())) { for (typename TNode::const_operand_iterator i = AExpr; i != i.end(); ++i) { // identifier not defined, search for first free operand } else { } } return true; AReg->mark(i.get()); // mark as already matched. // if operand not yet in registry and equal to given one... if (!AReg->contains(i.get()) && *i == *node) { for (typename TNode::const_operand_iterator i = AExpr; i != i.end(); ++i) { const TNode *node = AReg->get(FIdent); // identififier is already defined, look for another, but equal, one if (AReg->defined(FIdent)) {bool TAnyMatch::match(const TNode *AExpr, TMatchRegistry *AReg) const {template}TAnyMatch::TAnyMatch(const std::string& AId) : FIdent(AId) {template/* TAnyMatch */}libmath++-0.0.4/math++/visitor.h0000644000177600001440000000665307463320106016707 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: visitor.h,v 1.4 2002/04/29 19:34:30 cparpart Exp $ // (This file contains the abstract interface to the expression tree visitor) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_visitor_h #define libmath_visitor_h namespace math { template class TNumberNode; // numbers template class TSymbolNode; // symbols ("e", "pi", "t", ...") template class TParamNode; // usually the symbol "x" template class TPlusNode; // operations 1st degree template class TNegNode; template class TMulNode; // operations 2nd degree template class TDivNode; template class TPowNode; // operations 3rd degree template class TSqrtNode; // build-in functions template class TSinNode; template class TCosNode; template class TTanNode; template class TCoTanNode; template class TLnNode; template class TFuncNode; // user defined functions template class TIfNode; // extended functions template class TEquNode; // equations template class TUnEquNode; template class TGreaterNode; template class TLessNode; template class TGreaterEquNode; template class TLessEquNode; /** * TNodeVisitor<> is the abstract base class for the expression tree. * It is used to extend the tree by additional functionalities such as * derivation, simplifying, or what ever you'd like to add. */ template class TNodeVisitor { public: virtual ~TNodeVisitor() {}; virtual void visit(TNumberNode *) = 0; virtual void visit(TSymbolNode *) = 0; virtual void visit(TParamNode *) = 0; virtual void visit(TPlusNode *) = 0; virtual void visit(TNegNode *) = 0; virtual void visit(TMulNode *) = 0; virtual void visit(TDivNode *) = 0; virtual void visit(TPowNode *) = 0; virtual void visit(TSqrtNode *) = 0; virtual void visit(TSinNode *) = 0; virtual void visit(TCosNode *) = 0; virtual void visit(TTanNode *) = 0; virtual void visit(TLnNode *) = 0; virtual void visit(TFuncNode *) = 0; virtual void visit(TIfNode *) = 0; virtual void visit(TEquNode *) = 0; virtual void visit(TUnEquNode *) = 0; virtual void visit(TGreaterNode *) = 0; virtual void visit(TLessNode *) = 0; virtual void visit(TGreaterEquNode *) = 0; virtual void visit(TLessEquNode *) = 0; }; } // namespace math #endif libmath++-0.0.4/math++/calculator.tcc0000644000177600001440000001164707464254303017670 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: calculator.tcc,v 1.1 2002/04/20 06:39:18 cparpart Exp $ // (implements the function calculator) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_calculator_h #error You may not include math++/calculator.tcc directly; include math++/calculator.h instead. #endif #include namespace math { template T TCalculator::calculate(const TFunction& AFunction, const T& AParam, const TLibrary& ALibrary, unsigned ALimit) { TCalculator c(AFunction, AParam, ALibrary, ALimit); return c.FResult; } template TCalculator::TCalculator(const TFunction& AFunction, const T& AParam, const TLibrary& ALibrary, unsigned ALimit) : FParam(AParam), FLibrary(ALibrary), FLimit(ALimit) { AFunction.expression()->accept(*this); } template T TCalculator::calculate(const TNode *AExpression) { const_cast *>(AExpression)->accept(*this); return FResult; } template void TCalculator::visit(TNumberNode *ANode) { FResult = ANode->number(); } template void TCalculator::visit(TSymbolNode *ANode) { FResult = FLibrary.value(ANode->symbol()); } template void TCalculator::visit(TParamNode *ANode) { FResult = FParam; } template void TCalculator::visit(TPlusNode *ANode) { FResult = calculate(ANode->left()) + calculate(ANode->right()); } template void TCalculator::visit(TNegNode *ANode) { FResult = - calculate(ANode->node()); } template void TCalculator::visit(TMulNode *ANode) { FResult = calculate(ANode->left()) * calculate(ANode->right()); } template void TCalculator::visit(TDivNode *ANode) { FResult = calculate(ANode->left()) / calculate(ANode->right()); } template void TCalculator::visit(TPowNode *ANode) { FResult = pow(calculate(ANode->left()), calculate(ANode->right())); } template void TCalculator::visit(TSqrtNode *ANode) { FResult = sqrt(calculate(ANode->node())); } template void TCalculator::visit(TSinNode *ANode) { FResult = sin(calculate(ANode->node())); } template void TCalculator::visit(TCosNode *ANode) { FResult = cos(calculate(ANode->node())); } template void TCalculator::visit(TTanNode *ANode) { FResult = tan(calculate(ANode->node())); } template void TCalculator::visit(TLnNode *ANode) { FResult = log(calculate(ANode->node())); } template void TCalculator::visit(TFuncNode *ANode) { const std::string name(ANode->name()); if (FRecursions.find(name) == FRecursions.end()) FRecursions[name] = 0; if (++FRecursions[name] > FLimit) throw ECalcError("Function exceeds recursion counter: " + name + "."); T save(FParam); FParam = calculate(ANode->node()); FResult = calculate(FLibrary.function(name).expression()); FParam = save; } template void TCalculator::visit(TIfNode *ANode) { FResult = calculate(ANode->condition()) ? calculate(ANode->trueExpr()) : calculate(ANode->falseExpr()); } template void TCalculator::visit(TEquNode *ANode) { FResult = calculate(ANode->left()) == calculate(ANode->right()); } template void TCalculator::visit(TUnEquNode *ANode) { FResult = calculate(ANode->left()) != calculate(ANode->right()); } template void TCalculator::visit(TGreaterNode *ANode) { FResult = calculate(ANode->left()) > calculate(ANode->right()); } template void TCalculator::visit(TLessNode *ANode) { FResult = calculate(ANode->left()) < calculate(ANode->right()); } template void TCalculator::visit(TGreaterEquNode *ANode) { FResult = calculate(ANode->left()) >= calculate(ANode->right()); } template void TCalculator::visit(TLessEquNode *ANode) { FResult = calculate(ANode->left()) <= calculate(ANode->right()); } } // namespace math libmath++-0.0.4/math++/matcher.tcc0000644000177600001440000002157210114642016017144 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: matcher.tcc,v 1.4 2002/07/02 00:56:12 cparpart Exp $ // (This file contains the expression tree specific template members) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_matcher_h #error You may not include math/matcher.tcc directly; include math/matcher.h instead. #endif #include namespace math { /////////////////////////////////////////////////////////////////////// // TMatchRegistry /////////////////////////////////////////////////////////////////////// template TMatchRegistry::TMatchRegistry() { } template TMatchRegistry::TMatchRegistry(const TMatchRegistry& AProto) : FAnyMap(AProto.FAnyMap), FNodeList(AProto.FNodeList) { } template void TMatchRegistry::define(const std::string& AId, const TNode *ANode) { FAnyMap[AId] = ANode; } template bool TMatchRegistry::defined(const std::string& AId) const { for (typename TAnyMap::const_iterator i = FAnyMap.begin(); i != FAnyMap.end(); ++i) if (i->first == AId) return true; return false; } template const TNode *TMatchRegistry::get(const std::string& AId) const { for (typename TAnyMap::const_iterator i = FAnyMap.begin(); i != FAnyMap.end(); ++i) if (i->first == AId) return i->second; return 0; // should throw ! } template void TMatchRegistry::mark(const TNode *ANode) { FNodeList.push_back(ANode); } template bool TMatchRegistry::contains(const TNode *ANode) const { for (typename TAnyMap::const_iterator i = FAnyMap.begin(); i != FAnyMap.end(); ++i) if (i->second == ANode) return true; for (typename TNodeList::const_iterator i = FNodeList.begin(); i != FNodeList.end(); ++i) if (*i == ANode) return true; return false; } /////////////////////////////////////////////////////////////////////// // Match Template Tree /////////////////////////////////////////////////////////////////////// /* TNumMatch */ template TNumMatch::TNumMatch(const T& ANumber) : FNumber(ANumber) { } template bool TNumMatch::match(const TNode *AExpr, TMatchRegistry *AReg) const { for (typename TNode::const_operand_iterator i = AExpr; i != i.end(); ++i) { // find a number equal to the one we want to match and isn't yet matched // by another one. if (i->nodeType() == TNode::NUMBER_NODE && !AReg->contains(i.get()) && static_cast *>(i.get())->number() == FNumber) { AReg->mark(i.get()); return true; } } return false; } /* TAnyMatch */ template TAnyMatch::TAnyMatch(const std::string& AId) : FIdent(AId) { } template bool TAnyMatch::match(const TNode *AExpr, TMatchRegistry *AReg) const { if (AReg->defined(FIdent)) { // identififier is already defined, look for another, but equal, one const TNode *node = AReg->get(FIdent); for (typename TNode::const_operand_iterator i = AExpr; i != i.end(); ++i) { if (!AReg->contains(i.get()) && *i == *node) { // if operand not yet in registry and equal to given one... AReg->mark(i.get()); // mark as already matched. return true; } } } else { // identifier not defined, search for first free operand for (typename TNode::const_operand_iterator i = AExpr; i != i.end(); ++i) { if (!AReg->contains(i.get())) { // if operand not yet in registry, define and return success AReg->define(FIdent, i.get()); return true; } } } return false; } /* T2Match */ template T2Match::T2Match(TMatch *ALeft, TMatch *ARight) { FPatterns.push_back(ALeft); FPatterns.push_back(ARight); } template T2Match::~T2Match() { for (typename TList::iterator i = FPatterns.begin(); i != FPatterns.end(); ++i) delete *i; } /* TPlusMatch */ template TPlusMatch::TPlusMatch(TMatch *ALeft, TMatch *ARight, ...) : T2Match(ALeft, ARight) { va_list ap; va_start(ap, ARight); while (TMatch *p = va_arg(ap, TMatch *)) this->FPatterns.push_back(p); va_end(ap); } template bool TPlusMatch::match(const TNode *AExpr, TMatchRegistry *AReg) const { // yet a primitive sequencial search for (typename T2Match::TList::const_iterator p = this->FPatterns.begin(); p != this->FPatterns.end(); ++p) if (!TMatcher::match(*p, AExpr, AReg)) return false; return true; } /* TMulMatch */ template TMulMatch::TMulMatch(TMatch *ALeft, TMatch *ARight, ...) : T2Match(ALeft, ARight) { va_list ap; va_start(ap, ARight); while (TMatch *p = va_arg(ap, TMatch *)) this->FPatterns.push_back(p); va_end(ap); } template bool TMulMatch::match(const TNode *AExpr, TMatchRegistry *AReg) const { return false; } /* TPowMatch */ template TPowMatch::TPowMatch(TMatch *ABase, TMatch *AExp) : FBase(ABase), FExp(AExp) { } template bool TPowMatch::match(const TNode *AExpr, TMatchRegistry *AReg) const { for (typename TNode::const_operand_iterator i = AExpr; i != i.end(); ++i) { // look for a power node matching exactly our base and exponent template if (!AReg->contains(i.get()) && i->nodeType() == TNode::POW_NODE) { if (TMatcher::matchExact(FBase.get(), i->left()) && TMatcher::matchExact(FExp.get(), i->right())) { AReg->mark(i.get()); return true; } } } return false; } /////////////////////////////////////////////////////////////////////// // TMatcher /////////////////////////////////////////////////////////////////////// template bool TMatcher::matchExact(const TMatch *AMatch, const TNode *ANode, TMatchRegistry *AReg) { TMatcher matcher(AMatch, ANode, AReg); // TODO + FIXME return false;//!matcher.hasUnused(); } template bool TMatcher::match(const TMatch *AMatch, const TNode *ANode, TMatchRegistry *AReg) { TMatcher matcher(AMatch, ANode, AReg); // TODO + FIXME return false;//matcher.success(); } template TMatcher::TMatcher(const TMatch *AMatch, const TNode *ANode, TMatchRegistry *AReg) : FMatch(AMatch), FExpr(ANode) { } template void TMatcher::visit(TNumberNode *ANode) { } template void TMatcher::visit(TSymbolNode *ANode) { } template void TMatcher::visit(TParamNode *ANode) { } template void TMatcher::visit(TPlusNode *ANode) { } template void TMatcher::visit(TNegNode *ANode) { } template void TMatcher::visit(TMulNode *ANode) { } template void TMatcher::visit(TDivNode *ANode) { } template void TMatcher::visit(TPowNode *ANode) { } template void TMatcher::visit(TSqrtNode *ANode) { } template void TMatcher::visit(TSinNode *ANode) { } template void TMatcher::visit(TCosNode *ANode) { } template void TMatcher::visit(TTanNode *ANode) { } template void TMatcher::visit(TLnNode *ANode) { } template void TMatcher::visit(TFuncNode *ANode) { } template void TMatcher::visit(TIfNode *ANode) { } template void TMatcher::visit(TEquNode *ANode) { } template void TMatcher::visit(TUnEquNode *ANode) { } template void TMatcher::visit(TGreaterNode *ANode) { } template void TMatcher::visit(TLessNode *ANode) { } template void TMatcher::visit(TGreaterEquNode *ANode) { } template void TMatcher::visit(TLessEquNode *ANode) { } } // namespace math libmath++-0.0.4/math++/nodes.h0000644000177600001440000004411110114640402016276 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: nodes.h,v 1.13 2002/07/02 00:56:12 cparpart Exp $ // (This file contains the expression tree specific interface) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_nodes_h #define libmath_nodes_h #include #include #include /* EXAMPLE * expression: 3x^4 + 2x^2 + 1 * the tree: * ____ + ____ * / \ * ___ + ___ 1 * / \ * * * * / \ / \ * 3 ^ 2 ^ * / \ / \ * x 4 x 2 */ namespace math { template class TNodeVisitor; template class TNode; template class TUnaryNodeOp; template class TBinaryNodeOp; // ISSUE : we should, perhaps, support two iterator types // - one for the real iteration (each and every node, classic), // - and one wich takes care about the math privileges and stays // only in its scope /** * TNodeIterator is the implementation of the node iteration class. * This is used (as a typedef to TNode::iterator and * TNode::const_iterator) to iterate through the node operations, such as * plus, minus, and so on. * Use these as you would do with the STL. */ template class TNodeIterator { private: TNode *FCurrent; private: void increment() { // TODO : it must care about the operator privileges if (FCurrent->right()) { FCurrent = FCurrent->right(); while (FCurrent->left()) FCurrent = FCurrent->left(); } else { TNode *p = FCurrent->parent(); while (FCurrent == p->right()) { FCurrent = p; p = p->parent(); } if (FCurrent->right() != p) FCurrent = p; } } bool decrement() { // TODO : it must care about the operator privileges TNode *last = FCurrent; if (FCurrent->left()) { TNode *p = FCurrent->left(); while (p->right()) p = p->right(); FCurrent = p; } else { TNode *p = FCurrent->parent(); while (FCurrent == p->left()) { FCurrent = p; p = p->left(); } FCurrent = p; } return FCurrent != last; } /// returns to the very first node of this level TNodeIterator& rewind() { while (decrement()); return *this; } friend class TNode; // TNode may access the method rewind. public: TNodeIterator() : FCurrent(0) {} TNodeIterator(TNode *ANode) : FCurrent(ANode) {} TNodeIterator(const TNodeIterator& v) : FCurrent(v.FCurrent) {} TNode& operator*() const { return *FCurrent; } TNode *operator->() const { return FCurrent; } TNode *get() const { return FCurrent; } TNodeIterator& operator++() { increment(); return *this; } TNodeIterator& operator--() { decrement(); return *this; } }; template bool operator==(const TNodeIterator& a, const TNodeIterator& b) { return a.get() == b.get(); } template bool operator!=(const TNodeIterator& a, const TNodeIterator& b) { return a.get() != b.get(); } /** TOperandIter<> (use TNode<>::operand_iterator and const_operand_iterator) * are designed to iterate the operands of an given expression. * (e.g. all summands of an plus operation) */ template class TOperandIter { public: TOperandIter() : FOrigin(0), FCurrent(0) {} TOperandIter(NodeType *AOperator) : FOrigin(AOperator), FCurrent(FOrigin) { do FCurrent = FCurrent->left(); while (inScope(FCurrent)); } TOperandIter(const TOperandIter& AProto) : FOrigin(AProto.FOrigin), FCurrent(AProto.FCurrent) {} NodeType& operator*() const { return *FCurrent; } NodeType *operator->() const { return FCurrent; } NodeType *get() const { return this ? FCurrent : 0; } TOperandIter& end() const { return *static_cast *>(0); } TOperandIter& operator++() { increment(); return *this; } private: NodeType *FOrigin; NodeType *FCurrent; /// find operand right next to the current one and set void increment() { if (FCurrent) { NodeType *p = FCurrent->parent(); // as long as we're the right child of p while (p && FCurrent == p->right() && inScope(p)) { // go one up FCurrent = p; p = p->parent(); } FCurrent = p; // reached end of iteration if (!p || !inScope(p)) { FCurrent = 0; return; } FCurrent = FCurrent->right(); if (inScope(FCurrent)) { do FCurrent = FCurrent->left(); while (inScope(FCurrent)); } } } bool inScope(const NodeType *ANode) const { switch (FOrigin->nodeType()) { case NodeType::PLUS_NODE: case NodeType::MUL_NODE: return ANode->nodeType() == FOrigin->nodeType(); default: return false; } } }; template bool operator==(const TOperandIter& a, const TOperandIter& b) { return a.get() == b.get(); } template bool operator!=(const TOperandIter& a, const TOperandIter& b) { return a.get() != b.get(); } /** * TNode represents the abstract node base. */ template class TNode { public: typedef TNodeIterator iterator; typedef const TNodeIterator const_iterator; typedef TOperandIter > operand_iterator; typedef TOperandIter > const_operand_iterator; /** * This enumeration, TNodeType, is implemented for node type access. * This makes it also faster because it replaces the dynamic_cast<> operator. */ enum TNodeType { // take care, the order below is hard coded NUMBER_NODE, // numbers: 0, 3.1415, 2.17, 0.815, ... (prio: 0) SYMBOL_NODE, // any symbol value: pi, e, ... (prio: 0) PARAM_NODE, // the function parameter... (e.g. x) (prio: 0) PLUS_NODE, // x + y (prio: -5) NEG_NODE, // -x (prio: -5) MUL_NODE, // x * y (prio: -3) DIV_NODE, // x / y (prio: -3) MOD_NODE, // x mod y (prio: -3) POW_NODE, // x ^ y (prio: -1) EQU_NODE, // x == y (prio: -10) UNEQU_NODE, // x != y (prio: -10) LESS_EQU_NODE, // x <= y (prio: -10) GREATER_EQU_NODE,// x >= y (prio: -10) LESS_NODE, // x < y (prio: -10) GREATER_NODE, // x > y (prio: -10) FUNC_NODE, // userfunc(x) (prio: -1) SQRT_NODE, // sqrt(x); x ^ 0.5 (prio: -1) SIN_NODE, // sin(x) (prio: -1) COS_NODE, // cos(x) (prio: -1) TAN_NODE, // tan(x) (prio: -1) LN_NODE, // logn(x) (prio: -1) IF_NODE // IF(cond, then, else) (prio: -1) }; private: /// represents the type of node (used to workaround the slow dynamic_cast<>) TNodeType FNodeType; /// 0 is highes node priority (the higher the lower) short FPriority; /// contains a pointer to the parent node if any exists, otherwise 0 TNode *FParent; protected: /// initializes this node for given node type. TNode(TNodeType ANodeType, short APriority, TNode *AParentNode = 0); TNode(const TNode& n); /// initializes the parent node with the given one void parent(TNode *AParent); friend class TUnaryNodeOp; friend class TBinaryNodeOp; public: /// each virtual class needs a virtual destructor (this one does nothing) virtual ~TNode(); /// returns the type of this node TNodeType nodeType() const; /// returns the node priority short priority() const; /// returns the parent node (returns 0 if this node is the root node) TNode *parent() const; /// returns the left child node (returns 0 if this node doesn't support one) virtual TNode *left() const; /// returns the right child node (returns 0 if this node doesn't support one) virtual TNode *right() const; /// calls the visit method in TNodeVisitor<> virtual void accept(TNodeVisitor&) = 0; /// clones that node virtual TNode *clone() const = 0; /// iterator access to the first value node in this operator level iterator begin() { return iterator(this).rewind(); } /// iterator access to the end iterator end() { return iterator(0); } /// returns true, if given node equals to this one virtual bool equals(const TNode *ANode) const = 0; }; template bool operator==(const TNode&, const TNode&); template bool operator!=(const TNode&, const TNode&); /** * TNumberNode represents the node holding a constant value of type T. */ template class TNumberNode : public TNode { private: T FNumber; public: TNumberNode(const T& AValue); T number() const; virtual void accept(TNodeVisitor&); virtual TNumberNode *clone() const; virtual bool equals(const TNode *ANode) const; }; /** * TSymbolNode<> represents any symbol used in an expression, except * the function parameter and build-in functions itself. */ template class TSymbolNode : public TNode { private: std::string FSymbol; public: TSymbolNode(const std::string& ASymbol); /// returns the symbol's name std::string symbol() const; virtual void accept(TNodeVisitor&); virtual TSymbolNode *clone() const; virtual bool equals(const TNode *ANode) const; }; /** * This node represents a parameter node on wich the * whole expression tree usualle depends on. */ template class TParamNode : public TNode { public: TParamNode(); virtual void accept(TNodeVisitor&); virtual TParamNode *clone() const; virtual bool equals(const TNode *ANode) const; }; /** * TUnaryNodeOp represents the base class for any unary operation node * in the expression tree. */ template class TUnaryNodeOp : public TNode { private: std::auto_ptr > FNode; protected: /// creates an unary operator node of type AType. TUnaryNodeOp(typename TUnaryNodeOp::TNodeType AType, short APriority, TNode *ANode); public: /// returns the child node for that unary operator node. TNode *node() const; /// returns the child node (wrapper to the more declarative node() method) virtual TNode *right() const; virtual bool equals(const TNode *ANode) const; }; /** * TBinaryNodeOp represents the base class for any binary operation node * in the expression tree. */ template class TBinaryNodeOp : public TNode { private: std::auto_ptr > FLeft; std::auto_ptr > FRight; protected: /// creates an binary operator node of type AType TBinaryNodeOp(typename TBinaryNodeOp::TNodeType AType, short APrio, TNode *ALeft, TNode *ARight); public: /// returns the right child node of the expression tree virtual TNode *left() const; /// returns the left child node of the expression tree virtual TNode *right() const; virtual bool equals(const TNode *ANode) const; }; /** * The class TPlusNode implements the plus operator * for numbers of type T. */ template class TPlusNode : public TBinaryNodeOp { public: TPlusNode(TNode *ALeft, TNode *ARight); virtual void accept(TNodeVisitor&); virtual TPlusNode *clone() const; }; /** The class TNegNode implements the negotiation operation * for numbers of type T * */ template class TNegNode : public TUnaryNodeOp { public: TNegNode(TNode *ANode); virtual void accept(TNodeVisitor&); virtual TNegNode *clone() const; }; /** * The class TMulNode implements the muliplication operator * for numbers of type T. */ template class TMulNode : public TBinaryNodeOp { public: TMulNode(TNode *ALeft, TNode *ARight); virtual void accept(TNodeVisitor&); virtual TMulNode *clone() const; }; /** * TDivNode implements the division operator for * numbers of type T. */ template class TDivNode : public TBinaryNodeOp { public: TDivNode(TNode *ALeft, TNode *ARight); virtual void accept(TNodeVisitor&); virtual TDivNode *clone() const; }; /** * TPowNode implements the power operation */ template class TPowNode : public TBinaryNodeOp { public: TPowNode(TNode *ALeft, TNode *ARight); virtual void accept(TNodeVisitor&); virtual TPowNode *clone() const; }; /** * TSqrtNode<> implements the build-in sqrt() function. * for numbers of type T. */ template class TSqrtNode : public TUnaryNodeOp { public: TSqrtNode(TNode *ANode); virtual void accept(TNodeVisitor&); virtual TSqrtNode *clone() const; }; /** * The class TSinNode implements the build-in sinus function * for numbers of type T. */ template class TSinNode : public TUnaryNodeOp { public: TSinNode(TNode *AParam); virtual void accept(TNodeVisitor&); virtual TSinNode *clone() const; }; /** * The class TCosNode implements the build-in cosinus function * for numbers of type T. */ template class TCosNode : public TUnaryNodeOp { public: TCosNode(TNode *AParam); virtual void accept(TNodeVisitor&); virtual TCosNode *clone() const; }; /** * The class TTanNode implements the build-in tangens function * for numbers of type T. */ template class TTanNode : public TUnaryNodeOp { public: TTanNode(TNode *AParam); virtual void accept(TNodeVisitor&); virtual TTanNode *clone() const; }; /** * The class TLnNode implements the build-in logn function * for numbers of type T. */ template class TLnNode : public TUnaryNodeOp { public: TLnNode(TNode *AParam); virtual void accept(TNodeVisitor&); virtual TLnNode *clone() const; }; /** * Any user defined function defined in a given library. * If this user defined function can't be displayed * in a graph if it has multiple parameters. * MULTIPLE PARAMETER ARE TO BE DONE! */ template class TFuncNode : public TUnaryNodeOp { private: std::string FName; public: TFuncNode(const std::string& AName, TNode *AParam); std::string name() const; virtual void accept(TNodeVisitor&); virtual TFuncNode *clone() const; }; /** * TIfNode is a gread plus* for that library :). * example: sig(x) = IF(x > 0, 1, -1) * example: fib(n) = IF(n = 1, 1, n + fib(n - 1)), n element |N * example: t(x) = IF(int(x) % 3 = 0, 0, IF(int(x) % 3 = 1, 1, 2)) */ template class TIfNode : public TBinaryNodeOp { private: std::auto_ptr > FCondition; public: TIfNode(TNode *ACondNode, TNode *AThenNode, TNode *AElseNode); TNode *condition() const; TNode *trueExpr() const; TNode *falseExpr() const; virtual void accept(TNodeVisitor&); virtual TIfNode *clone() const; }; /** * The class TEquNode<> impelemnts the equation operation * on nodes for numbers of type T. * \todo: complete the Equation class interface and impelemntation. */ template class TEquNode : public TBinaryNodeOp { public: TEquNode(TNode *ALeft, TNode *ARight); virtual void accept(TNodeVisitor&); virtual TEquNode *clone() const; }; template class TUnEquNode : public TBinaryNodeOp { public: TUnEquNode(TNode *ALeft, TNode *ARight); virtual void accept(TNodeVisitor&); virtual TUnEquNode *clone() const; }; template class TGreaterNode : public TBinaryNodeOp { public: TGreaterNode(TNode *ALeft, TNode *ARight); virtual void accept(TNodeVisitor&); virtual TGreaterNode *clone() const; }; template class TLessNode : public TBinaryNodeOp { public: TLessNode(TNode *ALeft, TNode *ARight); virtual void accept(TNodeVisitor&); virtual TLessNode *clone() const; }; template class TGreaterEquNode : public TBinaryNodeOp { public: TGreaterEquNode(TNode *ALeft, TNode *ARight); virtual void accept(TNodeVisitor&); virtual TGreaterEquNode *clone() const; }; template class TLessEquNode : public TBinaryNodeOp { public: TLessEquNode(TNode *ALeft, TNode *ARight); virtual void accept(TNodeVisitor&); virtual TLessEquNode *clone() const; }; } // namespace math #include #endif libmath++-0.0.4/math++/reader.tcc0000644000177600001440000002657107510175054017000 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: reader.tcc,v 1.8 2002/07/02 00:56:12 cparpart Exp $ // (This file contains the reader (parser) specific template members) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_reader_h #error You may not include math++/reader.tcc directly; include math++/reader.h instead. #endif #include #include #include // just for debuggin #include #include namespace math { // TReader<> template TReader::TReader(const std::string& AInput) : FExprStr(AInput), FPos(0), FToken(tkInvalid) { } template TNode *TReader::parse(const std::string& AInput, bool AEquation) { TReader reader(AInput); TNode *e = AEquation ? reader.equation(true) : reader.expr(true); if (reader.FToken != tkEnd) { throw EReadError("Unexpected characters left on input (" + tok2str(reader.FToken) + ")."); } return e; } template TNode *TReader::equation(bool get) { TNode *left = simpleExpr(get); switch (FToken) { case tkEqu: left = new TEquNode(left, simpleExpr(true)); break; case tkUnEqu: left = new TUnEquNode(left, simpleExpr(true)); break; case tkGreater: left = new TGreaterNode(left, simpleExpr(true)); break; case tkLess: left = new TLessNode(left, simpleExpr(true)); break; case tkGreaterEqu: left = new TGreaterEquNode(left, simpleExpr(true)); break; case tkLessEqu: left = new TLessEquNode(left, simpleExpr(true)); break; default: // Enforce a syntax error. Because the input is no // equation as requested. consume(tkEqu); } return left; } template TNode *TReader::expr(bool get) { TNode *left = simpleExpr(get); while (true) { switch (FToken) { case tkEqu: left = new TEquNode(left, simpleExpr(true)); break; case tkUnEqu: left = new TUnEquNode(left, simpleExpr(true)); break; case tkGreater: left = new TGreaterNode(left, simpleExpr(true)); break; case tkLess: left = new TLessNode(left, simpleExpr(true)); break; case tkGreaterEqu: left = new TGreaterEquNode(left, simpleExpr(true)); break; case tkLessEqu: left = new TLessEquNode(left, simpleExpr(true)); break; default: return left; } } } template TNode *TReader::simpleExpr(bool get) { TNode *left = term(get); while (true) { switch (FToken) { case tkPlus: left = new TPlusNode(left, term(true)); break; case tkMinus: left = new TPlusNode(left, new TNegNode(term(true))); break; default: return left; } } } template TNode *TReader::term(bool get) { TNode *left = factor(get); while (true) { switch (FToken) { case tkMul: left = new TMulNode(left, factor(true)); break; case tkDiv: left = new TDivNode(left, factor(true)); break; case tkSymbol: case tkRndOpen: case tkBrOpen: // "algebraische schreibweise, z.B.: 2x+3, anstatt 2*x+3" left = new TMulNode(left, factor(false)); default: return left; } } } template TNode *TReader::factor(bool get) { TNode *left = prim(get); while (true) { switch (FToken) { case tkPow: left = new TPowNode(left, factor(true)); default: return left; } } } template TNode *TReader::prim(bool get) { TNode *n = 0; if (get) nextToken(); switch (FToken) { case tkPlus: n = prim(true); break; case tkMinus: n = new TNegNode(prim(true)); break; case tkRndOpen: n = expr(true); consume(tkRndClose); break; case tkBrOpen: n = expr(true); consume(tkBrClose); break; case tkNumber: n = new TNumberNode(FNumber); nextToken(); break; case tkSymbol: n = createSymbol(); break; case tkEnd: throw EReadError("Incomplete expression."); default: throw EReadError("Unexpected token " + tok2str(FToken) + "."); ;// unknown or misplaced token? (returns automatically 0) } return n; } template TNode *TReader::createSymbol() { if (FSymbol == "x") { nextToken(); return new TParamNode(); } else if (FSymbol == "sin") return new TSinNode(param()); else if (FSymbol == "cos") return new TCosNode(param()); else if (FSymbol == "tan") return new TTanNode(param()); else if (FSymbol == "ln") return new TLnNode(param()); else if (FSymbol == "IF") { // example nextToken(); consume(tkRndOpen); TNode *ifExpr = expr(false); consume(tkComma); TNode *thenExpr = expr(false); consume(tkComma); TNode *elseExpr = expr(false); consume(tkRndClose); return new TIfNode(ifExpr, thenExpr, elseExpr); } else { // okay, it's a user defined function to be called, or any constant // defined in a library std::string name(FSymbol); if (nextToken() == tkRndOpen) { #if 0 // TO BE IMPLEMENTED / DONE // a function TFuncNode *node = new TFuncNode(name); node->addParam(expr(true)); while (FToken == tkComma) node->addParam(expr(true)); consume(tkRndClose); return node; #else TNode *param = expr(true); consume(tkRndClose); return new TFuncNode(name, param); #endif } else // a constant return new TSymbolNode(name); } } template TNode *TReader::param() { consume(tkSymbol); consume(tkRndOpen); TNode *param = expr(false); consume(tkRndClose); return param; } template bool TReader::eof() const { return FPos >= FExprStr.size(); } template typename TReader::TToken TReader::nextToken() { // reset data FToken = tkInvalid; FSymbol.erase(); // skip spaces #if defined(__GNUC__) && (__GNUC__ < 3) while (FPos < FExprStr.size() && isspace(FExprStr[FPos])) #else while (FPos < FExprStr.size() && std::isspace(FExprStr[FPos])) #endif ++FPos; if (eof()) return FToken = tkEnd; if (readOperator()) return FToken; // readOperator sets FToken automatically if (readNumber()) return FToken = tkNumber; if (readSymbol()) return FToken = tkSymbol; return FToken; } template bool TReader::readOperator() { if (std::strchr("+-*/^(,)[]=", FExprStr[FPos])) { FToken = TToken(FExprStr[FPos++]); return true; } switch (FExprStr[FPos]) { case '<': switch (FExprStr[++FPos]) { case '=': ++FPos; return FToken = tkLessEqu; case '>': ++FPos; return FToken = tkUnEqu; default: return FToken = tkLess; } case '>': if (FExprStr[++FPos] == tkEqu) { ++FPos; return FToken = tkGreaterEqu; } return FToken = tkGreater; default: return false; } } template bool TReader::readNumber() { #if defined(__GNUC__) && (__GNUC__ < 3) while (isdigit(FExprStr[FPos]) || FExprStr[FPos] == '.') #else while (std::isdigit(FExprStr[FPos]) || FExprStr[FPos] == '.') #endif FSymbol += FExprStr[FPos++]; if (FSymbol.size()) { std::stringstream sstr(FSymbol); sstr >> FNumber; return true; } return false; } template bool TReader::readSymbol() { #if defined(__GNUC__) && (__GNUC__ < 3) while (FPos < FExprStr.size() && isalpha(FExprStr[FPos])) #else while (FPos < FExprStr.size() && std::isalpha(FExprStr[FPos])) #endif FSymbol += FExprStr[FPos++]; return FSymbol.size(); } template std::string TReader::tok2str(TToken AToken) { // The TToken structure is optimized for parsing, so it can't be // optimized here. We're using a switch instead;) switch (AToken) { case tkEqu: return "="; case tkUnEqu: return "<>"; case tkLess: return "<"; case tkGreater: return ">"; case tkLessEqu: return "<="; case tkGreaterEqu: return ">="; case tkVeryLess: return "<<"; case tkVeryGreat: return ">>"; case tkPlus: return "+"; case tkMinus: return "-"; case tkMul: return "*"; case tkDiv: return "/"; case tkPow: return "^"; case tkRndOpen: return "("; case tkRndClose: return ")"; case tkBrOpen: return "["; case tkBrClose: return "]"; case tkAngOpen: return "<"; case tkAngClose: return ">"; case tkSetOpen: return "{"; case tkSetClose: return "}"; case tkNumber: return ""; case tkSymbol: return ""; case tkEnd: return ""; case tkInvalid: return ""; default: return ""; } } template void TReader::consume(TToken AToken) { if (FToken != AToken) throw EReadError( std::string("Expected token was ") + tok2str(AToken) + std::string(" but got ") + tok2str(FToken) + std::string(" instead.") ); nextToken(); } } // namespace math libmath++-0.0.4/math++/matcher.h0000644000177600001440000001562407465745337016654 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: matcher.h,v 1.3 2002/05/07 12:38:55 cparpart Exp $ // (This file contains the expression tree specific template members) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_matcher_h #define libmath_matcher_h #include #include #include #include namespace math { template class TMatchRegistry { public: TMatchRegistry(); TMatchRegistry(const TMatchRegistry&); /// defines given expression node as given id. void define(const std::string& AId, const TNode *ANode); /// checks whether given id is defined or not. bool defined(const std::string& AId) const; /// returns expression node to given id. const TNode *get(const std::string& AId) const; /// marks given node as used void mark(const TNode *ANode); /// returns true when ANode is either marked as used or is defined as any bool contains(const TNode *ANode) const; private: typedef std::map *> TAnyMap; typedef std::list *> TNodeList; TAnyMap FAnyMap; TNodeList FNodeList; }; //////////////////////////////////////////////////////////////////////// // The match template tree template class TMatch { public: virtual ~TMatch() {} virtual bool match(const TNode *AExpr, TMatchRegistry *AReg) const = 0; }; template class TNumMatch : public TMatch { public: TNumMatch(const T& ANum); virtual bool match(const TNode *AExpr, TMatchRegistry *AReg) const; private: T FNumber; }; template class TAnyMatch : public TMatch { public: TAnyMatch(const std::string& AId); virtual bool match(const TNode *AExpr, TMatchRegistry *AReg) const; private: std::string FIdent; }; /** T2Match is the base class for operators where the operands may be equivalent exchaned (+, *) */ template class T2Match : public TMatch { protected: T2Match(TMatch *ALeft, TMatch *ARight); ~T2Match(); // gets additional match methods for share soon typedef std::list *> TList; TList FPatterns; }; template class TPlusMatch : public T2Match { public: TPlusMatch(TMatch *ALeft, TMatch *ARight, ...); virtual bool match(const TNode *AExpr, TMatchRegistry *AReg) const; }; template class TMulMatch : public T2Match { public: TMulMatch(TMatch *ALeft, TMatch *ARight, ...); virtual bool match(const TNode *AExpr, TMatchRegistry *AReg) const; }; template class TNegMatch : public TMatch { public: TNegMatch(TMatch *ANode); virtual bool match(const TNode *AExpr, TMatchRegistry *AReg) const; private: std::auto_ptr > FNode; }; template class TDivMatch : public TMatch { public: TDivMatch(TMatch *ALeft, TMatch *ARight); virtual bool match(const TNode *AExpr, TMatchRegistry *AReg) const; private: std::auto_ptr > FLeft; std::auto_ptr > FRight; }; template class TPowMatch : public TMatch { public: TPowMatch(TMatch *ABase, TMatch *AExp); virtual bool match(const TNode *AExpr, TMatchRegistry *AReg) const; private: std::auto_ptr > FBase; std::auto_ptr > FExp; }; /** TMatcher<> is a dynamic matching system for symbolic expressions. * One application for that is simplifying expressions. * * TMatcher<> class is really to be done. But it will rock then. * Example: *
  *   TMatcher::TResult matchResult;
  *   if (TMatcher::match("a+a", expr, machResult))
  *       return transform(expr, machResult, "2*a+$");
  * 
* * the "$" means the remaining part not matched using given template match, * here "a+a". Example: if you've a+b+a and want match a+a, then the remaining * part is b; if you've a^2+b^(sin(2x)+2)+c^2+c*2*a and want to match * a^2+2ab+b^2, then the matched parts is: "a^2+c^2+c*2*a" and the remaining * part will be: "b^(sin(2x)+2)". */ template class TMatcher : public TNodeVisitor { public: typedef std::map > TResult; /** matchExact returns true when the template (AMatch) represents exactly * the test expression (AExpr). */ static bool matchExact(const TMatch *AMatch, const TNode *AExpr, TMatchRegistry *AReg = 0); /** returns true when given pattern (AMatch) was matched in given * expression (AExpr). The result data is stored into the registry * on success only. */ static bool match(const TMatch *AMatch, const TNode *AExpr, TMatchRegistry *AReg = 0); /** match matches a given expression template on expression AExpr and * puts its result into AResult. */ static unsigned match(const std::string& AMatch, const TNode *AExpr, TResult& AResult); private: TMatcher(const TMatch *AMatch, const TNode *ANode, TMatchRegistry *AReg = 0); private: const TMatch *FMatch; const TNode *FExpr; private: virtual void visit(TNumberNode *); virtual void visit(TSymbolNode *); virtual void visit(TParamNode *); virtual void visit(TPlusNode *); virtual void visit(TNegNode *); virtual void visit(TMulNode *); virtual void visit(TDivNode *); virtual void visit(TPowNode *); virtual void visit(TSqrtNode *); virtual void visit(TSinNode *); virtual void visit(TCosNode *); virtual void visit(TTanNode *); virtual void visit(TLnNode *); virtual void visit(TFuncNode *); virtual void visit(TIfNode *); virtual void visit(TEquNode *); virtual void visit(TUnEquNode *); virtual void visit(TGreaterNode *); virtual void visit(TLessNode *); virtual void visit(TGreaterEquNode *); virtual void visit(TLessEquNode *); }; } // namespace math #include #endif libmath++-0.0.4/math++/calculator.h0000644000177600001440000000641007460206426017335 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: calculator.h,v 1.1 2002/04/20 06:39:18 cparpart Exp $ // (defines the interface for the function calculator) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_calculator_h #define libmath_calculator_h #include #include #include #include namespace math { template class TFunction; template class TLibrary; /** * ECalcError gets thrown whenever any error during function calculation * occurs. This may be e.g. a recursion error. */ class ECalcError : public EMath { public: ECalcError(const std::string& AReason) : EMath(AReason) {} }; /** * TCalculator calculates functions results using given function and * a library to use. You may also specify the recursion limit. */ template class TCalculator : protected TNodeVisitor { public: /// calculates the functions result using given values. static T calculate(const TFunction& AFunction, const T& AParam, const TLibrary& ALibrary, unsigned ARecursionLimit = 64); private: T FParam; const TLibrary& FLibrary; std::map FRecursions; unsigned FLimit; T FResult; private: /// creates a calculator TCalculator(const TFunction& AFunction, const T& AParam, const TLibrary& ALibrary, unsigned ALimit); /// calculates partial expression T calculate(const TNode *AExpression); virtual void visit(TNumberNode *); virtual void visit(TSymbolNode *); virtual void visit(TParamNode *); virtual void visit(TPlusNode *); virtual void visit(TNegNode *); virtual void visit(TMulNode *); virtual void visit(TDivNode *); virtual void visit(TPowNode *); virtual void visit(TSqrtNode *); virtual void visit(TSinNode *); virtual void visit(TCosNode *); virtual void visit(TTanNode *); virtual void visit(TLnNode *); virtual void visit(TFuncNode *); virtual void visit(TIfNode *); virtual void visit(TEquNode *); virtual void visit(TUnEquNode *); virtual void visit(TGreaterNode *); virtual void visit(TLessNode *); virtual void visit(TGreaterEquNode *); virtual void visit(TLessEquNode *); }; } // namespace math #include #endif libmath++-0.0.4/math++/library.h0000644000177600001440000001120507463320106016641 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: library.h,v 1.6 2002/04/29 19:34:30 cparpart Exp $ // (module info here) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_library_h #define libmath_library_h #include #include #include #include namespace math { template class TNode; template class TLibrary; /** * TFunction<> is used for multiple function management as done by TLibrary<>. */ template class TFunction { private: std::string FName; TNode *FExpression; public: TFunction(); TFunction(const TFunction&); TFunction(const std::string& AName, const std::string& AExprStr = std::string()); TFunction(const std::string& AName, const TNode *AExprTree); ~TFunction(); T call(const T& AParam, const TLibrary& ALibrary, unsigned ALimit = 64) const; void name(const std::string&); std::string name() const; void expression(const TNode *ACopyOf); void expression(const std::string& AExprStr); TNode *expression() const; }; /** * TConstant<> is used to store constants, such as e or pi, in a TLibrary<>. */ template class TConstant { private: std::string FName; T FValue; public: TConstant(); TConstant(const TConstant&); TConstant(const std::string& AName, const T& AValue = T()); void name(const std::string&); std::string name() const; void value(const T&); T value() const; }; /** * ELibraryLookup is thrown by the TLibrary<> class when ever any lookup fails * or any elements in a library are found multiple. */ class ELibraryLookup : public EMath { public: ELibraryLookup(const std::string& AMsg) : EMath(AMsg) {} }; /** * TLibrary<> is used to manage multiple functions and constants * to be shared and to be called each other. * Note, that you can't have a function called f and a constant called f. */ template class TLibrary { private: typedef std::list > TFunctionList; typedef std::list > TConstantList; TFunctionList FFunctions; TConstantList FConstants; void removeIf(const std::string& AName, bool AReplaceIfExists); public: TLibrary(); TLibrary(const TLibrary&); /// inserts given function into library, it throws if it's duplicated void insert(const TFunction&, bool AReplaceIfExists = false); /// inserts given constant into library, it throws if it's duplicated void insert(const TConstant&, bool AReplaceIfExists = false); /// removes function or constant called AName void remove(const std::string& AName); /// returns reference to requested function, throws if not found TFunction function(const std::string& AName) const; /// returns reference to requested constant, throws if not fuond TConstant constant(const std::string& AName) const; /// returns true, if function (AName) exists bool hasFunction(const std::string& AName) const; /// returns true, if constant (AName) exists bool hasConstant(const std::string& AName) const; /// call() looks for a function AName calls it using AParam and returns its result. It throws on lookup error. T call(const std::string& AName, const T& AParam) const; /// value() look for a constant AName and returns its value. It throws on lookup error. T value(const std::string& AName) const; /// returns the number of functions stored in this library. unsigned functions() const; /// returns the number of constants stored in this library. unsigned constants() const; }; } // namespace math template std::ostream& operator<<(std::ostream&, const math::TFunction&); #include #endif libmath++-0.0.4/math++/derive.h0000644000177600001440000000461207460205342016460 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: derive.h,v 1.4 2002/04/20 06:29:54 cparpart Exp $ // (This file contains the derivation-specific interface) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_derive_h #define libmath_derive_h #include namespace math { /** * \todo: complete implementation. */ template class TDeriver : public TNodeVisitor { public: /** * expands given expression (AExpression). */ static TNode *derive(TNode *AExpression); private: TNode *FResult; private: TDeriver(); virtual void visit(TNumberNode *); virtual void visit(TSymbolNode *); virtual void visit(TParamNode *); virtual void visit(TPlusNode *); virtual void visit(TNegNode *); virtual void visit(TMulNode *); virtual void visit(TDivNode *); virtual void visit(TPowNode *); virtual void visit(TSqrtNode *); virtual void visit(TSinNode *); virtual void visit(TCosNode *); virtual void visit(TTanNode *); virtual void visit(TLnNode *); virtual void visit(TFuncNode *); virtual void visit(TIfNode *); virtual void visit(TEquNode *); virtual void visit(TUnEquNode *); virtual void visit(TGreaterNode *); virtual void visit(TLessNode *); virtual void visit(TGreaterEquNode *); virtual void visit(TLessEquNode *); }; } // namespace math #include #endif libmath++-0.0.4/math++/expander.tcc0000644000177600001440000000226207454404030017327 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: expander.tcc,v 1.2 2002/04/08 21:14:00 cparpart Exp $ // (This file contains the expander specific template member methods) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// namespace math { // ... } // namespace math libmath++-0.0.4/math++/Makefile.am0000644000177600001440000000136010114643632017060 0ustar trapniusers00000000000000#include $(top_srcdir)/niceprint.mak AM_CXXFLAGS = -pedantic -ansi -Wall -Wno-long-long lib_LTLIBRARIES = libmath++.la libmath___la_SOURCES = utils.cpp libmath___la_LDFLAGS = -version-info @MATH_VERSION_INFO@ mathinc_HEADERS = \ nodes.h nodes.tcc \ reader.h reader.tcc \ printer.h printer.tcc \ calculator.h calculator.tcc \ derive.h derive.tcc \ simplifier.h simplifier.tcc \ expander.h expander.tcc \ library.h library.tcc \ matcher.h matcher.tcc \ utils.h utils.tcc \ visitor.h error.h mathincdir = $(includedir)/math++ install-exec-hook: $(mkinstalldirs) $(DESTDIR)$(mathincdir) # this is just a test program wich is needed for testing newly implemented things noinst_PROGRAMS = t1 t1_SOURCES = t1.cpp t1_LDADD = libmath++.la libmath++-0.0.4/math++/derive.tcc0000644000177600001440000001435207464474665017030 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: derive.tcc,v 1.7 2002/05/03 11:51:17 cparpart Exp $ // (This file contains the derivation specific template member methods) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// namespace math { template TNode *TDeriver::derive(TNode *AExpression) { TDeriver derive; AExpression->accept(derive); return derive.FResult; } template TDeriver::TDeriver() : FResult(0) { } template void TDeriver::visit(TNumberNode *ANode) { // [const]' = 0 FResult = new TNumberNode(T(0)); } template void TDeriver::visit(TSymbolNode *ANode) { // [const]' = 0 FResult = new TNumberNode(T(0)); } template void TDeriver::visit(TParamNode *ANode) { // [x]' = 1 <:= [x^1]' = 1x^0 // :=> [x]' = 1 FResult = new TNumberNode(T(1)); } template void TDeriver::visit(TPlusNode *ANode) { // [f + g]' = f' + g' FResult = new TPlusNode( derive(ANode->left()), derive(ANode->right()) ); } template void TDeriver::visit(TNegNode *ANode) { // [-f]' = -(f') FResult = new TNegNode( derive(ANode->node()) ); } template void TDeriver::visit(TMulNode *ANode) { // [f * g]' = f'g + g'f FResult = new TPlusNode( new TMulNode( derive(ANode->left()), ANode->right()->clone() ), new TMulNode( derive(ANode->right()), ANode->left()->clone() ) ); } template void TDeriver::visit(TDivNode *ANode) { // [f(x)/g(x)]' = (f'g - g'f)/(g^2), g <> 0 FResult = new TDivNode( new TPlusNode( new TMulNode( derive(ANode->left()), ANode->right()->clone() ), new TNegNode( new TMulNode( derive(ANode->right()), ANode->left()->clone() ) ) ), new TPowNode( ANode->right()->clone(), new TNumberNode(2) ) ); } template void TDeriver::visit(TPowNode *ANode) { // [f ^ g]' = f^g * (g'ln(f) + (f'g)/f) FResult = new TMulNode( ANode->clone(), new TPlusNode( new TMulNode( derive(ANode->right()), new TLnNode(ANode->left()->clone()) ), new TDivNode( new TMulNode( derive(ANode->left()), ANode->right()->clone() ), ANode->left()->clone() ) ) ); } template void TDeriver::visit(TSqrtNode *ANode) { // [sqrt(f)]' = sqrt'(f) * f' } template void TDeriver::visit(TSinNode *ANode) { // [sin(f(x))]' = sin'(f(x))*f'(x) // = cos(f(x))*f'(x) FResult = new TMulNode( new TCosNode( ANode->node()->clone() ), derive(ANode->node()) ); } template void TDeriver::visit(TCosNode *ANode) { // [cos(f)]' = -(sin(f) * f') FResult = new TNegNode( new TMulNode( new TSinNode( ANode->node()->clone() ), derive(ANode->node()) ) ); } template void TDeriver::visit(TTanNode *ANode) { // [tan(f)]' = (1 + tan(f)^2) * f' FResult = new TMulNode( new TPlusNode( new TNumberNode(T(1)), new TPowNode( ANode->clone(), new TNumberNode(T(2)) ) ), derive(ANode->node()) ); } template void TDeriver::visit(TLnNode *ANode) { // [ln(f)]' = f' / f FResult = new TDivNode( derive(ANode->node()), ANode->node()->clone() ); } template void TDeriver::visit(TFuncNode *ANode) { // TODO : Implement a good TFuncNode<> derivation here. FResult = ANode->clone(); } template void TDeriver::visit(TIfNode *ANode) { FResult = new TIfNode( ANode->condition()->clone(), derive(ANode->trueExpr()), derive(ANode->falseExpr()) ); } template void TDeriver::visit(TEquNode *ANode) { FResult = new TEquNode( ANode->left()->clone(), ANode->right()->clone() ); } template void TDeriver::visit(TUnEquNode *ANode) { FResult = new TUnEquNode( ANode->left()->clone(), ANode->right()->clone() ); } template void TDeriver::visit(TGreaterNode *ANode) { FResult = new TGreaterNode( ANode->left()->clone(), ANode->right()->clone() ); } template void TDeriver::visit(TLessNode *ANode) { FResult = new TLessNode( ANode->left()->clone(), ANode->right()->clone() ); } template void TDeriver::visit(TGreaterEquNode *ANode) { FResult = new TGreaterEquNode( ANode->left()->clone(), ANode->right()->clone() ); } template void TDeriver::visit(TLessEquNode *ANode) { FResult = new TLessEquNode( ANode->left()->clone(), ANode->right()->clone() ); } } // namespace math libmath++-0.0.4/math++/nodes.tcc0000644000177600001440000003215510114641555016637 0ustar trapniusers00000000000000/////////////////////////////////////////////////////////////////////// // Math Type Library // $Id: nodes.tcc,v 1.9 2002/07/02 00:56:12 cparpart Exp $ // (This file contains the expression tree specific template members) // // Copyright (c) 2002 by Christian Parpart // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public License // along with this library; see the file COPYING.LIB. If not, write to // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////// #ifndef libmath_nodes_h #error You may not include math++/nodes.tcc directly; include math++/nodes.h instead. #endif #include #include #include namespace math { // TNode template TNode::TNode(TNodeType ANodeType, short APriority, TNode *AParent) : FNodeType(ANodeType), FPriority(APriority), FParent(AParent) { } template TNode::TNode(const TNode& ANode) : FNodeType(ANode.FNodeType), FPriority(ANode.FPriority), FParent(ANode.FParent) { } template void TNode::parent(TNode *AParent) { FParent = AParent; } template TNode::~TNode() { } template typename TNode::TNodeType TNode::nodeType() const { return FNodeType; } template short TNode::priority() const { return FPriority; } template TNode *TNode::parent() const { return const_cast *>(FParent); } template TNode *TNode::left() const { // the node doesn't support children by default return 0; } template TNode *TNode::right() const { // the node doesn't support children by default return 0; } template bool operator==(const TNode& a, const TNode& b) { return a.equals(&b); } template bool operator!=(const TNode& a, const TNode& b) { return !(a == b); } // TNumberNode template TNumberNode::TNumberNode(const T& ANumber) : TNode(TNode::NUMBER_NODE, 0), FNumber(ANumber) { } template T TNumberNode::number() const { return FNumber; } template void TNumberNode::accept(TNodeVisitor& v) { v.visit(this); } template TNumberNode *TNumberNode::clone() const { return new TNumberNode(FNumber); } template bool TNumberNode::equals(const TNode *ANode) const { return this && ANode && ANode->nodeType() == TNode::NUMBER_NODE && FNumber == static_cast *>(ANode)->FNumber; } // TSymbolNode template TSymbolNode::TSymbolNode(const std::string& ASymbol) : TNode(TNode::SYMBOL_NODE, 0), FSymbol(ASymbol) { } template std::string TSymbolNode::symbol() const { return FSymbol; } template void TSymbolNode::accept(TNodeVisitor& v) { v.visit(this); } template TSymbolNode *TSymbolNode::clone() const { return new TSymbolNode(FSymbol); } template bool TSymbolNode::equals(const TNode *ANode) const { return this && ANode && ANode->nodeType() == TNode::SYMBOL_NODE && FSymbol == static_cast *>(ANode)->FSymbol; } // TParamNode template TParamNode::TParamNode() : TNode(TNode::PARAM_NODE, 0) { } template void TParamNode::accept(TNodeVisitor& v) { v.visit(this); } template TParamNode *TParamNode::clone() const { return new TParamNode(); } template bool TParamNode::equals(const TNode *ANode) const { return this && ANode && ANode->nodeType() == TNode::PARAM_NODE; } // TUnaryNodeOp template TUnaryNodeOp::TUnaryNodeOp(typename TUnaryNodeOp::TNodeType AType, short APrio, TNode *ANode) : TNode(AType, APrio), FNode(ANode) { FNode->parent(this); } template TNode *TUnaryNodeOp::node() const { return const_cast *>(FNode.get()); } template TNode *TUnaryNodeOp::right() const { return const_cast *>(FNode.get()); } template bool TUnaryNodeOp::equals(const TNode *ANode) const { // this method does not make use of the left() for performance reasons return this && ANode && this->nodeType() == ANode->nodeType() && FNode->equals(static_cast *>(ANode)->FNode.get()); } // TBinaryNodeOp template TBinaryNodeOp::TBinaryNodeOp(typename TBinaryNodeOp::TNodeType AType, short APrio, TNode *ALeft, TNode *ARight) : TNode(AType, APrio), FLeft(ALeft), FRight(ARight) { FLeft->parent(this); FRight->parent(this); } template TNode *TBinaryNodeOp::left() const { return const_cast *>(FLeft.get()); } template TNode *TBinaryNodeOp::right() const { return const_cast *>(FRight.get()); } template bool TBinaryNodeOp::equals(const TNode *ANode) const { // this method does not make use of the left() and right() methods // for performance reasons return this && ANode && this->nodeType() == ANode->nodeType() && FLeft->equals(static_cast *>(ANode)->FLeft.get()) && FRight->equals(static_cast *>(ANode)->FRight.get()); } // TPlusNode template TPlusNode::TPlusNode(TNode *ALeft, TNode *ARight) : TBinaryNodeOp(TNode::PLUS_NODE, -5, ALeft, ARight) { } template void TPlusNode::accept(TNodeVisitor& v) { v.visit(this); } template TPlusNode *TPlusNode::clone() const { return new TPlusNode(this->left()->clone(), this->right()->clone()); } // TNegNode template TNegNode::TNegNode(TNode *ANode) : TUnaryNodeOp(TNode::NEG_NODE, -5, ANode) { } template void TNegNode::accept(TNodeVisitor& v) { v.visit(this); } template TNegNode *TNegNode::clone() const { return new TNegNode(this->node()->clone()); } // TMulNode template TMulNode::TMulNode(TNode *ALeft, TNode *ARight) : TBinaryNodeOp(TNode::MUL_NODE, -3, ALeft, ARight) { } template void TMulNode::accept(TNodeVisitor& v) { v.visit(this); } template TMulNode *TMulNode::clone() const { return new TMulNode(this->left()->clone(), this->right()->clone()); } // TDivNode template TDivNode::TDivNode(TNode *ALeft, TNode *ARight) : TBinaryNodeOp(TNode::DIV_NODE, -3, ALeft, ARight) { } template void TDivNode::accept(TNodeVisitor& v) { v.visit(this); } template TDivNode *TDivNode::clone() const { return new TDivNode(this->left()->clone(), this->right()->clone()); } // TPowNode template TPowNode::TPowNode(TNode *ALeft, TNode *ARight) : TBinaryNodeOp(TNode::POW_NODE, -1, ALeft, ARight) { } template void TPowNode::accept(TNodeVisitor& v) { v.visit(this); } template TPowNode *TPowNode::clone() const { return new TPowNode(this->left()->clone(), this->right()->clone()); } // TSqrtNode template TSqrtNode::TSqrtNode(TNode *ANode) : TUnaryNodeOp(TNode::SQRT_NODE, -1, ANode) { } template void TSqrtNode::accept(TNodeVisitor& v) { v.visit(this); } template TSqrtNode *TSqrtNode::clone() const { return new TSqrtNode(this->node()->clone()); } // TSinNode template TSinNode::TSinNode(TNode *ANode) : TUnaryNodeOp(TNode::SIN_NODE, -1, ANode) { } template void TSinNode::accept(TNodeVisitor& v) { v.visit(this); } template TSinNode *TSinNode::clone() const { return new TSinNode(this->node()->clone()); } // TCosNode template TCosNode::TCosNode(TNode *ANode) : TUnaryNodeOp(TNode::COS_NODE, -1, ANode) { } template void TCosNode::accept(TNodeVisitor& v) { v.visit(this); } template TCosNode *TCosNode::clone() const { return new TCosNode(this->node()->clone()); } // TTanNode template TTanNode::TTanNode(TNode *ANode) : TUnaryNodeOp(TNode::TAN_NODE, -1, ANode) { } template void TTanNode::accept(TNodeVisitor& v) { v.visit(this); } template TTanNode *TTanNode::clone() const { return new TTanNode(this->node()->clone()); } // TCoTanNode // TArcSinNode // TArcCosNode // TArcTanNode // TArcCoTanNode // TLnNode template TLnNode::TLnNode(TNode *ANode) : TUnaryNodeOp(TNode::LN_NODE, -1, ANode) { } template void TLnNode::accept(TNodeVisitor& v) { v.visit(this); } template TLnNode *TLnNode::clone() const { return new TLnNode(this->node()->clone()); } // TFuncNode template TFuncNode::TFuncNode(const std::string& AName, TNode *AParam) : TUnaryNodeOp(TNode::FUNC_NODE, -1, AParam), FName(AName) { } template std::string TFuncNode::name() const { return FName; } template void TFuncNode::accept(TNodeVisitor& v) { v.visit(this); } template TFuncNode *TFuncNode::clone() const { return new TFuncNode(FName, this->node()->clone()); } // TIfNode template TIfNode::TIfNode(TNode *ACondNode, TNode *AThenNode, TNode *AElseNode) : TBinaryNodeOp(TNode::IF_NODE, -1, AThenNode, AElseNode), FCondition(ACondNode) { } template TNode *TIfNode::condition() const { return FCondition.get(); } template TNode *TIfNode::trueExpr() const { return this->left(); } template TNode *TIfNode::falseExpr() const { return this->right(); } template void TIfNode::accept(TNodeVisitor& v) { v.visit(this); } template TIfNode *TIfNode::clone() const { return new TIfNode(this->FCondition->clone(), this->left()->clone(), this->right()->clone()); } // TEquNode template TEquNode::TEquNode(TNode *ALeft, TNode *ARight) : TBinaryNodeOp(TNode::EQU_NODE, -10, ALeft, ARight) { } template void TEquNode::accept(TNodeVisitor& v) { v.visit(this); } template TEquNode *TEquNode::clone() const { return new TEquNode(this->left()->clone(), this->right()->clone()); } // TUnEquNode template TUnEquNode::TUnEquNode(TNode *ALeft, TNode *ARight) : TBinaryNodeOp(TNode::UNEQU_NODE, -10, ALeft, ARight) { } template void TUnEquNode::accept(TNodeVisitor& v) { v.visit(this); } template TUnEquNode *TUnEquNode::clone() const { return new TUnEquNode(this->left()->clone(), this->right()->clone()); } // TGreaterNode template TGreaterNode::TGreaterNode(TNode *ALeft, TNode *ARight) : TBinaryNodeOp(TNode::GREATER_NODE, -10, ALeft, ARight) { } template void TGreaterNode::accept(TNodeVisitor& v) { v.visit(this); } template TGreaterNode *TGreaterNode::clone() const { return new TGreaterNode(this->left()->clone(), this->right()->clone()); } // TLessNode template TLessNode::TLessNode(TNode *ALeft, TNode *ARight) : TBinaryNodeOp(TNode::LESS_NODE, -10, ALeft, ARight) { } template void TLessNode::accept(TNodeVisitor& v) { v.visit(this); } template TLessNode *TLessNode::clone() const { return new TLessNode(this->left()->clone(), this->right()->clone()); } // TGreaterEquNode template TGreaterEquNode::TGreaterEquNode(TNode *ALeft, TNode *ARight) : TBinaryNodeOp(TNode::GREATER_EQU_NODE, -10, ALeft, ARight) { } template void TGreaterEquNode::accept(TNodeVisitor& v) { v.visit(this); } template TGreaterEquNode *TGreaterEquNode::clone() const { return new TGreaterEquNode(this->left()->clone(), this->right()->clone()); } // TLessEquNode template TLessEquNode::TLessEquNode(TNode *ALeft, TNode *ARight) : TBinaryNodeOp(TNode::LESS_EQU_NODE, -10, ALeft, ARight) { } template void TLessEquNode::accept(TNodeVisitor& v) { v.visit(this); } template TLessEquNode *TLessEquNode::clone() const { return new TLessEquNode(this->left()->clone(), this->right()->clone()); } } // namespace math libmath++-0.0.4/autogen.sh0000755000177600001440000000155610114642375015760 0ustar trapniusers00000000000000#! /bin/sh if [ "$1" = "clean" ] || [ "$1" = "-clean" ] || [ "$1" = "--clean" ]; then rm -f Makefile aclocal.m4 config.cache config.guess config.h config.h.in config.log config.status config.sub configure install-sh libtool ltconfig ltmain.sh missing mkinstalldirs stamp-h stamp-h.in depcomp stamp-h1 *~ find . \( -name '*.o' -o -name '*.lo' -o -name 'Makefile.in' -o -name 'Makefile' -o -name '.libs' -o -name '.deps' \) -exec rm -rf {} \; &> /dev/null rm -rf autom4te*cache exit 0 fi export WANT_AUTOMAKE="1.7" export WANT_AUTOCONF_2_5=1 ACINCLUDES="-I ." [ -d /opt/surakware/share/aclocal ] && ACINCLUDES="${ACINCLUDES} -I /opt/surakware/share/aclocal" aclocal ${ACINCLUDES} && autoheader && autoconf && libtoolize --automake && automake -ac || exit 1 echo "Don't forget the standard procudure:" echo "example: ./configure --prefix=/usr && make && make install" libmath++-0.0.4/ChangeLog0000644000177600001440000000004507447002276015526 0ustar trapniusers00000000000000 May the ChangeLog be with you. libmath++-0.0.4/Makefile.am0000644000177600001440000000014307447002276016007 0ustar trapniusers00000000000000SUBDIRS = math++ examples doc api-doc: make -C doc api-doc EXTRA_DIST = bootstrap niceprint.mak