Logo coherent WaveBurst  
Library Reference Guide
Logo
numpy.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 "numpy.hh"
20 
21 double interp(double v, double* x, double* y, int n)
22 { int i;
23  for(i=0; i<n; ++i)if(v<x[i])break;
24  if(i==0)return y[0];
25  if(i==n)return y[n-1];
26  return y[i-1] + (v-x[i-1])/(x[i] - x[i-1]) *(y[i] - y[i-1]);
27 }
28 
29 double interp(double v, double* x, double* y, int n, double left, double right)
30 { int i;
31  for(i=0; i<n; ++i)if(v<x[i])break;
32  if(i==0)return left;
33  if(i==n)return right;
34  return y[i-1] + (v-x[i-1])/(x[i] - x[i-1]) *(y[i] - y[i-1]);
35 }
36 
37 double* interp(double* v, int Nv, double* x, double* y, int n, double left, double right)
38 { double* res = new double[Nv];
39  for(int i=0; i<Nv; ++i)res[i] = interp(v[i], x, y, n, left, right);
40  return res;
41 }
42 
44 { return Complex(x.Re() + y.Re(), x.Im() + y.Im());
45 }
46 
48 { return Complex(x.Re()*y.Re() - x.Im()*y.Im(), x.Re()*y.Im() + x.Im()*y.Re());
49 }
50 
51 Complex Exp(double phase)
52 { return Complex(cos(phase), sin(phase));
53 }
54 
55 double fabs(const Complex& x)
56 { return sqrt(x.Re()*x.Re() + x.Im()*x.Im());
57 }
Complex(double r=0., double i=0.)
Definition: numpy.hh:31
double Im() const
Definition: numpy.hh:33
WSeries< float > v[nIFO]
Definition: cwb_net.C:80
int n
Definition: cwb_net.C:28
cout<< endl;cout<< "ts size = "<< ts.size()<< " ts rate = "<< ts.rate()<< endl;tf.Forward(ts, wdm);int levels=tf.getLevel();cout<< "tf size = "<< tf.size()<< endl;double dF=tf.resolution();double dT=1./(2 *dF);cout<< "rate(hz) : "<< RATE<< "\ layers : "<< nLAYERS<< "\ dF(hz) : "<< dF<< "\ dT(ms) : "<< dT *1000.<< endl;int itime=TIME_PIXEL_INDEX;int ifreq=FREQ_PIXEL_INDEX;int index=(levels+1) *itime+ifreq;double time=itime *dT;double freq=(ifreq >0) ? ifreq *dF :dF/4;cout<< endl;cout<< "PIXEL TIME = "<< time<< " sec "<< endl;cout<< "PIXEL FREQ = "<< freq<< " Hz "<< endl;cout<< endl;wavearray< double > x
double phase
Complex operator*(const Complex &x, const Complex &y)
Definition: numpy.cc:47
Complex Exp(double phase)
Definition: numpy.cc:51
i drho i
Complex operator+(const Complex &x, const Complex &y)
Definition: numpy.cc:43
double interp(double v, double *x, double *y, int n)
Definition: numpy.cc:21
double fabs(const Complex &x)
Definition: numpy.cc:55
wavearray< double > y
Definition: Test10.C:31
double Re() const
Definition: numpy.hh:32
Definition: numpy.hh:29