MPS-Basic
Loading...
Searching...
No Matches
weight.cpp
Go to the documentation of this file.
1
#include "
weight.hpp
"
2
3
#include <cassert>
4
#include <iostream>
5
6
Weight::Weight
(
WeightType
weightType) {
7
this->weightType =
weightType
;
8
}
9
10
double
Weight::weightFn
(
double
dis,
double
re) {
11
assert(dis > 0.0);
12
13
if
(dis >= re) {
14
return
0.0;
15
}
else
{
16
if
(
weightType
==
WeightType::SemiImplicit
) {
17
return
(re / dis) - 1.0;
18
}
else
if
(
weightType
==
WeightType::Explicit
) {
19
return
(re / dis) + (dis / re) - 2.0;
20
}
else
if
(
weightType
==
WeightType::ExplicitGrad
) {
21
return
(re / dis) - (dis / re);
22
}
23
std::cerr <<
"ERROR: Unknown weight type."
<< std::endl;
24
std::exit(-1);
25
}
26
}
Weight::weightType
WeightType weightType
Definition
weight.hpp:17
Weight::weightFn
double weightFn(double dis, double re)
Weight function for MPS method.
Definition
weight.cpp:10
Weight::Weight
Weight()=default
weight.hpp
WeightType
WeightType
Definition
weight.hpp:5
WeightType::SemiImplicit
@ SemiImplicit
WeightType::Explicit
@ Explicit
WeightType::ExplicitGrad
@ ExplicitGrad
src
weight.cpp
Generated by
1.12.0