LCOV - code coverage report
Current view: top level - air_casawvr/src - partitionsum.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 17 17 100.0 %
Date: 2024-12-11 20:54:31 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /**
       2             :    \file partitionsum.cpp
       3             :    Bojan Nikolic <bn204@mrao.cam.ac.uk>, <bojan@bnikolic.co.uk>
       4             :    
       5             :    Initial version February 2008
       6             :    Maintained by ESO since 2013.
       7             :    Renamed partitionsum.cc 2023
       8             : 
       9             : */
      10             : 
      11             : #include "partitionsum.h"
      12             : 
      13             : namespace LibAIR2 {
      14             : 
      15          81 :   PartitionTable::PartitionTable(casacore::Matrix<double>* raw):
      16          81 :     raw(raw)
      17             :   {
      18          81 :   }
      19             : 
      20   159010610 :   size_t PartitionTable::findrow(double T) const
      21             :   {
      22   159010610 :     const size_t nrows= raw->shape()[0];
      23             :     
      24   159010610 :     size_t rlow = 0;
      25   159010610 :     size_t rhigh= nrows;
      26             :     
      27  2030888669 :     while  ( rhigh > rlow+1 ) 
      28             :     {
      29  1871878059 :       size_t rmid = (rlow+rhigh)/2;
      30             :       
      31  1871878059 :       if ( (*raw)(rmid,0) > T )
      32  1070694724 :         rhigh=rmid;
      33             :       else
      34   801183335 :         rlow=rmid;
      35             : 
      36             :     } ;
      37   159010610 :     return rlow;
      38             : 
      39             :   }
      40             : 
      41   159010610 :   double PartitionTable::eval(double T, size_t i) const
      42             :   {
      43   159010610 :     const size_t rlow  = findrow(T);
      44   159010610 :     const double delta = ( (*raw)(rlow+1, 0) - T) / ( (*raw)(rlow+1, 0) - (*raw)(rlow, 0) );
      45             : 
      46   159010610 :     return delta* (*raw)(rlow, i) + (1.0-delta)* (*raw)(rlow+1, i);
      47             : 
      48             :   }
      49             : 
      50             :   
      51             : 
      52             : }
      53             : 
      54             : 

Generated by: LCOV version 1.16