A Discrete-Event Network Simulator
API
spectrum-value.h
Go to the documentation of this file.
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 
99  const double& operator[] (size_t index) const;
100 
101 
107 
108 
114 
115 
121  Bands::const_iterator ConstBandsBegin () const;
122 
128  Bands::const_iterator ConstBandsEnd () const;
129 
130 
136  Values::const_iterator ConstValuesBegin () const;
137 
143  Values::const_iterator ConstValuesEnd () const;
144 
150  Values::iterator ValuesBegin ();
151 
157  Values::iterator ValuesEnd ();
158 
159 
160 
169  friend SpectrumValue operator+ (const SpectrumValue& lhs, const SpectrumValue& rhs);
170 
171 
180  friend SpectrumValue operator+ (const SpectrumValue& lhs, double rhs);
181 
190  friend SpectrumValue operator+ (double lhs, const SpectrumValue& rhs);
191 
192 
201  friend SpectrumValue operator- (const SpectrumValue& lhs, const SpectrumValue& rhs);
202 
211  friend SpectrumValue operator- (const SpectrumValue& lhs, double rhs);
212 
221  friend SpectrumValue operator- (double lhs, const SpectrumValue& rhs);
222 
231  friend SpectrumValue operator* (const SpectrumValue& lhs, const SpectrumValue& rhs);
232 
241  friend SpectrumValue operator* (const SpectrumValue& lhs, double rhs);
242 
251  friend SpectrumValue operator* (double lhs, const SpectrumValue& rhs);
252 
261  friend SpectrumValue operator/ (const SpectrumValue& lhs, const SpectrumValue& rhs);
262 
271  friend SpectrumValue operator/ (const SpectrumValue& lhs, double rhs);
272 
281  friend SpectrumValue operator/ (double lhs, const SpectrumValue& rhs);
282 
289  friend SpectrumValue operator+ (const SpectrumValue& rhs);
290 
297  friend SpectrumValue operator- (const SpectrumValue& rhs);
298 
299 
309  SpectrumValue operator<< (int n) const;
310 
320  SpectrumValue operator>> (int n) const;
321 
322 
323 
332 
341 
350 
359 
368  SpectrumValue& operator+= (double rhs);
369 
378  SpectrumValue& operator-= (double rhs);
379 
388  SpectrumValue& operator*= (double rhs);
389 
398  SpectrumValue& operator/= (double rhs);
399 
400 
409  SpectrumValue& operator= (double rhs);
410 
411 
412 
420  friend double Norm (const SpectrumValue& x);
421 
422 
430  friend double Sum (const SpectrumValue& x);
431 
432 
439  friend double Prod (const SpectrumValue& x);
440 
441 
450  friend SpectrumValue Pow (const SpectrumValue& lhs, double rhs);
451 
452 
461  friend SpectrumValue Pow (double lhs, const SpectrumValue& rhs);
462 
470  friend SpectrumValue Log10 (const SpectrumValue& arg);
471 
472 
480  friend SpectrumValue Log2 (const SpectrumValue& arg);
481 
489  friend SpectrumValue Log (const SpectrumValue& arg);
490 
498  friend double Integral (const SpectrumValue& arg);
499 
504  Ptr<SpectrumValue> Copy () const;
505 
514  typedef void (* TracedCallback)(Ptr<SpectrumValue> value);
515 
516 
517 private:
518  void Add (const SpectrumValue& x);
519  void Add (double s);
520  void Subtract (const SpectrumValue& x);
521  void Subtract (double s);
522  void Multiply (const SpectrumValue& x);
523  void Multiply (double s);
524  void Divide (const SpectrumValue& x);
525  void Divide (double s);
526  void ChangeSign ();
527  void ShiftLeft (int n);
528  void ShiftRight (int n);
529  void Pow (double exp);
530  void Exp (double base);
531  void Log10 ();
532  void Log2 ();
533  void Log ();
534 
536 
537 
545  Values m_values;
546 
547 
548 };
549 
550 std::ostream& operator << (std::ostream& os, const SpectrumValue& pvf);
551 
552 double Norm (const SpectrumValue& x);
553 double Sum (const SpectrumValue& x);
554 double Prod (const SpectrumValue& x);
555 SpectrumValue Pow (const SpectrumValue& lhs, double rhs);
556 SpectrumValue Pow (double lhs, const SpectrumValue& rhs);
557 SpectrumValue Log10 (const SpectrumValue& arg);
558 SpectrumValue Log2 (const SpectrumValue& arg);
559 SpectrumValue Log (const SpectrumValue& arg);
560 double Integral (const SpectrumValue& arg);
561 
562 
563 } // namespace ns3
564 
565 #endif /* SPECTRUM_VALUE_H */
Values::const_iterator ConstValuesEnd() const
SpectrumValue & operator*=(const SpectrumValue &rhs)
Multiply *this by the Right Hand Side of the operator, component by component.
uint32_t SpectrumModelUid_t
SpectrumValue & operator/=(const SpectrumValue &rhs)
Divide *this by the Right Hand Side of the operator, component by component.
double Integral(const SpectrumValue &arg)
void Subtract(const SpectrumValue &x)
SpectrumValue operator>>(int n) const
right shift operator
SpectrumValue & operator+=(const SpectrumValue &rhs)
Add the Right Hand Side of the operator to *this, component by component.
Forward calls to a chain of Callback.
SpectrumModelUid_t GetSpectrumModelUid() const
friend SpectrumValue operator-(const SpectrumValue &lhs, const SpectrumValue &rhs)
subtraction operator
std::vector< double > Values
Values::iterator ValuesEnd()
void Divide(const SpectrumValue &x)
void Multiply(const SpectrumValue &x)
friend SpectrumValue operator+(const SpectrumValue &lhs, const SpectrumValue &rhs)
addition operator
SpectrumValue & operator-=(const SpectrumValue &rhs)
Subtract the Right Hand Side of the operator from *this, component by component.
Bands::const_iterator ConstBandsEnd() const
SpectrumValue operator<<(int n) const
left shift operator
Ptr< const SpectrumModel > GetSpectrumModel() const
friend SpectrumValue Pow(const SpectrumValue &lhs, double rhs)
void Add(const SpectrumValue &x)
SpectrumValue Pow(double lhs, const SpectrumValue &rhs)
Ptr< const SpectrumModel > m_spectrumModel
void ShiftRight(int n)
friend double Prod(const SpectrumValue &x)
Bands::const_iterator ConstBandsBegin() const
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
Every class exported by the ns3 library is enclosed in the ns3 namespace.
friend SpectrumValue operator/(const SpectrumValue &lhs, const SpectrumValue &rhs)
division component-by-component
SpectrumValue Log10(const SpectrumValue &arg)
Values m_values
Set of values which implement the codomain of the functions in the Function Space defined by Spectrum...
double & operator[](size_t index)
Access value at given frequency index.
Values::iterator ValuesBegin()
SpectrumValue Log(const SpectrumValue &arg)
double Norm(const SpectrumValue &x)
SpectrumValue & operator=(double rhs)
Assign each component of *this to the value of the Right Hand Side of the operator.
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)
multiplication component-by-component (Schur product)
SpectrumValue Log2(const SpectrumValue &arg)
Set of values corresponding to a given SpectrumModel.
A template-based reference counting class.
void Exp(double base)
double Prod(const SpectrumValue &x)