Changeset 1495df4 in git
- Timestamp:
- Jul 15, 2008, 6:27:58 PM (15 years ago)
- Branches:
- (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
- Children:
- e3164c057b351ebc7de36b8955221b4cb648bdbe
- Parents:
- 67dbdb5d3b02ace5998471f519c0e9ae91a1c63b
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/claptmpl.cc
r67dbdb r1495df4 3 3 * Computer Algebra System SINGULAR * 4 4 ****************************************/ 5 // $Id: claptmpl.cc,v 1.4 2 2007-02-23 13:17:55 brickenExp $5 // $Id: claptmpl.cc,v 1.43 2008-07-15 16:27:11 motsak Exp $ 6 6 /* 7 7 * ABSTRACT - instantiation of all templates … … 202 202 // end of file 203 203 // ---------------------------------------------------------------------------- 204 205 #ifdef HAVE_PLURAL 206 207 #include <ncSACache.h> // for CCacheHash etc classes 208 #include <ncSAMult.h> // for CMultiplier etc classes 209 210 template class CMultiplier<int>; 211 template class CMultiplier<poly>; 212 template class CMultiplier<CPower>; 213 214 template class CCacheHash<poly>; 215 template class CCacheHash<int>; 216 217 #endif 218 204 219 #include "tgb_internal.h" 205 220 #ifdef HAVE_BOOST -
Singular/extra.cc
r67dbdb r1495df4 2 2 * Computer Algebra System SINGULAR * 3 3 *****************************************/ 4 /* $Id: extra.cc,v 1.27 5 2008-07-08 13:03:18 SingularExp $ */4 /* $Id: extra.cc,v 1.276 2008-07-15 16:27:11 motsak Exp $ */ 5 5 /* 6 6 * ABSTRACT: general interface to internals of Singular ("system" command) … … 88 88 #include "gring.h" 89 89 #include "sca.h" 90 #include <ncSAMult.h> // for CMultiplier etc classes 90 91 #include "ipconv.h" 91 92 #include "ratgring.h" … … 788 789 789 790 return FALSE; 790 } 791 } 792 793 791 794 if(strcmp(sys_cmd,"NCGetType")==0) 792 795 { … … 801 804 } 802 805 806 803 807 if(strcmp(sys_cmd,"ForceSCA")==0) 804 808 { … … 827 831 return FALSE; 828 832 } 829 /*==================== PLURAL =================*/ 833 834 if(strcmp(sys_cmd,"ForceNewNCMultiplication")==0) 835 { 836 if( !rIsPluralRing(currRing) ) 837 return TRUE; 838 839 if( !ncInitSpecialPairMultiplication(currRing) ) 840 return TRUE; 841 842 return FALSE; 843 } 844 845 /*==================== PLURAL =================*/ 830 846 /*==================== opp ==================================*/ 831 847 if (strcmp(sys_cmd, "opp")==0) -
kernel/Makefile.in
r67dbdb r1495df4 94 94 febase.cc feread.cc feResource.cc \ 95 95 ffields.cc hdegree.cc hilb.cc hutil.cc \ 96 sca.cc gring.cc gr_kstd2.cc summator.cc \96 sca.cc gring.cc gr_kstd2.cc summator.cc ncSAMult.cc ncSACache.cc \ 97 97 ideals.cc intvec.cc int64vec.cc \ 98 98 khstd.cc kstdfac.cc \ … … 155 155 ring.h timer.h dError.h fast_maps.h \ 156 156 febase.h shortfl.h mpr_complex.h mpr_global.h \ 157 summator.h sca.h gring.h \157 summator.h ncSAMult.h ncSACache.h sca.h gring.h \ 158 158 walkProc.h walkMain.h walkSupport.h\ 159 159 ffields.h khstd.h sparsmat.h gnumpfl.h gnumpc.h \ -
kernel/gring.cc
r67dbdb r1495df4 7 7 * Author: levandov (Viktor Levandovsky) 8 8 * Created: 8/00 - 11/00 9 * Version: $Id: gring.cc,v 1.6 0 2008-07-08 11:28:21 SingularExp $9 * Version: $Id: gring.cc,v 1.61 2008-07-15 16:27:58 motsak Exp $ 10 10 *******************************************************************/ 11 11 … … 42 42 #include "sca.h" 43 43 #include <summator.h> 44 45 #include <ncSAMult.h> // for CMultiplier etc classes 44 46 45 47 … … 2546 2548 2547 2549 assume( r->GetNC()->ref == 0 ); 2550 2551 if( rIsSCA(r) && (r->GetNC()->GetGlobalMultiplier() != NULL) ) 2552 { 2553 delete r->GetNC()->GetGlobalMultiplier(); 2554 r->GetNC()->GetGlobalMultiplier() = NULL; 2555 } 2548 2556 2549 2557 int i,j; -
kernel/gring.h
r67dbdb r1495df4 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: gring.h,v 1.2 4 2008-07-02 18:07:10motsak Exp $ */6 /* $Id: gring.h,v 1.25 2008-07-15 16:27:58 motsak Exp $ */ 7 7 /* 8 8 * ABSTRACT additional defines etc for --with-plural … … 14 14 #include <structs.h> 15 15 #include <ring.h> 16 #include <matpol.h> 16 17 17 18 // the part, related to the interface … … 247 248 248 249 250 // inline const nc_struct* GetNC() const { return GetBasering()->GetNC(); }; 251 252 253 // read only access to NC matrices C/D: 254 // get C_{i,j}, 1 <= row = i < j = col <= N 255 inline poly GetC( const ring r, int i, int j ) 256 { 257 assume(r!= NULL && rIsPluralRing(r)); 258 const matrix C = GetNC(r)->C; 259 assume(C != NULL); 260 const int ncols = C->ncols; 261 assume( (i > 0) && (i < j) && (j <= ncols) ); 262 return ( C->m[ncols * ((i)-1) + (j)-1] ); 263 }; 264 265 // get D_{i,j}, 1 <= row = i < j = col <= N 266 inline poly GetD( const ring r, int i, int j ) 267 { 268 assume(r!= NULL && rIsPluralRing(r)); 269 const matrix D = GetNC(r)->D; 270 assume(D != NULL); 271 const int ncols = D->ncols; 272 assume( (i > 0) && (i < j) && (j <= ncols) ); 273 return ( D->m[ncols * ((i)-1) + (j)-1] ); 274 }; 275 276 249 277 #ifdef PLURAL_INTERNAL_DECLARATIONS 250 278 -
kernel/ncSACache.cc
r67dbdb r1495df4 3 3 ****************************************/ 4 4 /*************************************************************** 5 * File: ncSA Mult.cc6 * Purpose: implementation of multiplication in simple NC subalgebras5 * File: ncSACache.cc 6 * Purpose: implementation of special Cache+Hash for Multiplier 7 7 * Author: motsak 8 8 * Created: 9 * Version: $Id: ncSACache.cc,v 1. 1 2008-07-11 15:53:28 motsak Exp $9 * Version: $Id: ncSACache.cc,v 1.2 2008-07-15 16:27:58 motsak Exp $ 10 10 *******************************************************************/ 11 11 12 12 13 #define MYTEST 014 #define OUTPUT 013 #define MYTEST 1 14 #define OUTPUT 1 15 15 16 16 #if MYTEST … … 28 28 29 29 30 v irtual void CGlobalCacheHash::History(const CGlobalCacheHash::CExponent a, const CGlobalCacheHash::CExponent b, const EHistoryType t)30 void CGlobalCacheHash::History(const CGlobalCacheHash::CExponent a, const CGlobalCacheHash::CExponent b, const EHistoryType t) 31 31 { 32 Print("GlobalPair!"); 32 Print("History: GlobalPair!"); 33 PrintS("Left : "); p_Write(a, GetBasering()); 34 PrintS("Right: "); p_Write(b, GetBasering()); 33 35 } 34 36 35 37 36 v irtual void CSpecialPairCacheHash::History(const CSpecialPairCacheHash::CExponent a, const CSpecialPairCacheHash::CExponent b, const EHistoryType t)38 void CSpecialPairCacheHash::History(const CSpecialPairCacheHash::CExponent a, const CSpecialPairCacheHash::CExponent b, const EHistoryType t) 37 39 { 38 40 Print("SpecialPair!\n"); 41 Print("Left : %d, Right: %d\n", a, b); 39 42 } -
kernel/ncSACache.h
r67dbdb r1495df4 1 #ifndef GRING_SA_ MULT_H2 #define GRING_SA_ MULT_H1 #ifndef GRING_SA_CACHEHASH_H 2 #define GRING_SA_CACHEHASH_H 3 3 /***************************************** 4 4 * Computer Algebra System SINGULAR * 5 5 *****************************************/ 6 /* $Id: ncSACache.h,v 1. 1 2008-07-11 15:53:28 motsak Exp $ */6 /* $Id: ncSACache.h,v 1.2 2008-07-15 16:27:58 motsak Exp $ */ 7 7 8 8 // #include <ncSACache.h> // for CCacheHash etc classes 9 9 10 10 #include <structs.h> 11 11 #include <febase.h> // for Print! 12 12 // //////////////////////////////////////////////////////////////////////// // 13 13 // 14 15 16 14 17 15 const int iMaxCacheSize = 20; … … 20 18 class CCacheHash 21 19 { 20 private: 21 ring m_basering; 22 int m_NVars; 23 22 24 public: 25 CCacheHash(ring r): m_basering(r), m_NVars(r->N){}; 26 27 const ring GetBasering() const { return m_basering; }; 28 inline int NVars() const { return m_NVars; } 29 30 virtual ~CCacheHash(){}; 31 23 32 enum EHistoryType { 24 33 MULT_LOOKUP 25 } 34 }; 26 35 27 36 struct CCacheItem … … 45 54 46 55 // -1 means no hits! 47 int Lookup (CExponent a, CExponent b, CCacheItem*& pItems) const56 int LookupEE(CExponent a, CExponent b, CCacheItem*& pItems) 48 57 { 49 58 History(a, b, MULT_LOOKUP); … … 52 61 } 53 62 54 bool Store (CExponent a, CExponent b, poly pProduct)63 bool StoreEE(CExponent a, CExponent b, poly pProduct) 55 64 { 65 Print("StoreEE!\n"); 56 66 return false; // the pair was not stored! 57 67 }; … … 59 69 virtual void History(const CExponent a, const CExponent b, const EHistoryType t) 60 70 { 61 Print("Mult !\n");71 Print("MultHistory!\n"); 62 72 } 63 73 64 74 private: // no copy constuctors! 65 CCacheHash( );66 operator =(CCacheHash&);75 CCacheHash(const CCacheHash&); 76 CCacheHash& operator=(const CCacheHash&); 67 77 }; 68 78 … … 74 84 typedef poly CExponent; 75 85 86 CGlobalCacheHash(ring r): CCacheHash<poly>(r) {}; 87 88 virtual ~CGlobalCacheHash() {}; 89 76 90 protected: 77 91 virtual void History(CExponent a, CExponent b, const EHistoryType t); 78 92 }; 79 80 81 93 82 94 class CSpecialPairCacheHash: public CCacheHash<int> … … 84 96 public: 85 97 typedef int CExponent; 86 98 99 CSpecialPairCacheHash(ring r): CCacheHash<int>(r) {}; 100 101 virtual ~CSpecialPairCacheHash() {}; 102 87 103 protected: 88 104 virtual void History(const CExponent a, const CExponent b, const EHistoryType t); 89 105 }; 90 106 107 108 109 #endif // GRING_SA_CACHEHASH_H 110 111 -
kernel/ncSAMult.cc
r67dbdb r1495df4 7 7 * Author: motsak 8 8 * Created: 9 * Version: $Id: ncSAMult.cc,v 1. 1 2008-07-04 16:18:42motsak Exp $9 * Version: $Id: ncSAMult.cc,v 1.2 2008-07-15 16:27:58 motsak Exp $ 10 10 *******************************************************************/ 11 11 12 12 13 #define MYTEST 014 #define OUTPUT 013 #define MYTEST 1 14 #define OUTPUT 1 15 15 16 16 #if MYTEST … … 22 22 23 23 #include <ncSAMult.h> // for CMultiplier etc classes 24 #include <ring.h> 25 #include <p_polys.h> 26 #include <sbuckets.h> 27 28 29 30 31 /* 24 #include <sca.h> // for SCA 25 26 27 28 32 29 // poly functions defined in p_Procs: ; 33 poly gnc_pp_Mult_mm(const poly p, const poly m, const ring r, poly 34 &last); 35 poly gnc_p_Mult_mm(poly p, const poly m, const ring r); 36 poly gnc_mm_Mult_p(const poly m, poly p, const ring r); 37 poly gnc_mm_Mult_pp(const poly m, const poly p, const ring r); 38 */ 30 static poly gnc_pp_Mult_mm(const poly p, const poly m, const ring r, poly& last) 31 { 32 #if OUTPUT 33 Print("gnc_pp_Mult_mm"); 34 PrintLn(); 35 #endif 36 assume( r->GetNC()->GetGlobalMultiplier() != NULL ); 37 38 return r->GetNC()->GetGlobalMultiplier()->MultiplyPE(p, m); 39 } 40 41 static poly gnc_p_Mult_mm(poly p, const poly m, const ring r) 42 { 43 #if OUTPUT 44 Print("gnc_p_Mult_mm"); 45 PrintLn(); 46 #endif 47 assume( r->GetNC()->GetGlobalMultiplier() != NULL ); 48 49 return r->GetNC()->GetGlobalMultiplier()->MultiplyPEDestroy(p, m); 50 } 51 52 static poly gnc_mm_Mult_p(const poly m, poly p, const ring r) 53 { 54 #if OUTPUT 55 Print("gnc_mm_Mult_p"); 56 PrintLn(); 57 #endif 58 assume( r->GetNC()->GetGlobalMultiplier() != NULL ); 59 60 return r->GetNC()->GetGlobalMultiplier()->MultiplyEPDestroy(m, p); 61 } 62 63 static poly gnc_mm_Mult_pp(const poly m, const poly p, const ring r) 64 { 65 #if OUTPUT 66 Print("gnc_mm_Mult_pp"); 67 PrintLn(); 68 #endif 69 70 assume( r->GetNC()->GetGlobalMultiplier() != NULL ); 71 72 return r->GetNC()->GetGlobalMultiplier()->MultiplyEP(m, p); 73 } 74 75 76 77 78 static void gnc_p_ProcsSet(ring rGR, p_Procs_s* p_Procs = NULL) 79 { 80 #if OUTPUT 81 Print("\ngnc_p_ProcsSet()!!!"); 82 PrintLn(); 83 #endif 84 85 if( p_Procs == NULL ) 86 p_Procs = rGR->p_Procs; 87 88 // "commutative" 89 p_Procs->p_Mult_mm = rGR->p_Procs->p_Mult_mm = gnc_p_Mult_mm; 90 p_Procs->pp_Mult_mm = rGR->p_Procs->pp_Mult_mm = gnc_pp_Mult_mm; 91 92 p_Procs->p_Minus_mm_Mult_qq = rGR->p_Procs->p_Minus_mm_Mult_qq = NULL; 93 94 // non-commutaitve multiplication by monomial from the left 95 rGR->GetNC()->p_Procs.mm_Mult_p = gnc_mm_Mult_p; 96 rGR->GetNC()->p_Procs.mm_Mult_pp = gnc_mm_Mult_pp; 97 98 } 99 100 101 102 103 104 105 106 bool ncInitSpecialPairMultiplication(ring r) 107 { 108 #if OUTPUT 109 Print("ncInitSpecialPairMultiplication(ring), ring: \n"); 110 rWrite(r); 111 PrintLn(); 112 #endif 113 assume(rIsPluralRing(r)); 114 assume(!rIsSCA(r)); 115 116 r->GetNC()->GetGlobalMultiplier() = new CGlobalMultiplier(r); 117 118 gnc_p_ProcsSet(r); 119 return true; 120 } 121 122 123 CGlobalMultiplier::CGlobalMultiplier(ring r): CMultiplier<poly>(r) 124 { 125 #if OUTPUT 126 Print("CGlobalMultiplier::CGlobalMultiplier(ring)!"); 127 PrintLn(); 128 #endif 129 130 m_cache = new CGlobalCacheHash(r); 131 m_powers = new CPowerMultiplier(r); 132 133 } 134 135 136 CGlobalMultiplier::~CGlobalMultiplier() 137 { 138 #if OUTPUT 139 Print("CGlobalMultiplier::~CGlobalMultiplier()!"); 140 PrintLn(); 141 #endif 142 143 delete m_cache; 144 delete m_powers; 145 } 146 147 148 149 // Exponent * Exponent 150 // TODO: handle components!!! 151 poly CGlobalMultiplier::MultiplyEE(const CExponent expLeft, const CExponent expRight) 152 { 153 #if OUTPUT 154 Print("CGlobalMultiplier::MultiplyEE(expLeft, expRight)!"); 155 PrintLn(); 156 #endif 157 158 CCacheHash<poly>::CCacheItem* pLookup; 159 int b = m_cache->LookupEE(expLeft, expRight, pLookup); 160 161 // up to now: 162 assume( b == -1 ); 163 164 // TODO: use PowerMultiplier!!!! 165 166 167 // up to now: 168 return NULL; 169 } 170 171 // Monom * Exponent 172 poly CGlobalMultiplier::MultiplyME(const poly pMonom, const CExponent expRight) 173 { 174 return MultiplyEE(pMonom, expRight); 175 } 176 177 // Exponent * Monom 178 poly CGlobalMultiplier::MultiplyEM(const CExponent expLeft, const poly pMonom) 179 { 180 return MultiplyEE(expLeft, pMonom); 181 } 182 183 184 185 186 187 // Exponent * Exponent 188 poly CCommutativeSpecialPairMultiplier::MultiplyEE(const int expLeft, const int expRight) 189 { 190 return NULL; 191 } 192 193 // Monom * Exponent 194 poly CCommutativeSpecialPairMultiplier::MultiplyME(const poly pMonom, const int expRight) 195 { 196 return NULL; 197 } 198 199 // Exponent * Monom 200 poly CCommutativeSpecialPairMultiplier::MultiplyEM(const int expLeft, const poly pMonom) 201 { 202 return NULL; 203 } 204 205 206 207 // factory method! 208 CSpecialPairMultiplier* AnalyzePair(const ring r, int i, int j) 209 { 210 #if OUTPUT 211 Print("AnalyzePair(ring, i: %d, j: %d)!", i, j); 212 PrintLn(); 213 #endif 214 215 const int N = r->N; 216 217 assume(i < j); 218 assume(i > 0); 219 assume(j <= N); 220 221 222 const poly c = GetC(r, i, j); 223 const poly d = GetD(r, i, j); 224 225 #if OUTPUT 226 Print("C_{%d, %d} = ", i, j); p_Write(c, r); 227 Print("D_{%d, %d} = ", i, j); p_Write(d, r); 228 #endif 229 230 if( (d == NULL) && n_IsOne(p_GetCoeff(c, r), r) ) 231 return new CCommutativeSpecialPairMultiplier(r, i, j); 232 233 return NULL; 234 } 235 236 237 238 239 240 241 CPowerMultiplier::CPowerMultiplier(ring r): CMultiplier<CPower>(r) 242 { 243 #if OUTPUT 244 Print("CPowerMultiplier::CPowerMultiplier(ring)!"); 245 PrintLn(); 246 #endif 247 248 m_specialpairs = (CSpecialPairMultiplier**)omAlloc0( ((NVars() * (NVars()-1)) / 2) * sizeof(CSpecialPairMultiplier*) ); 249 250 for( int i = 1; i < NVars(); i++ ) 251 for( int j = i + 1; j <= NVars(); j++ ) 252 GetPair(i, j) = AnalyzePair(GetBasering(), i, j); // factory method! 253 } 254 255 256 CPowerMultiplier::~CPowerMultiplier() 257 { 258 #if OUTPUT 259 Print("CPowerMultiplier::~CPowerMultiplier()!"); 260 PrintLn(); 261 #endif 262 263 omFreeSize((ADDRESS)m_specialpairs, ((NVars() * (NVars()-1)) / 2) * sizeof(CSpecialPairMultiplier*) ); 264 } 265 266 267 // Monom * Exponent 268 // pMonom may NOT be of the form: var(j)^{n}! 269 poly CPowerMultiplier::MultiplyME(const poly pMonom, const CExponent expRight) 270 { 271 const int j = expRight.Var; 272 const int n = expRight.Power; 273 274 #if OUTPUT 275 Print("CPowerMultiplier::MultiplyME(monom * var(%d)^{%d}!", j, n); 276 PrintLn(); 277 #endif 278 279 assume( (j > 0) && (j <= NVars())); 280 281 if( n == 0 ) 282 return p_Copy(pMonom, GetBasering()); // Copy?!? 283 284 285 int v = NVars(); 286 int e = p_GetExp(pMonom, v, GetBasering()); 287 288 while((v > j) && (e == 0)) 289 e = p_GetExp(pMonom, --v, GetBasering()); 290 291 // TODO: review this! 292 if( (e == 0) ) 293 return expRight.GetPoly(GetBasering()); 294 295 if( v == j ) 296 { 297 poly p = p_Copy(pMonom, GetBasering()); 298 p_SetExp(p, j, e + n, GetBasering()); 299 return p; 300 } 301 302 // And now the General Case: v > j! 303 304 poly p = MultiplyEE( CPower(v, e), expRight ); // Easy way! 305 306 --v; 307 308 while(v > 0) 309 { 310 e = p_GetExp(pMonom, v, GetBasering()); 311 312 if( e > 0 ) 313 p = MultiplyEPDestroy(CPower(v, e), p); 314 315 --v; 316 } 317 318 return p; 319 } 320 321 // Exponent * Monom 322 // pMonom may NOT be of the form: var(i)^{m}! 323 poly CPowerMultiplier::MultiplyEM(const CExponent expLeft, const poly pMonom) 324 { 325 // TODO: as above! (difference due to Left/Right semmantics!) 326 const int j = expLeft.Var; 327 const int n = expLeft.Power; 328 329 #if OUTPUT 330 Print("CPowerMultiplier::MultiplyEM(var(%d)^{%d} * monom)!", j, n); 331 PrintLn(); 332 #endif 333 334 assume( (j > 0) && (j <= NVars())); 335 336 if( n == 0 ) 337 return p_Copy(pMonom, GetBasering()); // Copy?!? 338 339 340 int v = 1; // NVars(); 341 int e = p_GetExp(pMonom, v, GetBasering()); 342 343 while((v < j) && (e == 0)) 344 e = p_GetExp(pMonom, ++v, GetBasering()); 345 346 // TODO: review this! 347 if( (e == 0) ) 348 return expLeft.GetPoly(GetBasering()); 349 350 if( v == j ) 351 { 352 poly p = p_Copy(pMonom, GetBasering()); 353 p_SetExp(p, j, e + n, GetBasering()); 354 return p; 355 } 356 357 // And now the General Case: v > j! 358 359 poly p = MultiplyEE( expLeft, CPower(v, e) ); // Easy way! 360 361 ++v; 362 while(v <= NVars()) 363 { 364 e = p_GetExp(pMonom, v, GetBasering()); 365 366 if( e > 0 ) 367 p = MultiplyPEDestroy(p, CPower(v, e)); 368 369 ++v; 370 } 371 372 } 373 374 375 // Exponent * Exponent 376 // Computes: var(j)^{expLeft} * var(i)^{expRight} 377 poly CPowerMultiplier::MultiplyEE(const CExponent expLeft, const CExponent expRight) 378 { 379 #if OUTPUT 380 Print("CPowerMultiplier::MultiplyEE)!"); 381 PrintLn(); 382 #endif 383 384 const int i = expRight.Var, j = expLeft.Var; 385 const int ei = expRight.Power, ej = expLeft.Power; 386 387 #if OUTPUT 388 Print("Input: var(%d)^{%d} * var(%d)^{%d}", j, ej, i, ei); 389 PrintLn(); 390 #endif 391 392 poly product; 393 394 if( i >= j ) 395 { 396 // easy! 397 product = NULL; 398 } else 399 { 400 assume(1 <= i); 401 assume(i < j); 402 assume(j <= NVars()); 403 assume(ei > 0); 404 assume(ej > 0); 405 406 // No Cache Lookup!? :( 407 408 CSpecialPairMultiplier* pSpecialMultiplier = GetPair(i, j); 409 410 poly product = NULL; 411 412 // Special case? 413 if( pSpecialMultiplier != NULL ) 414 { 415 assume( pSpecialMultiplier->GetI() == i ); 416 assume( pSpecialMultiplier->GetJ() == j ); 417 assume( pSpecialMultiplier->GetBasering() == GetBasering() ); 418 419 product = pSpecialMultiplier->MultiplyEE(ej, ei); 420 } else 421 { 422 // Perform general NC Multiplication: 423 // TODO 424 425 product = NULL; 426 } 427 } 428 429 return product; 430 } 431 432 433 434 435 436 437 CSpecialPairMultiplier::CSpecialPairMultiplier(ring r, int i, int j): 438 CMultiplier<int>(r), m_i(i), m_j(j) 439 { 440 assume(i < j); 441 assume(i > 0); 442 assume(j <= NVars()); 443 } 444 445 446 // Monom * Exponent 447 poly CSpecialPairMultiplier::MultiplyME(const poly pMonom, const CExponent expRight) 448 { 449 return MultiplyEE(p_GetExp(pMonom, GetJ(), GetBasering()), expRight); 450 } 451 452 // Exponent * Monom 453 poly CSpecialPairMultiplier::MultiplyEM(const CExponent expLeft, const poly pMonom) 454 { 455 return MultiplyEE(expLeft, p_GetExp(pMonom, GetI(), GetBasering())); 456 } 457 458 459 460 -
kernel/ncSAMult.h
r67dbdb r1495df4 4 4 * Computer Algebra System SINGULAR * 5 5 *****************************************/ 6 /* $Id: ncSAMult.h,v 1. 3 2008-07-11 15:53:28 motsak Exp $ */6 /* $Id: ncSAMult.h,v 1.4 2008-07-15 16:27:58 motsak Exp $ */ 7 7 #ifdef HAVE_PLURAL 8 8 … … 12 12 #include <ring.h> 13 13 #include <summator.h> // for CPolynomialSummator class 14 #include <febase.h> // for Print! 15 #include <p_polys.h> 16 #include <p_Mult_q.h> 14 17 15 18 #include <ncSACache.h> // for CCacheHash etc classes … … 26 29 protected: 27 30 ring m_basering; 28 29 public: 30 CMultiplier(ring rBaseRing): m_basering(rBaseRing) {}; 31 int m_NVars; // N = number of variables 32 33 public: 34 CMultiplier(ring rBaseRing): m_basering(rBaseRing), m_NVars(rBaseRing->N) {}; 35 virtual ~CMultiplier() {}; 31 36 32 37 const ring GetBasering() const { return m_basering; }; 38 inline int NVars() const { return m_NVars; } 39 33 40 34 41 … … 41 48 { return p_Mult_nn(MultiplyEM(expLeft, pTerm), p_GetCoeff(pTerm, GetBasering()), GetBasering()); } 42 49 43 // 44 // Main templates! 45 // 50 // Main templates: 46 51 47 52 // Poly * Exponent … … 94 99 95 100 96 protected:101 // protected: 97 102 98 103 // Exponent * Exponent … … 107 112 private: // no copy constuctors! 108 113 CMultiplier(); 109 operator =(CMultiplier&); 114 CMultiplier(const CMultiplier&); 115 CMultiplier& operator=(const CMultiplier&); 116 110 117 }; 111 118 … … 116 123 int m_i; 117 124 int m_j; 118 119 public: 125 126 poly m_c_ij; 127 poly m_d_ij; 128 129 130 public: 131 // 1 <= i < j <= NVars() 120 132 CSpecialPairMultiplier(ring r, int i, int j); 121 protected: 133 virtual ~CSpecialPairMultiplier(){} 134 135 inline int GetI() const { return m_i; } 136 inline int GetJ() const { return m_j; } 137 138 // protected: 122 139 typedef int CExponent; 123 140 124 141 // Exponent * Exponent 125 virtual poly MultiplyEE(const poly expLeft, const CExponent expRight); 126 127 // Monom * Exponent 142 // Computes: var(j)^{expLeft} * var(i)^{expRight} 143 virtual poly MultiplyEE(const CExponent expLeft, const CExponent expRight) = 0; 144 145 // Monom * Exponent 146 // pMonom must be of the form: var(j)^{n} 128 147 virtual poly MultiplyME(const poly pMonom, const CExponent expRight); 129 148 130 149 // Exponent * Monom 150 // pMonom must be of the form: var(i)^{m} 131 151 virtual poly MultiplyEM(const CExponent expLeft, const poly pMonom); 132 152 133 153 }; 134 154 135 /* 155 136 156 class CCommutativeSpecialPairMultiplier: public CSpecialPairMultiplier 137 157 { 138 158 public: 139 // Exponent * Exponent 140 virtual poly MultiplyEE(const poly expLeft, const CExponent expRight); 141 142 // Monom * Exponent 143 virtual poly MultiplyME(const poly pMonom, const CExponent expRight); 144 145 // Exponent * Monom 146 virtual poly MultiplyEM(const CExponent expLeft, const poly pMonom); 147 } 148 */ 149 150 151 152 153 class CGlobalMultiplier: public CMultiplier<poly> 159 CCommutativeSpecialPairMultiplier(ring r, int i, int j): 160 CSpecialPairMultiplier(r, i, j){}; 161 virtual ~CCommutativeSpecialPairMultiplier() {} 162 163 // Exponent * Exponent 164 virtual poly MultiplyEE(const int expLeft, const int expRight); 165 166 // Monom * Exponent 167 virtual poly MultiplyME(const poly pMonom, const int expRight); 168 169 // Exponent * Monom 170 virtual poly MultiplyEM(const int expLeft, const poly pMonom); 171 }; 172 173 174 175 176 177 struct CPower // represents var(iVar)^{iPower} 178 { 179 int Var; 180 int Power; 181 182 CPower(int i, int n): Var(i), Power(n) {}; 183 184 inline poly GetPoly(const ring r, int c = 1) const 185 { 186 poly p = p_ISet(c, r); 187 p_SetExp(p, Var, Power, r); 188 return p; 189 }; 190 191 }; 192 193 194 195 196 197 198 class CPowerMultiplier: public CMultiplier<CPower> 154 199 { 155 200 private: 156 201 CSpecialPairMultiplier** m_specialpairs; // upper triangular submatrix of pairs 1 <= i < j <= N of a N x N matrix. 157 int m_NVars; // N = number of variables 158 CGlobalCacheHash* m_cache; 159 160 public: 161 CGlobalMultiplier(ring r); 162 163 inline int NVars() const { return m_NVars; } 202 203 204 public: 205 CPowerMultiplier(ring r); 206 virtual ~CPowerMultiplier(); 164 207 165 208 inline CSpecialPairMultiplier* GetPair(int i, int j) const … … 168 211 assume( i > 0 ); 169 212 assume( i < j ); 170 assume( j <= iNVars ); 171 172 return m_specialpairs + ( (NVars() * ((i)-1) - ((i) * ((i)-1))/2 + (j)-1) - (i) ); 173 } 174 175 176 protected: 213 assume( j <= NVars() ); 214 215 return m_specialpairs[( (NVars() * ((i)-1) - ((i) * ((i)-1))/2 + (j)-1) - (i) )]; 216 } 217 218 inline CSpecialPairMultiplier*& GetPair(int i, int j) 219 { 220 assume( m_specialpairs != NULL ); 221 assume( i > 0 ); 222 assume( i < j ); 223 assume( j <= NVars() ); 224 225 return m_specialpairs[( (NVars() * ((i)-1) - ((i) * ((i)-1))/2 + (j)-1) - (i) )]; 226 } 227 228 // protected: 229 typedef CPower CExponent; 230 231 // Exponent * Exponent 232 // Computes: var(j)^{expLeft} * var(i)^{expRight} 233 virtual poly MultiplyEE(const CExponent expLeft, const CExponent expRight); 234 235 // Monom * Exponent 236 // pMonom may NOT be of the form: var(j)^{n}! 237 virtual poly MultiplyME(const poly pMonom, const CExponent expRight); 238 239 // Exponent * Monom 240 // pMonom may NOT be of the form: var(i)^{m}! 241 virtual poly MultiplyEM(const CExponent expLeft, const poly pMonom); 242 243 244 }; 245 246 247 248 249 class CGlobalMultiplier: public CMultiplier<poly> 250 { 251 private: 252 CGlobalCacheHash* m_cache; 253 CPowerMultiplier* m_powers; 254 255 public: 256 typedef CMultiplier<poly> CBaseType; 257 258 CGlobalMultiplier(ring r); 259 virtual ~CGlobalMultiplier(); 260 261 262 263 // protected: 177 264 typedef poly CExponent; 178 265 … … 180 267 181 268 // Exponent * Exponent 182 virtual poly MultiplyEE(const poly expLeft, const CExponent expRight); 269 // TODO: handle components!!! 270 virtual poly MultiplyEE(const CExponent expLeft, const CExponent expRight); 183 271 184 272 // Monom * Exponent … … 188 276 virtual poly MultiplyEM(const CExponent expLeft, const poly pMonom); 189 277 190 191 CSpecialPairMultiplier* AnalyzePair(const ring r, int j, int i);192 193 278 }; 194 279 -
kernel/structs.h
r67dbdb r1495df4 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: structs.h,v 1. 49 2008-07-07 12:21:43 wienandExp $ */6 /* $Id: structs.h,v 1.50 2008-07-15 16:27:58 motsak Exp $ */ 7 7 /* 8 8 * ABSTRACT … … 140 140 class sBucket; 141 141 class CPolynomialSummator; 142 class CGlobalMultiplier; 142 143 #endif 143 144 … … 468 469 short ref; 469 470 nc_type type; 470 ring basering; // the ring C,D,.. live in 471 472 // initial data: 473 matrix C; 471 ring basering; // the ring C,D,.. live in (commutative ring with this NC structure!) 472 473 // initial data: square matrices rVar() x rVar() 474 // logically: upper triangular!!! 475 // TODO: eliminate this waste of memory!!!! 476 matrix C; 474 477 matrix D; 475 478 … … 498 501 ideal idSCAQuotient; // = NULL by default. // must be deleted in Kill! 499 502 } sca; 503 500 504 } data; 501 505 506 CGlobalMultiplier* m_Multiplier; 507 502 508 public: 509 503 510 inline nc_type& ncRingType() { return (type); }; 504 511 inline nc_type ncRingType() const { return (type); }; … … 517 524 { assume(ncRingType() == nc_exterior); return (data.sca.idSCAQuotient); }; 518 525 526 inline CGlobalMultiplier* GetGlobalMultiplier() const 527 { assume(ncRingType() != nc_exterior); return (m_Multiplier); }; 528 529 inline CGlobalMultiplier*& GetGlobalMultiplier() 530 { assume(ncRingType() != nc_exterior); return (m_Multiplier); }; 531 519 532 public: 520 533 nc_pProcs p_Procs; // NC procedures.
Note: See TracChangeset
for help on using the changeset viewer.