COIN-OR::LEMON - Graph Library

Ticket #211: aix_fix-794458e32559.patch

File aix_fix-794458e32559.patch, 19.8 KB (added by Peter Kovacs, 16 years ago)
  • lemon/lgf_reader.h

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1235151635 -3600
    # Node ID 794458e325590c011cda01b4b98f9bf6eba7b4b4
    # Parent  879c55700cd4bf2903772de56606fc0aa6e99710
    Various fixes for compiling on AIX (#211, #212)
    
    diff --git a/lemon/lgf_reader.h b/lemon/lgf_reader.h
    a b  
    390390  template <typename Digraph>
    391391  class DigraphReader;
    392392
    393   /// \brief Return a \ref DigraphReader class
    394   ///
    395   /// This function just returns a \ref DigraphReader class.
    396   /// \relates DigraphReader
    397393  template <typename Digraph>
    398   DigraphReader<Digraph> digraphReader(Digraph& digraph,
    399                                        std::istream& is = std::cin) {
    400     DigraphReader<Digraph> tmp(digraph, is);
    401     return tmp;
    402   }
    403 
    404   /// \brief Return a \ref DigraphReader class
    405   ///
    406   /// This function just returns a \ref DigraphReader class.
    407   /// \relates DigraphReader
     394  DigraphReader<Digraph> digraphReader(Digraph& digraph,
     395                                       std::istream& is = std::cin);
    408396  template <typename Digraph>
    409   DigraphReader<Digraph> digraphReader(Digraph& digraph,
    410                                        const std::string& fn) {
    411     DigraphReader<Digraph> tmp(digraph, fn);
    412     return tmp;
    413   }
    414 
    415   /// \brief Return a \ref DigraphReader class
    416   ///
    417   /// This function just returns a \ref DigraphReader class.
    418   /// \relates DigraphReader
     397  DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn);
    419398  template <typename Digraph>
    420   DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
    421     DigraphReader<Digraph> tmp(digraph, fn);
    422     return tmp;
    423   }
     399  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char *fn);
    424400
    425401  /// \ingroup lemon_io
    426402  ///
     
    584560
    585561  private:
    586562
    587     friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
    588                                                   std::istream& is);
    589     friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
    590                                                   const std::string& fn);
    591     friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
    592                                                   const char *fn);
     563    template <typename DGR>
     564    friend DigraphReader<DGR> digraphReader(DGR& digraph, std::istream& is);
     565    template <typename DGR>
     566    friend DigraphReader<DGR> digraphReader(DGR& digraph,
     567                                            const std::string& fn);
     568    template <typename DGR>
     569    friend DigraphReader<DGR> digraphReader(DGR& digraph, const char *fn);
    593570
    594571    DigraphReader(DigraphReader& other)
    595572      : _is(other._is), local_is(other.local_is), _digraph(other._digraph),
     
    870847      while (readSuccess() && line >> c && c != '@') {
    871848        readLine();
    872849      }
    873       line.putback(c);
     850      if (readSuccess()) {
     851        line.putback(c);
     852      }
    874853    }
    875854
    876855    void readNodes() {
     
    12101189
    12111190  };
    12121191
    1213   template <typename Graph>
    1214   class GraphReader;
    1215 
    1216   /// \brief Return a \ref GraphReader class
     1192  /// \brief Return a \ref DigraphReader class
    12171193  ///
    1218   /// This function just returns a \ref GraphReader class.
    1219   /// \relates GraphReader
    1220   template <typename Graph>
    1221   GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) {
    1222     GraphReader<Graph> tmp(graph, is);
     1194  /// This function just returns a \ref DigraphReader class.
     1195  /// \relates DigraphReader
     1196  template <typename Digraph>
     1197  DigraphReader<Digraph> digraphReader(Digraph& digraph, std::istream& is) {
     1198    DigraphReader<Digraph> tmp(digraph, is);
    12231199    return tmp;
    12241200  }
    12251201
    1226   /// \brief Return a \ref GraphReader class
     1202  /// \brief Return a \ref DigraphReader class
    12271203  ///
    1228   /// This function just returns a \ref GraphReader class.
    1229   /// \relates GraphReader
    1230   template <typename Graph>
    1231   GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
    1232     GraphReader<Graph> tmp(graph, fn);
     1204  /// This function just returns a \ref DigraphReader class.
     1205  /// \relates DigraphReader
     1206  template <typename Digraph>
     1207  DigraphReader<Digraph> digraphReader(Digraph& digraph,
     1208                                       const std::string& fn) {
     1209    DigraphReader<Digraph> tmp(digraph, fn);
    12331210    return tmp;
    12341211  }
    12351212
    1236   /// \brief Return a \ref GraphReader class
     1213  /// \brief Return a \ref DigraphReader class
    12371214  ///
    1238   /// This function just returns a \ref GraphReader class.
    1239   /// \relates GraphReader
    1240   template <typename Graph>
    1241   GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
    1242     GraphReader<Graph> tmp(graph, fn);
     1215  /// This function just returns a \ref DigraphReader class.
     1216  /// \relates DigraphReader
     1217  template <typename Digraph>
     1218  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
     1219    DigraphReader<Digraph> tmp(digraph, fn);
    12431220    return tmp;
    12441221  }
    12451222
     1223  template <typename Graph>
     1224  class GraphReader;
     1225 
     1226  template <typename Graph>
     1227  GraphReader<Graph> graphReader(Graph& graph,
     1228                                 std::istream& is = std::cin);
     1229  template <typename Graph>
     1230  GraphReader<Graph> graphReader(Graph& graph, const std::string& fn);
     1231  template <typename Graph>
     1232  GraphReader<Graph> graphReader(Graph& graph, const char *fn);
     1233
    12461234  /// \ingroup lemon_io
    12471235  ///
    12481236  /// \brief \ref lgf-format "LGF" reader for undirected graphs
     
    13681356    }
    13691357
    13701358  private:
    1371     friend GraphReader<Graph> graphReader<>(Graph& graph, std::istream& is);
    1372     friend GraphReader<Graph> graphReader<>(Graph& graph,
    1373                                             const std::string& fn);
    1374     friend GraphReader<Graph> graphReader<>(Graph& graph, const char *fn);
     1359    template <typename GR>
     1360    friend GraphReader<GR> graphReader(GR& graph, std::istream& is);
     1361    template <typename GR>
     1362    friend GraphReader<GR> graphReader(GR& graph, const std::string& fn);
     1363    template <typename GR>
     1364    friend GraphReader<GR> graphReader(GR& graph, const char *fn);
    13751365
    13761366    GraphReader(GraphReader& other)
    13771367      : _is(other._is), local_is(other.local_is), _graph(other._graph),
     
    16991689      while (readSuccess() && line >> c && c != '@') {
    17001690        readLine();
    17011691      }
    1702       line.putback(c);
     1692      if (readSuccess()) {
     1693        line.putback(c);
     1694      }
    17031695    }
    17041696
    17051697    void readNodes() {
     
    20402032
    20412033  };
    20422034
     2035  /// \brief Return a \ref GraphReader class
     2036  ///
     2037  /// This function just returns a \ref GraphReader class.
     2038  /// \relates GraphReader
     2039  template <typename Graph>
     2040  GraphReader<Graph> graphReader(Graph& graph, std::istream& is) {
     2041    GraphReader<Graph> tmp(graph, is);
     2042    return tmp;
     2043  }
     2044
     2045  /// \brief Return a \ref GraphReader class
     2046  ///
     2047  /// This function just returns a \ref GraphReader class.
     2048  /// \relates GraphReader
     2049  template <typename Graph>
     2050  GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
     2051    GraphReader<Graph> tmp(graph, fn);
     2052    return tmp;
     2053  }
     2054
     2055  /// \brief Return a \ref GraphReader class
     2056  ///
     2057  /// This function just returns a \ref GraphReader class.
     2058  /// \relates GraphReader
     2059  template <typename Graph>
     2060  GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
     2061    GraphReader<Graph> tmp(graph, fn);
     2062    return tmp;
     2063  }
     2064
    20432065  class SectionReader;
    20442066
    20452067  SectionReader sectionReader(std::istream& is);
     
    22262248      while (readSuccess() && line >> c && c != '@') {
    22272249        readLine();
    22282250      }
    2229       line.putback(c);
     2251      if (readSuccess()) {
     2252        line.putback(c);
     2253      }
    22302254    }
    22312255
    22322256  public:
     
    25672591      while (readSuccess() && line >> c && c != '@') {
    25682592        readLine();
    25692593      }
    2570       line.putback(c);
     2594      if (readSuccess()) {
     2595        line.putback(c);
     2596      }
    25712597    }
    25722598
    25732599    void readMaps(std::vector<std::string>& maps) {
  • lemon/lgf_writer.h

    diff --git a/lemon/lgf_writer.h b/lemon/lgf_writer.h
    a b  
    350350  template <typename Digraph>
    351351  class DigraphWriter;
    352352
    353   /// \brief Return a \ref DigraphWriter class
    354   ///
    355   /// This function just returns a \ref DigraphWriter class.
    356   /// \relates DigraphWriter
    357353  template <typename Digraph>
    358354  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    359                                        std::ostream& os = std::cout) {
    360     DigraphWriter<Digraph> tmp(digraph, os);
    361     return tmp;
    362   }
    363 
    364   /// \brief Return a \ref DigraphWriter class
    365   ///
    366   /// This function just returns a \ref DigraphWriter class.
    367   /// \relates DigraphWriter
     355                                       std::ostream& os = std::cout);
    368356  template <typename Digraph>
    369357  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    370                                        const std::string& fn) {
    371     DigraphWriter<Digraph> tmp(digraph, fn);
    372     return tmp;
    373   }
     358                                       const std::string& fn);
    374359
    375   /// \brief Return a \ref DigraphWriter class
    376   ///
    377   /// This function just returns a \ref DigraphWriter class.
    378   /// \relates DigraphWriter
    379360  template <typename Digraph>
    380361  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    381                                        const char* fn) {
    382     DigraphWriter<Digraph> tmp(digraph, fn);
    383     return tmp;
    384   }
     362                                       const char* fn);
     363
    385364
    386365  /// \ingroup lemon_io
    387366  ///
     
    526505
    527506  private:
    528507
    529     friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
    530                                                   std::ostream& os);
    531     friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
    532                                                   const std::string& fn);
    533     friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
    534                                                   const char *fn);
     508    template <typename DGR>
     509    friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
     510                                            std::ostream& os);
     511    template <typename DGR>
     512    friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
     513                                            const std::string& fn);
     514    template <typename DGR>
     515    friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
     516                                            const char *fn);
    535517
    536518    DigraphWriter(DigraphWriter& other)
    537519      : _os(other._os), local_os(other.local_os), _digraph(other._digraph),
     
    933915    /// @}
    934916  };
    935917
     918  /// \brief Return a \ref DigraphWriter class
     919  ///
     920  /// This function just returns a \ref DigraphWriter class.
     921  /// \relates DigraphWriter
     922  template <typename Digraph>
     923  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
     924                                       std::ostream& os) {
     925    DigraphWriter<Digraph> tmp(digraph, os);
     926    return tmp;
     927  }
     928
     929  /// \brief Return a \ref DigraphWriter class
     930  ///
     931  /// This function just returns a \ref DigraphWriter class.
     932  /// \relates DigraphWriter
     933  template <typename Digraph>
     934  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
     935                                       const std::string& fn) {
     936    DigraphWriter<Digraph> tmp(digraph, fn);
     937    return tmp;
     938  }
     939
     940  /// \brief Return a \ref DigraphWriter class
     941  ///
     942  /// This function just returns a \ref DigraphWriter class.
     943  /// \relates DigraphWriter
     944  template <typename Digraph>
     945  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
     946                                       const char* fn) {
     947    DigraphWriter<Digraph> tmp(digraph, fn);
     948    return tmp;
     949  }
     950
    936951  template <typename Graph>
    937952  class GraphWriter;
    938953
    939   /// \brief Return a \ref GraphWriter class
    940   ///
    941   /// This function just returns a \ref GraphWriter class.
    942   /// \relates GraphWriter
    943954  template <typename Graph>
    944955  GraphWriter<Graph> graphWriter(const Graph& graph,
    945                                  std::ostream& os = std::cout) {
    946     GraphWriter<Graph> tmp(graph, os);
    947     return tmp;
    948   }
    949 
    950   /// \brief Return a \ref GraphWriter class
    951   ///
    952   /// This function just returns a \ref GraphWriter class.
    953   /// \relates GraphWriter
     956                                 std::ostream& os = std::cout);
    954957  template <typename Graph>
    955   GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
    956     GraphWriter<Graph> tmp(graph, fn);
    957     return tmp;
    958   }
    959 
    960   /// \brief Return a \ref GraphWriter class
    961   ///
    962   /// This function just returns a \ref GraphWriter class.
    963   /// \relates GraphWriter
     958  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn);
    964959  template <typename Graph>
    965   GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
    966     GraphWriter<Graph> tmp(graph, fn);
    967     return tmp;
    968   }
     960  GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn);
    969961
    970962  /// \ingroup lemon_io
    971963  ///
     
    10811073
    10821074  private:
    10831075
    1084     friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
    1085                                             std::ostream& os);
    1086     friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
    1087                                             const std::string& fn);
    1088     friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
    1089                                             const char *fn);
    1090 
     1076    template <typename GR>
     1077    friend GraphWriter<GR> graphWriter(const GR& graph,
     1078                                       std::ostream& os);
     1079    template <typename GR>
     1080    friend GraphWriter<GR> graphWriter(const GR& graph,
     1081                                       const std::string& fn);
     1082    template <typename GR>
     1083    friend GraphWriter<GR> graphWriter(const GR& graph,
     1084                                       const char *fn);
     1085   
    10911086    GraphWriter(GraphWriter& other)
    10921087      : _os(other._os), local_os(other.local_os), _graph(other._graph),
    10931088        _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) {
     
    15341529    /// @}
    15351530  };
    15361531
     1532  /// \brief Return a \ref GraphWriter class
     1533  ///
     1534  /// This function just returns a \ref GraphWriter class.
     1535  /// \relates GraphWriter
     1536  template <typename Graph>
     1537  GraphWriter<Graph> graphWriter(const Graph& graph,
     1538                                 std::ostream& os) {
     1539    GraphWriter<Graph> tmp(graph, os);
     1540    return tmp;
     1541  }
     1542
     1543  /// \brief Return a \ref GraphWriter class
     1544  ///
     1545  /// This function just returns a \ref GraphWriter class.
     1546  /// \relates GraphWriter
     1547  template <typename Graph>
     1548  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
     1549    GraphWriter<Graph> tmp(graph, fn);
     1550    return tmp;
     1551  }
     1552
     1553  /// \brief Return a \ref GraphWriter class
     1554  ///
     1555  /// This function just returns a \ref GraphWriter class.
     1556  /// \relates GraphWriter
     1557  template <typename Graph>
     1558  GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
     1559    GraphWriter<Graph> tmp(graph, fn);
     1560    return tmp;
     1561  }
     1562
    15371563  class SectionWriter;
    15381564
    15391565  SectionWriter sectionWriter(std::istream& is);
  • lemon/path.h

    diff --git a/lemon/path.h b/lemon/path.h
    a b  
    929929    };
    930930
    931931    template <typename Target, typename Source,
    932               bool buildEnable = BuildTagIndicator<Target>::value,
    933               bool revEnable = RevPathTagIndicator<Source>::value>
    934     struct PathCopySelector {
     932              bool buildEnable = BuildTagIndicator<Target>::value>
     933    struct PathCopySelectorForward {
    935934      static void copy(Target& target, const Source& source) {
    936935        target.clear();
    937936        for (typename Source::ArcIt it(source); it != INVALID; ++it) {
     
    941940    };
    942941
    943942    template <typename Target, typename Source>
    944     struct PathCopySelector<Target, Source, false, true> {
     943    struct PathCopySelectorForward<Target, Source, true> {
     944      static void copy(Target& target, const Source& source) {
     945        target.clear();
     946        target.build(source);
     947      }
     948    };
     949
     950    template <typename Target, typename Source,
     951              bool buildEnable = BuildTagIndicator<Target>::value>
     952    struct PathCopySelectorBackward {
    945953      static void copy(Target& target, const Source& source) {
    946954        target.clear();
    947955        for (typename Source::RevArcIt it(source); it != INVALID; ++it) {
     
    951959    };
    952960
    953961    template <typename Target, typename Source>
    954     struct PathCopySelector<Target, Source, true, false> {
    955       static void copy(Target& target, const Source& source) {
    956         target.clear();
    957         target.build(source);
    958       }
    959     };
    960 
    961     template <typename Target, typename Source>
    962     struct PathCopySelector<Target, Source, true, true> {
     962    struct PathCopySelectorBackward<Target, Source, true> {
    963963      static void copy(Target& target, const Source& source) {
    964964        target.clear();
    965965        target.buildRev(source);
    966966      }
    967967    };
    968968
     969   
     970    template <typename Target, typename Source,
     971              bool revEnable = RevPathTagIndicator<Source>::value>
     972    struct PathCopySelector {
     973      static void copy(Target& target, const Source& source) {
     974        PathCopySelectorForward<Target, Source>::copy(target, source);
     975      }     
     976    };
     977
     978    template <typename Target, typename Source>
     979    struct PathCopySelector<Target, Source, true> {
     980      static void copy(Target& target, const Source& source) {
     981        PathCopySelectorBackward<Target, Source>::copy(target, source);
     982      }     
     983    };
     984
    969985  }
    970986
    971987
  • lemon/random.h

    diff --git a/lemon/random.h b/lemon/random.h
    a b  
    344344      }
    345345    };
    346346
    347     template <typename Result, int exp, bool pos = (exp >= 0)>
     347    template <typename Result, int exp>
    348348    struct ShiftMultiplier {
    349349      static const Result multiplier() {
    350350        Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
    351351        res *= res;
    352         if ((exp & 1) == 1) res *= static_cast<Result>(2.0);
    353         return res;
    354       }
    355     };
    356 
    357     template <typename Result, int exp>
    358     struct ShiftMultiplier<Result, exp, false> {
    359       static const Result multiplier() {
    360         Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
    361         res *= res;
    362352        if ((exp & 1) == 1) res *= static_cast<Result>(0.5);
    363353        return res;
    364354      }
    365355    };
    366356
    367357    template <typename Result>
    368     struct ShiftMultiplier<Result, 0, true> {
     358    struct ShiftMultiplier<Result, 0> {
    369359      static const Result multiplier() {
    370360        return static_cast<Result>(1.0);
    371361      }
    372362    };
    373363
    374364    template <typename Result>
    375     struct ShiftMultiplier<Result, -20, true> {
     365    struct ShiftMultiplier<Result, 20> {
    376366      static const Result multiplier() {
    377367        return static_cast<Result>(1.0/1048576.0);
    378368      }
    379369    };
    380370
    381371    template <typename Result>
    382     struct ShiftMultiplier<Result, -32, true> {
     372    struct ShiftMultiplier<Result, 32> {
    383373      static const Result multiplier() {
    384         return static_cast<Result>(1.0/424967296.0);
     374        return static_cast<Result>(1.0/4294967296.0);
    385375      }
    386376    };
    387377
    388378    template <typename Result>
    389     struct ShiftMultiplier<Result, -53, true> {
     379    struct ShiftMultiplier<Result, 53> {
    390380      static const Result multiplier() {
    391381        return static_cast<Result>(1.0/9007199254740992.0);
    392382      }
    393383    };
    394384
    395385    template <typename Result>
    396     struct ShiftMultiplier<Result, -64, true> {
     386    struct ShiftMultiplier<Result, 64> {
    397387      static const Result multiplier() {
    398388        return static_cast<Result>(1.0/18446744073709551616.0);
    399389      }
     
    413403      static const int bits = std::numeric_limits<Word>::digits;
    414404
    415405      static Result convert(RandomCore<Word>& rnd) {
    416         return Shifting<Result, - shift - rest>::
     406        return Shifting<Result, shift + rest>::
    417407          shift(static_cast<Result>(rnd() >> (bits - rest)));
    418408      }
    419409    };
     
    423413      static const int bits = std::numeric_limits<Word>::digits;
    424414
    425415      static Result convert(RandomCore<Word>& rnd) {
    426         return Shifting<Result, - shift - bits>::
     416        return Shifting<Result, shift + bits>::
    427417          shift(static_cast<Result>(rnd())) +
    428418          RealConversion<Result, Word, rest-bits, shift + bits>::
    429419          convert(rnd);