ARTS
2.2.66
test_complex.cc
Go to the documentation of this file.
1
/* Copyright (C) 2002-2012 Stefan Buehler <sbuehler@ltu.se>
2
3
This program is free software; you can redistribute it and/or modify it
4
under the terms of the GNU General Public License as published by the
5
Free Software Foundation; either version 2, or (at your option) any
6
later version.
7
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
GNU General Public License for more details.
12
13
You should have received a copy of the GNU General Public License
14
along with this program; if not, write to the Free Software
15
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16
USA. */
17
26
#include <iostream>
27
#include "
complex.h
"
28
29
using
std::cout;
30
31
32
void
test01
()
33
{
34
Complex
a;
35
Complex
b (3., 0.);
36
37
//cout << "a = " << a << "\n";
38
cout <<
"b = "
<< b <<
"\n"
;
39
40
a = b;
41
cout <<
"a = "
<< a <<
"\n"
;
42
43
44
a =
Complex
(1., 1.);
45
cout <<
"a = "
<< a <<
"\n"
;
46
cout <<
"a.abs() = "
<<
abs
(a) <<
"\n"
;
47
cout <<
"a.arg()= "
<< arg (a)*57.2957914331333 <<
" degree"
<<
"\n"
;
48
49
50
Complex
c;
51
c = a + b;
52
cout <<
"c = "
<< c <<
"\n"
;
53
54
cout <<
"a += b: "
<< (a += b) <<
"\n"
;
55
56
cout <<
"c + 3 = "
<< (c + 3.) <<
"\n"
;
57
58
cout <<
"c + 3i = c + Complex (0,3) = "
<< (c +
Complex
(0., 3.)) <<
"\n"
;
59
60
Complex
d;
61
a =
Complex
(1., 1.);
62
b =
Complex
(-1., -1.);
63
d = a * b;
64
cout <<
"d = "
<< d <<
"\n"
;
65
Complex
e;
66
e = a / b;
67
cout <<
"e = "
<< e <<
"\n"
;
68
Complex
f;
69
f = pow(a,0)+pow(b,0);
70
cout <<
"f = "
<< f <<
"\n"
;
71
Complex
g;
72
g = pow(a,1)+pow(b,1);
73
cout <<
"g = "
<< g <<
"\n"
;
74
Complex
h;
75
h=pow(a,2)+pow(b,2)+pow(a,3)+pow(b,3);
76
cout <<
"h = "
<< h <<
"\n"
;
77
}
78
79
int
main
()
80
{
81
test01
();
82
return
0;
83
}
complex.h
A class implementing complex numbers for ARTS.
main
int main()
Definition:
test_complex.cc:79
Complex
std::complex< Numeric > Complex
Definition:
complex.h:32
abs
#define abs(x)
Definition:
continua.cc:20458
test01
void test01()
Definition:
test_complex.cc:32
arts-2.2
src
test_complex.cc
Generated on Wed Mar 18 2020 07:04:11 for ARTS by
1.8.13