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