|
| 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 | +# zlacpy |
| 22 | + |
| 23 | +> Copy all or part of a matrix `A` to another matrix `B`. |
| 24 | +
|
| 25 | +<section class="usage"> |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +```javascript |
| 30 | +var zlacpy = require( '@stdlib/lapack/base/zlacpy' ); |
| 31 | +``` |
| 32 | + |
| 33 | +#### zlacpy( order, uplo, M, N, A, LDA, B, LDB ) |
| 34 | + |
| 35 | +Copies all or part of a matrix `A` to another matrix `B`. |
| 36 | + |
| 37 | +```javascript |
| 38 | +var Complex128Array = require( '@stdlib/array/complex128' ); |
| 39 | + |
| 40 | +var A = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); |
| 41 | +var B = new Complex128Array( 4 ); |
| 42 | + |
| 43 | +zlacpy( 'row-major', 'all', 2, 2, A, 2, B, 2 ); |
| 44 | +// B => <Complex128Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] |
| 45 | +``` |
| 46 | + |
| 47 | +The function has the following parameters: |
| 48 | + |
| 49 | +- **order**: storage layout. |
| 50 | +- **uplo**: specifies whether to copy the upper or lower triangular/trapezoidal part of a matrix `A`. |
| 51 | +- **M**: number of rows in `A`. |
| 52 | +- **N**: number of columns in `A`. |
| 53 | +- **A**: input [`Complex128Array`][@stdlib/array/complex128]. |
| 54 | +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). |
| 55 | +- **B**: output [`Complex128Array`][@stdlib/array/complex128]. |
| 56 | +- **LDB**: stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`). |
| 57 | + |
| 58 | +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. |
| 59 | + |
| 60 | +<!-- eslint-disable stdlib/capitalized-comments --> |
| 61 | + |
| 62 | +```javascript |
| 63 | +var Complex128Array = require( '@stdlib/array/complex128' ); |
| 64 | + |
| 65 | +// Initial arrays... |
| 66 | +var A0 = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); |
| 67 | +var B0 = new Complex128Array( 5 ); |
| 68 | + |
| 69 | +// Create offset views... |
| 70 | +var A1 = new Complex128Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element |
| 71 | +var B1 = new Complex128Array( B0.buffer, B0.BYTES_PER_ELEMENT*1 ); // start at 2nd element |
| 72 | + |
| 73 | +zlacpy( 'row-major', 'all', 2, 2, A1, 2, B1, 2 ); |
| 74 | +// B0 => <Complex128Array>[ 0.0, 2.0, 3.0, 4.0, 5.0 ] |
| 75 | +``` |
| 76 | + |
| 77 | +#### zlacpy.ndarray( uplo, M, N, A, sa1, sa2, oa, B, sb1, sb2, ob ) |
| 78 | + |
| 79 | +Copies all or part of a matrix `A` to another matrix `B` using alternative indexing semantics. |
| 80 | + |
| 81 | +```javascript |
| 82 | +var Complex128Array = require( '@stdlib/array/complex128' ); |
| 83 | + |
| 84 | +var A = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); |
| 85 | +var B = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0 ] ); |
| 86 | + |
| 87 | +zlacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); |
| 88 | +// B => <Complex128Array>[ 1.0, 2.0, 3.0, 4.0 ] |
| 89 | +``` |
| 90 | + |
| 91 | +The function has the following parameters: |
| 92 | + |
| 93 | +- **uplo**: specifies whether to copy the upper or lower triangular/trapezoidal part of a matrix `A`. |
| 94 | +- **M**: number of rows in `A`. |
| 95 | +- **N**: number of columns in `A`. |
| 96 | +- **A**: input [`Complex128Array`][@stdlib/array/complex128]. |
| 97 | +- **sa1**: stride of the first dimension of `A`. |
| 98 | +- **sa2**: stride of the second dimension of `A`. |
| 99 | +- **oa**: starting index for `A`. |
| 100 | +- **B**: output [`Complex128Array`][@stdlib/array/complex128]. |
| 101 | +- **sb1**: stride of the first dimension of `B`. |
| 102 | +- **sb2**: stride of the second dimension of `B`. |
| 103 | +- **ob**: starting index for `B`. |
| 104 | + |
| 105 | +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, |
| 106 | + |
| 107 | +```javascript |
| 108 | +var Complex128Array = require( '@stdlib/array/complex128' ); |
| 109 | + |
| 110 | +var A = new Complex128Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); |
| 111 | +var B = new Complex128Array( [ 0.0, 0.0, 11.0, 312.0, 53.0, 412.0 ] ); |
| 112 | + |
| 113 | +zlacpy.ndarray( 'all', 2, 2, A, 2, 1, 1, B, 2, 1, 2 ); |
| 114 | +// B => <Complex128Array>[ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] |
| 115 | +``` |
| 116 | + |
| 117 | +</section> |
| 118 | + |
| 119 | +<!-- /.usage --> |
| 120 | + |
| 121 | +<section class="notes"> |
| 122 | + |
| 123 | +## Notes |
| 124 | + |
| 125 | +- `zlacpy()` corresponds to the [LAPACK][lapack] routine [`zlacpy`][lapack-zlacpy]. |
| 126 | + |
| 127 | +</section> |
| 128 | + |
| 129 | +<!-- /.notes --> |
| 130 | + |
| 131 | +<section class="examples"> |
| 132 | + |
| 133 | +## Examples |
| 134 | + |
| 135 | +<!-- eslint no-undef: "error" --> |
| 136 | + |
| 137 | +```javascript |
| 138 | +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); |
| 139 | +var uniform = require( '@stdlib/random/array/discrete-uniform' ); |
| 140 | +var numel = require( '@stdlib/ndarray/base/numel' ); |
| 141 | +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); |
| 142 | +var zlacpy = require( '@stdlib/lapack/base/zlacpy' ); |
| 143 | + |
| 144 | +var shape = [ 5, 8 ]; |
| 145 | +var order = 'row-major'; |
| 146 | +var strides = shape2strides( shape, order ); |
| 147 | + |
| 148 | +var N = numel( shape ); |
| 149 | + |
| 150 | +var A = uniform( N, -10, 10, { |
| 151 | + 'dtype': 'complex128' |
| 152 | +}); |
| 153 | +console.log( ndarray2array( A, shape, strides, 0, order ) ); |
| 154 | + |
| 155 | +var B = uniform( N, -10, 10, { |
| 156 | + 'dtype': 'complex128' |
| 157 | +}); |
| 158 | +console.log( ndarray2array( B, shape, strides, 0, order ) ); |
| 159 | + |
| 160 | +zlacpy( order, 'all', shape[ 0 ], shape[ 1 ], A, strides[ 0 ], B, strides[ 0 ] ); |
| 161 | +console.log( ndarray2array( B, shape, strides, 0, order ) ); |
| 162 | +``` |
| 163 | + |
| 164 | +</section> |
| 165 | + |
| 166 | +<!-- /.examples --> |
| 167 | + |
| 168 | +<!-- C interface documentation. --> |
| 169 | + |
| 170 | +* * * |
| 171 | + |
| 172 | +<section class="c"> |
| 173 | + |
| 174 | +## C APIs |
| 175 | + |
| 176 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 177 | + |
| 178 | +<section class="intro"> |
| 179 | + |
| 180 | +</section> |
| 181 | + |
| 182 | +<!-- /.intro --> |
| 183 | + |
| 184 | +<!-- C usage documentation. --> |
| 185 | + |
| 186 | +<section class="usage"> |
| 187 | + |
| 188 | +### Usage |
| 189 | + |
| 190 | +```c |
| 191 | +TODO |
| 192 | +``` |
| 193 | + |
| 194 | +#### TODO |
| 195 | + |
| 196 | +TODO. |
| 197 | + |
| 198 | +```c |
| 199 | +TODO |
| 200 | +``` |
| 201 | + |
| 202 | +TODO |
| 203 | + |
| 204 | +```c |
| 205 | +TODO |
| 206 | +``` |
| 207 | + |
| 208 | +</section> |
| 209 | + |
| 210 | +<!-- /.usage --> |
| 211 | + |
| 212 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 213 | + |
| 214 | +<section class="notes"> |
| 215 | + |
| 216 | +</section> |
| 217 | + |
| 218 | +<!-- /.notes --> |
| 219 | + |
| 220 | +<!-- C API usage examples. --> |
| 221 | + |
| 222 | +<section class="examples"> |
| 223 | + |
| 224 | +### Examples |
| 225 | + |
| 226 | +```c |
| 227 | +TODO |
| 228 | +``` |
| 229 | + |
| 230 | +</section> |
| 231 | + |
| 232 | +<!-- /.examples --> |
| 233 | + |
| 234 | +</section> |
| 235 | + |
| 236 | +<!-- /.c --> |
| 237 | + |
| 238 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 239 | + |
| 240 | +<section class="related"> |
| 241 | + |
| 242 | +</section> |
| 243 | + |
| 244 | +<!-- /.related --> |
| 245 | + |
| 246 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 247 | + |
| 248 | +<section class="links"> |
| 249 | + |
| 250 | +[lapack]: https://www.netlib.org/lapack/explore-html/ |
| 251 | + |
| 252 | +[lapack-zlacpy]: https://netlib.org/lapack/explore-html/d0/d9e/group__lacpy_ga243f0a47458b9a525136a69146c10192.html#ga243f0a47458b9a525136a69146c10192 |
| 253 | + |
| 254 | +[@stdlib/array/complex128]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/complex128 |
| 255 | + |
| 256 | +[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray |
| 257 | + |
| 258 | +</section> |
| 259 | + |
| 260 | +<!-- /.links --> |
0 commit comments