changed hex_metadata.config
 
@@ -1,132 +1,13 @@
1
1
{<<"app">>,<<"math">>}.
2
2
{<<"build_tools">>,[<<"mix">>]}.
3
3
{<<"description">>,
4
- <<84,104,101,32,77,97,116,104,32,109,111,100,117,108,101,32,97,100,100,115,
5
- 32,109,97,110,121,32,117,115,101,102,117,108,32,102,117,110,99,116,105,111,
6
- 110,115,32,116,104,97,116,32,101,120,116,101,110,100,32,69,108,105,120,105,
7
- 114,39,115,32,115,116,97,110,100,97,114,100,32,108,105,98,114,97,114,121,
8
- 46,10,10,45,32,71,101,110,101,114,97,108,32,70,117,110,99,116,105,111,110,
9
- 115,10,32,32,226,128,162,32,97,32,60,126,62,32,98,32,67,111,109,112,97,114,
10
- 105,115,111,110,32,111,102,32,102,108,111,97,116,115,44,32,116,111,32,99,
11
- 104,101,99,107,32,105,102,32,116,104,101,121,32,97,114,101,32,95,110,101,
12
- 97,114,108,121,95,32,101,113,117,97,108,46,10,32,32,226,128,162,32,77,97,
13
- 116,104,46,112,111,119,40,120,44,32,110,41,32,65,114,105,116,104,109,101,
14
- 116,105,99,32,101,120,112,111,110,101,110,116,105,97,116,105,111,110,46,32,
15
- 87,111,114,107,115,32,98,111,116,104,32,119,105,116,104,32,105,110,116,101,
16
- 103,101,114,32,112,111,119,101,114,115,32,97,110,100,32,102,108,111,97,116,
17
- 115,46,10,32,32,226,128,162,32,77,97,116,104,46,115,113,114,116,40,120,41,
18
- 32,84,104,101,32,115,113,117,97,114,101,32,114,111,111,116,32,111,102,32,
19
- 120,46,10,32,32,226,128,162,32,77,97,116,104,46,110,116,104,95,114,111,111,
20
- 116,40,120,44,32,110,41,32,84,104,101,32,110,45,116,104,32,114,111,111,116,
21
- 32,111,102,32,120,46,10,32,32,226,128,162,32,77,97,116,104,46,105,115,113,
22
- 114,116,40,120,41,32,32,84,104,101,32,105,110,116,101,103,101,114,32,115,
23
- 113,117,97,114,101,32,114,111,111,116,32,111,102,32,120,46,10,32,32,226,
24
- 128,162,32,77,97,116,104,46,103,99,100,40,97,44,32,98,41,32,84,104,101,32,
25
- 103,114,101,97,116,101,115,116,32,99,111,109,109,111,110,32,100,105,118,
26
- 105,115,111,114,32,111,102,32,97,32,97,110,100,32,98,46,10,32,32,226,128,
27
- 162,32,77,97,116,104,46,108,99,109,40,97,44,32,98,41,32,84,104,101,32,108,
28
- 101,97,115,116,32,99,111,109,109,111,110,32,109,117,108,116,105,112,108,
29
- 101,32,111,102,32,97,32,97,110,100,32,98,46,10,32,32,226,128,162,32,77,97,
30
- 116,104,46,102,97,99,116,111,114,105,97,108,40,110,41,32,84,104,101,32,110,
31
- 45,116,104,32,102,97,99,116,111,114,105,97,108,32,110,117,109,98,101,114,
32
- 46,10,32,32,226,128,162,32,77,97,116,104,46,107,95,112,101,114,109,117,116,
33
- 97,116,105,111,110,115,40,110,44,32,107,41,32,84,104,101,32,110,117,109,98,
34
- 101,114,32,111,102,32,100,105,115,116,105,110,99,116,32,119,97,121,115,32,
35
- 116,111,32,99,114,101,97,116,101,32,103,114,111,117,112,115,32,111,102,32,
36
- 115,105,122,101,32,107,32,102,114,111,109,32,110,32,100,105,115,116,105,
37
- 110,99,116,32,101,108,101,109,101,110,116,115,46,10,32,32,226,128,162,32,
38
- 77,97,116,104,46,107,95,99,111,109,98,105,110,97,116,105,111,110,115,40,
39
- 110,44,32,107,41,32,84,104,101,32,110,117,109,98,101,114,32,111,102,32,100,
40
- 105,115,116,105,110,99,116,32,119,97,121,115,32,116,111,32,99,114,101,97,
41
- 116,101,32,103,114,111,117,112,115,32,111,102,32,115,105,122,101,32,107,32,
42
- 102,114,111,109,32,110,32,100,105,115,116,105,110,99,116,32,101,108,101,
43
- 109,101,110,116,115,32,119,104,101,114,101,32,111,114,100,101,114,32,100,
44
- 111,101,115,32,110,111,116,32,109,97,116,116,101,114,46,10,10,10,45,32,76,
45
- 111,103,97,114,105,116,104,109,115,10,32,32,226,128,162,32,77,97,116,104,
46
- 46,101,120,112,40,120,41,32,67,97,108,99,117,108,97,116,101,115,32,226,132,
47
- 175,32,116,111,32,116,104,101,32,120,116,104,32,112,111,119,101,114,46,10,
48
- 32,32,226,128,162,32,77,97,116,104,46,108,111,103,40,120,41,32,67,97,108,
49
- 99,117,108,97,116,101,115,32,116,104,101,32,110,97,116,117,114,97,108,32,
50
- 108,111,103,97,114,105,116,104,109,32,40,98,97,115,101,32,226,132,175,41,
51
- 32,111,102,32,120,46,10,32,32,226,128,162,32,77,97,116,104,46,108,111,103,
52
- 40,120,44,32,98,41,32,67,97,108,99,117,108,97,116,101,115,32,116,104,101,
53
- 32,98,97,115,101,45,98,32,108,111,103,97,114,105,116,104,109,32,111,102,32,
54
- 120,10,32,32,226,128,162,32,77,97,116,104,46,108,111,103,50,40,120,41,32,
55
- 67,97,108,99,117,108,97,116,101,115,32,116,104,101,32,98,105,110,97,114,
56
- 121,32,108,111,103,97,114,105,116,104,109,32,40,98,97,115,101,32,50,41,32,
57
- 111,102,32,120,46,10,32,32,226,128,162,32,77,97,116,104,46,108,111,103,49,
58
- 48,40,120,41,32,67,97,108,99,117,108,97,116,101,115,32,116,104,101,32,99,
59
- 111,109,109,111,110,32,108,111,103,97,114,105,116,104,109,32,40,98,97,115,
60
- 101,32,49,48,41,32,111,102,32,120,46,10,32,32,226,128,162,32,77,97,116,104,
61
- 46,101,32,82,101,116,117,114,110,115,32,97,32,102,108,111,97,116,105,110,
62
- 103,45,112,111,105,110,116,32,97,112,112,114,111,120,105,109,97,116,105,
63
- 111,110,32,111,102,32,116,104,101,32,110,117,109,98,101,114,32,226,132,175,
64
- 46,10,10,45,32,84,114,105,103,111,110,111,109,101,116,114,121,10,32,32,226,
65
- 128,162,32,77,97,116,104,46,112,105,32,82,101,116,117,114,110,115,32,97,32,
66
- 102,108,111,97,116,105,110,103,45,112,111,105,110,116,32,97,112,112,114,
67
- 111,120,105,109,97,116,105,111,110,32,111,102,32,116,104,101,32,110,117,
68
- 109,98,101,114,32,207,128,46,10,32,32,226,128,162,32,77,97,116,104,46,100,
69
- 101,103,50,114,97,100,40,120,41,32,99,111,110,118,101,114,116,115,32,102,
70
- 114,111,109,32,100,101,103,114,101,101,115,32,116,111,32,114,97,100,105,97,
71
- 110,115,46,10,32,32,226,128,162,32,77,97,116,104,46,114,97,100,50,100,101,
72
- 103,40,120,41,32,99,111,110,118,101,114,116,115,32,102,114,111,109,32,114,
73
- 97,100,105,97,110,115,32,116,111,32,100,101,103,114,101,101,115,46,10,32,
74
- 32,226,128,162,32,77,97,116,104,46,115,105,110,40,120,41,32,84,104,101,32,
75
- 115,105,110,101,32,111,102,32,120,46,10,32,32,226,128,162,32,77,97,116,104,
76
- 46,99,111,115,40,120,41,32,84,104,101,32,99,111,115,105,110,101,32,111,102,
77
- 32,120,46,10,32,32,226,128,162,32,77,97,116,104,46,116,97,110,40,120,41,32,
78
- 84,104,101,32,116,97,110,103,101,110,116,32,111,102,32,120,46,10,32,32,226,
79
- 128,162,32,77,97,116,104,46,97,115,105,110,40,120,41,32,84,104,101,32,105,
80
- 110,118,101,114,115,101,32,115,105,110,101,32,111,102,32,120,46,10,32,32,
81
- 226,128,162,32,77,97,116,104,46,97,99,111,115,40,120,41,32,84,104,101,32,
82
- 105,110,118,101,114,115,101,32,99,111,115,105,110,101,32,111,102,32,120,46,
83
- 10,32,32,226,128,162,32,77,97,116,104,46,97,116,97,110,40,120,41,32,84,104,
84
- 101,32,105,110,118,101,114,115,101,32,116,97,110,103,101,110,116,32,111,
85
- 102,32,120,46,10,32,32,226,128,162,32,77,97,116,104,46,97,116,97,110,50,40,
86
- 120,44,32,121,41,32,84,104,101,32,105,110,118,101,114,115,101,32,116,97,
87
- 110,103,101,110,116,32,111,102,32,120,32,97,110,100,32,121,46,32,84,104,
88
- 105,115,32,118,97,114,105,97,110,116,32,114,101,116,117,114,110,115,32,116,
89
- 104,101,32,105,110,118,101,114,115,101,32,116,97,110,103,101,110,116,32,
90
- 105,110,32,116,104,101,32,99,111,114,114,101,99,116,32,113,117,97,100,114,
91
- 97,110,116,44,32,97,115,32,116,104,101,32,115,105,103,110,115,32,111,102,
92
- 32,98,111,116,104,32,120,32,97,110,100,32,121,32,97,114,101,32,107,110,111,
93
- 119,110,46,10,32,32,226,128,162,32,77,97,116,104,46,115,105,110,104,40,120,
94
- 41,32,84,104,101,32,104,121,112,101,114,98,111,108,105,99,32,115,105,110,
95
- 101,32,111,102,32,120,46,10,32,32,226,128,162,32,77,97,116,104,46,99,111,
96
- 115,104,40,120,41,32,84,104,101,32,104,121,112,101,114,98,111,108,105,99,
97
- 32,99,111,115,105,110,101,32,111,102,32,120,46,10,32,32,226,128,162,32,77,
98
- 97,116,104,46,116,97,110,104,40,120,41,32,84,104,101,32,104,121,112,101,
99
- 114,98,111,108,105,99,32,116,97,110,103,101,110,116,32,111,102,32,120,46,
100
- 10,32,32,226,128,162,32,77,97,116,104,46,97,115,105,110,104,40,120,41,32,
101
- 84,104,101,32,105,110,118,101,114,115,101,32,104,121,112,101,114,98,111,
102
- 108,105,99,32,115,105,110,101,32,111,102,32,120,46,10,32,32,226,128,162,32,
103
- 77,97,116,104,46,97,99,111,115,104,40,120,41,32,84,104,101,32,105,110,118,
104
- 101,114,115,101,32,104,121,112,101,114,98,111,108,105,99,32,99,111,115,105,
105
- 110,101,32,111,102,32,120,46,10,32,32,226,128,162,32,77,97,116,104,46,97,
106
- 116,97,110,104,40,120,41,32,84,104,101,32,105,110,118,101,114,115,101,32,
107
- 104,121,112,101,114,98,111,108,105,99,32,116,97,110,103,101,110,116,32,111,
108
- 102,32,120,46,10,10,45,32,87,111,114,107,105,110,103,32,119,105,116,104,32,
109
- 67,111,108,108,101,99,116,105,111,110,115,10,32,32,226,128,162,32,77,97,
110
- 116,104,46,69,110,117,109,46,112,114,111,100,117,99,116,40,99,111,108,108,
111
- 101,99,116,105,111,110,41,32,84,104,101,32,114,101,115,117,108,116,32,111,
112
- 102,32,109,117,108,116,105,112,108,121,105,110,103,32,97,108,108,32,101,
113
- 108,101,109,101,110,116,115,32,105,110,32,116,104,101,32,112,97,115,115,
114
- 101,100,32,99,111,108,108,101,99,116,105,111,110,46,10,32,32,226,128,162,
115
- 32,77,97,116,104,46,69,110,117,109,46,109,101,97,110,40,99,111,108,108,101,
116
- 99,116,105,111,110,41,32,116,104,101,32,109,101,97,110,32,111,102,32,116,
117
- 104,101,32,110,117,109,98,101,114,115,32,105,110,32,116,104,101,32,99,111,
118
- 108,108,101,99,116,105,111,110,46,10,32,32,226,128,162,32,77,97,116,104,46,
119
- 69,110,117,109,46,109,101,100,105,97,110,40,99,111,108,108,101,99,116,105,
120
- 111,110,41,32,116,104,101,32,109,101,100,105,97,110,32,111,102,32,116,104,
121
- 101,32,110,117,109,98,101,114,115,32,105,110,32,116,104,101,32,99,111,108,
122
- 108,101,99,116,105,111,110,46>>}.
4
+ <<"The Math library extends Elixir with many common math-related functions, constants and (optionally) operators.">>}.
123
5
{<<"elixir">>,<<"~> 1.2">>}.
124
6
{<<"files">>,
125
- [<<"lib/math.ex">>,<<"lib/math/enum.ex">>,<<"mix.exs">>,<<"README.md">>,
126
- <<"LICENSE">>]}.
7
+ [<<"lib">>,<<"lib/math.ex">>,<<"lib/math">>,<<"lib/math/enum.ex">>,
8
+ <<"mix.exs">>,<<"README.md">>,<<"LICENSE">>]}.
127
9
{<<"licenses">>,[<<"Apache-2.0">>]}.
128
10
{<<"links">>,[{<<"GitHub">>,<<"https://github.com/folz/math">>}]}.
129
- {<<"maintainers">>,[<<"Rodney Folz">>]}.
130
11
{<<"name">>,<<"math">>}.
131
12
{<<"requirements">>,[]}.
132
- {<<"version">>,<<"0.3.0">>}.
13
+ {<<"version">>,<<"0.3.1">>}.
changed lib/math.ex
 
