Line data Source code
1 : //# FTMachine.tcc //For templated functions of FTMachine class 2 : //# Copyright (C) 2015-2019 3 : //# Associated Universities, Inc. Washington DC, USA. 4 : //# 5 : //# This library is free software; you can redistribute it and/or modify 6 : //# it under the terms of the GNU General Public License as published by 7 : //# the Free Software Foundation; either version 2 of the License, or 8 : //# (at your option) any later version. 9 : //# 10 : //# This library is distributed in the hope that it will be useful, 11 : //# but WITHOUT ANY WARRANTY; without even the implied warranty of 12 : //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 : //# GNU General Public License for more details. 14 : //# 15 : //# You should have received a copy of the GNU General Public License 16 : //# along with this library; if not, write to the Free Software 17 : //# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 : //# 19 : //# Correspondence concerning AIPS++ should be addressed as follows: 20 : //# Internet email: casa-feedback@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 : 27 0 : template <class T> void FTMachine::getGrid(casacore::Array<T>& thegrid){ 28 : 29 0 : thegrid.resize(); 30 0 : void * ptr = nullptr; 31 0 : casacore::Array<casacore::Float> tmpFloat; 32 0 : casacore::Array<casacore::Double> tmpDouble; 33 0 : casacore::IPosition shp; 34 : bool del; 35 0 : if((whatType<Array<T>>()==casacore::TpArrayComplex)){ 36 0 : if(useDoubleGrid_p){ 37 0 : griddedData.resize(griddedData2.shape()); 38 0 : convertArray(griddedData, griddedData2); 39 0 : griddedData2.resize(); 40 0 : useDoubleGrid_p=false; 41 : } 42 0 : ptr=griddedData.getStorage(del); 43 0 : shp=griddedData.shape(); 44 : } 45 0 : else if(whatType<Array<T>>()==casacore::TpArrayDComplex){ 46 0 : if(!useDoubleGrid_p){ 47 0 : griddedData2.resize(griddedData.shape()); 48 0 : convertArray(griddedData2, griddedData); 49 0 : griddedData.resize(); 50 0 : useDoubleGrid_p=true; 51 : } 52 0 : ptr=griddedData2.getStorage(del); 53 0 : shp=griddedData2.shape(); 54 : 55 : 56 : } 57 0 : else if(((whatType<Array<T>>()==casacore::TpArrayFloat))){ 58 0 : if(!useDoubleGrid_p){ 59 0 : tmpFloat.resize(griddedData.shape()); 60 : 61 : } 62 : else{ 63 0 : tmpFloat.resize(griddedData2.shape()); 64 0 : griddedData.resize(griddedData2.shape()); 65 0 : convertArray(griddedData, griddedData2); 66 0 : griddedData2.resize(); 67 0 : useDoubleGrid_p=false; 68 : //convertArray(tmpFloat, real(griddedData2)); 69 : } 70 : 71 : 72 0 : tmpFloat.set(0.0); 73 0 : shp=tmpFloat.shape(); 74 0 : Int end_indx = 0; 75 : //cerr << "getgrid " << sum(griddedData) << endl; 76 0 : casacore::IPosition in(4, 0, 0, 0, 0); 77 0 : casacore::IPosition out(4, 0,0,0,0); 78 : 79 0 : tmpFloat = real(griddedData); 80 : //cerr << "tmpFloat " << sum(tmpFloat) << endl; 81 0 : for (casacore::Int cc=0; cc< shp[3]; ++cc){ 82 0 : in[3]=cc; 83 0 : out[3]=cc; 84 0 : for(casacore::Int pp=0; pp< shp[2]; ++pp){ 85 0 : in[2]=pp; 86 0 : out[2]=pp; 87 : 88 0 : for (casacore::Int yy=-shp[1]/2; yy< shp[1]-shp[1]/2; ++yy){ 89 : 90 0 : for(casacore::Int xx=-shp[0]/2; xx< shp[0]-shp[0]/2; ++xx){ 91 0 : in[0]=xx + shp[0]/2; 92 0 : in[1]=yy + shp[1]/2; 93 0 : out[0]=-xx + shp[0]/2; 94 0 : out[1]=-yy + shp[1]/2; 95 : 96 0 : if((out[0] < shp[0]) && (out[1] < shp[1])) 97 : { 98 0 : tmpFloat(in)+=real(griddedData(out)); 99 : } 100 : } 101 : 102 : } 103 : } 104 : } 105 : //cerr << "getgrid " << sum(griddedData) << endl; 106 : //tmpFloat = real(griddedData); 107 : //cerr << "tmpFloat " << sum(tmpFloat) << endl; 108 0 : ptr=tmpFloat.getStorage(del); 109 : //ptr=griddedData.getStorage(del); 110 0 : } 111 0 : else if(((whatType<Array<T>>()==casacore::TpArrayDouble))){ 112 0 : if(useDoubleGrid_p){ 113 0 : tmpDouble.resize(griddedData2.shape()); 114 : } 115 : else{ 116 0 : tmpDouble.resize(griddedData.shape()); 117 0 : griddedData2.resize(griddedData.shape()); 118 0 : convertArray(griddedData2, griddedData); 119 0 : griddedData.resize(); 120 0 : useDoubleGrid_p=true; 121 : //convertArray(tmpFloat, real(griddedData2)); 122 : } 123 : 124 0 : tmpDouble=real(griddedData2); 125 0 : shp=tmpDouble.shape(); 126 0 : casacore::IPosition in(4, 0, 0, 0, 0); 127 0 : casacore::IPosition out(4, 0,0,0,0); 128 : 129 0 : for (casacore::Int cc=0; cc< shp[3]; ++cc){ 130 0 : in[3]=cc; 131 0 : out[3]=cc; 132 0 : for(casacore::Int pp=0; pp< shp[2]; ++pp){ 133 0 : in[2]=pp; 134 0 : out[2]=pp; 135 : 136 0 : for (casacore::Int yy=-shp[1]/2; yy< shp[1]-shp[1]/2; ++yy){ 137 : 138 0 : for(casacore::Int xx=-shp[0]/2; xx< shp[0]-shp[0]/2; ++xx){ 139 0 : in[0]=xx + shp[0]/2; 140 0 : in[1]=yy + shp[1]/2; 141 0 : out[0]=-xx + shp[0]/2; 142 0 : out[1]=-yy + shp[1]/2; 143 : 144 0 : if((out[0] < shp[0]) && (out[1] < shp[1])) 145 : { 146 0 : tmpDouble(in)+=real(griddedData(out)); 147 : } 148 : } 149 : 150 : } 151 : } 152 : } 153 0 : ptr=tmpDouble.getStorage(del); 154 : 155 : 156 0 : } 157 0 : thegrid=casacore::Array<T>(shp, (T*)(ptr)); 158 0 : griddedData.resize(); 159 0 : griddedData2.resize(); 160 0 : };