diff --git a/nuTens/propagator/CMakeLists.txt b/nuTens/propagator/CMakeLists.txt index 8b13789..aff6add 100644 --- a/nuTens/propagator/CMakeLists.txt +++ b/nuTens/propagator/CMakeLists.txt @@ -1 +1,7 @@ + +add_library(propagator STATIC vacuum-propagator.hpp vacuum-propagator.cpp) +target_link_libraries(propagator PUBLIC tensor) + +target_include_directories(propagator PUBLIC "${CMAKE_SOURCE_DIR}") +set_target_properties(propagator PROPERTIES LINKER_LANGUAGE CXX) diff --git a/nuTens/propagator/vacuum-propagator.cpp b/nuTens/propagator/vacuum-propagator.cpp new file mode 100644 index 0000000..3dca301 --- /dev/null +++ b/nuTens/propagator/vacuum-propagator.cpp @@ -0,0 +1,17 @@ +#include + + +Tensor VacuumPropagator::calculateProbs(){ + Tensor weightMatrix; + weightMatrix.ones({1,nGenerations, nGenerations}, NTdtypes::kComplexFloat).requiresGrad(false); + + for(int i = 0; i < nGenerations; i++){ + weightMatrix.setValue({0, i, "..."}, Tensor::exp(Tensor::div(Tensor::scale(Tensor::mul(masses, masses), -1.0j * baseline), Tensor::scale(energies, 2.0)))); + } + weightMatrix.requiresGrad(true); + + Tensor sqrtProbabilities = Tensor::matmul(PMNSmatrix.conj(), Tensor::transpose(Tensor::mul(PMNSmatrix, weightMatrix), 1, 2)); + Tensor probabilities = Tensor::mul(sqrtProbabilities.abs(), sqrtProbabilities.abs()); + + return probabilities; +} diff --git a/nuTens/propagator/vacuum-propagator.hpp b/nuTens/propagator/vacuum-propagator.hpp new file mode 100644 index 0000000..bf2eab8 --- /dev/null +++ b/nuTens/propagator/vacuum-propagator.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include +#include + +class VacuumPropagator{ + + public: + + VacuumPropagator(int nGenerations, float baseline) + : + baseline(baseline), + nGenerations(nGenerations) + {}; + + Tensor calculateProbs(); + + /// @name Setters + /// @{ + void setEnergies(Tensor newEnergies){ energies = newEnergies; } + + void setMasses(Tensor newMasses){ masses = newMasses; } + + inline void setPMNS(Tensor newPMNS){ PMNSmatrix = newPMNS; } + + inline void setPMNS(const std::vector &indices, float value){ PMNSmatrix.setValue(indices, value); } + + inline void setPMNS(const std::vector &indices, std::complex value){ PMNSmatrix.setValue(indices, value); } + /// @} + + private: + Tensor PMNSmatrix; + Tensor masses; + Tensor energies; + int nGenerations; + float baseline; +}; \ No newline at end of file