A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
spectrum-value.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 CTTC
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
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, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Nicola Baldo <nbaldo@cttc.es>
19  */
20 
21 #ifndef SPECTRUM_VALUE_H
22 #define SPECTRUM_VALUE_H
23 
24 #include <ns3/ptr.h>
25 #include <ns3/simple-ref-count.h>
26 #include <ns3/spectrum-model.h>
27 #include <ostream>
28 #include <vector>
29 
30 namespace ns3 {
31 
32 
33 typedef std::vector<double> Values;
34 
57 class SpectrumValue : public SimpleRefCount<SpectrumValue>
58 {
59 public:
78 
79 
80  SpectrumValue ();
81 
82 
90  double& operator[] (size_t index);
91 
92 
93 
98  SpectrumModelUid_t GetSpectrumModelUid () const;
99 
100 
106 
107 
113  Bands::const_iterator ConstBandsBegin () const;
114 
120  Bands::const_iterator ConstBandsEnd () const;
121 
122 
128  Values::const_iterator ConstValuesBegin () const;
129 
135  Values::const_iterator ConstValuesEnd () const;
136 
142  Values::iterator ValuesBegin ();
143 
149  Values::iterator ValuesEnd ();
150 
151 
152 
161  friend SpectrumValue operator+ (const SpectrumValue& lhs, const SpectrumValue& rhs);
162 
163 
172  friend SpectrumValue operator+ (const SpectrumValue& lhs, double rhs);
173 
182  friend SpectrumValue operator+ (double lhs, const SpectrumValue& rhs);
183 
184 
193  friend SpectrumValue operator- (const SpectrumValue& lhs, const SpectrumValue& rhs);
194 
203  friend SpectrumValue operator- (const SpectrumValue& lhs, double rhs);
204 
213  friend SpectrumValue operator- (double lhs, const SpectrumValue& rhs);
214 
223  friend SpectrumValue operator* (const SpectrumValue& lhs, const SpectrumValue& rhs);
224 
233  friend SpectrumValue operator* (const SpectrumValue& lhs, double rhs);
234 
243  friend SpectrumValue operator* (double lhs, const SpectrumValue& rhs);
244 
253  friend SpectrumValue operator/ (const SpectrumValue& lhs, const SpectrumValue& rhs);
254 
263  friend SpectrumValue operator/ (const SpectrumValue& lhs, double rhs);
264 
273  friend SpectrumValue operator/ (double lhs, const SpectrumValue& rhs);
274 
281  friend SpectrumValue operator+ (const SpectrumValue& rhs);
282 
289  friend SpectrumValue operator- (const SpectrumValue& rhs);
290 
291 
301  SpectrumValue operator<< (int n) const;
302 
312  SpectrumValue operator>> (int n) const;
313 
314 
315 
324 
333 
342 
351 
360  SpectrumValue& operator+= (double rhs);
361 
370  SpectrumValue& operator-= (double rhs);
371 
380  SpectrumValue& operator*= (double rhs);
381 
390  SpectrumValue& operator/= (double rhs);
391 
392 
401  SpectrumValue& operator= (double rhs);
402 
403 
404 
412  friend double Norm (const SpectrumValue& x);
413 
414 
422  friend double Sum (const SpectrumValue& x);
423 
424 
431  friend double Prod (const SpectrumValue& x);
432 
433 
442  friend SpectrumValue Pow (const SpectrumValue& lhs, double rhs);
443 
444 
453  friend SpectrumValue Pow (double lhs, const SpectrumValue& rhs);
454 
462  friend SpectrumValue Log10 (const SpectrumValue& arg);
463 
464 
472  friend SpectrumValue Log2 (const SpectrumValue& arg);
473 
481  friend SpectrumValue Log (const SpectrumValue& arg);
482 
490  friend double Integral (const SpectrumValue& arg);
491 
496  Ptr<SpectrumValue> Copy () const;
497 
498 
499 
500 private:
501  void Add (const SpectrumValue& x);
502  void Add (double s);
503  void Subtract (const SpectrumValue& x);
504  void Subtract (double s);
505  void Multiply (const SpectrumValue& x);
506  void Multiply (double s);
507  void Divide (const SpectrumValue& x);
508  void Divide (double s);
509  void ChangeSign ();
510  void ShiftLeft (int n);
511  void ShiftRight (int n);
512  void Pow (double exp);
513  void Exp (double base);
514  void Log10 ();
515  void Log2 ();
516  void Log ();
517 
518  Ptr<const SpectrumModel> m_spectrumModel;
519 
520 
528  Values m_values;
529 
530 
531 };
532 
533 std::ostream& operator << (std::ostream& os, const SpectrumValue& pvf);
534 
535 double Norm (const SpectrumValue& x);
536 double Sum (const SpectrumValue& x);
537 double Prod (const SpectrumValue& x);
538 SpectrumValue Pow (const SpectrumValue& lhs, double rhs);
539 SpectrumValue Pow (double lhs, const SpectrumValue& rhs);
540 SpectrumValue Log10 (const SpectrumValue& arg);
541 SpectrumValue Log2 (const SpectrumValue& arg);
542 SpectrumValue Log (const SpectrumValue& arg);
543 double Integral (const SpectrumValue& arg);
544 
545 
546 } // namespace ns3
547 
548 #endif /* SPECTRUM_VALUE_H */
Values::const_iterator ConstValuesEnd() const
SpectrumValue & operator*=(const SpectrumValue &rhs)
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
SpectrumValue & operator/=(const SpectrumValue &rhs)
double Integral(const SpectrumValue &arg)
SpectrumValue operator>>(int n) const
SpectrumValue & operator+=(const SpectrumValue &rhs)
SpectrumModelUid_t GetSpectrumModelUid() const
friend SpectrumValue operator-(const SpectrumValue &lhs, const SpectrumValue &rhs)
Values::iterator ValuesEnd()
friend SpectrumValue Log(const SpectrumValue &arg)
friend SpectrumValue Log10(const SpectrumValue &arg)
friend SpectrumValue operator+(const SpectrumValue &lhs, const SpectrumValue &rhs)
SpectrumValue & operator-=(const SpectrumValue &rhs)
Bands::const_iterator ConstBandsEnd() const
SpectrumValue operator<<(int n) const
Ptr< const SpectrumModel > GetSpectrumModel() const
friend SpectrumValue Pow(const SpectrumValue &lhs, double rhs)
SpectrumValue Pow(double lhs, const SpectrumValue &rhs)
friend double Prod(const SpectrumValue &x)
Bands::const_iterator ConstBandsBegin() const
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:43
friend SpectrumValue operator/(const SpectrumValue &lhs, const SpectrumValue &rhs)
SpectrumValue Log10(const SpectrumValue &arg)
friend SpectrumValue Log2(const SpectrumValue &arg)
double & operator[](size_t index)
Values::iterator ValuesBegin()
SpectrumValue Log(const SpectrumValue &arg)
double Norm(const SpectrumValue &x)
SpectrumValue & operator=(double rhs)
double Sum(const SpectrumValue &x)
Ptr< SpectrumValue > Copy() const
friend double Integral(const SpectrumValue &arg)
Values::const_iterator ConstValuesBegin() const
friend double Sum(const SpectrumValue &x)
friend double Norm(const SpectrumValue &x)
friend SpectrumValue operator*(const SpectrumValue &lhs, const SpectrumValue &rhs)
SpectrumValue Log2(const SpectrumValue &arg)
Set of values corresponding to a given SpectrumModel.
A template-based reference counting class.
double Prod(const SpectrumValue &x)