laddu_amplitudes/kmatrix/
f2.rs

1use super::FixedKMatrix;
2use laddu_core::{
3    amplitudes::{Amplitude, AmplitudeID, ParameterLike},
4    data::Event,
5    resources::{Cache, ComplexVectorID, MatrixID, ParameterID, Parameters, Resources},
6    utils::variables::{Mass, Variable},
7    Float, LadduError,
8};
9#[cfg(feature = "python")]
10use laddu_python::{
11    amplitudes::{PyAmplitude, PyParameterLike},
12    utils::variables::PyMass,
13};
14use nalgebra::{matrix, vector, DVector, SMatrix, SVector};
15use num::Complex;
16#[cfg(feature = "python")]
17use pyo3::prelude::*;
18use serde::{Deserialize, Serialize};
19use std::array;
20
21const G_F2: SMatrix<Float, 4, 4> = matrix![
22     0.40033,  0.01820, -0.06709, -0.49924;
23     0.15479,  0.17300,  0.22941,  0.19295;
24    -0.08900,  0.32393, -0.43133,  0.27975;
25    -0.00113,  0.15256,  0.23721, -0.03987
26];
27
28const C_F2: SMatrix<Float, 4, 4> = matrix![
29    -0.04319,  0.00000,  0.00984,  0.01028;
30     0.00000,  0.00000,  0.00000,  0.00000;
31     0.00984,  0.00000, -0.07344,  0.05533;
32     0.01028,  0.00000,  0.05533, -0.05183
33];
34
35const M_F2: SVector<Float, 4> = vector![1.15299, 1.48359, 1.72923, 1.96700];
36
37const COV_F2: SMatrix<Float, 36, 36> = matrix![
38    0.00000000000000, -0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00000000000000, 0.00000000000000, -0.00000000000000, 0.00000000000000, -0.00000000000000, 0.00000000000000, -0.00000000000000, 0.00000000000000, -0.00000000000000, -0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00000000000000, -0.00000000000000, 0.00000000000000, -0.00000000000000, 0.00000000000000;
39    -0.00000000000000, 0.00000000000001, 0.00000000022965, 0.00000000000000, -0.00000000001878, -0.00000000000016, -0.00000000065337, 0.00000000000000, 0.00000000000000, -0.00000000003574, 0.00000000091495, 0.00000000000000, -0.00000000001447, -0.00000000032942, -0.00000000086530, 0.00000000000000, -0.00000000000433, 0.00000000000000, -0.00000000001051, -0.00000000002961, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00000000000283, -0.00000000007379, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000005678, 0.00000000000248, 0.00000000002691, -0.00000000020470, 0.00000000000000;
40    0.00000000000000, 0.00000000022965, 0.00020810475177, 0.00000000000000, -0.00002017796231, 0.00000000778406, -0.00048546523204, 0.00000000000000, -0.00000000000630, 0.00010221652645, 0.00051663367454, 0.00000000000000, -0.00000509806086, -0.00015222017267, -0.00112613397259, 0.00000000000000, 0.00000135971725, 0.00000000000000, 0.00000080623080, -0.00001338578863, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00000617047714, -0.00000991268602, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00001724685959, 0.00000287435535, -0.00001001652618, -0.00007549764696, 0.00000000000000;
41    0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000;
42    -0.00000000000000, -0.00000000001878, -0.00002017796231, 0.00000000000000, 0.00000525722489, 0.00000000347535, 0.00007350861954, 0.00000000000000, 0.00000000001396, -0.00002021695069, -0.00006160939975, 0.00000000000000, 0.00000023103828, 0.00002452125562, 0.00012137914521, 0.00000000000000, -0.00000025962545, 0.00000000000000, 0.00000097175304, 0.00000183615384, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000295694459, 0.00000421294651, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00000803261003, -0.00000065823199, 0.00000349837417, -0.00000336314015, 0.00000000000000;
43    0.00000000000000, -0.00000000000016, 0.00000000778406, 0.00000000000000, 0.00000000347535, 0.00000000389489, -0.00000000990126, 0.00000000000000, 0.00000000000001, 0.00000004424962, 0.00000015369780, 0.00000000000000, -0.00000001127840, 0.00000005605393, -0.00000013259646, 0.00000000000000, -0.00000000001938, 0.00000000000000, -0.00000001160782, -0.00000000341675, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000012073237, -0.00000001929218, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00000001941485, -0.00000000143073, -0.00000006552572, -0.00000002253226, 0.00000000000000;
44    -0.00000000000000, -0.00000000065337, -0.00048546523204, 0.00000000000000, 0.00007350861954, -0.00000000990126, 0.00160693804884, 0.00000000000000, 0.00000000000716, -0.00032239627461, -0.00146564294012, 0.00000000000000, -0.00001091407346, 0.00060953662553, 0.00271778119791, 0.00000000000000, -0.00000458707014, 0.00000000000000, 0.00002420661713, 0.00003157138911, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00006172454915, 0.00003742551790, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00004481679431, -0.00000990554723, 0.00005210207785, -0.00002914750198, 0.00000000000000;
45    0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000;
46    -0.00000000000000, 0.00000000000000, -0.00000000000630, 0.00000000000000, 0.00000000001396, 0.00000000000001, 0.00000000000716, 0.00000000000000, 0.00000000000001, -0.00000000015266, 0.00000000068388, 0.00000000000000, -0.00000000002020, 0.00000000021413, 0.00000000047953, 0.00000000000000, -0.00000000000229, 0.00000000000000, 0.00000000000701, -0.00000000004114, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000390, 0.00000000002973, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00000000013896, -0.00000000000119, 0.00000000007601, 0.00000000016843, 0.00000000000000;
47    0.00000000000000, -0.00000000003574, 0.00010221652645, 0.00000000000000, -0.00002021695069, 0.00000004424962, -0.00032239627461, 0.00000000000000, -0.00000000015266, 0.00027348566347, 0.00027881566888, 0.00000000000000, -0.00000585835284, -0.00011191586495, -0.00054183174648, 0.00000000000000, 0.00000178367809, 0.00000000000000, -0.00000880807311, -0.00000212815472, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000173087260, -0.00001543868374, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00005245267478, 0.00000250597329, -0.00003534471579, -0.00001401703507, 0.00000000000000;
48    -0.00000000000000, 0.00000000091495, 0.00051663367454, 0.00000000000000, -0.00006160939975, 0.00000015369780, -0.00146564294012, 0.00000000000000, 0.00000000068388, 0.00027881566888, 0.00276953127748, 0.00000000000000, -0.00006133405257, -0.00070912629842, -0.00242022766908, 0.00000000000000, 0.00000245425082, 0.00000000000000, -0.00002889424830, -0.00009148385754, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00006190803960, -0.00014333356119, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00007320581453, 0.00000917563104, 0.00005504920575, 0.00012387354261, 0.00000000000000;
49    0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000;
50    -0.00000000000000, -0.00000000001447, -0.00000509806086, 0.00000000000000, 0.00000023103828, -0.00000001127840, -0.00001091407346, 0.00000000000000, -0.00000000002020, -0.00000585835284, -0.00006133405257, 0.00000000000000, 0.00001487107091, 0.00003279810089, 0.00000992667858, 0.00000000000000, -0.00000037239227, 0.00000000000000, 0.00000032079537, 0.00000836864671, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000004861005, 0.00001466955130, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00002455088013, -0.00000001487073, -0.00000343475307, -0.00001044704032, 0.00000000000000;
51    -0.00000000000000, -0.00000000032942, -0.00015222017267, 0.00000000000000, 0.00002452125562, 0.00000005605393, 0.00060953662553, 0.00000000000000, 0.00000000021413, -0.00011191586495, -0.00070912629842, 0.00000000000000, 0.00003279810089, 0.00079820504834, 0.00104020065646, 0.00000000000000, -0.00000231617382, 0.00000000000000, 0.00002397953873, 0.00002737632607, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00012757590469, 0.00004824700869, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00001309788555, -0.00000368941509, 0.00002244357219, -0.00016023613815, 0.00000000000000;
52    0.00000000000000, -0.00000000086530, -0.00112613397259, 0.00000000000000, 0.00012137914521, -0.00000013259646, 0.00271778119791, 0.00000000000000, 0.00000000047953, -0.00054183174648, -0.00242022766908, 0.00000000000000, 0.00000992667858, 0.00104020065646, 0.00767507299236, 0.00000000000000, -0.00000515543606, 0.00000000000000, -0.00001664001856, 0.00007656613893, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00006180921638, 0.00004133504962, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00000471840482, -0.00001687638765, 0.00009376741583, 0.00016545659203, 0.00000000000000;
53    0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000;
54    0.00000000000000, -0.00000000000433, 0.00000135971725, 0.00000000000000, -0.00000025962545, -0.00000000001938, -0.00000458707014, 0.00000000000000, -0.00000000000229, 0.00000178367809, 0.00000245425082, 0.00000000000000, -0.00000037239227, -0.00000231617382, -0.00000515543606, 0.00000000000000, 0.00000023456698, 0.00000000000000, -0.00000018331318, -0.00000020703744, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00000035651349, -0.00000079138986, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00000001316365, 0.00000004440982, -0.00000070831155, 0.00000039952137, 0.00000000000000;
55    0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000;
56    0.00000000000000, -0.00000000001051, 0.00000080623080, 0.00000000000000, 0.00000097175304, -0.00000001160782, 0.00002420661713, 0.00000000000000, 0.00000000000701, -0.00000880807311, -0.00002889424830, 0.00000000000000, 0.00000032079537, 0.00002397953873, -0.00001664001856, 0.00000000000000, -0.00000018331318, 0.00000000000000, 0.00000360123320, 0.00000026629523, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000537738382, 0.00000482723936, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00000093100664, -0.00000012553906, 0.00000408193142, -0.00000637292890, 0.00000000000000;
57    0.00000000000000, -0.00000000002961, -0.00001338578863, 0.00000000000000, 0.00000183615384, -0.00000000341675, 0.00003157138911, 0.00000000000000, -0.00000000004114, -0.00000212815472, -0.00009148385754, 0.00000000000000, 0.00000836864671, 0.00002737632607, 0.00007656613893, 0.00000000000000, -0.00000020703744, 0.00000000000000, 0.00000026629523, 0.00000858580230, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000732995476, 0.00001074373530, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00000874436468, -0.00000027168487, -0.00000506193615, -0.00002351900788, 0.00000000000000;
58    0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000;
59    0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000;
60    0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000;
61    0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000;
62    0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000;
63    0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000;
64    0.00000000000000, -0.00000000000283, -0.00000617047714, 0.00000000000000, 0.00000295694459, 0.00000012073237, 0.00006172454915, 0.00000000000000, 0.00000000000390, 0.00000173087260, -0.00006190803960, 0.00000000000000, 0.00000004861005, 0.00012757590469, 0.00006180921638, 0.00000000000000, -0.00000035651349, 0.00000000000000, 0.00000537738382, 0.00000732995476, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00013805207149, -0.00001502499066, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00001099054675, -0.00000096634621, -0.00000784965922, 0.00000128742195, 0.00000000000000;
65    0.00000000000000, -0.00000000007379, -0.00000991268602, 0.00000000000000, 0.00000421294651, -0.00000001929218, 0.00003742551790, 0.00000000000000, 0.00000000002973, -0.00001543868374, -0.00014333356119, 0.00000000000000, 0.00001466955130, 0.00004824700869, 0.00004133504962, 0.00000000000000, -0.00000079138986, 0.00000000000000, 0.00000482723936, 0.00001074373530, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00001502499066, 0.00005785344938, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00008000514946, -0.00000041743220, -0.00000516000944, -0.00001686519773, 0.00000000000000;
66    0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000;
67    0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000;
68    0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000;
69    -0.00000000000000, 0.00000000005678, 0.00001724685959, 0.00000000000000, -0.00000803261003, -0.00000001941485, 0.00004481679431, 0.00000000000000, -0.00000000013896, 0.00005245267478, 0.00007320581453, 0.00000000000000, -0.00002455088013, -0.00001309788555, -0.00000471840482, 0.00000000000000, -0.00000001316365, 0.00000000000000, -0.00000093100664, -0.00000874436468, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00001099054675, -0.00008000514946, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00028674728271, 0.00000066210435, -0.00000357698028, -0.00009025993466, 0.00000000000000;
70    -0.00000000000000, 0.00000000000248, 0.00000287435535, 0.00000000000000, -0.00000065823199, -0.00000000143073, -0.00000990554723, 0.00000000000000, -0.00000000000119, 0.00000250597329, 0.00000917563104, 0.00000000000000, -0.00000001487073, -0.00000368941509, -0.00001687638765, 0.00000000000000, 0.00000004440982, 0.00000000000000, -0.00000012553906, -0.00000027168487, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00000096634621, -0.00000041743220, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000066210435, 0.00000008824672, -0.00000030577689, 0.00000030910338, 0.00000000000000;
71    0.00000000000000, 0.00000000002691, -0.00001001652618, 0.00000000000000, 0.00000349837417, -0.00000006552572, 0.00005210207785, 0.00000000000000, 0.00000000007601, -0.00003534471579, 0.00005504920575, 0.00000000000000, -0.00000343475307, 0.00002244357219, 0.00009376741583, 0.00000000000000, -0.00000070831155, 0.00000000000000, 0.00000408193142, -0.00000506193615, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00000784965922, -0.00000516000944, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00000357698028, -0.00000030577689, 0.00003443338248, 0.00001741704563, 0.00000000000000;
72    -0.00000000000000, -0.00000000020470, -0.00007549764696, 0.00000000000000, -0.00000336314015, -0.00000002253226, -0.00002914750198, 0.00000000000000, 0.00000000016843, -0.00001401703507, 0.00012387354261, 0.00000000000000, -0.00001044704032, -0.00016023613815, 0.00016545659203, 0.00000000000000, 0.00000039952137, 0.00000000000000, -0.00000637292890, -0.00002351900788, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000128742195, -0.00001686519773, 0.00000000000000, 0.00000000000000, 0.00000000000000, -0.00009025993466, 0.00000030910338, 0.00001741704563, 0.00046175356447, 0.00000000000000;
73    0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000, 0.00000000000000;
74];
75
76/// A K-matrix parameterization for $`f_2`$ particles described by Kopf et al.[^1] with fixed couplings and mass poles
77/// (free production couplings only).
78///
79/// [^1]: Kopf, B., Albrecht, M., Koch, H., Küßner, M., Pychy, J., Qin, X., & Wiedner, U. (2021). Investigation of the lightest hybrid meson candidate with a coupled-channel analysis of $`\bar{p}p`$-, $`\pi^- p`$- and $`\pi \pi`$-Data. The European Physical Journal C, 81(12). [doi:10.1140/epjc/s10052-021-09821-2](https://doi.org/10.1140/epjc/s10052-021-09821-2)
80#[derive(Clone, Serialize, Deserialize)]
81pub struct KopfKMatrixF2 {
82    name: String,
83    channel: usize,
84    mass: Mass,
85    constants: FixedKMatrix<4, 4>,
86    couplings_real: [ParameterLike; 4],
87    couplings_imag: [ParameterLike; 4],
88    couplings_indices_real: [ParameterID; 4],
89    couplings_indices_imag: [ParameterID; 4],
90    ikc_cache_index: ComplexVectorID<4>,
91    p_vec_cache_index: MatrixID<4, 4>,
92}
93
94impl KopfKMatrixF2 {
95    /// Construct a new [`KopfKMatrixF2`] with the given name, production couplings, channel,
96    /// and input mass.
97    ///
98    /// | Channel index | Channel |
99    /// | ------------- | ------- |
100    /// | 0             | $`\pi\pi`$ |
101    /// | 1             | $`2\pi 2\pi`$ |
102    /// | 2             | $`K\bar{K}`$ |
103    /// | 3             | $`\eta\eta`$ |
104    ///
105    /// | Pole names |
106    /// | ---------- |
107    /// | $`f_2(1270)`$ |
108    /// | $`f_2'(1525)`$ |
109    /// | $`f_2(1810)`$ |
110    /// | $`f_2(1950)`$ |
111    pub fn new(
112        name: &str,
113        couplings: [[ParameterLike; 2]; 4],
114        channel: usize,
115        mass: &Mass,
116        seed: Option<usize>,
117    ) -> Box<Self> {
118        let mut couplings_real: [ParameterLike; 4] = array::from_fn(|_| ParameterLike::default());
119        let mut couplings_imag: [ParameterLike; 4] = array::from_fn(|_| ParameterLike::default());
120        for i in 0..4 {
121            couplings_real[i] = couplings[i][0].clone();
122            couplings_imag[i] = couplings[i][1].clone();
123        }
124        Self {
125            name: name.to_string(),
126            channel,
127            mass: mass.clone(),
128            constants: FixedKMatrix::new(
129                G_F2,
130                C_F2,
131                vector![0.1349768, 2.0 * 0.1349768, 0.493677, 0.547862],
132                vector![0.1349768, 2.0 * 0.1349768, 0.497611, 0.547862],
133                M_F2,
134                None,
135                2,
136                COV_F2,
137                seed,
138            ),
139            couplings_real,
140            couplings_imag,
141            couplings_indices_real: [ParameterID::default(); 4],
142            couplings_indices_imag: [ParameterID::default(); 4],
143            ikc_cache_index: ComplexVectorID::default(),
144            p_vec_cache_index: MatrixID::default(),
145        }
146        .into()
147    }
148}
149
150#[typetag::serde]
151impl Amplitude for KopfKMatrixF2 {
152    fn register(&mut self, resources: &mut Resources) -> Result<AmplitudeID, LadduError> {
153        for i in 0..self.couplings_indices_real.len() {
154            self.couplings_indices_real[i] = resources.register_parameter(&self.couplings_real[i]);
155            self.couplings_indices_imag[i] = resources.register_parameter(&self.couplings_imag[i]);
156        }
157        self.ikc_cache_index = resources
158            .register_complex_vector(Some(&format!("KopfKMatrixF2<{}> ikc_vec", self.name)));
159        self.p_vec_cache_index =
160            resources.register_matrix(Some(&format!("KopfKMatrixF2<{}> p_vec", self.name)));
161        resources.register_amplitude(&self.name)
162    }
163
164    fn precompute(&self, event: &Event, cache: &mut Cache) {
165        let s = self.mass.value(event).powi(2);
166        cache.store_complex_vector(
167            self.ikc_cache_index,
168            self.constants.ikc_inv_vec(s, self.channel),
169        );
170        cache.store_matrix(self.p_vec_cache_index, self.constants.p_vec_constants(s));
171    }
172
173    fn compute(&self, parameters: &Parameters, _event: &Event, cache: &Cache) -> Complex<Float> {
174        let betas = SVector::from_fn(|i, _| {
175            Complex::new(
176                parameters.get(self.couplings_indices_real[i]),
177                parameters.get(self.couplings_indices_imag[i]),
178            )
179        });
180        let ikc_inv_vec = cache.get_complex_vector(self.ikc_cache_index);
181        let p_vec_constants = cache.get_matrix(self.p_vec_cache_index);
182        FixedKMatrix::compute(&betas, &ikc_inv_vec, &p_vec_constants)
183    }
184
185    fn compute_gradient(
186        &self,
187        _parameters: &Parameters,
188        _event: &Event,
189        cache: &Cache,
190        gradient: &mut DVector<Complex<Float>>,
191    ) {
192        let ikc_inv_vec = cache.get_complex_vector(self.ikc_cache_index);
193        let p_vec_constants = cache.get_matrix(self.p_vec_cache_index);
194        let internal_gradient = FixedKMatrix::compute_gradient(&ikc_inv_vec, &p_vec_constants);
195        for i in 0..4 {
196            if let ParameterID::Parameter(index) = self.couplings_indices_real[i] {
197                gradient[index] = internal_gradient[i];
198            }
199            if let ParameterID::Parameter(index) = self.couplings_indices_imag[i] {
200                gradient[index] = Complex::<Float>::I * internal_gradient[i];
201            }
202        }
203    }
204}
205
206/// A fixed K-Matrix Amplitude for :math:`f_2` mesons
207///
208/// Parameters
209/// ----------
210/// name : str
211///     The Amplitude name
212/// couplings : list of list of laddu.ParameterLike
213///     Each initial-state coupling (as a list of pairs of real and imaginary parts)
214/// channel : int
215///     The channel onto which the K-Matrix is projected
216/// mass: laddu.Mass
217///     The total mass of the resonance
218/// seed: int, optional
219///     Seed used to resample fixed K-matrix components according to their covariance
220///     No resampling is done if seed is None
221///
222/// Returns
223/// -------
224/// laddu.Amplitude
225///     An Amplitude which can be registered by a laddu.Manager
226///
227/// See Also
228/// --------
229/// laddu.Manager
230///
231/// Notes
232/// -----
233/// This Amplitude follows the prescription of [Kopf]_ and fixes the K-Matrix to data
234/// from that paper, leaving the couplings to the initial state free
235///
236/// +---------------+-------------------+
237/// | Channel index | Channel           |
238/// +===============+===================+
239/// | 0             | :math:`\pi\pi`    |
240/// +---------------+-------------------+
241/// | 1             | :math:`2\pi 2\pi` |
242/// +---------------+-------------------+
243/// | 2             | :math:`K\bar{K}`  |
244/// +---------------+-------------------+
245/// | 3             | :math:`\eta\eta`  |
246/// +---------------+-------------------+
247///
248/// +---------------------+
249/// | Pole names          |
250/// +=====================+
251/// | :math:`f_2(1270)`   |
252/// +---------------------+
253/// | :math:`f_2'(1525)`  |
254/// +---------------------+
255/// | :math:`f_2(1810)`   |
256/// +---------------------+
257/// | :math:`f_2(1950)`   |
258/// +---------------------+
259///
260#[cfg(feature = "python")]
261#[pyfunction(name = "KopfKMatrixF2", signature = (name, couplings, channel, mass, seed = None))]
262pub fn py_kopf_kmatrix_f2(
263    name: &str,
264    couplings: [[PyParameterLike; 2]; 4],
265    channel: usize,
266    mass: PyMass,
267    seed: Option<usize>,
268) -> PyAmplitude {
269    PyAmplitude(KopfKMatrixF2::new(
270        name,
271        array::from_fn(|i| array::from_fn(|j| couplings[i][j].clone().0)),
272        channel,
273        &mass.0,
274        seed,
275    ))
276}
277
278#[cfg(test)]
279mod tests {
280    // Note: These tests are not exhaustive, they only check one channel
281    use std::sync::Arc;
282
283    use super::*;
284    use approx::assert_relative_eq;
285    use laddu_core::{data::test_dataset, parameter, Manager, Mass};
286    #[test]
287    fn test_f2_evaluation() {
288        let mut manager = Manager::default();
289        let res_mass = Mass::new([2, 3]);
290        let amp = KopfKMatrixF2::new(
291            "f2",
292            [
293                [parameter("p0"), parameter("p1")],
294                [parameter("p2"), parameter("p3")],
295                [parameter("p4"), parameter("p5")],
296                [parameter("p6"), parameter("p7")],
297            ],
298            1,
299            &res_mass,
300            None,
301        );
302        let aid = manager.register(amp).unwrap();
303
304        let dataset = Arc::new(test_dataset());
305        let expr = aid.into();
306        let model = manager.model(&expr);
307        let evaluator = model.load(&dataset);
308
309        let result = evaluator.evaluate(&[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]);
310
311        assert_relative_eq!(result[0].re, 0.02523304, epsilon = Float::EPSILON.sqrt());
312        assert_relative_eq!(result[0].im, 0.39712393, epsilon = Float::EPSILON.sqrt());
313    }
314
315    #[test]
316    fn test_f2_gradient() {
317        let mut manager = Manager::default();
318        let res_mass = Mass::new([2, 3]);
319        let amp = KopfKMatrixF2::new(
320            "f2",
321            [
322                [parameter("p0"), parameter("p1")],
323                [parameter("p2"), parameter("p3")],
324                [parameter("p4"), parameter("p5")],
325                [parameter("p6"), parameter("p7")],
326            ],
327            1,
328            &res_mass,
329            None,
330        );
331        let aid = manager.register(amp).unwrap();
332
333        let dataset = Arc::new(test_dataset());
334        let expr = aid.into();
335        let model = manager.model(&expr);
336        let evaluator = model.load(&dataset);
337
338        let result = evaluator.evaluate_gradient(&[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]);
339
340        assert_relative_eq!(result[0][0].re, -0.3078948, epsilon = Float::EPSILON.cbrt());
341        assert_relative_eq!(result[0][0].im, 0.3808689, epsilon = Float::EPSILON.cbrt());
342        assert_relative_eq!(result[0][1].re, -result[0][0].im);
343        assert_relative_eq!(result[0][1].im, result[0][0].re);
344        assert_relative_eq!(result[0][2].re, 0.4290085, epsilon = Float::EPSILON.cbrt());
345        assert_relative_eq!(result[0][2].im, 0.0799660, epsilon = Float::EPSILON.cbrt());
346        assert_relative_eq!(result[0][3].re, -result[0][2].im);
347        assert_relative_eq!(result[0][3].im, result[0][2].re);
348        assert_relative_eq!(result[0][4].re, 0.1657487, epsilon = Float::EPSILON.cbrt());
349        assert_relative_eq!(result[0][4].im, -0.0041382, epsilon = Float::EPSILON.cbrt());
350        assert_relative_eq!(result[0][5].re, -result[0][4].im);
351        assert_relative_eq!(result[0][5].im, result[0][4].re);
352        assert_relative_eq!(result[0][6].re, 0.0594691, epsilon = Float::EPSILON.cbrt());
353        assert_relative_eq!(result[0][6].im, 0.1143819, epsilon = Float::EPSILON.cbrt());
354        assert_relative_eq!(result[0][7].re, -result[0][6].im);
355        assert_relative_eq!(result[0][7].im, result[0][6].re);
356    }
357
358    #[test]
359    fn test_f2_resample() {
360        let res_mass = Mass::new([2, 3]);
361        let _amp = KopfKMatrixF2::new(
362            "f2",
363            [
364                [parameter("p0"), parameter("p1")],
365                [parameter("p2"), parameter("p3")],
366                [parameter("p4"), parameter("p5")],
367                [parameter("p6"), parameter("p7")],
368            ],
369            1,
370            &res_mass,
371            Some(1),
372        );
373    }
374}