PyTrilinos Logo

PyTrilinos Documentation for Trilinos Release 5.0

There are a number of ways to obtain PyTrilinos documentation. Running python interactively, you can use the help() or dir() functions on PyTrilinos modules, classes, methods or objects. Within a UNIX shell, you can run pydoc on any class in the PyTrilinos hierarchy. For more in-depth documentation, you should consult the specific package documentation pages available on the web or built locally with your copy of Trilinos.

This on-line PyTrilinos documentation therefore serves as a quick reference for listing which packages have wrappers, which header files within those packages have been wrapped, and any differences between the C++ and python implementation of a given class.

Current PyTrilinos Modules and Wrapped Header Files

Differences Between C++ and Python Implementations

  • The operator=() operator is always ignored, as you cannot override the python assignment mechanism.
  • The operator<<() operator is always ignored.
  • Any python keyword, such as print, will be ignored if it is a class method.
  • For any set of overloaded functions that differ only in argument types that python cannot distinguish, only one of the methods will be implemented in python. This means that int/long/bool overloads will default to the long version, and float/double pairs will default to the double version.
  • The Epetra_ prefix for all Epetra classes has been stripped in the python implementation. These classes are put in the Epetra python namespace, so the syntax is nearly identical, with the python "dot" namespace operator replacing the underscore present in the C++ Epetra names.
  • When an argument list calls for a C array of integers (e.g., int * Indices), the python programmer should provide a Numeric array of integers in its place.
The Print() and operator<<() methods are ignored for all classes that derive off of Epetra_Object, i.e. all Epetra classes. In its place, a python __str__() method has been added that calls the C++ Print() method. Thus the python statement print object, where object is derived from Epetra_Object, will give the desired output.
The operator()(int) method is ignored.
The operator()(int) method is ignored.
The Solve(bool, bool, bool, Epetra_Vector const&, Epetra_Vector&) method is ignored.
  • The operator()(int,int) method is ignored.
  • The A() const method is ignored.
  • A __getitem__(i,j) and __setitem__(i,j) method have been added to access individual elements of the matrix.
The operator()(int) methods are ignored.
The python Epetra.Vector class inherts from both Epetra_Vector and the Numeric UserArray class, with both views pointing to the same data buffer. Thus, an Epetra.Vector also behaves like a Numeric array, with, for example, a shape attribute. Thus a python programmer used to using Numeric arrays can use an Epetra.Vector exactly as he is accustomed to using Numeric arrays, but with the additional Epetra functionality.
  • There are three constructors for the python implementation. The first takes a Epetra_BlockMap and initializes the data to zero. The second takes a Epetra_BlockMap and a Numeric array (which must have equivalent sizes). The third takes just a Numeric array and creates an internal map based on an Epetra_SerialComm communicator.
  • The python print statement produces output with the Epetra.Vector formatted as a Numeric array would be.
  • The Print() method is re-instated for this class, with no argument. It sends the Epetra_Vector::Print() results to standard output.
  • A getArray() method has been added to access the vector as a pure Numeric array.
  • The None enumeration conflicts with the python None object. It has been renamed Group_None.
  • A getSoln(array) method has been added to retrieve the solution and copy it into array.
  • The getParameter() method has been implemented to use a single string argument. The second argument simply provides typing information not needed in python.
  • The boolean version of setParameter() is ignored. Use an integer argument instead.
  • The isParameterBool() method is ignored.
  • The boolean version of isParameterEqual() method is ignored. Use the integer version instead.
The None enumeration conflicts with the python None object. It has been renamed StatusTest_None.