@stdlib/complex-float32 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -446
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -7
- package/dist/index.js.map +4 -4
- package/docs/types/index.d.ts +89 -41
- package/lib/index.js +86 -12
- package/package.json +17 -19
- package/include/stdlib/complex/float32.h +0 -148
- package/lib/main.js +0 -159
- package/lib/tojson.js +0 -39
- package/lib/tostring.js +0 -42
- package/manifest.json +0 -38
- package/src/main.c +0 -151
package/lib/tojson.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Apache-2.0
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2018 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
|
-
'use strict';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Serializes a complex number as a JSON object.
|
|
23
|
-
*
|
|
24
|
-
* @private
|
|
25
|
-
* @returns {Object} JSON representation
|
|
26
|
-
*/
|
|
27
|
-
function toJSON() {
|
|
28
|
-
/* eslint-disable no-invalid-this */
|
|
29
|
-
var out = {};
|
|
30
|
-
out.type = 'Complex64';
|
|
31
|
-
out.re = this.re;
|
|
32
|
-
out.im = this.im;
|
|
33
|
-
return out;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// EXPORTS //
|
|
38
|
-
|
|
39
|
-
module.exports = toJSON;
|
package/lib/tostring.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Apache-2.0
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2018 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
|
-
'use strict';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Serializes a complex number as a string.
|
|
23
|
-
*
|
|
24
|
-
* @private
|
|
25
|
-
* @returns {string} serialized complex number
|
|
26
|
-
*/
|
|
27
|
-
function toString() { // eslint-disable-line stdlib/no-redeclare
|
|
28
|
-
/* eslint-disable no-invalid-this */
|
|
29
|
-
var str = '' + this.re;
|
|
30
|
-
if ( this.im < 0 ) {
|
|
31
|
-
str += ' - ' + (-this.im);
|
|
32
|
-
} else {
|
|
33
|
-
str += ' + ' + this.im;
|
|
34
|
-
}
|
|
35
|
-
str += 'i';
|
|
36
|
-
return str;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// EXPORTS //
|
|
41
|
-
|
|
42
|
-
module.exports = toString;
|
package/manifest.json
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"options": {},
|
|
3
|
-
"fields": [
|
|
4
|
-
{
|
|
5
|
-
"field": "src",
|
|
6
|
-
"resolve": true,
|
|
7
|
-
"relative": true
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"field": "include",
|
|
11
|
-
"resolve": true,
|
|
12
|
-
"relative": true
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"field": "libraries",
|
|
16
|
-
"resolve": false,
|
|
17
|
-
"relative": false
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"field": "libpath",
|
|
21
|
-
"resolve": true,
|
|
22
|
-
"relative": false
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
"confs": [
|
|
26
|
-
{
|
|
27
|
-
"src": [
|
|
28
|
-
"./src/main.c"
|
|
29
|
-
],
|
|
30
|
-
"include": [
|
|
31
|
-
"./include"
|
|
32
|
-
],
|
|
33
|
-
"libraries": [],
|
|
34
|
-
"libpath": [],
|
|
35
|
-
"dependencies": []
|
|
36
|
-
}
|
|
37
|
-
]
|
|
38
|
-
}
|
package/src/main.c
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Apache-2.0
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2021 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
|
-
#include "stdlib/complex/float32.h"
|
|
20
|
-
#include <stdint.h>
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Returns a single-precision complex floating-point number.
|
|
24
|
-
*
|
|
25
|
-
* @param real real component
|
|
26
|
-
* @param imag imaginary component
|
|
27
|
-
* @return single-precision complex floating-point number
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* stdlib_complex64_t z = stdlib_complex64( 5.0f, 2.0f );
|
|
31
|
-
*/
|
|
32
|
-
stdlib_complex64_t stdlib_complex64( const float real, const float imag ) {
|
|
33
|
-
stdlib_complex64_parts_t z;
|
|
34
|
-
z.parts[ 0 ] = real;
|
|
35
|
-
z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable
|
|
36
|
-
return z.value;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Converts a single-precision floating-point number to a single-precision complex floating-point number.
|
|
41
|
-
*
|
|
42
|
-
* @param real real component
|
|
43
|
-
* @return single-precision complex floating-point number
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* stdlib_complex64_t z = stdlib_complex64_from_float32( 5.0f );
|
|
47
|
-
*/
|
|
48
|
-
stdlib_complex64_t stdlib_complex64_from_float32( const float real ) {
|
|
49
|
-
stdlib_complex64_parts_t z;
|
|
50
|
-
z.parts[ 0 ] = real;
|
|
51
|
-
z.parts[ 1 ] = 0.0f; // cppcheck-suppress unreadVariable
|
|
52
|
-
return z.value;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Converts a double-precision floating-point number to a single-precision complex floating-point number.
|
|
57
|
-
*
|
|
58
|
-
* @param real real component
|
|
59
|
-
* @return single-precision complex floating-point number
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* stdlib_complex64_t z = stdlib_complex64_from_float64( 5.0 );
|
|
63
|
-
*/
|
|
64
|
-
stdlib_complex64_t stdlib_complex64_from_float64( const double real ) {
|
|
65
|
-
stdlib_complex64_parts_t z;
|
|
66
|
-
z.parts[ 0 ] = (float)real;
|
|
67
|
-
z.parts[ 1 ] = 0.0f; // cppcheck-suppress unreadVariable
|
|
68
|
-
return z.value;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Converts (copies) a single-precision complex floating-point number to a single-precision complex floating-point number.
|
|
73
|
-
*
|
|
74
|
-
* @param z single-precision complex floating-point number
|
|
75
|
-
* @return single-precision complex floating-point number
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f );
|
|
79
|
-
* stdlib_complex64_t z2 = stdlib_complex64_from_complex64( z1 );
|
|
80
|
-
*/
|
|
81
|
-
stdlib_complex64_t stdlib_complex64_from_complex64( const stdlib_complex64_t z ) {
|
|
82
|
-
stdlib_complex64_parts_t v1 = { z };
|
|
83
|
-
stdlib_complex64_parts_t v2;
|
|
84
|
-
v2.parts[ 0 ] = v1.parts[ 0 ];
|
|
85
|
-
v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable
|
|
86
|
-
return v2.value;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Converts a signed 8-bit integer to a single-precision complex floating-point number.
|
|
91
|
-
*
|
|
92
|
-
* @param real real component
|
|
93
|
-
* @return single-precision complex floating-point number
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* stdlib_complex64_t z = stdlib_complex64_from_int8( 5 );
|
|
97
|
-
*/
|
|
98
|
-
stdlib_complex64_t stdlib_complex64_from_int8( const int8_t real ) {
|
|
99
|
-
stdlib_complex64_parts_t z;
|
|
100
|
-
z.parts[ 0 ] = (float)real;
|
|
101
|
-
z.parts[ 1 ] = 0.0f; // cppcheck-suppress unreadVariable
|
|
102
|
-
return z.value;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Converts an unsigned 8-bit integer to a single-precision complex floating-point number.
|
|
107
|
-
*
|
|
108
|
-
* @param real real component
|
|
109
|
-
* @return single-precision complex floating-point number
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* stdlib_complex64_t z = stdlib_complex64_from_uint8( 5 );
|
|
113
|
-
*/
|
|
114
|
-
stdlib_complex64_t stdlib_complex64_from_uint8( const uint8_t real ) {
|
|
115
|
-
stdlib_complex64_parts_t z;
|
|
116
|
-
z.parts[ 0 ] = (float)real;
|
|
117
|
-
z.parts[ 1 ] = 0.0f; // cppcheck-suppress unreadVariable
|
|
118
|
-
return z.value;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Converts a signed 16-bit integer to a single-precision complex floating-point number.
|
|
123
|
-
*
|
|
124
|
-
* @param real real component
|
|
125
|
-
* @return single-precision complex floating-point number
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* stdlib_complex64_t z = stdlib_complex64_from_int16( 5 );
|
|
129
|
-
*/
|
|
130
|
-
stdlib_complex64_t stdlib_complex64_from_int16( const int16_t real ) {
|
|
131
|
-
stdlib_complex64_parts_t z;
|
|
132
|
-
z.parts[ 0 ] = (float)real;
|
|
133
|
-
z.parts[ 1 ] = 0.0f; // cppcheck-suppress unreadVariable
|
|
134
|
-
return z.value;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Converts an unsigned 16-bit integer to a single-precision complex floating-point number.
|
|
139
|
-
*
|
|
140
|
-
* @param real real component
|
|
141
|
-
* @return single-precision complex floating-point number
|
|
142
|
-
*
|
|
143
|
-
* @example
|
|
144
|
-
* stdlib_complex64_t z = stdlib_complex64_from_uint16( 5 );
|
|
145
|
-
*/
|
|
146
|
-
stdlib_complex64_t stdlib_complex64_from_uint16( const uint16_t real ) {
|
|
147
|
-
stdlib_complex64_parts_t z;
|
|
148
|
-
z.parts[ 0 ] = (float)real;
|
|
149
|
-
z.parts[ 1 ] = 0.0f; // cppcheck-suppress unreadVariable
|
|
150
|
-
return z.value;
|
|
151
|
-
}
|