Changeset e88c64 in git for modules


Ignore:
Timestamp:
Sep 15, 2006, 11:27:44 AM (18 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
Children:
8d1ad78ac082c58a90181498f0f20747571dcb62
Parents:
21e48b4cf85109274682f479ef676117ed623121
Message:
*hannes: 64bit stuff


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

Legend:

Unmodified
Added
Removed
  • modules/python/interpreter_support.cc

    r21e48b re88c64  
    1 //$Id: interpreter_support.cc,v 1.21 2006-06-21 06:27:11 bricken Exp $
     1//$Id: interpreter_support.cc,v 1.22 2006-09-15 09:27:44 Singular Exp $
    22
    33#include <sstream>
     
    3232matrix matrixFromArray(const array& f){
    3333  object o=f.attr("shape");
    34  
     34
    3535  object o1=o[0];
    36  
     36
    3737  object o2=o[1];
    3838  int l1=extract<int>(o1);
    3939
    40  
     40
    4141  int l2=extract<int>(o2);
    4242  matrix m=mpNew(l1,l2);
     
    6666      omFreeBin(args, sleftv_bin);
    6767    }
    68    
     68
    6969  }
    7070  leftv pop_front(){
     
    104104  void appendint(int p){
    105105      leftv v=initArg();
    106     v->data=(void*)p;
     106    v->data=(void*)((long)p);
    107107    v->rtyp=INT_CMD;
    108108    internal_append(v);
     
    126126    v->rtyp=MATRIX_CMD;
    127127    internal_append(v);
    128    
     128
    129129  }
    130130  void appendString(const char* s){
     
    144144  lists dumpToLists(){
    145145    int n=length();
    146    
     146
    147147    lists res=(lists)omAlloc0Bin(slists_bin);
    148148    res->Init(n);
     
    155155    }
    156156    return res;
    157    
     157
    158158  }
    159159  void appendPrelist(arg_list& l){
     
    182182      leftv last=args;
    183183      while(last->next!=NULL){
    184         last=last->next;
     184        last=last->next;
    185185      }
    186186      last->next=v;
     
    188188      args=v;
    189189  }
    190  
     190
    191191};
    192192
     
    210210  }
    211211  void writePoly(const Poly& p){
    212    
     212
    213213    if (id->typ==POLY_CMD){
    214214      p_Delete(&id->data.p, currRing);
    215215      id->data.p=p.as_poly();
    216216    }
    217    
     217
    218218  }
    219219  void writeIdeal(const Ideal& p){
    220220    if (id->typ==IDEAL_CMD){
    221221      id_Delete(&id->data.uideal, currRing);
    222      
     222
    223223      id->data.uideal=p.as_ideal();
    224224    }
     
    227227    if (id->typ==MODUL_CMD){
    228228      id_Delete(&id->data.uideal, currRing);
    229      
     229
    230230      id->data.uideal=p.as_module();
    231231    }
     
    237237  }
    238238  void writeNumber(const Number& p){
    239      
     239
    240240 if (id->typ==NUMBER_CMD){
    241241      n_Delete(&id->data.n, currRing);
     
    244244  }
    245245  void writeVector(const Vector& p){
    246        
     246
    247247    if (id->typ==VECTOR_CMD){
    248248      p_Delete(&id->data.p, currRing);
     
    295295  using boost::python::object;
    296296  using boost::python::list;
    297  
     297
    298298  list l;
    299  
    300  
     299
     300
    301301  for(int i=1;i<=MATROWS(m);i++){
    302302    list row;
     
    311311  //FIXME: should call this only once
    312312  array::set_module_and_type("Numeric",
    313                              "ArrayType"
    314                              );
    315  
     313                             "ArrayType"
     314                             );
     315
    316316  return array(l);
    317317}
     
    320320    using boost::python::list;
    321321    list res;
    322    
     322
    323323    for(int i=0;i<=l->nr;i++){
    324324        leftv lv=&l->m[i];
     
    333333  switch (v->rtyp){
    334334  case INT_CMD:
    335     return object((int)v->data);
     335    return object((int)((long)v->data));
    336336  case POLY_CMD:
    337    
    338337    return object(Poly((poly) v->data, currRing));
    339338  case STRING_CMD:
    340339    return str((const char*) v->data);
    341340  case  VECTOR_CMD:
    342    
    343341    return object( Vector((poly) v->data, currRing));
    344342  case IDEAL_CMD:
     
    347345    return object(Module((ideal) v->data, currRing));
    348346  case  NUMBER_CMD:
    349  
    350347    return object(Number((number) v->data, currRing));
    351348  case MATRIX_CMD:
    352     {
    353       return buildPythonMatrix((matrix) v->data,currRing);
    354     }
     349    return buildPythonMatrix((matrix) v->data,currRing);
    355350  case LIST_CMD:
    356351    return buildPythonList((lists) v->data, currRing);
     
    359354  case INTVEC_CMD:
    360355    return object(Intvec(*(intvec*) v->data));
     356
    361357  default:
    362    
    363358    return object();
    364359  }
    365360}
    366 boost::python::object buildPyObjectFromIdhdl(const idhdl_wrap&  id){
     361boost::python::object buildPyObjectFromIdhdl(const idhdl_wrap&  id)
     362{
    367363  using boost::python::object;
    368  
     364
    369365  switch (id.id->typ){
    370366  case STRING_CMD:
     
    374370    return object((int)id.id->data.i);
    375371  case POLY_CMD:
    376    
     372
    377373    return object(Poly((poly) id.id->data.p, currRing));
    378374  case  VECTOR_CMD:
    379    
     375
    380376    return object( Vector((poly) id.id->data.p, currRing));
    381377  case IDEAL_CMD:
     
    388384    return object(Module((ideal) id.id->data.uideal, currRing));
    389385  case  NUMBER_CMD:
    390  
     386
    391387    return object(Number((number) id.id->data.n, currRing));
    392388  case MATRIX_CMD:
     
    401397    return object(Intvec(*(intvec*) id.id->data.iv));
    402398  default:
    403     return object();   
     399    return object();
    404400    //Py_INCREF(Py_None);
    405401    //return Py_None;
     
    409405boost::python::object call_interpreter_method(const idhdl_wrap& proc, const arg_list& args){
    410406  //idhdl oldPackHDL=currPackHdl;
    411  
     407
    412408  //package oldPack=currPack;
    413409  //currPack=proc.id->data.pinf->pack;
     
    423419
    424420  return buildPyObjectFromLeftv(&iiRETURNEXPR[voice]);
    425  
     421
    426422  //return res;
    427423}
    428424boost::python::object call_builtin_method_general(const char* name, arg_list& l){
    429  
     425
    430426
    431427  int cmd_n=-1;
     
    435431//   return Py_None;
    436432  if (cmd_n<0){
    437  
     433
    438434
    439435  return object();
    440  
     436
    441437  } else {
    442438
     
    450446    case 2:
    451447      {
    452         leftv arg1=l.pop_front();
    453         leftv arg2=l.pop_front();
    454         iiExprArith2(res,arg1,cmd_n,arg2,TRUE);
    455         free_leftv(arg1);
    456         free_leftv(arg2);
    457         break;
     448        leftv arg1=l.pop_front();
     449        leftv arg2=l.pop_front();
     450        iiExprArith2(res,arg1,cmd_n,arg2,TRUE);
     451        free_leftv(arg1);
     452        free_leftv(arg2);
     453        break;
    458454      }
    459455    case 3:
    460456      {
    461         leftv arg1=l.pop_front();
    462         leftv arg2=l.pop_front();
    463         leftv arg3=l.pop_front();
    464        
    465        
    466         iiExprArith3(res,cmd_n,arg1,arg2,arg3);
    467         free_leftv(arg1);
    468         free_leftv(arg2);
    469         free_leftv(arg3);
    470         break;
     457        leftv arg1=l.pop_front();
     458        leftv arg2=l.pop_front();
     459        leftv arg3=l.pop_front();
     460
     461
     462        iiExprArith3(res,cmd_n,arg1,arg2,arg3);
     463        free_leftv(arg1);
     464        free_leftv(arg2);
     465        free_leftv(arg3);
     466        break;
    471467      }
    472468    default:
     
    485481  using boost::python::str;
    486482  //ring r=p.getRing();
    487  
     483
    488484
    489485  std::basic_stringstream<char>  s;
     
    530526  def("transfer_to_python",buildPyObjectFromIdhdl);
    531527  def("is_builtin", is_builtin);
    532  
    533 }
    534 
    535 
     528
     529}
     530
     531
Note: See TracChangeset for help on using the changeset viewer.