SyFi  0.3
SyFi::Simplex Class Reference

#include <Polygon.h>

Inheritance diagram for SyFi::Simplex:
SyFi::Polygon

List of all members.

Public Member Functions

 Simplex (GiNaC::lst vertices, const std::string &subscript="")
 Simplex (const Simplex &simplex)
virtual ~Simplex ()
virtual unsigned int no_space_dim () const
virtual GiNaC::ex repr (Repr_format format=SUBS_PERFORMED) const
virtual const std::string str () const
virtual GiNaC::ex integrate (GiNaC::ex f, Repr_format format=SUBS_PERFORMED)
Simplex sub_simplex (unsigned int i)
virtual Simplexcopy () const

Detailed Description

Definition at line 241 of file Polygon.h.


Constructor & Destructor Documentation

SyFi::Simplex::Simplex ( GiNaC::lst  vertices,
const std::string &  subscript = "" 
)

Referenced by copy(), and sub_simplex().

SyFi::Simplex::Simplex ( const Simplex simplex)

Definition at line 1271 of file Polygon.cpp.

                                              :
        Polygon(simplex)
        {
        }
virtual SyFi::Simplex::~Simplex ( ) [inline, virtual]

Definition at line 246 of file Polygon.h.

{}

Member Function Documentation

Simplex * SyFi::Simplex::copy ( ) const [virtual]

Implements SyFi::Polygon.

Definition at line 1385 of file Polygon.cpp.

References Simplex().

        {
                return new Simplex(*this);
        }
ex SyFi::Simplex::integrate ( GiNaC::ex  f,
Repr_format  format = SUBS_PERFORMED 
) [virtual]

Implements SyFi::Polygon.

Definition at line 1344 of file Polygon.cpp.

References SyFi::nsd, repr(), and SyFi::Polygon::vertex().

Referenced by main().

        {
                ex ret;

                unsigned int nsd = vertex(0).nops();

                ex s_repr = repr();
                lst subs;
                for (unsigned int i=0; i< nsd; i++)
                {
                        subs.append(s_repr.op(i));
                }

                ex intf = func.subs(subs);

                for (unsigned int i=s_repr.nops()-1; i>=nsd; i--)
                {
                        intf = GiNaC::integral(s_repr.op(i).op(0), s_repr.op(i).op(1), s_repr.op(i).op(2), intf);
                        intf = GiNaC::eval_integ(intf);
                }

                return intf;
        }
unsigned int SyFi::Simplex::no_space_dim ( ) const [virtual]

Implements SyFi::Polygon.

Definition at line 1276 of file Polygon.cpp.

        {
                return p[0].nops()-1;
        }
ex SyFi::Simplex::repr ( Repr_format  format = SUBS_PERFORMED) const [virtual]

Implements SyFi::Polygon.

Definition at line 1281 of file Polygon.cpp.

References SyFi::get_symbolic_vector(), SyFi::Polygon::no_vertices(), SyFi::nsd, SyFi::Polygon::vertex(), and SyFi::x.

Referenced by integrate(), and main().

        {
                unsigned int nsd = vertex(0).nops();
                unsigned int no_lines = no_vertices()-1;

                ex r = get_symbolic_vector(nsd, "r");
                ex x = get_symbolic_vector(nsd, "x");
                ex ri;
                lst lines;
                for (unsigned int i=0; i< no_vertices()-1; i++)
                {
                        ri = r.op(i);
                        lst line_i_repr;
                        for (unsigned int d=0; d< nsd; d++)
                        {
                                line_i_repr.append(x.op(d) == (vertex(i+1).op(d) - vertex(0).op(d))*ri + vertex(0).op(d));
                        }
                        line_i_repr.append(lst(ri, 0, 1));

                        lines.append(line_i_repr);
                }

                lst ret;
                for (unsigned int i=0; i < nsd; i++)
                {
                        ri = r.op(i);
                        GiNaC::ex xi_expr;
                        GiNaC::ex rhs  = lines.op(0).op(i).rhs().coeff(ri,0);
                        for (unsigned int l=0; l < no_lines; l++)
                        {
                                //        xi_expr2 == xi_expr.lhs() == xi_expr.rhs()  + lines.op(l).op(i).rhs().coeff(ri,1)*ri;
                                rhs += lines.op(l).op(i).rhs().coeff(ri,1)*ri;

                        }
                        xi_expr = x.op(i) == rhs;
                        ret.append(xi_expr);
                }

                GiNaC::ex limit=1;
                for (unsigned int i=0; i< no_lines; i++)
                {
                        ri = r.op(i);
                        ret.append(lst(ri, 0, limit));
                        limit -= ri;
                }

                return ret;
        }
const string SyFi::Simplex::str ( ) const [virtual]

Implements SyFi::Polygon.

Definition at line 1330 of file Polygon.cpp.

Referenced by main().

        {
                std::ostringstream s;
                /*
                s <<"Simplex(";
                for (int i=0; i<p.size()-1; i++) {
                  s << p[i]<<",";
                }
                s << p[p.size()-1]<<")";
                */
                s <<"Simplex";
                return s.str();
        }
Simplex SyFi::Simplex::sub_simplex ( unsigned int  i)

Definition at line 1368 of file Polygon.cpp.

References SyFi::istr(), Simplex(), SyFi::Polygon::subscript, and test_syfi::debug::v.

Referenced by main().

        {
                if ( i < 0 || i >= p.size())
                {
                        throw std::out_of_range("Can only create subsimplices between 0 and the number of vertices-1.");
                }
                lst v;
                for (unsigned int k=0; k< p.size(); k++)
                {
                        if ( k != i)
                        {
                                v.append(p[k]);
                        }
                }
                return Simplex(v, istr(subscript, i));
        }

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator