Changeset ecbe9f7 in git for kernel/Poly.h
- Timestamp:
- Aug 17, 2005, 8:34:17 AM (19 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd08f5f0bb3329b8ca19f23b74cb1473686415c3a')
- Children:
- 77ed9949773a942859e2d90eb3e135a1e0d09d7a
- Parents:
- 89ccc16173d3e69a1de96f508bbe39a32a01ca75
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/Poly.h
r89ccc1 recbe9f7 1 //$Id: Poly.h,v 1. 7 2005-08-16 14:36:10bricken Exp $1 //$Id: Poly.h,v 1.8 2005-08-17 06:34:16 bricken Exp $ 2 2 3 3 … … 24 24 //Poly wraps around PolyImpl with reference counting using boost 25 25 class PolyImpl{ 26 friend class Poly; 26 friend class PolyBase<RING>; 27 friend class PolyBase<MODUL>; 27 28 //friend class Number; 28 29 protected: … … 324 325 325 326 }; 326 class Poly{ 327 328 template <poly_variant variant> class PolyBase; 329 template <poly_variant v> inline PolyBase<v> operator+(const PolyBase<v>& p1, const PolyBase<v>& p2); 330 template <poly_variant v> inline PolyBase<v> operator*(const PolyBase<v>& p1, const PolyBase<v>& p2); 331 template <poly_variant v>inline PolyBase<v> operator*(const PolyBase<v>& p1, const Number& n); 332 template<poly_variant variant> class PolyBase{ 327 333 328 334 public: 329 typedef PolyInputIterator<Poly > iterator;335 typedef PolyInputIterator<PolyBase> iterator; 330 336 void copy_on_write(){ 331 337 if (!ptr.unique()){ … … 342 348 } 343 349 344 Poly (ring r=currRing):ptr(new PolyImpl((poly) NULL,r)){345 } 346 Poly (int n, ring r=currRing):ptr(new PolyImpl(n,r)){347 348 } 349 Poly (const char* c, ring r=currRing):ptr(new PolyImpl((poly)NULL,r)){350 PolyBase(ring r=currRing):ptr(new PolyImpl((poly) NULL,r)){ 351 } 352 PolyBase(int n, ring r=currRing):ptr(new PolyImpl(n,r)){ 353 354 } 355 PolyBase(const char* c, ring r=currRing):ptr(new PolyImpl((poly)NULL,r)){ 350 356 //p_Read takes no const so do 351 357 char* cp=(char*) omalloc((strlen(c)+1)*sizeof(char)); … … 354 360 omfree(cp); 355 361 } 356 Poly (const Poly&p):ptr(p.ptr){357 } 358 Poly (const Number& n):ptr(new PolyImpl(n)){359 360 } 361 Poly (std::vector<int> v, ring r=currRing):ptr(new PolyImpl((poly) NULL,r)){362 PolyBase(const PolyBase&p):ptr(p.ptr){ 363 } 364 PolyBase(const Number& n):ptr(new PolyImpl(n)){ 365 366 } 367 PolyBase(std::vector<int> v, ring r=currRing):ptr(new PolyImpl((poly) NULL,r)){ 362 368 unsigned int i; 363 369 int s=v.size(); … … 369 375 ptr->p=p; 370 376 } 371 Poly & operator+=(Polyp2){377 PolyBase& operator+=(PolyBase p2){ 372 378 copy_on_write(); 373 379 *ptr += *p2.ptr; … … 375 381 return *this; 376 382 } 377 Poly & operator*=(Polyp2){383 PolyBase& operator*=(PolyBase p2){ 378 384 copy_on_write(); 379 385 *ptr *= *p2.ptr; … … 381 387 return *this; 382 388 } 383 Poly & operator*=(Number n){389 PolyBase& operator*=(Number n){ 384 390 copy_on_write(); 385 391 *ptr *=n; … … 392 398 Print(StringAppendS("")); 393 399 }*/ 394 virtual ~Poly (){}395 Poly (poly p, ring r):ptr(new PolyImpl(p,r)){396 } 397 Poly (poly p, ring r,int):ptr(new PolyImpl(p,r,0)){400 virtual ~PolyBase(){} 401 PolyBase(poly p, ring r):ptr(new PolyImpl(p,r)){ 402 } 403 PolyBase(poly p, ring r,int):ptr(new PolyImpl(p,r,0)){ 398 404 } 399 405 /*Poly(Poly& p){ … … 401 407 }*/ 402 408 403 PolyInputIterator<Poly > begin(){404 return PolyInputIterator<Poly >(ptr->p,ptr->r);405 } 406 PolyInputIterator<Poly > end(){407 return PolyInputIterator<Poly >(NULL, ptr->r);409 PolyInputIterator<PolyBase> begin(){ 410 return PolyInputIterator<PolyBase>(ptr->p,ptr->r); 411 } 412 PolyInputIterator<PolyBase> end(){ 413 return PolyInputIterator<PolyBase>(NULL, ptr->r); 408 414 } 409 415 ring getRing(){ … … 411 417 } 412 418 protected: 413 Poly (PolyImpl& impl):ptr(&impl){419 PolyBase(PolyImpl& impl):ptr(&impl){ 414 420 415 421 } … … 419 425 private: 420 426 shared_ptr<PolyImpl> ptr; 421 friend inline Poly operator+(const Poly& p1, const Poly& p2);422 friend inline Polyoperator*(const Poly& p1, const Poly& p2);423 friend inline Polyoperator*(const Poly& p1, const Number& n);427 //friend inline Poly operator+(const Poly& p1, const Poly& p2); 428 ///friend inline PolyBase operator*(const Poly& p1, const Poly& p2); 429 //friend inline PolyBase operator*(const Poly& p1, const Number& n); 424 430 // friend inline Poly operator*(const Poly& p1, const Number& n); 425 431 // friend inline template PolyBase<poly_variant variant> operator+(const PolyBase<v>& p1, const PolyBase<v>& p2); 432 friend PolyBase<variant> operator+<>(const PolyBase<variant>& p1, const PolyBase<variant>& p2); 433 friend PolyBase<variant> operator*<>(const PolyBase<variant>& p1, const PolyBase<variant>& p2); 434 friend PolyBase<variant> operator*<>(const PolyBase<variant>& p1, const Number& p2); 426 435 }; 427 428 inline Poly operator+(const Poly& p1, const Poly& p2){436 typedef PolyBase<RING> Poly; 437 template <poly_variant v> inline PolyBase<v> operator+(const PolyBase<v>& p1, const PolyBase<v>& p2){ 429 438 PolyImpl* res=new PolyImpl(*p1.ptr); 430 439 *res+=*p2.ptr; 431 return(Poly (*res));432 } 433 inline Poly operator*(const Poly& p1, const Poly& p2){440 return(PolyBase<v>(*res)); 441 } 442 template <poly_variant v> inline PolyBase<v> operator*(const PolyBase<v>& p1, const PolyBase<v>& p2){ 434 443 PolyImpl* res=new PolyImpl(*p1.ptr); 435 444 *res *= *p2.ptr; 436 return(Poly (*res));437 } 438 inline Poly operator*(const Poly& p1, const Number& n){445 return(PolyBase<v> (*res)); 446 } 447 template <poly_variant v>inline PolyBase<v> operator*(const PolyBase<v>& p1, const Number& n){ 439 448 PolyImpl* res=new PolyImpl(*p1.ptr); 440 449 *res *= n; 441 return(Poly (*res));450 return(PolyBase<v>(*res)); 442 451 } 443 452
Note: See TracChangeset
for help on using the changeset viewer.