Gemmi C++ API
Loading...
Searching...
No Matches
addends.hpp
Go to the documentation of this file.
1// Copyright 2020 Global Phasing Ltd.
2//
3// Addends to scattering form factors used in DensityCalculator
4// and in StructureFactorCalculator.
5
6#ifndef GEMMI_ADDENDS_HPP_
7#define GEMMI_ADDENDS_HPP_
8
9#include <array>
10#include "elem.hpp" // for El, Element
11
12namespace gemmi {
13
14struct Addends {
15 std::array<float, (int)El::END> values = {};
16
17 void set(Element el, float val) { values[el.ordinal()] = val; }
18 float get(Element el) const { return values[el.ordinal()]; }
19 size_t size() const { return values.size(); }
20 void clear() {
21 for (size_t i = 0; i != size(); ++i)
22 values[i] = 0.;
23 }
24 void subtract_z(bool except_hydrogen=false) {
25 for (int z = 2; z < (int)El::D; ++z)
26 values[z] -= z;
27 if (!except_hydrogen) {
28 values[(int)El::H] -= 1;
29 values[(int)El::D] -= 1;
30 }
31 }
32};
33
34} // namespace gemmi
35#endif
size_t size() const
Definition addends.hpp:19
std::array< float,(int) El::END > values
Definition addends.hpp:15
float get(Element el) const
Definition addends.hpp:18
void set(Element el, float val)
Definition addends.hpp:17
void subtract_z(bool except_hydrogen=false)
Definition addends.hpp:24
int ordinal() const
Definition elem.hpp:301