Changeset fb8b1cf in git for kernel/ncSAMult.h


Ignore:
Timestamp:
Jul 10, 2008, 5:07:46 PM (16 years ago)
Author:
Motsak Oleksandr <motsak@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
1367162082700b6bd218bdf7c3bacb10d1f624ca
Parents:
e675a91b1fd1b28f733dcb506498d7adfd7c1d1b
Message:
*motsak: more to an implementation


git-svn-id: file:///usr/local/Singular/svn/trunk@10856 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/ncSAMult.h

    re675a91 rfb8b1cf  
    44 *  Computer Algebra System SINGULAR     *
    55 *****************************************/
    6 /* $Id: ncSAMult.h,v 1.1 2008-07-04 16:18:42 motsak Exp $ */
     6/* $Id: ncSAMult.h,v 1.2 2008-07-10 15:07:46 motsak Exp $ */
    77#ifdef HAVE_PLURAL
    88
     
    1111#include <structs.h>
    1212#include <ring.h>
     13#include <summator.h> // for CPolynomialSummator class
    1314
    1415// //////////////////////////////////////////////////////////////////////// //
    1516//
     17template <typename CExponent>
     18class CMultiplier
     19{
     20  protected:
     21    ring m_basering;
     22
     23    enum EHistoryType {
     24      MULT_START
     25    }
     26
     27  public:
     28    CMultiplier(ring rBaseRing): m_basering(rBaseRing) {};
     29   
     30  protected:
     31    virtual CExponent GetExponent(const poly pMonom); // ugly!
     32
     33    virtual poly Multiply(const CExponent a, const CExponent b) = 0;
     34   
     35    inline poly MultiplyMonoms(const poly pPoly, const CExponent b)
     36    { return( p_Mult_nn(Multiply(GetExponent(pPoly), b), p_GetCoeff(pPoly,m_basering), m_basering); }
     37   
     38    inline poly MultiplyMonoms(const CExponent a, const poly pPoly)
     39    { return( p_Mult_nn(Multiply(a, GetExponent(pPoly)), p_GetCoeff(pPoly,m_basering), m_basering); }
     40   
     41   
     42    poly Multiply(const poly pPoly, const CExponent b)
     43    {
     44      bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
     45      CPolynomialSummator sum(m_basering, bUsePolynomial);
     46
     47      for( poly q = pPoly; q !=NULL; q = pNext(q) )
     48        sum += MultiplyMonoms(q, b);
     49     
     50      return sum;
     51    };
     52   
     53    poly Multiply(CExponent a, const poly pPoly)
     54    {
     55      bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
     56      CPolynomialSummator sum(m_basering, bUsePolynomial);
     57
     58      for( poly q = pPoly; q !=NULL; q = pNext(q) )
     59        sum += MultiplyMonoms(a, q);
     60     
     61      return sum;
     62    };
     63
     64    poly MultiplyAndDestroyPoly(poly pPoly, const CExponent b)
     65    {
     66      bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
     67      CPolynomialSummator sum(m_basering, bUsePolynomial);
     68
     69
     70      for( ; pPoly!=NULL; pPoly  = p_LmDeleteAndNext(pPoly, m_basering) )
     71        sum += MultiplyMonoms(pPoly, b);
     72
     73      return sum;
     74    };
     75
     76    poly MultiplyAndDestroyPoly(CExponent a, poly pPoly)
     77    {
     78      bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (pLength(pPoly) < MIN_LENGTH_BUCKET);
     79      CPolynomialSummator sum(m_basering, bUsePolynomial);
     80
     81      for( ; pPoly!=NULL; pPoly  = p_LmDeleteAndNext(pPoly, m_basering) )
     82        sum += MultiplyMonoms(a, pPoly);
     83
     84      return sum;
     85    };
     86   
     87       
     88    void History(CExponent a, CExponent b, EHistoryType t)
     89    {
     90      Print("Mult!\n");
     91    }
     92  private: // no copy constuctors!
     93    CMultiplier();
     94    operator =(CMultiplier&);
     95};
     96
     97typedef CMultiplier<int> CSpecialPairMultiplier;
     98typedef CMultiplier<int*> CGlobalMultiplier;
     99
     100
     101
    16102/*
    17103
     
    42128
    43129
    44 template <typename CExponent>
    45 class CMultiplier
    46 {
    47   public:
    48     virtual poly Multiply(CExponent a, CExponent b);
    49   protected:
    50     poly Multiply(poly p, CExponent b);
    51     poly Multiply(CExponent a, poly p);
    52     void History(CExponent a, CExponent b);
    53   private: // no copy constuctors!
    54     CMultiplier();
    55     operator =(CMultiplier&);
    56 }
    57 
    58 typedef CMultiplier<int> CSpecialPairMultiplier;
    59 typedef CMultiplier<int*> CGlobalMultiplier;
    60 
    61 
    62130class CCommutativeSpecialPairMultiplier: public CSpecialPairMultiplier
    63131{
Note: See TracChangeset for help on using the changeset viewer.