Changeset d07137 in git for factory


Ignore:
Timestamp:
Oct 15, 2003, 7:19:41 PM (21 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
ecd23349865d588d280037e46df36f300536d5a2
Parents:
2499bf918092002632ace751f0bbae7bd5a2cccb
Message:
*hannes: faster conversions


git-svn-id: file:///usr/local/Singular/svn/trunk@6895 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
factory
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • factory/NTLconvert.cc

    r2499bf rd07137  
    1 /* $Id: NTLconvert.cc,v 1.11 2003-08-28 11:54:31 Singular Exp $ */
     1/* $Id: NTLconvert.cc,v 1.12 2003-10-15 17:19:38 Singular Exp $ */
    22#include <config.h>
    33
     
    453453  char dummy[2];
    454454  int minusremainder=0;
     455  char numbers[]="0123456789abcdef";
    455456
    456457  coeff_long=to_long(coefficient);
     
    479480
    480481    int l=0;
    481     while (coefficient>9)
     482    while (coefficient>15)
    482483    {
    483484      ZZ quotient,remaind;
    484       ZZ ten;ten=10;
     485      ZZ ten;ten=16;
    485486      DivRem(quotient,remaind,coefficient,ten);
    486       dummy[0]=(char)(to_long(remaind)+'0');
     487      dummy[0]=numbers[to_long(remaind)];
    487488      //tmp*=10; tmp+=to_long(remaind);
    488489
     
    505506    }
    506507    //built up the string in dummy[0]
    507     dummy[0]=(char)(to_long(coefficient)+'0');
     508    dummy[0]=numbers[to_long(coefficient)];
    508509    strcat(cf_stringtemp,dummy);
    509510    //tmp*=10; tmp+=to_long(coefficient);
     
    526527
    527528  //convert the string to canonicalform using the char*-Constructor
    528   return CanonicalForm(cf_stringtemp2);
     529  return CanonicalForm(cf_stringtemp2,16);
    529530  //return tmp;
    530531}
  • factory/canonicalform.cc

    r2499bf rd07137  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: canonicalform.cc,v 1.32 2001-06-18 08:44:35 pfister Exp $ */
     2/* $Id: canonicalform.cc,v 1.33 2003-10-15 17:19:39 Singular Exp $ */
    33
    44#include <config.h>
     
    4949
    5050//{{{ constructors, destructors, selectors
    51 CanonicalForm::CanonicalForm( const char * str ) : value( CFFactory::basic( str ) )
     51CanonicalForm::CanonicalForm( const char * str, const int base ) : value( CFFactory::basic( str, base ) )
    5252{
    5353}
  • factory/canonicalform.h

    r2499bf rd07137  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: canonicalform.h,v 1.27 2001-06-22 15:57:41 Singular Exp $ */
     2/* $Id: canonicalform.h,v 1.28 2003-10-15 17:19:39 Singular Exp $ */
    33
    44#ifndef INCL_CANONICALFORM_H
     
    5656    CF_INLINE CanonicalForm( const Variable & );
    5757    CF_INLINE CanonicalForm( const Variable &, int );
    58     CanonicalForm( const char * ); // use with caution - does only handle integers !!!
     58    CanonicalForm( const char *, const int base=10 ); // use with caution - does only handle integers !!!
    5959
    6060    CF_NO_INLINE ~CanonicalForm();
  • factory/cf_factory.cc

    r2499bf rd07137  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: cf_factory.cc,v 1.3 1997-06-19 12:27:13 schmidt Exp $ */
     2/* $Id: cf_factory.cc,v 1.4 2003-10-15 17:19:40 Singular Exp $ */
    33
    44#include <config.h>
     
    119119
    120120InternalCF *
     121CFFactory::basic ( const char * str, int base )
     122{
     123    if ( currenttype == IntegerDomain ) {
     124        InternalInteger * dummy = new InternalInteger( str, base );
     125        if ( dummy->is_imm() ) {
     126            InternalCF * res = int2imm( dummy->intval() );
     127            delete dummy;
     128            return res;
     129        }
     130        else
     131            return dummy;
     132    }
     133//     else  if ( currenttype == RationalDomain ) {
     134//      InternalRational * dummy = new InternalRational( str );
     135//      if ( dummy->is_imm() ) {
     136//          InternalCF * res = int2imm( dummy->intval() );
     137//          delete dummy;
     138//          return res;
     139//      }
     140//      else
     141//          return dummy;
     142//     }
     143    else  if ( currenttype == FiniteFieldDomain ) {
     144        InternalInteger * dummy = new InternalInteger( str, base );
     145        InternalCF * res = int2imm_p( dummy->intmod( ff_prime ) );
     146        delete dummy;
     147        return res;
     148    }
     149    else  if ( currenttype == GaloisFieldDomain ) {
     150        InternalInteger * dummy = new InternalInteger( str, base );
     151        InternalCF * res = int2imm_gf( gf_int2gf( dummy->intmod( ff_prime ) ) );
     152        delete dummy;
     153        return res;
     154    }
     155    else  if ( currenttype == PrimePowerDomain )
     156        return new InternalPrimePower( str, base );
     157    else {
     158        ASSERT( 0, "illegal basic domain!" );
     159        return 0;
     160    }
     161}
     162
     163InternalCF *
    121164CFFactory::basic ( int type, const char * const str )
    122165{
  • factory/cf_factory.h

    r2499bf rd07137  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: cf_factory.h,v 1.3 2001-11-05 17:07:12 Singular Exp $ */
     2/* $Id: cf_factory.h,v 1.4 2003-10-15 17:19:40 Singular Exp $ */
    33
    44#ifndef INCL_CF_FACTORY_H
     
    2525    static InternalCF * basic ( int type, int value );
    2626    static InternalCF * basic ( const char * str );
     27    static InternalCF * basic ( const char * str, int base );
    2728    static InternalCF * basic ( int type, const char * const str );
    2829    static InternalCF * basic ( int type, int value, bool nonimm );
  • factory/int_int.cc

    r2499bf rd07137  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: int_int.cc,v 1.16 2001-01-24 12:59:36 Singular Exp $ */
     2/* $Id: int_int.cc,v 1.17 2003-10-15 17:19:40 Singular Exp $ */
    33
    44#include <config.h>
     
    2727InternalInteger::InternalInteger( const MP_INT & mpi) : thempi( mpi ) {}
    2828
    29 InternalInteger::InternalInteger( const char * str )
    30 {
    31     mpz_init_set_str( &thempi, str, 10 );
     29InternalInteger::InternalInteger( const char * str, const int base )
     30{
     31    mpz_init_set_str( &thempi, str, base );
    3232}
    3333
  • factory/int_int.h

    r2499bf rd07137  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: int_int.h,v 1.10 2000-09-04 13:31:30 obachman Exp $ */
     2/* $Id: int_int.h,v 1.11 2003-10-15 17:19:41 Singular Exp $ */
    33
    44#ifndef INCL_INT_INT_H
     
    5858    }
    5959    InternalInteger( const int i );
    60     InternalInteger( const char * str );
     60    InternalInteger( const char * str, const int base=10 );
    6161    InternalInteger( const MP_INT & );
    6262    ~InternalInteger();
  • factory/int_pp.cc

    r2499bf rd07137  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: int_pp.cc,v 1.9 1998-06-26 16:14:26 schmidt Exp $ */
     2/* $Id: int_pp.cc,v 1.10 2003-10-15 17:19:41 Singular Exp $ */
    33
    44#include <config.h>
     
    3838InternalPrimePower::InternalPrimePower( const MP_INT & mpi ) : thempi( mpi ) {}
    3939
    40 InternalPrimePower::InternalPrimePower( const char * str )
    41 {
    42     mpz_init_set_str( &thempi, str, 10 );
     40InternalPrimePower::InternalPrimePower( const char * str, const int base )
     41{
     42    mpz_init_set_str( &thempi, str, base );
    4343    if ( mpz_cmp_si( &thempi, 0 ) < 0 ) {
    4444        mpz_neg( &thempi, &thempi );
  • factory/int_pp.h

    r2499bf rd07137  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: int_pp.h,v 1.3 1997-06-19 12:22:29 schmidt Exp $ */
     2/* $Id: int_pp.h,v 1.4 2003-10-15 17:19:41 Singular Exp $ */
    33
    44#ifndef INCL_INT_PP_H
     
    3636    }
    3737    InternalPrimePower( const int i );
    38     InternalPrimePower( const char * str );
     38    InternalPrimePower( const char * str, const int base=10 );
    3939    InternalPrimePower( const MP_INT & );
    4040    ~InternalPrimePower();
Note: See TracChangeset for help on using the changeset viewer.