Ignore:
Timestamp:
Aug 3, 2012, 1:06:22 PM (11 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'ad2543eab51733612ba7d118afc77edca719600e')
Children:
b0732eb4254fbe76540d72c337f3d7f985adf948
Parents:
b8610796eaca5ba7db8dc75f8bc88d698e077b365abb0e7fdca82a2bad9778e410148c74d7b49a0b
Message:
Merge pull request #162 from steenpass/libs

changes in LIBs from master
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/libfac/charset/alg_factor.cc

    r5abb0e7 rc10f46  
    22// emacs edit mode for this file is -*- C++ -*-
    33////////////////////////////////////////////////////////////
    4 ////////////////////////////////////////////////////////////
     4
    55// FACTORY - Includes
    66#include <factory.h>
     
    1818#include "alg_factor.h"
    1919
    20 void out_cf(char *s1,const CanonicalForm &f,char *s2);
     20void out_cf(const char *s1,const CanonicalForm &f,const char *s2);
    2121
    2222#ifdef ALGFACTORDEBUG
     
    8080// replacement for factory's broken psr
    8181static CanonicalForm
    82 mypsr ( const CanonicalForm &rr, const CanonicalForm &vv, const Variable & x ){
     82mypsr ( const CanonicalForm &rr, const CanonicalForm &vv, const Variable & x )
     83{
    8384  CanonicalForm r=rr, v=vv, l, test, lu, lv, t, retvalue;
    8485  int dr, dv, d,n=0;
     
    104105// replacement for factory's broken resultant
    105106static CanonicalForm
    106 resultante( const CanonicalForm & f, const CanonicalForm& g, const Variable & v ){
     107resultante( const CanonicalForm & f, const CanonicalForm& g, const Variable & v )
     108{
    107109  bool on_rational = isOn(SW_RATIONAL);
    108110  On(SW_RATIONAL);
     
    113115  if (!on_rational)  Off(SW_RATIONAL);
    114116
    115 return resultant(fz,gz,v);
     117  return resultant(fz,gz,v);
    116118}
    117119
     
    133135sqrf_norm_sub( const CanonicalForm & f, const CanonicalForm & PPalpha,
    134136           CFGenerator & myrandom, CanonicalForm & s,  CanonicalForm & g,
    135            CanonicalForm & R){
     137           CanonicalForm & R)
     138{
    136139  Variable y=PPalpha.mvar(),vf=f.mvar();
    137140  CanonicalForm temp, Palpha=PPalpha, t;
     
    147150
    148151  // Norm, resultante taken with respect to y
    149   while ( !sqfreetest ){
     152  while ( !sqfreetest )
     153  {
    150154    DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha);
    151155    R = resultante(Palpha, g, y); R= R* bCommonDen(R);
     
    160164      DEBOUTLN(CERR, "sqrf_norm_sub: sqfreetest= ", sqfreetest);
    161165    }
    162     else{
     166    else
     167    {
    163168      DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!");
    164169      // Look at SqrFreeTest!
     
    169174      if (getAlgVar(R,X))
    170175      {
    171         if (R.isUnivariate())
    172176          testlist=factorize( R, X );
    173         else
    174           testlist= Factorize(R, X, 0);
    175177      }
    176178      else
     
    183185      DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest);
    184186    }
    185     if ( ! sqfreetest ){
     187    if ( ! sqfreetest )
     188    {
    186189      myrandom.next();
    187190      DEBOUTLN(CERR, "sqrf_norm_sub generated new myrandom item: ", myrandom.item());
     
    198201sqrf_agnorm_sub( const CanonicalForm & f, const CanonicalForm & PPalpha,
    199202           AlgExtGenerator & myrandom, CanonicalForm & s,  CanonicalForm & g,
    200            CanonicalForm & R){
     203           CanonicalForm & R)
     204{
    201205  Variable y=PPalpha.mvar(),vf=f.mvar();
    202206  CanonicalForm temp, Palpha=PPalpha, t;
     
    212216
    213217  // Norm, resultante taken with respect to y
    214   while ( !sqfreetest ){
     218  while ( !sqfreetest )
     219  {
    215220    DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha);
    216221    R = resultante(Palpha, g, y); R= R* bCommonDen(R);
     
    225230      DEBOUTLN(CERR, "sqrf_norm_sub: sqfreetest= ", sqfreetest);
    226231    }
    227     else{
     232    else
     233    {
    228234      DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!");
    229235      // Look at SqrFreeTest!
     
    234240      if (getAlgVar(R,X))
    235241      {
    236         if (R.isUnivariate())
    237242          testlist=factorize( R, X );
    238         else
    239           testlist= Factorize(R, X, 0);
    240243      }
    241244      else
     
    248251      DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest);
    249252    }
    250     if ( ! sqfreetest ){
     253    if ( ! sqfreetest )
     254    {
    251255      myrandom.next();
    252256      DEBOUTLN(CERR, "sqrf_norm_sub generated new myrandom item: ", myrandom.item());
     
    264268sqrf_norm( const CanonicalForm & f, const CanonicalForm & PPalpha,
    265269           const Variable & Extension, CanonicalForm & s,  CanonicalForm & g,
    266            CanonicalForm & R){
    267 
     270           CanonicalForm & R)
     271{
    268272  DEBOUTLN(CERR, "sqrf_norm:      f= ", f);
    269273  DEBOUTLN(CERR, "sqrf_norm: Palpha= ", PPalpha);
    270   if ( getCharacteristic() == 0 ) {
     274  if ( getCharacteristic() == 0 )
     275  {
    271276    IntGenerator myrandom;
    272277    DEBOUTMSG(CERR, "sqrf_norm: no extension, char=0");
     
    278283    DEBOUTLN(CERR, "sqrf_norm:      R= ", R);
    279284  }
    280   else if ( degree(Extension) > 0 ){ // working over Extensions
     285  else if ( degree(Extension) > 0 ) // working over Extensions
     286  {
    281287    DEBOUTLN(CERR, "sqrf_norm: degree of extension is ", degree(Extension));
    282288    AlgExtGenerator myrandom(Extension);
    283289    sqrf_agnorm_sub(f,PPalpha, myrandom, s,g,R);
    284290  }
    285   else{
     291  else
     292  {
    286293    FFGenerator myrandom;
    287294    DEBOUTMSG(CERR, "sqrf_norm: degree of extension is 0");
     
    296303  Variable x;
    297304
    298   for ( VarlistIterator i=uord; i.hasItem(); i++){
     305  for ( VarlistIterator i=uord; i.hasItem(); i++)
     306  {
    299307    x=i.getItem();
    300     for ( CFListIterator j=Astar; j.hasItem(); j++ ){
     308    for ( CFListIterator j=Astar; j.hasItem(); j++ )
     309    {
    301310      elem= j.getItem();
    302       if ( degree(elem,x) > 0 ){ // x actually occures in Astar
     311      if ( degree(elem,x) > 0 ) // x actually occures in Astar
     312      {
    303313        output.append(x);
    304314        break;
     
    312322// Must be a power of p: i.e. y^{p^e}-x
    313323static int
    314 inseperable(const CFList & Astar){
     324inseperable(const CFList & Astar)
     325{
    315326  CanonicalForm elem;
    316327  int Counter= 1;
    317328
    318329  if ( Astar.length() == 0 ) return 0;
    319   for ( CFListIterator i=Astar; i.hasItem(); i++){
     330  for ( CFListIterator i=Astar; i.hasItem(); i++)
     331  {
    320332    elem= i.getItem();
    321333    if ( elem.deriv() == elem.genZero() ) return Counter;
     
    327339// calculate gcd of f and g in char=0
    328340static CanonicalForm
    329 gcd0( CanonicalForm f, CanonicalForm g ){
     341gcd0( CanonicalForm f, CanonicalForm g )
     342{
    330343  int charac= getCharacteristic();
    331344  int save=isOn(SW_RATIONAL);
     
    333346  CanonicalForm ff= mapinto(f), gg= mapinto(g);
    334347  CanonicalForm result= gcd(ff,gg);
    335   setCharacteristic(charac); 
     348  setCharacteristic(charac);
    336349  if (save) On(SW_RATIONAL);
    337350  return mapinto(result);
     
    344357// have enough elements to plug in.
    345358static int
    346 getextension( IntList & degreelist, int n){
     359getextension( IntList & degreelist, int n)
     360{
    347361  int charac= getCharacteristic();
    348362  setCharacteristic(0); // need it for k !
     
    543557
    544558static CFFList
    545 endler( const CanonicalForm & f, const CFList & AS, const Varlist & uord ){
     559endler( const CanonicalForm & f, const CFList & AS, const Varlist & uord )
     560{
    546561  CanonicalForm F=f, g, q,r;
    547562  CFFList Output;
     
    551566  Variable vg;
    552567
    553   for (i=as; i.hasItem(); i++){
     568  for (i=as; i.hasItem(); i++)
     569  {
    554570    g= i.getItem();
    555     if (g.deriv() == 0 ){
     571    if (g.deriv() == 0 )
     572    {
    556573      DEBOUTLN(CERR, "Inseperable extension detected: ", g);
    557       for (j=uord; j.hasItem(); j++){
     574      for (j=uord; j.hasItem(); j++)
     575      {
    558576        if ( degree(g,j.getItem()) > 0 ) vg= j.getItem();
    559577      }
     
    568586      // Now transform all remaining polys in as:
    569587      int x=0;
    570       for (ii=i; ii.hasItem(); ii++){
    571         if ( x != 0 ){
     588      for (ii=i; ii.hasItem(); ii++)
     589      {
     590        if ( x != 0 )
     591        {
    572592          divrem(ii.getItem(), gg, q,r);
    573593//          CERR << ii.getItem() << " divided by " << gg << "\n";
     
    595615
    596616  // Transform back:
    597   for ( CFFListIterator k=factorlist; k.hasItem(); k++){
     617  for ( CFFListIterator k=factorlist; k.hasItem(); k++)
     618  {
    598619    CanonicalForm factor= k.getItem().factor();
    599620    ii=One;
    600     for (i=Two; i.hasItem(); i++){
     621    for (i=Two; i.hasItem(); i++)
     622    {
    601623      DEBOUTLN(CERR, "Mapping ", i.getItem());
    602624      DEBOUTLN(CERR, "     to ", ii.getItem());
     
    618640//           no transcendentals, seperable and inseperable extensions
    619641CFFList
    620 newfactoras( const CanonicalForm & f, const CFList & as, int &success){
     642newfactoras( const CanonicalForm & f, const CFList & as, int &success)
     643{
    621644  Variable vf=f.mvar();
    622645  CFListIterator i;
     
    751774
    752775CFFList
    753 newcfactor(const CanonicalForm & f, const CFList & as, int & success ){
     776newcfactor(const CanonicalForm & f, const CFList & as, int & success )
     777{
    754778  Off(SW_RATIONAL);
    755   CFFList Output, output, Factors=Factorize(f); On(SW_RATIONAL);
     779  CFFList Output, output, Factors=Factorize(f);
     780  On(SW_RATIONAL);
    756781  Factors.removeFirst();
    757782
     
    760785
    761786  success=1;
    762   for ( CFFListIterator i=Factors; i.hasItem(); i++ ){
     787  for ( CFFListIterator i=Factors; i.hasItem(); i++ )
     788  {
    763789    output=newfactoras(i.getItem().factor(),as, success);
    764790    for ( CFFListIterator j=output; j.hasItem(); j++)
Note: See TracChangeset for help on using the changeset viewer.