[Trilinos-Users] [EXTERNAL] Trilinos-Users Digest, Vol 130, Issue 11

Hoemmen, Mark mhoemme at sandia.gov
Tue Jun 7 13:46:19 EDT 2016



On 6/7/16, 11:34 AM, "Trilinos-Users on behalf of trilinos-users-request at trilinos.org" <trilinos-users-bounces at trilinos.org on behalf of trilinos-users-request at trilinos.org> wrote:
>Message: 1
>Date: Tue, 7 Jun 2016 11:26:27 -0600
>From: Ashesh Chattopadhyay <ashesh6810 at gmail.com>
>To: Trilinos-Users at trilinos.org
>Subject: [Trilinos-Users] Accessing elements of a Tpetra Vector with
>	[]	operator
>Message-ID:
>	<CACbaWS2-odJQFkRRhc1yZfWUT+5rBr4EYMkXgU1f8iptkKF6KA at mail.gmail.com>
>Content-Type: text/plain; charset="utf-8"
>
>Hi All,
>
>I have an example of a Tpetra vector whose elements I want to fill inside a
>for loop.
>My code snippet looks like this(I am only writing the essential lines)
>
>*  typedef Tpetra::Vector<>::scalar_type scalar_type;*
>
>*  typedef Tpetra::Vector<>::global_ordinal_type global_ordinal_type;*
>
>*  typedef Tpetra::Vector<>::local_ordinal_type local_ordinal_type;*
>
>*  const size_t length=contigMap->getNodeNumElements();*
>
>*  for(local_ordinal_type i=0;i<length;++i)*
>*   {*
>
>*      x[i]=1;*
>
>*  }*
>
>However I get the following error.
>
> *error: no match for ?operator[]? (operand types are ?vector_type {aka
>Tpetra::Vector<>}? and ?local_ordinal_type {aka int}?)*
>*       x[i]=1;*
>
>According to the user guide I can access Tpetra vector elements with []
>operator as long as the indices are local to a processor and are of
>local_ordinal type.

Please show me the place in the user guide where it says that.

>Can you please help me understand how to access Tpetra vectors in such a
>scenario?

Check out the Tpetra tutorial examples, in particular Lesson 07.

mfh



More information about the Trilinos-Users mailing list