Logo coherent WaveBurst  
Library Reference Guide
Logo
SymmObjArray.cc
Go to the documentation of this file.
1 /*
2 # Copyright (C) 2019 Sergey Klimenko, Valentin Necula
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
18 
19 #include "SymmObjArray.hh"
20 
21 #include "SymmArray.hh"
22 #include "SymmArraySSE.hh"
23 
25 
26 template <class T>
27 SymmObjArray<T>::SymmObjArray(unsigned int n)
28 { Size = 2*n+1; //mind the plus
29  rec = new T[Size];
30  zero = rec+n;
31  if(rec == 0 )printf("SymmObjArray::SymmObjArray : memory not allocated\n");
32 }
33 
34 template <class T>
36 { zero = rec = 0;
37  *this=a;
38 }
39 
40 template <class T>
42 { Resize0(other.Size);
43  for(int i=0; i<Size; ++i) rec[i]= other.rec[i];
44  zero = rec + Size/2;
45  return *this;
46 }
47 
48 template <class T>
50 { delete [] rec;
51 }
52 
53 template <class T>
54 void SymmObjArray<T>::Resize(unsigned int sz)
55 { Resize0(sz = 2*sz+1);
56 }
57 
58 template <class T>
59 void SymmObjArray<T>::Resize0(unsigned int sz)
60 { delete [] rec;
61  Size = sz;
62  rec = new T[Size];
63  zero = rec + Size/2;
64 }
65 
66 template <class T>
68 { fwrite(&Size, sizeof(int), 1, f);
69  for(int i=0; i<Size; ++i)rec[i].Write(f);
70 }
71 
72 template <class T>
74 { int newSize;
75  fread(&newSize, sizeof(int), 1, f);
76  if(Size)delete [] rec;
77  Size = newSize;
78  rec = new T[Size];
79  zero = rec + Size/2;
80  for(int i=0; i<Size; ++i)rec[i].Read(f);
81 }
82 
83 template class SymmObjArray< SymmArray<int> >;
84 template class SymmObjArray< SymmArray<float> >;
85 template class SymmObjArray< SymmArray<double> >;
86 
87 template class SymmObjArray< SymmArraySSE<int> >;
88 template class SymmObjArray< SymmArraySSE<float> >;
89 template class SymmObjArray< SymmArraySSE<double> >;
wavearray< double > a(hp.size())
int n
Definition: cwb_net.C:28
void Read(FILE *f)
Definition: SymmObjArray.cc:73
i drho i
cout<< "SNR "<< xsnr<< endl;wavearray< double > f
Definition: ComputeSNR.C:75
tlive_fix Write()
virtual ~SymmObjArray()
Definition: SymmObjArray.cc:49
void Resize(unsigned int sz)
Definition: SymmObjArray.cc:54
printf("total live time: non-zero lags = %10.1f \, liveTot)
void Resize0(unsigned int sz)
Definition: SymmObjArray.cc:59
double T
Definition: testWDM_4.C:11
SymmObjArray(unsigned int n=0)
Definition: SymmObjArray.cc:27
SymmObjArray & operator=(const SymmObjArray &other)
Definition: SymmObjArray.cc:41
void Write(FILE *f)
Definition: SymmObjArray.cc:67