Changeset 3056

Show
Ignore:
Timestamp:
09/30/08 17:04:20 (2 months ago)
Author:
saunders
Message:

commentator mods to eliminate some destructor problems.
use of /dev/null may be less portable.

Location:
trunk/linbox
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/linbox/linbox/util/commentator.C

    r2814 r3056  
    8181 
    8282        Commentator::Commentator ()  
    83                 : cnull (new nullstreambuf), _estimationMethod (BEST_ESTIMATE), _format (OUTPUT_CONSOLE), 
     83                //: cnull (new nullstreambuf), _estimationMethod (BEST_ESTIMATE), _format (OUTPUT_CONSOLE), 
     84                : cnull ("/dev/null"), _estimationMethod (BEST_ESTIMATE), _format (OUTPUT_CONSOLE), 
    8485                  _show_timing (true), _show_progress (true), _show_est_time (true) 
    8586        { 
     
    9596        } 
    9697        Commentator::Commentator (std::ostream& out)  
    97                 : cnull (new nullstreambuf), _estimationMethod (BEST_ESTIMATE), _format (OUTPUT_CONSOLE), 
     98                //: cnull (new nullstreambuf), _estimationMethod (BEST_ESTIMATE), _format (OUTPUT_CONSOLE), 
     99                : cnull ("/dev/null"), _estimationMethod (BEST_ESTIMATE), _format (OUTPUT_CONSOLE), 
    98100                  _show_timing (true), _show_progress (true), _show_est_time (true) 
    99101        { 
    100                 registerMessageClass (BRIEF_REPORT,         out, 1, LEVEL_IMPORTANT); 
     102                //registerMessageClass (BRIEF_REPORT,         out, 1, LEVEL_IMPORTANT); 
    101103                registerMessageClass (BRIEF_REPORT,         out, 1, LEVEL_IMPORTANT); 
    102104                registerMessageClass (PROGRESS_REPORT,      _report); 
     
    110112 
    111113        Commentator::~Commentator() { 
    112                 std::map <const char *, MessageClass *, LessThanString>::iterator i; 
     114                std::map <const char *, MessageClass * >::iterator i; 
    113115                for (i = _messageClasses.begin (); i != _messageClasses.end (); ++i)  
    114116                        delete i->second; 
     
    182184                if (isPrinted (_activities.size (), LEVEL_IMPORTANT, BRIEF_REPORT, fn)) 
    183185                { 
    184                 //std::cout << "calling finishA "; 
    185186                        finishActivityReport (*top_act, msg); 
    186                         //std::cout << std::endl; 
    187187                } 
    188188 
     
    282282        { 
    283283                MessageClass &briefReportClass = getMessageClass (BRIEF_REPORT); 
    284                 std::map <const char *, MessageClass *, LessThanString>::iterator i; 
     284                std::map <const char *, MessageClass *>::iterator i; 
    285285 
    286286                for (i = _messageClasses.begin (); i != _messageClasses.end (); ++i) 
     
    292292        { 
    293293                MessageClass &briefReportClass = getMessageClass (BRIEF_REPORT); 
    294                 std::map <const char *, MessageClass *, LessThanString>::iterator i; 
     294                std::map <const char *, MessageClass *>::iterator i; 
    295295 
    296296                for (i = _messageClasses.begin (); i != _messageClasses.end (); ++i) 
     
    336336        { 
    337337                MessageClass &briefReportClass = getMessageClass (BRIEF_REPORT); 
    338                 std::map <const char *, MessageClass *, LessThanString>::iterator i; 
     338                std::map <const char *, MessageClass *>::iterator i; 
    339339 
    340340                for (i = _messageClasses.begin (); i != _messageClasses.end (); ++i) 
     
    366366        void Commentator::setReportStream (std::ostream &stream)  
    367367        { 
     368                setMessageClassStream (BRIEF_REPORT,      stream); 
    368369                setMessageClassStream (PROGRESS_REPORT,      stream); 
    369370                setMessageClassStream (TIMING_MEASURE,       stream); 
     
    472473        void Commentator::finishActivityReport (Activity &activity, const char *msg)  
    473474        { 
    474         //std::cout << "finishA " << _show_progress << _show_timing << std::endl; 
    475475                MessageClass &messageClass = getMessageClass (BRIEF_REPORT); 
    476476                unsigned int i; 
     
    584584        bool MessageClass::isPrinted (unsigned long depth, unsigned long level, const char *fn) 
    585585        { 
     586                return  
     587                        checkConfig (_configuration[""], depth, level)  
     588                        || 
     589                        (       fn != (const char *) 0  
     590                                &&  
     591                                checkConfig (_configuration[fn], depth, level) 
     592                        ); 
     593                /* 
    586594                if (checkConfig (_configuration[""], depth, level)) 
    587                 {       //std::cout << " fn=\"\", d " << depth << ", l " << level << " false" << std::endl; 
    588595                        return true; 
    589                 } 
    590596                else if (fn != (const char *) 0) 
    591597                        //return checkConfig (_configuration[fn], depth, level); 
    592598                        { bool ans = checkConfig (_configuration[fn], depth, level); 
    593599                          if (ans)  
    594                                 {       //std::cout << " fn=" << fn << ", d " << depth << ", l " << level << " true" << std::endl; 
     600                                {       //std::cerr << " fn=" << fn << ", d " << depth << ", l " << level << " true" << std::endl; 
    595601                                        return true; 
    596602                                } 
    597603                          else 
    598                                 {       //std::cout << " fn=" << fn << ", d " << depth << ", l " << level << " false" << std::endl; 
     604                                {       //std::cerr << " fn=" << fn << ", d " << depth << ", l " << level << " false" << std::endl; 
    599605                                        return false; 
    600606                                } 
     
    602608 
    603609                else 
    604                 {       //std::cout << " fn=0, d " << depth << ", l " << level << " false" << std::endl; 
     610                {       //std::cerr << " fn=0, d " << depth << ", l " << level << " false" << std::endl; 
    605611                        return false; 
    606612                } 
     613                */ 
    607614        } 
    608615 
     
    630637                std::list <std::pair <unsigned long, unsigned long> >::iterator i; 
    631638 
    632                 i = config.begin (); 
    633                 while (i != config.end ()) { 
     639                for ( i = config.begin (); i != config.end (); ++i) { 
    634640                        if (depth < i->first) { 
    635                                 if (level <= i->second) 
    636                                         return true; 
    637                                 else 
    638                                         return false; 
    639                         } 
    640  
    641                         i++; 
     641                                //// uninitialized value error goes away if we ignore level. 
     642                                //if (level <= i->second) 
     643                                //      return true; 
     644                                //else 
     645                                //      return false; 
     646                                return true; 
     647                        } 
    642648                } 
    643649 
  • trunk/linbox/linbox/util/commentator.h

    r2962 r3056  
    8383        class MessageClass; 
    8484        class Commentator; 
    85  
    86         // Utility object needed for associative containers 
    87         struct LessThanString 
    88         { 
    89                 bool operator () (const char *str1, const char *str2) const  
    90                         { return strcmp (str1, str2) < 0; } 
    91         }; 
    9285 
    9386        // \class ActivityState commentator.h linbox/util/commentator.h 
     
    528521                /** Use this stream to disable a message class entirely 
    529522                 */ 
    530                 std::ostream cnull; 
     523                std::ofstream cnull; 
    531524 
    532525            private: 
     526                /* 
    533527                // Null std::ostream prints nothing 
    534528                struct nullstreambuf : public std::streambuf { 
     
    541535                        void imbue(const std::locale &loc) {} 
    542536                }; 
     537                */ 
    543538 
    544539            protected: 
     
    567562                std::stack<Activity *>           _activities;      // Stack of activity structures 
    568563 
    569                 std::map<const char *, MessageClass *, LessThanString> 
     564                std::map<const char *, MessageClass *> 
    570565                                                 _messageClasses; 
    571566                EstimationMethod                 _estimationMethod;     // Activity estimator 
     
    668663 
    669664            private: 
    670                 typedef std::map <const char *, std::list<std::pair <unsigned long, unsigned long> >, LessThanString> Configuration; 
     665                typedef std::map <const char *, std::list<std::pair <unsigned long, unsigned long> > > Configuration; 
    671666 
    672667                class smartStreambuf : public std::streambuf  
     
    743738        class Commentator { 
    744739            public:  
    745                 inline Commentator () : cnull (new nullstreambuf) {} 
     740                //inline Commentator () : cnull (new nullstreambuf) {} 
     741                inline Commentator () : cnull ("/dev/null") {} 
    746742                inline  ~Commentator () {} 
    747743                inline void start (const char *description, const char *fn = (const char *) 0, unsigned long len = 0) {} 
     
    800796                inline bool printed (long msglevel, const char *msgclass) { return false; } 
    801797 
    802                 std::ostream cnull; 
     798                std::ofstream cnull; 
    803799 
    804800            private: 
     801                /* 
    805802                // Null std::ostream prints nothing 
    806803                struct nullstreambuf : public std::streambuf { 
     
    813810                        inline void imbue (const std::locale &loc) {} 
    814811                }; 
     812                */ 
    815813 
    816814                MessageClass _msgcls; 
  • trunk/linbox/linbox/vector/vector-domain.h

    r3027 r3056  
    423423                //@} Implementation-Specific Methods 
    424424     
     425                template <class Vector> 
     426                Vector& random(Vector& v) 
     427                { 
     428                        typename Field::RandIter r(field()); 
     429 
     430                        typedef typename Vector::iterator iterator; 
     431                        for (iterator p = v.begin(); p != v.end(); ++p) r.random(*p); 
     432                        return v; 
     433                } 
     434 
    425435        protected: 
    426436 
  • trunk/linbox/tests/test-minpoly.C

    r3031 r3056  
    363363 
    364364        static size_t n = 10; 
    365         static integer q = 2147483647U; 
     365        //static integer q = 2147483647U; 
     366        static integer q = 1000003; // ok for both Modular<int> and Modular<double> 
    366367        static int iterations = 1; 
    367368        static int numVectors = 1; 
     
    386387        if (q > 5 && q % 2 != 0 && q % 3 != 0 && q % 5 != 0 ) 
    387388        { 
    388         typedef Modular<LinBox::uint32> Field; 
    389 //      typedef Modular<double> Field; 
     389        //typedef Modular<LinBox::uint32> Field; 
     390        //typedef Modular<int> Field; 
     391        typedef Modular<double> Field; 
    390392        Field F (q); 
    391393        srand (time (NULL));