BasisMapping.h 2.23 KB
Newer Older
Francois Gygi committed
1 2
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
3 4 5 6 7 8 9 10 11 12 13 14
// Copyright (c) 2008 The Regents of the University of California
//
// This file is part of Qbox
//
// Qbox is distributed under the terms of the GNU General Public License 
// as published by the Free Software Foundation, either version 2 of 
// 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 16 17
//  BasisMapping.h
//
////////////////////////////////////////////////////////////////////////////////
Francois Gygi committed
18
// $Id: BasisMapping.h,v 1.3 2008-08-13 06:39:42 fgygi Exp $
Francois Gygi committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

#ifndef BASISMAPPING_H
#define BASISMAPPING_H

#include <complex>
#include <vector>

class Basis;
class Context;

class BasisMapping
{
  private:

  const Context& ctxt_;
  const Basis& basis_;
  int nprocs_, myproc_;

  int np0_, np1_, np2_, np012_, np012loc_;
  int nvec_;
39

Francois Gygi committed
40 41
  std::vector<int> np2_loc_;   // np2_loc_[iproc], iproc=0, nprocs_-1
  std::vector<int> np2_first_; // np2_first_[iproc], iproc=0, nprocs_-1
42

Francois Gygi committed
43 44 45 46 47
  std::vector<int> scounts, sdispl, rcounts, rdispl;
  std::vector<std::complex<double> > sbuf, rbuf;

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

Francois Gygi committed
49 50 51 52 53 54 55 56 57 58 59 60 61
  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 np012(void) const { return np012_; }
  int np012loc(void) const { return np012loc_; }
  int nvec(void) const { return nvec_; }
  int zvec_size(void) const { return nvec_ * np2_; }

  const Context& context(void) const { return ctxt_; }
62

Francois Gygi committed
63
  // map a function c(G) to zvec_
64
  void vector_to_zvec(const std::complex<double> *c,
Francois Gygi committed
65 66
                      std::complex<double> *zvec);
  // map zvec_ to a function c(G)
67
  void zvec_to_vector(const std::complex<double> *zvec,
Francois Gygi committed
68
                      std::complex<double> *c);
69 70

  void transpose_fwd(const std::complex<double> *zvec,
Francois Gygi committed
71
                     std::complex<double> *ct);
72
  void transpose_bwd(const std::complex<double> *ct,
Francois Gygi committed
73 74 75
                     std::complex<double> *zvec);
};
#endif