Repository navigation
Expand file tree
/
Copy pathdiag_const_nums.cpp
More file actions
56 lines (50 loc) · 2.29 KB
/
Copy pathdiag_const_nums.cpp
File metadata and controls
56 lines (50 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "diag_const_nums.h"
#include <complex>
template class const_nums<double>;
template class const_nums<float>;
template class const_nums<std::complex<double>>;
template class const_nums<std::complex<float>>;
// Specialize templates to support double types
template <>
const_nums<double>::const_nums()
{
base_device::memory::resize_memory_op<double, base_device::DEVICE_CPU>()(this->zero, 1);
this->zero[0] = 0.0;
base_device::memory::resize_memory_op<double, base_device::DEVICE_CPU>()(this->one, 1);
this->one[0] = 1.0;
base_device::memory::resize_memory_op<double, base_device::DEVICE_CPU>()(this->neg_one, 1);
this->neg_one[0] = -1.0;
}
// Specialize templates to support double types
template <>
const_nums<float>::const_nums()
{
base_device::memory::resize_memory_op<float, base_device::DEVICE_CPU>()(this->zero, 1);
this->zero[0] = 0.0;
base_device::memory::resize_memory_op<float, base_device::DEVICE_CPU>()(this->one, 1);
this->one[0] = 1.0;
base_device::memory::resize_memory_op<float, base_device::DEVICE_CPU>()(this->neg_one, 1);
this->neg_one[0] = -1.0;
}
// Specialized templates to support std:: std::complex<double>types
template <>
const_nums<std::complex<double>>::const_nums()
{
base_device::memory::resize_memory_op<std::complex<double>, base_device::DEVICE_CPU>()(this->zero, 1);
this->zero[0] = std::complex<double>(0.0, 0.0);
base_device::memory::resize_memory_op<std::complex<double>, base_device::DEVICE_CPU>()(this->one, 1);
this->one[0] = std::complex<double>(1.0, 0.0);
base_device::memory::resize_memory_op<std::complex<double>, base_device::DEVICE_CPU>()(this->neg_one, 1);
this->neg_one[0] = std::complex<double>(-1.0, 0.0);
}
// Specialized templates to support std:: complex<float>types
template <>
const_nums<std::complex<float>>::const_nums()
{
base_device::memory::resize_memory_op<std::complex<float>, base_device::DEVICE_CPU>()(this->zero, 1);
this->zero[0] = std::complex<float>(0.0, 0.0);
base_device::memory::resize_memory_op<std::complex<float>, base_device::DEVICE_CPU>()(this->one, 1);
this->one[0] = std::complex<float>(1.0, 0.0);
base_device::memory::resize_memory_op<std::complex<float>, base_device::DEVICE_CPU>()(this->neg_one, 1);
this->neg_one[0] = std::complex<float>(-1.0, 0.0);
}