Changeset c08bb7 in git for modules


Ignore:
Timestamp:
Aug 26, 2005, 12:39:08 PM (19 years ago)
Author:
Michael Brickenstein <bricken@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b21a664aa22dc6e196223af8a74ad4885e83547c')
Children:
91dc8b83208724311e3438df2a814cdd79ff2534
Parents:
595f592ce8b422634b4bab909107a7abff85373a
Message:
*bricken: matrix as input for Singular


git-svn-id: file:///usr/local/Singular/svn/trunk@8573 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
modules/python
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • modules/python/README

    r595f59 rc08bb7  
    1616vector
    1717number
     18matrix
    1819
    1920Output:
  • modules/python/interpretertester

    r595f59 rc08bb7  
    11ring r=0,(x,y,z),lp;
    22timer=1;
     3proc myprintmat(matrix m){
     4  print(m);
     5}
    36proc testproc1(){
    47print("Hallo Welt");
     
    3336    }
    3437  }
    35   print(m);
     38
    3639  return(m);
    3740}
     
    5558from Singular import foo2;
    5659m=functions.testproc6(x,y)
    57 print foo2(m)
     60functions.myprintmat(m)
    5861
    5962");
  • modules/python/playground.cc

    r595f59 rc08bb7  
    3131 
    3232}
    33 boost::python::str foo2(array f){
     33boost::python::object foo2(array f){
     34  using boost::python::extract;
     35  object o=f.attr("shape");
     36 
     37  object o1=o[0];
     38 
     39  object o2=o[1];
     40  int l1=extract<int>(o1);
     41
     42  Print("%d",l1);
     43  int l2=extract<int>(o2);
     44  Print("%d",l2);
     45  Poly& x = boost::python::extract<Poly&>(f[boost::python::make_tuple(0,0)]);
     46  x.print();
     47 
    3448  return boost::python::str("suc");
    3549}
  • modules/python/wrapper.h

    r595f59 rc08bb7  
    1 //$Id: wrapper.h,v 1.23 2005-08-25 11:20:34 bricken Exp $
     1//$Id: wrapper.h,v 1.24 2005-08-26 10:39:08 bricken Exp $
    22#ifndef PYTHON_SINGULAR_WRAPPER_HEADER
    33#define PYTHON_SINGULAR_WRAPPER_HEADER
     
    2525#include "playground.h"
    2626#include "matpol.h"
     27using boost::python::numeric::array;
     28using boost::python::extract;
    2729extern BOOLEAN errorreported;
    2830extern int inerror;
     
    8789    v->rtyp=VECTOR_CMD;
    8890    internal_append(v);
     91  }
     92  void appendArray(const array& f){
     93   
     94   
     95    object o=f.attr("shape");
     96 
     97    object o1=o[0];
     98   
     99    object o2=o[1];
     100    int l1=extract<int>(o1);
     101   
     102
     103    int l2=extract<int>(o2);
     104    matrix m=mpNew(l1,l2);
     105    for(int i=0;i<l1;i++){
     106      for(int j=0;j<l2;j++){
     107        Poly& x = boost::python::extract<Poly&>(f[boost::python::make_tuple(i,j)]);
     108        poly p=x.as_poly();
     109        MATELEM(m,i+1,j+1)=p;
     110      }
     111    }
     112    leftv v=initArg();
     113    v->data=m;
     114    v->rtyp=MATRIX_CMD;
     115    internal_append(v);
     116   
    89117  }
    90118 protected:
     
    179207  boost::python::class_<arg_list>("i_arg_list")
    180208    .def("append", &arg_list::appendPoly)
     209    .def("append", &arg_list::appendArray)
    181210    .def("append", &arg_list::appendNumber)
    182211   .def("append", &arg_list::appendint)
Note: See TracChangeset for help on using the changeset viewer.