/[marvin]/marvin/src/libsip/type/discsignal.cc
ViewVC logotype

Diff of /marvin/src/libsip/type/discsignal.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by exos, Thu Sep 11 22:45:21 2003 UTC revision 1.12 by hannibal, Sat Sep 13 18:14:20 2003 UTC
# Line 78  DiscSignal &DiscSignal::sub ( DiscSignal Line 78  DiscSignal &DiscSignal::sub ( DiscSignal
78    return *res;    return *res;
79  }  }
80    
81  DiscSignal &DiscSignal::mult ( DiscSignal &src1, DiscSignal &src2 )  DiscSignal &DiscSignal::mult ( DiscSignal &src )
82  {  {
83    int   it;    int   it;
84    int length = maximum((src1.length()), (src2.length()));    int length = maximum((this->length()), (src.length()));
85    double *data = new double[length + 1];    double *data = new double[length];
86    DiscSignal *res = new DiscSignal(data, length);    DiscSignal *res = new DiscSignal(data, length);
87    
88    for (it = 0; src1[it] && src2[it] && it < length; ++it)    for (it = 0; (*this)[it] && src[it] && it < length; ++it)
89      (*res)[it] = src1[it] * src2[it];      (*res)[it] = (*this)[it] * src[it];
90    if ( !src2[it] )    if ( !src[it] )
91      for ( ;it < length; ++it)      for ( ;it < length; ++it)
92        (*res)[it] = src1[it];        (*res)[it] = (*this)[it];
93    if ( !src1[it] )    if ( !(*this)[it] )
94      for ( ;it < length; ++it)      for ( ;it < length; ++it)
95        (*res)[it] = src2[it];        (*res)[it] = src[it];
96    return *res;    return *res;
97  }  }
98    
99  DiscSignal &DiscSignal::concat ( DiscSignal &src1, DiscSignal &src2 )  DiscSignal &DiscSignal::concat ( DiscSignal &src )
100  {  {
101    int   it1, it2;    int   it1, it2;
102    int length = src1.length() + src2.length();    int length = this->length() + src.length();
103    double  *data = new double[length + 1];    double  *data = new double[length];
104    DiscSignal *res = new DiscSignal(data, length);    DiscSignal *res = new DiscSignal(data, length);
105    for (it1 = 0; it1 < src1.length(); ++it1)    for (it1 = 0; it1 < this->length(); ++it1)
106      (*res)[it1] = src1[it1];      (*res)[it1] = (*this)[it1];
107    for (it2 = 0; it2 < src2.length(); ++it2, ++it1)    for (it2 = 0; it2 < src.length(); ++it2, ++it1)
108      (*res)[it1] = src2[it2];      (*res)[it1] = src[it2];
109    return *res;    return *res;
110  }  }
111    
# Line 129  DiscSignal &DiscSignal::hamming () const Line 129  DiscSignal &DiscSignal::hamming () const
129    for (it = 0; it < this->length(); ++it)    for (it = 0; it < this->length(); ++it)
130      (*res)[it] = (*this)[it] * (0.54 - 0.46 * cos(2 * PI * it /      (*res)[it] = (*this)[it] * (0.54 - 0.46 * cos(2 * PI * it /
131                                                    (this->length() - 1)));                                                    (this->length() - 1)));
132      res[it] = '\0';
133      return *res;
134    }
135    
136    DiscSignal &DiscSignal::truncate (const int begin, const int end )
137    {
138      assert (end < begin);
139      int it;
140      int length = end - begin;
141      double  *data = new double[length];
142      DiscSignal *res = new DiscSignal(data, length);
143      for (it = 0; it < length; ++it)
144        (*res)[it] = (*this)[begin + it];
145    return *res;    return *res;
146  }  }
147    
# Line 136  int DiscSignal::min ( ) Line 149  int DiscSignal::min ( )
149  {  {
150    double min = DBL_MAX;    double min = DBL_MAX;
151    int res = -1;    int res = -1;
152        int length = this->length();
153    for (int i = 0; (*this)[i]; ++i)  
154      for (int i = 0; (*this)[i] < length; ++i)
155      if ((*this)[i] < min)      if ((*this)[i] < min)
156        {        {
157          res = i;          res = i;
# Line 149  int DiscSignal::min ( ) Line 163  int DiscSignal::min ( )
163  double DiscSignal::min_val ( )  double DiscSignal::min_val ( )
164  {  {
165    double min = DBL_MAX;    double min = DBL_MAX;
166      int length = this->length();
167    
168    for (int i = 0; (*this)[i]; ++i)    for (int i = 0; (*this)[i] < length; ++i)
169      if ((*this)[i] < min)      if ((*this)[i] < min)
170          min = (*this)[i];          min = (*this)[i];
171    return min;    return min;
# Line 160  int DiscSignal::max () Line 175  int DiscSignal::max ()
175  {  {
176    double max = DBL_MIN;    double max = DBL_MIN;
177    int res = -1;    int res = -1;
178      int length = this->length();
179        
180    for (int i = 0; (*this)[i]; ++i)    for (int i = 0; (*this)[i] < length; ++i)
181      if ( (*this)[i] > max )      if ( (*this)[i] > max )
182        {        {
183          res = i;          res = i;
# Line 173  int DiscSignal::max () Line 189  int DiscSignal::max ()
189  double DiscSignal::max_val ( )  double DiscSignal::max_val ( )
190  {  {
191    double max = DBL_MIN;    double max = DBL_MIN;
192        int length = this->length();
193    for (int i = 0; (*this)[i]; ++i)  
194      for (int i = 0; (*this)[i] < length; ++i)
195      if ((*this)[i] > max )      if ((*this)[i] > max )
196        max = (*this)[i];        max = (*this)[i];
197    return max;    return max;

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26