source: trunk/src/SDFitTable.cc @ 528

Last change on this file since 528 was 528, checked in by mar637, 19 years ago

fixed bug in copy constr.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1//#---------------------------------------------------------------------------
2//# SDFitTable.h: A wrapper for fit parameters
3//#---------------------------------------------------------------------------
4//# Copyright (C) 2004
5//# ATNF
6//#
7//# This program is free software; you can redistribute it and/or modify it
8//# under the terms of the GNU General Public License as published by the Free
9//# Software Foundation; either version 2 of the License, or (at your option)
10//# any later version.
11//#
12//# This program is distributed in the hope that it will be useful, but
13//# WITHOUT ANY WARRANTY; without even the implied warranty of
14//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
15//# Public License for more details.
16//#
17//# You should have received a copy of the GNU General Public License along
18//# with this program; if not, write to the Free Software Foundation, Inc.,
19//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
20//#
21//# Correspondence concerning this software should be addressed as follows:
22//#        Internet email: Malte.Marquarding@csiro.au
23//#        Postal address: Malte Marquarding,
24//#                        Australia Telescope National Facility,
25//#                        P.O. Box 76,
26//#                        Epping, NSW, 2121,
27//#                        AUSTRALIA
28//#
29//# $Id:
30//#---------------------------------------------------------------------------
31
32#include "MathUtils.h"
33#include "SDFitTable.h"
34
35using namespace casa;
36using namespace asap;
37
38SDFitTable::SDFitTable(const SDFitTable& other) { 
39  if (other.length() > 0) {
40    this->nfits_ = other.nfits_;
41    this->pars_ = other.pars_;
42    this->mask_ = other.mask_;
43    this->funcs_ = other.funcs_;
44    this->comps_ = other.comps_;
45    this->frameinfo_ = other.frameinfo_;
46  } else {
47    this->nfits_ = 0;
48  }
49}
50
51
52void SDFitTable::addSTLFit(const std::vector<double>& p,
53                      const std::vector<bool>& m,
54                      const std::vector<std::string>& f,
55                      const std::vector<Int>& c,
56                      const std::vector<std::string>& fi)
57{
58  pars_.push_back(p);
59  mask_.push_back(m);
60  funcs_.push_back(f);
61  comps_.push_back(c);
62  frameinfo_.push_back(fi);
63  nfits_++;
64}
65
66void SDFitTable::addFit(const Vector<Double>& p,
67                   const Vector<Bool>& m,
68                   const Vector<String>& f,
69                   const Vector<Int>& c,
70                   const Vector<String>& fi)
71{
72  std::vector<double> p1;
73  p.tovector(p1);
74  pars_.push_back(p1);
75  std::vector<bool> m1;
76  m.tovector(m1);
77  mask_.push_back(m1);
78  std::vector<string> f1;
79  f1 = mathutil::tovectorstring(f);
80  funcs_.push_back(f1);
81  std::vector<int> c1;
82  c.tovector(c1);
83  comps_.push_back(c1);
84  std::vector<string> fi1;
85  fi1 = mathutil::tovectorstring(fi);
86  frameinfo_.push_back(fi1);
87  nfits_++;
88}
89
90std::vector<double> SDFitTable::getSTLParameters(int which) const
91{
92  if (which >= nfits_)
93    return std::vector<double>(); 
94  return pars_[which];
95}
96
97Vector<Double> SDFitTable::getParameters(uInt which) const{
98  if (int(which) >= nfits_)
99    return Vector<Double>(std::vector<double>()); 
100  return Vector<Double>(pars_[which]);
101}
102
103std::vector<bool> SDFitTable::getSTLParameterMask(int which) const
104{
105  if (which >= nfits_)
106    return  std::vector<bool>();
107  return mask_[which];
108}
109
110Vector<Bool> SDFitTable::getParameterMask(uInt which) const
111{
112  if (which >= nfits_)
113    return  Vector<Bool>(std::vector<bool>()); 
114  return Vector<Bool>(mask_[which]);
115}
116
117std::vector<std::string> SDFitTable::getSTLFunctions(int which) const
118{
119  if (which >= nfits_)
120    return std::vector<std::string>(); 
121  return funcs_[which];
122}
123
124Vector<String> SDFitTable::getFunctions(uInt which) const
125{
126  if (int(which) >= nfits_)
127    return mathutil::toVectorString(std::vector<std::string>());
128  return mathutil::toVectorString(funcs_[which]);
129}
130
131std::vector<int> SDFitTable::getSTLComponents(int which) const
132{
133  if (which >= nfits_)
134    return std::vector<int>(); 
135  return comps_[which];
136}
137
138Vector<Int> SDFitTable::getComponents(uInt which) const
139{
140  if (int(which) >= nfits_)
141    return Vector<Int>(std::vector<int>()); 
142  return Vector<Int>(comps_[which]);
143}
144
145std::vector<std::string> SDFitTable::getSTLFrameInfo(int which) const
146{
147  if (which >= nfits_)
148    return std::vector<std::string>(); 
149  return frameinfo_[which];
150}
151
152Vector<String> SDFitTable::getFrameInfo(uInt which) const
153{
154  if (int(which) >= nfits_)
155    return mathutil::toVectorString(std::vector<std::string>());
156  return mathutil::toVectorString(frameinfo_[which]);
157}
158
Note: See TracBrowser for help on using the repository browser.