This file is indexed.

/usr/include/casacore/scimath/Mathematics/ConvolveGridder.tcc is in casacore-dev 2.2.0-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
//# ConvolveGridder.cc: Convolutional Gridder
//# Copyright (C) 1996,1997,1999,2002,2003
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//#        Internet email: aips2-request@nrao.edu.
//#        Postal address: AIPS++ Project Office
//#                        National Radio Astronomy Observatory
//#                        520 Edgemont Road
//#                        Charlottesville, VA 22903-2475 USA
//#
//#
//# $Id$

#ifndef SCIMATH_CONVOLVEGRIDDER_TCC
#define SCIMATH_CONVOLVEGRIDDER_TCC

#include <casacore/scimath/Mathematics/ConvolveGridder.h>
#include <casacore/casa/BasicSL/Constants.h>
#include <casacore/casa/Arrays/ArrayMath.h>
#include <casacore/casa/Arrays/Vector.h>
#include <casacore/casa/iostream.h>

namespace casacore { //# NAMESPACE CASACORE - BEGIN

#define NEED_UNDERSCORES
#if defined(NEED_UNDERSCORES)
#define grdsf grdsf_
#define cgrd1d cgrd1d_
#define cgrd2d cgrd2d_
#define cgrd3d cgrd3d_
#define cdgrd1d cdgrd1d_
#define cdgrd2d cdgrd2d_
#define cdgrd3d cdgrd3d_

#define dgrd1d dgrd1d_
#define dgrd2d dgrd2d_
#define dgrd3d dgrd3d_
#define ddgrd1d ddgrd1d_
#define ddgrd2d ddgrd2d_
#define ddgrd3d ddgrd3d_

#define fgrd1d fgrd1d_
#define fgrd2d fgrd2d_
#define fgrd3d fgrd3d_
#define fdgrd1d fdgrd1d_
#define fdgrd2d fdgrd2d_
#define fdgrd3d fdgrd3d_

#endif

extern "C" { 
   void grdsf(Double*, Double*);
   void cgrd1d(Int*, Int*, Complex*, const Complex*, Int*, Int*, Double*,
		 Double*);
   void cgrd2d(Int*, Int*, Int*, Int*, Complex*, const Complex*, Int*,
		 Int*, Double*, Double*, Double*);
   void cgrd3d(Int*, Int*, Int *, Int*, Int*, Int *, Complex*,
		 const Complex*, Int*, Int*, Double*, Double*, Double*,
		 Double*);
   void cdgrd1d(Int*, Int*, const Complex*, Complex*, Int*, Int*, Double*,
		 Double*);
   void cdgrd2d(Int*, Int*, Int*, Int*, const Complex*, Complex*, Int*,
		 Int*, Double*, Double*, Double*);
   void cdgrd3d(Int*, Int*, Int *, Int*, Int*, Int *, const Complex*,
		 Complex*, Int*, Int*, Double*, Double*, Double*,
		 Double*);

   void fgrd1d(Int*, Int*, Float*, const Float*, Int*, Int*, Double*,
		 Double*);
   void fgrd2d(Int*, Int*, Int*, Int*, Float*, const Float*, Int*,
		 Int*, Double*, Double*, Double*);
   void fgrd3d(Int*, Int*, Int *, Int*, Int*, Int *, Float*,
		 const Float*, Int*, Int*, Double*, Double*, Double*,
		 Double*);
   void fdgrd1d(Int*, Int*, const Float*, Float*, Int*, Int*, Double*,
		 Double*);
   void fdgrd2d(Int*, Int*, Int*, Int*, const Float*, Float*, Int*,
		 Int*, Double*, Double*, Double*);
   void fdgrd3d(Int*, Int*, Int *, Int*, Int*, Int *, const Float*,
		 Float*, Int*, Int*, Double*, Double*, Double*,
		 Double*);

   void dgrd1d(Int*, Int*, Double*, const Double*, Int*, Int*, Double*,
		 Double*);
   void dgrd2d(Int*, Int*, Int*, Int*, Double*, const Double*, Int*,
		 Int*, Double*, Double*, Double*);
   void dgrd3d(Int*, Int*, Int *, Int*, Int*, Int *, Double*,
		 const Double*, Int*, Int*, Double*, Double*, Double*,
		 Double*);
   void ddgrd1d(Int*, Int*, const Double*, Double*, Int*, Int*, Double*,
		 Double*);
   void ddgrd2d(Int*, Int*, Int*, Int*, const Double*, Double*, Int*,
		 Int*, Double*, Double*, Double*);
   void ddgrd3d(Int*, Int*, Int *, Int*, Int*, Int *, const Double*,
		 Double*, Int*, Int*, Double*, Double*, Double*,
		 Double*);
}

// Double versions

inline void grd1d(Int* ni, Int* li,
		  Double* grid, const Double* value,
		  Int* sampling, Int* support,
		  Double* posi,
		  Double* convFunc) 
{
  dgrd1d(ni, li, grid, value, sampling, support, posi, convFunc);
}

inline void grd2d(Int* ni, Int* nj, Int* li, Int* lj,
		  Double* grid, const Double* value,
		  Int* sampling, Int* support,
		  Double* posi, Double* posj,
		  Double* convFunc)
{
  dgrd2d(ni, nj, li, lj, grid, value, sampling, support, posi, posj, convFunc);
}

inline void grd3d(Int* ni, Int* nj, Int *nk, Int* li, Int* lj, Int* lk,
		  Double* grid, const Double* value,
		  Int* sampling, Int* support,
		  Double* posi, Double* posj, Double* posk,
		  Double* convFunc)
{
  dgrd3d(ni, nj, nk, li, lj, lk, grid, value, sampling, support,
	 posi, posj, posk, convFunc);
}



inline void dgrd1d(Int* ni, Int* li,
		  const Double* grid, Double* value,
		  Int* sampling, Int* support,
		  Double* posi,
		  Double* convFunc)
{
  ddgrd1d(ni, li, grid, value, sampling, support, posi, convFunc);
}
inline void dgrd2d(Int* ni, Int* nj, Int* li, Int* lj,
		  const Double* grid, Double* value,
		  Int* sampling, Int* support,
		  Double* posi, Double* posj,
		  Double* convFunc)
{
  ddgrd2d(ni, nj, li, lj, grid, value, sampling, support, posi, posj, convFunc);
}

inline void dgrd3d(Int* ni, Int* nj, Int *nk, Int* li, Int* lj, Int* lk,
		  const Double* grid, Double* value,
		  Int* sampling, Int* support,
		  Double* posi, Double* posj, Double* posk,
		  Double* convFunc)
{
  ddgrd3d(ni, nj, nk, li, lj, lk, grid, value, sampling, support,
	  posi, posj, posk, convFunc);
}

// Complex versions

inline void grd1d(Int* ni, Int* li,
		  Complex* grid, const Complex* value,
		  Int* sampling, Int* support,
		  Double* posi,
		  Double* convFunc) 
{
  cgrd1d(ni, li, grid, value, sampling, support, posi, convFunc);
}

inline void grd2d(Int* ni, Int* nj, Int* li, Int* lj,
		  Complex* grid, const Complex* value,
		  Int* sampling, Int* support,
		  Double* posi, Double* posj,
		  Double* convFunc)
{
  cgrd2d(ni, nj, li, lj, grid, value, sampling, support, posi, posj, convFunc);
}

inline void grd3d(Int* ni, Int* nj, Int *nk, Int* li, Int* lj, Int* lk,
		  Complex* grid, const Complex* value,
		  Int* sampling, Int* support,
		  Double* posi, Double* posj, Double* posk,
		  Double* convFunc)
{
  cgrd3d(ni, nj, nk, li, lj, lk, grid, value, sampling, support,
	 posi, posj, posk, convFunc);
}



inline void dgrd1d(Int* ni, Int* li,
		  const Complex* grid, Complex* value,
		  Int* sampling, Int* support,
		  Double* posi,
		  Double* convFunc)
{
  cdgrd1d(ni, li, grid, value, sampling, support, posi, convFunc);
}
inline void dgrd2d(Int* ni, Int* nj, Int* li, Int* lj,
		  const Complex* grid, Complex* value,
		  Int* sampling, Int* support,
		  Double* posi, Double* posj,
		  Double* convFunc)
{
  cdgrd2d(ni, nj, li, lj, grid, value, sampling, support, posi, posj, convFunc);
}

inline void dgrd3d(Int* ni, Int* nj, Int *nk, Int* li, Int* lj, Int* lk,
		  const Complex* grid, Complex* value,
		  Int* sampling, Int* support,
		  Double* posi, Double* posj, Double* posk,
		  Double* convFunc)
{
  cdgrd3d(ni, nj, nk, li, lj, lk, grid, value, sampling, support,
	  posi, posj, posk, convFunc);
}

// Float versions

inline void grd1d(Int* ni, Int* li,
		  Float* grid, const Float* value,
		  Int* sampling, Int* support,
		  Double* posi,
		  Double* convFunc) 
{
  fgrd1d(ni, li, grid, value, sampling, support, posi, convFunc);
}

inline void grd2d(Int* ni, Int* nj, Int* li, Int* lj,
		  Float* grid, const Float* value,
		  Int* sampling, Int* support,
		  Double* posi, Double* posj,
		  Double* convFunc)
{
  fgrd2d(ni, nj, li, lj, grid, value, sampling, support, posi, posj, convFunc);
}

inline void grd3d(Int* ni, Int* nj, Int *nk, Int* li, Int* lj, Int* lk,
		  Float* grid, const Float* value,
		  Int* sampling, Int* support,
		  Double* posi, Double* posj, Double* posk,
		  Double* convFunc)
{
  fgrd3d(ni, nj, nk, li, lj, lk, grid, value, sampling, support,
	 posi, posj, posk, convFunc);
}



inline void dgrd1d(Int* ni, Int* li,
		  const Float* grid, Float* value,
		  Int* sampling, Int* support,
		  Double* posi,
		  Double* convFunc)
{
  fdgrd1d(ni, li, grid, value, sampling, support, posi, convFunc);
}
inline void dgrd2d(Int* ni, Int* nj, Int* li, Int* lj,
		  const Float* grid, Float* value,
		  Int* sampling, Int* support,
		  Double* posi, Double* posj,
		  Double* convFunc)
{
  fdgrd2d(ni, nj, li, lj, grid, value, sampling, support, posi, posj, convFunc);
}

inline void dgrd3d(Int* ni, Int* nj, Int *nk, Int* li, Int* lj, Int* lk,
		  const Float* grid, Float* value,
		  Int* sampling, Int* support,
		  Double* posi, Double* posj, Double* posk,
		  Double* convFunc)
{
  fdgrd3d(ni, nj, nk, li, lj, lk, grid, value, sampling, support,
	  posi, posj, posk, convFunc);
}

template <class Domain, class Range>
ConvolveGridder<Domain, Range>::ConvolveGridder(const IPosition& shape,
				    const Vector<Domain>& scale,
				    const Vector<Domain>& offset,
				    const String& convType) 
: Gridder<Domain, Range>(shape, scale, offset)
{
  setConvolutionFunction(convType);
  fillCorrectionVectors();
  loc.resize(ndim);
  loc=0;
  supportVec.resize(ndim);
  supportVec=support;
}

template <class Domain, class Range>
Bool ConvolveGridder<Domain, Range>::grid(Array<Range> &gridded,
				    const Vector<Domain>& p,
				    const Range& value)
{
  loc=this->location(loc,p);
  loc-=offsetVec;
  if(onGrid(loc,supportVec)) {
    Bool del;
    posVec=this->position(posVec, p);
    const IPosition& fs = gridded.shape();
    vector<Int> s(fs.begin(), fs.end());
    switch(loc.nelements()) {
    case 1:
      grd1d(&s[0], &loc(0), gridded.getStorage(del), &value, &support,
	       &sampling, &posVec(0), convFunc.getStorage(del));
      break;
    case 2:
      grd2d(&s[0], &s[1], &loc(0), &loc(1), gridded.getStorage(del),
	       &value, &support, &sampling, &posVec(0), &posVec(1),
	       convFunc.getStorage(del));
      break;
    case 3:
      grd3d(&s[0], &s[1], &s[2], &loc(0), &loc(1), &loc(2),
	       gridded.getStorage(del), &value, &support,
	       &sampling, &posVec(0), &posVec(1), &posVec(2),
	       convFunc.getStorage(del));
      break;
    default:
      return False;
      break;
    }
    return True;
  }
  else {
    cout<<"Off grid"<<endl;
    return False;
  }
}

template <class Domain, class Range>
Bool ConvolveGridder<Domain, Range>::degrid(const Array<Range> &gridded,
				    const Vector<Domain>& p,
				    Range& value)
{
  loc=this->location(loc,p); 
 if(onGrid(loc,supportVec)) {
    Bool del;
    posVec=this->position(posVec, p);
    const IPosition& fs = gridded.shape();
    vector<Int> s(fs.begin(), fs.end());
    switch(loc.nelements()) {
    case 1:
      dgrd1d(&s[0], &loc(0), gridded.getStorage(del), &value, &support,
	       &sampling, &posVec(0), convFunc.getStorage(del));
      break;
    case 2:
      dgrd2d(&s[0], &s[1], &loc(0), &loc(1), gridded.getStorage(del),
	       &value, &support, &sampling, &posVec(0), &posVec(1),
	       convFunc.getStorage(del));
      break;
    case 3:
      dgrd3d(&s[0], &s[1], &s[2], &loc(0), &loc(1), &loc(2),
	       gridded.getStorage(del), &value, &support,
	       &sampling, &posVec(0), &posVec(1), &posVec(2),
	       convFunc.getStorage(del));
      break;
    default:
      return False;
      break;
    }
    return True;
  }
  else {
    return False;
  }
}

template <class Domain, class Range>
Range ConvolveGridder<Domain, Range>::correctionFactor1D(Int loc, Int len)
{
  Int offset=loc-len/2;
  if(cType=="BOX") {
    if(offset!=0.0) {
      Double arg=C::pi*Double(offset)/Double(len);
      return sin(arg)/arg;
    }
    else {
      return 1.0;
    }
  }
  else {
    Double nu=abs(Double(offset)/Double(len/2));
    Double val;
    grdsf(&nu, &val);
    return val;
  }
  return 1.0;
}

template <class Domain, class Range>
void ConvolveGridder<Domain, Range>::setConvolutionFunction(const String& type) {

  cType=type;
  if(type=="BOX") {
    support=0;
    sampling=100;
    convFunc.resize(sampling*(support+1));
    convFunc=0.0;
    for (Int i=0;i<sampling*(support+1);i++) {
      convFunc(i)=1.0;
    }
  }
  else {
    // SF
    support=3;
    sampling=100;
    convFunc.resize(sampling*(support+1));
    convFunc=0.0;
    for (Int i=0;i<sampling*support;i++) {
      Double nu=Double(i)/Double(support*sampling);
      Double val;
      grdsf(&nu, &val);
      convFunc(i)=(1.0-nu*nu)*val;
    }
  }
}

template <class Domain, class Range>
Vector<Double>& ConvolveGridder<Domain, Range>::cFunction() {
  return convFunc;
}

template <class Domain, class Range>
Vector<Int>& ConvolveGridder<Domain, Range>::cSupport() {
  return supportVec;
}

template <class Domain, class Range>
Int& ConvolveGridder<Domain, Range>::cSampling() {
  return sampling;
}

} //# NAMESPACE CASACORE - END


#endif