A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
spectrum-value.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 CTTC
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Nicola Baldo <nbaldo@cttc.es>
18 */
19
20#ifndef SPECTRUM_VALUE_H
21#define SPECTRUM_VALUE_H
22
23#include "spectrum-model.h"
24
25#include <ns3/ptr.h>
26#include <ns3/simple-ref-count.h>
27
28#include <ostream>
29#include <vector>
30
31namespace ns3
32{
33
35typedef std::vector<double> Values;
36
60class SpectrumValue : public SimpleRefCount<SpectrumValue>
61{
62 public:
81
83
91 double& operator[](size_t index);
92
100 const double& operator[](size_t index) const;
101
107
113
119 Bands::const_iterator ConstBandsBegin() const;
120
126 Bands::const_iterator ConstBandsEnd() const;
127
133 Values::const_iterator ConstValuesBegin() const;
134
140 Values::const_iterator ConstValuesEnd() const;
141
147 Values::iterator ValuesBegin();
148
154 Values::iterator ValuesEnd();
155
160 uint32_t GetValuesN() const;
161
167 const double& ValuesAt(uint32_t pos) const;
168
177 friend SpectrumValue operator+(const SpectrumValue& lhs, const SpectrumValue& rhs);
178
187 friend SpectrumValue operator+(const SpectrumValue& lhs, double rhs);
188
197 friend SpectrumValue operator+(double lhs, const SpectrumValue& rhs);
198
207 friend SpectrumValue operator-(const SpectrumValue& lhs, const SpectrumValue& rhs);
208
217 friend SpectrumValue operator-(const SpectrumValue& lhs, double rhs);
218
227 friend SpectrumValue operator-(double lhs, const SpectrumValue& rhs);
228
237 friend SpectrumValue operator*(const SpectrumValue& lhs, const SpectrumValue& rhs);
238
247 friend SpectrumValue operator*(const SpectrumValue& lhs, double rhs);
248
257 friend SpectrumValue operator*(double lhs, const SpectrumValue& rhs);
258
267 friend SpectrumValue operator/(const SpectrumValue& lhs, const SpectrumValue& rhs);
268
277 friend SpectrumValue operator/(const SpectrumValue& lhs, double rhs);
278
287 friend SpectrumValue operator/(double lhs, const SpectrumValue& rhs);
288
295 friend SpectrumValue operator+(const SpectrumValue& rhs);
296
303 friend SpectrumValue operator-(const SpectrumValue& rhs);
304
314 SpectrumValue operator<<(int n) const;
315
325 SpectrumValue operator>>(int n) const;
326
335
344
353
362
371 SpectrumValue& operator+=(double rhs);
372
381 SpectrumValue& operator-=(double rhs);
382
391 SpectrumValue& operator*=(double rhs);
392
401 SpectrumValue& operator/=(double rhs);
402
411 SpectrumValue& operator=(double rhs);
412
420 friend double Norm(const SpectrumValue& x);
421
429 friend double Sum(const SpectrumValue& x);
430
437 friend double Prod(const SpectrumValue& x);
438
447 friend SpectrumValue Pow(const SpectrumValue& lhs, double rhs);
448
456 friend SpectrumValue Pow(double lhs, const SpectrumValue& rhs);
457
465 friend SpectrumValue Log10(const SpectrumValue& arg);
466
474 friend SpectrumValue Log2(const SpectrumValue& arg);
475
483 friend SpectrumValue Log(const SpectrumValue& arg);
484
492 friend double Integral(const SpectrumValue& arg);
493
498 Ptr<SpectrumValue> Copy() const;
499
508 typedef void (*TracedCallback)(Ptr<SpectrumValue> value);
509
510 private:
515 void Add(const SpectrumValue& x);
520 void Add(double s);
525 void Subtract(const SpectrumValue& x);
530 void Subtract(double s);
535 void Multiply(const SpectrumValue& x);
540 void Multiply(double s);
545 void Divide(const SpectrumValue& x);
550 void Divide(double s);
554 void ChangeSign();
559 void ShiftLeft(int n);
564 void ShiftRight(int n);
570 void Pow(double exp);
577 void Exp(double base);
581 void Log10();
585 void Log2();
589 void Log();
590
592
601};
602
603std::ostream& operator<<(std::ostream& os, const SpectrumValue& pvf);
604
605double Norm(const SpectrumValue& x);
606double Sum(const SpectrumValue& x);
607double Prod(const SpectrumValue& x);
608SpectrumValue Pow(const SpectrumValue& lhs, double rhs);
609SpectrumValue Pow(double lhs, const SpectrumValue& rhs);
613double Integral(const SpectrumValue& arg);
614
615} // namespace ns3
616
617#endif /* SPECTRUM_VALUE_H */
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
A template-based reference counting class.
Set of values corresponding to a given SpectrumModel.
friend SpectrumValue operator-(const SpectrumValue &lhs, const SpectrumValue &rhs)
subtraction operator
double & operator[](size_t index)
Access value at given frequency index.
void Subtract(const SpectrumValue &x)
Subtracts a SpectrumValue (element by element subtraction)
Values::const_iterator ConstValuesBegin() const
friend SpectrumValue operator+(const SpectrumValue &lhs, const SpectrumValue &rhs)
addition operator
friend double Prod(const SpectrumValue &x)
Bands::const_iterator ConstBandsEnd() const
void Divide(const SpectrumValue &x)
Divides by a SpectrumValue (element to element division)
friend double Norm(const SpectrumValue &x)
friend double Integral(const SpectrumValue &arg)
SpectrumValue & operator=(double rhs)
Assign each component of *this to the value of the Right Hand Side of the operator.
Values::iterator ValuesBegin()
void Exp(double base)
Modifies each element so that it is the base raised to each element value.
Bands::const_iterator ConstBandsBegin() const
void ChangeSign()
Change the values sign.
friend SpectrumValue Log2(const SpectrumValue &arg)
friend SpectrumValue Log10(const SpectrumValue &arg)
SpectrumValue operator<<(int n) const
left shift operator
void ShiftLeft(int n)
Shift the values to the left.
Ptr< SpectrumValue > Copy() const
friend SpectrumValue Log(const SpectrumValue &arg)
friend SpectrumValue operator/(const SpectrumValue &lhs, const SpectrumValue &rhs)
division component-by-component
Values m_values
Set of values which implement the codomain of the functions in the Function Space defined by Spectrum...
uint32_t GetValuesN() const
Get the number of values stored in the array.
Values::iterator ValuesEnd()
Ptr< const SpectrumModel > GetSpectrumModel() const
SpectrumValue & operator*=(const SpectrumValue &rhs)
Multiply *this by the Right Hand Side of the operator, component by component.
Ptr< const SpectrumModel > m_spectrumModel
The spectrum model.
void ShiftRight(int n)
Shift the values to the right.
friend SpectrumValue operator*(const SpectrumValue &lhs, const SpectrumValue &rhs)
multiplication component-by-component (Schur product)
friend double Sum(const SpectrumValue &x)
void Add(const SpectrumValue &x)
Add a SpectrumValue (element to element addition)
void Multiply(const SpectrumValue &x)
Multiplies for a SpectrumValue (element to element multiplication)
SpectrumModelUid_t GetSpectrumModelUid() const
SpectrumValue & operator/=(const SpectrumValue &rhs)
Divide *this by the Right Hand Side of the operator, component by component.
SpectrumValue & operator+=(const SpectrumValue &rhs)
Add the Right Hand Side of the operator to *this, component by component.
Values::const_iterator ConstValuesEnd() const
SpectrumValue & operator-=(const SpectrumValue &rhs)
Subtract the Right Hand Side of the operator from *this, component by component.
SpectrumValue operator>>(int n) const
right shift operator
friend SpectrumValue Pow(const SpectrumValue &lhs, double rhs)
const double & ValuesAt(uint32_t pos) const
Get the value element at the position.
Forward calls to a chain of Callback.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
SpectrumValue Pow(double lhs, const SpectrumValue &rhs)
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159
double Integral(const SpectrumValue &arg)
SpectrumValue Log2(const SpectrumValue &arg)
SpectrumValue Log10(const SpectrumValue &arg)
double Norm(const SpectrumValue &x)
SpectrumValue Log(const SpectrumValue &arg)
double Prod(const SpectrumValue &x)
std::vector< double > Values
Container for element values.
double Sum(const SpectrumValue &x)