Changeset 26f928 in git for modules/python
- Timestamp:
- Sep 9, 2005, 12:03:07 PM (19 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38dfc5131670d387a89455159ed1e071997eec94')
- Children:
- a675fcb30922f056ecdcbd0e77cdd66c2c919faf
- Parents:
- 4a8f253390029bf6c14db1e195cea6271e34a4d4
- Location:
- modules/python
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/python/README
r4a8f25 r26f928 75 75 76 76 77 NEWS: 78 *global_functions has be renamed to singular_globals_proxy 79 the old name exists for short time for compat. 80 81 *it is now possible to use the singular_globals_proxy for 82 -reading global variables 83 -writing global variables, if the var exists with the correct type in the interpreter 84 -calling global interpreter functions (not builtins, for example groebner but not std 77 85 78 86 … … 83 91 84 92 85 -
modules/python/interpreter.py
r4a8f25 r26f928 21 21 raise AttributeError("Global variable "+name+" has unknown type") 22 22 return res 23 23 def __setattr__(self,name,value): 24 id=get_idhdl(name) 25 if id.is_zero(): 26 raise Expception 27 else: 28 id.write(value) 24 29 #for compatibility the old name 25 30 global_functions=singular_globals_proxy -
modules/python/interpreter_support.cc
r4a8f25 r26f928 18 18 using boost::python::numeric::array; 19 19 using boost::python::extract; 20 matrix matrixFromArray(const array& f){ 21 object o=f.attr("shape"); 22 23 object o1=o[0]; 24 25 object o2=o[1]; 26 int l1=extract<int>(o1); 27 28 29 int l2=extract<int>(o2); 30 matrix m=mpNew(l1,l2); 31 for(int i=0;i<l1;i++){ 32 for(int j=0;j<l2;j++){ 33 Poly& x = boost::python::extract<Poly&>(f[boost::python::make_tuple(i,j)]); 34 poly p=x.as_poly(); 35 MATELEM(m,i+1,j+1)=p; 36 } 37 } 38 return m; 39 } 20 40 class idhdl_wrap{ 21 41 public: … … 36 56 Print("type:%d\n",id->typ); 37 57 } 58 void writePoly(const Poly& p){ 59 60 if (id->typ==POLY_CMD){ 61 p_Delete(&id->data.p, currRing); 62 id->data.p=p.as_poly(); 63 } 64 65 } 66 void writeIdeal(const Ideal& p){ 67 if (id->typ==IDEAL_CMD){ 68 id_Delete(&id->data.uideal, currRing); 69 70 id->data.uideal=p.as_ideal(); 71 } 72 } 73 void writeint(int p){ 74 if (id->typ==INT_CMD){ 75 id->data.i=p; 76 } 77 } 78 void writeNumber(const Number& p){ 79 80 if (id->typ==NUMBER_CMD){ 81 n_Delete(&id->data.n, currRing); 82 id->data.n=p.as_number(); 83 } 84 } 85 void writeVector(const Vector& p){ 86 87 if (id->typ==VECTOR_CMD){ 88 p_Delete(&id->data.p, currRing); 89 id->data.p=p.as_poly(); 90 } 91 } 92 void writeArray(const array& f){ 93 if(id->typ=MATRIX_CMD){ 94 matrix m=matrixFromArray(f); 95 id_Delete((ideal*) &id->data.umatrix,currRing); 96 id->data.umatrix; 97 } 98 } 38 99 }; 100 101 39 102 class arg_list{ 40 103 public: … … 79 142 } 80 143 void appendArray(const array& f){ 81 82 83 object o=f.attr("shape"); 84 85 object o1=o[0]; 86 87 object o2=o[1]; 88 int l1=extract<int>(o1); 89 90 91 int l2=extract<int>(o2); 92 matrix m=mpNew(l1,l2); 93 for(int i=0;i<l1;i++){ 94 for(int j=0;j<l2;j++){ 95 Poly& x = boost::python::extract<Poly&>(f[boost::python::make_tuple(i,j)]); 96 poly p=x.as_poly(); 97 MATELEM(m,i+1,j+1)=p; 98 } 99 } 100 leftv v=initArg(); 144 leftv v=initArg(); 145 matrix m=matrixFromArray(f); 101 146 v->data=m; 102 147 v->rtyp=MATRIX_CMD; … … 236 281 .def("is_proc", &idhdl_wrap::id_is_proc) 237 282 .def("print_type", &idhdl_wrap::print_type) 283 .def("write", &idhdl_wrap::writePoly) 284 .def("write", &idhdl_wrap::writeArray) 285 .def("write", &idhdl_wrap::writeNumber) 286 .def("write", &idhdl_wrap::writeint) 287 .def("write", &idhdl_wrap::writeIdeal) 288 .def("write", &idhdl_wrap::writeVector) 238 289 .def("__str__", idhdl_as_str); 239 290 def("call_interpreter_method",call_interpreter_method); -
modules/python/interpretertester
r4a8f25 r26f928 1 1 ring r=0,(x,y,z),lp; 2 2 int a=12345; 3 poly f=0; 3 4 timer=1; 4 5 proc myprintmat(matrix m){ … … 53 54 print functions.groebner(i); 54 55 xy=x*y 55 56 functions.f=xy 56 57 57 58 xye1=xy*gen(1) … … 67 68 print functions.a 68 69 "); 70 print(f); 69 71 $
Note: See TracChangeset
for help on using the changeset viewer.