Changeset 51d835 in git


Ignore:
Timestamp:
May 19, 2010, 10:38:34 PM (14 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
8835e2bb59a1c09633e3d9728f08161ac7d4be8d
Parents:
d236a684943ed1055a5f2965d9999b7fea2676ea
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2010-05-19 22:38:34+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 11:52:58+01:00
Message:
My coeffs: Init, Equal... :-/
Location:
coeffs
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • coeffs/Makefile.in

    rd236a6 r51d835  
    3535CXXFLAGS        = -O3 -w -fomit-frame-pointer --no-rtti ${PIPE}
    3636CXXTEMPLFLAGS   = -fno-implicit-templates --no-exceptions
    37 CPPFLAGS        = -I${srcdir} -I${includedir} -I${srcdir}/../misc/ -I${srcdir}/../resource/
     37CPPFLAGS        = -I${srcdir} -I${includedir} -I${srcdir}/../misc/ -I${srcdir}/../resource/ -I${srcdir}/../output/ -I${srcdir}/../omalloc/
    3838DEFS            = -DNDEBUG -DOM_NDEBUG -Dix86_Linux -DHAVE_CONFIG_H
    3939
  • coeffs/gnumpc.cc

    rd236a6 r51d835  
    2222#include "shortfl.h"
    2323
     24/// Our Type!
     25static const n_coeffType ID = n_long_C;
     26
    2427
    2528#ifdef LDEBUG
     
    3235}
    3336#endif
    34 
    35 // #ifndef assume
    36 // #  define assume(a) if(!(a)){ Werror( "Assumption: is wrong: %s\n", #a ); };
    37 // #endif
    38 
    39 static const n_coeffType ID = n_long_C;
    40 
    41 number ngcMapQ(number from, const coeffs aRing, const coeffs r)
    42 {
    43   assume( getCoeffType(r) == ID );
    44   assume( getCoeffType(aRing) == n_Q );
    45 
    46   if ( from != NULL )
    47   {
    48     gmp_complex *res=new gmp_complex(numberFieldToFloat(from,QTOF,aRing));
    49     return (number)res;
    50   }
    51   else
    52     return NULL;
    53 }
    54 
    55 static number ngcMapLongR(number from, const coeffs aRing, const coeffs r)
    56 {
    57   assume( getCoeffType(r) == ID );
    58   assume( getCoeffType(aRing) == n_long_R );
    59  
    60   if ( from != NULL )
    61   {
    62     gmp_complex *res=new gmp_complex(*((gmp_float *)from));
    63     return (number)res;
    64   }
    65   else
    66     return NULL;
    67 }
    68 
    69 static number ngcMapR(number from, const coeffs aRing, const coeffs r)
    70 {
    71   assume( getCoeffType(r) == ID );
    72   assume( getCoeffType(aRing) == n_R );
    73 
    74   if ( from != NULL )
    75   {
    76     gmp_complex *res=new gmp_complex((double)nrFloat(from));
    77     return (number)res;
    78   }
    79   else
    80     return NULL;
    81 }
    82 
    83 static number ngcMapP(number from, const coeffs aRing, const coeffs r)
    84 {
    85   assume( getCoeffType(r) == ID );
    86   assume( getCoeffType(aRing) ==  n_Zp );
    87  
    88   if ( from != NULL)
    89     return ngcInit(npInt(from, aRing), r);
    90   else
    91     return NULL;
    92 }
    93 
    94 
    95 
    96 static number ngcCopyMap(number from, const coeffs aRing, const coeffs r)
    97 {
    98   assume( getCoeffType(r) == ID );
    99   assume( getCoeffType(aRing) ==  ID );
    100 
    101   gmp_complex* b = NULL;
    102  
    103   if ( from !=  NULL )
    104   {
    105     b = new gmp_complex( *(gmp_complex*)from );
    106   }
    107   return (number)b; 
    108 }
    109 
    110 nMapFunc ngcSetMap(const coeffs src, const coeffs dst)
    111 {
    112   assume( getCoeffType(dst) == ID );
    113  
    114   if(nField_is_Q(src))
    115   {
    116     return ngcMapQ;
    117   }
    118   if (nField_is_long_R(src))
    119   {
    120     return ngcMapLongR;
    121   }
    122   if (nField_is_long_C(src))
    123   {
    124     return ngcCopyMap;
    125   }
    126   if(nField_is_R(src))
    127   {
    128     return ngcMapR;
    129   }
    130   if (nField_is_Zp(src))
    131   {
    132     return ngcMapP;
    133   }
    134   return NULL;
    135 }
    136 
    13737
    13838
     
    470370}
    471371
    472 // local Variables: ***
    473 // folded-file: t ***
    474 // compile-command: "make installg" ***
    475 // End: ***
     372
     373
     374
     375static BOOLEAN ngcCoeffsEqual(const coeffs r, n_coeffType n, int)
     376{
     377  assume( getCoeffType(r) == ID );
     378 
     379  return (n == ID);
     380};
     381
     382void ngcInitChar(coeffs n, int)
     383{
     384  assume( getCoeffType(n) == ID );
     385
     386  n->cfDelete  = ngcDelete;
     387  n->nNormalize=ndNormalize;
     388  n->cfInit   = ngcInit;
     389  n->n_Int    = ngcInt;
     390  n->nAdd     = ngcAdd;
     391  n->nSub     = ngcSub;
     392  n->nMult    = ngcMult;
     393  n->nDiv     = ngcDiv;
     394  n->nExactDiv= ngcDiv;
     395  n->nNeg     = ngcNeg;
     396  n->nInvers  = ngcInvers;
     397  n->cfCopy   = ngcCopy;
     398  n->nGreater = ngcGreater;
     399  n->nEqual   = ngcEqual;
     400  n->nIsZero  = ngcIsZero;
     401  n->nIsOne   = ngcIsOne;
     402  n->nIsMOne  = ngcIsMOne;
     403  n->nGreaterZero = ngcGreaterZero;
     404  n->cfWrite  = ngcWrite;
     405  n->nRead    = ngcRead;
     406  n->nPower   = ngcPower;
     407  n->cfSetMap = ngcSetMap;
     408  n->nPar     = ngcPar;
     409  n->nRePart  = ngcRePart;
     410  n->nImPart  = ngcImPart;
     411    // nSize  = ndSize;
     412#ifdef LDEBUG
     413  n->nDBTest  = ndDBTest; // not yet implemented: ngcDBTest
     414#endif
     415
     416
     417 
     418/* 
     419  //r->cfInitChar=nlInitChar;
     420  r->cfKillChar=NULL;
     421  r->cfSetChar=NULL;
     422  r->nCoeffIsEqual=nlCoeffsEqual;
     423
     424  r->nMult  = nlMult;
     425  r->nSub   = nlSub;
     426  r->nAdd   = nlAdd;
     427  r->nDiv   = nlDiv;
     428  r->nIntDiv= nlIntDiv;
     429  r->nIntMod= nlIntMod;
     430  r->nExactDiv= nlExactDiv;
     431  r->cfInit = nlInit;
     432  r->nPar = ndPar;
     433  r->nParDeg = ndParDeg;
     434  r->nSize  = nlSize;
     435  r->n_Int  = nlInt;
     436#ifdef HAVE_RINGS
     437  r->nDivComp = NULL; // only for ring stuff
     438  r->nIsUnit = NULL; // only for ring stuff
     439  r->nGetUnit = NULL; // only for ring stuff
     440  r->nExtGcd = NULL; // only for ring stuff
     441#endif
     442  r->nNeg   = nlNeg;
     443  r->nInvers= nlInvers;
     444  r->cfCopy  = nl_Copy;
     445  r->nRePart = nl_Copy;
     446  r->nImPart = ndReturn0;
     447  r->cfWrite = nlWrite;
     448  r->nRead = nlRead;
     449  r->nNormalize=nlNormalize;
     450  r->nGreater = nlGreater;
     451#ifdef HAVE_RINGS
     452  r->nDivBy = NULL; // only for ring stuff
     453#endif
     454  r->nEqual = nlEqual;
     455  r->nIsZero = nlIsZero;
     456  r->nIsOne = nlIsOne;
     457  r->nIsMOne = nlIsMOne;
     458  r->nGreaterZero = nlGreaterZero;
     459  r->nPower = nlPower;
     460  r->cfGetDenom = nlGetDenom;
     461  r->cfGetNumerator = nlGetNumerator;
     462  r->nGcd  = nlGcd;
     463  r->nLcm  = nlLcm;
     464  r->cfDelete= nlDelete;
     465  r->cfSetMap = nlSetMap;
     466  r->nName = ndName;
     467  r->nInpMult=nlInpMult;
     468  r->nInit_bigint=nlCopyMap;
     469#ifdef LDEBUG
     470  // debug stuff
     471  r->nDBTest=nlDBTest;
     472#endif
     473
     474  // the variables:
     475  r->nNULL = INT_TO_SR(0);
     476  r->type = n_Q;
     477  r->ch = 0;
     478  r->has_simple_Alloc=FALSE;
     479  r->has_simple_Inverse=FALSE;
     480*/
     481
     482/// TODO: Any variables?
     483 
     484}
     485
     486
     487
     488
     489
     490number ngcMapQ(number from, const coeffs aRing, const coeffs r)
     491{
     492  assume( getCoeffType(r) == ID );
     493  assume( getCoeffType(aRing) == n_Q );
     494
     495  if ( from != NULL )
     496  {
     497    gmp_complex *res=new gmp_complex(numberFieldToFloat(from,QTOF,aRing));
     498    return (number)res;
     499  }
     500  else
     501    return NULL;
     502}
     503
     504static number ngcMapLongR(number from, const coeffs aRing, const coeffs r)
     505{
     506  assume( getCoeffType(r) == ID );
     507  assume( getCoeffType(aRing) == n_long_R );
     508
     509  if ( from != NULL )
     510  {
     511    gmp_complex *res=new gmp_complex(*((gmp_float *)from));
     512    return (number)res;
     513  }
     514  else
     515    return NULL;
     516}
     517
     518static number ngcMapR(number from, const coeffs aRing, const coeffs r)
     519{
     520  assume( getCoeffType(r) == ID );
     521  assume( getCoeffType(aRing) == n_R );
     522
     523  if ( from != NULL )
     524  {
     525    gmp_complex *res=new gmp_complex((double)nrFloat(from));
     526    return (number)res;
     527  }
     528  else
     529    return NULL;
     530}
     531
     532static number ngcMapP(number from, const coeffs aRing, const coeffs r)
     533{
     534  assume( getCoeffType(r) == ID );
     535  assume( getCoeffType(aRing) ==  n_Zp );
     536
     537  if ( from != NULL)
     538    return ngcInit(npInt(from, aRing), r);
     539  else
     540    return NULL;
     541}
     542
     543
     544
     545static number ngcCopyMap(number from, const coeffs aRing, const coeffs r)
     546{
     547  assume( getCoeffType(r) == ID );
     548  assume( getCoeffType(aRing) ==  ID );
     549
     550  gmp_complex* b = NULL;
     551
     552  if ( from !=  NULL )
     553  {
     554    b = new gmp_complex( *(gmp_complex*)from );
     555  }
     556  return (number)b; 
     557}
     558
     559
     560nMapFunc ngcSetMap(const coeffs src, const coeffs dst)
     561{
     562  assume( getCoeffType(dst) == ID );
     563
     564  if(nField_is_Q(src))
     565  {
     566    return ngcMapQ;
     567  }
     568  if (nField_is_long_R(src))
     569  {
     570    return ngcMapLongR;
     571  }
     572  if (nField_is_long_C(src))
     573  {
     574    return ngcCopyMap;
     575  }
     576  if(nField_is_R(src))
     577  {
     578    return ngcMapR;
     579  }
     580  if (nField_is_Zp(src))
     581  {
     582    return ngcMapP;
     583  }
     584  return NULL;
     585}
     586
     587
  • coeffs/gnumpc.h

    rd236a6 r51d835  
    1010#include "coeffs.h"
    1111
    12 BOOLEAN  ngcGreaterZero(number za, const coeffs r); // !!! MAY NOT WORK AS EXPECTED !!!
     12/// Get a mapping function from src into the domain of this type: long_C!
     13nMapFunc  ngcSetMap(const coeffs src, const coeffs dst);
     14
     15/// Initialize r
     16void ngcInitChar(coeffs r, int);
     17
     18/// test, whether r is an instance of nInitCoeffs(n, parameter) */
     19static BOOLEAN ngcCoeffsEqual(const coeffs r, n_coeffType n, int parameter);
     20
     21
     22
     23/* // Private interface should be hidden!!!
     24     
     25/// Note: MAY NOT WORK AS EXPECTED!
     26BOOLEAN  ngcGreaterZero(number za, const coeffs r);
    1327BOOLEAN  ngcGreater(number a, number b, const coeffs r);
    1428BOOLEAN  ngcEqual(number a, number b, const coeffs r);
     
    3852BOOLEAN  ngcDBTest(number a, const char *f, const int l, const coeffs r);
    3953#endif
     54*/
    4055
    41 /// Get a mapping function from src into the domain of this type: long_C!
    42 nMapFunc  ngcSetMap(const coeffs src, const coeffs dst);
     56
    4357
    4458// Why is this here? who needs it?
  • coeffs/longrat.h

    rd236a6 r51d835  
    5959
    6060void     nlInitChar(coeffs r, int ch);
     61
    6162number   nlInit2 (int i, int j, const coeffs r);
    6263number   nlInit2gmp (mpz_t i, mpz_t j);
  • coeffs/numbers.cc

    rd236a6 r51d835  
    358358  /*----------------------char. p----------------*/
    359359  {
     360    npInitChar(r, c); // r?
     361
    360362    /* never again:
    361     npInitChar(c,r);
     363     
    362364    n->cfInit = npInit;
    363365    n->n_Int  = npInt;
     
    435437  else if (nField_is_R(r))
    436438  {
    437     n->cfInit = nrInit;
    438     n->n_Int  = nrInt;
    439     n->nAdd   = nrAdd;
    440     n->nSub   = nrSub;
    441     n->nMult  = nrMult;
    442     n->nDiv   = nrDiv;
    443     n->nExactDiv= nrDiv;
    444     n->nNeg   = nrNeg;
    445     n->nInvers= nrInvers;
    446     n->cfCopy  = ndCopy;
    447     n->nGreater = nrGreater;
    448     n->nEqual = nrEqual;
    449     n->nIsZero = nrIsZero;
    450     n->nIsOne = nrIsOne;
    451     n->nIsMOne = nrIsMOne;
    452     n->nGreaterZero = nrGreaterZero;
    453     n->cfWrite = nrWrite;
    454     n->nRead = nrRead;
    455     n->nPower = nrPower;
    456     n->cfSetMap=nrSetMap;
    457     /* nName= ndName; */
    458     n->nSize = nrSize;
    459 #ifdef LDEBUG
    460     n->nDBTest=ndDBTest; // not yet implemented: nrDBTest;
    461 #endif
     439    nrInitChar(r, 0); // n/r? 0?
    462440  }
    463441  /* -------------- long R -----------------------*/
     
    494472  else if (nField_is_long_C(r))
    495473  {
    496     n->cfDelete= ngcDelete;
    497     n->nNormalize=ndNormalize;
    498     n->cfInit = ngcInit;
    499     n->n_Int  = ngcInt;
    500     n->nAdd   = ngcAdd;
    501     n->nSub   = ngcSub;
    502     n->nMult  = ngcMult;
    503     n->nDiv   = ngcDiv;
    504     n->nExactDiv= ngcDiv;
    505     n->nNeg   = ngcNeg;
    506     n->nInvers= ngcInvers;
    507     n->cfCopy  = ngcCopy;
    508     n->nGreater = ngcGreater;
    509     n->nEqual = ngcEqual;
    510     n->nIsZero = ngcIsZero;
    511     n->nIsOne = ngcIsOne;
    512     n->nIsMOne = ngcIsMOne;
    513     n->nGreaterZero = ngcGreaterZero;
    514     n->cfWrite = ngcWrite;
    515     n->nRead = ngcRead;
    516     n->nPower = ngcPower;
    517     n->cfSetMap=ngcSetMap;
    518     n->nPar=ngcPar;
    519     n->nRePart=ngcRePart;
    520     n->nImPart=ngcImPart;
    521     n->nSize = ngcSize;
    522 #ifdef LDEBUG
    523     n->nDBTest=ndDBTest; // not yet implemented: ngcDBTest
    524 #endif
     474    ngcInitChar(r, 0); // n/r? 0?
    525475  }
    526476#ifdef TEST
  • coeffs/shortfl.cc

    rd236a6 r51d835  
    1818
    1919#include <mylimits.h>
    20 // #include "limits.h"
    21 
    22 // #ifndef assume
    23 // #  define assume(a) if(!(a)){ Werror( "Assumption: is wrong: %s\n", #a ); };
    24 // #endif
    25 
    26 
    27 
     20
     21/// Our Type!
    2822static const n_coeffType ID = n_R;
    2923
     
    538532  return NULL;
    539533}
     534
     535
     536
     537
     538
     539/// test, whether r is an instance of nInitCoeffs(n, parameter) */
     540static BOOLEAN nrCoeffsEqual(const coeffs r, n_coeffType n, int parameter)
     541{
     542  assume( getCoeffType(r) == ID );
     543
     544  return (n == ID);
     545};
     546
     547
     548
     549void nrInitChar(coeffs n, int)
     550{
     551  assume( getCoeffType(n) == ID );
     552
     553  n->cfInit = nrInit;
     554  n->n_Int  = nrInt;
     555  n->nAdd   = nrAdd;
     556  n->nSub   = nrSub;
     557  n->nMult  = nrMult;
     558  n->nDiv   = nrDiv;
     559  n->nExactDiv= nrDiv;
     560  n->nNeg   = nrNeg;
     561  n->nInvers= nrInvers;
     562  n->cfCopy  = ndCopy;
     563  n->nGreater = nrGreater;
     564  n->nEqual = nrEqual;
     565  n->nIsZero = nrIsZero;
     566  n->nIsOne = nrIsOne;
     567  n->nIsMOne = nrIsMOne;
     568  n->nGreaterZero = nrGreaterZero;
     569  n->cfWrite = nrWrite;
     570  n->nRead = nrRead;
     571  n->nPower = nrPower;
     572  n->cfSetMap=nrSetMap;
     573    /* nName= ndName; */
     574    /*nSize  = ndSize;*/
     575#ifdef LDEBUG
     576  n->nDBTest=ndDBTest; // not yet implemented: nrDBTest;
     577#endif
     578 
     579
     580
     581/// TODO: Any variables?
     582 
     583}
  • coeffs/shortfl.h

    rd236a6 r51d835  
    99/* $Id$ */
    1010#include "coeffs.h"
     11
     12
     13/// Get a mapping function from src into the domain of this type: n_R
     14nMapFunc nrSetMap(const coeffs src, const coeffs dst);
     15
     16/// Initialize r
     17void nrInitChar(coeffs r, int);
     18
     19/// test, whether r is an instance of nInitCoeffs(n, parameter) */
     20static BOOLEAN nrCoeffsEqual(const coeffs r, n_coeffType n, int parameter);
     21
     22
     23/* // Private interface should be hidden!!!
    1124
    1225BOOLEAN nrGreaterZero (number k, const coeffs r);
     
    3043BOOLEAN nrDBTest(number a, const coeffs r, const char *f, const int l);
    3144#endif
     45*/
    3246
    33 /// Get a mapping function from src into the domain of this type: n_R
    34 nMapFunc nrSetMap(const coeffs src, const coeffs dst);
     47
    3548
    3649// Where are the following used?
     
    4053
    4154/// Converts a n_R number into a float. Needed by Maps
    42 float   nrFloat(number n);
     55float   nrFloat(number n);
     56
    4357
    4458#endif
Note: See TracChangeset for help on using the changeset viewer.