@ohos-ports/stdlib-complex-real 0.2.1-beta.0 → 0.2.1-beta.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohos-ports/stdlib-complex-real",
3
- "version": "0.2.1-beta.0",
3
+ "version": "0.2.1-beta.1",
4
4
  "description": "Return the real component of a double-precision complex floating-point number.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -27,7 +27,7 @@
27
27
  "repository": {
28
28
  "type": "git",
29
29
  "url": "https://github.com/ohos-ports/ohos-ports.git",
30
- "directory": "ports/stdlib-complex-real/0.2.1"
30
+ "directory": "ports/@stdlib/complex-real/0.2.1"
31
31
  },
32
32
  "bugs": {
33
33
  "url": "https://github.com/ohos-ports/ohos-ports/issues"
@@ -36,6 +36,7 @@
36
36
  "@stdlib/complex-float64": "^0.2.1"
37
37
  },
38
38
  "devDependencies": {},
39
+ "bundleDependencies": true,
39
40
  "engines": {
40
41
  "node": ">=0.10.0",
41
42
  "npm": ">2.7.0"
@@ -46,11 +47,11 @@
46
47
  "freebsd",
47
48
  "linux",
48
49
  "macos",
50
+ "openharmony",
49
51
  "openbsd",
50
52
  "sunos",
51
53
  "win32",
52
- "windows",
53
- "openharmony"
54
+ "windows"
54
55
  ],
