MADNESS  version 0.9
complex_fun.h
Go to the documentation of this file.
1 /*
2  This file is part of MADNESS.
3 
4  Copyright (C) 2007,2010 Oak Ridge National Laboratory
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 
20  For more information please contact:
21 
22  Robert J. Harrison
23  Oak Ridge National Laboratory
24  One Bethel Valley Road
25  P.O. Box 2008, MS-6367
26 
27  email: harrisonrj@ornl.gov
28  tel: 865-241-3937
29  fax: 865-572-0680
30 
31  $Id$
32 */
33 #ifndef __complex_fun__
34 #define __complex_fun__
35 
36 template <typename Q, int NDIM>
37 struct real_op
38 {
39  typedef typename TensorTypeData<Q>::scalar_type resultT;
40  Tensor<resultT> operator()(const Key<NDIM>& key, const Tensor<Q>& t) const
41  {
42  Tensor<resultT> result(t.ndim, t.dim);
43  BINARY_OPTIMIZED_ITERATOR(Q, t, resultT, result, *_p1 = real(*_p0););
44  return result;
45  }
46  template <typename Archive>
47  void serialize(Archive& ar) {}
48 };
49 
50 template<typename Q, int NDIM>
51 Function<typename TensorTypeData<Q>::scalar_type,NDIM> real(const Function<Q,NDIM>& func)
52 {
53  return unary_op_coeffs(func, real_op<Q,NDIM>());
54 }
55 
56 inline void ln(const Key<3> &key, Tensor<std::complex<double> > &t) {
57  UNARY_OPTIMIZED_ITERATOR(std::complex<double>, t,
58  *_p0 = log(*_p0));
59 }
60 
61 #endif
std::complex< double > func(int n, int t1, int t2, int t3, double xx, double yy, double zz)
Definition: wannier.cc:98
const mpreal log(const mpreal &v, mp_rnd_t rnd_mode)
Definition: mpreal.h:2213
void serialize(Archive &ar)
Definition: complex_fun.h:47
const int NDIM
Definition: tdse1.cc:44
Definition: complex_fun.h:37
void ln(const Key< 3 > &key, Tensor< std::complex< double > > &t)
Definition: complex_fun.h:56
#define BINARY_OPTIMIZED_ITERATOR(X, x, Y, y, exp)
Definition: tensor_macros.h:701
Function< typename TensorTypeData< Q >::scalar_type, NDIM > real(const Function< Q, NDIM > &func)
Definition: complex_fun.h:51
Function< typename opT::resultT, NDIM > unary_op_coeffs(const Function< Q, NDIM > &func, const opT &op, bool fence=true)
Out of place application of unary operation to scaling function coefficients with optional fence...
Definition: mra.h:1620
#define UNARY_OPTIMIZED_ITERATOR(X, x, exp)
Definition: tensor_macros.h:658
TensorTypeData< Q >::scalar_type resultT
Definition: complex_fun.h:39
Tensor< resultT > operator()(const Key< NDIM > &key, const Tensor< Q > &t) const
Definition: complex_fun.h:40