root/win32/itpp-4.0.1/itpp/base/math/error.h @ 35

Revision 35, 3.8 kB (checked in by mido, 16 years ago)

zasadni zmeny ve /win32

RevLine 
[35]1/*!
2 * \file
3 * \brief Error functions - header file
4 * \author Tony Ottosson and Adam Piatyszek
5 *
6 * -------------------------------------------------------------------------
7 *
8 * IT++ - C++ library of mathematical, signal processing, speech processing,
9 *        and communications classes and functions
10 *
11 * Copyright (C) 1995-2007  (see AUTHORS file for a list of contributors)
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 *
27 * -------------------------------------------------------------------------
28 */
29
30#ifndef ERROR_H
31#define ERROR_H
32
33#ifndef _MSC_VER
34#  include <itpp/config.h>
35#else
36#  include <itpp/config_msvc.h>
37#endif
38
39#include <itpp/base/help_functions.h>
40
41
42//!\addtogroup errorfunc
43//!@{
44
45#ifndef HAVE_ERF
46//! \brief Error function
47double erf(double x);
48#endif
49
50#ifndef HAVE_ERFC
51//! Complementary error function
52double erfc(double x);
53#endif
54
55//!@}
56
57
58namespace itpp {
59
60  //!\addtogroup errorfunc
61  //!@{
62
63  /*!
64   * \brief Error function for complex argument
65   * \author Adam Piatyszek
66   *
67   * This function calculates a well known error function \c erf(z)
68   * for complex \c z. The implementation is based on unofficial
69   * implementation for Octave. Here is a part of the author's note
70   * from original sources:
71   *
72   * Put together by John Smith john at arrows dot demon dot co dot uk,
73   * using ideas by others.
74   *
75   * Calculate \c erf(z) for complex \c z.
76   * Three methods are implemented; which one is used depends on z.
77   *
78   * The code includes some hard coded constants that are intended to
79   * give about 14 decimal places of accuracy. This is appropriate for
80   * 64-bit floating point numbers.
81   */
82  std::complex<double> erf(const std::complex<double>& z);
83
84  //! Inverse of error function
85  double erfinv(double x);
86
87  //! Q-function
88  double Qfunc(double x);
89
90
91  // ----------------------------------------------------------------------
92  // functions for matrices and vectors
93  // ----------------------------------------------------------------------
94
95  //! Error function
96  inline vec erf(const vec &x)
97  {
98    return apply_function<double>(::erf, x);
99  }
100  //! Error function
101  inline mat erf(const mat &x)
102  {
103    return apply_function<double>(::erf, x);
104  }
105  //! Error function
106  inline cvec erf(const cvec &x)
107  {
108    return apply_function<std::complex<double> >(erf, x);
109  }
110  //! Error function
111  inline cmat erf(const cmat &x)
112  {
113    return apply_function<std::complex<double> >(erf, x);
114  }
115
116  //! Inverse of error function
117  inline vec erfinv(const vec &x)
118  {
119    return apply_function<double>(erfinv, x);
120  }
121  //! Inverse of error function
122  inline mat erfinv(const mat &x)
123  {
124    return apply_function<double>(erfinv, x);
125  }
126
127  //! Complementary error function
128  inline vec erfc(const vec &x)
129  {
130    return apply_function<double>(::erfc, x);
131  }
132  //! Complementary error function
133  inline mat erfc(const mat &x)
134  {
135    return apply_function<double>(::erfc, x);
136  }
137
138  //! Q-function
139  inline vec Qfunc(const vec &x)
140  {
141    return apply_function<double>(Qfunc, x);
142  }
143
144  //! Q-function
145  inline mat Qfunc(const mat &x)
146  {
147    return apply_function<double>(Qfunc, x);
148  }
149  //!@}
150
151} // namespace itpp
152
153#endif // #ifndef ERROR_H
154
155
156
Note: See TracBrowser for help on using the browser.