@@ -7,7 +7,7 @@ defmodule Math do
7
7
8
8
# For practical uses floats can be considered equal if their difference is less than this value. See <~>.
9
9
@epsilon 1.0e-15
10
-
10
+
11
11
# Theoretical limit is 1.80e308, but Erlang errors at that value, so the practical limit is slightly below that one.
12
12
@max_value 1.79769313486231580793e308
13
13
 
@@ -35,7 +35,7 @@ defmodule Math do
35
35
The returned number is a floating-point approximation (as τ is irrational)
36
36
"""
37
37
@spec tau :: float
38
- def tau, do: pi * 2
38
+ def tau, do: pi() * 2
39
39
40
40
@doc """
41
41
The mathematical constant *ℯ* (e).
 
@@ -55,7 +55,7 @@ defmodule Math do
55
55
iex> 2.3 - 0.3 == 2.0
56
56
false
57
57
iex> 2.3 - 0.3 <~> 2.0
58
- true
58
+ true
59
59
"""
60
60
@spec number <~> number :: boolean
61
61
def x <~> y do
 
@@ -85,7 +85,7 @@ defmodule Math do
85
85
86
86
When one of the numbers is a float, returns a `float` by using erlang's `:math.pow/2` function.
87
87
88
- It is possible to calculate roots by choosing *n* between 0.0 and 1.0 (To calculate the *p* -th-root, pass 1/*p* to the function)
88
+ It is possible to calculate roots by choosing *n* between 0.0 and 1.0 (To calculate the *p* -th-root, pass 1/*p* to the function)
89
89
90
90
## Examples
91
91
 
@@ -112,7 +112,7 @@ defmodule Math do
112
112
:math.pow(x, n)
113
113
end
114
114
115
- # Integer implementation. Uses Exponentiation by Squaring.
115
+ # Integer implementation. Uses Exponentiation by Squaring.
116
116
defp _pow(x, n, y \\ 1)
117
117
defp _pow(_x, 0, y), do: y
118
118
defp _pow(x, 1, y), do: x * y
 
@@ -162,7 +162,7 @@ defmodule Math do
162
162
def isqrt(x) when x < 0, do: raise ArithmeticError
163
163
164
164
def isqrt(x), do: _isqrt(x, 1, div((1 + x), 2))
165
-
165
+
166
166
defp _isqrt(x, m, n) when abs(m - n) <= 1 and n * n <= x, do: n
167
167
defp _isqrt(_x, m, n) when abs(m - n) <= 1, do: n - 1
168
168
 
@@ -171,7 +171,7 @@ defmodule Math do
171
171
end
172
172
173
173
174
- #
174
+ #
175
175
@doc """
176
176
Calculates the Greatest Common divisor of two numbers.
177
177
 
