Commit a8092940 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

Fix parsing of rational numbers without denominator.

* include/vaucanson/algebra/implementation/semiring/q_number.hxx
(operator>>): Fix parsing of rational numbers without denominator.
* taf-kit/tests/vcsn-char-q.test: Test it.
parent 811b7bc5
2012-07-17 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Fix parsing of rational numbers without denominator.
* include/vaucanson/algebra/implementation/semiring/q_number.hxx
(operator>>): Fix parsing of rational numbers without denominator.
* taf-kit/tests/vcsn-char-q.test: Test it.
2012-07-14 Alexandre Duret-Lutz <adl@lrde.epita.fr>
 
* configure.ac, doc/NEWS.txt: Bump version to 1.4.1a.
......
......@@ -2,7 +2,7 @@
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2011 The Vaucanson Group.
// Copyright (C) 2011, 2012 The Vaucanson Group.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
......@@ -152,7 +152,7 @@ namespace vcsn {
TRationalNumber<IntType>&
TRationalNumber<IntType>::operator+= (const TRationalNumber<IntType>& nb)
{
IntType g = vcsn::misc::gcd(den_,nb.den_);
IntType g = vcsn::misc::gcd(den_,nb.den_);
set_rational (nb.den_ / g * num_+ den_ / g * nb.num_, den_ / g * nb.den_);
return (*this);
}
......@@ -162,7 +162,7 @@ namespace vcsn {
TRationalNumber<IntType>&
TRationalNumber<IntType>::operator-= (const TRationalNumber<IntType>& nb)
{
IntType g = vcsn::misc::gcd(den_,nb.den_);
IntType g = vcsn::misc::gcd(den_,nb.den_);
set_rational (nb.den_ / g * num_ - den_ / g * nb.num_, den_ / g * nb.den_);
return (*this);
}
......@@ -323,16 +323,22 @@ namespace vcsn {
istr >> num;
char slash;
if (!istr.eof())
istr.get(slash);
if ('/' != slash) // Test if a slash is present.
if (istr.eof())
{
a.set(num, 1);
return istr;
}
// Do we have a slash?
istr.get(slash);
if ('/' != slash)
{
istr.unget();
a.set(num, 1);
return istr;
}
// Otherwise read the denominator.
// Read the denominator.
IntType den;
istr >> den;
a.set(num, den);
......
#! /bin/sh
# Vaucanson, a generic library for finite state machines.
# Copyright (C) 2011 The Vaucanson Group.
# Copyright (C) 2011, 2012 The Vaucanson Group.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
......@@ -100,6 +100,12 @@ $VCSN power b1.xml 4 > b4.xml
$VCSN reduce b4.xml > b4r.xml
#$VCSN data b4r.xml | grep 'States: 6'
# Make sure we don't need to use a denominator.
$VCSN exp-to-aut -aa a > c.xml
$VCSN right-mult c.xml 2 > ca.xml
$VCSN right-mult c.xml 2/1 > cb.xml
cmp ca.xml cb.xml
sed '/^#/d' <<EOF | $VCSN --alphabet=ab edit undef.xml
# Add states
1
......
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