| 1 |
MATH Module |
| 2 |
|
| 3 |
Daniel-Constantin Mierla |
| 4 |
|
| 5 |
<[email protected]> |
| 6 |
|
| 7 |
Edited by |
| 8 |
|
| 9 |
Daniel-Constantin Mierla |
| 10 |
|
| 11 |
<[email protected]> |
| 12 |
|
| 13 |
Copyright © 2023 asipto.com |
| 14 |
__________________________________________________________________ |
| 15 |
|
| 16 |
Table of Contents |
| 17 |
|
| 18 |
1. Admin Guide |
| 19 |
|
| 20 |
1. Overview |
| 21 |
2. Dependencies |
| 22 |
|
| 23 |
2.1. Kamailio Modules |
| 24 |
2.2. External Libraries or Applications |
| 25 |
|
| 26 |
3. Functions |
| 27 |
|
| 28 |
3.1. pow(base, power, res) |
| 29 |
3.2. math_logN(x, res) |
| 30 |
3.3. math_log2(x, res) |
| 31 |
3.4. math_log10(x, res) |
| 32 |
3.5. math_sqrt(x, res) |
| 33 |
|
| 34 |
List of Examples |
| 35 |
|
| 36 |
1.1. math_pow usage |
| 37 |
1.2. math_logN usage |
| 38 |
1.3. math_log2 usage |
| 39 |
1.4. math_log10 usage |
| 40 |
1.5. math_sqrt usage |
| 41 |
|
| 42 |
Chapter 1. Admin Guide |
| 43 |
|
| 44 |
Table of Contents |
| 45 |
|
| 46 |
1. Overview |
| 47 |
2. Dependencies |
| 48 |
|
| 49 |
2.1. Kamailio Modules |
| 50 |
2.2. External Libraries or Applications |
| 51 |
|
| 52 |
3. Functions |
| 53 |
|
| 54 |
3.1. pow(base, power, res) |
| 55 |
3.2. math_logN(x, res) |
| 56 |
3.3. math_log2(x, res) |
| 57 |
3.4. math_log10(x, res) |
| 58 |
3.5. math_sqrt(x, res) |
| 59 |
|
| 60 |
1. Overview |
| 61 |
|
| 62 |
This module provides a collection of functions for math operations. |
| 63 |
|
| 64 |
Note that the result values are casted to intger (long value), being |
| 65 |
the type supported by the config variables. |
| 66 |
|
| 67 |
2. Dependencies |
| 68 |
|
| 69 |
2.1. Kamailio Modules |
| 70 |
2.2. External Libraries or Applications |
| 71 |
|
| 72 |
2.1. Kamailio Modules |
| 73 |
|
| 74 |
The following modules must be loaded before this module: |
| 75 |
* none |
| 76 |
|
| 77 |
2.2. External Libraries or Applications |
| 78 |
|
| 79 |
The following libraries or applications must be installed before |
| 80 |
running Kamailio with this module loaded: |
| 81 |
* none |
| 82 |
|
| 83 |
3. Functions |
| 84 |
|
| 85 |
3.1. pow(base, power, res) |
| 86 |
3.2. math_logN(x, res) |
| 87 |
3.3. math_log2(x, res) |
| 88 |
3.4. math_log10(x, res) |
| 89 |
3.5. math_sqrt(x, res) |
| 90 |
|
| 91 |
3.1. pow(base, power, res) |
| 92 |
|
| 93 |
The exponentiation function, computing the base raised to power, |
| 94 |
storing in res. |
| 95 |
|
| 96 |
This function can be used from ANY_ROUTE. |
| 97 |
|
| 98 |
Example 1.1. math_pow usage |
| 99 |
... |
| 100 |
math_pow("2", "10", "$var(res)"); |
| 101 |
$var(base) = 2; |
| 102 |
$var(power) = 10; |
| 103 |
math_pow("$var(base)", "$var(power)", "$var(res)"); |
| 104 |
... |
| 105 |
|
| 106 |
3.2. math_logN(x, res) |
| 107 |
|
| 108 |
The function computes the natural logarithm of x and stores the result |
| 109 |
in res. |
| 110 |
|
| 111 |
This function can be used from ANY_ROUTE. |
| 112 |
|
| 113 |
Example 1.2. math_logN usage |
| 114 |
... |
| 115 |
math_logN("10", "$var(res)"); |
| 116 |
$var(x) = 10; |
| 117 |
math_logN("$var(x)", "$var(res)"); |
| 118 |
... |
| 119 |
|
| 120 |
3.3. math_log2(x, res) |
| 121 |
|
| 122 |
The function computes the base-2 logarithm of x and stores the result |
| 123 |
in res. |
| 124 |
|
| 125 |
This function can be used from ANY_ROUTE. |
| 126 |
|
| 127 |
Example 1.3. math_log2 usage |
| 128 |
... |
| 129 |
math_log2("16", "$var(res)"); |
| 130 |
$var(x) = 16; |
| 131 |
math_log2("$var(x)", "$var(res)"); |
| 132 |
... |
| 133 |
|
| 134 |
3.4. math_log10(x, res) |
| 135 |
|
| 136 |
The function computes the base-10 logarithm of x and stores the result |
| 137 |
in res. |
| 138 |
|
| 139 |
This function can be used from ANY_ROUTE. |
| 140 |
|
| 141 |
Example 1.4. math_log10 usage |
| 142 |
... |
| 143 |
math_log10("100", "$var(res)"); |
| 144 |
$var(x) = 100; |
| 145 |
math_log10("$var(x)", "$var(res)"); |
| 146 |
... |
| 147 |
|
| 148 |
3.5. math_sqrt(x, res) |
| 149 |
|
| 150 |
The function computes the square root of x and stores the result in |
| 151 |
res. |
| 152 |
|
| 153 |
This function can be used from ANY_ROUTE. |
| 154 |
|
| 155 |
Example 1.5. math_sqrt usage |
| 156 |
... |
| 157 |
math_sqrt("16", "$var(res)"); |
| 158 |
$var(x) = 16; |
| 159 |
math_sqrt("$var(x)", "$var(res)"); |
| 160 |
... |