mathematical equation implmentation in c++
Hello,
I need to implement the following math conversion in the c++. I am looking for simple function. Could you help me with this., I am not much aware of the maths functionalities available in c++
1. Need to convert dBns to ns and the in the xml requirements, I see the formula as : 10^(0.8 * x)
2. Other conversion is similar(mBradians to radians) : 10 ^ (0.001 * x)
Then I need the convert the radians to degrees
Thanks a lot
pdk
Re: mathematical equation implmentation in c++
What is dBns? ns? mBradians?
Re: mathematical equation implmentation in c++
Quote:
Originally Posted by
VictorN
What is dBns? ns? mBradians?
DeciBel nano Secs to Nano Secs. It may not be much relevance as the conversion formula is shown above .
I just want to implement the conversion formula in c++
Re: mathematical equation implmentation in c++
And the conversion formula is in the excel. Any idea, the symbol "^" mean in excel ?
It is very help ful if I get this info as soon as possible as I have release next week ! :d
Re: mathematical equation implmentation in c++
It is the same as function power()
Re: mathematical equation implmentation in c++
For C++, use pow() function instead of ^ http://www.cplusplus.com/reference/cmath/pow/
so 10 ^ (0.8 * X) becomes pow(10, 0.8 * X). And similar for the other.
To convert radians to degrees (and vice versa), always remember that 360 deg = 2 * pi radians. So 1 radian is 360 / (2 * pi) degrees which is 180 / pi degrees. So y radians are y * 180 / pi degrees.
To get the value of pi without having to define a constant, use the value of M_PI as explained in https://docs.microsoft.com/en-us/cpp...s?view=vs-2019
Re: mathematical equation implmentation in c++
Thankyou very much Kaud. :) Very helpful .
Re: mathematical equation implmentation in c++
Another doubt generic not c++ :):
To convert nsDb to ns, the formula given is dBns to ns : 10^(0.8 * x) .
From the look of it, it does not look right ?
Because the other formula, (mBradians to radians) : 10 ^ (0.001 * x) looks ok, because the mB = .001 Bell
my maths skills have been rusty, so very helpful to get some inputs here. :)
Re: mathematical equation implmentation in c++
decibel - or bel - has got not nothing to do with time or angles and everything to do with power ratios. radians/degrees has got nothing to do with (deci)bel. A decibel is 1/10 of a bel.
See https://en.wikipedia.org/wiki/Metric_prefix for a list of SI prefixes.
To do a conversion from one type to another, they must be a mathematical relationship between them. ie there is one between radians and degrees, but not between decibel and sec(ond)s.
What are you trying to do? You said in post #3 that you had the formulas and all you needed was help implementing them? If the formulas are now not correct, you need to determine what the original number represents in terms of a unit (mass, length, time etc) and its prefix. Then determine what the required number is to represent. Once you know that, then the required conversion formula can be obtained.
Re: mathematical equation implmentation in c++
Thanks a lot kaud , for the reply . These formulas are provided in requirements. But req are in initial stages and may not be correct.
The formula I showed above , 10^(0.8 * x) , is to convert "nanoSecond DB" to "nanosecond" ? Looks incorrect and even sample values were coming very high. so I am thinking it may be some typo in requirements ?
Re: mathematical equation implmentation in c++
If DB is for Decibel, then nanoSecond Decibel is a nonsense. A nano Decibel would make sense which would be 10 ^ -10 Bel. But in physical terms, that's such a very low power level that something doesn't seem right.
Where are these formulas coming from? What exactly are you trying to do?
Re: mathematical equation implmentation in c++
Quote:
Originally Posted by
pdk5
To convert nsDb to ns, the formula given is dBns to ns : 10^(0.8 * x) .
From the look of it, it does not look right ?
Because the other formula, (mBradians to radians) : 10 ^ (0.001 * x) looks ok, because the mB = .001 Bell
Note that there's a slight difference of notation between dBns and mBradians.
It's easier to see if you rewrite these like dB(ns) and mB(radians). The first would be the dB value corresponding to a ratio relative to 1 nanosecond. The second would be the mB value corresponding to a ratio relative to 1 radian. It could explain why the formulas do not conform logically.
Re: mathematical equation implmentation in c++
Quote:
Originally Posted by
2kaud
If DB is for Decibel, then nanoSecond Decibel is a nonsense. A nano Decibel would make sense which would be 10 ^ -10 Bel. But in physical terms, that's such a very low power level that something doesn't seem right.
Where are these formulas coming from? What exactly are you trying to do?
- The "nanosec DB" is the unit received for the Delay spread in the LTE/5g at a pixel from the basestation. In our tool, they want to display with the unit of microseconds. rather than nanosec DB. I have not much worked on Physical layer stuff. But even then , this unit looks bit odd for me. I mean to use DB on nanosecs ?
- And the other unit is from "mBradians" to "radians" is for the Angular spread data .
Re: mathematical equation implmentation in c++
... continuing from #12:
The second formula would be
x = 1000 * log(ratio) // mB formula
=>
ratio = 10 ^ (x/1000)
so it looks right.
Re: mathematical equation implmentation in c++
Quote:
Originally Posted by
wolle
The second formula would be
x = 1000 * log(ratio)
=>
ratio = 10 ^ (x/1000)
Thanks , but whatabout the first one ? :)
Re: mathematical equation implmentation in c++
Quote:
Originally Posted by
pdk5
Thanks , but whatabout the first one ? :)
Well, if you have a time measure in nanoseconds and take the dB measure of that relative to 1 nanosecond you get exactly the same dB measure as if you instead have the measure in seconds relative to 1 second. In both cases you would use the same decibel formula,
ratio = 10 ^ (x/10)
to recover the ratio from the dB value. You just have to remember that the ratio in the nanosecond case has to be multiplied by 10^-9 to get the time in seconds.
The first of your formulas can be rewritten as
ratio = 10 ^ (8*x/10)
This is the ordinary dB formula but with a strange constant 8. I have no idea where it comes from. I first suspected it may have something to do with the 1 nanosecond reference but I have not been able to find out how. Maybe it's some application constant, perhaps a cubic volume with sides 2, I don't know. I suggest you ask your costumer for a clarification.
Re: mathematical equation implmentation in c++
Thanks a lot wolle for getting back and explaining in detail. Very helpful . :)
Re: mathematical equation implmentation in c++
[Subject to wolle's posts, I've mugged up on the use of dB and found that it can indeed be used to express a change in value as well as ratios of power. When I studied Physics, we only used dB as a power ratio (mainly audio), hence my earlier posts. Sorry for my previous misleading posts. You learn something new every day! ]
Re: mathematical equation implmentation in c++
Thanks a lot kaud :) for the response . and discussions/views here are really helpul to learn in better way :)