|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2025 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 | +# add3 |
| 22 | + |
| 23 | +> Compute the sum of three double-precision complex floating-point numbers. |
| 24 | +
|
| 25 | +<section class="intro"> |
| 26 | + |
| 27 | +</section> |
| 28 | + |
| 29 | +<!-- /.intro --> |
| 30 | + |
| 31 | +<section class="usage"> |
| 32 | + |
| 33 | +## Usage |
| 34 | + |
| 35 | +```javascript |
| 36 | +var add3 = require( '@stdlib/complex/float64/base/add3' ); |
| 37 | +``` |
| 38 | + |
| 39 | +#### add3( z1, z2, z3 ) |
| 40 | + |
| 41 | +Computes the sum of three double-precision complex floating-point numbers. |
| 42 | + |
| 43 | +```javascript |
| 44 | +var Complex128 = require( '@stdlib/complex/float64/ctor' ); |
| 45 | + |
| 46 | +var z = new Complex128( -1.5, 2.5 ); |
| 47 | + |
| 48 | +var v = add3( z, z, z ); |
| 49 | +// returns <Complex128>[ -4.5, 7.5 ] |
| 50 | +``` |
| 51 | + |
| 52 | +The function supports the following parameters: |
| 53 | + |
| 54 | +- **z1**: first complex number. |
| 55 | +- **z2**: second complex number. |
| 56 | +- **z3**: third complex number. |
| 57 | + |
| 58 | +#### add3.assign( re1, im1, re2, im2, re3, im3, out, strideOut, offsetOut ) |
| 59 | + |
| 60 | +Computes the sum of three double-precision complex floating-point numbers and assigns results to a provided output array. |
| 61 | + |
| 62 | +```javascript |
| 63 | +var Float64Array = require( '@stdlib/array/float64' ); |
| 64 | + |
| 65 | +var out = new Float64Array( 2 ); |
| 66 | +var v = add3.assign( 5.0, 3.0, -2.0, 1.0, 5.0, 3.0, out, 1, 0 ); |
| 67 | +// returns <Float64Array>[ 8.0, 7.0 ] |
| 68 | + |
| 69 | +var bool = ( out === v ); |
| 70 | +// returns true |
| 71 | +``` |
| 72 | + |
| 73 | +The function supports the following parameters: |
| 74 | + |
| 75 | +- **re1**: real component of the first complex number. |
| 76 | +- **im1**: imaginary component of the first complex number. |
| 77 | +- **re2**: real component of the second complex number. |
| 78 | +- **im2**: imaginary component of the second complex number. |
| 79 | +- **re3**: real component of the third complex number. |
| 80 | +- **im3**: imaginary component of the third complex number. |
| 81 | +- **out**: output array. |
| 82 | +- **strideOut**: stride length for `out`. |
| 83 | +- **offsetOut**: starting index for `out`. |
| 84 | + |
| 85 | +#### add3.strided( z1, sz1, oz1, z2, sz2, oz2, z3, sz3, oz3, out, so, oo ) |
| 86 | + |
| 87 | +Computes the sum of three double-precision complex floating-point numbers stored in real-valued strided array views and assigns results to a provided strided output array. |
| 88 | + |
| 89 | +```javascript |
| 90 | +var Float64Array = require( '@stdlib/array/float64' ); |
| 91 | + |
| 92 | +var z1 = new Float64Array( [ 5.0, 3.0 ] ); |
| 93 | +var z2 = new Float64Array( [ -2.0, 1.0 ] ); |
| 94 | +var z3 = new Float64Array( [ 5.0, 3.0 ] ); |
| 95 | +var out = new Float64Array( 2 ); |
| 96 | + |
| 97 | +var v = add3.strided( z1, 1, 0, z2, 1, 0, z3, 1, 0, out, 1, 0 ); |
| 98 | +// returns <Float64Array>[ 8.0, 7.0 ] |
| 99 | + |
| 100 | +var bool = ( out === v ); |
| 101 | +// returns true |
| 102 | +``` |
| 103 | + |
| 104 | +The function supports the following parameters: |
| 105 | + |
| 106 | +- **z1**: first complex number strided array view. |
| 107 | +- **sz1**: stride length for `z1`. |
| 108 | +- **oz1**: starting index for `z1`. |
| 109 | +- **z2**: second complex number strided array view. |
| 110 | +- **sz2**: stride length for `z2`. |
| 111 | +- **oz2**: starting index for `z2`. |
| 112 | +- **z3**: third complex number strided array view. |
| 113 | +- **sz3**: stride length for `z3`. |
| 114 | +- **oz3**: starting index for `z3`. |
| 115 | +- **out**: output array. |
| 116 | +- **so**: stride length for `out`. |
| 117 | +- **oo**: starting index for `out`. |
| 118 | + |
| 119 | +</section> |
| 120 | + |
| 121 | +<!-- /.usage --> |
| 122 | + |
| 123 | +<section class="examples"> |
| 124 | + |
| 125 | +## Examples |
| 126 | + |
| 127 | +<!-- eslint no-undef: "error" --> |
| 128 | + |
| 129 | +```javascript |
| 130 | +var Complex128Array = require( '@stdlib/array/complex128' ); |
| 131 | +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); |
| 132 | +var logEachMap = require( '@stdlib/console/log-each-map' ); |
| 133 | +var add3 = require( '@stdlib/complex/float64/base/add3' ); |
| 134 | + |
| 135 | +// Generate arrays of random values: |
| 136 | +var z1 = new Complex128Array( discreteUniform( 200, -50, 50 ) ); |
| 137 | +var z2 = new Complex128Array( discreteUniform( 200, -50, 50 ) ); |
| 138 | +var z3 = new Complex128Array( discreteUniform( 200, -50, 50 ) ); |
| 139 | + |
| 140 | +// Perform element-wise addition: |
| 141 | +logEachMap( '(%s) + (%s) + (%s) = %s', z1, z2, z3, add3 ); |
| 142 | +``` |
| 143 | + |
| 144 | +</section> |
| 145 | + |
| 146 | +<!-- /.examples --> |
| 147 | + |
| 148 | +<!-- C interface documentation. --> |
| 149 | + |
| 150 | +* * * |
| 151 | + |
| 152 | +<section class="c"> |
| 153 | + |
| 154 | +## C APIs |
| 155 | + |
| 156 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 157 | + |
| 158 | +<section class="intro"> |
| 159 | + |
| 160 | +</section> |
| 161 | + |
| 162 | +<!-- /.intro --> |
| 163 | + |
| 164 | +<!-- C usage documentation. --> |
| 165 | + |
| 166 | +<section class="usage"> |
| 167 | + |
| 168 | +### Usage |
| 169 | + |
| 170 | +```c |
| 171 | +#include "stdlib/complex/float64/base/add3.h" |
| 172 | +``` |
| 173 | + |
| 174 | +#### stdlib_base_complex128_add3( z1, z2, z3 ) |
| 175 | + |
| 176 | +Computes the sum of three double-precision complex floating-point numbers. |
| 177 | + |
| 178 | +```c |
| 179 | +#include "stdlib/complex/float64/ctor.h" |
| 180 | +#include "stdlib/complex/float64/real.h" |
| 181 | +#include "stdlib/complex/float64/imag.h" |
| 182 | + |
| 183 | +stdlib_complex128_t z = stdlib_complex128( 3.0, -2.0 ); |
| 184 | + |
| 185 | +stdlib_complex128_t out = stdlib_base_complex128_add3( z, z, z ); |
| 186 | + |
| 187 | +double re = stdlib_complex128_real( out ); |
| 188 | +// returns 9.0 |
| 189 | + |
| 190 | +double im = stdlib_complex128_imag( out ); |
| 191 | +// returns -6.0 |
| 192 | +``` |
| 193 | + |
| 194 | +The function accepts the following arguments: |
| 195 | + |
| 196 | +- **z1**: `[in] stdlib_complex128_t` first input value. |
| 197 | +- **z2**: `[in] stdlib_complex128_t` second input value. |
| 198 | +- **z3**: `[in] stdlib_complex128_t` third input value. |
| 199 | + |
| 200 | +```c |
| 201 | +stdlib_complex128_t stdlib_base_complex128_add3( const stdlib_complex128_t z1, const stdlib_complex128_t z2, const stdlib_complex128_t z3 ); |
| 202 | +``` |
| 203 | +
|
| 204 | +</section> |
| 205 | +
|
| 206 | +<!-- /.usage --> |
| 207 | +
|
| 208 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 209 | +
|
| 210 | +<section class="notes"> |
| 211 | +
|
| 212 | +</section> |
| 213 | +
|
| 214 | +<!-- /.notes --> |
| 215 | +
|
| 216 | +<!-- C API usage examples. --> |
| 217 | +
|
| 218 | +<section class="examples"> |
| 219 | +
|
| 220 | +### Examples |
| 221 | +
|
| 222 | +```c |
| 223 | +#include "stdlib/complex/float64/base/add3.h" |
| 224 | +#include "stdlib/complex/float64/ctor.h" |
| 225 | +#include "stdlib/complex/float64/reim.h" |
| 226 | +#include <stdio.h> |
| 227 | +
|
| 228 | +int main( void ) { |
| 229 | + const stdlib_complex128_t x[] = { |
| 230 | + stdlib_complex128( 3.14, 1.5 ), |
| 231 | + stdlib_complex128( -3.14, 1.5 ), |
| 232 | + stdlib_complex128( 0.0, -0.0 ), |
| 233 | + stdlib_complex128( 0.0/0.0, 0.0/0.0 ) |
| 234 | + }; |
| 235 | +
|
| 236 | + stdlib_complex128_t v; |
| 237 | + stdlib_complex128_t y; |
| 238 | + double re; |
| 239 | + double im; |
| 240 | + int i; |
| 241 | + for ( i = 0; i < 4; i++ ) { |
| 242 | + v = x[ i ]; |
| 243 | + stdlib_complex128_reim( v, &re, &im ); |
| 244 | + printf( "z = %lf + %lfi\n", re, im ); |
| 245 | +
|
| 246 | + y = stdlib_base_complex128_add3( v, v, v ); |
| 247 | + stdlib_complex128_reim( y, &re, &im ); |
| 248 | + printf( "add3(z, z, z) = %lf + %lfi\n", re, im ); |
| 249 | + } |
| 250 | +} |
| 251 | +``` |
| 252 | + |
| 253 | +</section> |
| 254 | + |
| 255 | +<!-- /.examples --> |
| 256 | + |
| 257 | +</section> |
| 258 | + |
| 259 | +<!-- /.c --> |
| 260 | + |
| 261 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 262 | + |
| 263 | +<section class="related"> |
| 264 | + |
| 265 | +</section> |
| 266 | + |
| 267 | +<!-- /.related --> |
| 268 | + |
| 269 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 270 | + |
| 271 | +<section class="links"> |
| 272 | + |
| 273 | +</section> |
| 274 | + |
| 275 | +<!-- /.links --> |
0 commit comments