Skip to content

Commit dd9cf61

Browse files
Merge branch 'Add-C-implementations-to-base-special-math-functions' of https://github.com/vivekmaurya001/stdlib into Add-C-implementations-to-base-special-math-functions
2 parents 7ece9c1 + 8a6128e commit dd9cf61

File tree

14 files changed

+618
-30
lines changed

14 files changed

+618
-30
lines changed

.github/workflows/labeler.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ name: labeler
2222
# Workflow triggers:
2323
on:
2424
pull_request_target:
25+
types:
26+
- opened
27+
- synchronize
28+
- reopened
29+
- edited
30+
- review_requested
31+
- review_request_removed
32+
- ready_for_review
33+
- converted_to_draft
2534

2635
# Workflow jobs:
2736
jobs:
@@ -53,3 +62,52 @@ jobs:
5362
with:
5463
configuration-path: .github/labeler.yml
5564
repo-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }}
65+
66+
# Add "Needs Review" label when PR is opened and not a draft:
67+
- name: 'Add "Needs Review" label if PR is opened and not draft'
68+
if: ${{ github.event.action == 'opened' && github.event.pull_request.draft == false }}
69+
# Pin action to full length commit SHA
70+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
71+
with:
72+
github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }}
73+
script: |
74+
await github.rest.issues.addLabels({
75+
'owner': context.repo.owner,
76+
'repo': context.repo.repo,
77+
'issue_number': context.payload.pull_request.number,
78+
'labels': ['Needs Review'],
79+
})
80+
81+
# Add "Needs Review" label when PR is marked ready for review:
82+
- name: 'Add "Needs Review" label if PR is ready for review'
83+
if: ${{ github.event.action == 'ready_for_review' }}
84+
# Pin action to full length commit SHA
85+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
86+
with:
87+
github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }}
88+
script: |
89+
await github.rest.issues.addLabels({
90+
'owner': context.repo.owner,
91+
'repo': context.repo.repo,
92+
'issue_number': context.payload.pull_request.number,
93+
'labels': ['Needs Review'],
94+
})
95+
96+
# Remove "Needs Review" label when PR is converted to draft or closed:
97+
- name: 'Remove "Needs Review" label if PR is converted to draft or closed'
98+
if: ${{ github.event.action == 'converted_to_draft' || github.event.action == 'closed' }}
99+
# Pin action to full length commit SHA
100+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
101+
with:
102+
github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }}
103+
script: |
104+
try {
105+
await github.rest.issues.removeLabel({
106+
'owner': context.repo.owner,
107+
'repo': context.repo.repo,
108+
'issue_number': context.payload.pull_request.number,
109+
'name': 'Needs Review',
110+
})
111+
} catch ( error ) {
112+
console.log( 'Error removing label: %s', error.message );
113+
}