55
56
  "keywords": [
56
57
  "stdlib",
@@ -69,6 +70,5 @@
69
70
  "funding": {
70
71
  "type": "opencollective",
71
72
  "url": "https://opencollective.com/stdlib"
72
- },
73
- "bundleDependencies": true
74
- }
73
+ }
74
+ }
@@ -1,148 +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
- #ifndef STDLIB_COMPLEX_FLOAT32_H
20
- #define STDLIB_COMPLEX_FLOAT32_H
21
-
22
- #include <complex.h>
23
- #include <stdint.h>
24
-
25
- /*
26
- * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
27
- */
28
- #ifdef __cplusplus
29
- extern "C" {
30
- #endif
31
-
32
- // Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality)
33
- #if defined(_Imaginary_I) && defined(CMPLXF)
34
-
35
- /**
36
- * An opaque type definition for a single-precision complex floating-point number.
37
- */
38
- typedef float complex stdlib_complex64_t;
39
-
40
- // If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components...
41
- #else
42
-
43
- /**
44
- * An opaque type definition for a single-precision complex floating-point number.
45
- *
46
- * @example
47
- * stdlib_complex64_t z;
48
- *
49
- * // Set the real component:
50
- * z.re = 5.0f;
51
- *
52
- * // Set the imaginary component:
53
- * z.im = 2.0f;
54
- */
55
- typedef struct {
56
- /**
57
- * Real component.
58
- */
59
- float re;
60
-
61
- /**
62
- * Imaginary component.
63
- */
64
- float im;
65
- } stdlib_complex64_t;
66
-
67
- #endif
68
-
69
- /**
70
- * An opaque type definition for a union for accessing the real and imaginary parts of a single-precision complex floating-point number.
71
- *
72
- * @example
73
- * float realf( const stdlib_complex64_t z ) {
74
- * stdlib_complex64_parts_t v;
75
- *
76
- * // Assign a single-precision complex floating-point number:
77
- * v.value = z;
78
- *
79
- * // Extract the real component:
80
- * float re = v.parts[ 0 ];
81
- *
82
- * return re;
83
- * }
84
- *
85
- * // ...
86
- *
87
- * // Create a complex number:
88
- * stdlib_complex64_t z = stdlib_complex64( 5.0f, 2.0f );
89
- *
90
- * // ...
91
- *
92
- * // Access the real component:
93
- * float re = realf( z );
94
- * // returns 5.0f
95
- */
96
- typedef union {
97
- // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number):
98
- stdlib_complex64_t value;
99
-
100
- // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see <https://en.cppreference.com/w/c/language/arithmetic_types#Complex_floating_types>), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `float complex`):
101
- float parts[ 2 ];
102
- } stdlib_complex64_parts_t;
103
-
104
- /**
105
- * Returns a single-precision complex floating-point number.
106
- */
107
- stdlib_complex64_t stdlib_complex64( const float real, const float imag );
108
-
109
- /**
110
- * Converts a single-precision floating-point number to a single-precision complex floating-point number.
111
- */
112
- stdlib_complex64_t stdlib_complex64_from_float32( const float real );
113
-
114
- /**
115
- * Converts a double-precision floating-point number to a single-precision complex floating-point number.
116
- */
117
- stdlib_complex64_t stdlib_complex64_from_float64( const double real );
118
-
119
- /**
120
- * Converts (copies) a single-precision complex floating-point number to a single-precision complex floating-point number.
121
- */
122
- stdlib_complex64_t stdlib_complex64_from_complex64( const stdlib_complex64_t z );
123
-
124
- /**
125
- * Converts a signed 8-bit integer to a single-precision complex floating-point number.
126
- */
127
- stdlib_complex64_t stdlib_complex64_from_int8( const int8_t real );
128
-
129
- /**
130
- * Converts an unsigned 8-bit integer to a single-precision complex floating-point number.
131
- */
132
- stdlib_complex64_t stdlib_complex64_from_uint8( const uint8_t real );
133
-
134
- /**
135
- * Converts a signed 16-bit integer to a single-precision complex floating-point number.
136
- */
137
- stdlib_complex64_t stdlib_complex64_from_int16( const int16_t real );
138
-
139
- /**
140
- * Converts an unsigned 16-bit integer to a single-precision complex floating-point number.
141
- */
142
- stdlib_complex64_t stdlib_complex64_from_uint16( const uint16_t real );
143
-
144
- #ifdef __cplusplus
145
- }
146
- #endif
147
-
148
- #endif // !STDLIB_COMPLEX_FLOAT32_H
@@ -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
- }
@@ -1,169 +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
- #ifndef STDLIB_COMPLEX_FLOAT64_H
20
- #define STDLIB_COMPLEX_FLOAT64_H
21
-
22
- #include "stdlib/complex/float32.h"
23
- #include <complex.h>
24
- #include <stdint.h>
25
-
26
- /*
27
- * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
28
- */
29
- #ifdef __cplusplus
30
- extern "C" {
31
- #endif
32
-
33
- // Check for C11 support where we can precisely define a complex number and thus avoid issues concerning infinities and NaNs as real and/or imaginary components... (TODO: revisit the following check; similar to NumPy, we may want to check for a compile time variable (e.g., STDLIB_USE_C99_COMPLEX), rather than checking for C11 support, especially if we are not using C11 functionality)
34
- #if defined(_Imaginary_I) && defined(CMPLX)
35
-
36
- /**
37
- * An opaque type definition for a double-precision complex floating-point number.
38
- */
39
- typedef double complex stdlib_complex128_t;
40
-
41
- // If we aren't going to use the native complex number type, we need to define a complex number as an "opaque" struct (here, "opaque" meaning type consumers should **not** be accessing the components directly, but only through dedicated functions) for storing the real and imaginary components...
42
- #else
43
-
44
- /**
45
- * An opaque type definition for a double-precision complex floating-point number.
46
- *
47
- * @example
48
- * stdlib_complex128_t z;
49
- *
50
- * // Set the real component:
51
- * z.re = 5.0;
52
- *
53
- * // Set the imaginary component:
54
- * z.im = 2.0;
55
- */
56
- typedef struct {
57
- /**
58
- * Real component.
59
- */
60
- double re;
61
-
62
- /**
63
- * Imaginary component.
64
- */
65
- double im;
66
- } stdlib_complex128_t;
67
-
68
- #endif
69
-
70
- /**
71
- * An opaque type definition for a union for accessing the real and imaginary parts of a double-precision complex floating-point number.
72
- *
73
- * @example
74
- * double real( const stdlib_complex128_t z ) {
75
- * stdlib_complex128_parts_t v;
76
- *
77
- * // Assign a double-precision complex floating-point number:
78
- * v.value = z;
79
- *
80
- * // Extract the real component:
81
- * double re = v.parts[ 0 ];
82
- *
83
- * return re;
84
- * }
85
- *
86
- * // ...
87
- *
88
- * // Create a complex number:
89
- * stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 );
90
- *
91
- * // ...
92
- *
93
- * // Access the real component:
94
- * double re = real( z );
95
- * // returns 5.0
96
- */
97
- typedef union {
98
- // An opaque type for the output value (e.g., could be a `struct` or a C99 complex number):
99
- stdlib_complex128_t value;
100
-
101
- // Leverage the fact that C99 specifies that complex numbers have the same representation and alignment as a two-element array (see <https://en.cppreference.com/w/c/language/arithmetic_types#Complex_floating_types>), where the first element is the real component and the second element is the imaginary component, thus allowing us to create a complex number irrespective of its native data type (e.g., `struct` vs `double complex`):
102
- double parts[ 2 ];
103
- } stdlib_complex128_parts_t;
104
-
105
- /**
106
- * Returns a double-precision complex floating-point number.
107
- */
108
- stdlib_complex128_t stdlib_complex128( const double real, const double imag );
109
-
110
- /**
111
- * Converts a single-precision floating-point number to a double-precision complex floating-point number.
112
- */
113
- stdlib_complex128_t stdlib_complex128_from_float32( const float real );
114
-
115
- /**
116
- * Converts a double-precision floating-point number to a double-precision complex floating-point number.
117
- */
118
- stdlib_complex128_t stdlib_complex128_from_float64( const double real );
119
-
120
- /**
121
- * Converts a single-precision complex floating-point number to a double-precision complex floating-point number.
122
- */
123
- stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z );
124
-
125
- /**
126
- * Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number.
127
- */
128
- stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z );
129
-
130
- /**
131
- * Converts a signed 8-bit integer to a double-precision complex floating-point number.
132
- */
133
- stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real );
134
-
135
- /**
136
- * Converts an unsigned 8-bit integer to a double-precision complex floating-point number.
137
- */
138
- stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real );
139
-
140
- /**
141
- * Converts a signed 16-bit integer to a double-precision complex floating-point number.
142
- */
143
- stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real );
144
-
145
- /**
146
- * Converts an unsigned 16-bit integer to a double-precision complex floating-point number.
147
- */
148
- stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real );
149
-
150
- /**
151
- * Converts a signed 32-bit integer to a double-precision complex floating-point number.
152
- */
153
- stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real );
154
-
155
- /**
156
- * Converts an unsigned 32-bit integer to a double-precision complex floating-point number.
157
- */
158
- stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real );
159
-
160
- /**
161
- * Converts a double-precision complex floating-point number to a single-precision complex floating-point number.
162
- */
163
- stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z );
164
-
165
- #ifdef __cplusplus
166
- }
167
- #endif
168
-
169
- #endif // !STDLIB_COMPLEX_FLOAT64_H
@@ -1,224 +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/float64.h"
20
- #include "stdlib/complex/float32.h"
21
- #include <stdint.h>
22
-
23
- /**
24
- * Returns a double-precision complex floating-point number.
25
- *
26
- * @param real real component
27
- * @param imag imaginary component
28
- * @return double-precision complex floating-point number
29
- *
30
- * @example
31
- * stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 );
32
- */
33
- stdlib_complex128_t stdlib_complex128( const double real, const double imag ) {
34
- stdlib_complex128_parts_t z;
35
- z.parts[ 0 ] = real;
36
- z.parts[ 1 ] = imag; // cppcheck-suppress unreadVariable
37
- return z.value;
38
- }
39
-
40
- /**
41
- * Converts a single-precision floating-point number to a double-precision complex floating-point number.
42
- *
43
- * @param real real component
44
- * @return double-precision complex floating-point number
45
- *
46
- * @example
47
- * stdlib_complex128_t z = stdlib_complex128_from_float32( 5.0f );
48
- */
49
- stdlib_complex128_t stdlib_complex128_from_float32( const float real ) {
50
- stdlib_complex128_parts_t z;
51
- z.parts[ 0 ] = (double)real;
52
- z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable
53
- return z.value;
54
- }
55
-
56
- /**
57
- * Converts a double-precision floating-point number to a double-precision complex floating-point number.
58
- *
59
- * @param real real component
60
- * @return double-precision complex floating-point number
61
- *
62
- * @example
63
- * stdlib_complex128_t z = stdlib_complex128_from_float64( 5.0 );
64
- */
65
- stdlib_complex128_t stdlib_complex128_from_float64( const double real ) {
66
- stdlib_complex128_parts_t z;
67
- z.parts[ 0 ] = real;
68
- z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable
69
- return z.value;
70
- }
71
-
72
- /**
73
- * Converts a single-precision complex floating-point number to a double-precision complex floating-point number.
74
- *
75
- * @param z single-precision complex floating-point number
76
- * @return double-precision complex floating-point number
77
- *
78
- * @example
79
- * #include "stdlib/complex/float32.h"
80
- *
81
- * stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f );
82
- * stdlib_complex128_t z2 = stdlib_complex128_from_complex64( z1 );
83
- */
84
- stdlib_complex128_t stdlib_complex128_from_complex64( const stdlib_complex64_t z ) {
85
- stdlib_complex64_parts_t v1 = { z };
86
- stdlib_complex128_parts_t v2;
87
- v2.parts[ 0 ] = (double)v1.parts[ 0 ];
88
- v2.parts[ 1 ] = (double)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable
89
- return v2.value;
90
- }
91
-
92
- /**
93
- * Converts (copies) a double-precision complex floating-point number to a double-precision complex floating-point number.
94
- *
95
- * @param z double-precision complex floating-point number
96
- * @return double-precision complex floating-point number
97
- *
98
- * @example
99
- * stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 );
100
- * stdlib_complex128_t z2 = stdlib_complex128_from_complex128( z1 );
101
- */
102
- stdlib_complex128_t stdlib_complex128_from_complex128( const stdlib_complex128_t z ) {
103
- stdlib_complex128_parts_t v1 = { z };
104
- stdlib_complex128_parts_t v2;
105
- v2.parts[ 0 ] = v1.parts[ 0 ];
106
- v2.parts[ 1 ] = v1.parts[ 1 ]; // cppcheck-suppress unreadVariable
107
- return v2.value;
108
- }
109
-
110
- /**
111
- * Converts a signed 8-bit integer to a double-precision complex floating-point number.
112
- *
113
- * @param real real component
114
- * @return double-precision complex floating-point number
115
- *
116
- * @example
117
- * stdlib_complex128_t z = stdlib_complex128_from_int8( 5 );
118
- */
119
- stdlib_complex128_t stdlib_complex128_from_int8( const int8_t real ) {
120
- stdlib_complex128_parts_t z;
121
- z.parts[ 0 ] = (double)real;
122
- z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable
123
- return z.value;
124
- }
125
-
126
- /**
127
- * Converts an unsigned 8-bit integer to a double-precision complex floating-point number.
128
- *
129
- * @param real real component
130
- * @return double-precision complex floating-point number
131
- *
132
- * @example
133
- * stdlib_complex128_t z = stdlib_complex128_from_uint8( 5 );
134
- */
135
- stdlib_complex128_t stdlib_complex128_from_uint8( const uint8_t real ) {
136
- stdlib_complex128_parts_t z;
137
- z.parts[ 0 ] = (double)real;
138
- z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable
139
- return z.value;
140
- }
141
-
142
- /**
143
- * Converts a signed 16-bit integer to a double-precision complex floating-point number.
144
- *
145
- * @param real real component
146
- * @return double-precision complex floating-point number
147
- *
148
- * @example
149
- * stdlib_complex128_t z = stdlib_complex128_from_int16( 5 );
150
- */
151
- stdlib_complex128_t stdlib_complex128_from_int16( const int16_t real ) {
152
- stdlib_complex128_parts_t z;
153
- z.parts[ 0 ] = (double)real;
154
- z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable
155
- return z.value;
156
- }
157
-
158
- /**
159
- * Converts an unsigned 16-bit integer to a double-precision complex floating-point number.
160
- *
161
- * @param real real component
162
- * @return double-precision complex floating-point number
163
- *
164
- * @example
165
- * stdlib_complex128_t z = stdlib_complex128_from_uint16( 5 );
166
- */
167
- stdlib_complex128_t stdlib_complex128_from_uint16( const uint16_t real ) {
168
- stdlib_complex128_parts_t z;
169
- z.parts[ 0 ] = (double)real;
170
- z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable
171
- return z.value;
172
- }
173
-
174
- /**
175
- * Converts a signed 32-bit integer to a double-precision complex floating-point number.
176
- *
177
- * @param real real component
178
- * @return double-precision complex floating-point number
179
- *
180
- * @example
181
- * stdlib_complex128_t z = stdlib_complex128_from_int32( 5 );
182
- */
183
- stdlib_complex128_t stdlib_complex128_from_int32( const int32_t real ) {
184
- stdlib_complex128_parts_t z;
185
- z.parts[ 0 ] = (double)real;
186
- z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable
187
- return z.value;
188
- }
189
-
190
- /**
191
- * Converts an unsigned 32-bit integer to a double-precision complex floating-point number.
192
- *
193
- * @param real real component
194
- * @return double-precision complex floating-point number
195
- *
196
- * @example
197
- * stdlib_complex128_t z = stdlib_complex128_from_uint32( 5 );
198
- */
199
- stdlib_complex128_t stdlib_complex128_from_uint32( const uint32_t real ) {
200
- stdlib_complex128_parts_t z;
201
- z.parts[ 0 ] = (double)real;
202
- z.parts[ 1 ] = 0.0; // cppcheck-suppress unreadVariable
203
- return z.value;
204
- }
205
-
206
- /**
207
- * Converts a double-precision complex floating-point number to a single-precision complex floating-point number.
208
- *
209
- * @param z double-precision complex floating-point number
210
- * @return single-precision complex floating-point number
211
- *
212
- * @example
213
- * #include "stdlib/complex/float32.h"
214
- *
215
- * stdlib_complex128_t z1 = stdlib_complex128( 5.0, 3.0 );
216
- * stdlib_complex64_t z2 = stdlib_complex128_to_complex64( z1 );
217
- */
218
- stdlib_complex64_t stdlib_complex128_to_complex64( const stdlib_complex128_t z ) {
219
- stdlib_complex128_parts_t v1 = { z };
220
- stdlib_complex64_parts_t v2;
221
- v2.parts[ 0 ] = (float)v1.parts[ 0 ];
222
- v2.parts[ 1 ] = (float)v1.parts[ 1 ]; // cppcheck-suppress unreadVariable
223
- return v2.value;
224
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * @license Apache-2.0
3
- *
4
- * Copyright (c) 2022 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
- #ifndef STDLIB_CONSTANTS_FLOAT64_PINF_H
20
- #define STDLIB_CONSTANTS_FLOAT64_PINF_H
21
-
22
- #include <math.h>
23
-
24
- /**
25
- * Macro for double-precision floating-point positive infinity.
26
- */
27
- #define STDLIB_CONSTANT_FLOAT64_PINF HUGE_VAL
28
-
29
- #endif // !STDLIB_CONSTANTS_FLOAT64_PINF_H