/[escript]/trunk/escript/src/escriptcpp.cpp
ViewVC logotype

Diff of /trunk/escript/src/escriptcpp.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3368 by jfenwick, Fri Nov 19 05:59:46 2010 UTC revision 3506 by jfenwick, Wed May 11 01:59:45 2011 UTC
# Line 278  args("arg"), "assigns new location to th Line 278  args("arg"), "assigns new location to th
278    //    //
279    // Interface for Data    // Interface for Data
280    //    //
281    class_<escript::Data>("Data","Represents a collection of datapoints. It is used to store the values of a function. For more details please consult the c++ class documentation.",init<>() )    class_<escript::Data>("Data"/*,shared_ptr<Data>*/, "Represents a collection of datapoints. It is used to store the values of a function. For more details please consult the c++ class documentation.",init<>() )
282      // various constructors for Data objects      // various constructors for Data objects
283      .def(init<const object&, optional<const escript::FunctionSpace&, bool> >(args("value","what","expand")))      .def(init<const object&, optional<const escript::FunctionSpace&, bool> >(args("value","what","expand")))
284      .def(init<const double, const tuple&, optional<const escript::FunctionSpace&, bool> >(args("value","shape","what","expand")))      .def(init<const double, const tuple&, optional<const escript::FunctionSpace&, bool> >(args("value","shape","what","expand")))
# Line 424  args("arg"), "assigns new location to th Line 424  args("arg"), "assigns new location to th
424      .def("__neg__",&escript::Data::neg, ":return: negation of the values in this object\n:rtype: `Data`")      .def("__neg__",&escript::Data::neg, ":return: negation of the values in this object\n:rtype: `Data`")
425      // following implements the python "+" identity operator      // following implements the python "+" identity operator
426      .def("__pos__",&escript::Data::pos, "\nThe unary + operator\n\n:rtype: `Data`")      .def("__pos__",&escript::Data::pos, "\nThe unary + operator\n\n:rtype: `Data`")
427      // following two functions implement the python [] operator      // following three functions implement the python [] operator
428      .def("__getitem__",&escript::Data::getItem,"Used by the python [] operator\n\n:rtype: `Data`")      .def("__getitem__",&escript::Data::getItem,"Used by the python [] operator\n\n:rtype: `Data`")
429      .def("__setitem__",&escript::Data::setItemO,"Used by the python [] operator")      .def("__setitem__",&escript::Data::setItemO,"Used by the python [] operator")
430      .def("__setitem__",&escript::Data::setItemD,"Used by the python [] operator")      .def("__setitem__",&escript::Data::setItemD,"Used by the python [] operator")
431      // following two functions implement the python ** operator      // following three functions implement the python ** operator
432      .def("__pow__",&escript::Data::powO,"Used by the python ** operator\n\n:rtype: `Data`")      .def("__pow__",&escript::Data::powO,"Used by the python ** operator\n\n:rtype: `Data`")
433      .def("__pow__",&escript::Data::powD)      .def("__pow__",&escript::Data::powD)
434      .def("__rpow__",&escript::Data::rpowO,"\nUsed by the python ** operator\n\n:rtype: `Data`")      .def("__rpow__",&escript::Data::rpowO,"\nUsed by the python ** operator\n\n:rtype: `Data`")
435        // following two functions implement the newer python / operator
436        .def("__truediv__",&escript::Data::truedivD)
437        .def("__truediv__",&escript::Data::truedivO)
438      // NOTE:: The order of these declarations is important. Anything      // NOTE:: The order of these declarations is important. Anything
439      // declared before the generic declaration isn't found so the generic      // declared before the generic declaration isn't found so the generic
440      // version will be called.      // version will be called.
441      .def(self + other<object>())  //    .def(self + other<object>())
442      .def(other<object>() + self)  //    .def(other<object>() + self)
443      .def(self + self)  //    .def(self + self)
444      .def(self += other<object>())      .def(self += other<object>())
445      .def(self += self)      .def(self += self)
446    
447      .def(self - other<object>())  //     .def(self - other<object>())
448      .def(other<object>() - self)  //     .def(other<object>() - self)
449      .def(self - self)  //     .def(self - self)
450      .def(self -= other<object>())      .def(self -= other<object>())
451      .def(self -= self)      .def(self -= self)
452    
453      .def(self * other<object>())  //     .def(self * other<object>())
454      .def(other<object>() * self)  //     .def(other<object>() * self)
455      .def(self * self)  //     .def(self * self)
456      .def(self *= other<object>())      .def(self *= other<object>())
457      .def(self *= self)      .def(self *= self)
458    
459      .def(self / other<object>())  //     .def(self / other<object>())
460      .def(other<object>() / self)  //     .def(other<object>() / self)
461      .def(self / self)  //     .def(self / self)
462      .def(self /= other<object>())      .def(self /= other<object>())
463      .def(self /= self)      .def(self /= self)
464      // Need scope resolution due to a bug either in the compiler or      // Need scope resolution due to a bug either in the compiler or
465      // the boost code. This calls operator << for Data.      // the boost code. This calls operator << for Data.
466      .def(self_ns::str(self))      .def(self_ns::str(self))
467      .def("_inverse", &escript::Data::matrixInverse, ":return: inverse of square matricies\n");      .def("_inverse", &escript::Data::matrixInverse, ":return: inverse of square matricies\n")
468    //    .def("__add__", &escript::Data::addOperatorD)
469        .def("__add__", &escript::Data::__add__)
470        .def("__radd__", &escript::Data::__add__)  // its the same coz + is commutative
471        .def("__sub__", &escript::Data::__sub__)
472        .def("__rsub__", &escript::Data::__rsub__)
473        .def("__mul__", &escript::Data::__mul__)  
474        .def("__rmul__", &escript::Data::__mul__)   // commutative
475        .def("__div__", &escript::Data::__div__)  
476        .def("__rdiv__", &escript::Data::__rdiv__)   // commutative
477        
478        ;
479    
480    //    //
481    // Factory methods for function space    // Factory methods for function space
# Line 559  args("arg"), "assigns new location to th Line 572  args("arg"), "assigns new location to th
572      arg("what")=escript::FunctionSpace(),      arg("what")=escript::FunctionSpace(),
573      arg("expanded")=false));      arg("expanded")=false));
574    
575    
576     def("RandomData", escript::randomData, (arg("shape"), arg("fs"), arg("seed")=0),
577    "Creates a new expanded Data object containing (not very) random values.\n\n"
578    ":param shape: datapoint shape\n:type shape: tuple\n"
579    ":param fs: function space for data object.\n:type fs: `FunctionSpace`\n"
580    ":param seed: seed for random number generator.\n:type seed: long\n");
581    
582    //    //
583    // Binary operators    // Binary operators
584    //    //

Legend:
Removed from v.3368  
changed lines
  Added in v.3506

  ViewVC Help
Powered by ViewVC 1.1.26