Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Aug 24, 2024
1 parent 2ae2bb2 commit d3d103c
Show file tree
Hide file tree
Showing 25 changed files with 1,869 additions and 2 deletions.
28 changes: 26 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<section class="release" id="unreleased">

## Unreleased (2024-08-23)
## Unreleased (2024-08-24)

<section class="packages">

Expand Down Expand Up @@ -32,6 +32,28 @@

<!-- /.package -->

<section class="package" id="math-base-special-logf-unreleased">

#### [@stdlib/math/base/special/logf](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/logf)

<details>

<section class="features">

##### Features

- [`6c8f019`](https://github.com/stdlib-js/stdlib/commit/6c8f019db8adb12466250957693edb9830496a7b) - add `math/base/special/logf`

</section>

<!-- /.features -->

</details>

</section>

<!-- /.package -->

<section class="package" id="math-base-special-maxf-unreleased">

#### [@stdlib/math/base/special/maxf](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/maxf)
Expand Down Expand Up @@ -84,10 +106,11 @@

### Contributors

A total of 2 people contributed to this release. Thank you to the following contributors:
A total of 3 people contributed to this release. Thank you to the following contributors:

- Athan Reines
- Gunj Joshi
- Philipp Burckhardt

</section>

Expand All @@ -99,6 +122,7 @@ A total of 2 people contributed to this release. Thank you to the following cont

<details>

- [`6c8f019`](https://github.com/stdlib-js/stdlib/commit/6c8f019db8adb12466250957693edb9830496a7b) - **feat:** add `math/base/special/logf` _(by Gunj Joshi, Philipp Burckhardt)_
- [`50b38f9`](https://github.com/stdlib-js/stdlib/commit/50b38f941b50a3f71b531d965c7312d4c6932f84) - **feat:** add `math/base/special/acotdf` [(#2799)](https://github.com/stdlib-js/stdlib/pull/2799) _(by Gunj Joshi)_
- [`15878f9`](https://github.com/stdlib-js/stdlib/commit/15878f9056d9e0e4bae0411870655316bf68dff3) - **feat:** add `math/base/special/maxf` [(#2816)](https://github.com/stdlib-js/stdlib/pull/2816) _(by Gunj Joshi)_
- [`ef703d6`](https://github.com/stdlib-js/stdlib/commit/ef703d629af0fa6f4a34e697a26beea37dc7345c) - **feat:** add `math/base/special/minf` [(#2820)](https://github.com/stdlib-js/stdlib/pull/2820) _(by Gunj Joshi, Athan Reines)_
Expand Down
198 changes: 198 additions & 0 deletions base/special/logf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
<!--
@license Apache-2.0
Copyright (c) 2024 The Stdlib Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# Logarithm

> Compute the base `b` [logarithm][logarithm] of a single-precision floating-point number..
<section class="usage">

## Usage

```javascript
var logf = require( '@stdlib/math/base/special/logf' );
```

#### logf( x, b )

Computes the base `b` logarithm of a single-precision floating-point number.

```javascript
var v = logf( 100.0, 10.0 );
// returns 2.0

v = logf( 16.0, 2.0 );
// returns 4.0

v = logf( 5.0, 1.0 );
// returns Infinity
```

For negative `x` or `b`, the [logarithm][logarithm] is **not** defined.

```javascript
var v = logf( -4.0, 1.0 );
// returns NaN

v = logf( 2.0, -4.0 );
// returns NaN
```

</section>

<!-- /.usage -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var randu = require( '@stdlib/random/base/randu' );
var roundf = require( '@stdlib/math/base/special/roundf' );
var logf = require( '@stdlib/math/base/special/logf' );

var b;
var x;
var i;

for ( i = 0; i < 100; i++ ) {
x = roundf( randu() * 100.0 );
b = roundf( randu() * 5.0 );
console.log( 'logf( %d, %d ) = %d', x, b, logf( x, b ) );
}
```

</section>

<!-- /.examples -->

<!-- C interface documentation. -->

* * *

<section class="c">

## C APIs

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- C usage documentation. -->

<section class="usage">

### Usage

```c
#include "stdlib/math/base/special/logf.h"
```

#### stdlib_base_logf( x, b )

Computes the base `b` logarithm of a single-precision floating-point number.

```c
float v = stdlib_base_logf( 100.0f, 10.0f );
// returns 2.0f
```

The function accepts the following arguments:

- **x**: `[in] float` input value.
- **b**: `[in] float` input value.

```c
float stdlib_base_logf( const float x, const float b );
```
</section>
<!-- /.usage -->
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
<section class="notes">
</section>
<!-- /.notes -->
<!-- C API usage examples. -->
<section class="examples">
### Examples
```c
#include "stdlib/math/base/special/logf.h"
#include <stdlib.h>
#include <stdio.h>
int main( void ) {
float out;
float x;
float b;
int i;
for ( i = 0; i < 100; i++ ) {
x = ( (float)rand() / (float)RAND_MAX ) * 100.0f;
b = ( (float)rand() / (float)RAND_MAX ) * 5.0f;
out = stdlib_base_logf( x, b );
printf( "logf(%f, %f) = %f\n", x, b, out );
}
}
```

</section>

<!-- /.examples -->

</section>

<!-- /.c -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[logarithm]: https://en.wikipedia.org/wiki/Logarithm

<!-- <related-links> -->

<!-- </related-links> -->

</section>

<!-- /.links -->
55 changes: 55 additions & 0 deletions base/special/logf/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/array/uniform' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var isnanf = require( './../../../../base/assert/is-nanf' );
var pkg = require( './../package.json' ).name;
var logf = require( './../lib' );


// MAIN //

bench( pkg, function benchmark( b ) {
var base;
var x;
var y;
var i;

x = randu( 100, 1.0, 1000.0 );
base = discreteUniform( 100, 2.0, 10.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
y = logf( x[ i % x.length ], base[ i % base.length ] );
if ( isnanf( y ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnanf( y ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});
64 changes: 64 additions & 0 deletions base/special/logf/benchmark/benchmark.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/array/uniform' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var isnanf = require( './../../../../base/assert/is-nanf' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;


// VARIABLES //

var logf = tryRequire( resolve( __dirname, './../lib/native.js' ) );
var opts = {
'skip': ( logf instanceof Error )
};


// MAIN //

bench( pkg+'::native', opts, function benchmark( b ) {
var base;
var x;
var y;
var i;

x = randu( 100, 1.0, 1000.0 );
base = discreteUniform( 100, 2.0, 10.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
y = logf( x[ i % x.length ], base[ i % base.length ] );
if ( isnanf( y ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnanf( y ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});
Loading

0 comments on commit d3d103c

Please sign in to comment.