On 12/27/2017 10:15 PM, Phani Motamarri wrote:

I have a STL array of parallel distributed vectors

*std::vector<VectorType> X;*

This unrelated to your problem, but storing (linear algebra) vectors in std::vector is awkward because it may require copying vectors around when you resize the std::vector. A useful design pattern is to use
  std::vector<std::unique_ptr<VectorType>>
instead. If you resize the vector, then you only need to copy the pointer, not the entire vector.


In the above VectorType denotes parallel::distributed::Vector<double>. The size of X (numVectorsX) can be close to 5,000 to 10,000 for very large problems. All these vectors in X form a subspace and I would like to evaluate the overlap matrix associated with these vectors i.e I would like to evaluate the matrix A = Q^T*Q where Q is the matrix whose column vectors are the vectors in X and the matrix A is a square matrix
with dimension equal to numVectorsX.

I was wondering if anyone can suggest a computationally efficient way of evaluating this overlap matrix A using deal ii functionality.

I don't see a different way than to do the N^2/2 dot products that make up the matrix A:
  for (unsigned int i=0; i<N; ++i)
    for (unsigned int j=i; j<N; ++j)
      A(i,j) = A(j,i) = X[i] * X[j];

This could be made more efficient if you didn't store a vector of vectors, but instead a dense matrix that is distributed across processors. PETSc has a matrix type for this (see http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateDense.html#MatCreateDense) but we don't currently have wrappers for the parallel version (PETScWrappers::FullMatrix is apparently only sequential). It would not be terribly difficult to extend these wrappers to the parallel case, if you wanted to go this route -- and we'd be happy to guide you in this direction.

Best
 W.

--
------------------------------------------------------------------------
Wolfgang Bangerth          email:                 [email protected]
                           www: http://www.math.colostate.edu/~bangerth/

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to