Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Frequently Asked Questions (FAQ) about Thyra Software


Questions about the smart pointer class Teuchos::RCP

Q: What are RCP objects and why are they important?

A:The class Teuchos::RCP implements a form of reference counting which, through the magic of smart pointers in C++, allows objects to be created and used without much concern for when and where they should be deleted. It is a form of garbage collection but is not as general or fail- safe as in languages with built in garbage collection. For more information see:


and click on: Teuchos::RCP

Q: Should my code use RCP's everywhere?

A: You should only use RCP to wrap objects where a persisting relationship is being formed or maintained. For non-persisting relationships, use raw C++ references and pointers.

For more information see the main body and Appendix D of the document:

Questions about Fundamental Thyra Operator/Vector Interfaces

Q: Why is Thyra written with so many non-member helper functions instead of member functions?

In many standard C++ classes students are told that the beauty of OOP is that functions and data can be put together into classes to combine the operations with the data on which they operate. Is this not correct?

A: Generally member functions should only be used over non-member functions when direct access to private or protected data for functions is required. By minimizing the amount of code that can access non-public data you greatly simplify maintenance. See Item 44 in "C++ Coding Standards" by Sutter and Alexandrescu for a discussion of this topic.

Q: Where is the Scalar class, and how do I use it to replace my underlying data-type, e.g. double, in my ANA?

A: The 'Scalar' class is in a template argument in all of the core Thyra interface code. The goal of this template argument is to allow many abstract numerical algorithms to be written in a general form to support a number of different scalar types (e.g. real, complex, extended precision etc.). While the interfaces, the composite classes, and many of the concrete implementations are fully templated some are not and can only support one scalar type (e.g. see the Epetra/Thyra adapters).

See the sillyCgSolve() and sillyPowerMethod() examples for how this templating is used.

Q: How do I create a Thyra::VectorBase or Thyra::MultiVectorBase object?

The member functions Thyra::VectorSpaceBase::createMember() and Thyra::VectorSpaceBase::createMembers() are protected and can not be called by client code.

A: You must use the non-member functions Thyra::createMember() and Thyra::createMembers() described here and also used in the examples sillyCgSolve() and sillyModifiedGramSchmidt().