votca 2024.2-dev
Loading...
Searching...
No Matches
correlate.cc
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
3 *
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16
17// Local VOTCA includes
19#include "votca/tools/eigen.h"
20
21namespace votca {
22namespace tools {
23
25 Index N = Index(data[0].size());
26 double Nd = (double)N;
27 Eigen::Map<Eigen::ArrayXd> m0(data[0].data(), N);
28 double xm = m0.sum();
29 xm /= Nd;
30 double xsq = m0.abs2().sum();
31
32 for (Index v = 1; v < data.size(); v++) {
33 Eigen::Map<Eigen::ArrayXd> m_v(data[v].data(), N);
34 double ym = m_v.sum();
35 double ysq = m_v.abs2().sum();
36 double p = (m_v * m0).sum();
37 ym /= Nd;
38 double norm = std::sqrt((xsq - Nd * xm * xm) * (ysq - Nd * ym * ym));
39 p = (p - Nd * xm * ym) / norm;
40 corr_.push_back(p);
41 }
42}
43
44} // namespace tools
45} // namespace votca
std::vector< double > corr_
Definition correlate.h:50
void CalcCorrelations(DataCollection< double >::selection &data)
Definition correlate.cc:24
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26