@@ -191,10 +191,10 @@ defmodule Math do
191
191
6
192
192
iex> Math.gcd(-54, 24)
193
193
6
194
- """
194
+ """
195
195
@spec gcd(integer, integer) :: non_neg_integer
196
196
def gcd(a, 0), do: abs(a)
197
-
197
+
198
198
def gcd(0, b), do: abs(b)
199
199
def gcd(a, b) when a < 0 or b < 0, do: gcd(abs(a), abs(b))
200
200
def gcd(a, b), do: gcd(b, rem(a,b))
 
@@ -256,7 +256,7 @@ defmodule Math do
256
256
Calculates the k-permutations of *n*.
257
257
258
258
This is the number of distinct ways to create groups of size *k* from *n* distinct elements.
259
-
259
+
260
260
Notice that *n* is the first parameter, for easier piping.
261
261
262
262
## Examples
 
@@ -280,7 +280,7 @@ defmodule Math do
280
280
281
281
282
282
@doc """
283
- Calculates the k-combinations of *n*.
283
+ Calculates the k-combinations of *n*.
284
284
285
285
## Examples
286
286
iex> Math.k_combinations(10, 2)
 
@@ -327,7 +327,7 @@ defmodule Math do
327
327
328
328
iex> Math.log(5, 5)
329
329
1.0
330
- iex> Math.log(20, 2) <~> Math.log2(20)
330
+ iex> Math.log(20, 2) <~> Math.log2(20)
331
331
true
332
332
iex> Math.log(20, 10) <~> Math.log10(20)
333
333
true
 
@@ -367,7 +367,7 @@ defmodule Math do
367
367
368
368
iex>Math.deg2rad(180)
369
369
3.141592653589793
370
-
370
+
371
371
"""
372
372
@spec deg2rad(x) :: float
373
373
def deg2rad(x) do
 
