source: trunk/external-alma/components/SpectralComponents/SpectralList2.tcc@ 3006

Last change on this file since 3006 was 2980, checked in by Malte Marquarding, 10 years ago

Add a copy of casacore/components/SpectralComponents to external-alma directory to prepare for its removal from casacore-trunk. DOn;t activate in SConscript yet.

File size: 2.7 KB
Line 
1//# SpectralList2.cc: Member templates for SpectralList
2//# Copyright (C) 2001,2002
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: aips2-request@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25//#
26//# $Id: SpectralList2.tcc 19935 2007-02-27 05:07:40Z Malte.Marquarding $
27
28//# Includes
29#include <components/SpectralComponents/SpectralList.h>
30
31#include <casa/Arrays/Vector.h>
32#include <casa/Exceptions/Error.h>
33#include <components/SpectralComponents/SpectralElement.h>
34
35namespace casa { //# NAMESPACE CASA - BEGIN
36
37//# Member templates
38template <class MT>
39void SpectralList::evaluate(Vector<MT> &y) const {
40 for (uInt j=0; j<y.nelements(); j++) {
41 if (list_p.nelements() > 0) y(j) = (*list_p[0])(j);
42 else y(j) = 0;
43 };
44 for (uInt i=1; i<list_p.nelements(); i++) {
45 for (uInt j=0; j<y.nelements(); j++) y(j) += (*list_p[i])(j);
46 };
47}
48
49template <class MT>
50void SpectralList::evaluate(Vector<MT> &y, const Vector<MT> &x) const {
51 y.resize(x.nelements());
52 for (uInt j=0; j<x.nelements(); j++) {
53 if (list_p.nelements() > 0) y(j) = (*list_p[0])(x(j));
54 else y(j) = 0;
55 };
56 for (uInt i=1; i<list_p.nelements(); i++) {
57 for (uInt j=0; j<x.nelements(); j++) y(j) += (*list_p[i])(x(j));
58 };
59}
60
61template <class MT>
62void SpectralList::residual(Vector<MT> &y) const {
63 for (uInt i=0; i<list_p.nelements(); i++) {
64 for (uInt j=0; j<y.nelements(); j++) y(j) -= (*list_p[i])(j);
65 };
66}
67
68template <class MT>
69void SpectralList::residual(Vector<MT> &y, const Vector<MT> &x) const {
70 if (x.nelements() != y.nelements()) {
71 throw(AipsError("Unequal lengths in arguments SpectralList::residual"));
72 };
73 for (uInt i=0; i<list_p.nelements(); i++) {
74 for (uInt j=0; j<x.nelements(); j++) y(j) -= (*list_p[i])(x(j));
75 };
76}
77
78} //# NAMESPACE CASA - END
79
Note: See TracBrowser for help on using the repository browser.