LCOV - code coverage report
Current view: top level - alma/ASDM - Frequency.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 25 71 35.2 %
Date: 2024-12-11 20:54:31 Functions: 5 12 41.7 %

          Line data    Source code
       1             : /*
       2             :  * ALMA - Atacama Large Millimeter Array
       3             :  * (c) European Southern Observatory, 2002
       4             :  * (c) Associated Universities Inc., 2002
       5             :  * Copyright by ESO (in the framework of the ALMA collaboration),
       6             :  * Copyright by AUI (in the framework of the ALMA collaboration),
       7             :  * All rights reserved.
       8             :  * 
       9             :  * This library is free software; you can redistribute it and/or
      10             :  * modify it under the terms of the GNU Lesser General Public
      11             :  * License as published by the Free software Foundation; either
      12             :  * version 2.1 of the License, or (at your option) any later version.
      13             :  * 
      14             :  * This library is distributed in the hope that it will be useful,
      15             :  * but WITHOUT ANY WARRANTY, without even the implied warranty of
      16             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17             :  * Lesser General Public License for more details.
      18             :  * 
      19             :  * You should have received a copy of the GNU Lesser General Public
      20             :  * License along with this library; if not, write to the Free Software
      21             :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      22             :  * MA 02111-1307  USA
      23             :  *
      24             :  * File Frequency.cpp
      25             :  */
      26             : 
      27             : #include <alma/ASDM/Frequency.h>
      28             : #include <alma/ASDM/DoubleWrapper.h>
      29             : #include <alma/ASDM/NumberFormatException.h>
      30             : 
      31             : using namespace std;
      32             : 
      33             : namespace asdm {
      34             : 
      35       27137 : Frequency Frequency::getFrequency(StringTokenizer &t) {
      36       27137 :         double value = Double::parseDouble(t.nextToken());
      37       27137 :         return Frequency (value);
      38             : }
      39             : 
      40           0 : bool Frequency::isZero() const {
      41           0 :         return value == 0.0;
      42             : }
      43             : 
      44        8383 : double Frequency::fromString(const string& s) {
      45        8383 :         return Double::parseDouble(s);
      46             : }
      47             : 
      48      156523 : string Frequency::toString(double x) {
      49      156523 :         return Double::toString(x);
      50             : }
      51             : 
      52           0 : void Frequency::toBin(EndianOSStream& eoss) {
      53           0 :         eoss.writeDouble(       value);
      54           0 : }
      55             : 
      56           0 : void Frequency::toBin(const vector<Frequency>& frequency,  EndianOSStream& eoss) {
      57           0 :         eoss.writeInt((int) frequency.size());
      58           0 :         for (unsigned int i = 0; i < frequency.size(); i++)
      59           0 :                 eoss.writeDouble(frequency.at(i).value);
      60           0 : }
      61             : 
      62           0 : void Frequency::toBin(const vector<vector<Frequency> >& frequency,  EndianOSStream& eoss) {
      63           0 :         eoss.writeInt((int) frequency.size());
      64           0 :         eoss.writeInt((int) frequency.at(0).size());
      65           0 :         for (unsigned int i = 0; i < frequency.size(); i++)
      66           0 :                 for (unsigned int j = 0; j < frequency.at(0).size(); j++)
      67           0 :                         eoss.writeDouble(frequency.at(i).at(j).value);
      68           0 : }
      69             : 
      70           0 : void Frequency::toBin(const vector< vector<vector<Frequency> > >& frequency,  EndianOSStream& eoss) {
      71           0 :         eoss.writeInt((int) frequency.size());
      72           0 :         eoss.writeInt((int) frequency.at(0).size());
      73           0 :         eoss.writeInt((int) frequency.at(0).at(0).size());      
      74           0 :         for (unsigned int i = 0; i < frequency.size(); i++)
      75           0 :                 for (unsigned int j = 0; j < frequency.at(0).size(); j++)
      76           0 :                                 for (unsigned int k = 0; k < frequency.at(0).at(0).size(); j++)
      77           0 :                                         eoss.writeDouble(frequency.at(i).at(j).at(k).value);
      78           0 : }
      79             : 
      80           0 : Frequency Frequency::fromBin(EndianIStream & eis) {
      81           0 :         return Frequency(eis.readDouble());
      82             : }
      83             : 
      84          65 : vector<Frequency> Frequency::from1DBin(EndianIStream & eis) {
      85          65 :         int dim1 = eis.readInt();
      86          65 :         vector<Frequency> result;
      87         195 :         for (int i = 0; i < dim1; i++)
      88         130 :                 result.push_back(Frequency(eis.readDouble()));
      89          65 :         return result;  
      90           0 : }
      91             : 
      92           1 : vector<vector<Frequency > > Frequency::from2DBin(EndianIStream & eis) {
      93           1 :         int dim1 = eis.readInt();
      94           1 :         int dim2 = eis.readInt();
      95           1 :         vector< vector<Frequency> >result;
      96           1 :         vector <Frequency> aux;
      97           5 :         for (int i = 0; i < dim1; i++) {
      98           4 :                 aux.clear();
      99          12 :                 for (int j = 0; j < dim2; j++)
     100           8 :                         aux.push_back(Frequency(eis.readDouble()));
     101           4 :                 result.push_back(aux);
     102             :         }
     103           2 :         return result;  
     104           1 : }
     105             : 
     106           0 : vector<vector<vector<Frequency > > > Frequency::from3DBin(EndianIStream & eis) {
     107           0 :         int dim1 = eis.readInt();
     108           0 :         int dim2 = eis.readInt();
     109           0 :         int dim3 = eis.readInt();
     110           0 :         vector<vector< vector<Frequency> > >result;
     111           0 :         vector < vector<Frequency> >aux1;
     112           0 :         vector <Frequency> aux2;
     113           0 :         for (int i = 0; i < dim1; i++) {
     114           0 :                 aux1.clear();
     115           0 :                 for (int j = 0; j < dim2; j++) {
     116           0 :                         aux2.clear();
     117           0 :                         for (int k = 0; k < dim3; k++)
     118           0 :                                 aux2.push_back(Frequency(eis.readDouble()));
     119           0 :                         aux1.push_back(aux2);
     120             :                 }
     121           0 :                 result.push_back(aux1);
     122             :         }
     123           0 :         return result;  
     124           0 : }
     125             : 
     126             : } // End namespace asdm

Generated by: LCOV version 1.16