1#ifndef __COMPLEX_ARRAY_H__
2#define __COMPLEX_ARRAY_H__
4#include <boost/archive/text_iarchive.hpp>
5#include <boost/archive/text_oarchive.hpp>
6#include <boost/serialization/shared_ptr.hpp>
8#include <gsl/gsl_errno.h>
9#include <gsl/gsl_fft_complex.h>
13#define REAL(z, i) ((z)[2 * (i)])
14#define IMAG(z, i) ((z)[2 * (i) + 1])
15namespace mspass::algorithms::deconvolution {
16typedef std::complex<double> Complex64;
17typedef std::complex<float> Complex32;
28template <
class Archive>
29void serialize(Archive &ar,
FortranComplex64 &z,
const unsigned int version) {
63 template <
class T>
ComplexArray(
int nsamp, std::vector<T> d);
104 double *ptr(
int sample);
131 std::vector<double> abs()
const;
135 double norm2()
const;
137 std::vector<double> phase()
const;
160 std::shared_ptr<FortranComplex64[]> data;
162 friend boost::serialization::access;
163 template <
class Archive>
164 void save(Archive &ar,
const unsigned int version)
const {
165 std::vector<FortranComplex64> dv;
166 dv.reserve(this->nsamp);
167 for (
auto i = 0; i < nsamp; ++i)
168 dv.push_back(this->data[i]);
172 template <
class Archive>
void load(Archive &ar,
const unsigned int version) {
174 std::vector<FortranComplex64> dv;
175 dv.reserve(this->nsamp);
179 for (
auto i = 0; i < this->nsamp; ++i)
180 this->data[i] = dv[i];
182 BOOST_SERIALIZATION_SPLIT_MEMBER()
213 if (nsamp > d.size()) {
215 for (std::size_t i = 0; i < d.size(); i++) {
216 this->data[i].real = d[i];
217 this->data[i].imag = 0.0;
219 for (std::size_t i = d.size(); i < nsamp; i++) {
220 this->data[i].real = 0.0;
221 this->data[i].imag = 0.0;
225 for (std::size_t i = 0; i < nsamp; i++) {
226 this->data[i].real = d[i];
227 this->data[i].imag = 0.0;
234 for (std::size_t i = 0; i < nsamp; i++) {
235 this->data[i].real = d;
236 this->data[i].imag = 0.0;
Definition ComplexArray.h:37
ComplexArray()
Definition ComplexArray.cc:8
void conj()
Definition ComplexArray.cc:241
Complex64 operator[](int sample)
Definition ComplexArray.cc:117
ComplexArray(std::vector< double > mag, std::vector< double > phase)
ComplexArray(std::vector< Complex32 > &d)
ComplexArray(std::vector< Complex64 > &d)
Definition ComplexArray.h:19
Definition ComplexArray.h:23