.github/workflows/slash_commands.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ jobs:
5151
github-token: ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}
5252
script: |
5353
github.rest.issues.addLabels({
54-
owner: context.repo.owner,
55-
repo: context.repo.repo,
56-
issue_number: context.issue.number,
57-
labels: ['bot: In Progress']
54+
'owner': context.repo.owner,
55+
'repo': context.repo.repo,
56+
'issue_number': context.issue.number,
57+
'labels': ['bot: In Progress']
5858
})
5959
6060
# Add initial reaction to comment with slash command:
@@ -254,11 +254,11 @@ jobs:
254254
script: |
255255
try {
256256
await github.rest.issues.removeLabel({
257-
owner: context.repo.owner,
258-
repo: context.repo.repo,
259-
issue_number: context.issue.number,
260-
name: 'bot: In Progress'
257+
'owner': context.repo.owner,
258+
'repo': context.repo.repo,
259+
'issue_number': context.issue.number,
260+
'name': 'bot: In Progress'
261261
})
262-
} catch (error) {
263-
console.log( 'Error removing label:', error );
262+
} catch ( error ) {
263+
console.log( 'Error removing label: %s', error.message );
264264
}
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
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+
# FLOAT64_MAX_SAFE_NTH_TRIBONACCI
22+
23+
> Maximum safe nth [Tribonacci number][tribonacci-number] when stored in [double-precision floating-point][ieee754] format.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
<!-- eslint-disable id-length -->
30+
31+
```javascript
32+
var FLOAT64_MAX_SAFE_NTH_TRIBONACCI = require( '@stdlib/constants/float64/max-safe-nth-tribonacci' );
33+
```
34+
35+
#### FLOAT64_MAX_SAFE_NTH_TRIBONACCI
36+
37+
Maximum [safe][safe-integers] nth [Tribonacci number][tribonacci-number] when stored in [double-precision floating-point][ieee754] format.
38+
39+
<!-- eslint-disable id-length -->
40+
41+
```javascript
42+
var bool = ( FLOAT64_MAX_SAFE_NTH_TRIBONACCI === 63 );
43+
// returns true
44+
```
45+
46+
</section>
47+
48+
<!-- /.usage -->
49+
50+
<section class="examples">
51+
52+
## Examples
53+
54+
<!-- eslint-disable id-length -->
55+
56+
<!-- eslint no-undef: "error" -->
57+
58+
```javascript
59+
var FLOAT64_MAX_SAFE_NTH_TRIBONACCI = require( '@stdlib/constants/float64/max-safe-nth-tribonacci' );
60+
61+
function tribonacci( n ) {
62+
var a;
63+
var b;
64+
var c;
65+
var d;
66+
var i;
67+
68+
a = 0;
69+
b = 0;
70+
c = 1;
71+
if ( n === 0 ) {
72+
return a;
73+
}
74+
if ( n === 1 ) {
75+
return b;
76+
}
77+
if ( n === 2 ) {
78+
return c;
79+
}
80+
for ( i = 3; i <= n; i++ ) {
81+
d = a + b + c;
82+
a = b;
83+
b = c;
84+
c = d;
85+
}
86+
return c;
87+
}
88+
89+
var v;
90+
var i;
91+
for ( i = 0; i < 100; i++ ) {
92+
v = tribonacci( i );
93+
if ( i > FLOAT64_MAX_SAFE_NTH_TRIBONACCI ) {
94+
console.log( 'Unsafe: %d', v );
95+
} else {
96+
console.log( 'Safe: %d', v );
97+
}
98+
}
99+
```
100+
101+
</section>
102+
103+
<!-- /.examples -->
104+
105+
<!-- C interface documentation. -->
106+
107+
* * *
108+
109+
<section class="c">
110+
111+
## C APIs
112+
113+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
114+
115+
<section class="intro">
116+
117+
</section>
118+
119+
<!-- /.intro -->
120+
121+
<!-- C usage documentation. -->
122+
123+
<section class="usage">
124+
125+
### Usage
126+
127+
```c
128+
#include "stdlib/constants/float64/max_safe_nth_tribonacci.h"
129+
```
130+
131+
#### STDLIB_CONSTANT_FLOAT64_MAX_SAFE_NTH_TRIBONACCI
132+
133+
Maximum [safe][safe-integers] nth [Tribonacci number][tribonacci-number] when stored in [double-precision floating-point][ieee754] format.
134+
135+
</section>
136+
137+
<!-- /.usage -->
138+
139+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
140+
141+
<section class="notes">
142+
143+
</section>
144+
145+
<!-- /.notes -->
146+
147+
<!-- C API usage examples. -->
148+
149+
<section class="examples">
150+
151+
</section>
152+
153+
<!-- /.examples -->
154+
155+
</section>
156+
157+
<!-- /.c -->
158+
159+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
160+
161+
<section class="related">
162+
163+
</section>
164+
165+
<!-- /.related -->
166+
167+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
168+
169+
<section class="links">
170+
171+
[safe-integers]: http://www.2ality.com/2013/10/safe-integers.html
172+
173+
[tribonacci-number]: https://en.wikipedia.org/wiki/Tribonacci_number
174+
175+
[ieee754]: https://en.wikipedia.org/wiki/IEEE_754-1985
176+
177+
<!-- <related-links> -->
178+
179+
<!-- </related-links> -->
180+
181+
</section>
182+
183+
<!-- /.links -->
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
{{alias}}
3+
Maximum safe nth Tribonacci number when stored in double-precision
4+
floating-point format.
5+
6+
Examples
7+
--------
8+
> {{alias}}
9+
63
10+
11+
See Also
12+
--------
13+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// TypeScript Version: 4.1
20+
21+
/**
22+
* Maximum safe nth Tribonacci number when stored in double-precision floating-point format.
23+
*
24+
* @example
25+
* var max = FLOAT64_MAX_SAFE_NTH_TRIBONACCI;
26+
* // returns 63
27+
*/
28+
declare const FLOAT64_MAX_SAFE_NTH_TRIBONACCI: number;
29+
30+
31+
// EXPORTS //
32+
33+
export = FLOAT64_MAX_SAFE_NTH_TRIBONACCI;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import FLOAT64_MAX_SAFE_NTH_TRIBONACCI = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The export is a number...
25+
{
26+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
27+
FLOAT64_MAX_SAFE_NTH_TRIBONACCI; // $ExpectType number
28+
}

0 commit comments

Comments
 (0)