Skip to content

Commit 89e920f

Browse files
committed
feat: basic setup
1 parent f8bcfd8 commit 89e920f

File tree

5 files changed

+610
-0
lines changed

5 files changed

+610
-0
lines changed
Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2024 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# lcmf
22+
23+
> Compute the [least common multiple][lcm] (lcm) of two single-precision floating-point numbers.
24+
25+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
26+
27+
<section class="intro">
28+
29+
The [least common multiple][lcm] (lcm) of two non-zero integers `a` and `b` is the smallest positive integer that is divisible by both `a` and `b`. The lcm is also known as the **lowest common multiple** or **smallest common multiple** and finds common use in calculating the **lowest common denominator** (lcd).
30+
31+
</section>
32+
33+
<!-- /.intro -->
34+
35+
<!-- Package usage documentation. -->
36+
37+
<section class="usage">
38+
39+
## Usage
40+
41+
```javascript
42+
var lcmf = require( '@stdlib/math/base/special/lcmf' );
43+
```
44+
45+
#### lcmf( a, b )
46+
47+
Computes the [least common multiple][lcm] (lcm) of two single-precision floating-point numbers.
48+
49+
```javascript
50+
var v = lcmf( 48, 18 );
51+
// returns 144
52+
```
53+
54+
If either `a` or `b` is `0`, the function returns `0`.
55+
56+
```javascript
57+
var v = lcmf( 0, 0 );
58+
// returns 0
59+
60+
v = lcmf( 2, 0 );
61+
// returns 0
62+
63+
v = lcmf( 0, 3 );
64+
// returns 0
65+
```
66+
67+
Both `a` and `b` must have integer values; otherwise, the function returns `NaN`.
68+
69+
```javascript
70+
var v = lcmf( 3.14, 18 );
71+
// returns NaN
72+
73+
v = lcmf( 48, 3.14 );
74+
// returns NaN
75+
76+
v = lcmf( NaN, 18 );
77+
// returns NaN
78+
79+
v = lcmf( 48, NaN );
80+
// returns NaN
81+
```
82+
83+
</section>
84+
85+
<!-- /.usage -->
86+
87+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
88+
89+
<section class="notes">
90+
91+
</section>
92+
93+
<!-- /.notes -->
94+
95+
<!-- Package usage examples. -->
96+
97+
<section class="examples">
98+
99+
## Examples
100+
101+
<!-- eslint no-undef: "error" -->
102+
103+
```javascript
104+
var randu = require( '@stdlib/random/base/randu' );
105+
var round = require( '@stdlib/math/base/special/round' );
106+
var lcmf = require( '@stdlib/math/base/special/lcmf' );
107+
108+
var a;
109+
var b;
110+
var v;
111+
var i;
112+
113+
for ( i = 0; i < 100; i++ ) {
114+
a = round( randu()*50 );
115+
b = round( randu()*50 );
116+
v = lcmf( a, b );
117+
console.log( 'lcmf(%d,%d) = %d', a, b, v );
118+
}
119+
```
120+
121+
</section>
122+
123+
<!-- /.examples -->
124+
125+
<!-- C interface documentation. -->
126+
127+
* * *
128+
129+
<section class="c">
130+
131+
## C APIs
132+
133+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
134+
135+
<section class="intro">
136+
137+
</section>
138+
139+
<!-- /.intro -->
140+
141+
<!-- C usage documentation. -->
142+
143+
<section class="usage">
144+
145+
### Usage
146+
147+
```c
148+
#include "stdlib/math/base/special/lcmf.h"
149+
```
150+
151+
#### stdlib_base_lcmf( a, b )
152+
153+
Computes the [least common multiple][lcm] (lcm) of two single-precision floating-point numbers.
154+
155+
```c
156+
double v = stdlib_base_lcmf( 48.0f, 18.0f );
157+
// returns 144.0f
158+
```
159+
160+
The function accepts the following arguments:
161+
162+
- **a**: `[in] float` input value.
163+
- **b**: `[in] float` input value.
164+
165+
```c
166+
float stdlib_base_lcmf( const float a, const float b );
167+
```
168+
169+
</section>
170+
171+
<!-- /.usage -->
172+
173+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
174+
175+
<section class="notes">
176+
177+
</section>
178+
179+
<!-- /.notes -->
180+
181+
<!-- C API usage examples. -->
182+
183+
<section class="examples">
184+
185+
### Examples
186+
187+
```c
188+
#include "stdlib/math/base/special/lcmf.h"
189+
#include <stdio.h>
190+
191+
int main( void ) {
192+
const float a[] = { 24.0f, 32.0f, 48.0f, 116.0f, 33.0f };
193+
const float b[] = { 12.0f, 6.0f, 15.0f, 52.0f, 22.0f };
194+
195+
float out;
196+
int i;
197+
for ( i = 0; i < 5; i++ ) {
198+
out = stdlib_base_lcmf( a[ i ], b[ i ] );
199+
printf( "lcmf(%f, %f) = %f\n", a[ i ], b[ i ], out );
200+
}
201+
}
202+
```
203+
204+
</section>
205+
206+
<!-- /.examples -->
207+
208+
</section>
209+
210+
<!-- /.c -->
211+
212+
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
213+
214+
<section class="references">
215+
216+
</section>
217+
218+
<!-- /.references -->
219+
220+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
221+
222+
<section class="related">
223+
224+
</section>
225+
226+
<!-- /.related -->
227+
228+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
229+
230+
<section class="links">
231+
232+
[lcm]: https://en.wikipedia.org/wiki/Least_common_multiple
233+
234+
<!-- <related-links> -->
235+
236+
<!-- </related-links> -->
237+
238+
</section>
239+
240+
<!-- /.links -->

0 commit comments

Comments
 (0)