Changeset 451a9a in git
- Timestamp:
- Jun 21, 2006, 8:27:12 AM (18 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38dfc5131670d387a89455159ed1e071997eec94')
- Children:
- 20d72f0729f1c6d0a9a7ed847785c4fb0271b3b7
- Parents:
- e6cbed94a014891c3db90b82149bb853254bb0d9
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/Ideal.h
re6cbed r451a9a 1 1 #ifndef IDEAL_CPP_HEADER 2 2 #define IDEAL_CPP_HEADER 3 //$Id: Ideal.h,v 1. 7 2005-09-21 09:51:10bricken Exp $3 //$Id: Ideal.h,v 1.8 2006-06-21 06:26:58 bricken Exp $ 4 4 #include <vector> 5 5 #include "Poly.h" … … 106 106 } 107 107 }; 108 class Modul :108 class Module: 109 109 public IdealBase<Vector>{ 110 public: 111 Module(ideal i, ring r){ 112 for(int j=0;j<IDELEMS(i);j++){ 113 storage.push_back(Vector(i->m[j],r)); 114 } 115 } 116 ideal as_module() const{ 117 118 //no checks for rings 119 int s=size(); 120 121 if (s==0) 122 s=1; 123 124 ideal result=idInit(s,1); 125 result->m[0]=NULL; 126 s=size(); 127 for(int i=0;i<s;i++){ 128 result->m[i]=storage[i].as_poly(); 129 130 } 131 if (size()==0) 132 result->rank=0; 133 else 134 result->rank=idRankFreeModule(result,storage[0].getRing()); 135 return result; 136 137 } 138 Module(iterator first, 139 iterator last, 140 const allocator_type& __a = allocator_type()): 141 IdealBase<Vector>(first,last,__a){ 142 } 143 Module(){ 144 } 110 145 }; 111 146 #endif -
kernel/Poly.h
re6cbed r451a9a 1 //$Id: Poly.h,v 1.3 3 2006-03-22 14:14:29bricken Exp $1 //$Id: Poly.h,v 1.34 2006-06-21 06:26:58 bricken Exp $ 2 2 3 3 … … 60 60 } 61 61 friend inline bool operator==(const Poly& p1, const Poly& p2); 62 friend inline bool operator==(const Vector& p1, const Vector& p2); 62 63 friend PolyImpl operator+(const PolyImpl& p1, const PolyImpl& n2); 63 64 friend PolyImpl operator-(const PolyImpl& p1, const PolyImpl& n2); … … 525 526 return *this; 526 527 } 527 528 friend inline bool operator==(const Vector& p1, const Vector& p2); 528 529 }; 529 530 … … 583 584 return p_EqualPolys(p1.ptr->p,p2.ptr->p,r1); 584 585 } 586 inline bool operator==(const Vector& p1, const Vector& p2){ 587 ring r1=p1.getRing(); 588 ring r2=p2.getRing(); 589 if (r1!=r2) return false; 590 return p_EqualPolys(p1.ptr->p,p2.ptr->p,r1); 591 } 585 592 template <poly_variant variant, class create_type,class error_traits> 586 593 inline typename PolyBase<variant,create_type,error_traits>::create_type -
modules/python/ideal_wrap.cc
re6cbed r451a9a 1 //$Id: ideal_wrap.cc,v 1. 9 2006-03-15 10:40:43bricken Exp $1 //$Id: ideal_wrap.cc,v 1.10 2006-06-21 06:27:11 bricken Exp $ 2 2 #include <boost/python.hpp> 3 3 #include "mod2.h" … … 29 29 return res; 30 30 } 31 static boost::python::object Module_as_str(const Module& p) 32 { 33 using boost::python::str; 34 //ring r=p.getRing(); 35 str helper; 36 list tojoin; 37 int i; 38 int s=p.size(); 39 //tojoin.append("["); 40 for(i=0;i<s;i++){ 41 tojoin.append(Vector_as_str(p[i])); 42 if (i<s-1) 43 tojoin.append(", "); 44 } 45 //tojoin.append("]"); 46 str res=helper.join(tojoin); 47 return res; 48 } 49 31 50 static Ring Ideal_get_Ring(const Ideal & p){ 32 51 return p.getRing(); … … 39 58 python list supports with the expception, that elements must\ 40 59 be Polynomials") 60 .def(init<>()) 61 .def(init<const Ideal&>()) 41 62 .def("__str__", Ideal_as_str) 42 63 .def("ring",Ideal_get_Ring) … … 45 66 46 67 } 68 void export_module() 69 { 70 boost::python::class_<Module>("Module", "supports most operation a\ 71 python list supports with the expception, that elements must\ 72 be Polynomials") 73 .def(init<>()) 74 .def(init<const Module&>()) 75 .def("__str__", Module_as_str) 76 .def("ring",Ideal_get_Ring) 77 .def(boost::python::init <>()) 78 .def(vector_indexing_suite<Module>()); 79 80 } 47 81 48 82 -
modules/python/ideal_wrap.h
re6cbed r451a9a 2 2 #define IDEAL_WRAP_HEADER 3 3 void export_ideal(); 4 void export_module(); 4 5 #endif -
modules/python/idealtester
re6cbed r451a9a 1 1 ring r=0,(x,y,z),lp; 2 2 timer=1; 3 python_module::python("from Singular import number, polynomial, ideal 4 i=ideal() 5 zero=number(0) 6 one=number(1) 7 zerop=polynomial(0) 3 LIB("python_module.so"); 4 Python_module::python("from Singular import Number, Polynomial, Ideal, gen, Module 5 i=Ideal() 6 zero=Number(0) 7 one=Number(1) 8 zerop=Polynomial(0) 8 9 i.append(zerop) 9 10 print len(i) 10 onep= polynomial(1)11 onep=Polynomial(1) 11 12 i.append(onep) 12 13 print len(i) … … 14 15 print p 15 16 print i 16 xy= polynomial('xy')17 xy=Polynomial('xy') 17 18 print xy 18 comp= polynomial('xy+1')19 comp=Polynomial('xy+1') 19 20 print comp 20 21 #the same as only monomials are build 21 22 22 z= polynomial(xy);23 z*= number(3);23 z=Polynomial(xy); 24 z*=Number(3); 24 25 print z,xy 25 print xy+ number(1)26 print xy+Number(1) 26 27 print z+xy 27 28 print z,xy 28 29 print xy*xy 29 30 print xy 30 for t in ((xy+ number(1))*(xy+number(-1))):31 for t in ((xy+Number(1))*(xy+Number(-1))): 31 32 print t,-t,t 33 import util 34 r=util.create_ring(char=0,nvars=3, varNames=['t','u','v','w'], ordering='lp', register=locals()) 35 r.set() 36 m=Module() 37 m.append(t*u*gen(1)+v*gen(2)) 38 m.append(w*gen(4)) 39 m.append(v*u*gen(3)) 40 print m 41 print m[1:] 42 del m[1] 43 print m 32 44 "); 33 45 $ -
modules/python/interpreter_support.cc
re6cbed r451a9a 1 //$Id: interpreter_support.cc,v 1.2 0 2006-06-17 13:47:17bricken Exp $1 //$Id: interpreter_support.cc,v 1.21 2006-06-21 06:27:11 bricken Exp $ 2 2 3 3 #include <sstream> … … 96 96 internal_append(v); 97 97 } 98 void appendModule(const Module& p){ 99 leftv v=initArg(); 100 v->data=p.as_module(); 101 v->rtyp=MODUL_CMD; 102 internal_append(v); 103 } 98 104 void appendint(int p){ 99 105 leftv v=initArg(); … … 218 224 } 219 225 } 226 void writeModule(const Module& p){ 227 if (id->typ==MODUL_CMD){ 228 id_Delete(&id->data.uideal, currRing); 229 230 id->data.uideal=p.as_module(); 231 } 232 } 220 233 void writeint(int p){ 221 234 if (id->typ==INT_CMD){ … … 331 344 case IDEAL_CMD: 332 345 return object(Ideal((ideal) v->data, currRing)); 346 case MODUL_CMD: 347 return object(Module((ideal) v->data, currRing)); 333 348 case NUMBER_CMD: 334 349 … … 368 383 369 384 return object(Ideal((ideal) id.id->data.uideal, currRing)); 385 case MODUL_CMD: 386 //object res; 387 388 return object(Module((ideal) id.id->data.uideal, currRing)); 370 389 case NUMBER_CMD: 371 390 … … 485 504 .def("append", &arg_list::appendint) 486 505 .def("append", &arg_list::appendIdeal) 506 .def("append", &arg_list::appendModule) 487 507 .def("append", &arg_list::appendPrelist) 488 508 .def("append", &arg_list::appendVector) … … 499 519 .def("write", &idhdl_wrap::writeint) 500 520 .def("write", &idhdl_wrap::writeIdeal) 521 .def("write", &idhdl_wrap::writeModule) 501 522 .def("write", &idhdl_wrap::writeVector) 502 523 .def("write", &idhdl_wrap::writeList) -
modules/python/interpretertester
re6cbed r451a9a 3 3 poly f=10; 4 4 ideal i=x,y; 5 module m=x*gen(1),y*gen(2); 5 6 list l=f,i; 6 7 intvec iv=1,2,3,45,5,6,7,8; … … 37 38 return(p); 38 39 } 40 39 41 proc testproc5(int p){ 40 42 print("Hallo Welt ihr ints"); … … 54 56 return(m); 55 57 } 58 59 proc testproc7(module p){ 60 print("Hallo Welt ihr Modules"); 61 print(p); 62 return(p); 63 } 64 56 65 list mylist=1,2,3; 57 66 LIB("python_module.so"); … … 95 104 print functions.testproc5(325) 96 105 print functions.testproc6(x,y) 106 print functions.testproc7(functions.m) 97 107 from Singular import foo2; 98 108 m=functions.testproc6(x,y) 99 109 functions.myprintmat(m) 100 110 print functions.a 111 print 'Read module:', functions.m 101 112 102 113 print i -
modules/python/poly_wrap.cc
re6cbed r451a9a 8 8 using boost::python::self; 9 9 boost::python::str Poly_as_str(const Poly& p) 10 { 11 using boost::python::str; 12 //ring r=p.getRing(); 13 14 char* out=p.c_string(); 15 return boost::python::str(out,strlen(out)); 16 } 17 boost::python::str Vector_as_str(const Vector& p) 10 18 { 11 19 using boost::python::str; … … 34 42 .def("leadCoef",&Poly::leadCoef) 35 43 .def("leadExp", &Poly::leadExp) 44 36 45 .def(-self) 37 46 .def(self*=self) … … 46 55 .def(self+=Number()) 47 56 .def(self*=Number()) 57 48 58 .def(self*self); 59 49 60 } 50 61 -
modules/python/poly_wrap.h
re6cbed r451a9a 6 6 void export_poly(); 7 7 boost::python::str Poly_as_str(const Poly& p); 8 boost::python::str Vector_as_str(const Vector& p); 8 9 #endif -
modules/python/wrapper.h
re6cbed r451a9a 1 //$Id: wrapper.h,v 1.3 3 2006-03-24 17:36:58bricken Exp $1 //$Id: wrapper.h,v 1.34 2006-06-21 06:27:12 bricken Exp $ 2 2 #ifndef PYTHON_SINGULAR_WRAPPER_HEADER 3 3 #define PYTHON_SINGULAR_WRAPPER_HEADER … … 61 61 export_playground(); 62 62 export_ideal(); 63 export_module(); 63 64 //export_interpreter(); 64 65 export_ring();
Note: See TracChangeset
for help on using the changeset viewer.