Commit 7fca32b9 authored by Jerome Galtier's avatar Jerome Galtier
Browse files

Rework monoid and series representations for FMP.

	* include/vaucanson/algebra/concept/freemonoid_product.hh
	  (monoid_rep): Remove method declarations of `first_projection' and
	  `second_projection'. (series_rep): Add new type helpers. Rename
	  `first_projection' to `first_representation' and
	  `second_projection' to `second_representation'. Remove the `const'
	  qualifier from `first_representation' and `second_representation'.
	  Change return types to references. Add const versions.
	* include/vaucanson/algebra/concept/freemonoid_product.hxx: Remove
	  implementations of `first_projection' and `second_projection' for
	  `monoid_rep'. Rework implementation of `first_representation' and
	  `second_representation'.
	* include/vaucanson/contexts/fmp_transducer_maker.thh
	  (make_automaton): Remove the last two arguments.
	* include/vaucanson/contexts/fmp_transducer_maker.thxx
	  (make_automaton): Remove a `FIXME'. Update implementation
	  according to the modified prototypes.
	* taf-kit/src/common.hh (arguments_t): Remove the two attributes
	  `srep1' and `srep2'.
	* taf-kit/src/edition_commands.hxx,
	* taf-kit/src/fmp_commands.cc,
	* taf-kit/src/getters.hxx: Update calls to `make_automaton'.
	* taf-kit/src/main.cc: Use `p_opts1' and `p_opts2' to setup the
	  first and second series representation respectively.
parent b55be297
2008-11-27 Jerome Galtier <jerome.galtier@lrde.epita.fr>
Rework monoid and series representations for FMP.
* include/vaucanson/algebra/concept/freemonoid_product.hh
(monoid_rep): Remove method declarations of `first_projection' and
`second_projection'. (series_rep): Add new type helpers. Rename
`first_projection' to `first_representation' and
`second_projection' to `second_representation'. Remove the `const'
qualifier from `first_representation' and `second_representation'.
Change return types to references. Add const versions.
* include/vaucanson/algebra/concept/freemonoid_product.hxx: Remove
implementations of `first_projection' and `second_projection' for
`monoid_rep'. Rework implementation of `first_representation' and
`second_representation'.
* include/vaucanson/contexts/fmp_transducer_maker.thh
(make_automaton): Remove the last two arguments.
* include/vaucanson/contexts/fmp_transducer_maker.thxx
(make_automaton): Remove a `FIXME'. Update implementation
according to the modified prototypes.
* taf-kit/src/common.hh (arguments_t): Remove the two attributes
`srep1' and `srep2'.
* taf-kit/src/edition_commands.hxx,
* taf-kit/src/fmp_commands.cc,
* taf-kit/src/getters.hxx: Update calls to `make_automaton'.
* taf-kit/src/main.cc: Use `p_opts1' and `p_opts2' to setup the
first and second series representation respectively.
2008-11-27 Jerome Galtier <jerome.galtier@lrde.epita.fr>
 
