Changeset ded085 in git


Ignore:
Timestamp:
Dec 11, 2009, 4:40:02 PM (14 years ago)
Author:
Frank Seelisch <seelisch@…>
Branches:
(u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
Children:
867e1a39616ddc1692d837af059565a1320e8cc7
Parents:
b54a393fcb8e823c662951c5a6219096fb8a6800
Message:
in ring.cc: completed rChar for Z/n, Z/p^m, and Z/2^m
in ideals.*: made insertion into ideals return TRUE/FALSE instead of void

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

Legend:

Unmodified
Added
Removed
  • kernel/ideals.cc

    rb54a393 rded085  
    541541
    542542/*2
    543 * concat h1 and h2
    544 */
    545 void idInsertPoly (ideal h1,poly h2)
    546 {
    547   if (h2==NULL) return;
     543* insert h2 into h1 (if h2 is not the zero polynomial)
     544* return TRUE iff h2 was indeed inserted
     545*/
     546BOOLEAN idInsertPoly (ideal h1, poly h2)
     547{
     548  if (h2==NULL) return FALSE;
    548549  int j = IDELEMS(h1)-1;
    549550  while ((j >= 0) && (h1->m[j] == NULL)) j--;
     
    555556  }
    556557  h1->m[j]=h2;
    557 }
    558 
    559 /*2
    560 * concat h1 and h2 (if h2 is neither zero nor a generator of h1)
    561 */
    562 void idInsertPolyNoDuplicates (ideal h1,poly h2)
     558  return TRUE;
     559}
     560
     561/*2
     562* insert h2 into h1 (if h2 is neither the zero polynomial
     563* nor a generator in h1)
     564* return TRUE iff h2 was indeed inserted
     565*/
     566BOOLEAN idInsertPolyNoDuplicates (ideal h1, poly h2)
    563567{
    564568  bool h2FoundInH1 = false;
     
    569573    i++;
    570574  }
    571   if (!h2FoundInH1) idInsertPoly(h1, h2);
     575  if (!h2FoundInH1) return idInsertPoly(h1, h2);
     576  else return FALSE;
    572577}
    573578
  • kernel/ideals.h

    rb54a393 rded085  
    5454ideal idAdd (ideal h1,ideal h2);
    5555  /* h1 + h2 */
    56 void idInsertPoly (ideal h1,poly h2);
     56BOOLEAN idInsertPoly (ideal h1,poly h2);
    5757  /* h1 + h2 */
    58 void idInsertPolyNoDuplicates (ideal h1,poly h2);
     58BOOLEAN idInsertPolyNoDuplicates (ideal h1,poly h2);
    5959  /* h1 + h2 */
    6060ideal idMult (ideal h1,ideal h2);
  • kernel/ring.cc

    rb54a393 rded085  
    766766}
    767767
     768int binaryPower (const int a, const int b)
     769{
     770  /* computes a^b according to the binary representation of b,
     771     i.e., a^7 = a^4 * a^2 * a^1. This saves some multiplications. */
     772  int result = 1;
     773  int factor = a;
     774  int bb = b;
     775  while (bb != 0)
     776  {
     777    if (bb % 2 != 0) result = result * factor;
     778    bb = bb / 2;
     779    factor = factor * factor;
     780  }
     781  return result;
     782}
     783
    768784int rChar(ring r)
    769785{
     786  if (rField_is_Ring_2toM(r))
     787    return binaryPower(2, (int)(unsigned long)r->ringflagb);
     788  if (rField_is_Ring_ModN(r))
     789    return (int)mpz_get_ui(r->ringflaga);
     790  if (rField_is_Ring_PtoM(r))
     791    return binaryPower((int)mpz_get_ui(r->ringflaga),
     792                       (int)(unsigned long)r->ringflagb);
    770793  if (rField_is_numeric(r))
    771794    return 0;
Note: See TracChangeset for help on using the changeset viewer.