PLaSK library
Toggle main menu visibility
Main Page
Topics
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
ζ
ξ
φ
Functions
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
v
w
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
ζ
ξ
φ
Typedefs
a
c
d
e
f
i
l
m
o
p
r
s
t
u
x
Enumerations
Enumerator
_
a
b
c
e
f
i
l
m
o
p
r
s
t
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
v
w
Enumerations
a
b
c
d
e
f
i
k
m
n
p
r
s
t
w
Enumerator
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
y
z
Properties
o
Related Symbols
a
b
d
e
f
g
l
m
n
o
p
r
s
t
w
Files
File List
File Members
All
_
a
b
c
d
e
f
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
z
Functions
a
b
c
d
e
f
i
k
m
r
s
t
w
x
z
Variables
Typedefs
a
c
d
e
f
h
i
j
k
l
m
n
r
s
u
v
x
z
Enumerations
Enumerator
Macros
_
a
b
c
d
e
f
l
m
n
o
p
r
s
t
u
v
w
x
z
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
math.cpp
Go to the documentation of this file.
1
/*
2
* This file is part of PLaSK (https://plask.app) by Photonics Group at TUL
3
* Copyright (c) 2022 Lodz University of Technology
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, version 3.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*/
14
#include "
math.hpp
"
15
16
namespace
plask
{
17
18
template
std::complex<double>
parse_complex<double>
(std::string
str_to_parse
);
19
20
AccurateSum
&
AccurateSum::operator=
(
double
v
) {
21
s =
v
;
22
c = 0.0;
23
return
*
this
;
24
}
20
AccurateSum
&
AccurateSum::operator=
(
double
v
) {
…
}
25
26
//Kahan and Babuska summation, Neumaier variant.
27
//(better than Kahan method? https://github.com/JuliaLang/julia/issues/199)
28
/*AccurateSum& AccurateSum::operator+=(double v) {
29
const double t = s + v;
30
if (std::abs(s) >= std::abs(v))
31
c += (s - t) + v;
32
else
33
c += (v - t) + s;
34
s = t;
35
return *this;
36
}
37
38
operator double() const { return s + c; }
39
40
AccurateSum& AccurateSum::operator+=(const AccurateSum& other) {
41
*this += other.s;
42
*this += other.c;
43
return *this;
44
}*/
45
46
AccurateSum
&
AccurateSum::operator+=
(
const
AccurateSum
&other) {
47
*
this
+= -other.c;
48
*
this
+= other.s;
49
return
*
this
;
50
}
46
AccurateSum
&
AccurateSum::operator+=
(
const
AccurateSum
&other) {
…
}
51
52
AccurateSum
&
AccurateSum::operator+=
(
double
v
) {
53
const
double
y =
v
- c;
// compensed value to add
54
const
double
news
= s + y;
// new sum
55
c = (
news
- s) - y;
// news is to hight by c (algebraically, c should always be zero, typically c is negative)
56
s =
news
;
// we will substract c from sum next time
57
return
*
this
;
58
}
52
AccurateSum
&
AccurateSum::operator+=
(
double
v
) {
…
}
59
60
}
// namespace plask
plask
math.cpp
Generated by
1.9.8