Typo in comments.
......
......@@ -58,10 +58,6 @@ namespace vcsn {
std::string close_par;
monoid_rep();
/// Project an FMP monoid representation.
monoid_rep<F> first_projection() const;
monoid_rep<S> second_projection() const;
};
/*-------------------------------------------------------------.
......@@ -73,6 +69,8 @@ namespace vcsn {
{
// Type helpers.
typedef series_rep<Semiring, F> parent_t;
typedef series_rep<Semiring, F> first_rep_t;
typedef series_rep<Semiring, S> second_rep_t;
using parent_t::open_par;
using parent_t::close_par;
......@@ -87,9 +85,17 @@ namespace vcsn {
/// Default CTOR.
series_rep();
/// Project an FMP series representation.
series_rep<Semiring, F> first_projection() const;
series_rep<Semiring, S> second_projection() const;
/// Accessors.
first_rep_t& first_representation();
second_rep_t& second_representation();
const first_rep_t& first_representation() const;
const second_rep_t& second_representation() const;
private:
/// Representation derived when constructing K<<F>>
first_rep_t first_representation_;
second_rep_t second_representation_;
};
template <typename F, typename S>
......
......@@ -44,66 +44,38 @@ namespace vcsn
concat = "";
}
template <typename F, typename S>
monoid_rep<F>
monoid_rep<FreeMonoidProduct<F, S> >::first_projection() const
template <typename Semiring, typename F, typename S>
series_rep<Semiring, FreeMonoidProduct<F, S> >::series_rep() :
series_rep<Semiring, F>()
{
monoid_rep<F> ret;
ret.empty = empty;
return ret;
}
template <typename F, typename S>
monoid_rep<S>
monoid_rep<FreeMonoidProduct<F, S> >::second_projection() const
template <typename Semiring, typename F, typename S>
series_rep<Semiring, F>&
series_rep<Semiring, FreeMonoidProduct<F, S> >::first_representation()
{
monoid_rep<S> ret;
ret.empty = empty;
return ret;
return first_representation_;
}
template <typename Semiring, typename F, typename S>
series_rep<Semiring, FreeMonoidProduct<F, S> >::series_rep() :
series_rep<Semiring, F>()
const series_rep<Semiring, F>&
series_rep<Semiring, FreeMonoidProduct<F, S> >::first_representation() const
{
return first_representation_;
}
template <typename Semiring, typename F, typename S>
series_rep<Semiring, F>
series_rep<Semiring, FreeMonoidProduct<F, S> >::first_projection() const
const series_rep<Semiring, S>&
series_rep<Semiring, FreeMonoidProduct<F, S> >::second_representation() const
{
series_rep<Semiring, F> ret;
ret.open_par = open_par;
ret.close_par = close_par;
ret.plus = plus;
ret.times = times;
ret.star = star;
ret.zero = zero;
ret.open_weight = open_weight;
ret.close_weight = close_weight;
ret.spaces = spaces;
return ret;
return second_representation_;
}
template <typename Semiring, typename F, typename S>
series_rep<Semiring, S>
series_rep<Semiring, FreeMonoidProduct<F, S> >::second_projection() const
series_rep<Semiring, S>&
series_rep<Semiring, FreeMonoidProduct<F, S> >::second_representation()
{
series_rep<Semiring, S> ret;
ret.open_par = open_par;
ret.close_par = close_par;
ret.plus = plus;
ret.times = times;
ret.star = star;
ret.zero = zero;
ret.open_weight = open_weight;
ret.close_weight = close_weight;
ret.spaces = spaces;
return ret;
return second_representation_;
}
template <typename F, typename S>
......
......@@ -37,9 +37,7 @@ namespace vcsn
const monoid_rep_t& mrep,
const first_monoid_rep_t& mrep1,
const second_monoid_rep_t& mrep2,
const series_rep_t& srep,
const first_series_rep_t& srep1,
const second_series_rep_t& srep2);
const series_rep_t& srep);
template <class FirstInputIterator, class SecondInputIterator>
automaton_t make_automaton(const FirstInputIterator first_begin,
......@@ -55,9 +53,7 @@ namespace vcsn
const monoid_rep_t& mrep,
const first_monoid_rep_t& mrep1,
const second_monoid_rep_t& mrep2,
const series_rep_t& srep,
const first_series_rep_t& srep1,
const second_series_rep_t& srep2);
const series_rep_t& srep);
template <class T1, class T2>
monoid_elt_t make_couple(const T1& first_alphabet,
......
......@@ -67,9 +67,7 @@ namespace vcsn
const monoid_rep_t& mrep,
const first_monoid_rep_t& mrep1,
const second_monoid_rep_t& mrep2,
const series_rep_t& srep,
const first_series_rep_t& srep1,
const second_series_rep_t& srep2)
const series_rep_t& srep)
{
first_alphabet_t first_alpha;
......@@ -85,7 +83,6 @@ namespace vcsn
first_monoid_t mA(first_alpha, mrep1);
second_monoid_t mB(second_alpha, mrep2);
monoid_t freemonoidproduct(mA, mB, mrep);
// FIXME: srep1 and srep2 cannot be used.
series_set_t series(semiring, freemonoidproduct, srep);
return automata_set_t(series);
......@@ -109,14 +106,12 @@ namespace vcsn
const monoid_rep_t& mrep,
const first_monoid_rep_t& mrep1,
const second_monoid_rep_t& mrep2,
const series_rep_t& srep,
const first_series_rep_t& srep1,
const second_series_rep_t& srep2)
const series_rep_t& srep)
{
return automaton_t(make_automata_set(first_begin, first_end,
second_begin, second_end,
mrep, mrep1, mrep2,
srep, srep1, srep2));
srep));
}
template <class T1, class T2>
......@@ -133,13 +128,11 @@ namespace vcsn
const monoid_rep_t& mrep,
const first_monoid_rep_t& mrep1,
const second_monoid_rep_t& mrep2,
const series_rep_t& srep,
const first_series_rep_t& srep1,
const second_series_rep_t& srep2)
const series_rep_t& srep)
{
return make_automaton(first_alphabet.begin(), first_alphabet.end(),
second_alphabet.begin(), second_alphabet.end(),
mrep, mrep1, mrep2, srep, srep1, srep2);
mrep, mrep1, mrep2, srep);
}
template <class FirstIterator, class SecondIterator>
......
......@@ -104,10 +104,6 @@ struct arguments_t
series_rep_t srep;
# ifdef WITH_TWO_ALPHABETS
// Representation of Series<Semiring, FirstMonoid>
IOAUT_CONTEXT::series_rep_t srep1;
// Representation of Series<Semiring, SecondMonoid>
IOAUT_CONTEXT::series_rep_t srep2;
// Representation of FirstMonoid.
first_monoid_rep_t mrep1;
// Representation of SecondMonoid.
......
......@@ -430,7 +430,7 @@ static int edit_automaton_command (const arguments_t& args)
# else
automaton_t a = make_automaton (first_alphabet_t (), second_alphabet_t (),
args.mrep, args.mrep1, args.mrep2,
args.srep, args.srep1, args.srep2);
args.srep);
# endif // !WITH_TWO_ALPHABETS
std::fstream input (args.args[1]);
......@@ -450,7 +450,7 @@ static int edit_automaton_command (const arguments_t& args)
a = make_automaton (get_first_alphabet (args.alphabet1),
get_second_alphabet (args.alphabet2),
args.mrep, args.mrep1, args.mrep2,
args.srep, args.srep1, args.srep2);
args.srep);
# endif // !WITH_TWO_ALPHABETS
}
......
......@@ -88,7 +88,8 @@ DEFINE_COMMAND (NAME (evaluation)
evaluation (src,
IOAUT_CONTEXT::make_rat_exp(src.structure().
series().monoid().first_monoid().alphabet(),
args.args[2], args.mrep1, args.srep1)) <<
args.args[2], args.mrep1,
args.srep.first_representation())) <<
std::endl)
RETURNVALUE (0));
......@@ -97,7 +98,7 @@ DEFINE_COMMAND (NAME (evaluation_fmp)
automaton_t src = get_aut(args, 1);
IOAUT_CONTEXT::automaton_t a = get_boolean_aut(args, 2);
IOAUT_CONTEXT::automaton_t res =
IOAUT_CONTEXT::make_automaton(src.structure().series().monoid().second_monoid().alphabet(), *(src.structure().series().monoid().second_monoid().representation()), args.srep2);
IOAUT_CONTEXT::make_automaton(src.structure().series().monoid().second_monoid().alphabet(), *(src.structure().series().monoid().second_monoid().representation()), args.srep.second_representation());
evaluation_fmp(src, a, res))
KEEP_AUTOMATON (res)
RETURNVALUE (0));
......@@ -106,7 +107,7 @@ DEFINE_COMMAND (NAME (domain)
CODE (
automaton_t src = get_aut(args, 1);
IOAUT_CONTEXT::automaton_t a =
IOAUT_CONTEXT::make_automaton(src.structure().series().monoid().first_monoid().alphabet(), *(src.structure().series().monoid().first_monoid().representation()), args.srep1);
IOAUT_CONTEXT::make_automaton(src.structure().series().monoid().first_monoid().alphabet(), *(src.structure().series().monoid().first_monoid().representation()), args.srep.first_representation());
domain(src, a))
KEEP_AUTOMATON (a)
RETURNVALUE (0));
......@@ -115,7 +116,7 @@ DEFINE_COMMAND (NAME (image)
CODE (
automaton_t src = get_aut(args, 1);
IOAUT_CONTEXT::automaton_t a =
IOAUT_CONTEXT::make_automaton(src.structure().series().monoid().second_monoid().alphabet(), *(src.structure().series().monoid().second_monoid().representation()), args.srep2);
IOAUT_CONTEXT::make_automaton(src.structure().series().monoid().second_monoid().alphabet(), *(src.structure().series().monoid().second_monoid().representation()), args.srep.second_representation());
image(src, a))
KEEP_AUTOMATON (a)
RETURNVALUE (0));
......@@ -139,7 +140,7 @@ DEFINE_COMMAND (NAME (intersection)
get_boolean_aut(args, 1);
IOAUT_CONTEXT::alphabet_t A =
a.structure().series().monoid().alphabet();
automaton_t fmp = make_automaton(A, A, args.mrep, *(a.structure().series().monoid().representation()), *(a.structure().series().monoid().representation()), args.srep, *(a.structure().series().representation()), *(a.structure().series().representation()));
automaton_t fmp = make_automaton(A, A, args.mrep, *(a.structure().series().monoid().representation()), *(a.structure().series().monoid().representation()), args.srep);
identity(a, fmp))
KEEP_AUTOMATON (fmp)
RETURNVALUE (0));
......
......@@ -161,7 +161,7 @@ static automaton_t get_aut (const arguments_t& args, int n)
# ifndef WITH_TWO_ALPHABETS
automaton_t a = make_automaton (alphabet_t (), args.mrep, args.srep);
# else
automaton_t a = make_automaton (first_alphabet_t (), second_alphabet_t (), args.mrep, args.mrep1, args.mrep2, args.srep, args.srep1, args.srep2);
automaton_t a = make_automaton (first_alphabet_t (), second_alphabet_t (), args.mrep, args.mrep1, args.mrep2, args.srep);
# endif // !WITH_TWO_ALPHABETS
# ifdef GLOBAL_RESULT
......@@ -217,7 +217,8 @@ static IOAUT_CONTEXT::automaton_t get_boolean_aut(const arguments_t& args, const
using namespace vcsn::xml;
IOAUT_CONTEXT::automaton_t a =
IOAUT_CONTEXT::make_automaton(first_alphabet_t(), args.mrep1, args.srep1);
IOAUT_CONTEXT::make_automaton(first_alphabet_t(), args.mrep1,
args.srep.first_representation());
# ifdef GLOBAL_RESULT
switch (GLOBAL_RESULT.input_type)
......
......@@ -104,16 +104,16 @@ namespace
"Set the first alphabet for rational expressions or automata", 0 },
{ "alphabet2", 'A', "ALPHABET", 0,
"Set the second alphabet for rational expressions or automata", 0 },
{ "parser1", 'p', "OPTIONS", 0,
{ "parser1", 'P', "OPTIONS", 0,
"Set the first parsing options for rational expressions", 0 },
{ "parser2", 'P', "OPTIONS", 0,
{ "parser2", 'Q', "OPTIONS", 0,
"Set the second parsing options for rational expressions", 0 },
#else /* ! WITH_TWO_ALPHABETS */
{ "alphabet", 'a', "ALPHABET", 0,
"Set the alphabet for rational expressions or automata", 0 },
#endif /* ! WITH_TWO_ALPHABETS */
{ "parser", 'p', "OPTIONS", 0,
"Set the parsing options for rational expressions", 0 },
#endif /* ! WITH_TWO_ALPHABETS */
#ifndef NO_PREDEF_ALPHABETS
{ 0, 0, 0, 0, "The following alphabets are predefined:\n"
......@@ -192,6 +192,9 @@ namespace
break;
#ifdef WITH_TWO_ALPHABETS
case 'P':
args.add_parser1_option(NULL, arg);
break;
case 'Q':
args.add_parser2_option(NULL, arg);
break;
#endif /* ! WITH_TWO_ALPHABETS */
......@@ -333,9 +336,9 @@ int main (int argc, char* argv[])
li->args.alphabet1 = p_opts1.get_letters();
li->args.alphabet2 = p_opts2.get_letters();
li->args.srep1 = p_opts.get_srep().first_projection();
li->args.srep.first_representation() = p_opts1.get_srep();
li->args.mrep1 = p_opts1.get_mrep();
li->args.srep2 = p_opts.get_srep().second_projection();
li->args.srep.second_representation() = p_opts2.get_srep();
li->args.mrep2 = p_opts2.get_mrep();
#endif
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment