- Files adapted from other projects carry both licences: StrongPixelSet.cpp,
SpotExtractorGPU.cu and the four GEMMI-derived structure_refinement files
"GPL-3.0-only AND MPL-2.0"; FFBIDXIndexerCPU.cpp, LMSolver.{h,cpp} and
xds-plugin/plugin.* "GPL-3.0-only AND BSD-3-Clause"; fpga/hls/parallel_stream.h
"CERN-OHL-S-2.0 AND Apache-2.0"; fpga/hls/icmp.cpp and ip_header_checksum.h
(HPCN UAM, with PSI modifications) "CERN-OHL-S-2.0 AND BSD-3-Clause".
- writer/H5FDpoison_sec2.{c,h} and tests/enospc_shim.c: "OR HDF5" is not an
SPDX id; now "OR LicenseRef-HDF5", with the text named (licenses/hdf5.txt).
The poison driver wraps the stock sec2 driver rather than copying it (only
the H5FD_class_t initialiser layout matches H5FDsec2.c), so the files stay
dual-licensed (OR), not derived (AND).
- 151 first-party files without a tag (CMake, shell, Python, frontend, docs
JS, a few C++) get one: GPL-3.0-only, CERN-OHL-S-2.0 for fpga/, fpga/hls/
and fpga/scripts/, with the copyright line of the neighbouring files and the
year the file was added. Generated and vendored code is not touched;
fpga/pcie_driver/postinstall.sh and preuninstall.sh are left untagged, as
they say they are taken from a blog post.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK
38 lines
1002 B
C++
38 lines
1002 B
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
//
|
|
// Created by leonarski_f on 18.05.2026.
|
|
//
|
|
|
|
#include <cmath>
|
|
|
|
#include "CorrelationCoefficient.h"
|
|
|
|
void CorrelationCoefficient::Add(double x, double y, double w) {
|
|
sum_x += w * x;
|
|
sum_y += w * y;
|
|
sum_x2 += w * x * x;
|
|
sum_y2 += w * y * y;
|
|
sum_xy += w * x * y;
|
|
sum_w += w;
|
|
n_cc++;
|
|
}
|
|
|
|
double CorrelationCoefficient::GetCC() const {
|
|
if (n_cc < 2 || !(sum_w > 0.0))
|
|
return NAN;
|
|
const double n = sum_w;
|
|
const double mean_x = sum_x / n;
|
|
const double mean_y = sum_y / n;
|
|
|
|
const double cov = sum_xy / n - mean_x * mean_y;
|
|
const double var_x = sum_x2 / n - mean_x * mean_x;
|
|
const double var_y = sum_y2 / n - mean_y * mean_y;
|
|
|
|
if (!(var_x > 0.0 && var_y > 0.0))
|
|
return NAN;
|
|
|
|
return cov / std::sqrt(var_x * var_y);
|
|
}
|