Changeset 308a766 in git


Ignore:
Timestamp:
Nov 29, 2012, 11:02:36 PM (10 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
05c3b87378ab3e8310b306f10a0eec4bd579ca9c894604cd8e2bd80d9c29cfc35d194404eaa0d476
Parents:
4b5098278b256cb9f73dc0b32dedd20101972d76
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-11-29 23:02:36+01:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-11-29 23:08:28+01:00
Message:
Fixing Frank's Minor stuff

add: forward declarations
fix: includes
fix: assert -> assume
fix: cout, printf -> use Print(S)
fix: removed using namespace std: in headers use std::
Location:
Singular
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • Singular/Cache.h

    r4b5098 r308a766  
    44#include <string>
    55#include <list>
    6 #include <assert.h>
    7 
    8 using namespace std;
     6
     7// #include <assert.h>
     8// using namespace std;
    99
    1010/*! \class Cache
     
    7575     * as long as the pair <c>key(_rank(i)) -->  value(_rank(i))</c>.
    7676     */
    77      list<int> _rank;
     77   std::list<int> _rank;
    7878 
    7979     /**
     
    8383     * in KeyClass.
    8484     */
    85      list<KeyClass> _key;
     85     std::list<KeyClass> _key;
    8686 
    8787     /**
     
    9191     * argument \c _key[i]).
    9292     */
    93      list<ValueClass> _value;
     93     std::list<ValueClass> _value;
    9494     
    9595     /**
    9696     * container for the weights of all cached values
    9797     */
    98      list<int> _weights;
     98     std::list<int> _weights;
    9999 
    100100     /**
     
    104104     * const, as the user would expect for these methods.
    105105     */
    106      mutable typename list<KeyClass>::const_iterator _itKey;
     106     mutable typename std::list<KeyClass>::const_iterator _itKey;
    107107     
    108108     /**
     
    112112     * const, as the user would expect for these methods.
    113113     */
    114      mutable typename list<ValueClass>::const_iterator _itValue;
     114     mutable typename std::list<ValueClass>::const_iterator _itValue;
    115115 
    116116     /**
     
    314314     *         string
    315315     */
    316      string toString () const;
     316   std::string toString () const;
    317317 
    318318     /**
     
    324324};
    325325
    326 #include <CacheImplementation.h>
     326#include "CacheImplementation.h"
    327327
    328328#endif
  • Singular/CacheImplementation.h

    r4b5098 r308a766  
    11#ifndef CACHE_IMPLEMENTATION_H
    22#define CACHE_IMPLEMENTATION_H
     3
     4#include <reporter/reporter.h>
    35
    46#include <cstdio> // for sprintf
     
    5355{
    5456  _itKey = _key.end(); // referring to past-the-end element in the list
    55   typename list<KeyClass>::const_iterator itKey;
     57   typename std::list<KeyClass>::const_iterator itKey;
    5658  _itValue = _value.begin();
    5759  /* As _key is a sorted list, the following could actually be implemented
     
    8082       thus, getValue has been called although hasKey
    8183       produced no match */
    82     assert(false);
     84    assume(false);
    8385
    8486  return *_itValue;
     
    123125     erasing the last entry which is only implemented for forward
    124126     iterators by std::list. */
    125   list<int>::iterator itRank;
     127   std::list<int>::iterator itRank;
    126128  for (itRank = _rank.begin(); itRank != _rank.end(); itRank++) { }
    127129  itRank--; /* Now, this forward iterator points to the last list entry. */
     
    132134  /* now delete entries in _key and _value with index deleteIndex */
    133135  int k = 0;
    134   typename list<KeyClass>::iterator itKey;
    135   typename list<ValueClass>::iterator itValue = _value.begin();
    136   typename list<int>::iterator itWeights = _weights.begin();
     136  typename std::list<KeyClass>::iterator itKey;
     137  typename std::list<ValueClass>::iterator itValue = _value.begin();
     138  typename std::list<int>::iterator itWeights = _weights.begin();
    137139  for (itKey = _key.begin(); itKey != _key.end(); itKey++)
    138140  {
     
    176178                                       keyWasContained == false */
    177179  int k = 0;
    178   typename list<KeyClass>::iterator itKey;
     180  typename std::list<KeyClass>::iterator itKey;
    179181  // itOldValue will later only be used in the case keyWasContained == true: */
    180   typename list<ValueClass>::iterator itOldValue = _value.begin();
     182  typename std::list<ValueClass>::iterator itOldValue = _value.begin();
    181183  /* itOldWeights will later only be used in the case
    182184     keyWasContained == true */
    183   typename list<int>::iterator itOldWeights = _weights.begin();
     185  typename std::list<int>::iterator itOldWeights = _weights.begin();
    184186  for (itKey = _key.begin(); itKey != _key.end(); itKey++)
    185187  {
     
    203205  int newWeight = value.getWeight();
    204206  k = 0;
    205   typename list<ValueClass>::iterator itValue = _value.begin();
     207  typename std::list<ValueClass>::iterator itValue = _value.begin();
    206208  for (itValue = _value.begin(); itValue != _value.end(); itValue++)
    207209  {
     
    229231       _rank[oldIndexInRank] == oldIndexInKey, i.e.
    230232       _key[_rank[oldIndexInRank]] == key: */
    231     list<int>::iterator itRank;
     233    std::list<int>::iterator itRank;
    232234    k = 0;
    233235    for (itRank = _rank.begin(); itRank != _rank.end(); itRank++)
     
    306308       Let's make room for the assignment
    307309       _rank[newIndexInRank] := newIndexInKey: */
    308     list<int>::iterator itRank;
     310    std::list<int>::iterator itRank;
    309311    for (itRank = _rank.begin(); itRank != _rank.end(); itRank++)
    310312    {
     
    323325    /* let's insert new key and new value at index newIndexInKey: */
    324326    itValue = _value.begin();
    325     typename list<int>::iterator itWeights = _weights.begin();
     327    typename std::list<int>::iterator itWeights = _weights.begin();
    326328    k = 0;
    327329    for (itKey = _key.begin(); itKey != _key.end(); itKey++)
     
    344346                                 new (key, value)-pair */
    345347
    346   assert(_rank.size() == _key.size());
    347   assert(_rank.size() == _value.size());
     348  assume(_rank.size() == _key.size());
     349  assume(_rank.size() == _value.size());
    348350  return !result; /* true iff the new (key --> value) pair is
    349351                     actually in the cache now */
     
    351353
    352354template<class KeyClass, class ValueClass>
    353 string Cache<KeyClass, ValueClass>::toString() const
     355std::string Cache<KeyClass, ValueClass>::toString() const
    354356{
    355357  char h[10];
    356   string s = "Cache:";
     358  std::string s = "Cache:";
    357359  s += "\n   entries: ";
    358360  sprintf(h, "%d", getNumberOfEntries()); s += h;
     
    371373    int k = 1;
    372374    s += "\n   (key --> value) pairs in ascending order of keys:";
    373     typename list<KeyClass>::const_iterator itKey;
    374     typename list<ValueClass>::const_iterator itValue = _value.begin();
     375    typename std::list<KeyClass>::const_iterator itKey;
     376    typename std::list<ValueClass>::const_iterator itValue = _value.begin();
    375377    for (itKey = _key.begin(); itKey != _key.end(); itKey++)
    376378    {
     
    385387    }
    386388    s += "\n   (key --> value) pairs in descending order of ranks:";
    387     list<int>::const_iterator itRank;
     389    std::list<int>::const_iterator itRank;
    388390    int r = 1;
    389391    for (itRank = _rank.begin(); itRank != _rank.end(); itRank++)
     
    413415void Cache<KeyClass, ValueClass>::print() const
    414416{
    415   cout << this->toString();
     417  PrintS(this->toString().c_str());
    416418}
    417419
  • Singular/Minor.cc

    r4b5098 r308a766  
    1 #include <iostream>
    2 
    31#include "config.h"
    42#include <kernel/mod2.h>
     3
     4#include "Minor.h"
     5
    56#include <kernel/structs.h>
    67#include <kernel/polys.h>
    7 #include <Minor.h>
    88#include <kernel/febase.h>
    99
     10using namespace std;
    1011
    1112void MinorKey::reset()
     
    114115void MinorKey::print() const
    115116{
    116   cout << this->toString();
     117  PrintS(this->toString().c_str());
    117118}
    118119
     
    145146  }
    146147  /* We should never reach this line of code. */
    147   assert(false);
     148  assume(false);
    148149}
    149150
     
    176177  }
    177178  /* We should never reach this line of code. */
    178   assert(false);
     179  assume(false);
    179180}
    180181
     
    198199    }
    199200  }
    200   return;
    201201}
    202202
     
    220220    }
    221221  }
    222   return;
    223222}
    224223
     
    251250  }
    252251  /* We should never reach this line of code. */
    253   assert(false);
     252  assume(false);
    254253}
    255254
     
    282281  }
    283282  /* We should never reach this line of code. */
    284   assert(false);
     283  assume(false);
    285284}
    286285
     
    439438bool MinorKey::operator==(const MinorKey& mk) const
    440439{
    441   assert(false);
     440  assume(false);
    442441  return this->compare(mk) == 0;
    443442}
     
    447446bool MinorKey::operator<(const MinorKey& mk) const
    448447{
    449   assert(false);
     448  assume(false);
    450449  return this->compare(mk) == -1;
    451450}
     
    833832int MinorValue::getWeight () const
    834833{
    835   assert(false);  /* must be overridden in derived classes */
     834  assume(false);  /* must be overridden in derived classes */
    836835  return 0;
    837836}
     
    841840bool MinorValue::operator==(const MinorValue& mv) const
    842841{
    843   assert(false);
     842  assume(false);
    844843  return (this == &mv);  /* compare addresses of both objects */
    845844}
     
    847846string MinorValue::toString () const
    848847{
    849   assert(false);  /* must be overridden in derived classes */
     848  assume(false);  /* must be overridden in derived classes */
    850849  return "";
    851850}
     
    855854bool MinorValue::operator<(const MinorValue& mv) const
    856855{
    857   assert(false);
     856  assume(false);
    858857  return (this < &mv);  /* compare addresses of both objects */
    859858}
     
    896895void MinorValue::print() const
    897896{
    898   cout << this->toString();
     897  PrintS(this->toString().c_str());
    899898}
    900899
  • Singular/Minor.h

    r4b5098 r308a766  
    22#define MINOR_H
    33
    4 #include <assert.h>
     4// #include <assert.h>
    55#include <string>
    66
    7 #include <kernel/polys.h>
    8 
    9 using namespace std;
     7struct spolyrec; typedef struct spolyrec polyrec; typedef polyrec* poly;
     8struct ip_sring; typedef struct ip_sring* ring; typedef struct ip_sring const* const_ring;
     9
     10struct sip_sideal; typedef struct sip_sideal *       ideal;
     11
     12// using namespace std;
    1013
    1114/*! \class MinorKey
     
    391394     * string
    392395     */
    393      string toString () const;
     396   std::string toString () const;
    394397
    395398     /**
     
    683686    *         string
    684687    */
    685     virtual string toString () const;
     688   virtual std::string toString () const;
    686689   
    687690    /**
     
    771774    * string
    772775    */
    773     string toString () const;
     776   std::string toString () const;
    774777};
    775778
     
    858861    * string
    859862    */
    860     string toString () const;
     863   std::string toString () const;
    861864};
    862865
  • Singular/MinorInterface.cc

    r4b5098 r308a766  
     1#include "config.h"
     2#include <kernel/mod2.h>
     3
    14// include before anything to avoid clashes with stdio.h included elsewhere
    2 #include <cstdio>
    3 
    4 #include <MinorInterface.h>
    5 #include <MinorProcessor.h>
     5// #include <cstdio>
     6
     7#include "MinorInterface.h"
     8#include "MinorProcessor.h"
     9
     10#include <polys/simpleideals.h>
    611
    712#include <kernel/polys.h>
    813#include <kernel/structs.h>
    9 
    10 #include "config.h"
    11 #include <kernel/mod2.h>
     14#include <kernel/kstd1.h>
    1215#include <kernel/ideals.h>
    13 #include <kernel/kstd1.h>
     16
     17using namespace std;
    1418
    1519bool currRingIsOverIntegralDomain ()
     
    172176#if (defined COUNT_AND_PRINT_OPERATIONS) && (COUNT_AND_PRINT_OPERATIONS > 1)
    173177    qqq++;
    174     printf("after %d", qqq);
     178    Print("after %d", qqq);
    175179    printCounters ("-th minor", false);
    176180#endif
     
    401405#if (defined COUNT_AND_PRINT_OPERATIONS) && (COUNT_AND_PRINT_OPERATIONS > 1)
    402406    qqq++;
    403     printf("after %d", qqq);
     407    Print("after %d", qqq);
    404408    printCounters ("-th minor", false);
    405409#endif
  • Singular/MinorInterface.h

    r4b5098 r308a766  
    33
    44
    5 #include <polys/simpleideals.h>
    6 #include <kernel/polys.h>
     5struct spolyrec; typedef struct spolyrec polyrec; typedef polyrec* poly;
     6struct ip_sring; typedef struct ip_sring* ring; typedef struct ip_sring const* const_ring;
     7
     8struct sip_sideal; typedef struct sip_sideal *       ideal;
     9
     10class ip_smatrix; typedef ip_smatrix *       matrix;
    711
    812/* all computations are module char, if char <> 0;
  • Singular/MinorProcessor.cc

    r4b5098 r308a766  
    1 #include <MinorProcessor.h>
    2 
    31#include "config.h"
    42#include <kernel/mod2.h>
     3
     4#include "MinorProcessor.h"
     5
     6#include <polys/kbuckets.h>
     7
    58#include <kernel/structs.h>
    69#include <kernel/polys.h>
    710#include <kernel/febase.h>
    811#include <kernel/kstd1.h>
    9 #include <polys/kbuckets.h>
     12
     13#include <kernel/ideals.h>
     14
     15using namespace std;
    1016
    1117#ifdef COUNT_AND_PRINT_OPERATIONS
     
    213219{
    214220  /* This is a non-recursive implementation. */
    215   assert( (i >= 0) && (j >= 0) && (i >= j));
     221  assume( (i >= 0) && (j >= 0) && (i >= j));
    216222  if (j == 0 || i == j) return 1;
    217223  int result = 1;
     
    227233{
    228234  /* This is a non-recursive implementation. */
    229   assert(i >= 0);
     235  assume(i >= 0);
    230236  int result = 1;
    231237  for (int j = 1; j <= i; j++) result *= j;
     
    444450     const ideal& iSB)
    445451{
    446   assert(k > 0); /* k is the minor's dimension; the minor must be at least
     452  assume(k > 0); /* k is the minor's dimension; the minor must be at least
    447453                    1x1 */
    448454  /* The method works by recursion, and using Lapace's Theorem along the
     
    561567     const ideal& iSB)
    562568{
    563   assert(k > 0); /* k is the minor's dimension; the minor must be at least
     569  assume(k > 0); /* k is the minor's dimension; the minor must be at least
    564570                    1x1 */
    565571  int *theRows=new int[k]; mk.getAbsoluteRowIndices(theRows);
     
    652658     const int characteristic, const ideal& iSB)
    653659{
    654   assert(k > 0); /* k is the minor's dimension; the minor must be at least
     660  assume(k > 0); /* k is the minor's dimension; the minor must be at least
    655661                    1x1 */
    656662  /* The method works by recursion, and using Lapace's Theorem along
     
    944950                                                          const ideal& iSB)
    945951{
    946   assert(k > 0); /* k is the minor's dimension; the minor must be at least
     952  assume(k > 0); /* k is the minor's dimension; the minor must be at least
    947953                    1x1 */
    948954  /* The method works by recursion, and using Lapace's Theorem along the
     
    10811087     const ideal& iSB)
    10821088{
    1083   assert(k > 0); /* k is the minor's dimension; the minor must be at least
     1089  assume(k > 0); /* k is the minor's dimension; the minor must be at least
    10841090                    1x1 */
    10851091  /* The method works by recursion, and using Lapace's Theorem along
     
    13841390                                                          const ideal& iSB)
    13851391{
    1386   assert(k > 0); /* k is the minor's dimension; the minor must be at least
     1392  assume(k > 0); /* k is the minor's dimension; the minor must be at least
    13871393                    1x1 */
    13881394  int *theRows=new int[k]; mk.getAbsoluteRowIndices(theRows);
  • Singular/MinorProcessor.h

    r4b5098 r308a766  
    22#define MINOR_PROCESSOR_H
    33
    4 #include <Cache.h>
    5 #include <Minor.h>
    6 #include <assert.h>
     4#include "Cache.h"
     5#include "Minor.h"
     6
     7struct spolyrec; typedef struct spolyrec polyrec; typedef polyrec* poly;
     8struct ip_sring; typedef struct ip_sring* ring; typedef struct ip_sring const* const_ring;
     9
     10struct sip_sideal; typedef struct sip_sideal *       ideal;
     11
     12// #include <assert.h>
    713#include <string>
    814
     
    279285    * string
    280286    */
    281     virtual string toString () const;
     287   virtual std::string toString () const;
    282288
    283289    /**
     
    546552    *         string
    547553    */
    548     string toString () const;
     554   std::string toString () const;
    549555};
    550556
     
    760766    *         string
    761767    */
    762     string toString () const;
     768   std::string toString () const;
    763769};
    764770
Note: See TracChangeset for help on using the changeset viewer.