@@ -376,7 +376,7 @@ defmodule Math do
376
376
377
377
@doc """
378
378
Converts radians to degrees
379
-
379
+
380
380
## Examples
381
381
382
382
iex>Math.rad2deg(Math.pi)
changed mix.exs
 
@@ -3,11 +3,11 @@ defmodule Math.Mixfile do
3
3
4
4
def project do
5
5
[app: :math,
6
- version: "0.3.0",
6
+ version: "0.3.1",
7
7
elixir: "~> 1.2",
8
- description: description,
9
- package: package,
10
- deps: deps,
8
+ description: description(),
9
+ package: package(),
10
+ deps: deps(),
11
11
build_embedded: Mix.env == :prod,
12
12
start_permanent: Mix.env == :prod]
13
13
end
 
@@ -21,72 +21,18 @@ defmodule Math.Mixfile do
21
21
22
22
defp description do
23
23
"""
24
- The Math module adds many useful functions that extend Elixir's standard library.
25
-
26
- - General Functions
27
- • a <~> b Comparison of floats, to check if they are _nearly_ equal.
28
- • Math.pow(x, n) Arithmetic exponentiation. Works both with integer powers and floats.
29
- • Math.sqrt(x) The square root of x.
30
- • Math.nth_root(x, n) The n-th root of x.
31
- • Math.isqrt(x) The integer square root of x.
32
- • Math.gcd(a, b) The greatest common divisor of a and b.
33
- • Math.lcm(a, b) The least common multiple of a and b.
34
- • Math.factorial(n) The n-th factorial number.
35
- • Math.k_permutations(n, k) The number of distinct ways to create groups of size k from n distinct elements.
36
- • Math.k_combinations(n, k) The number of distinct ways to create groups of size k from n distinct elements where order does not matter.
37
-
38
-
39
- - Logarithms
40
- • Math.exp(x) Calculates ℯ to the xth power.
41
- • Math.log(x) Calculates the natural logarithm (base ℯ) of x.
42
- • Math.log(x, b) Calculates the base-b logarithm of x
43
- • Math.log2(x) Calculates the binary logarithm (base 2) of x.
44
- • Math.log10(x) Calculates the common logarithm (base 10) of x.
45
- • Math.e Returns a floating-point approximation of the number ℯ.
46
-
47
- - Trigonometry
48
- • Math.pi Returns a floating-point approximation of the number π.
49
- • Math.deg2rad(x) converts from degrees to radians.
50
- • Math.rad2deg(x) converts from radians to degrees.
51
- • Math.sin(x) The sine of x.
52
- • Math.cos(x) The cosine of x.
53
- • Math.tan(x) The tangent of x.
54
- • Math.asin(x) The inverse sine of x.
55
- • Math.acos(x) The inverse cosine of x.
56
- • Math.atan(x) The inverse tangent of x.
57
- • Math.atan2(x, y) The inverse tangent of x and y. This variant returns the inverse tangent in the correct quadrant, as the signs of both x and y are known.
58
- • Math.sinh(x) The hyperbolic sine of x.
59
- • Math.cosh(x) The hyperbolic cosine of x.
60
- • Math.tanh(x) The hyperbolic tangent of x.
61
- • Math.asinh(x) The inverse hyperbolic sine of x.
62
- • Math.acosh(x) The inverse hyperbolic cosine of x.
63
- • Math.atanh(x) The inverse hyperbolic tangent of x.
64
-
65
- - Working with Collections
66
- • Math.Enum.product(collection) The result of multiplying all elements in the passed collection.
67
- • Math.Enum.mean(collection) the mean of the numbers in the collection.
68
- • Math.Enum.median(collection) the median of the numbers in the collection.
69
-
24
+ The Math library extends Elixir with many common math-related functions, constants and (optionally) operators.
70
25
"""
71
26
end
72
27
73
28
defp package do
74
29
[
75
- maintainers: ["Rodney Folz"],
30
+ maintainers: ["Rodney Folz", "Wiebe-Marten Wijnja/Qqwy"],
76
31
licenses: ["Apache-2.0"],
77
32
links: %{"GitHub": "https://github.com/folz/math"}
78
33
]
79
34
end
80
35
81
- # Dependencies can be Hex packages:
82
- #
83
- # {:mydep, "~> 0.3.0"}
84
- #
85
- # Or git/path repositories:
86
- #
87
- # {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"}
88
- #
89
- # Type "mix help deps" for more examples and options
90
36
defp deps do
91
37
[
92
38
{:ex_doc, ">= 0.11.4", only: [:dev]}