http://software.sandia.gov/Trilinos/RefCountPtrBeginnersGuideSAND.pdf
and click on: Teuchos::RefCountPtr
A: There are two ways to get at the underlying raw pointer to an object that is wrapped in the RefCountPtr<C> object c_ptr:
C *c_rptr1 = c_ptr.get(); // Unchecked, can be NULL C *c_rptr2 = &*c_ptr; // Checked in debug build and will not return NULL
You should use c_ptr.get() when it is okay for the pointer to be NULL. On the other hand, you should use &*c_ptr when you don't want to allow the raw pointer to be NULL. This is because the operator function <tt>Teuchos::RefCountPtr::operator*() will throw an exception if Teuchos::RefCountPtr::get()==NULL when the code is compiled using the macro define -D_DEBUG.
For more information see Item 3 in Appendix B in
http://software.sandia.gov/Trilinos/RefCountPtrBeginnersGuideSAND.pdf
For more information see the main body and Appendix D of the document:
http://software.sandia.gov/Trilinos/RefCountPtrBeginnersGuideSAND.pdf
A: Generally member functions should only be used over non-member functions when direct access to private or protected data for functions is required. My minimizing the amount of code that can access non-public data you greatly simplify maintenance. See section 11.3.1 in "The C++ Programming Language: Special Edition" for a discussion of this topic.
Thyra::VectorBase interface can not be allowed in most general abstract numerical algorithms except in very specialized cases. Direct element access assumes that all of the the vector data is readily available which is not the case in distributed-memory, out-of-core and certainly not client/server runtime configurations. In addition, an overloaded operator[] function would be extremely inefficient since it would have to be a virtual function.
For more information on the philosophy of the design of vector interface Thyra::VectorBase see the document "Vector Reduction/Transformation Operators" at:
http://software.sandia.gov/RTOp/RTOpTOMS.pdf
y = alpha*x + z; y = adjoint(A)*x + B*z;
for large abstract objects in a near-optimally efficient manner is extremely non-trivial. Such a capability can be supported through the creation of handle classes and compile-time expression templates but such an implementation is complicated and is difficult for beginners to debug through. There are a whole host of other reasons they Matlab-like syntax will not work as well as in Matlab. For a slightly more detailed discussion, see the document
A Simple Convention for the Specification of Linear Algebra Function Prototypes in C++
In short, Thyra does not (yet) support operator overloading for Matlab-like syntax and will not until the resulting code can be as efficient, compile-time safe, and as debuggable as the current lower-level function-call interface. However, check back with Thyra in the near future and you might find such handle classes with operator overloading.
See the Thyra::sillyCgSolve() and Thyra::sillyPowerMethod() examples for how this templating is used.
A: You must use the non-member functions Thyra::createMember() and Thyra::createMembers() described here.
1.3.9.1