40 |
*******************************************************************/ |
*******************************************************************/ |
41 |
#include "contsignal.hh" |
#include "contsignal.hh" |
42 |
|
|
43 |
ContSignal &ContSignal::add ( ContSignal &src1, ContSignal &src2 ) |
ContSignal &ContSignal::add ( ContSignal &src ) |
44 |
{ |
{ |
45 |
int it; |
int it; |
46 |
int length = maximum((src1.length()), (src2.length())); |
int length = maximum((this->length()), (src.length())); |
47 |
double *data = new double[length + 1]; |
double *data = new double[length]; |
48 |
ContSignal *res = new ContSignal(data, length); |
ContSignal *res = new ContSignal(data, length); |
49 |
|
|
50 |
for (it = 0; it < length; ++it) |
for (it = 0; it < length; ++it) |
51 |
(*res)[it] = src1[it] + src2[it]; |
(*res)[it] = (*this)[it] + src[it]; |
|
(*res)[it] = '\0'; |
|
52 |
return *res; |
return *res; |
53 |
} |
} |
54 |
|
|
55 |
ContSignal &ContSignal::mult ( ContSignal &src1, ContSignal &src2 ) |
ContSignal &ContSignal::mult ( ContSignal &src ) |
56 |
{ |
{ |
57 |
int i,j,k; |
int i,j,k; |
58 |
int length = (src1.length() - 1 ) * (src2.length() - 1); |
int length = (this->length() - 1 ) * (src.length() - 1); |
59 |
double *data = new double[length + 1]; |
double *data = new double[length]; |
60 |
ContSignal *res = new ContSignal(data, length); |
ContSignal *res = new ContSignal(data, length); |
61 |
|
|
62 |
for (i = 0 ; i < length; ++i) |
for (i = 0 ; i < length; ++i) |
63 |
for (j = 0, k = i; j < i && k >= 0; ++j, --k) |
for (j = 0, k = i; j < i && k >= 0; ++j, --k) |
64 |
if ( !src1[j] ) |
if ( !(*this)[j] ) |
65 |
(*res)[i] += 0; |
(*res)[i] += 0; |
66 |
else if ( !src2[k] ) |
else if ( !src[k] ) |
67 |
(*res)[i] += 0; |
(*res)[i] += 0; |
68 |
else (*res)[i] += src1[j] * src2[k]; |
else (*res)[i] += (*this)[j] * src[k]; |
|
(*res)[i] = '\0'; |
|
69 |
return *res; |
return *res; |
70 |
} |
} |
71 |
|
|
72 |
ContSignal &ContSignal::concat ( ContSignal &src1, ContSignal &src2 ) |
int ContSignal::min ( ) |
|
{ |
|
|
std::cerr << "We couldn't concatenate two continus signals" << std::endl; |
|
|
exit (1); |
|
|
} |
|
|
|
|
|
ContSignal &ContSignal::hamming ( ContSignal &src ) |
|
|
{ |
|
|
std::cerr << "We couldn't applicate hamming on a continu signal" << std::endl; |
|
|
exit(1); |
|
|
} |
|
|
|
|
|
ContSignal &ContSignal::truncate ( ContSignal &src, const int begin, const int end ) |
|
|
{ |
|
|
std::cerr << "We couldn't truncate a continu signal" << std::endl; |
|
|
exit(1); |
|
|
} |
|
|
|
|
|
int ContSignal::min ( ContSignal &src ) |
|
73 |
{ |
{ |
74 |
std::cerr << "We couldn't search min of a continu signal" << std::endl; |
std::cerr << "We couldn't search min of a continu signal" << std::endl; |
75 |
exit(1); |
exit(1); |
76 |
} |
} |
77 |
|
|
78 |
int ContSignal::max ( ContSignal &src ) |
int ContSignal::max ( ) |
79 |
{ |
{ |
80 |
std::cerr << "We couldn't search max of a continu signal" << std::endl; |
std::cerr << "We couldn't search max of a continu signal" << std::endl; |
81 |
exit(1); |
exit(1); |