BasisMapping.h 2.03 KB
Newer Older
Francois Gygi committed
1 2
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
3 4 5 6
// Copyright (c) 2008 The Regents of the University of California
//
// This file is part of Qbox
//
Francois Gygi committed
7 8
// Qbox is distributed under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 2 of
Francois Gygi committed
9 10 11 12 13 14
// the License, or (at your option) any later version.
// See the file COPYING in the root directory of this distribution
// or <http://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
15
// BasisMapping.h
Francois Gygi committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
//
////////////////////////////////////////////////////////////////////////////////

#ifndef BASISMAPPING_H
#define BASISMAPPING_H

#include <complex>
#include <vector>

class Basis;

class BasisMapping
{
  private:

  const Basis& basis_;
  int nprocs_, myproc_;

34
  int np0_, np1_, np2_, np012loc_;
Francois Gygi committed
35
  int nvec_;
36

Francois Gygi committed
37 38
  std::vector<int> np2_loc_;   // np2_loc_[iproc], iproc=0, nprocs_-1
  std::vector<int> np2_first_; // np2_first_[iproc], iproc=0, nprocs_-1
39

Francois Gygi committed
40 41 42 43 44
  std::vector<int> scounts, sdispl, rcounts, rdispl;
  std::vector<std::complex<double> > sbuf, rbuf;

  std::vector<int> ip_, im_;
  std::vector<int> ipack_, iunpack_;
45

Francois Gygi committed
46 47 48 49 50 51 52 53 54 55 56 57
  public:

  BasisMapping (const Basis &basis);
  int np0(void) const { return np0_; }
  int np1(void) const { return np1_; }
  int np2(void) const { return np2_; }
  int np2loc(void) const { return np2_loc_[myproc_]; }
  int np012loc(void) const { return np012loc_; }
  int nvec(void) const { return nvec_; }
  int zvec_size(void) const { return nvec_ * np2_; }

  // map a function c(G) to zvec_
58
  void vector_to_zvec(const std::complex<double> *c,
Francois Gygi committed
59 60
                      std::complex<double> *zvec);
  // map zvec_ to a function c(G)
61
  void zvec_to_vector(const std::complex<double> *zvec,
Francois Gygi committed
62
                      std::complex<double> *c);
63 64

  void transpose_fwd(const std::complex<double> *zvec,
Francois Gygi committed
65
                     std::complex<double> *ct);
66
  void transpose_bwd(const std::complex<double> *ct,
Francois Gygi committed
67 68 69
                     std::complex<double> *zvec);
};
#endif