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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ add_custom_target(docs ALL
${CMAKE_CURRENT_SOURCE_DIR}
${SPHINX_HTML_DIR}
COMMENT "Building HTML documentation with Sphinx"
SOURCES ${DOC_SOURCES}
DEPENDS run_examples
SOURCES ${DOC_SOURCES} conf.py
)
set_target_properties(docs PROPERTIES FOLDER "CMake Targets")
2,442 changes: 2,442 additions & 0 deletions docs/Doxyfile

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
================
The Symbol class
================

.. doxygenclass:: codegenvar::Symbol

------------
Constructors
------------
A Symbol object can be initialized as a named symbol or a constant.

.. code-block:: c++

Symbol x("x"), y("y"), zero(0), c3(3.0);
auto vars = Symbol::Array("a", "b", "c", 0, 3.14);

.. doxygengroup:: symbol_ctors
:content-only:

-----------------------
Mathematical operations
-----------------------
The :cpp:class:`codegenvar::Symbol` class has support for the following mathematical operations.

.. doxygengroup:: symbol_math_ops
:content-only:

----------------------
Mathematical functions
----------------------
The :cpp:class:`codegenvar::Symbol` class has support for the following mathematical operations.

.. doxygengroup:: symbol_math_functions
:content-only:

------------------
Logical operations
------------------
The :cpp:class:`codegenvar::Symbol` class has support for the following boolean operations.

.. NOTE::

If you plan to use these boolean operations, have a look at :doc:`conditional_example`.

.. doxygengroup:: symbol_logical_ops
:content-only:
2 changes: 1 addition & 1 deletion docs/conditional_example.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
EXCEPTION: Your code contains conditional branches, but you haven't created a boolean evaluator.
See http://cppcodegenvar.readthedocs.io/en/latest/conditional_example.html for details.
<src>/CppCodeGenVar/src/BooleanEvaluator.cpp line 100
<src>/CppCodeGenVar/src/BooleanEvaluator.cpp line 112
...
z = 0 == y ?
x :
Expand Down
25 changes: 22 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
# import sys
# sys.path.insert(0, os.path.abspath('.'))

# -- Doxygen preprocessing ------------------------------------------------
import os
import subprocess

build_doxygen = os.environ.get('READTHEDOCS', None) == 'True'

if build_doxygen:
subprocess.call('doxygen', shell=True)

# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
Expand All @@ -34,8 +43,13 @@
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.ifconfig',
'sphinx_tabs.tabs',
'sphinx.ext.githubpages']
'sphinx_tabs.tabs',
'sphinx.ext.githubpages',
'breathe']

# Breathe configurations
breathe_projects = {"cppcodegenvar": "doxyout/xml"}
breathe_default_project = "cppcodegenvar"

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down Expand Up @@ -100,10 +114,15 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = []
import sphinx_rtd_theme
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

# I don't know why this is necessary.
html_context = {
'css_files': ['https://media.readthedocs.org/css/sphinx_rtd_theme.css'],
}

# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
Expand Down
5 changes: 3 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ its `GitHub Site
<https://github.com/bjornpiltz/CppCodeGenVar>`_ .

.. toctree::
:maxdepth: 1
:maxdepth: 4
:hidden:

examples
api
installation
license
license
5 changes: 3 additions & 2 deletions docs/pip-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# we use sphinx_tabs
sphinx_tabs
sphinx>=1.4
breathe>=4.5
sphinx_tabs
14 changes: 12 additions & 2 deletions include/codegenvar/Symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ namespace codegenvar {

namespace internal {class SymbolPrivate;}

/**
* The class Symbol is the main class of the CppCondegenVar project.
*/
class Symbol
{
public:
Expand All @@ -25,10 +28,13 @@ class Symbol
explicit Symbol(double value);
explicit Symbol(const Scalar& value);

// Constructors creating variables or named constants.
/// Constructor creating a named variable.
explicit Symbol(const std::string&);

// Constructor creating an array of symbols.
/// Constructor creating an array of symbols. \ingroup symbol_ctors
/// \code
/// auto vars = Symbol::Array("a", "b", "c", 0, 3.14);
/// \endcode
template <class... Args>
static std::array<Symbol, sizeof...(Args)> Array(Args... args)
{
Expand Down Expand Up @@ -65,6 +71,9 @@ class Symbol

// Unary functions:

/** @defgroup symbol_math_functions Mathematical functions
* @{
*/
friend Symbol abs(const Symbol&);
friend Symbol log(const Symbol&);
friend Symbol exp(const Symbol&);
Expand All @@ -81,6 +90,7 @@ class Symbol
friend Symbol floor(const Symbol&);
friend Symbol ceil(const Symbol&);
friend Symbol pow(const Symbol&, const Symbol&);
/** @} */ // end of symbol_math_functions

// Booleans:
friend bool operator ==(const Symbol& lhs, const Symbol& rhs);
Expand Down
14 changes: 13 additions & 1 deletion src/BooleanEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using namespace SymEngine;
struct BooleanEvaluatorPrivate
{
static bool handle(const SymbolPrivate* lhs, const SymbolPrivate* rhs, BooleanOp op);
bool handle(RCP<const Basic> lhs, RCP<const Basic> rhs, BooleanOp op);
bool handle(SymExpr lhs, SymExpr rhs, BooleanOp op);

ConditionalTree evaluated;
ConditionalTree::Iterator currentContext;
Expand Down Expand Up @@ -51,6 +51,10 @@ std::weak_ptr<BooleanEvaluatorPrivate> BooleanEvaluator::get()
return p;
}


/** @defgroup symbol_logical_ops Logical operators
* @{
*/
bool operator ==(const Symbol& lhs, const Symbol& rhs)
{
return BooleanEvaluatorPrivate::handle(lhs.p.get(), rhs.p.get(), EQ);
Expand All @@ -66,6 +70,14 @@ bool operator > (const Symbol& lhs, const Symbol& rhs)
return BooleanEvaluatorPrivate::handle(lhs.p.get(), rhs.p.get(), GT);
}

bool operator !=(const Symbol& lhs, const Symbol& rhs){ return !(lhs == rhs);}

bool operator <=(const Symbol& lhs, const Symbol& rhs){ return !(lhs > rhs);}

bool operator >=(const Symbol& lhs, const Symbol& rhs){ return !(lhs < rhs);}
/** @} */ // end of symbol_logical_ops


namespace internal {

bool BooleanEvaluatorPrivate::handle(const SymbolPrivate *lhs, const SymbolPrivate *rhs, BooleanOp op)
Expand Down
Loading