[Trilinos-Users] Accessing elements of a Tpetra Vector with [] operator

Ashesh Chattopadhyay ashesh6810 at gmail.com
Tue Jun 7 13:26:27 EDT 2016


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.
Can you please help me understand how to access Tpetra vectors in such a
scenario?

Thanks
Ashesh





-- 
Research Assistant, Multi-Scale Multi-Physics Computation Lab
University of Texas at El Paso
Texas, El Paso, USA
(+1) 915-355-5013
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://trilinos.org/pipermail/trilinos-users/attachments/20160607/9d363da0/attachment.html>


More information about the Trilinos-Users mailing list