Changeset 7fee876 in git for libpolys/coeffs/gnumpc.cc


Ignore:
Timestamp:
Mar 16, 2012, 9:26:19 PM (11 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
Children:
5a72fe43aa1fbae0fb93ebbff5685375e726f93c
Parents:
ce1f78b09d525de2d3babcf986a9f4821e60ed00
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-03-16 21:26:19+01:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-03-17 05:41:42+01:00
Message:
moved prarameter-handling to coeffs from rings.* and related fixes

chg: removed complex_parameter, m_nfParameter
add: n_NumberOfParameters, n_ParameterNames, n_Param(coeffs)
fix: par(1) (n_Param) for n_GF & n_long_C
fix/chg: n_long_C is an Extension as well (rIsExtension)
fix: n_long_C ngcCoeffWrite: additional space needed for compatibility with legacy Singular
fix: complexToStr over non-C coeffs!
fix: rRenameVars renames _new_ VARIABLES instead of _old_ parameters!
fix: coeff construction was broken in walk.cc
add/fix: nfKillChar, ngcKillChar
chg: cleanup of headers & tests
chg: parameter output during "make check"
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/gnumpc.cc

    rce1f78 r7fee876  
    1111#include "config.h"
    1212
     13#include <omalloc/omalloc.h>
     14
     15#include <misc/auxiliary.h>
     16#include <misc/mylimits.h>
     17
     18#include <reporter/reporter.h>
     19#include <resources/feFopen.h>
     20
    1321#include <coeffs/coeffs.h>
    1422#include <coeffs/numbers.h>
     23
    1524#include <coeffs/longrat.h>
    1625#include <coeffs/modulop.h>
     26
    1727#include <coeffs/gnumpc.h>
    1828#include <coeffs/gnumpfl.h>
     29#include <coeffs/shortfl.h>
     30
    1931#include <coeffs/mpr_complex.h>
    20 #include <reporter/reporter.h>
    21 #include <omalloc/omalloc.h>
    22 
    23 
    24 #include <coeffs/shortfl.h>
     32
     33
     34/// Get a mapping function from src into the domain of this type: long_C!
     35nMapFunc  ngcSetMap(const coeffs src, const coeffs dst);
     36
     37number ngcMapQ(number from, const coeffs r, const coeffs aRing);
     38
     39void ngcSetChar(const coeffs r);
     40
     41// Private interface should be hidden!!!
     42
     43/// Note: MAY NOT WORK AS EXPECTED!
     44BOOLEAN  ngcGreaterZero(number za, const coeffs r);
     45BOOLEAN  ngcGreater(number a, number b, const coeffs r);
     46BOOLEAN  ngcEqual(number a, number b, const coeffs r);
     47BOOLEAN  ngcIsOne(number a, const coeffs r);
     48BOOLEAN  ngcIsMOne(number a, const coeffs r);
     49BOOLEAN  ngcIsZero(number za, const coeffs r);
     50number   ngcInit(long i, const coeffs r);
     51int      ngcInt(number &n, const coeffs r);
     52number   ngcNeg(number za, const coeffs r);
     53number   ngcInvers(number a, const coeffs r);
     54number   ngcParameter(int i, const coeffs r);
     55number   ngcAdd(number la, number li, const coeffs r);
     56number   ngcSub(number la, number li, const coeffs r);
     57number   ngcMult(number a, number b, const coeffs r);
     58number   ngcDiv(number a, number b, const coeffs r);
     59void     ngcPower(number x, int exp, number *lu, const coeffs r);
     60number   ngcCopy(number a, const coeffs r);
     61number   ngc_Copy(number a, coeffs r);
     62const char * ngcRead (const char *s, number *a, const coeffs r);
     63void     ngcWrite(number &a, const coeffs r);
     64number   ngcRePart(number a, const coeffs r);
     65number   ngcImPart(number a, const coeffs r);
     66
     67void     ngcDelete(number *a, const coeffs r);
     68void     ngcCoeffWrite(const coeffs r, BOOLEAN details);
     69
     70#ifdef LDEBUG
     71BOOLEAN  ngcDBTest(number a, const char *f, const int l, const coeffs r);
     72#endif
     73
     74
     75// Why is this here? who needs it?
     76// number ngcMapQ(number from, const coeffs r, const coeffs aRing);
    2577
    2678/// Our Type!
     
    3890#endif
    3991
    40 /*
    41 number   ngcPar(int i, const coeffs r)
     92number   ngcParameter(int i, const coeffs r)
    4293{
    4394  assume( getCoeffType(r) == ID );
    4495  assume(i==1);
    4596
    46   gmp_complex* n= new gmp_complex( (long)0, (long)1 );
    47   return (number)n;
    48 }
    49 */
     97  if( i == 1 )
     98    return (number)(new gmp_complex( (long)0, (long)1 ));
     99
     100  return NULL; // new gmp_complex( )  // 0?
     101}
    50102
    51103/*2
     
    329381{
    330382  assume( getCoeffType(r) == ID );
    331   assume( r->complex_parameter != NULL );
     383  const char * const complex_parameter = n_ParameterNames(r)[0];
     384  assume( complex_parameter != NULL );
     385  const int N = strlen(complex_parameter);
    332386
    333387  if ((*s >= '0') && (*s <= '9'))
     
    339393    delete re;
    340394  }
    341   else if (strncmp(s, r->complex_parameter,strlen(r->complex_parameter))==0)
    342   {
    343     s+=strlen(r->complex_parameter);
     395  else if (strncmp(s, complex_parameter, N)==0)
     396  {
     397    s += N;
    344398    gmp_complex *aa=new gmp_complex((long)0,(long)1);
    345399    *a=(number)aa;
     
    385439        (p->float_len2 == r->float_len2)
    386440       )
    387       if (strcmp(p->par_name, r->complex_parameter) == 0)
     441      if (strcmp(p->par_name, n_ParameterNames(r)[0]) == 0)
    388442        return (TRUE);
    389443  }
     
    391445}
    392446
     447static void ngcKillChar(coeffs r)
     448{
     449  char** p = (char**)n_ParameterNames(r);
     450
     451  const int P = n_NumberOfParameters(r);
     452
     453  for( int i = 1; i <= P; i++ )
     454    if (p[i-1] != NULL)
     455      omFree( (ADDRESS)p[i-1] );
     456
     457  omFreeSize((ADDRESS)p, P * sizeof(char*)); 
     458}
     459
    393460BOOLEAN ngcInitChar(coeffs n, void* parameter)
    394461{
    395462  assume( getCoeffType(n) == ID );
    396463
    397   n->cfKillChar = ndKillChar; /* dummy */
     464  n->cfKillChar = ngcKillChar;
    398465  n->ch = 0;
    399466
     
    496563  r->has_simple_Inverse=FALSE;
    497564*/
    498    
     565
     566  n->iNumberOfParameters = 1;
     567  n->cfParameter = ngcParameter;
     568
     569  char ** pParameterNames = (char **) omAlloc0(sizeof(char *));
     570
    499571  if( parameter != NULL)
    500572  {
    501573    LongComplexInfo* p = (LongComplexInfo*)parameter;
    502     n->complex_parameter = omStrDup(p->par_name);
     574    pParameterNames[0] = omStrDup(p->par_name); //TODO use omAlloc for allocating memory and use strcpy?
    503575    n->float_len = p->float_len;
    504576    n->float_len2 = p->float_len2;
     
    506578  } else // default values, just for testing!
    507579  {
    508     n->complex_parameter = omStrDup("i");
     580    pParameterNames[0] = omStrDup("i");
    509581    n->float_len = SHORT_REAL_LENGTH;
    510582    n->float_len2 = SHORT_REAL_LENGTH;     
     
    513585  assume( n->float_len <= n->float_len2 );
    514586  assume( n->float_len2 >= SHORT_REAL_LENGTH );
    515   assume( n->complex_parameter != NULL );
    516 
     587  assume( pParameterNames != NULL );
     588  assume( pParameterNames[0] != NULL );
     589 
     590  n->pParameterNames = pParameterNames;
     591
     592  // NOTE: n->complex_parameter was replaced by n_ParameterNames(n)[0]
     593  // TODO: nfKillChar MUST destroy n->pParameterNames[0] (0-term. string) && n->pParameterNames (array of size 1)
     594 
    517595  return FALSE;
    518596}
     
    623701  Print("//   characteristic : 0 (complex:%d digits, additional %d digits)\n",
    624702        r->float_len, r->float_len2);  /* long C */
    625   Print("//   1 parameter    : %s\n", r->complex_parameter);
    626   Print("//   minpoly        : (%s^2+1)\n", r->complex_parameter); 
    627 }
     703  Print("//   1 parameter    : %s \n", n_ParameterNames(r)[0]); // this trailing space is for compatibility with the legacy Singular
     704  Print("//   minpoly        : (%s^2+1)\n", n_ParameterNames(r)[0]); 
     705}
Note: See TracChangeset for help on using the changeset viewer.