|
| 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 | +# scabs1 |
| 22 | + |
| 23 | +> Compute the sum of the [absolute values][absolute-value] of the real and imaginary components of a single-precision [complex][@stdlib/complex/float32/ctor] floating-point number. |
| 24 | +
|
| 25 | +<section class="usage"> |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +```javascript |
| 30 | +var scabs1 = require( '@stdlib/blas/base/scabs1' ); |
| 31 | +``` |
| 32 | + |
| 33 | +#### scabs1( z ) |
| 34 | + |
| 35 | +Computes the sum of the [absolute values][absolute-value] of the real and imaginary components of a single-precision [complex][@stdlib/complex/float32/ctor] floating-point number. |
| 36 | + |
| 37 | +```javascript |
| 38 | +var Complex64 = require( '@stdlib/complex/float32/ctor' ); |
| 39 | + |
| 40 | +var y = scabs1( new Complex64( 5.0, -3.0 ) ); |
| 41 | +// returns 8.0 |
| 42 | +``` |
| 43 | + |
| 44 | +</section> |
| 45 | + |
| 46 | +<!-- /.usage --> |
| 47 | + |
| 48 | +<section class="examples"> |
| 49 | + |
| 50 | +## Examples |
| 51 | + |
| 52 | +<!-- eslint no-undef: "error" --> |
| 53 | + |
| 54 | +```javascript |
| 55 | +var Complex64 = require( '@stdlib/complex/float32/ctor' ); |
| 56 | +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); |
| 57 | +var scabs1 = require( '@stdlib/blas/base/scabs1' ); |
| 58 | + |
| 59 | +var c; |
| 60 | +var i; |
| 61 | +for ( i = 0; i < 100; i++ ) { |
| 62 | + c = new Complex64( discreteUniform( -50, 50 ), discreteUniform( -50, 50 ) ); |
| 63 | + console.log( 'scabs1(%s) = %d', c.toString(), scabs1( c ) ); |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | +</section> |
| 68 | + |
| 69 | +<!-- /.examples --> |
| 70 | + |
| 71 | +<!-- C interface documentation. --> |
| 72 | + |
| 73 | +* * * |
| 74 | + |
| 75 | +<section class="c"> |
| 76 | + |
| 77 | +## C APIs |
| 78 | + |
| 79 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 80 | + |
| 81 | +<section class="intro"> |
| 82 | + |
| 83 | +</section> |
| 84 | + |
| 85 | +<!-- /.intro --> |
| 86 | + |
| 87 | +<!-- C usage documentation. --> |
| 88 | + |
| 89 | +<section class="usage"> |
| 90 | + |
| 91 | +### Usage |
| 92 | + |
| 93 | +```c |
| 94 | +#include "stdlib/blas/base/scabs1.h" |
| 95 | +``` |
| 96 | + |
| 97 | +#### c_scabs1( c ) |
| 98 | + |
| 99 | +Computes the sum of the [absolute values][absolute-value] of the real and imaginary components of a single-precision [complex][@stdlib/complex/float32/ctor] floating-point number. |
| 100 | + |
| 101 | +```c |
| 102 | +#include "stdlib/complex/float32/ctor.h" |
| 103 | + |
| 104 | +const stdlib_complex64_t c = stdlib_complex64( 5.0f, -3.0f ); |
| 105 | + |
| 106 | +float y = c_scabs1( c ); |
| 107 | +// returns 8.0f |
| 108 | +``` |
| 109 | + |
| 110 | +The function accepts the following arguments: |
| 111 | + |
| 112 | +- **c**: `[in] stdlib_complex64_t` complex number. |
| 113 | + |
| 114 | +```c |
| 115 | +float c_scabs1( const stdlib_complex64_t c ); |
| 116 | +``` |
| 117 | +
|
| 118 | +</section> |
| 119 | +
|
| 120 | +<!-- /.usage --> |
| 121 | +
|
| 122 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 123 | +
|
| 124 | +<section class="notes"> |
| 125 | +
|
| 126 | +</section> |
| 127 | +
|
| 128 | +<!-- /.notes --> |
| 129 | +
|
| 130 | +<!-- C API usage examples. --> |
| 131 | +
|
| 132 | +<section class="examples"> |
| 133 | +
|
| 134 | +### Examples |
| 135 | +
|
| 136 | +```c |
| 137 | +#include "stdlib/blas/base/scabs1.h" |
| 138 | +#include "stdlib/complex/float32/ctor.h" |
| 139 | +#include "stdlib/complex/realf.h" |
| 140 | +#include "stdlib/complex/imagf.h" |
| 141 | +#include <stdio.h> |
| 142 | +
|
| 143 | +int main( void ) { |
| 144 | + const stdlib_complex64_t x[] = { |
| 145 | + stdlib_complex64( 3.14f, 1.0f ), |
| 146 | + stdlib_complex64( -3.14f, -1.0f ), |
| 147 | + stdlib_complex64( 0.0f, 0.0f ), |
| 148 | + stdlib_complex64( 0.0f/0.0f, 0.0f/0.0f ) |
| 149 | + }; |
| 150 | +
|
| 151 | + float y; |
| 152 | + int i; |
| 153 | + for ( i = 0; i < 4; i++ ) { |
| 154 | + y = c_scabs1( x[ i ] ); |
| 155 | + printf( "f(%f + %f) = %f\n", stdlib_realf( x[ i ] ), stdlib_imagf( x[ i ] ), y ); |
| 156 | + } |
| 157 | +} |
| 158 | +``` |
| 159 | + |
| 160 | +</section> |
| 161 | + |
| 162 | +<!-- /.examples --> |
| 163 | + |
| 164 | +</section> |
| 165 | + |
| 166 | +<!-- /.c --> |
| 167 | + |
| 168 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 169 | + |
| 170 | +<section class="related"> |
| 171 | + |
| 172 | +</section> |
| 173 | + |
| 174 | +<!-- /.related --> |
| 175 | + |
| 176 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 177 | + |
| 178 | +<section class="links"> |
| 179 | + |
| 180 | +[absolute-value]: https://en.wikipedia.org/wiki/Absolute_value |
| 181 | + |
| 182 | +[@stdlib/complex/float32/ctor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float32/ctor |
| 183 | + |
| 184 | +</section> |
| 185 | + |
| 186 | +<!-- /.links --> |
0 commit comments